1 | <?php |
||
23 | abstract class GenericHasher extends GenericEquivalence implements Hasher |
||
24 | { |
||
25 | /** |
||
26 | * {@inheritdoc} |
||
27 | */ |
||
28 | 66 | public function hash($value) |
|
65 | |||
66 | /** |
||
67 | * Returns a hash code for the given array. |
||
68 | * |
||
69 | * The resulting hash code is guaranteed to be _consistent_ with the |
||
70 | * {@link equivalentArray()} method, which means that for any references |
||
71 | * `$x` and `$y`, if `equivalentArray($x, $y)`, then |
||
72 | * `hashArray($x) === hashArray($y)`. |
||
73 | * |
||
74 | * @param array $value The array to hash. |
||
75 | * |
||
76 | * @return integer The hash code for the given array. |
||
77 | * |
||
78 | * @link http://php.net/manual/en/language.types.array.php PHP array |
||
79 | */ |
||
80 | abstract protected function hashArray(array $value); |
||
81 | |||
82 | /** |
||
83 | * Returns a hash code for the given boolean value. |
||
84 | * |
||
85 | * The resulting hash code is guaranteed to be _consistent_ with the |
||
86 | * {@link equivalentBoolean()} method, which means that for any references |
||
87 | * `$x` and `$y`, if `equivalentBoolean($x, $y)`, then |
||
88 | * `hashBoolean($x) === hashBoolean($y)`. |
||
89 | * |
||
90 | * @param boolean $value The boolean value to hash. |
||
91 | * |
||
92 | * @return integer The hash code for the given boolean value. |
||
93 | * |
||
94 | * @link http://php.net/manual/en/language.types.boolean.php PHP boolean |
||
95 | */ |
||
96 | abstract protected function hashBoolean($value); |
||
97 | |||
98 | /** |
||
99 | * Returns a hash code for the given floating-point number. |
||
100 | * |
||
101 | * The resulting hash code is guaranteed to be _consistent_ with the |
||
102 | * {@link equivalentFloat()} method, which means that for any references |
||
103 | * `$x` and `$y`, if `equivalentFloat($x, $y)`, then |
||
104 | * `hashFloat($x) === hashFloat($y)`. |
||
105 | * |
||
106 | * @param float $value The floating-point number to hash. |
||
107 | * |
||
108 | * @return integer The hash code for the given floating-point number. |
||
109 | * |
||
110 | * @link http://php.net/manual/en/language.types.float.php PHP float |
||
111 | */ |
||
112 | abstract protected function hashFloat($value); |
||
113 | |||
114 | /** |
||
115 | * Returns a hash code for the given integer number. |
||
116 | * |
||
117 | * The resulting hash code is guaranteed to be _consistent_ with the |
||
118 | * {@link equivalentInteger()} method, which means that for any references |
||
119 | * `$x` and `$y`, if `equivalentInteger($x, $y)`, then |
||
120 | * `hashInteger($x) === hashInteger($y)`. |
||
121 | * |
||
122 | * @param integer $value The integer number to hash. |
||
123 | * |
||
124 | * @return integer The hash code for the given integer number. |
||
125 | * |
||
126 | * @link http://php.net/manual/en/language.types.integer.php PHP interger |
||
127 | */ |
||
128 | abstract protected function hashInteger($value); |
||
129 | |||
130 | /** |
||
131 | * Returns a hash code for the null value. |
||
132 | * |
||
133 | * @return integer The hash code for the `NULL` value. |
||
134 | * |
||
135 | * @link http://php.net/manual/en/language.types.null.php PHP NULL |
||
136 | */ |
||
137 | abstract protected function hashNull(); |
||
138 | |||
139 | /** |
||
140 | * Returns a hash code for the given object. |
||
141 | * |
||
142 | * The resulting hash code is guaranteed to be _consistent_ with the |
||
143 | * {@link equivalentObject()} method, which means that for any references |
||
144 | * `$x` and `$y`, if `equivalentObject($x, $y)`, then |
||
145 | * `hashObject($x) === hashObject($y)`. |
||
146 | * |
||
147 | * @param object $value The object to hash. |
||
148 | * |
||
149 | * @return integer The hash code for the given object. |
||
150 | * |
||
151 | * @link http://php.net/manual/en/language.types.object.php PHP object |
||
152 | */ |
||
153 | abstract protected function hashObject($value); |
||
154 | |||
155 | /** |
||
156 | * Returns a hash code for the given resource. |
||
157 | * |
||
158 | * The resulting hash code is guaranteed to be _consistent_ with the |
||
159 | * {@link equivalentResource()} method, which means that for any references |
||
160 | * `$x` and `$y`, if `equivalentResource($x, $y)`, then |
||
161 | * `hashResource($x) === hashResource($y)`. |
||
162 | * |
||
163 | * @param resource $value The resource to hash. |
||
164 | * |
||
165 | * @return integer The hash code for the given resource. |
||
166 | * |
||
167 | * @link http://php.net/manual/en/language.types.resource.php PHP resource |
||
168 | */ |
||
169 | abstract protected function hashResource($value); |
||
170 | |||
171 | /** |
||
172 | * Returns a hash code for the given string value. |
||
173 | * |
||
174 | * The resulting hash code is guaranteed to be _consistent_ with the |
||
175 | * {@link equivalentString()} method, which means that for any references |
||
176 | * `$x` and `$y`, if `equivalentString($x, $y)`, then |
||
177 | * `hashString($x) === hashString($y)`. |
||
178 | * |
||
179 | * @param string $value The string value to hash. |
||
180 | * |
||
181 | * @return integer The hash code for the given object. |
||
182 | * |
||
183 | * @link http://php.net/manual/en/language.types.string.php PHP string |
||
184 | */ |
||
185 | abstract protected function hashString($value); |
||
186 | } |
||
187 |