-
Notifications
You must be signed in to change notification settings - Fork 6
/
BoxDrawings.php
50 lines (40 loc) · 1.09 KB
/
BoxDrawings.php
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
44
45
46
47
48
49
50
<?php
namespace Oro\TwigInspector;
/**
* Generates prefixed for start and end comment tags.
*/
class BoxDrawings
{
protected const CHARSETS = [
['┏', '━', '┗'],
['╭', '─', '╰'],
['╔', '═', '╚'],
['┎', '─', '┖'],
];
private int $charsetIndex = 0;
private int $length = 0;
public function getStartCommentPrefix(): string
{
$prefix = $this->getCharset()[0];
$prefix .= str_repeat($this->getCharset()[1], $this->length);
return $prefix;
}
public function getEndCommentPrefix(): string
{
$prefix = $this->getCharset()[2];
$prefix .= str_repeat($this->getCharset()[1], $this->length);
return $prefix;
}
public function blockChanged(int $length): void
{
$this->length = $length;
$this->charsetIndex++;
if ($length === 0 || count(self::CHARSETS) - 1 === $this->charsetIndex) {
$this->charsetIndex = 0;
}
}
private function getCharset(): array
{
return self::CHARSETS[$this->charsetIndex];
}
}