4
4
5
5
namespace jblond ;
6
6
7
+ use InvalidArgumentException ;
7
8
use jblond \Diff \SequenceMatcher ;
9
+ use OutOfRangeException ;
8
10
9
11
/**
10
12
* Diff
@@ -63,7 +65,7 @@ class Diff
63
65
/**
64
66
* The constructor.
65
67
*
66
- * The first two parameters define the data to compare to eachother .
68
+ * The first two parameters define the data to compare to each other .
67
69
* The values can be of type string or array.
68
70
* If the type is string, it's split into array elements by line-end characters.
69
71
*
@@ -89,13 +91,15 @@ public function __construct($old, $new, array $options = [])
89
91
90
92
/**
91
93
* Set the options to be used by the sequence matcher, called by this class.
92
- * @see Diff::getGroupedOpcodes()
94
+ *
95
+ * @param array $options User defined option names and values.
96
+ *
97
+ *@see Diff::$defaultOptions
98
+ *
99
+ * @see Diff::getGroupedOpCodes()
93
100
*
94
101
* When a keyName matches the name of a default option, that option's value will be overridden by the key's value.
95
102
* Any other keyName (and it's value) will be added as an option, but will not be used if not implemented.
96
- * @see Diff::$defaultOptions
97
- *
98
- * @param array $options User defined option names and values.
99
103
*/
100
104
public function setOptions (array $ options )
101
105
{
@@ -152,14 +156,14 @@ public function render(object $renderer)
152
156
* @param int|null $end The last element of the range to get.
153
157
* If not supplied, only the element at start will be returned.
154
158
*
155
- * @throws \ OutOfRangeException When the value of start or end are invalid to define a range.
159
+ * @throws OutOfRangeException When the value of start or end are invalid to define a range.
156
160
*
157
161
* @return array Array containing all of the elements of the specified range.
158
162
*/
159
163
public function getArrayRange (array $ array , int $ start = 0 , $ end = null ): array
160
164
{
161
165
if ($ start < 0 || $ end < 0 || $ end < $ start ) {
162
- throw new \ OutOfRangeException ('Start parameter must be lower than End parameter while both are positive! ' );
166
+ throw new OutOfRangeException ('Start parameter must be lower than End parameter while both are positive! ' );
163
167
}
164
168
165
169
if ($ start == 0 && $ end === null ) {
@@ -187,7 +191,7 @@ public function getArrayRange(array $array, int $start = 0, $end = null): array
187
191
*
188
192
* @param mixed $var Variable to get type from.
189
193
*
190
- * @throws \ InvalidArgumentException When the type isn't 'array' or 'string'.
194
+ * @throws InvalidArgumentException When the type isn't 'array' or 'string'.
191
195
*
192
196
* @return int Number indicating the type of the variable. 0 for array type and 1 for string type.
193
197
*/
@@ -199,7 +203,7 @@ public function getArgumentType($var): int
199
203
case (is_string ($ var )):
200
204
return 1 ;
201
205
default :
202
- throw new \ InvalidArgumentException ('Invalid argument type! Argument must be of type array or string. ' );
206
+ throw new InvalidArgumentException ('Invalid argument type! Argument must be of type array or string. ' );
203
207
}
204
208
}
205
209
@@ -212,15 +216,15 @@ public function getArgumentType($var): int
212
216
*
213
217
* @return array Array of the grouped op-codes for the generated diff.
214
218
*/
215
- public function getGroupedOpcodes (): array
219
+ public function getGroupedOpCodes (): array
216
220
{
217
221
if ($ this ->groupedCodes !== null ) {
218
222
//Return the cached results.
219
223
return $ this ->groupedCodes ;
220
224
}
221
225
222
226
//Get and cache the grouped op-codes.
223
- $ sequenceMatcher = new SequenceMatcher ($ this ->old , $ this ->new , $ this ->options , null );
227
+ $ sequenceMatcher = new SequenceMatcher ($ this ->old , $ this ->new , $ this ->options );
224
228
$ this ->groupedCodes = $ sequenceMatcher ->getGroupedOpCodes ($ this ->options ['context ' ]);
225
229
226
230
return $ this ->groupedCodes ;
0 commit comments