|
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 InvalidArgumentException; |
|
17
|
|
|
use Zend\Text\Figlet\Figlet as ZendFiglet; |
|
|
|
|
|
|
18
|
|
|
|
|
19
|
|
|
/** |
|
20
|
|
|
* @internal |
|
21
|
|
|
*/ |
|
22
|
|
|
final class FigletString |
|
23
|
|
|
{ |
|
24
|
|
|
private $string; |
|
25
|
|
|
|
|
26
|
|
|
private $figlet; |
|
27
|
|
|
|
|
28
|
|
|
public const DEFAULT_FONT = __DIR__.DIRECTORY_SEPARATOR.'fonts'.DIRECTORY_SEPARATOR.'big.flf'; |
|
29
|
|
|
|
|
30
|
|
|
public function __construct(string $string, array $options) |
|
31
|
|
|
{ |
|
32
|
|
|
$this->string = $string; |
|
33
|
|
|
$this->figlet = new ZendFiglet(); |
|
34
|
|
|
|
|
35
|
|
|
$this->parseOptions($options); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
private function parseOptions(array $config) |
|
39
|
|
|
{ |
|
40
|
|
|
$this |
|
41
|
|
|
->font($config['font'] ?? self::DEFAULT_FONT) |
|
42
|
|
|
->outputWidth($config['outputWidth'] ?? 80) |
|
43
|
|
|
->justification($config['justification'] ?? null) |
|
44
|
|
|
->rightToLeft($config['rightToLeft'] ?? null); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
private function font(?string $font) |
|
48
|
|
|
{ |
|
49
|
|
|
if (is_null($font)) { |
|
50
|
|
|
return $this; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
$this->figlet->setFont($font); |
|
54
|
|
|
|
|
55
|
|
|
return $this; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
private function outputWidth(int $outputWidth) |
|
59
|
|
|
{ |
|
60
|
|
|
$this->figlet->setOutputWidth($outputWidth); |
|
61
|
|
|
|
|
62
|
|
|
return $this; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
private function justification(?string $justification) |
|
66
|
|
|
{ |
|
67
|
|
|
switch ($justification) { |
|
68
|
|
|
case 'left': |
|
69
|
|
|
$this->figlet->setJustification(ZendFiglet::JUSTIFICATION_LEFT); |
|
70
|
|
|
break; |
|
71
|
|
|
case 'center': |
|
72
|
|
|
$this->figlet->setJustification(ZendFiglet::JUSTIFICATION_LEFT); |
|
73
|
|
|
break; |
|
74
|
|
|
case 'right': |
|
75
|
|
|
$this->figlet->setJustification(ZendFiglet::JUSTIFICATION_LEFT); |
|
76
|
|
|
break; |
|
77
|
|
|
case null: |
|
|
|
|
|
|
78
|
|
|
// Let ZendFiglet handle the justification |
|
79
|
|
|
break; |
|
80
|
|
|
default: |
|
81
|
|
|
throw new InvalidArgumentException('Invalid value given for the `logo.justification` option'); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
return $this; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
private function rightToLeft(?string $rightToLeft) |
|
88
|
|
|
{ |
|
89
|
|
|
switch ($rightToLeft) { |
|
90
|
|
|
case 'right-to-left': |
|
91
|
|
|
$this->figlet->setRightToLeft(ZendFiglet::DIRECTION_RIGHT_TO_LEFT); |
|
92
|
|
|
break; |
|
93
|
|
|
case 'left-to-right': |
|
94
|
|
|
$this->figlet->setRightToLeft(ZendFiglet::DIRECTION_LEFT_TO_RIGHT); |
|
95
|
|
|
break; |
|
96
|
|
|
case null: |
|
|
|
|
|
|
97
|
|
|
// Let ZendFiglet handle this |
|
98
|
|
|
break; |
|
99
|
|
|
default: |
|
100
|
|
|
throw new \InvalidArgumentException('Invalid value given for the `logo.rightToLeft` option'); |
|
101
|
|
|
} |
|
102
|
|
|
|
|
103
|
|
|
return $this; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
public function __toString() |
|
107
|
|
|
{ |
|
108
|
|
|
$rendered = $this->figlet->render($this->string); |
|
109
|
|
|
|
|
110
|
|
|
return "\n$rendered\n"; |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|
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