diff --git a/README.md b/README.md index dd7464f4..88bfd1d8 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,36 @@ composer require jblond/php-diff ## Example Use +```PHP + true, + //'ignoreCase' => true, +); +// Initialize the diff class +$diff = new \jblond\Diff($a, $b, $options); + +//choose renderer +$renderer = new \jblond\Diff\Renderer\Html\SideBySide(array( + 'title_a' => 'Custom title for OLD version', + 'title_b' => 'Custom title for NEW version', +)); + +//show it +echo $diff->Render($renderer); +``` + +### Example Output A quick usage example can be found in the example/ directory and under example.php. @@ -60,3 +90,11 @@ Contributors since I forked the repo. ### License (BSD License) see [License](LICENSE) + +## tests + +```BASH +composer run-script phpunit +composer run-script php_src +composer run-script php_test +``` diff --git a/composer.json b/composer.json index a571509f..c3ab7814 100644 --- a/composer.json +++ b/composer.json @@ -22,11 +22,17 @@ "ext-mbstring": "*" }, "require-dev": { - "phpunit/phpunit": "7.*" + "phpunit/phpunit": "7.*", + "squizlabs/php_codesniffer": "*" }, "autoload": { "psr-4": { "jblond\\": "lib/jblond" } + }, + "scripts": { + "phpunit": "phpunit ./tests/", + "php_src": "phpcs --standard=phpcs.xml -s -p --colors ./lib/", + "php_test": "phpcs --standard=phpcs.xml -s -p --colors ./tests/" } } diff --git a/example/example.php b/example/example.php index 901091a6..6a6b516a 100644 --- a/example/example.php +++ b/example/example.php @@ -1,67 +1,67 @@ - + -
- -++Unified Diff
+render($renderer)); + // Generate a unified diff + $renderer = new \jblond\Diff\Renderer\Text\Unified(); + echo htmlspecialchars($diff->render($renderer)); - ?> --Context Diff
-++Context Diff
+render($renderer)); - ?> -- + // Generate a context diff + $renderer = new \jblond\Diff\Renderer\Text\Context; + echo htmlspecialchars($diff->render($renderer)); + ?> +