/** * @covers ::check * @dataProvider provideScalars * @expectedException GanbaroDigital\Reflection\Exceptions\E4xx_UnsupportedType */ public function testRejectsEverythingElseWhenCalledStatically($item) { // ---------------------------------------------------------------- // setup your test // ---------------------------------------------------------------- // perform the change RequireObject::check($item); }
/** * is $data compatible with $constraint? * * @param object $data * the object to check * @param string|object $constraint * the class or object that $data must be compatible with * @return boolean * TRUE if $data is compatible * FALSE otherwise */ public static function checkObject($data, $constraint) { // defensive programming! RequireObject::check($data, E4xx_UnsupportedType::class); RequireAnyOneOf::check([new IsObject(), new IsStringy()], [$constraint], E4xx_UnsupportedType::class); // this is the easiest test case of all :) return $data instanceof $constraint; }