public function __construct(Manager $manager, array $config) { parent::__construct($manager, $config); $this->rules = Manager::readConfig($config, self::CFG_RULES); $this->button = Manager::readConfig($config, self::CFG_BUTTON); Screen::assertRules($this->rules); Position::assertRect($this->button); }
public static function assertDialogRule(array &$dialog) { if (!isset($dialog[self::DIALOG_JUDGE]) || !isset($dialog[self::DIALOG_BUTTON])) { throw new \InvalidArgumentException('Rules should be an array.'); } Screen::assertRules($dialog[self::DIALOG_JUDGE]); Position::assertRect($dialog[self::DIALOG_BUTTON]); }
public static function getRectVertex(array &$rect) { Position::assertRect($rect); return [Position::makePoint($rect[Position::X1], $rect[Position::Y1]), Position::makePoint($rect[Position::X2], $rect[Position::Y2])]; }
public static function getRectAlign(array &$rect) { Position::assertRect($rect); return $rect[Position::X1] < $rect[Position::X2] ? self::ALIGN_LEFT : self::ALIGN_RIGHT; }
public function swipeLine($line) { Position::assertRect($line); return $this->swipe($line[Position::X1], $line[Position::Y1], $line[Position::X2], $line[Position::Y2]); }
public static function assertRules(array $rules) { foreach ($rules as $color => $positions) { if (!preg_match(self::REGEXP_COLOR, $color)) { throw new \InvalidArgumentException("Invalid color notation '{$color}'."); } if (!is_array($positions)) { throw new \InvalidArgumentException('Points array in rule entry does not exist.'); } foreach ($positions as $position) { try { Position::assertPoint($position); } catch (\Exception $e) { Position::assertRect($position); } } } return true; }