@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -return array ( |
|
3 | +return array( |
|
4 | 4 | 'À' => 'À', |
5 | 5 | 'Á' => 'Á', |
6 | 6 | 'Â' => 'Â', |
@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | -return array ( |
|
3 | +return array( |
|
4 | 4 | '̀' => 230, |
5 | 5 | '́' => 230, |
6 | 6 | '̂' => 230, |
@@ -23,8 +23,7 @@ |
||
23 | 23 | * |
24 | 24 | * @final |
25 | 25 | */ |
26 | -class ProcessHelper extends Helper |
|
27 | -{ |
|
26 | +class ProcessHelper extends Helper { |
|
28 | 27 | /** |
29 | 28 | * Runs an external process. |
30 | 29 | * |
@@ -25,124 +25,124 @@ |
||
25 | 25 | */ |
26 | 26 | class ProcessHelper extends Helper |
27 | 27 | { |
28 | - /** |
|
29 | - * Runs an external process. |
|
30 | - * |
|
31 | - * @param array|Process $cmd An instance of Process or an array of the command and arguments |
|
32 | - * @param callable|null $callback A PHP callback to run whenever there is some |
|
33 | - * output available on STDOUT or STDERR |
|
34 | - * |
|
35 | - * @return Process |
|
36 | - */ |
|
37 | - public function run(OutputInterface $output, $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process |
|
38 | - { |
|
39 | - if (!class_exists(Process::class)) { |
|
40 | - throw new \LogicException('The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".'); |
|
41 | - } |
|
42 | - |
|
43 | - if ($output instanceof ConsoleOutputInterface) { |
|
44 | - $output = $output->getErrorOutput(); |
|
45 | - } |
|
46 | - |
|
47 | - $formatter = $this->getHelperSet()->get('debug_formatter'); |
|
48 | - |
|
49 | - if ($cmd instanceof Process) { |
|
50 | - $cmd = [$cmd]; |
|
51 | - } |
|
52 | - |
|
53 | - if (!\is_array($cmd)) { |
|
54 | - throw new \TypeError(sprintf('The "command" argument of "%s()" must be an array or a "%s" instance, "%s" given.', __METHOD__, Process::class, get_debug_type($cmd))); |
|
55 | - } |
|
56 | - |
|
57 | - if (\is_string($cmd[0] ?? null)) { |
|
58 | - $process = new Process($cmd); |
|
59 | - $cmd = []; |
|
60 | - } elseif (($cmd[0] ?? null) instanceof Process) { |
|
61 | - $process = $cmd[0]; |
|
62 | - unset($cmd[0]); |
|
63 | - } else { |
|
64 | - throw new \InvalidArgumentException(sprintf('Invalid command provided to "%s()": the command should be an array whose first element is either the path to the binary to run or a "Process" object.', __METHOD__)); |
|
65 | - } |
|
66 | - |
|
67 | - if ($verbosity <= $output->getVerbosity()) { |
|
68 | - $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine()))); |
|
69 | - } |
|
70 | - |
|
71 | - if ($output->isDebug()) { |
|
72 | - $callback = $this->wrapCallback($output, $process, $callback); |
|
73 | - } |
|
74 | - |
|
75 | - $process->run($callback, $cmd); |
|
76 | - |
|
77 | - if ($verbosity <= $output->getVerbosity()) { |
|
78 | - $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode()); |
|
79 | - $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful())); |
|
80 | - } |
|
81 | - |
|
82 | - if (!$process->isSuccessful() && null !== $error) { |
|
83 | - $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error))); |
|
84 | - } |
|
85 | - |
|
86 | - return $process; |
|
87 | - } |
|
88 | - |
|
89 | - /** |
|
90 | - * Runs the process. |
|
91 | - * |
|
92 | - * This is identical to run() except that an exception is thrown if the process |
|
93 | - * exits with a non-zero exit code. |
|
94 | - * |
|
95 | - * @param array|Process $cmd An instance of Process or a command to run |
|
96 | - * @param callable|null $callback A PHP callback to run whenever there is some |
|
97 | - * output available on STDOUT or STDERR |
|
98 | - * |
|
99 | - * @return Process |
|
100 | - * |
|
101 | - * @throws ProcessFailedException |
|
102 | - * |
|
103 | - * @see run() |
|
104 | - */ |
|
105 | - public function mustRun(OutputInterface $output, $cmd, string $error = null, callable $callback = null): Process |
|
106 | - { |
|
107 | - $process = $this->run($output, $cmd, $error, $callback); |
|
108 | - |
|
109 | - if (!$process->isSuccessful()) { |
|
110 | - throw new ProcessFailedException($process); |
|
111 | - } |
|
112 | - |
|
113 | - return $process; |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Wraps a Process callback to add debugging output. |
|
118 | - */ |
|
119 | - public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null): callable |
|
120 | - { |
|
121 | - if ($output instanceof ConsoleOutputInterface) { |
|
122 | - $output = $output->getErrorOutput(); |
|
123 | - } |
|
124 | - |
|
125 | - $formatter = $this->getHelperSet()->get('debug_formatter'); |
|
126 | - |
|
127 | - return function ($type, $buffer) use ($output, $process, $callback, $formatter) { |
|
128 | - $output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type)); |
|
129 | - |
|
130 | - if (null !== $callback) { |
|
131 | - $callback($type, $buffer); |
|
132 | - } |
|
133 | - }; |
|
134 | - } |
|
135 | - |
|
136 | - private function escapeString(string $str): string |
|
137 | - { |
|
138 | - return str_replace('<', '\\<', $str); |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * {@inheritdoc} |
|
143 | - */ |
|
144 | - public function getName(): string |
|
145 | - { |
|
146 | - return 'process'; |
|
147 | - } |
|
28 | + /** |
|
29 | + * Runs an external process. |
|
30 | + * |
|
31 | + * @param array|Process $cmd An instance of Process or an array of the command and arguments |
|
32 | + * @param callable|null $callback A PHP callback to run whenever there is some |
|
33 | + * output available on STDOUT or STDERR |
|
34 | + * |
|
35 | + * @return Process |
|
36 | + */ |
|
37 | + public function run(OutputInterface $output, $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process |
|
38 | + { |
|
39 | + if (!class_exists(Process::class)) { |
|
40 | + throw new \LogicException('The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".'); |
|
41 | + } |
|
42 | + |
|
43 | + if ($output instanceof ConsoleOutputInterface) { |
|
44 | + $output = $output->getErrorOutput(); |
|
45 | + } |
|
46 | + |
|
47 | + $formatter = $this->getHelperSet()->get('debug_formatter'); |
|
48 | + |
|
49 | + if ($cmd instanceof Process) { |
|
50 | + $cmd = [$cmd]; |
|
51 | + } |
|
52 | + |
|
53 | + if (!\is_array($cmd)) { |
|
54 | + throw new \TypeError(sprintf('The "command" argument of "%s()" must be an array or a "%s" instance, "%s" given.', __METHOD__, Process::class, get_debug_type($cmd))); |
|
55 | + } |
|
56 | + |
|
57 | + if (\is_string($cmd[0] ?? null)) { |
|
58 | + $process = new Process($cmd); |
|
59 | + $cmd = []; |
|
60 | + } elseif (($cmd[0] ?? null) instanceof Process) { |
|
61 | + $process = $cmd[0]; |
|
62 | + unset($cmd[0]); |
|
63 | + } else { |
|
64 | + throw new \InvalidArgumentException(sprintf('Invalid command provided to "%s()": the command should be an array whose first element is either the path to the binary to run or a "Process" object.', __METHOD__)); |
|
65 | + } |
|
66 | + |
|
67 | + if ($verbosity <= $output->getVerbosity()) { |
|
68 | + $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine()))); |
|
69 | + } |
|
70 | + |
|
71 | + if ($output->isDebug()) { |
|
72 | + $callback = $this->wrapCallback($output, $process, $callback); |
|
73 | + } |
|
74 | + |
|
75 | + $process->run($callback, $cmd); |
|
76 | + |
|
77 | + if ($verbosity <= $output->getVerbosity()) { |
|
78 | + $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode()); |
|
79 | + $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful())); |
|
80 | + } |
|
81 | + |
|
82 | + if (!$process->isSuccessful() && null !== $error) { |
|
83 | + $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error))); |
|
84 | + } |
|
85 | + |
|
86 | + return $process; |
|
87 | + } |
|
88 | + |
|
89 | + /** |
|
90 | + * Runs the process. |
|
91 | + * |
|
92 | + * This is identical to run() except that an exception is thrown if the process |
|
93 | + * exits with a non-zero exit code. |
|
94 | + * |
|
95 | + * @param array|Process $cmd An instance of Process or a command to run |
|
96 | + * @param callable|null $callback A PHP callback to run whenever there is some |
|
97 | + * output available on STDOUT or STDERR |
|
98 | + * |
|
99 | + * @return Process |
|
100 | + * |
|
101 | + * @throws ProcessFailedException |
|
102 | + * |
|
103 | + * @see run() |
|
104 | + */ |
|
105 | + public function mustRun(OutputInterface $output, $cmd, string $error = null, callable $callback = null): Process |
|
106 | + { |
|
107 | + $process = $this->run($output, $cmd, $error, $callback); |
|
108 | + |
|
109 | + if (!$process->isSuccessful()) { |
|
110 | + throw new ProcessFailedException($process); |
|
111 | + } |
|
112 | + |
|
113 | + return $process; |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Wraps a Process callback to add debugging output. |
|
118 | + */ |
|
119 | + public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null): callable |
|
120 | + { |
|
121 | + if ($output instanceof ConsoleOutputInterface) { |
|
122 | + $output = $output->getErrorOutput(); |
|
123 | + } |
|
124 | + |
|
125 | + $formatter = $this->getHelperSet()->get('debug_formatter'); |
|
126 | + |
|
127 | + return function ($type, $buffer) use ($output, $process, $callback, $formatter) { |
|
128 | + $output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type)); |
|
129 | + |
|
130 | + if (null !== $callback) { |
|
131 | + $callback($type, $buffer); |
|
132 | + } |
|
133 | + }; |
|
134 | + } |
|
135 | + |
|
136 | + private function escapeString(string $str): string |
|
137 | + { |
|
138 | + return str_replace('<', '\\<', $str); |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * {@inheritdoc} |
|
143 | + */ |
|
144 | + public function getName(): string |
|
145 | + { |
|
146 | + return 'process'; |
|
147 | + } |
|
148 | 148 | } |
@@ -34,53 +34,53 @@ discard block |
||
34 | 34 | * |
35 | 35 | * @return Process |
36 | 36 | */ |
37 | - public function run(OutputInterface $output, $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE): Process |
|
37 | + public function run( OutputInterface $output, $cmd, string $error = null, callable $callback = null, int $verbosity = OutputInterface::VERBOSITY_VERY_VERBOSE ): Process |
|
38 | 38 | { |
39 | - if (!class_exists(Process::class)) { |
|
40 | - throw new \LogicException('The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".'); |
|
39 | + if ( ! class_exists( Process::class ) ) { |
|
40 | + throw new \LogicException( 'The ProcessHelper cannot be run as the Process component is not installed. Try running "compose require symfony/process".' ); |
|
41 | 41 | } |
42 | 42 | |
43 | - if ($output instanceof ConsoleOutputInterface) { |
|
43 | + if ( $output instanceof ConsoleOutputInterface ) { |
|
44 | 44 | $output = $output->getErrorOutput(); |
45 | 45 | } |
46 | 46 | |
47 | - $formatter = $this->getHelperSet()->get('debug_formatter'); |
|
47 | + $formatter = $this->getHelperSet()->get( 'debug_formatter' ); |
|
48 | 48 | |
49 | - if ($cmd instanceof Process) { |
|
50 | - $cmd = [$cmd]; |
|
49 | + if ( $cmd instanceof Process ) { |
|
50 | + $cmd = [ $cmd ]; |
|
51 | 51 | } |
52 | 52 | |
53 | - if (!\is_array($cmd)) { |
|
54 | - throw new \TypeError(sprintf('The "command" argument of "%s()" must be an array or a "%s" instance, "%s" given.', __METHOD__, Process::class, get_debug_type($cmd))); |
|
53 | + if ( ! \is_array( $cmd ) ) { |
|
54 | + throw new \TypeError( sprintf( 'The "command" argument of "%s()" must be an array or a "%s" instance, "%s" given.', __METHOD__, Process::class, get_debug_type( $cmd ) ) ); |
|
55 | 55 | } |
56 | 56 | |
57 | - if (\is_string($cmd[0] ?? null)) { |
|
58 | - $process = new Process($cmd); |
|
59 | - $cmd = []; |
|
60 | - } elseif (($cmd[0] ?? null) instanceof Process) { |
|
61 | - $process = $cmd[0]; |
|
62 | - unset($cmd[0]); |
|
57 | + if ( \is_string( $cmd[ 0 ] ?? null ) ) { |
|
58 | + $process = new Process( $cmd ); |
|
59 | + $cmd = [ ]; |
|
60 | + } elseif ( ( $cmd[ 0 ] ?? null ) instanceof Process ) { |
|
61 | + $process = $cmd[ 0 ]; |
|
62 | + unset( $cmd[ 0 ] ); |
|
63 | 63 | } else { |
64 | - throw new \InvalidArgumentException(sprintf('Invalid command provided to "%s()": the command should be an array whose first element is either the path to the binary to run or a "Process" object.', __METHOD__)); |
|
64 | + throw new \InvalidArgumentException( sprintf( 'Invalid command provided to "%s()": the command should be an array whose first element is either the path to the binary to run or a "Process" object.', __METHOD__ ) ); |
|
65 | 65 | } |
66 | 66 | |
67 | - if ($verbosity <= $output->getVerbosity()) { |
|
68 | - $output->write($formatter->start(spl_object_hash($process), $this->escapeString($process->getCommandLine()))); |
|
67 | + if ( $verbosity <= $output->getVerbosity() ) { |
|
68 | + $output->write( $formatter->start( spl_object_hash( $process ), $this->escapeString( $process->getCommandLine() ) ) ); |
|
69 | 69 | } |
70 | 70 | |
71 | - if ($output->isDebug()) { |
|
72 | - $callback = $this->wrapCallback($output, $process, $callback); |
|
71 | + if ( $output->isDebug() ) { |
|
72 | + $callback = $this->wrapCallback( $output, $process, $callback ); |
|
73 | 73 | } |
74 | 74 | |
75 | - $process->run($callback, $cmd); |
|
75 | + $process->run( $callback, $cmd ); |
|
76 | 76 | |
77 | - if ($verbosity <= $output->getVerbosity()) { |
|
78 | - $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf('%s Command did not run successfully', $process->getExitCode()); |
|
79 | - $output->write($formatter->stop(spl_object_hash($process), $message, $process->isSuccessful())); |
|
77 | + if ( $verbosity <= $output->getVerbosity() ) { |
|
78 | + $message = $process->isSuccessful() ? 'Command ran successfully' : sprintf( '%s Command did not run successfully', $process->getExitCode() ); |
|
79 | + $output->write( $formatter->stop( spl_object_hash( $process ), $message, $process->isSuccessful() ) ); |
|
80 | 80 | } |
81 | 81 | |
82 | - if (!$process->isSuccessful() && null !== $error) { |
|
83 | - $output->writeln(sprintf('<error>%s</error>', $this->escapeString($error))); |
|
82 | + if ( ! $process->isSuccessful() && null !== $error ) { |
|
83 | + $output->writeln( sprintf( '<error>%s</error>', $this->escapeString( $error ) ) ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $process; |
@@ -102,12 +102,12 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @see run() |
104 | 104 | */ |
105 | - public function mustRun(OutputInterface $output, $cmd, string $error = null, callable $callback = null): Process |
|
105 | + public function mustRun( OutputInterface $output, $cmd, string $error = null, callable $callback = null ): Process |
|
106 | 106 | { |
107 | - $process = $this->run($output, $cmd, $error, $callback); |
|
107 | + $process = $this->run( $output, $cmd, $error, $callback ); |
|
108 | 108 | |
109 | - if (!$process->isSuccessful()) { |
|
110 | - throw new ProcessFailedException($process); |
|
109 | + if ( ! $process->isSuccessful() ) { |
|
110 | + throw new ProcessFailedException( $process ); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | return $process; |
@@ -116,26 +116,26 @@ discard block |
||
116 | 116 | /** |
117 | 117 | * Wraps a Process callback to add debugging output. |
118 | 118 | */ |
119 | - public function wrapCallback(OutputInterface $output, Process $process, callable $callback = null): callable |
|
119 | + public function wrapCallback( OutputInterface $output, Process $process, callable $callback = null ): callable |
|
120 | 120 | { |
121 | - if ($output instanceof ConsoleOutputInterface) { |
|
121 | + if ( $output instanceof ConsoleOutputInterface ) { |
|
122 | 122 | $output = $output->getErrorOutput(); |
123 | 123 | } |
124 | 124 | |
125 | - $formatter = $this->getHelperSet()->get('debug_formatter'); |
|
125 | + $formatter = $this->getHelperSet()->get( 'debug_formatter' ); |
|
126 | 126 | |
127 | - return function ($type, $buffer) use ($output, $process, $callback, $formatter) { |
|
128 | - $output->write($formatter->progress(spl_object_hash($process), $this->escapeString($buffer), Process::ERR === $type)); |
|
127 | + return function( $type, $buffer ) use ( $output, $process, $callback, $formatter ) { |
|
128 | + $output->write( $formatter->progress( spl_object_hash( $process ), $this->escapeString( $buffer ), Process::ERR === $type ) ); |
|
129 | 129 | |
130 | - if (null !== $callback) { |
|
131 | - $callback($type, $buffer); |
|
130 | + if ( null !== $callback ) { |
|
131 | + $callback( $type, $buffer ); |
|
132 | 132 | } |
133 | 133 | }; |
134 | 134 | } |
135 | 135 | |
136 | - private function escapeString(string $str): string |
|
136 | + private function escapeString( string $str ): string |
|
137 | 137 | { |
138 | - return str_replace('<', '\\<', $str); |
|
138 | + return str_replace( '<', '\\<', $str ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | /** |
@@ -21,44 +21,44 @@ |
||
21 | 21 | */ |
22 | 22 | final class Dumper |
23 | 23 | { |
24 | - private $output; |
|
25 | - private $dumper; |
|
26 | - private $cloner; |
|
27 | - private $handler; |
|
24 | + private $output; |
|
25 | + private $dumper; |
|
26 | + private $cloner; |
|
27 | + private $handler; |
|
28 | 28 | |
29 | - public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null) |
|
30 | - { |
|
31 | - $this->output = $output; |
|
32 | - $this->dumper = $dumper; |
|
33 | - $this->cloner = $cloner; |
|
29 | + public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null) |
|
30 | + { |
|
31 | + $this->output = $output; |
|
32 | + $this->dumper = $dumper; |
|
33 | + $this->cloner = $cloner; |
|
34 | 34 | |
35 | - if (class_exists(CliDumper::class)) { |
|
36 | - $this->handler = function ($var): string { |
|
37 | - $dumper = $this->dumper ?? $this->dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR); |
|
38 | - $dumper->setColors($this->output->isDecorated()); |
|
35 | + if (class_exists(CliDumper::class)) { |
|
36 | + $this->handler = function ($var): string { |
|
37 | + $dumper = $this->dumper ?? $this->dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR); |
|
38 | + $dumper->setColors($this->output->isDecorated()); |
|
39 | 39 | |
40 | - return rtrim($dumper->dump(($this->cloner ?? $this->cloner = new VarCloner())->cloneVar($var)->withRefHandles(false), true)); |
|
41 | - }; |
|
42 | - } else { |
|
43 | - $this->handler = function ($var): string { |
|
44 | - switch (true) { |
|
45 | - case null === $var: |
|
46 | - return 'null'; |
|
47 | - case true === $var: |
|
48 | - return 'true'; |
|
49 | - case false === $var: |
|
50 | - return 'false'; |
|
51 | - case \is_string($var): |
|
52 | - return '"'.$var.'"'; |
|
53 | - default: |
|
54 | - return rtrim(print_r($var, true)); |
|
55 | - } |
|
56 | - }; |
|
57 | - } |
|
58 | - } |
|
40 | + return rtrim($dumper->dump(($this->cloner ?? $this->cloner = new VarCloner())->cloneVar($var)->withRefHandles(false), true)); |
|
41 | + }; |
|
42 | + } else { |
|
43 | + $this->handler = function ($var): string { |
|
44 | + switch (true) { |
|
45 | + case null === $var: |
|
46 | + return 'null'; |
|
47 | + case true === $var: |
|
48 | + return 'true'; |
|
49 | + case false === $var: |
|
50 | + return 'false'; |
|
51 | + case \is_string($var): |
|
52 | + return '"'.$var.'"'; |
|
53 | + default: |
|
54 | + return rtrim(print_r($var, true)); |
|
55 | + } |
|
56 | + }; |
|
57 | + } |
|
58 | + } |
|
59 | 59 | |
60 | - public function __invoke($var): string |
|
61 | - { |
|
62 | - return ($this->handler)($var); |
|
63 | - } |
|
60 | + public function __invoke($var): string |
|
61 | + { |
|
62 | + return ($this->handler)($var); |
|
63 | + } |
|
64 | 64 | } |
@@ -26,39 +26,39 @@ |
||
26 | 26 | private $cloner; |
27 | 27 | private $handler; |
28 | 28 | |
29 | - public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null) |
|
29 | + public function __construct( OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null ) |
|
30 | 30 | { |
31 | 31 | $this->output = $output; |
32 | 32 | $this->dumper = $dumper; |
33 | 33 | $this->cloner = $cloner; |
34 | 34 | |
35 | - if (class_exists(CliDumper::class)) { |
|
36 | - $this->handler = function ($var): string { |
|
37 | - $dumper = $this->dumper ?? $this->dumper = new CliDumper(null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR); |
|
38 | - $dumper->setColors($this->output->isDecorated()); |
|
35 | + if ( class_exists( CliDumper::class ) ) { |
|
36 | + $this->handler = function( $var ): string { |
|
37 | + $dumper = $this->dumper ?? $this->dumper = new CliDumper( null, null, CliDumper::DUMP_LIGHT_ARRAY | CliDumper::DUMP_COMMA_SEPARATOR ); |
|
38 | + $dumper->setColors( $this->output->isDecorated() ); |
|
39 | 39 | |
40 | - return rtrim($dumper->dump(($this->cloner ?? $this->cloner = new VarCloner())->cloneVar($var)->withRefHandles(false), true)); |
|
40 | + return rtrim( $dumper->dump( ( $this->cloner ?? $this->cloner = new VarCloner() )->cloneVar( $var )->withRefHandles( false ), true ) ); |
|
41 | 41 | }; |
42 | 42 | } else { |
43 | - $this->handler = function ($var): string { |
|
44 | - switch (true) { |
|
43 | + $this->handler = function( $var ): string { |
|
44 | + switch ( true ) { |
|
45 | 45 | case null === $var: |
46 | 46 | return 'null'; |
47 | 47 | case true === $var: |
48 | 48 | return 'true'; |
49 | 49 | case false === $var: |
50 | 50 | return 'false'; |
51 | - case \is_string($var): |
|
52 | - return '"'.$var.'"'; |
|
51 | + case \is_string( $var ): |
|
52 | + return '"' . $var . '"'; |
|
53 | 53 | default: |
54 | - return rtrim(print_r($var, true)); |
|
54 | + return rtrim( print_r( $var, true ) ); |
|
55 | 55 | } |
56 | 56 | }; |
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | - public function __invoke($var): string |
|
60 | + public function __invoke( $var ): string |
|
61 | 61 | { |
62 | - return ($this->handler)($var); |
|
62 | + return ( $this->handler )( $var ); |
|
63 | 63 | } |
64 | 64 | } |
@@ -19,15 +19,13 @@ |
||
19 | 19 | /** |
20 | 20 | * @author Roland Franssen <[email protected]> |
21 | 21 | */ |
22 | -final class Dumper |
|
23 | -{ |
|
22 | +final class Dumper { |
|
24 | 23 | private $output; |
25 | 24 | private $dumper; |
26 | 25 | private $cloner; |
27 | 26 | private $handler; |
28 | 27 | |
29 | - public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null) |
|
30 | - { |
|
28 | + public function __construct(OutputInterface $output, CliDumper $dumper = null, ClonerInterface $cloner = null) { |
|
31 | 29 | $this->output = $output; |
32 | 30 | $this->dumper = $dumper; |
33 | 31 | $this->cloner = $cloner; |
@@ -18,8 +18,8 @@ |
||
18 | 18 | */ |
19 | 19 | class TableSeparator extends TableCell |
20 | 20 | { |
21 | - public function __construct(array $options = []) |
|
22 | - { |
|
23 | - parent::__construct('', $options); |
|
24 | - } |
|
21 | + public function __construct(array $options = []) |
|
22 | + { |
|
23 | + parent::__construct('', $options); |
|
24 | + } |
|
25 | 25 | } |
@@ -18,8 +18,8 @@ |
||
18 | 18 | */ |
19 | 19 | class TableSeparator extends TableCell |
20 | 20 | { |
21 | - public function __construct(array $options = []) |
|
21 | + public function __construct( array $options = [ ] ) |
|
22 | 22 | { |
23 | - parent::__construct('', $options); |
|
23 | + parent::__construct( '', $options ); |
|
24 | 24 | } |
25 | 25 | } |
@@ -16,10 +16,8 @@ |
||
16 | 16 | * |
17 | 17 | * @author Fabien Potencier <[email protected]> |
18 | 18 | */ |
19 | -class TableSeparator extends TableCell |
|
20 | -{ |
|
21 | - public function __construct(array $options = []) |
|
22 | - { |
|
19 | +class TableSeparator extends TableCell { |
|
20 | + public function __construct(array $options = []) { |
|
23 | 21 | parent::__construct('', $options); |
24 | 22 | } |
25 | 23 | } |
@@ -21,13 +21,13 @@ |
||
21 | 21 | */ |
22 | 22 | abstract class InputAwareHelper extends Helper implements InputAwareInterface |
23 | 23 | { |
24 | - protected $input; |
|
24 | + protected $input; |
|
25 | 25 | |
26 | - /** |
|
27 | - * {@inheritdoc} |
|
28 | - */ |
|
29 | - public function setInput(InputInterface $input) |
|
30 | - { |
|
31 | - $this->input = $input; |
|
32 | - } |
|
26 | + /** |
|
27 | + * {@inheritdoc} |
|
28 | + */ |
|
29 | + public function setInput(InputInterface $input) |
|
30 | + { |
|
31 | + $this->input = $input; |
|
32 | + } |
|
33 | 33 | } |
@@ -26,7 +26,7 @@ |
||
26 | 26 | /** |
27 | 27 | * {@inheritdoc} |
28 | 28 | */ |
29 | - public function setInput(InputInterface $input) |
|
29 | + public function setInput( InputInterface $input ) |
|
30 | 30 | { |
31 | 31 | $this->input = $input; |
32 | 32 | } |
@@ -19,15 +19,13 @@ |
||
19 | 19 | * |
20 | 20 | * @author Wouter J <[email protected]> |
21 | 21 | */ |
22 | -abstract class InputAwareHelper extends Helper implements InputAwareInterface |
|
23 | -{ |
|
22 | +abstract class InputAwareHelper extends Helper implements InputAwareInterface { |
|
24 | 23 | protected $input; |
25 | 24 | |
26 | 25 | /** |
27 | 26 | * {@inheritdoc} |
28 | 27 | */ |
29 | - public function setInput(InputInterface $input) |
|
30 | - { |
|
28 | + public function setInput(InputInterface $input) { |
|
31 | 29 | $this->input = $input; |
32 | 30 | } |
33 | 31 | } |
@@ -18,61 +18,61 @@ |
||
18 | 18 | */ |
19 | 19 | class TableCell |
20 | 20 | { |
21 | - private $value; |
|
22 | - private $options = [ |
|
23 | - 'rowspan' => 1, |
|
24 | - 'colspan' => 1, |
|
25 | - 'style' => null, |
|
26 | - ]; |
|
21 | + private $value; |
|
22 | + private $options = [ |
|
23 | + 'rowspan' => 1, |
|
24 | + 'colspan' => 1, |
|
25 | + 'style' => null, |
|
26 | + ]; |
|
27 | 27 | |
28 | - public function __construct(string $value = '', array $options = []) |
|
29 | - { |
|
30 | - $this->value = $value; |
|
28 | + public function __construct(string $value = '', array $options = []) |
|
29 | + { |
|
30 | + $this->value = $value; |
|
31 | 31 | |
32 | - // check option names |
|
33 | - if ($diff = array_diff(array_keys($options), array_keys($this->options))) { |
|
34 | - throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff))); |
|
35 | - } |
|
32 | + // check option names |
|
33 | + if ($diff = array_diff(array_keys($options), array_keys($this->options))) { |
|
34 | + throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff))); |
|
35 | + } |
|
36 | 36 | |
37 | - if (isset($options['style']) && !$options['style'] instanceof TableCellStyle) { |
|
38 | - throw new InvalidArgumentException('The style option must be an instance of "TableCellStyle".'); |
|
39 | - } |
|
37 | + if (isset($options['style']) && !$options['style'] instanceof TableCellStyle) { |
|
38 | + throw new InvalidArgumentException('The style option must be an instance of "TableCellStyle".'); |
|
39 | + } |
|
40 | 40 | |
41 | - $this->options = array_merge($this->options, $options); |
|
42 | - } |
|
41 | + $this->options = array_merge($this->options, $options); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * Returns the cell value. |
|
46 | - * |
|
47 | - * @return string |
|
48 | - */ |
|
49 | - public function __toString() |
|
50 | - { |
|
51 | - return $this->value; |
|
52 | - } |
|
44 | + /** |
|
45 | + * Returns the cell value. |
|
46 | + * |
|
47 | + * @return string |
|
48 | + */ |
|
49 | + public function __toString() |
|
50 | + { |
|
51 | + return $this->value; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Gets number of colspan. |
|
56 | - * |
|
57 | - * @return int |
|
58 | - */ |
|
59 | - public function getColspan() |
|
60 | - { |
|
61 | - return (int) $this->options['colspan']; |
|
62 | - } |
|
54 | + /** |
|
55 | + * Gets number of colspan. |
|
56 | + * |
|
57 | + * @return int |
|
58 | + */ |
|
59 | + public function getColspan() |
|
60 | + { |
|
61 | + return (int) $this->options['colspan']; |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * Gets number of rowspan. |
|
66 | - * |
|
67 | - * @return int |
|
68 | - */ |
|
69 | - public function getRowspan() |
|
70 | - { |
|
71 | - return (int) $this->options['rowspan']; |
|
72 | - } |
|
64 | + /** |
|
65 | + * Gets number of rowspan. |
|
66 | + * |
|
67 | + * @return int |
|
68 | + */ |
|
69 | + public function getRowspan() |
|
70 | + { |
|
71 | + return (int) $this->options['rowspan']; |
|
72 | + } |
|
73 | 73 | |
74 | - public function getStyle(): ?TableCellStyle |
|
75 | - { |
|
76 | - return $this->options['style']; |
|
77 | - } |
|
74 | + public function getStyle(): ?TableCellStyle |
|
75 | + { |
|
76 | + return $this->options['style']; |
|
77 | + } |
|
78 | 78 | } |
@@ -25,20 +25,20 @@ discard block |
||
25 | 25 | 'style' => null, |
26 | 26 | ]; |
27 | 27 | |
28 | - public function __construct(string $value = '', array $options = []) |
|
28 | + public function __construct( string $value = '', array $options = [ ] ) |
|
29 | 29 | { |
30 | 30 | $this->value = $value; |
31 | 31 | |
32 | 32 | // check option names |
33 | - if ($diff = array_diff(array_keys($options), array_keys($this->options))) { |
|
34 | - throw new InvalidArgumentException(sprintf('The TableCell does not support the following options: \'%s\'.', implode('\', \'', $diff))); |
|
33 | + if ( $diff = array_diff( array_keys( $options ), array_keys( $this->options ) ) ) { |
|
34 | + throw new InvalidArgumentException( sprintf( 'The TableCell does not support the following options: \'%s\'.', implode( '\', \'', $diff ) ) ); |
|
35 | 35 | } |
36 | 36 | |
37 | - if (isset($options['style']) && !$options['style'] instanceof TableCellStyle) { |
|
38 | - throw new InvalidArgumentException('The style option must be an instance of "TableCellStyle".'); |
|
37 | + if ( isset( $options[ 'style' ] ) && ! $options[ 'style' ] instanceof TableCellStyle ) { |
|
38 | + throw new InvalidArgumentException( 'The style option must be an instance of "TableCellStyle".' ); |
|
39 | 39 | } |
40 | 40 | |
41 | - $this->options = array_merge($this->options, $options); |
|
41 | + $this->options = array_merge( $this->options, $options ); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | */ |
59 | 59 | public function getColspan() |
60 | 60 | { |
61 | - return (int) $this->options['colspan']; |
|
61 | + return (int)$this->options[ 'colspan' ]; |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -68,11 +68,11 @@ discard block |
||
68 | 68 | */ |
69 | 69 | public function getRowspan() |
70 | 70 | { |
71 | - return (int) $this->options['rowspan']; |
|
71 | + return (int)$this->options[ 'rowspan' ]; |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | public function getStyle(): ?TableCellStyle |
75 | 75 | { |
76 | - return $this->options['style']; |
|
76 | + return $this->options[ 'style' ]; |
|
77 | 77 | } |
78 | 78 | } |
@@ -16,8 +16,7 @@ discard block |
||
16 | 16 | /** |
17 | 17 | * @author Abdellatif Ait boudad <[email protected]> |
18 | 18 | */ |
19 | -class TableCell |
|
20 | -{ |
|
19 | +class TableCell { |
|
21 | 20 | private $value; |
22 | 21 | private $options = [ |
23 | 22 | 'rowspan' => 1, |
@@ -25,8 +24,7 @@ discard block |
||
25 | 24 | 'style' => null, |
26 | 25 | ]; |
27 | 26 | |
28 | - public function __construct(string $value = '', array $options = []) |
|
29 | - { |
|
27 | + public function __construct(string $value = '', array $options = []) { |
|
30 | 28 | $this->value = $value; |
31 | 29 | |
32 | 30 | // check option names |
@@ -46,8 +44,7 @@ discard block |
||
46 | 44 | * |
47 | 45 | * @return string |
48 | 46 | */ |
49 | - public function __toString() |
|
50 | - { |
|
47 | + public function __toString() { |
|
51 | 48 | return $this->value; |
52 | 49 | } |
53 | 50 | |
@@ -56,8 +53,7 @@ discard block |
||
56 | 53 | * |
57 | 54 | * @return int |
58 | 55 | */ |
59 | - public function getColspan() |
|
60 | - { |
|
56 | + public function getColspan() { |
|
61 | 57 | return (int) $this->options['colspan']; |
62 | 58 | } |
63 | 59 | |
@@ -66,8 +62,7 @@ discard block |
||
66 | 62 | * |
67 | 63 | * @return int |
68 | 64 | */ |
69 | - public function getRowspan() |
|
70 | - { |
|
65 | + public function getRowspan() { |
|
71 | 66 | return (int) $this->options['rowspan']; |
72 | 67 | } |
73 | 68 |
@@ -25,85 +25,85 @@ |
||
25 | 25 | */ |
26 | 26 | class SymfonyQuestionHelper extends QuestionHelper |
27 | 27 | { |
28 | - /** |
|
29 | - * {@inheritdoc} |
|
30 | - */ |
|
31 | - protected function writePrompt(OutputInterface $output, Question $question) |
|
32 | - { |
|
33 | - $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion()); |
|
34 | - $default = $question->getDefault(); |
|
28 | + /** |
|
29 | + * {@inheritdoc} |
|
30 | + */ |
|
31 | + protected function writePrompt(OutputInterface $output, Question $question) |
|
32 | + { |
|
33 | + $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion()); |
|
34 | + $default = $question->getDefault(); |
|
35 | 35 | |
36 | - if ($question->isMultiline()) { |
|
37 | - $text .= sprintf(' (press %s to continue)', $this->getEofShortcut()); |
|
38 | - } |
|
36 | + if ($question->isMultiline()) { |
|
37 | + $text .= sprintf(' (press %s to continue)', $this->getEofShortcut()); |
|
38 | + } |
|
39 | 39 | |
40 | - switch (true) { |
|
41 | - case null === $default: |
|
42 | - $text = sprintf(' <info>%s</info>:', $text); |
|
40 | + switch (true) { |
|
41 | + case null === $default: |
|
42 | + $text = sprintf(' <info>%s</info>:', $text); |
|
43 | 43 | |
44 | - break; |
|
44 | + break; |
|
45 | 45 | |
46 | - case $question instanceof ConfirmationQuestion: |
|
47 | - $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no'); |
|
46 | + case $question instanceof ConfirmationQuestion: |
|
47 | + $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no'); |
|
48 | 48 | |
49 | - break; |
|
49 | + break; |
|
50 | 50 | |
51 | - case $question instanceof ChoiceQuestion && $question->isMultiselect(): |
|
52 | - $choices = $question->getChoices(); |
|
53 | - $default = explode(',', $default); |
|
51 | + case $question instanceof ChoiceQuestion && $question->isMultiselect(): |
|
52 | + $choices = $question->getChoices(); |
|
53 | + $default = explode(',', $default); |
|
54 | 54 | |
55 | - foreach ($default as $key => $value) { |
|
56 | - $default[$key] = $choices[trim($value)]; |
|
57 | - } |
|
55 | + foreach ($default as $key => $value) { |
|
56 | + $default[$key] = $choices[trim($value)]; |
|
57 | + } |
|
58 | 58 | |
59 | - $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default))); |
|
59 | + $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default))); |
|
60 | 60 | |
61 | - break; |
|
61 | + break; |
|
62 | 62 | |
63 | - case $question instanceof ChoiceQuestion: |
|
64 | - $choices = $question->getChoices(); |
|
65 | - $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($choices[$default] ?? $default)); |
|
63 | + case $question instanceof ChoiceQuestion: |
|
64 | + $choices = $question->getChoices(); |
|
65 | + $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($choices[$default] ?? $default)); |
|
66 | 66 | |
67 | - break; |
|
67 | + break; |
|
68 | 68 | |
69 | - default: |
|
70 | - $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default)); |
|
71 | - } |
|
69 | + default: |
|
70 | + $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default)); |
|
71 | + } |
|
72 | 72 | |
73 | - $output->writeln($text); |
|
73 | + $output->writeln($text); |
|
74 | 74 | |
75 | - $prompt = ' > '; |
|
75 | + $prompt = ' > '; |
|
76 | 76 | |
77 | - if ($question instanceof ChoiceQuestion) { |
|
78 | - $output->writeln($this->formatChoiceQuestionChoices($question, 'comment')); |
|
77 | + if ($question instanceof ChoiceQuestion) { |
|
78 | + $output->writeln($this->formatChoiceQuestionChoices($question, 'comment')); |
|
79 | 79 | |
80 | - $prompt = $question->getPrompt(); |
|
81 | - } |
|
80 | + $prompt = $question->getPrompt(); |
|
81 | + } |
|
82 | 82 | |
83 | - $output->write($prompt); |
|
84 | - } |
|
83 | + $output->write($prompt); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * {@inheritdoc} |
|
88 | - */ |
|
89 | - protected function writeError(OutputInterface $output, \Exception $error) |
|
90 | - { |
|
91 | - if ($output instanceof SymfonyStyle) { |
|
92 | - $output->newLine(); |
|
93 | - $output->error($error->getMessage()); |
|
86 | + /** |
|
87 | + * {@inheritdoc} |
|
88 | + */ |
|
89 | + protected function writeError(OutputInterface $output, \Exception $error) |
|
90 | + { |
|
91 | + if ($output instanceof SymfonyStyle) { |
|
92 | + $output->newLine(); |
|
93 | + $output->error($error->getMessage()); |
|
94 | 94 | |
95 | - return; |
|
96 | - } |
|
95 | + return; |
|
96 | + } |
|
97 | 97 | |
98 | - parent::writeError($output, $error); |
|
99 | - } |
|
98 | + parent::writeError($output, $error); |
|
99 | + } |
|
100 | 100 | |
101 | - private function getEofShortcut(): string |
|
102 | - { |
|
103 | - if ('Windows' === \PHP_OS_FAMILY) { |
|
104 | - return '<comment>Ctrl+Z</comment> then <comment>Enter</comment>'; |
|
105 | - } |
|
101 | + private function getEofShortcut(): string |
|
102 | + { |
|
103 | + if ('Windows' === \PHP_OS_FAMILY) { |
|
104 | + return '<comment>Ctrl+Z</comment> then <comment>Enter</comment>'; |
|
105 | + } |
|
106 | 106 | |
107 | - return '<comment>Ctrl+D</comment>'; |
|
108 | - } |
|
107 | + return '<comment>Ctrl+D</comment>'; |
|
108 | + } |
|
109 | 109 | } |
@@ -28,79 +28,79 @@ |
||
28 | 28 | /** |
29 | 29 | * {@inheritdoc} |
30 | 30 | */ |
31 | - protected function writePrompt(OutputInterface $output, Question $question) |
|
31 | + protected function writePrompt( OutputInterface $output, Question $question ) |
|
32 | 32 | { |
33 | - $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion()); |
|
33 | + $text = OutputFormatter::escapeTrailingBackslash( $question->getQuestion() ); |
|
34 | 34 | $default = $question->getDefault(); |
35 | 35 | |
36 | - if ($question->isMultiline()) { |
|
37 | - $text .= sprintf(' (press %s to continue)', $this->getEofShortcut()); |
|
36 | + if ( $question->isMultiline() ) { |
|
37 | + $text .= sprintf( ' (press %s to continue)', $this->getEofShortcut() ); |
|
38 | 38 | } |
39 | 39 | |
40 | - switch (true) { |
|
40 | + switch ( true ) { |
|
41 | 41 | case null === $default: |
42 | - $text = sprintf(' <info>%s</info>:', $text); |
|
42 | + $text = sprintf( ' <info>%s</info>:', $text ); |
|
43 | 43 | |
44 | 44 | break; |
45 | 45 | |
46 | 46 | case $question instanceof ConfirmationQuestion: |
47 | - $text = sprintf(' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no'); |
|
47 | + $text = sprintf( ' <info>%s (yes/no)</info> [<comment>%s</comment>]:', $text, $default ? 'yes' : 'no' ); |
|
48 | 48 | |
49 | 49 | break; |
50 | 50 | |
51 | 51 | case $question instanceof ChoiceQuestion && $question->isMultiselect(): |
52 | 52 | $choices = $question->getChoices(); |
53 | - $default = explode(',', $default); |
|
53 | + $default = explode( ',', $default ); |
|
54 | 54 | |
55 | - foreach ($default as $key => $value) { |
|
56 | - $default[$key] = $choices[trim($value)]; |
|
55 | + foreach ( $default as $key => $value ) { |
|
56 | + $default[ $key ] = $choices[ trim( $value ) ]; |
|
57 | 57 | } |
58 | 58 | |
59 | - $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape(implode(', ', $default))); |
|
59 | + $text = sprintf( ' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape( implode( ', ', $default ) ) ); |
|
60 | 60 | |
61 | 61 | break; |
62 | 62 | |
63 | 63 | case $question instanceof ChoiceQuestion: |
64 | 64 | $choices = $question->getChoices(); |
65 | - $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($choices[$default] ?? $default)); |
|
65 | + $text = sprintf( ' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape( $choices[ $default ] ?? $default ) ); |
|
66 | 66 | |
67 | 67 | break; |
68 | 68 | |
69 | 69 | default: |
70 | - $text = sprintf(' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape($default)); |
|
70 | + $text = sprintf( ' <info>%s</info> [<comment>%s</comment>]:', $text, OutputFormatter::escape( $default ) ); |
|
71 | 71 | } |
72 | 72 | |
73 | - $output->writeln($text); |
|
73 | + $output->writeln( $text ); |
|
74 | 74 | |
75 | 75 | $prompt = ' > '; |
76 | 76 | |
77 | - if ($question instanceof ChoiceQuestion) { |
|
78 | - $output->writeln($this->formatChoiceQuestionChoices($question, 'comment')); |
|
77 | + if ( $question instanceof ChoiceQuestion ) { |
|
78 | + $output->writeln( $this->formatChoiceQuestionChoices( $question, 'comment' ) ); |
|
79 | 79 | |
80 | 80 | $prompt = $question->getPrompt(); |
81 | 81 | } |
82 | 82 | |
83 | - $output->write($prompt); |
|
83 | + $output->write( $prompt ); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | /** |
87 | 87 | * {@inheritdoc} |
88 | 88 | */ |
89 | - protected function writeError(OutputInterface $output, \Exception $error) |
|
89 | + protected function writeError( OutputInterface $output, \Exception $error ) |
|
90 | 90 | { |
91 | - if ($output instanceof SymfonyStyle) { |
|
91 | + if ( $output instanceof SymfonyStyle ) { |
|
92 | 92 | $output->newLine(); |
93 | - $output->error($error->getMessage()); |
|
93 | + $output->error( $error->getMessage() ); |
|
94 | 94 | |
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | - parent::writeError($output, $error); |
|
98 | + parent::writeError( $output, $error ); |
|
99 | 99 | } |
100 | 100 | |
101 | 101 | private function getEofShortcut(): string |
102 | 102 | { |
103 | - if ('Windows' === \PHP_OS_FAMILY) { |
|
103 | + if ( 'Windows' === \PHP_OS_FAMILY ) { |
|
104 | 104 | return '<comment>Ctrl+Z</comment> then <comment>Enter</comment>'; |
105 | 105 | } |
106 | 106 |
@@ -23,13 +23,11 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @author Kevin Bond <[email protected]> |
25 | 25 | */ |
26 | -class SymfonyQuestionHelper extends QuestionHelper |
|
27 | -{ |
|
26 | +class SymfonyQuestionHelper extends QuestionHelper { |
|
28 | 27 | /** |
29 | 28 | * {@inheritdoc} |
30 | 29 | */ |
31 | - protected function writePrompt(OutputInterface $output, Question $question) |
|
32 | - { |
|
30 | + protected function writePrompt(OutputInterface $output, Question $question) { |
|
33 | 31 | $text = OutputFormatter::escapeTrailingBackslash($question->getQuestion()); |
34 | 32 | $default = $question->getDefault(); |
35 | 33 | |
@@ -86,8 +84,7 @@ discard block |
||
86 | 84 | /** |
87 | 85 | * {@inheritdoc} |
88 | 86 | */ |
89 | - protected function writeError(OutputInterface $output, \Exception $error) |
|
90 | - { |
|
87 | + protected function writeError(OutputInterface $output, \Exception $error) { |
|
91 | 88 | if ($output instanceof SymfonyStyle) { |
92 | 89 | $output->newLine(); |
93 | 90 | $output->error($error->getMessage()); |
@@ -21,8 +21,7 @@ discard block |
||
21 | 21 | * @author Саша Стаменковић <[email protected]> |
22 | 22 | * @author Dany Maillard <[email protected]> |
23 | 23 | */ |
24 | -class TableStyle |
|
25 | -{ |
|
24 | +class TableStyle { |
|
26 | 25 | private $paddingChar = ' '; |
27 | 26 | private $horizontalOutsideBorderChar = '-'; |
28 | 27 | private $horizontalInsideBorderChar = '-'; |
@@ -53,8 +52,7 @@ discard block |
||
53 | 52 | * |
54 | 53 | * @return $this |
55 | 54 | */ |
56 | - public function setPaddingChar(string $paddingChar) |
|
57 | - { |
|
55 | + public function setPaddingChar(string $paddingChar) { |
|
58 | 56 | if (!$paddingChar) { |
59 | 57 | throw new LogicException('The padding char must not be empty.'); |
60 | 58 | } |
@@ -69,8 +67,7 @@ discard block |
||
69 | 67 | * |
70 | 68 | * @return string |
71 | 69 | */ |
72 | - public function getPaddingChar() |
|
73 | - { |
|
70 | + public function getPaddingChar() { |
|
74 | 71 | return $this->paddingChar; |
75 | 72 | } |
76 | 73 | |
@@ -196,8 +193,7 @@ discard block |
||
196 | 193 | * |
197 | 194 | * @return string |
198 | 195 | */ |
199 | - public function getCrossingChar() |
|
200 | - { |
|
196 | + public function getCrossingChar() { |
|
201 | 197 | return $this->crossingChar; |
202 | 198 | } |
203 | 199 | |
@@ -229,8 +225,7 @@ discard block |
||
229 | 225 | * |
230 | 226 | * @return $this |
231 | 227 | */ |
232 | - public function setCellHeaderFormat(string $cellHeaderFormat) |
|
233 | - { |
|
228 | + public function setCellHeaderFormat(string $cellHeaderFormat) { |
|
234 | 229 | $this->cellHeaderFormat = $cellHeaderFormat; |
235 | 230 | |
236 | 231 | return $this; |
@@ -241,8 +236,7 @@ discard block |
||
241 | 236 | * |
242 | 237 | * @return string |
243 | 238 | */ |
244 | - public function getCellHeaderFormat() |
|
245 | - { |
|
239 | + public function getCellHeaderFormat() { |
|
246 | 240 | return $this->cellHeaderFormat; |
247 | 241 | } |
248 | 242 | |
@@ -251,8 +245,7 @@ discard block |
||
251 | 245 | * |
252 | 246 | * @return $this |
253 | 247 | */ |
254 | - public function setCellRowFormat(string $cellRowFormat) |
|
255 | - { |
|
248 | + public function setCellRowFormat(string $cellRowFormat) { |
|
256 | 249 | $this->cellRowFormat = $cellRowFormat; |
257 | 250 | |
258 | 251 | return $this; |
@@ -263,8 +256,7 @@ discard block |
||
263 | 256 | * |
264 | 257 | * @return string |
265 | 258 | */ |
266 | - public function getCellRowFormat() |
|
267 | - { |
|
259 | + public function getCellRowFormat() { |
|
268 | 260 | return $this->cellRowFormat; |
269 | 261 | } |
270 | 262 | |
@@ -273,8 +265,7 @@ discard block |
||
273 | 265 | * |
274 | 266 | * @return $this |
275 | 267 | */ |
276 | - public function setCellRowContentFormat(string $cellRowContentFormat) |
|
277 | - { |
|
268 | + public function setCellRowContentFormat(string $cellRowContentFormat) { |
|
278 | 269 | $this->cellRowContentFormat = $cellRowContentFormat; |
279 | 270 | |
280 | 271 | return $this; |
@@ -285,8 +276,7 @@ discard block |
||
285 | 276 | * |
286 | 277 | * @return string |
287 | 278 | */ |
288 | - public function getCellRowContentFormat() |
|
289 | - { |
|
279 | + public function getCellRowContentFormat() { |
|
290 | 280 | return $this->cellRowContentFormat; |
291 | 281 | } |
292 | 282 | |
@@ -295,8 +285,7 @@ discard block |
||
295 | 285 | * |
296 | 286 | * @return $this |
297 | 287 | */ |
298 | - public function setBorderFormat(string $borderFormat) |
|
299 | - { |
|
288 | + public function setBorderFormat(string $borderFormat) { |
|
300 | 289 | $this->borderFormat = $borderFormat; |
301 | 290 | |
302 | 291 | return $this; |
@@ -307,8 +296,7 @@ discard block |
||
307 | 296 | * |
308 | 297 | * @return string |
309 | 298 | */ |
310 | - public function getBorderFormat() |
|
311 | - { |
|
299 | + public function getBorderFormat() { |
|
312 | 300 | return $this->borderFormat; |
313 | 301 | } |
314 | 302 | |
@@ -317,8 +305,7 @@ discard block |
||
317 | 305 | * |
318 | 306 | * @return $this |
319 | 307 | */ |
320 | - public function setPadType(int $padType) |
|
321 | - { |
|
308 | + public function setPadType(int $padType) { |
|
322 | 309 | if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) { |
323 | 310 | throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); |
324 | 311 | } |
@@ -333,8 +320,7 @@ discard block |
||
333 | 320 | * |
334 | 321 | * @return int |
335 | 322 | */ |
336 | - public function getPadType() |
|
337 | - { |
|
323 | + public function getPadType() { |
|
338 | 324 | return $this->padType; |
339 | 325 | } |
340 | 326 |
@@ -23,354 +23,354 @@ |
||
23 | 23 | */ |
24 | 24 | class TableStyle |
25 | 25 | { |
26 | - private $paddingChar = ' '; |
|
27 | - private $horizontalOutsideBorderChar = '-'; |
|
28 | - private $horizontalInsideBorderChar = '-'; |
|
29 | - private $verticalOutsideBorderChar = '|'; |
|
30 | - private $verticalInsideBorderChar = '|'; |
|
31 | - private $crossingChar = '+'; |
|
32 | - private $crossingTopRightChar = '+'; |
|
33 | - private $crossingTopMidChar = '+'; |
|
34 | - private $crossingTopLeftChar = '+'; |
|
35 | - private $crossingMidRightChar = '+'; |
|
36 | - private $crossingBottomRightChar = '+'; |
|
37 | - private $crossingBottomMidChar = '+'; |
|
38 | - private $crossingBottomLeftChar = '+'; |
|
39 | - private $crossingMidLeftChar = '+'; |
|
40 | - private $crossingTopLeftBottomChar = '+'; |
|
41 | - private $crossingTopMidBottomChar = '+'; |
|
42 | - private $crossingTopRightBottomChar = '+'; |
|
43 | - private $headerTitleFormat = '<fg=black;bg=white;options=bold> %s </>'; |
|
44 | - private $footerTitleFormat = '<fg=black;bg=white;options=bold> %s </>'; |
|
45 | - private $cellHeaderFormat = '<info>%s</info>'; |
|
46 | - private $cellRowFormat = '%s'; |
|
47 | - private $cellRowContentFormat = ' %s '; |
|
48 | - private $borderFormat = '%s'; |
|
49 | - private $padType = \STR_PAD_RIGHT; |
|
50 | - |
|
51 | - /** |
|
52 | - * Sets padding character, used for cell padding. |
|
53 | - * |
|
54 | - * @return $this |
|
55 | - */ |
|
56 | - public function setPaddingChar(string $paddingChar) |
|
57 | - { |
|
58 | - if (!$paddingChar) { |
|
59 | - throw new LogicException('The padding char must not be empty.'); |
|
60 | - } |
|
61 | - |
|
62 | - $this->paddingChar = $paddingChar; |
|
63 | - |
|
64 | - return $this; |
|
65 | - } |
|
66 | - |
|
67 | - /** |
|
68 | - * Gets padding character, used for cell padding. |
|
69 | - * |
|
70 | - * @return string |
|
71 | - */ |
|
72 | - public function getPaddingChar() |
|
73 | - { |
|
74 | - return $this->paddingChar; |
|
75 | - } |
|
76 | - |
|
77 | - /** |
|
78 | - * Sets horizontal border characters. |
|
79 | - * |
|
80 | - * <code> |
|
81 | - * ╔═══════════════╤══════════════════════════╤══════════════════╗ |
|
82 | - * 1 ISBN 2 Title │ Author ║ |
|
83 | - * ╠═══════════════╪══════════════════════════╪══════════════════╣ |
|
84 | - * ║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║ |
|
85 | - * ║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║ |
|
86 | - * ║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║ |
|
87 | - * ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║ |
|
88 | - * ╚═══════════════╧══════════════════════════╧══════════════════╝ |
|
89 | - * </code> |
|
90 | - * |
|
91 | - * @return $this |
|
92 | - */ |
|
93 | - public function setHorizontalBorderChars(string $outside, string $inside = null): self |
|
94 | - { |
|
95 | - $this->horizontalOutsideBorderChar = $outside; |
|
96 | - $this->horizontalInsideBorderChar = $inside ?? $outside; |
|
97 | - |
|
98 | - return $this; |
|
99 | - } |
|
100 | - |
|
101 | - /** |
|
102 | - * Sets vertical border characters. |
|
103 | - * |
|
104 | - * <code> |
|
105 | - * ╔═══════════════╤══════════════════════════╤══════════════════╗ |
|
106 | - * ║ ISBN │ Title │ Author ║ |
|
107 | - * ╠═══════1═══════╪══════════════════════════╪══════════════════╣ |
|
108 | - * ║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║ |
|
109 | - * ║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║ |
|
110 | - * ╟───────2───────┼──────────────────────────┼──────────────────╢ |
|
111 | - * ║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║ |
|
112 | - * ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║ |
|
113 | - * ╚═══════════════╧══════════════════════════╧══════════════════╝ |
|
114 | - * </code> |
|
115 | - * |
|
116 | - * @return $this |
|
117 | - */ |
|
118 | - public function setVerticalBorderChars(string $outside, string $inside = null): self |
|
119 | - { |
|
120 | - $this->verticalOutsideBorderChar = $outside; |
|
121 | - $this->verticalInsideBorderChar = $inside ?? $outside; |
|
122 | - |
|
123 | - return $this; |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Gets border characters. |
|
128 | - * |
|
129 | - * @internal |
|
130 | - */ |
|
131 | - public function getBorderChars(): array |
|
132 | - { |
|
133 | - return [ |
|
134 | - $this->horizontalOutsideBorderChar, |
|
135 | - $this->verticalOutsideBorderChar, |
|
136 | - $this->horizontalInsideBorderChar, |
|
137 | - $this->verticalInsideBorderChar, |
|
138 | - ]; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Sets crossing characters. |
|
143 | - * |
|
144 | - * Example: |
|
145 | - * <code> |
|
146 | - * 1═══════════════2══════════════════════════2══════════════════3 |
|
147 | - * ║ ISBN │ Title │ Author ║ |
|
148 | - * 8'══════════════0'═════════════════════════0'═════════════════4' |
|
149 | - * ║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║ |
|
150 | - * ║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║ |
|
151 | - * 8───────────────0──────────────────────────0──────────────────4 |
|
152 | - * ║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║ |
|
153 | - * ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║ |
|
154 | - * 7═══════════════6══════════════════════════6══════════════════5 |
|
155 | - * </code> |
|
156 | - * |
|
157 | - * @param string $cross Crossing char (see #0 of example) |
|
158 | - * @param string $topLeft Top left char (see #1 of example) |
|
159 | - * @param string $topMid Top mid char (see #2 of example) |
|
160 | - * @param string $topRight Top right char (see #3 of example) |
|
161 | - * @param string $midRight Mid right char (see #4 of example) |
|
162 | - * @param string $bottomRight Bottom right char (see #5 of example) |
|
163 | - * @param string $bottomMid Bottom mid char (see #6 of example) |
|
164 | - * @param string $bottomLeft Bottom left char (see #7 of example) |
|
165 | - * @param string $midLeft Mid left char (see #8 of example) |
|
166 | - * @param string|null $topLeftBottom Top left bottom char (see #8' of example), equals to $midLeft if null |
|
167 | - * @param string|null $topMidBottom Top mid bottom char (see #0' of example), equals to $cross if null |
|
168 | - * @param string|null $topRightBottom Top right bottom char (see #4' of example), equals to $midRight if null |
|
169 | - * |
|
170 | - * @return $this |
|
171 | - */ |
|
172 | - public function setCrossingChars(string $cross, string $topLeft, string $topMid, string $topRight, string $midRight, string $bottomRight, string $bottomMid, string $bottomLeft, string $midLeft, string $topLeftBottom = null, string $topMidBottom = null, string $topRightBottom = null): self |
|
173 | - { |
|
174 | - $this->crossingChar = $cross; |
|
175 | - $this->crossingTopLeftChar = $topLeft; |
|
176 | - $this->crossingTopMidChar = $topMid; |
|
177 | - $this->crossingTopRightChar = $topRight; |
|
178 | - $this->crossingMidRightChar = $midRight; |
|
179 | - $this->crossingBottomRightChar = $bottomRight; |
|
180 | - $this->crossingBottomMidChar = $bottomMid; |
|
181 | - $this->crossingBottomLeftChar = $bottomLeft; |
|
182 | - $this->crossingMidLeftChar = $midLeft; |
|
183 | - $this->crossingTopLeftBottomChar = $topLeftBottom ?? $midLeft; |
|
184 | - $this->crossingTopMidBottomChar = $topMidBottom ?? $cross; |
|
185 | - $this->crossingTopRightBottomChar = $topRightBottom ?? $midRight; |
|
186 | - |
|
187 | - return $this; |
|
188 | - } |
|
189 | - |
|
190 | - /** |
|
191 | - * Sets default crossing character used for each cross. |
|
192 | - * |
|
193 | - * @see {@link setCrossingChars()} for setting each crossing individually. |
|
194 | - */ |
|
195 | - public function setDefaultCrossingChar(string $char): self |
|
196 | - { |
|
197 | - return $this->setCrossingChars($char, $char, $char, $char, $char, $char, $char, $char, $char); |
|
198 | - } |
|
199 | - |
|
200 | - /** |
|
201 | - * Gets crossing character. |
|
202 | - * |
|
203 | - * @return string |
|
204 | - */ |
|
205 | - public function getCrossingChar() |
|
206 | - { |
|
207 | - return $this->crossingChar; |
|
208 | - } |
|
209 | - |
|
210 | - /** |
|
211 | - * Gets crossing characters. |
|
212 | - * |
|
213 | - * @internal |
|
214 | - */ |
|
215 | - public function getCrossingChars(): array |
|
216 | - { |
|
217 | - return [ |
|
218 | - $this->crossingChar, |
|
219 | - $this->crossingTopLeftChar, |
|
220 | - $this->crossingTopMidChar, |
|
221 | - $this->crossingTopRightChar, |
|
222 | - $this->crossingMidRightChar, |
|
223 | - $this->crossingBottomRightChar, |
|
224 | - $this->crossingBottomMidChar, |
|
225 | - $this->crossingBottomLeftChar, |
|
226 | - $this->crossingMidLeftChar, |
|
227 | - $this->crossingTopLeftBottomChar, |
|
228 | - $this->crossingTopMidBottomChar, |
|
229 | - $this->crossingTopRightBottomChar, |
|
230 | - ]; |
|
231 | - } |
|
232 | - |
|
233 | - /** |
|
234 | - * Sets header cell format. |
|
235 | - * |
|
236 | - * @return $this |
|
237 | - */ |
|
238 | - public function setCellHeaderFormat(string $cellHeaderFormat) |
|
239 | - { |
|
240 | - $this->cellHeaderFormat = $cellHeaderFormat; |
|
241 | - |
|
242 | - return $this; |
|
243 | - } |
|
244 | - |
|
245 | - /** |
|
246 | - * Gets header cell format. |
|
247 | - * |
|
248 | - * @return string |
|
249 | - */ |
|
250 | - public function getCellHeaderFormat() |
|
251 | - { |
|
252 | - return $this->cellHeaderFormat; |
|
253 | - } |
|
254 | - |
|
255 | - /** |
|
256 | - * Sets row cell format. |
|
257 | - * |
|
258 | - * @return $this |
|
259 | - */ |
|
260 | - public function setCellRowFormat(string $cellRowFormat) |
|
261 | - { |
|
262 | - $this->cellRowFormat = $cellRowFormat; |
|
263 | - |
|
264 | - return $this; |
|
265 | - } |
|
266 | - |
|
267 | - /** |
|
268 | - * Gets row cell format. |
|
269 | - * |
|
270 | - * @return string |
|
271 | - */ |
|
272 | - public function getCellRowFormat() |
|
273 | - { |
|
274 | - return $this->cellRowFormat; |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Sets row cell content format. |
|
279 | - * |
|
280 | - * @return $this |
|
281 | - */ |
|
282 | - public function setCellRowContentFormat(string $cellRowContentFormat) |
|
283 | - { |
|
284 | - $this->cellRowContentFormat = $cellRowContentFormat; |
|
285 | - |
|
286 | - return $this; |
|
287 | - } |
|
288 | - |
|
289 | - /** |
|
290 | - * Gets row cell content format. |
|
291 | - * |
|
292 | - * @return string |
|
293 | - */ |
|
294 | - public function getCellRowContentFormat() |
|
295 | - { |
|
296 | - return $this->cellRowContentFormat; |
|
297 | - } |
|
298 | - |
|
299 | - /** |
|
300 | - * Sets table border format. |
|
301 | - * |
|
302 | - * @return $this |
|
303 | - */ |
|
304 | - public function setBorderFormat(string $borderFormat) |
|
305 | - { |
|
306 | - $this->borderFormat = $borderFormat; |
|
307 | - |
|
308 | - return $this; |
|
309 | - } |
|
310 | - |
|
311 | - /** |
|
312 | - * Gets table border format. |
|
313 | - * |
|
314 | - * @return string |
|
315 | - */ |
|
316 | - public function getBorderFormat() |
|
317 | - { |
|
318 | - return $this->borderFormat; |
|
319 | - } |
|
320 | - |
|
321 | - /** |
|
322 | - * Sets cell padding type. |
|
323 | - * |
|
324 | - * @return $this |
|
325 | - */ |
|
326 | - public function setPadType(int $padType) |
|
327 | - { |
|
328 | - if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) { |
|
329 | - throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); |
|
330 | - } |
|
331 | - |
|
332 | - $this->padType = $padType; |
|
333 | - |
|
334 | - return $this; |
|
335 | - } |
|
336 | - |
|
337 | - /** |
|
338 | - * Gets cell padding type. |
|
339 | - * |
|
340 | - * @return int |
|
341 | - */ |
|
342 | - public function getPadType() |
|
343 | - { |
|
344 | - return $this->padType; |
|
345 | - } |
|
346 | - |
|
347 | - public function getHeaderTitleFormat(): string |
|
348 | - { |
|
349 | - return $this->headerTitleFormat; |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * @return $this |
|
354 | - */ |
|
355 | - public function setHeaderTitleFormat(string $format): self |
|
356 | - { |
|
357 | - $this->headerTitleFormat = $format; |
|
358 | - |
|
359 | - return $this; |
|
360 | - } |
|
361 | - |
|
362 | - public function getFooterTitleFormat(): string |
|
363 | - { |
|
364 | - return $this->footerTitleFormat; |
|
365 | - } |
|
366 | - |
|
367 | - /** |
|
368 | - * @return $this |
|
369 | - */ |
|
370 | - public function setFooterTitleFormat(string $format): self |
|
371 | - { |
|
372 | - $this->footerTitleFormat = $format; |
|
373 | - |
|
374 | - return $this; |
|
375 | - } |
|
26 | + private $paddingChar = ' '; |
|
27 | + private $horizontalOutsideBorderChar = '-'; |
|
28 | + private $horizontalInsideBorderChar = '-'; |
|
29 | + private $verticalOutsideBorderChar = '|'; |
|
30 | + private $verticalInsideBorderChar = '|'; |
|
31 | + private $crossingChar = '+'; |
|
32 | + private $crossingTopRightChar = '+'; |
|
33 | + private $crossingTopMidChar = '+'; |
|
34 | + private $crossingTopLeftChar = '+'; |
|
35 | + private $crossingMidRightChar = '+'; |
|
36 | + private $crossingBottomRightChar = '+'; |
|
37 | + private $crossingBottomMidChar = '+'; |
|
38 | + private $crossingBottomLeftChar = '+'; |
|
39 | + private $crossingMidLeftChar = '+'; |
|
40 | + private $crossingTopLeftBottomChar = '+'; |
|
41 | + private $crossingTopMidBottomChar = '+'; |
|
42 | + private $crossingTopRightBottomChar = '+'; |
|
43 | + private $headerTitleFormat = '<fg=black;bg=white;options=bold> %s </>'; |
|
44 | + private $footerTitleFormat = '<fg=black;bg=white;options=bold> %s </>'; |
|
45 | + private $cellHeaderFormat = '<info>%s</info>'; |
|
46 | + private $cellRowFormat = '%s'; |
|
47 | + private $cellRowContentFormat = ' %s '; |
|
48 | + private $borderFormat = '%s'; |
|
49 | + private $padType = \STR_PAD_RIGHT; |
|
50 | + |
|
51 | + /** |
|
52 | + * Sets padding character, used for cell padding. |
|
53 | + * |
|
54 | + * @return $this |
|
55 | + */ |
|
56 | + public function setPaddingChar(string $paddingChar) |
|
57 | + { |
|
58 | + if (!$paddingChar) { |
|
59 | + throw new LogicException('The padding char must not be empty.'); |
|
60 | + } |
|
61 | + |
|
62 | + $this->paddingChar = $paddingChar; |
|
63 | + |
|
64 | + return $this; |
|
65 | + } |
|
66 | + |
|
67 | + /** |
|
68 | + * Gets padding character, used for cell padding. |
|
69 | + * |
|
70 | + * @return string |
|
71 | + */ |
|
72 | + public function getPaddingChar() |
|
73 | + { |
|
74 | + return $this->paddingChar; |
|
75 | + } |
|
76 | + |
|
77 | + /** |
|
78 | + * Sets horizontal border characters. |
|
79 | + * |
|
80 | + * <code> |
|
81 | + * ╔═══════════════╤══════════════════════════╤══════════════════╗ |
|
82 | + * 1 ISBN 2 Title │ Author ║ |
|
83 | + * ╠═══════════════╪══════════════════════════╪══════════════════╣ |
|
84 | + * ║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║ |
|
85 | + * ║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║ |
|
86 | + * ║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║ |
|
87 | + * ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║ |
|
88 | + * ╚═══════════════╧══════════════════════════╧══════════════════╝ |
|
89 | + * </code> |
|
90 | + * |
|
91 | + * @return $this |
|
92 | + */ |
|
93 | + public function setHorizontalBorderChars(string $outside, string $inside = null): self |
|
94 | + { |
|
95 | + $this->horizontalOutsideBorderChar = $outside; |
|
96 | + $this->horizontalInsideBorderChar = $inside ?? $outside; |
|
97 | + |
|
98 | + return $this; |
|
99 | + } |
|
100 | + |
|
101 | + /** |
|
102 | + * Sets vertical border characters. |
|
103 | + * |
|
104 | + * <code> |
|
105 | + * ╔═══════════════╤══════════════════════════╤══════════════════╗ |
|
106 | + * ║ ISBN │ Title │ Author ║ |
|
107 | + * ╠═══════1═══════╪══════════════════════════╪══════════════════╣ |
|
108 | + * ║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║ |
|
109 | + * ║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║ |
|
110 | + * ╟───────2───────┼──────────────────────────┼──────────────────╢ |
|
111 | + * ║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║ |
|
112 | + * ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║ |
|
113 | + * ╚═══════════════╧══════════════════════════╧══════════════════╝ |
|
114 | + * </code> |
|
115 | + * |
|
116 | + * @return $this |
|
117 | + */ |
|
118 | + public function setVerticalBorderChars(string $outside, string $inside = null): self |
|
119 | + { |
|
120 | + $this->verticalOutsideBorderChar = $outside; |
|
121 | + $this->verticalInsideBorderChar = $inside ?? $outside; |
|
122 | + |
|
123 | + return $this; |
|
124 | + } |
|
125 | + |
|
126 | + /** |
|
127 | + * Gets border characters. |
|
128 | + * |
|
129 | + * @internal |
|
130 | + */ |
|
131 | + public function getBorderChars(): array |
|
132 | + { |
|
133 | + return [ |
|
134 | + $this->horizontalOutsideBorderChar, |
|
135 | + $this->verticalOutsideBorderChar, |
|
136 | + $this->horizontalInsideBorderChar, |
|
137 | + $this->verticalInsideBorderChar, |
|
138 | + ]; |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Sets crossing characters. |
|
143 | + * |
|
144 | + * Example: |
|
145 | + * <code> |
|
146 | + * 1═══════════════2══════════════════════════2══════════════════3 |
|
147 | + * ║ ISBN │ Title │ Author ║ |
|
148 | + * 8'══════════════0'═════════════════════════0'═════════════════4' |
|
149 | + * ║ 99921-58-10-7 │ Divine Comedy │ Dante Alighieri ║ |
|
150 | + * ║ 9971-5-0210-0 │ A Tale of Two Cities │ Charles Dickens ║ |
|
151 | + * 8───────────────0──────────────────────────0──────────────────4 |
|
152 | + * ║ 960-425-059-0 │ The Lord of the Rings │ J. R. R. Tolkien ║ |
|
153 | + * ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie ║ |
|
154 | + * 7═══════════════6══════════════════════════6══════════════════5 |
|
155 | + * </code> |
|
156 | + * |
|
157 | + * @param string $cross Crossing char (see #0 of example) |
|
158 | + * @param string $topLeft Top left char (see #1 of example) |
|
159 | + * @param string $topMid Top mid char (see #2 of example) |
|
160 | + * @param string $topRight Top right char (see #3 of example) |
|
161 | + * @param string $midRight Mid right char (see #4 of example) |
|
162 | + * @param string $bottomRight Bottom right char (see #5 of example) |
|
163 | + * @param string $bottomMid Bottom mid char (see #6 of example) |
|
164 | + * @param string $bottomLeft Bottom left char (see #7 of example) |
|
165 | + * @param string $midLeft Mid left char (see #8 of example) |
|
166 | + * @param string|null $topLeftBottom Top left bottom char (see #8' of example), equals to $midLeft if null |
|
167 | + * @param string|null $topMidBottom Top mid bottom char (see #0' of example), equals to $cross if null |
|
168 | + * @param string|null $topRightBottom Top right bottom char (see #4' of example), equals to $midRight if null |
|
169 | + * |
|
170 | + * @return $this |
|
171 | + */ |
|
172 | + public function setCrossingChars(string $cross, string $topLeft, string $topMid, string $topRight, string $midRight, string $bottomRight, string $bottomMid, string $bottomLeft, string $midLeft, string $topLeftBottom = null, string $topMidBottom = null, string $topRightBottom = null): self |
|
173 | + { |
|
174 | + $this->crossingChar = $cross; |
|
175 | + $this->crossingTopLeftChar = $topLeft; |
|
176 | + $this->crossingTopMidChar = $topMid; |
|
177 | + $this->crossingTopRightChar = $topRight; |
|
178 | + $this->crossingMidRightChar = $midRight; |
|
179 | + $this->crossingBottomRightChar = $bottomRight; |
|
180 | + $this->crossingBottomMidChar = $bottomMid; |
|
181 | + $this->crossingBottomLeftChar = $bottomLeft; |
|
182 | + $this->crossingMidLeftChar = $midLeft; |
|
183 | + $this->crossingTopLeftBottomChar = $topLeftBottom ?? $midLeft; |
|
184 | + $this->crossingTopMidBottomChar = $topMidBottom ?? $cross; |
|
185 | + $this->crossingTopRightBottomChar = $topRightBottom ?? $midRight; |
|
186 | + |
|
187 | + return $this; |
|
188 | + } |
|
189 | + |
|
190 | + /** |
|
191 | + * Sets default crossing character used for each cross. |
|
192 | + * |
|
193 | + * @see {@link setCrossingChars()} for setting each crossing individually. |
|
194 | + */ |
|
195 | + public function setDefaultCrossingChar(string $char): self |
|
196 | + { |
|
197 | + return $this->setCrossingChars($char, $char, $char, $char, $char, $char, $char, $char, $char); |
|
198 | + } |
|
199 | + |
|
200 | + /** |
|
201 | + * Gets crossing character. |
|
202 | + * |
|
203 | + * @return string |
|
204 | + */ |
|
205 | + public function getCrossingChar() |
|
206 | + { |
|
207 | + return $this->crossingChar; |
|
208 | + } |
|
209 | + |
|
210 | + /** |
|
211 | + * Gets crossing characters. |
|
212 | + * |
|
213 | + * @internal |
|
214 | + */ |
|
215 | + public function getCrossingChars(): array |
|
216 | + { |
|
217 | + return [ |
|
218 | + $this->crossingChar, |
|
219 | + $this->crossingTopLeftChar, |
|
220 | + $this->crossingTopMidChar, |
|
221 | + $this->crossingTopRightChar, |
|
222 | + $this->crossingMidRightChar, |
|
223 | + $this->crossingBottomRightChar, |
|
224 | + $this->crossingBottomMidChar, |
|
225 | + $this->crossingBottomLeftChar, |
|
226 | + $this->crossingMidLeftChar, |
|
227 | + $this->crossingTopLeftBottomChar, |
|
228 | + $this->crossingTopMidBottomChar, |
|
229 | + $this->crossingTopRightBottomChar, |
|
230 | + ]; |
|
231 | + } |
|
232 | + |
|
233 | + /** |
|
234 | + * Sets header cell format. |
|
235 | + * |
|
236 | + * @return $this |
|
237 | + */ |
|
238 | + public function setCellHeaderFormat(string $cellHeaderFormat) |
|
239 | + { |
|
240 | + $this->cellHeaderFormat = $cellHeaderFormat; |
|
241 | + |
|
242 | + return $this; |
|
243 | + } |
|
244 | + |
|
245 | + /** |
|
246 | + * Gets header cell format. |
|
247 | + * |
|
248 | + * @return string |
|
249 | + */ |
|
250 | + public function getCellHeaderFormat() |
|
251 | + { |
|
252 | + return $this->cellHeaderFormat; |
|
253 | + } |
|
254 | + |
|
255 | + /** |
|
256 | + * Sets row cell format. |
|
257 | + * |
|
258 | + * @return $this |
|
259 | + */ |
|
260 | + public function setCellRowFormat(string $cellRowFormat) |
|
261 | + { |
|
262 | + $this->cellRowFormat = $cellRowFormat; |
|
263 | + |
|
264 | + return $this; |
|
265 | + } |
|
266 | + |
|
267 | + /** |
|
268 | + * Gets row cell format. |
|
269 | + * |
|
270 | + * @return string |
|
271 | + */ |
|
272 | + public function getCellRowFormat() |
|
273 | + { |
|
274 | + return $this->cellRowFormat; |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * Sets row cell content format. |
|
279 | + * |
|
280 | + * @return $this |
|
281 | + */ |
|
282 | + public function setCellRowContentFormat(string $cellRowContentFormat) |
|
283 | + { |
|
284 | + $this->cellRowContentFormat = $cellRowContentFormat; |
|
285 | + |
|
286 | + return $this; |
|
287 | + } |
|
288 | + |
|
289 | + /** |
|
290 | + * Gets row cell content format. |
|
291 | + * |
|
292 | + * @return string |
|
293 | + */ |
|
294 | + public function getCellRowContentFormat() |
|
295 | + { |
|
296 | + return $this->cellRowContentFormat; |
|
297 | + } |
|
298 | + |
|
299 | + /** |
|
300 | + * Sets table border format. |
|
301 | + * |
|
302 | + * @return $this |
|
303 | + */ |
|
304 | + public function setBorderFormat(string $borderFormat) |
|
305 | + { |
|
306 | + $this->borderFormat = $borderFormat; |
|
307 | + |
|
308 | + return $this; |
|
309 | + } |
|
310 | + |
|
311 | + /** |
|
312 | + * Gets table border format. |
|
313 | + * |
|
314 | + * @return string |
|
315 | + */ |
|
316 | + public function getBorderFormat() |
|
317 | + { |
|
318 | + return $this->borderFormat; |
|
319 | + } |
|
320 | + |
|
321 | + /** |
|
322 | + * Sets cell padding type. |
|
323 | + * |
|
324 | + * @return $this |
|
325 | + */ |
|
326 | + public function setPadType(int $padType) |
|
327 | + { |
|
328 | + if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) { |
|
329 | + throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); |
|
330 | + } |
|
331 | + |
|
332 | + $this->padType = $padType; |
|
333 | + |
|
334 | + return $this; |
|
335 | + } |
|
336 | + |
|
337 | + /** |
|
338 | + * Gets cell padding type. |
|
339 | + * |
|
340 | + * @return int |
|
341 | + */ |
|
342 | + public function getPadType() |
|
343 | + { |
|
344 | + return $this->padType; |
|
345 | + } |
|
346 | + |
|
347 | + public function getHeaderTitleFormat(): string |
|
348 | + { |
|
349 | + return $this->headerTitleFormat; |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * @return $this |
|
354 | + */ |
|
355 | + public function setHeaderTitleFormat(string $format): self |
|
356 | + { |
|
357 | + $this->headerTitleFormat = $format; |
|
358 | + |
|
359 | + return $this; |
|
360 | + } |
|
361 | + |
|
362 | + public function getFooterTitleFormat(): string |
|
363 | + { |
|
364 | + return $this->footerTitleFormat; |
|
365 | + } |
|
366 | + |
|
367 | + /** |
|
368 | + * @return $this |
|
369 | + */ |
|
370 | + public function setFooterTitleFormat(string $format): self |
|
371 | + { |
|
372 | + $this->footerTitleFormat = $format; |
|
373 | + |
|
374 | + return $this; |
|
375 | + } |
|
376 | 376 | } |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | * |
54 | 54 | * @return $this |
55 | 55 | */ |
56 | - public function setPaddingChar(string $paddingChar) |
|
56 | + public function setPaddingChar( string $paddingChar ) |
|
57 | 57 | { |
58 | - if (!$paddingChar) { |
|
59 | - throw new LogicException('The padding char must not be empty.'); |
|
58 | + if ( ! $paddingChar ) { |
|
59 | + throw new LogicException( 'The padding char must not be empty.' ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $this->paddingChar = $paddingChar; |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @return $this |
92 | 92 | */ |
93 | - public function setHorizontalBorderChars(string $outside, string $inside = null): self |
|
93 | + public function setHorizontalBorderChars( string $outside, string $inside = null ): self |
|
94 | 94 | { |
95 | 95 | $this->horizontalOutsideBorderChar = $outside; |
96 | 96 | $this->horizontalInsideBorderChar = $inside ?? $outside; |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return $this |
117 | 117 | */ |
118 | - public function setVerticalBorderChars(string $outside, string $inside = null): self |
|
118 | + public function setVerticalBorderChars( string $outside, string $inside = null ): self |
|
119 | 119 | { |
120 | 120 | $this->verticalOutsideBorderChar = $outside; |
121 | 121 | $this->verticalInsideBorderChar = $inside ?? $outside; |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @return $this |
171 | 171 | */ |
172 | - public function setCrossingChars(string $cross, string $topLeft, string $topMid, string $topRight, string $midRight, string $bottomRight, string $bottomMid, string $bottomLeft, string $midLeft, string $topLeftBottom = null, string $topMidBottom = null, string $topRightBottom = null): self |
|
172 | + public function setCrossingChars( string $cross, string $topLeft, string $topMid, string $topRight, string $midRight, string $bottomRight, string $bottomMid, string $bottomLeft, string $midLeft, string $topLeftBottom = null, string $topMidBottom = null, string $topRightBottom = null ): self |
|
173 | 173 | { |
174 | 174 | $this->crossingChar = $cross; |
175 | 175 | $this->crossingTopLeftChar = $topLeft; |
@@ -192,9 +192,9 @@ discard block |
||
192 | 192 | * |
193 | 193 | * @see {@link setCrossingChars()} for setting each crossing individually. |
194 | 194 | */ |
195 | - public function setDefaultCrossingChar(string $char): self |
|
195 | + public function setDefaultCrossingChar( string $char ): self |
|
196 | 196 | { |
197 | - return $this->setCrossingChars($char, $char, $char, $char, $char, $char, $char, $char, $char); |
|
197 | + return $this->setCrossingChars( $char, $char, $char, $char, $char, $char, $char, $char, $char ); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | /** |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | * |
236 | 236 | * @return $this |
237 | 237 | */ |
238 | - public function setCellHeaderFormat(string $cellHeaderFormat) |
|
238 | + public function setCellHeaderFormat( string $cellHeaderFormat ) |
|
239 | 239 | { |
240 | 240 | $this->cellHeaderFormat = $cellHeaderFormat; |
241 | 241 | |
@@ -257,7 +257,7 @@ discard block |
||
257 | 257 | * |
258 | 258 | * @return $this |
259 | 259 | */ |
260 | - public function setCellRowFormat(string $cellRowFormat) |
|
260 | + public function setCellRowFormat( string $cellRowFormat ) |
|
261 | 261 | { |
262 | 262 | $this->cellRowFormat = $cellRowFormat; |
263 | 263 | |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | * |
280 | 280 | * @return $this |
281 | 281 | */ |
282 | - public function setCellRowContentFormat(string $cellRowContentFormat) |
|
282 | + public function setCellRowContentFormat( string $cellRowContentFormat ) |
|
283 | 283 | { |
284 | 284 | $this->cellRowContentFormat = $cellRowContentFormat; |
285 | 285 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * |
302 | 302 | * @return $this |
303 | 303 | */ |
304 | - public function setBorderFormat(string $borderFormat) |
|
304 | + public function setBorderFormat( string $borderFormat ) |
|
305 | 305 | { |
306 | 306 | $this->borderFormat = $borderFormat; |
307 | 307 | |
@@ -323,10 +323,10 @@ discard block |
||
323 | 323 | * |
324 | 324 | * @return $this |
325 | 325 | */ |
326 | - public function setPadType(int $padType) |
|
326 | + public function setPadType( int $padType ) |
|
327 | 327 | { |
328 | - if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) { |
|
329 | - throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).'); |
|
328 | + if ( ! \in_array( $padType, [ \STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH ], true ) ) { |
|
329 | + throw new InvalidArgumentException( 'Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).' ); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | $this->padType = $padType; |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | /** |
353 | 353 | * @return $this |
354 | 354 | */ |
355 | - public function setHeaderTitleFormat(string $format): self |
|
355 | + public function setHeaderTitleFormat( string $format ): self |
|
356 | 356 | { |
357 | 357 | $this->headerTitleFormat = $format; |
358 | 358 | |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | /** |
368 | 368 | * @return $this |
369 | 369 | */ |
370 | - public function setFooterTitleFormat(string $format): self |
|
370 | + public function setFooterTitleFormat( string $format ): self |
|
371 | 371 | { |
372 | 372 | $this->footerTitleFormat = $format; |
373 | 373 |