Файл: gapps/vendor/phpspec/prophecy/src/Prophecy/Argument.php
Строк: 253
<?php
/*
* This file is part of the Prophecy.
* (c) Konstantin Kudryashov <ever.zet@gmail.com>
* Marcello Duarte <marcello.duarte@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Prophecy;
use ProphecyArgumentToken;
/**
* Argument tokens shortcuts.
*
* @author Konstantin Kudryashov <ever.zet@gmail.com>
*/
class Argument
{
/**
* Checks that argument is exact value or object.
*
* @param mixed $value
*
* @return TokenExactValueToken
*/
public static function exact($value)
{
return new TokenExactValueToken($value);
}
/**
* Checks that argument is of specific type or instance of specific class.
*
* @param string $type Type name (`integer`, `string`) or full class name
*
* @return TokenTypeToken
*/
public static function type($type)
{
return new TokenTypeToken($type);
}
/**
* Checks that argument object has specific state.
*
* @param string $methodName
* @param mixed $value
*
* @return TokenObjectStateToken
*/
public static function which($methodName, $value)
{
return new TokenObjectStateToken($methodName, $value);
}
/**
* Checks that argument matches provided callback.
*
* @param callable $callback
*
* @return TokenCallbackToken
*/
public static function that($callback)
{
return new TokenCallbackToken($callback);
}
/**
* Matches any single value.
*
* @return TokenAnyValueToken
*/
public static function any()
{
return new TokenAnyValueToken;
}
/**
* Matches all values to the rest of the signature.
*
* @return TokenAnyValuesToken
*/
public static function cetera()
{
return new TokenAnyValuesToken;
}
/**
* Checks that argument matches all tokens
*
* @param mixed ... a list of tokens
*
* @return TokenLogicalAndToken
*/
public static function allOf()
{
return new TokenLogicalAndToken(func_get_args());
}
/**
* Checks that argument array or countable object has exact number of elements.
*
* @param integer $value array elements count
*
* @return TokenArrayCountToken
*/
public static function size($value)
{
return new TokenArrayCountToken($value);
}
/**
* Checks that argument array contains (key, value) pair
*
* @param mixed $key exact value or token
* @param mixed $value exact value or token
*
* @return TokenArrayEntryToken
*/
public static function withEntry($key, $value)
{
return new TokenArrayEntryToken($key, $value);
}
/**
* Checks that arguments array entries all match value
*
* @param mixed $value
*
* @return TokenArrayEveryEntryToken
*/
public static function withEveryEntry($value)
{
return new TokenArrayEveryEntryToken($value);
}
/**
* Checks that argument array contains value
*
* @param mixed $value
*
* @return TokenArrayEntryToken
*/
public static function containing($value)
{
return new TokenArrayEntryToken(self::any(), $value);
}
/**
* Checks that argument array has key
*
* @param mixed $key exact value or token
*
* @return TokenArrayEntryToken
*/
public static function withKey($key)
{
return new TokenArrayEntryToken($key, self::any());
}
/**
* Checks that argument does not match the value|token.
*
* @param mixed $value either exact value or argument token
*
* @return TokenLogicalNotToken
*/
public static function not($value)
{
return new TokenLogicalNotToken($value);
}
/**
* @param string $value
*
* @return TokenStringContainsToken
*/
public static function containingString($value)
{
return new TokenStringContainsToken($value);
}
/**
* Checks that argument is identical value.
*
* @param mixed $value
*
* @return TokenIdenticalValueToken
*/
public static function is($value)
{
return new TokenIdenticalValueToken($value);
}
/**
* Check that argument is same value when rounding to the
* given precision.
*
* @param float $value
* @param float $precision
*
* @return TokenApproximateValueToken
*/
public static function approximate($value, $precision = 0)
{
return new TokenApproximateValueToken($value, $precision);
}
}