File tree 3 files changed +48
-32
lines changed
3 files changed +48
-32
lines changed Original file line number Diff line number Diff line change 5
5
namespace jblond ;
6
6
7
7
use InvalidArgumentException ;
8
+ use jblond \Diff \ConstantsInterface ;
8
9
use jblond \Diff \SequenceMatcher ;
9
10
use jblond \Diff \Similarity ;
10
11
use OutOfRangeException ;
26
27
* @version 2.3.0
27
28
* @link https://github.com/JBlond/php-diff
28
29
*/
29
- class Diff
30
+ class Diff implements ConstantsInterface
30
31
{
31
- /**
32
- * Flag to disable ignore of successive empty/blank lines.
33
- */
34
- public const DIFF_IGNORE_LINE_NONE = 0 ;
35
- /**
36
- * Flag to ignore successive empty lines.
37
- */
38
- public const DIFF_IGNORE_LINE_EMPTY = 1 ;
39
- /**
40
- * Flag to ignore successive blank lines. (Lines which contain no or only non printable characters.)
41
- */
42
- public const DIFF_IGNORE_LINE_BLANK = 2 ;
43
32
/**
44
33
* @var array The first version to compare.
45
34
* Each element contains a line of this string.
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace jblond \Diff ;
4
+ /**
5
+ * Constant Interface
6
+ *
7
+ * Defines the library constants which needs to be shared across the different classes.
8
+ *
9
+ * PHP version 7.2 or greater
10
+ *
11
+ * @package jblond
12
+ * @author Ferry Cools <[email protected] >
13
+ * @copyright (c) 2020 Mario Brandt
14
+ * @license New BSD License http://www.opensource.org/licenses/bsd-license.php
15
+ * @version 2.3.0
16
+ * @link https://github.com/JBlond/php-diff
17
+ */
18
+ interface ConstantsInterface
19
+ {
20
+ /**
21
+ * Flag to disable ignore of successive empty/blank lines.
22
+ */
23
+ public const DIFF_IGNORE_LINE_NONE = 0 ;
24
+ /**
25
+ * Flag to ignore empty lines.
26
+ */
27
+ public const DIFF_IGNORE_LINE_EMPTY = 1 ;
28
+ /**
29
+ * Flag to ignore blank lines. (Lines which contain no or only non printable characters.)
30
+ */
31
+ public const DIFF_IGNORE_LINE_BLANK = 2 ;
32
+
33
+ }
Original file line number Diff line number Diff line change 20
20
* @version 2.3.0
21
21
* @link https://github.com/JBlond/php-diff
22
22
*/
23
- class SequenceMatcher
23
+ class SequenceMatcher implements ConstantsInterface
24
24
{
25
- /**
26
- * Flag to disable ignore of successive empty/blank lines.
27
- */
28
- public const DIFF_IGNORE_LINE_NONE = 0 ;
29
- /**
30
- * Flag to ignore empty lines.
31
- */
32
- public const DIFF_IGNORE_LINE_EMPTY = 1 ;
33
- /**
34
- * Flag to ignore blank lines. (Lines which contain no or only non printable characters.)
35
- */
36
- public const DIFF_IGNORE_LINE_BLANK = 2 ;
37
25
/**
38
26
* @var array The first sequence to compare against.
39
27
*/
@@ -360,12 +348,18 @@ public function getOpCodes(): array
360
348
$ part2 = array_slice ($ this ->new , $ j , $ bj - $ j );
361
349
362
350
if ($ this ->options ['ignoreLines ' ] == 2 ) {
363
- array_walk ($ part1 , function (&$ line ) {
364
- $ line = trim ($ line );
365
- });
366
- array_walk ($ part2 , function (&$ line ) {
367
- $ line = trim ($ line );
368
- });
351
+ array_walk (
352
+ $ part1 ,
353
+ function (&$ line ) {
354
+ $ line = trim ($ line );
355
+ }
356
+ );
357
+ array_walk (
358
+ $ part2 ,
359
+ function (&$ line ) {
360
+ $ line = trim ($ line );
361
+ }
362
+ );
369
363
unset($ line );
370
364
}
371
365
You can’t perform that action at this time.
0 commit comments