Esempio n. 1
0
 /**
  * @covers Headzoo\Core\Comparator::isInstanceOf
  */
 public function testIsInstanceOf()
 {
     $this->assertTrue(Comparator::isInstanceOf($this, ComparatorTest::class));
     $this->assertFalse(Comparator::isInstanceOf($this, Comparator::class));
 }
Esempio n. 2
0
 /**
  * Returns which condition the value matches
  * 
  * @param  mixed     $return    The callable return value or thrown exception
  * @param  Exception $exception Any exception that was thrown
  *
  * @return null|string
  */
 protected function matchesCondition($return, $exception = null)
 {
     $matched = false;
     foreach ($this->conditions as $expression) {
         if ("isExceptionOf" === $expression["compare"]) {
             $matched = Comparator::isInstanceOf($exception, $expression["value"]);
         } else {
             $matched = Comparator::$expression["compare"]($return, $expression["value"]);
         }
         if ($matched) {
             $matched = $expression["action"];
             break;
         }
     }
     return $matched;
 }