File tree Expand file tree Collapse file tree 5 files changed +135
-0
lines changed Expand file tree Collapse file tree 5 files changed +135
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace StructureCheck ;
4+
5+ use StructureCheck \Type \TypeInterface ;
6+
7+ /**
8+ * Class Checker
9+ * @package StructureCheck
10+ */
11+ class Checker implements CheckerInterface
12+ {
13+
14+ /**
15+ * @inheritdoc
16+ */
17+ public function fulfills (array $ argument1 , TypeInterface $ requirement )
18+ {
19+ return new Result (true , []);
20+ }
21+
22+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace StructureCheck ;
4+
5+ use StructureCheck \Type \TypeInterface ;
6+
7+ /**
8+ * Interface CheckerInterface
9+ * @package StructureCheck
10+ */
11+ interface CheckerInterface
12+ {
13+
14+ /**
15+ * @param array $tested
16+ * @param TypeInterface $requirement
17+ *
18+ * @return ResultInterface
19+ */
20+ public function fulfills (array $ tested , TypeInterface $ requirement );
21+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace StructureCheck ;
4+
5+ /**
6+ * Class Result
7+ * @package StructureCheck
8+ */
9+ class Result implements ResultInterface
10+ {
11+
12+ /**
13+ * @var bool
14+ */
15+ private $ valid ;
16+
17+ /**
18+ * @var array
19+ */
20+ private $ errors ;
21+
22+ /**
23+ * Result constructor.
24+ *
25+ * @param bool $valid
26+ * @param array $errors
27+ */
28+ public function __construct ($ valid , array $ errors )
29+ {
30+ $ this ->valid = $ valid ;
31+ $ this ->errors = $ errors ;
32+ }
33+
34+ /**
35+ * @inheritdoc
36+ */
37+ public function isValid ()
38+ {
39+ return true ;
40+ }
41+
42+ /**
43+ * @inheritdoc
44+ */
45+ public function getErrors ()
46+ {
47+ return [];
48+ }
49+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace StructureCheck ;
4+
5+ /**
6+ *
7+ * @package StructureCheck
8+ */
9+ interface ResultInterface
10+ {
11+ /**
12+ * Returns TRUE if the check was successful.
13+ *
14+ * @return bool
15+ */
16+ public function isValid ();
17+
18+ /**
19+ * Returns a list of errors. If no error occurred, it will return an empty array.
20+ *
21+ * @return array
22+ */
23+ public function getErrors ();
24+ }
Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace StructureCheck \Type ;
4+
5+ use StructureCheck \ResultInterface ;
6+
7+ /**
8+ * Interface TypeInterface
9+ * @package StructureCheck\Type
10+ */
11+ interface TypeInterface
12+ {
13+ /**
14+ * @param mixed $value
15+ *
16+ * @return ResultInterface
17+ */
18+ public function check ($ value );
19+ }
You can’t perform that action at this time.
0 commit comments