Source of file Condition.php
Size: 1,073 Bytes - Last Modified: 2021-12-23T10:02:17+00:00
/var/www/docs.ssmods.com/process/src/code/Heuristics/Condition.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | <?php namespace Seeder\Heuristics; /** * Class Condition * @package Seeder\Heuristics */ class Condition { /** * @var */ private $property; /** * @var array */ private $matchers = array(); /** * @param $property */ public function __construct($property) { $this->property = $property; } /** * @param Matcher $matcher */ public function addMatcher(Matcher $matcher) { $this->matchers[] = $matcher; } /** * @param $field * @return bool */ public function match($field) { $properties = explode('.', $this->property); $value = $field; foreach ($properties as $property) { if (!is_object($value) || !isset($value->$property)) { return false; } $value = $value->$property; } $isMatch = false; foreach ($this->matchers as $matcher) { $isMatch = $isMatch || $matcher->match($value); } return $isMatch; } } |