Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
Resolver refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
mkorkmaz committed Jul 13, 2017
1 parent ec6d7af commit 8433b65
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
31 changes: 21 additions & 10 deletions src/Resolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,10 @@ class Resolver

public static function getParameterHints(string $className, string $methodName) : array
{
if (! class_exists($className)) {
throw new InvalidArgumentException(
sprintf('%s class does not exist!', $className)
);
}
if (! method_exists($className, $methodName)) {
throw new InvalidArgumentException(
sprintf('%s does not have method named %s!', $className, $methodName)
);
}

self::checkClassName($className);
self::checkMethodName($className, $methodName);

$method = new ReflectionMethod($className, $methodName);
/**
* @var array $parameters
Expand All @@ -42,6 +36,23 @@ public static function getParameterHints(string $className, string $methodName)
return $parameterHints;
}

private static function checkClassName(string $className) : void
{
if (! class_exists($className)) {
throw new InvalidArgumentException(
sprintf('%s class does not exist!', $className)
);
}
}

private static function checkMethodName(string $className, string $methodName) : void
{
if (! method_exists($className, $methodName)) {
throw new InvalidArgumentException(
sprintf('%s does not have method named %s!', $className, $methodName)
);
}
}

/**
* @param ReflectionParameter $parameter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use Codeception\Test\Test;
use Codeception\Test\Unit;

class ParameterResolverTest extends Unit
class ResolverTest extends Unit
{
/**
* @var \UnitTester
Expand Down

0 comments on commit 8433b65

Please sign in to comment.