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'; } }