Assert\Assertion::same PHP 메소드

same() 공개 정적인 메소드

Assert that two values are the same (using ===).
public static same ( mixed $value, mixed $value2, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$value2 mixed
$message string | null
$propertyPath string | null
리턴 boolean
    public static function same($value, $value2, $message = null, $propertyPath = null)
    {
        if ($value !== $value2) {
            $message = sprintf($message ?: 'Value "%s" is not the same as expected value "%s".', static::stringify($value), static::stringify($value2));
            throw static::createException($value, $message, static::INVALID_SAME, $propertyPath, array('expected' => $value2));
        }
        return true;
    }

Usage Example

예제 #1
0
 /**
  * @param array $types
  *
  * @throws \InvalidArgumentException
  *
  * @return static
  */
 public function withTypes(array $types)
 {
     $choices = [PlatformInterface::TYPE_MOBILE, PlatformInterface::TYPE_TV, PlatformInterface::TYPE_WEB];
     Assertion::allChoice($types, $choices);
     Assertion::same($types, array_unique($types));
     $instance = clone $this;
     $instance->types = $types;
     return $instance;
 }
All Usage Examples Of Assert\Assertion::same