class CallbackToken in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/phpspec/prophecy/src/Prophecy/Argument/Token/CallbackToken.php \Prophecy\Argument\Token\CallbackToken
Callback-verified token.
@author Konstantin Kudryashov <ever.zet@gmail.com>
Hierarchy
- class \Prophecy\Argument\Token\CallbackToken implements TokenInterface
Expanded class hierarchy of CallbackToken
File
- vendor/
phpspec/ prophecy/ src/ Prophecy/ Argument/ Token/ CallbackToken.php, line 21
Namespace
Prophecy\Argument\TokenView source
class CallbackToken implements TokenInterface {
private $callback;
/**
* Initializes token.
*
* @param callable $callback
*
* @throws \Prophecy\Exception\InvalidArgumentException
*/
public function __construct($callback) {
if (!is_callable($callback)) {
throw new InvalidArgumentException(sprintf('Callable expected as an argument to CallbackToken, but got %s.', gettype($callback)));
}
$this->callback = $callback;
}
/**
* Scores 7 if callback returns true, false otherwise.
*
* @param $argument
*
* @return bool|int
*/
public function scoreArgument($argument) {
return call_user_func($this->callback, $argument) ? 7 : false;
}
/**
* Returns false.
*
* @return bool
*/
public function isLast() {
return false;
}
/**
* Returns string representation for token.
*
* @return string
*/
public function __toString() {
return 'callback()';
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CallbackToken:: |
private | property | ||
CallbackToken:: |
public | function |
Returns false. Overrides TokenInterface:: |
|
CallbackToken:: |
public | function |
Scores 7 if callback returns true, false otherwise. Overrides TokenInterface:: |
|
CallbackToken:: |
public | function | Initializes token. | |
CallbackToken:: |
public | function |
Returns string representation for token. Overrides TokenInterface:: |