-
Notifications
You must be signed in to change notification settings - Fork 0
/
1-single-rule.php
40 lines (26 loc) · 1.21 KB
/
1-single-rule.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php
/**
* Bit&Black TypoRules.
*
* @author Tobias Köngeter
* @copyright Copyright © Bit&Black
* @link https://www.bitandblack.com
* @license MIT
*/
use BitAndBlack\TypoRules\Diff\CharacterDiff;
use BitAndBlack\TypoRules\Rule\RemoveDuplicatedWhitespaceRule;
require dirname(__DIR__) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
$content = 'Dies ist ein Beispielsatz.Von wem? Von mir. An dich. Keine Ahnung warum!Ich bin der, der einen Satz schreibt.';
echo 'Running the RemoveDuplicatedWhitespaceRule with content "' . $content . '".' . PHP_EOL;
echo PHP_EOL;
$removeDuplicatedWhitespaceRule = new RemoveDuplicatedWhitespaceRule();
$violations = $removeDuplicatedWhitespaceRule->getViolations($content);
$contentFixed = $removeDuplicatedWhitespaceRule->getContentFixed($content);
echo 'Found ' . count($violations) . ' violations. ' . PHP_EOL;
foreach ($violations as $key => $violation) {
echo 'Violation ' . $key . ': ' . $violation->getViolationPreview() . PHP_EOL;
}
echo PHP_EOL;
echo 'The fixed content: "' . $contentFixed . '".' . PHP_EOL;
echo PHP_EOL;
echo 'The changes in a diff view: "' . CharacterDiff::create()->getDiff($content, $contentFixed) . '".' . PHP_EOL;