<commit_before><?php

/*
 * This file is part of the xAPI package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Xabbuh\XApi\Storage\Doctrine\Manager;

use Xabbuh\XApi\Model\Statement;
use Xabbuh\XApi\Model\StatementsFilter;
use Xabbuh\XApi\Storage\Api\Exception\NotFoundException;
use Xabbuh\XApi\Storage\Api\StatementManagerInterface;
use Xabbuh\XApi\Storage\Doctrine\Repository\StatementRepositoryInterface;

/**
 * Doctrine based {@link Statement} manager.
 *
 * @author <NAME> <<EMAIL>>
 */
class StatementManager implements StatementManagerInterface
{
    /**
     * @var StatementRepositoryInterface The statement repository
     */
    private $repository;

    public function __construct(StatementRepositoryInterface $repository)
    {
        $this->repository = $repository;
    }

    /**
     * {@inheritDoc}
     */
    public function findStatementById($statementId)
    {
        /** @var Statement $statement */
        $statement = $this->repository->findOneBy(array('id' => $statementId));

        if (null === $statement) {
            throw new NotFoundException();
        }

        return $statement;
    }

    /**
     * {@inheritDoc}
     */
    public function findVoidedStatementById($statementId)
    {
        /** @var Statement $statement */
        $statement = $this->repository->findOneBy(array('id' => $statementId));

        if (null === $statement) {
            throw new NotFoundException();
        }

        return $statement;
    }

    /**
     * {@inheritDoc}
     */
    public function findStatementsBy(StatementsFilter $filter)
    {
        return $this->repository->findBy($filter->getFilter());
    }

    /**
     * {@inheritDoc}
     */
    public function save(Statement $statement, $flush = true)
    {
        $this->repository->save($statement, $flush);
    }
}<commit_msg>check the returned Statement type<commit_after><?php

/*
 * This file is part of the xAPI package.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Xabbuh\XApi\Storage\Doctrine\Manager;

use Xabbuh\XApi\Model\Statement;
use Xabbuh\XApi\Model\StatementsFilter;
use Xabbuh\XApi\Storage\Api\Exception\NotFoundException;
use Xabbuh\XApi\Storage\Api\StatementManagerInterface;
use Xabbuh\XApi\Storage\Doctrine\Repository\StatementRepositoryInterface;

/**
 * Doctrine based {@link Statement} manager.
 *
 * @author <NAME> <<EMAIL>>
 */
class StatementManager implements StatementManagerInterface
{
    /**
     * @var StatementRepositoryInterface The statement repository
     */
    private $repository;

    public function __construct(StatementRepositoryInterface $repository)
    {
        $this->repository = $repository;
    }

    /**
     * {@inheritDoc}
     */
    public function findStatementById($statementId)
    {
        /** @var Statement $statement */
        $statement = $this->repository->findOneBy(array('id' => $statementId));

        if (null === $statement || $statement->isVoidStatement()) {
            throw new NotFoundException();
        }

        return $statement;
    }

    /**
     * {@inheritDoc}
     */
    public function findVoidedStatementById($statementId)
    {
        /** @var Statement $statement */
        $statement = $this->repository->findOneBy(array('id' => $statementId));

        if (null === $statement || !$statement->isVoidStatement()) {
            throw new NotFoundException();
        }

        return $statement;
    }

    /**
     * {@inheritDoc}
     */
    public function findStatementsBy(StatementsFilter $filter)
    {
        return $this->repository->findBy($filter->getFilter());
    }

    /**
     * {@inheritDoc}
     */
    public function save(Statement $statement, $flush = true)
    {
        $this->repository->save($statement, $flush);
    }
}
{'fraction_non_alphanumeric': 0.13052158722236087, 'fraction_numerical': 0.0, 'mean_word_length': 2.8427612655800574, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7631189', 'n_tokens_mistral': 1128, 'n_tokens_neox': 1102, 'n_words': 246}