mirror of
https://github.com/rectorphp/rector.git
synced 2024-05-31 00:10:51 +00:00
6c20d257e3
d3d18d442c
keep relative paths
32 lines
915 B
PHP
32 lines
915 B
PHP
<?php
|
|
|
|
declare (strict_types=1);
|
|
namespace RectorPrefix202209\Symplify\PackageBuilder\Console\Output;
|
|
|
|
use RectorPrefix202209\SebastianBergmann\Diff\Differ;
|
|
use RectorPrefix202209\Symplify\PackageBuilder\Console\Formatter\ColorConsoleDiffFormatter;
|
|
/**
|
|
* @api
|
|
*/
|
|
final class ConsoleDiffer
|
|
{
|
|
/**
|
|
* @var \SebastianBergmann\Diff\Differ
|
|
*/
|
|
private $differ;
|
|
/**
|
|
* @var \Symplify\PackageBuilder\Console\Formatter\ColorConsoleDiffFormatter
|
|
*/
|
|
private $colorConsoleDiffFormatter;
|
|
public function __construct(Differ $differ, 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);
|
|
}
|
|
}
|