Debian Codegraph @

vendor/symfony/console/Helper/TreeStyle.php

raw
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <[email protected]>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\Console\Helper;
13
14 /**
15 * Configures the output of the Tree helper.
16 *
17 * @author Simon André <[email protected]>
18 */
19 final class TreeStyle
20 {
21 public function __construct(
22 private readonly string $prefixEndHasNext,
23 private readonly string $prefixEndLast,
24 private readonly string $prefixLeft,
25 private readonly string $prefixMidHasNext,
26 private readonly string $prefixMidLast,
27 private readonly string $prefixRight,
28 ) {
29 }
30
31 public static function box(): self
32 {
33 return new self('┃╸ ', '┗╸ ', '', '┃ ', ' ', '');
34 }
35
36 public static function boxDouble(): self
37 {
38 return new self('╠═ ', '╚═ ', '', '║ ', ' ', '');
39 }
40
41 public static function compact(): self
42 {
43 return new self('├ ', '└ ', '', '│ ', ' ', '');
44 }
45
46 public static function default(): self
47 {
48 return new self('├── ', '└── ', '', '│ ', ' ', '');
49 }
50
51 public static function light(): self
52 {
53 return new self('|-- ', '`-- ', '', '| ', ' ', '');
54 }
55
56 public static function minimal(): self
57 {
58 return new self('. ', '. ', '', '. ', ' ', '');
59 }
60
61 public static function rounded(): self
62 {
63 return new self('├─ ', '╰─ ', '', '│ ', ' ', '');
64 }
65
66 /**
67 * @internal
68 */
69 public function applyPrefixes(\RecursiveTreeIterator $iterator): void
70 {
71 $iterator->setPrefixPart(\RecursiveTreeIterator::PREFIX_LEFT, $this->prefixLeft);
72 $iterator->setPrefixPart(\RecursiveTreeIterator::PREFIX_MID_HAS_NEXT, $this->prefixMidHasNext);
73 $iterator->setPrefixPart(\RecursiveTreeIterator::PREFIX_MID_LAST, $this->prefixMidLast);
74 $iterator->setPrefixPart(\RecursiveTreeIterator::PREFIX_END_HAS_NEXT, $this->prefixEndHasNext);
75 $iterator->setPrefixPart(\RecursiveTreeIterator::PREFIX_END_LAST, $this->prefixEndLast);
76 $iterator->setPrefixPart(\RecursiveTreeIterator::PREFIX_RIGHT, $this->prefixRight);
77 }
78 }