/** * throws exceptions if $item is not a PHP class that exists * * this is a wrapper around our IsObjectOfType check * * @param mixed $item * the container to check * @param string $type * the class or interface that we want to check against * @param string $exception * the class to use when throwing an exception * @return void */ public static function check($item, $type, $exception = E4xx_UnsupportedType::class) { // robustness! RequireStringy::check($type, $exception); // make sure we have a PHP class that exists if (!IsObjectOfType::check($item, $type)) { throw new $exception(SimpleType::from($item)); } }
/** * @covers ::check * @dataProvider provideDataToTest */ public function testCanCallStatically($data, $type, $expectedResult) { // ---------------------------------------------------------------- // setup your test // ---------------------------------------------------------------- // perform the change $actualResult = IsObjectOfType::check($data, $type); // ---------------------------------------------------------------- // test the results $this->assertEquals($expectedResult, $actualResult); }