| 1 | <?php | ||
| 5 | class Rule | ||
| 6 | { | ||
| 7 | /** | ||
| 8 | * @var string | ||
| 9 | */ | ||
| 10 | private $class; | ||
| 11 | |||
| 12 | /** | ||
| 13 | * Property => Key | ||
| 14 | * | ||
| 15 | * @var array | ||
| 16 | */ | ||
| 17 | private $map = []; | ||
| 18 | |||
| 19 | /** | ||
| 20 | * Key => Property | ||
| 21 | * | ||
| 22 | * @var array | ||
| 23 | */ | ||
| 24 | private $reflectedMap = []; | ||
| 25 | |||
| 26 | /** | ||
| 27 | * Rule constructor. | ||
| 28 | * | ||
| 29 | * @param string $class | ||
| 30 | */ | ||
| 31 | public function __construct($class) | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Create new rule | ||
| 38 | * | ||
| 39 | * @param string $class | ||
| 40 | * | ||
| 41 | * @return Rule | ||
| 42 | */ | ||
| 43 | public static function create(string $class): Rule | ||
| 47 | |||
| 48 | /** | ||
| 49 | * Create rule with one-to-one mapping | ||
| 50 | * | ||
| 51 | * @param string $class | ||
| 52 | * | ||
| 53 | * @return Rule | ||
| 54 | */ | ||
| 55 | public static function createDefault(string $class): Rule | ||
| 69 | |||
| 70 | /** | ||
| 71 | * Add property-key pair | ||
| 72 | * | ||
| 73 | * @param string $property | ||
| 74 | * @param string $key | ||
| 75 | * | ||
| 76 | * @return $this | ||
| 77 | */ | ||
| 78 | public function assign(string $property, string $key) | ||
| 85 | |||
| 86 | /** | ||
| 87 | * @return string | ||
| 88 | */ | ||
| 89 | public function getClass(): string | ||
| 93 | |||
| 94 | /** | ||
| 95 | * @return array | ||
| 96 | */ | ||
| 97 | public function getMap(): array | ||
| 101 | |||
| 102 | /** | ||
| 103 | * @return array | ||
| 104 | */ | ||
| 105 | public function getReflectedMap(): array | ||
| 109 | } | ||
| 110 |