<commit_before><?php
declare(strict_types=1);

namespace Moka\Strategy;

use Moka\Exception\MockNotCreatedException;
use Moka\Strategy\Prophecy\NoPriorityToken;
use Moka\Stub\Stub;
use Moka\Stub\StubSet;
use Prophecy\Exception\Prophecy\ObjectProphecyException;
use Prophecy\Prophecy\ObjectProphecy;
use Prophecy\Prophet;

/**
 * Class ProphecyMockingStrategy
 * @package Moka\Strategy
 */
class ProphecyMockingStrategy extends AbstractMockingStrategy
{
    /**
     * @var Prophet
     */
    private $prophet;

    /**
     * PHPUnitMockingStrategy constructor.
     */
    public function __construct()
    {
        $this->prophet = new Prophet();
        $this->setMockType(ObjectProphecy::class);
    }

    /**
     * @param string $fqcn
     * @return ObjectProphecy
     */
    protected function doBuild(string $fqcn)
    {
        return $this->prophet->prophesize($fqcn);
    }

    /**
     * @param ObjectProphecy $mock
     * @param StubSet $stubs
     * @return void
     */
    protected function doDecorate($mock, StubSet $stubs)
    {
        /** @var Stub $stub */
        foreach ($stubs as $stub) {
            $methodValue = $stub->getMethodValue();

            $partial = $mock->{$stub->getMethodName()}(new NoPriorityToken());
            $methodValue instanceof \Throwable
                ? $partial->willThrow($methodValue)
                : $partial->willReturn($methodValue);
        }
    }

    /**
     * @param object $mock
     * @return mixed
     *
     * @throws MockNotCreatedException
     */
    protected function doGet($mock)
    {
        try {
            return $mock->reveal();
        } catch (ObjectProphecyException $exception) {
            throw new MockNotCreatedException(
                sprintf(
                    'Cannot create mock object: %s',
                    $exception->getMessage()
                )
            );
        }<commit_msg>Document variable type<commit_after><?php
declare(strict_types=1);

namespace Moka\Strategy;

use Moka\Exception\MockNotCreatedException;
use Moka\Strategy\Prophecy\NoPriorityToken;
use Moka\Stub\Stub;
use Moka\Stub\StubSet;
use Prophecy\Exception\Prophecy\ObjectProphecyException;
use Prophecy\Prophecy\MethodProphecy;
use Prophecy\Prophecy\ObjectProphecy;
use Prophecy\Prophet;

/**
 * Class ProphecyMockingStrategy
 * @package Moka\Strategy
 */
class ProphecyMockingStrategy extends AbstractMockingStrategy
{
    /**
     * @var Prophet
     */
    private $prophet;

    /**
     * PHPUnitMockingStrategy constructor.
     */
    public function __construct()
    {
        $this->prophet = new Prophet();
        $this->setMockType(ObjectProphecy::class);
    }

    /**
     * @param string $fqcn
     * @return ObjectProphecy
     */
    protected function doBuild(string $fqcn)
    {
        return $this->prophet->prophesize($fqcn);
    }

    /**
     * @param ObjectProphecy $mock
     * @param StubSet $stubs
     * @return void
     */
    protected function doDecorate($mock, StubSet $stubs)
    {
        /** @var Stub $stub */
        foreach ($stubs as $stub) {
            $methodName = $stub->getMethodName();
            $methodValue = $stub->getMethodValue();

            /** @var MethodProphecy $partial */
            $partial = $mock->$methodName(new NoPriorityToken());
            $methodValue instanceof \Throwable
                ? $partial->willThrow($methodValue)
                : $partial->willReturn($methodValue);
        }
    }

    /**
     * @param object $mock
     * @return mixed
     *
     * @throws MockNotCreatedException
     */
    protected function doGet($mock)
    {
        try {
            return $mock->reveal();
        } catch (ObjectProphecyException $exception) {
            throw new MockNotCreatedException(
                sprintf(
                    'Cannot create mock object: %s',
                    $exception->getMessage()
                )
            );
        }
{'fraction_non_alphanumeric': 0.11579481970543423, 'fraction_numerical': 0.0005078720162519045, 'mean_word_length': 2.153722978382706, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '968975', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1153, 'n_words': 223}