/** * throws exceptions if $item is not a double, or something that can * be cast as a double * * this is a wrapper around our IsDouble check * * @param mixed $item * the container to check * @param string $exception * the class to use when throwing an exception * @return void */ public static function check($item, $exception = E4xx_UnsupportedType::class) { // make sure we have a double if (!IsDouble::check($item)) { throw new $exception(SimpleType::from($item)); } }
/** * @covers ::__invoke * @covers ::check */ public function testCanDetectDoublesInStrings() { // ---------------------------------------------------------------- // setup your test $obj = new IsDouble(); $data = "3.1415927"; // ---------------------------------------------------------------- // perform the change $actualResult1 = $obj($data); $actualResult2 = IsDouble::check($data); // ---------------------------------------------------------------- // test the results $this->assertTrue($actualResult1); $this->assertTrue($actualResult2); }