1 | <?php |
||
54 | class IsCompatibleWith implements Check |
||
55 | { |
||
56 | /** |
||
57 | * the classname or object that we want to check for |
||
58 | * @var string|object |
||
59 | */ |
||
60 | private $expectedType; |
||
61 | |||
62 | /** |
||
63 | * our constructor |
||
64 | * |
||
65 | * @param string|object $expectedType |
||
66 | * the classname or object that we want to check for |
||
67 | */ |
||
68 | public function __construct($expectedType) |
||
72 | |||
73 | /** |
||
74 | * fluent interface entry point |
||
75 | * |
||
76 | * @param string|object $expectedType |
||
77 | * the classname or object that we want to check for |
||
78 | * @return IsCompatibleWith |
||
79 | * the customised Check, ready to use |
||
80 | */ |
||
81 | public static function using($expectedType) |
||
85 | |||
86 | /** |
||
87 | * is $fieldOrVar compatible with $expectedType? |
||
88 | * |
||
89 | * @param mixed $fieldOrVar |
||
90 | * the classname or object to check |
||
91 | * @param string|object $expectedType |
||
92 | * the classname or object that we want to check for |
||
93 | * @return bool |
||
94 | * TRUE if $fieldOrVar is compatible |
||
95 | * FALSE otherwise |
||
96 | */ |
||
97 | public static function check($fieldOrVar, $expectedType) |
||
114 | |||
115 | /** |
||
116 | * is $fieldOrVar compatible with $expectedType? |
||
117 | * |
||
118 | * @param object $fieldOrVar |
||
119 | * the object to check |
||
120 | * @param string|object $expectedType |
||
121 | * the class or object that $fieldOrVar must be compatible with |
||
122 | * @return bool |
||
123 | * TRUE if $fieldOrVar is compatible |
||
124 | * FALSE otherwise |
||
125 | */ |
||
126 | private static function checkObject($fieldOrVar, $expectedType) |
||
131 | |||
132 | /** |
||
133 | * is $fieldOrVar compatible with $expectedType? |
||
134 | * |
||
135 | * @param string $fieldOrVar |
||
136 | * the class name to check |
||
137 | * @param string|object $expectedType |
||
138 | * the class or object that $fieldOrVar must be compatible with |
||
139 | * @return bool |
||
140 | * TRUE if $fieldOrVar is compatible |
||
141 | * FALSE otherwise |
||
142 | */ |
||
143 | private static function checkString($fieldOrVar, $expectedType) |
||
158 | |||
159 | /** |
||
160 | * is $fieldOrVar compatible with $expectedType? |
||
161 | * |
||
162 | * @param mixed $fieldOrVar |
||
163 | * the classname or object to check |
||
164 | * @return bool |
||
165 | * TRUE if $fieldOrVar is compatible |
||
166 | * FALSE otherwise |
||
167 | */ |
||
168 | public function inspect($fieldOrVar) |
||
172 | } |
||
173 |