PHP 8.2.31
Preview: MatcherInvocationCountMethodCallNodeFactory.php Size: 1.35 KB
//opt/cpanel/ea-wappspector/vendor/rector/rector/vendor/rector/rector-phpunit/src/NodeFactory/MatcherInvocationCountMethodCallNodeFactory.php

<?php

declare (strict_types=1);
namespace Rector\PHPUnit\NodeFactory;

use PhpParser\Node\Expr\MethodCall;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Identifier;
use Rector\PHPUnit\Composer\ProjectPackageVersionResolver;
use Rector\PHPUnit\Enum\ConsecutiveVariable;
final class MatcherInvocationCountMethodCallNodeFactory
{
    /**
     * @readonly
     * @var \Rector\PHPUnit\Composer\ProjectPackageVersionResolver
     */
    private $projectPackageVersionResolver;
    public function __construct(ProjectPackageVersionResolver $projectPackageVersionResolver)
    {
        $this->projectPackageVersionResolver = $projectPackageVersionResolver;
    }
    public function create() : MethodCall
    {
        $invocationMethodName = $this->getInvocationMethodName();
        $matcherVariable = new Variable(ConsecutiveVariable::MATCHER);
        return new MethodCall($matcherVariable, new Identifier($invocationMethodName));
    }
    private function getInvocationMethodName() : string
    {
        $projectPHPUnitVersion = $this->projectPackageVersionResolver->findPackageVersion('phpunit/phpunit');
        if ($projectPHPUnitVersion === null || \version_compare($projectPHPUnitVersion, '10.0', '>=')) {
            // phpunit 10 naming
            return 'numberOfInvocations';
        }
        // phpunit 9 naming
        return 'getInvocationCount';
    }
}

Directory Contents

Dirs: 0 × Files: 5

Name Size Perms Modified Actions
588 B lrw-r--r-- 2024-11-08 13:59:10
Edit Download
5.26 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
2.20 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.35 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download
1.95 KB lrw-r--r-- 2024-11-08 13:59:10
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).