class TypeToken in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/phpspec/prophecy/src/Prophecy/Argument/Token/TypeToken.php \Prophecy\Argument\Token\TypeToken
Value type token.
@author Konstantin Kudryashov <ever.zet@gmail.com>
Hierarchy
- class \Prophecy\Argument\Token\TypeToken implements TokenInterface
Expanded class hierarchy of TypeToken
File
- vendor/
phpspec/ prophecy/ src/ Prophecy/ Argument/ Token/ TypeToken.php, line 21
Namespace
Prophecy\Argument\TokenView source
class TypeToken implements TokenInterface {
private $type;
/**
* @param string $type
*/
public function __construct($type) {
$checker = "is_{$type}";
if (!function_exists($checker) && !interface_exists($type) && !class_exists($type)) {
throw new InvalidArgumentException(sprintf('Type or class name expected as an argument to TypeToken, but got %s.', $type));
}
$this->type = $type;
}
/**
* Scores 5 if argument has the same type this token was constructed with.
*
* @param $argument
*
* @return bool|int
*/
public function scoreArgument($argument) {
$checker = "is_{$this->type}";
if (function_exists($checker)) {
return call_user_func($checker, $argument) ? 5 : false;
}
return $argument instanceof $this->type ? 5 : false;
}
/**
* Returns false.
*
* @return bool
*/
public function isLast() {
return false;
}
/**
* Returns string representation for token.
*
* @return string
*/
public function __toString() {
return sprintf('type(%s)', $this->type);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
TypeToken:: |
private | property | ||
TypeToken:: |
public | function |
Returns false. Overrides TokenInterface:: |
|
TypeToken:: |
public | function |
Scores 5 if argument has the same type this token was constructed with. Overrides TokenInterface:: |
|
TypeToken:: |
public | function | ||
TypeToken:: |
public | function |
Returns string representation for token. Overrides TokenInterface:: |