PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.6
Kubio AI Page Builder v2.8.6
2.8.6 2.8.5 2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / vendor / sebastian / diff / src / Output / AbstractChunkOutputBuilder.php
kubio / vendor / sebastian / diff / src / Output Last commit date
AbstractChunkOutputBuilder.php 1 year ago DiffOnlyOutputBuilder.php 1 year ago DiffOutputBuilderInterface.php 1 year ago StrictUnifiedDiffOutputBuilder.php 1 year ago UnifiedDiffOutputBuilder.php 1 year ago
AbstractChunkOutputBuilder.php
53 lines
1 <?php declare(strict_types=1);
2 /*
3 * This file is part of sebastian/diff.
4 *
5 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6 *
7 * For the full copyright and license information, please view the LICENSE
8 * file that was distributed with this source code.
9 */
10 namespace SebastianBergmann\Diff\Output;
11
12 use function count;
13
14 abstract class AbstractChunkOutputBuilder implements DiffOutputBuilderInterface
15 {
16 /**
17 * Takes input of the diff array and returns the common parts.
18 * Iterates through diff line by line.
19 */
20 protected function getCommonChunks(array $diff, int $lineThreshold = 5): array
21 {
22 $diffSize = count($diff);
23 $capturing = false;
24 $chunkStart = 0;
25 $chunkSize = 0;
26 $commonChunks = [];
27
28 for ($i = 0; $i < $diffSize; ++$i) {
29 if ($diff[$i][1] === 0 /* OLD */) {
30 if ($capturing === false) {
31 $capturing = true;
32 $chunkStart = $i;
33 $chunkSize = 0;
34 } else {
35 ++$chunkSize;
36 }
37 } elseif ($capturing !== false) {
38 if ($chunkSize >= $lineThreshold) {
39 $commonChunks[$chunkStart] = $chunkStart + $chunkSize;
40 }
41
42 $capturing = false;
43 }
44 }
45
46 if ($capturing !== false && $chunkSize >= $lineThreshold) {
47 $commonChunks[$chunkStart] = $chunkStart + $chunkSize;
48 }
49
50 return $commonChunks;
51 }
52 }
53