1 | <?php namespace CMPayments\SchemaValidator\Validators; |
||
14 | trait ErrorTrait |
||
15 | { |
||
16 | /** |
||
17 | * @var null|Cache |
||
18 | */ |
||
19 | protected $cache; |
||
20 | |||
21 | /** |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $errors = []; |
||
25 | |||
26 | /** |
||
27 | * @var array |
||
28 | */ |
||
29 | private $stringifiedOrdinals = ['th', 'st', 'nd', 'rd']; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | */ |
||
34 | private $prepositionDefault = 'a'; |
||
35 | |||
36 | /** |
||
37 | * @var array |
||
38 | */ |
||
39 | private $prepositions = [ |
||
40 | BaseValidator::_ARRAY => 'an', |
||
41 | BaseValidator::BOOLEAN => 'a', |
||
42 | BaseValidator::CLOSURE => 'a', |
||
43 | BaseValidator::INTEGER => 'an', |
||
44 | BaseValidator::NUMBER => 'a', |
||
45 | BaseValidator::OBJECT => 'an', |
||
46 | BaseValidator::STRING => 'a', |
||
47 | BaseValidator::_NULL => '' |
||
48 | ]; |
||
49 | |||
50 | /** |
||
51 | * @return array |
||
52 | */ |
||
53 | public function getErrors() |
||
57 | |||
58 | /** |
||
59 | * @param int $code |
||
60 | * @param array $args |
||
61 | */ |
||
62 | protected function addError($code, array $args = []) |
||
67 | |||
68 | /** |
||
69 | * Returns boolean on whether the JSON is valid or not |
||
70 | * |
||
71 | * @return bool |
||
72 | */ |
||
73 | public function isValid() |
||
77 | |||
78 | /** |
||
79 | * Returns the preposition for a specific type |
||
80 | * |
||
81 | * @param $type |
||
82 | * |
||
83 | * @return mixed |
||
84 | * @throws ValidateSchemaException |
||
85 | */ |
||
86 | public function getPreposition($type) |
||
103 | |||
104 | /** |
||
105 | * Returns a valid conjugation of the verb 'to be' |
||
106 | * |
||
107 | * @param integer $count |
||
108 | * |
||
109 | * @return string |
||
110 | */ |
||
111 | public function conjugationToBe($count) |
||
116 | |||
117 | /** |
||
118 | * Returns a valid representation of 'items' (or other value) |
||
119 | * |
||
120 | * @param integer $count |
||
121 | * @param string $single |
||
122 | * @param string $plural |
||
123 | * |
||
124 | * @return string |
||
125 | */ |
||
126 | public function conjugationObject($count, $single = 'item', $plural = 'items') |
||
130 | |||
131 | /** |
||
132 | * Converts a number to a ordinal |
||
133 | * |
||
134 | * @param int $number |
||
135 | * |
||
136 | * @return string |
||
137 | */ |
||
138 | public function numberToOrdinal($number) |
||
147 | } |
||
148 |
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.