Skip to content

Commit

Permalink
refactoring: code standarding
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscoelho committed Oct 27, 2023
1 parent cf8b6e0 commit b80f04f
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions classes/PHPMock.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use phpmock\Deactivatable;
use PHPUnit\Event\Facade;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Runner\Version;
use ReflectionClass;
use ReflectionProperty;
use SebastianBergmann\Template\Template;
Expand Down Expand Up @@ -44,8 +43,9 @@ trait PHPMock
{
public static $templatesPath = '/tmp';

private $openInvocation = 'new \PHPUnit\Framework\MockObject\Invocation(';
private $openWrapper = '\phpmock\phpunit\DefaultArgumentRemover::removeDefaultArgumentsWithReflection(';
private $phpunitVersionClass = '\\PHPUnit\\Runner\\Version';
private $openInvocation = 'new \\PHPUnit\\Framework\\MockObject\\Invocation(';
private $openWrapper = '\\phpmock\\phpunit\\DefaultArgumentRemover::removeDefaultArgumentsWithReflection(';
private $closeFunc = ')';

/**
Expand Down Expand Up @@ -180,7 +180,7 @@ private function prepareCustomTemplates()

$templates = [];

$prefix = 'phpmock-phpunit-' . Version::id() . '-';
$prefix = 'phpmock-phpunit-' . $this->getPhpUnitVersion() . '-';

foreach ($directoryIterator as $fileinfo) {
if ($fileinfo->getExtension() !== 'tpl') {
Expand Down Expand Up @@ -219,10 +219,13 @@ private function prepareCustomTemplates()

private function shouldPrepareCustomTemplates()
{
$phpunitVersionClass = 'PHPUnit\\Runner\\Version';
return class_exists($this->phpunitVersionClass)
&& version_compare($this->getPhpUnitVersion(), '10.0.0') >= 0;
}

return class_exists($phpunitVersionClass)
&& version_compare(call_user_func([$phpunitVersionClass, 'id']), '10.0.0') >= 0;
private function getPhpUnitVersion()
{
return call_user_func([$this->phpunitVersionClass, 'id']);
}

/**
Expand Down

0 comments on commit b80f04f

Please sign in to comment.