-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathAbstractFormatter.php
More file actions
43 lines (36 loc) · 1 KB
/
AbstractFormatter.php
File metadata and controls
43 lines (36 loc) · 1 KB
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
41
42
43
<?php
namespace IonBazan\ComposerDiff\Formatter;
use IonBazan\ComposerDiff\Diff\DiffEntry;
use Symfony\Component\Console\Output\OutputInterface;
abstract class AbstractFormatter implements Formatter
{
/**
* @var OutputInterface
*/
protected $output;
public function __construct(OutputInterface $output)
{
$this->output = $output;
}
/**
* @return string
*/
protected function getDecoratedPackageName(DiffEntry $entry)
{
return $this->terminalLink($entry->getProjectUrl(), $entry->getPackageName());
}
/**
* @param string|null $url
* @param string $title
*
* @return string
*/
private function terminalLink($url, $title)
{
if (null === $url) {
return $title;
}
// @phpstan-ignore function.alreadyNarrowedType
return method_exists('Symfony\Component\Console\Formatter\OutputFormatterStyle', 'setHref') ? sprintf('<href=%s>%s</>', $url, $title) : $title;
}
}