1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* This file is part of Laravel Zero. |
7
|
|
|
* |
8
|
|
|
* (c) Nuno Maduro <[email protected]> |
9
|
|
|
* |
10
|
|
|
* For the full copyright and license information, please view the LICENSE |
11
|
|
|
* file that was distributed with this source code. |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace LaravelZero\Framework\Components\Logo; |
15
|
|
|
|
16
|
|
|
use Zend\Text\Figlet\Figlet as ZendFiglet; |
|
|
|
|
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @internal |
20
|
|
|
*/ |
21
|
|
|
final class FigletString |
22
|
|
|
{ |
23
|
|
|
private $string; |
24
|
|
|
|
25
|
|
|
private $figlet; |
26
|
|
|
|
27
|
|
|
public const DEFAULT_FONT = __DIR__.DIRECTORY_SEPARATOR.'fonts'.DIRECTORY_SEPARATOR.'big.flf'; |
28
|
|
|
|
29
|
|
|
public function __construct(string $string, array $options) |
30
|
|
|
{ |
31
|
|
|
$this->string = $string; |
32
|
|
|
$this->figlet = new ZendFiglet(); |
33
|
|
|
|
34
|
|
|
$this->parseOptions($options); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
private function parseOptions(array $config) |
38
|
|
|
{ |
39
|
|
|
$this |
40
|
|
|
->font($config['font'] ?? self::DEFAULT_FONT) |
41
|
|
|
->outputWidth($config['outputWidth'] ?? 80) |
42
|
|
|
->justification($config['justification'] ?? null) |
43
|
|
|
->rightToLeft($config['rightToLeft'] ?? null); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
private function font(?string $font) |
47
|
|
|
{ |
48
|
|
|
if (is_null($font)) { |
49
|
|
|
return $this; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
$this->figlet->setFont($font); |
53
|
|
|
|
54
|
|
|
return $this; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
private function outputWidth(int $outputWidth) |
58
|
|
|
{ |
59
|
|
|
$this->figlet->setOutputWidth($outputWidth); |
60
|
|
|
|
61
|
|
|
return $this; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
private function justification(?string $justification) |
65
|
|
|
{ |
66
|
|
|
switch ($justification) { |
67
|
|
|
case 'left': |
68
|
|
|
$this->figlet->setJustification(ZendFiglet::JUSTIFICATION_LEFT); |
69
|
|
|
break; |
70
|
|
|
case 'center': |
71
|
|
|
$this->figlet->setJustification(ZendFiglet::JUSTIFICATION_LEFT); |
72
|
|
|
break; |
73
|
|
|
case 'right': |
74
|
|
|
$this->figlet->setJustification(ZendFiglet::JUSTIFICATION_LEFT); |
75
|
|
|
break; |
76
|
|
|
case null: |
|
|
|
|
77
|
|
|
// Let ZendFiglet handle the justification |
78
|
|
|
break; |
79
|
|
|
default: |
80
|
|
|
throw new \InvalidArgumentException('Invalid value given for the `logo.justification` option'); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
return $this; |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
private function rightToLeft(?string $rightToLeft) |
87
|
|
|
{ |
88
|
|
|
switch ($rightToLeft) { |
89
|
|
|
case 'right-to-left': |
90
|
|
|
$this->figlet->setRightToLeft(ZendFiglet::DIRECTION_RIGHT_TO_LEFT); |
91
|
|
|
break; |
92
|
|
|
case 'left-to-right': |
93
|
|
|
$this->figlet->setRightToLeft(ZendFiglet::DIRECTION_LEFT_TO_RIGHT); |
94
|
|
|
break; |
95
|
|
|
case null: |
|
|
|
|
96
|
|
|
// Let ZendFiglet handle this |
97
|
|
|
break; |
98
|
|
|
default: |
99
|
|
|
throw new \InvalidArgumentException('Invalid value given for the `logo.rightToLeft` option'); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
return $this; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
public function __toString() |
106
|
|
|
{ |
107
|
|
|
$rendered = $this->figlet->render($this->string); |
108
|
|
|
|
109
|
|
|
return "\n$rendered\n"; |
110
|
|
|
} |
111
|
|
|
} |
112
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths