-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
115 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit bootstrap="./vendor/autoload.php"> | ||
|
||
<testsuites> | ||
<testsuite name="PHPMND Test Suite"> | ||
<directory>tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist> | ||
<directory>src/</directory> | ||
<exclude> | ||
<directory>vendor/</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
|
||
</phpunit> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage> | ||
<include> | ||
<directory>src/</directory> | ||
</include> | ||
<exclude> | ||
<directory>vendor/</directory> | ||
</exclude> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="PHPMND Test Suite"> | ||
<directory>tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace Povils\PHPMND\Printer; | ||
|
||
use JakubOnderka\PhpConsoleColor\ConsoleColor; | ||
use JakubOnderka\PhpConsoleHighlighter\Highlighter; | ||
|
||
class Colour implements Decorator | ||
{ | ||
private $highlighter; | ||
|
||
public function __construct() | ||
{ | ||
$this->highlighter = new Highlighter(new ConsoleColor()); | ||
} | ||
|
||
public function getLine(string $fileContents, int $lineNumber): string | ||
{ | ||
return $this->highlighter->getCodeSnippet($fileContents, $lineNumber, 0, 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
declare(strict_types=1); | ||
namespace Povils\PHPMND\Printer; | ||
|
||
interface Decorator | ||
{ | ||
public function getLine(string $fileContents, int $lineNumber): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Povils\PHPMND\Printer; | ||
|
||
class Plain implements Decorator | ||
{ | ||
|
||
public function getLine(string $fileContents, int $lineNumber): string | ||
{ | ||
$format = ' > %d| %s'; | ||
return sprintf( | ||
$format, | ||
$lineNumber, | ||
explode("\n", $fileContents)[$lineNumber - 1] | ||
); | ||
} | ||
} |