1 | <?php |
||
5 | class Padding extends DynamicTerminalObject |
||
6 | { |
||
7 | /** |
||
8 | * The length that lines should be padded to |
||
9 | * |
||
10 | * @var integer $length |
||
11 | */ |
||
12 | protected $length = 0; |
||
13 | |||
14 | /** |
||
15 | * The character(s) that should be used to pad |
||
16 | * |
||
17 | * @var string $char |
||
18 | */ |
||
19 | protected $char = '.'; |
||
20 | |||
21 | |||
22 | /** |
||
23 | * If they pass in a padding character, set the char |
||
24 | * |
||
25 | * @param int $length |
||
26 | * @param string $char |
||
27 | */ |
||
28 | 24 | public function __construct($length = null, $char = null) |
|
38 | |||
39 | /** |
||
40 | * Set the character(s) that should be used to pad |
||
41 | * |
||
42 | * @param string $char |
||
43 | * |
||
44 | * @return \League\CLImate\TerminalObject\Dynamic\Padding |
||
45 | */ |
||
46 | 8 | public function char($char) |
|
52 | |||
53 | /** |
||
54 | * Set the length of the line that should be generated |
||
55 | * |
||
56 | * @param integer $length |
||
57 | * |
||
58 | * @return \League\CLImate\TerminalObject\Dynamic\Padding |
||
59 | */ |
||
60 | 16 | public function length($length) |
|
66 | |||
67 | /** |
||
68 | * Get the length of the line based on the width of the terminal window |
||
69 | * |
||
70 | * @return integer |
||
71 | */ |
||
72 | 24 | protected function getLength() |
|
80 | |||
81 | /** |
||
82 | * Pad the content with the characters |
||
83 | * |
||
84 | * @param string $content |
||
85 | * |
||
86 | * @return string |
||
87 | */ |
||
88 | 24 | protected function padContent($content) |
|
100 | |||
101 | /** |
||
102 | * Output the content and pad to the previously defined length |
||
103 | * |
||
104 | * @param string $content |
||
105 | * |
||
106 | * @return \League\CLImate\TerminalObject\Dynamic\Padding |
||
107 | */ |
||
108 | 24 | public function label($content) |
|
131 | |||
132 | /** |
||
133 | * Output result |
||
134 | * |
||
135 | * @param string $content |
||
136 | */ |
||
137 | 24 | public function result($content) |
|
141 | } |
||
142 |