You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
468 B
29 lines
468 B
<?php
|
|
|
|
namespace DeepCopy\TypeMatcher;
|
|
|
|
class TypeMatcher
|
|
{
|
|
/**
|
|
* @var string
|
|
*/
|
|
private $type;
|
|
|
|
/**
|
|
* @param string $type
|
|
*/
|
|
public function __construct($type)
|
|
{
|
|
$this->type = $type;
|
|
}
|
|
|
|
/**
|
|
* @param mixed $element
|
|
*
|
|
* @return boolean
|
|
*/
|
|
public function matches($element)
|
|
{
|
|
return is_object($element) ? is_a($element, $this->type) : gettype($element) === $this->type;
|
|
}
|
|
}
|
|
|