mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-29 07:20:52 +00:00
72019c1f5a
88b75c6180
[Console] Move color differ here (#2887)
30 lines
832 B
PHP
30 lines
832 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace Rector\Core\Console\Formatter;
|
|
|
|
use RectorPrefix202209\SebastianBergmann\Diff\Differ;
|
|
final class ConsoleDiffer
|
|
{
|
|
/**
|
|
* @readonly
|
|
* @var \SebastianBergmann\Diff\Differ
|
|
*/
|
|
private $differ;
|
|
/**
|
|
* @readonly
|
|
* @var \Rector\Core\Console\Formatter\ColorConsoleDiffFormatter
|
|
*/
|
|
private $colorConsoleDiffFormatter;
|
|
public function __construct(Differ $differ, \Rector\Core\Console\Formatter\ColorConsoleDiffFormatter $colorConsoleDiffFormatter)
|
|
{
|
|
$this->differ = $differ;
|
|
$this->colorConsoleDiffFormatter = $colorConsoleDiffFormatter;
|
|
}
|
|
public function diff(string $old, string $new) : string
|
|
{
|
|
$diff = $this->differ->diff($old, $new);
|
|
return $this->colorConsoleDiffFormatter->format($diff);
|
|
}
|
|
}
|