1<?php 2 3namespace DeepCopy\TypeMatcher; 4 5class TypeMatcher 6{ 7 /** 8 * @var string 9 */ 10 private $type; 11 12 /** 13 * @param string $type 14 */ 15 public function __construct($type) 16 { 17 $this->type = $type; 18 } 19 20 /** 21 * @param mixed $element 22 * 23 * @return boolean 24 */ 25 public function matches($element) 26 { 27 return is_object($element) ? is_a($element, $this->type) : gettype($element) === $this->type; 28 } 29} 30