diff --git a/library/Mockery/CountValidator/AtLeast.php b/library/Mockery/CountValidator/AtLeast.php index 4a18f6e1b..eee0b441d 100644 --- a/library/Mockery/CountValidator/AtLeast.php +++ b/library/Mockery/CountValidator/AtLeast.php @@ -4,13 +4,15 @@ * Mockery (https://docs.mockery.io/) * * @copyright https://github.com/mockery/mockery/blob/HEAD/COPYRIGHT.md - * @license https://github.com/mockery/mockery/blob/HEAD/LICENSE BSD 3-Clause License - * @link https://github.com/mockery/mockery for the canonical source repository + * @license https://github.com/mockery/mockery/blob/HEAD/LICENSE BSD 3-Clause License + * @link https://github.com/mockery/mockery for the canonical source repository */ namespace Mockery\CountValidator; -use Mockery; +use Mockery\Exception\InvalidCountException; + +use const PHP_EOL; class AtLeast extends CountValidatorAbstract { @@ -18,6 +20,7 @@ class AtLeast extends CountValidatorAbstract * Checks if the validator can accept an additional nth call * * @param int $n + * * @return bool */ public function isEligible($n) @@ -29,12 +32,13 @@ public function isEligible($n) * Validate the call count against this validator * * @param int $n + * * @return bool */ public function validate($n) { if ($this->_limit > $n) { - $exception = new Mockery\Exception\InvalidCountException( + $exception = new InvalidCountException( 'Method ' . (string) $this->_expectation . ' from ' . $this->_expectation->getMock()->mockery_getName() . ' should be called' . PHP_EOL diff --git a/library/Mockery/CountValidator/AtMost.php b/library/Mockery/CountValidator/AtMost.php index b52368b25..19173f3c1 100644 --- a/library/Mockery/CountValidator/AtMost.php +++ b/library/Mockery/CountValidator/AtMost.php @@ -4,13 +4,15 @@ * Mockery (https://docs.mockery.io/) * * @copyright https://github.com/mockery/mockery/blob/HEAD/COPYRIGHT.md - * @license https://github.com/mockery/mockery/blob/HEAD/LICENSE BSD 3-Clause License - * @link https://github.com/mockery/mockery for the canonical source repository + * @license https://github.com/mockery/mockery/blob/HEAD/LICENSE BSD 3-Clause License + * @link https://github.com/mockery/mockery for the canonical source repository */ namespace Mockery\CountValidator; -use Mockery; +use Mockery\Exception\InvalidCountException; + +use const PHP_EOL; class AtMost extends CountValidatorAbstract { @@ -18,12 +20,13 @@ class AtMost extends CountValidatorAbstract * Validate the call count against this validator * * @param int $n + * * @return bool */ public function validate($n) { if ($this->_limit < $n) { - $exception = new Mockery\Exception\InvalidCountException( + $exception = new InvalidCountException( 'Method ' . (string) $this->_expectation . ' from ' . $this->_expectation->getMock()->mockery_getName() . ' should be called' . PHP_EOL diff --git a/library/Mockery/CountValidator/CountValidatorAbstract.php b/library/Mockery/CountValidator/CountValidatorAbstract.php index 73ce562f6..3ecfde3a5 100644 --- a/library/Mockery/CountValidator/CountValidatorAbstract.php +++ b/library/Mockery/CountValidator/CountValidatorAbstract.php @@ -4,18 +4,20 @@ * Mockery (https://docs.mockery.io/) * * @copyright https://github.com/mockery/mockery/blob/HEAD/COPYRIGHT.md - * @license https://github.com/mockery/mockery/blob/HEAD/LICENSE BSD 3-Clause License - * @link https://github.com/mockery/mockery for the canonical source repository + * @license https://github.com/mockery/mockery/blob/HEAD/LICENSE BSD 3-Clause License + * @link https://github.com/mockery/mockery for the canonical source repository */ namespace Mockery\CountValidator; -abstract class CountValidatorAbstract +use Mockery\Expectation; + +abstract class CountValidatorAbstract implements CountValidatorInterface { /** * Expectation for which this validator is assigned * - * @var \Mockery\Expectation + * @var Expectation */ protected $_expectation = null; @@ -29,10 +31,9 @@ abstract class CountValidatorAbstract /** * Set Expectation object and upper call limit * - * @param \Mockery\Expectation $expectation * @param int $limit */ - public function __construct(\Mockery\Expectation $expectation, $limit) + public function __construct(Expectation $expectation, $limit) { $this->_expectation = $expectation; $this->_limit = $limit; @@ -42,17 +43,19 @@ public function __construct(\Mockery\Expectation $expectation, $limit) * Checks if the validator can accept an additional nth call * * @param int $n + * * @return bool */ public function isEligible($n) { - return ($n < $this->_limit); + return $n < $this->_limit; } /** * Validate the call count against this validator * * @param int $n + * * @return bool */ abstract public function validate($n); diff --git a/library/Mockery/CountValidator/CountValidatorInterface.php b/library/Mockery/CountValidator/CountValidatorInterface.php new file mode 100644 index 000000000..1cbf4cc31 --- /dev/null +++ b/library/Mockery/CountValidator/CountValidatorInterface.php @@ -0,0 +1,24 @@ +_limit !== $n) { $because = $this->_expectation->getExceptionMessage(); - $exception = new Mockery\Exception\InvalidCountException( + $exception = new InvalidCountException( 'Method ' . (string) $this->_expectation . ' from ' . $this->_expectation->getMock()->mockery_getName() . ' should be called' . PHP_EOL diff --git a/library/Mockery/CountValidator/Exception.php b/library/Mockery/CountValidator/Exception.php index e9899cb7f..b1c20cd4b 100644 --- a/library/Mockery/CountValidator/Exception.php +++ b/library/Mockery/CountValidator/Exception.php @@ -4,14 +4,15 @@ * Mockery (https://docs.mockery.io/) * * @copyright https://github.com/mockery/mockery/blob/HEAD/COPYRIGHT.md - * @license https://github.com/mockery/mockery/blob/HEAD/LICENSE BSD 3-Clause License - * @link https://github.com/mockery/mockery for the canonical source repository + * @license https://github.com/mockery/mockery/blob/HEAD/LICENSE BSD 3-Clause License + * @link https://github.com/mockery/mockery for the canonical source repository */ namespace Mockery\CountValidator; use Mockery\Exception\MockeryExceptionInterface; +use OutOfBoundsException; -class Exception extends \OutOfBoundsException implements MockeryExceptionInterface +class Exception extends OutOfBoundsException implements MockeryExceptionInterface { }