Completed
Pull Request — develop (#1656)
by
unknown
17:57
created
vendor/symfony/console/Helper/HelperSet.php 1 patch
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -21,79 +21,79 @@
 block discarded – undo
21 21
  */
22 22
 class HelperSet implements \IteratorAggregate
23 23
 {
24
-    /**
25
-     * @var Helper[]
26
-     */
27
-    private $helpers = [];
28
-    private $command;
24
+	/**
25
+	 * @var Helper[]
26
+	 */
27
+	private $helpers = [];
28
+	private $command;
29 29
 
30
-    /**
31
-     * @param Helper[] $helpers An array of helper
32
-     */
33
-    public function __construct(array $helpers = [])
34
-    {
35
-        foreach ($helpers as $alias => $helper) {
36
-            $this->set($helper, \is_int($alias) ? null : $alias);
37
-        }
38
-    }
30
+	/**
31
+	 * @param Helper[] $helpers An array of helper
32
+	 */
33
+	public function __construct(array $helpers = [])
34
+	{
35
+		foreach ($helpers as $alias => $helper) {
36
+			$this->set($helper, \is_int($alias) ? null : $alias);
37
+		}
38
+	}
39 39
 
40
-    public function set(HelperInterface $helper, string $alias = null)
41
-    {
42
-        $this->helpers[$helper->getName()] = $helper;
43
-        if (null !== $alias) {
44
-            $this->helpers[$alias] = $helper;
45
-        }
40
+	public function set(HelperInterface $helper, string $alias = null)
41
+	{
42
+		$this->helpers[$helper->getName()] = $helper;
43
+		if (null !== $alias) {
44
+			$this->helpers[$alias] = $helper;
45
+		}
46 46
 
47
-        $helper->setHelperSet($this);
48
-    }
47
+		$helper->setHelperSet($this);
48
+	}
49 49
 
50
-    /**
51
-     * Returns true if the helper if defined.
52
-     *
53
-     * @return bool true if the helper is defined, false otherwise
54
-     */
55
-    public function has(string $name)
56
-    {
57
-        return isset($this->helpers[$name]);
58
-    }
50
+	/**
51
+	 * Returns true if the helper if defined.
52
+	 *
53
+	 * @return bool true if the helper is defined, false otherwise
54
+	 */
55
+	public function has(string $name)
56
+	{
57
+		return isset($this->helpers[$name]);
58
+	}
59 59
 
60
-    /**
61
-     * Gets a helper value.
62
-     *
63
-     * @return HelperInterface The helper instance
64
-     *
65
-     * @throws InvalidArgumentException if the helper is not defined
66
-     */
67
-    public function get(string $name)
68
-    {
69
-        if (!$this->has($name)) {
70
-            throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
71
-        }
60
+	/**
61
+	 * Gets a helper value.
62
+	 *
63
+	 * @return HelperInterface The helper instance
64
+	 *
65
+	 * @throws InvalidArgumentException if the helper is not defined
66
+	 */
67
+	public function get(string $name)
68
+	{
69
+		if (!$this->has($name)) {
70
+			throw new InvalidArgumentException(sprintf('The helper "%s" is not defined.', $name));
71
+		}
72 72
 
73
-        return $this->helpers[$name];
74
-    }
73
+		return $this->helpers[$name];
74
+	}
75 75
 
76
-    public function setCommand(Command $command = null)
77
-    {
78
-        $this->command = $command;
79
-    }
76
+	public function setCommand(Command $command = null)
77
+	{
78
+		$this->command = $command;
79
+	}
80 80
 
81
-    /**
82
-     * Gets the command associated with this helper set.
83
-     *
84
-     * @return Command A Command instance
85
-     */
86
-    public function getCommand()
87
-    {
88
-        return $this->command;
89
-    }
81
+	/**
82
+	 * Gets the command associated with this helper set.
83
+	 *
84
+	 * @return Command A Command instance
85
+	 */
86
+	public function getCommand()
87
+	{
88
+		return $this->command;
89
+	}
90 90
 
91
-    /**
92
-     * @return \Traversable<Helper>
93
-     */
94
-    #[\ReturnTypeWillChange]
95
-    public function getIterator()
96
-    {
97
-        return new \ArrayIterator($this->helpers);
98
-    }
91
+	/**
92
+	 * @return \Traversable<Helper>
93
+	 */
94
+	#[\ReturnTypeWillChange]
95
+	public function getIterator()
96
+	{
97
+		return new \ArrayIterator($this->helpers);
98
+	}
99 99
 }
Please login to merge, or discard this patch.
vendor/symfony/console/Helper/DebugFormatterHelper.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -20,88 +20,88 @@
 block discarded – undo
20 20
  */
21 21
 class DebugFormatterHelper extends Helper
22 22
 {
23
-    private $colors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default'];
24
-    private $started = [];
25
-    private $count = -1;
26
-
27
-    /**
28
-     * Starts a debug formatting session.
29
-     *
30
-     * @return string
31
-     */
32
-    public function start(string $id, string $message, string $prefix = 'RUN')
33
-    {
34
-        $this->started[$id] = ['border' => ++$this->count % \count($this->colors)];
35
-
36
-        return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
37
-    }
38
-
39
-    /**
40
-     * Adds progress to a formatting session.
41
-     *
42
-     * @return string
43
-     */
44
-    public function progress(string $id, string $buffer, bool $error = false, string $prefix = 'OUT', string $errorPrefix = 'ERR')
45
-    {
46
-        $message = '';
47
-
48
-        if ($error) {
49
-            if (isset($this->started[$id]['out'])) {
50
-                $message .= "\n";
51
-                unset($this->started[$id]['out']);
52
-            }
53
-            if (!isset($this->started[$id]['err'])) {
54
-                $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
55
-                $this->started[$id]['err'] = true;
56
-            }
57
-
58
-            $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
59
-        } else {
60
-            if (isset($this->started[$id]['err'])) {
61
-                $message .= "\n";
62
-                unset($this->started[$id]['err']);
63
-            }
64
-            if (!isset($this->started[$id]['out'])) {
65
-                $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
66
-                $this->started[$id]['out'] = true;
67
-            }
68
-
69
-            $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
70
-        }
71
-
72
-        return $message;
73
-    }
74
-
75
-    /**
76
-     * Stops a formatting session.
77
-     *
78
-     * @return string
79
-     */
80
-    public function stop(string $id, string $message, bool $successful, string $prefix = 'RES')
81
-    {
82
-        $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
83
-
84
-        if ($successful) {
85
-            return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
86
-        }
87
-
88
-        $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
89
-
90
-        unset($this->started[$id]['out'], $this->started[$id]['err']);
91
-
92
-        return $message;
93
-    }
94
-
95
-    private function getBorder(string $id): string
96
-    {
97
-        return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
98
-    }
99
-
100
-    /**
101
-     * {@inheritdoc}
102
-     */
103
-    public function getName()
104
-    {
105
-        return 'debug_formatter';
106
-    }
23
+	private $colors = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default'];
24
+	private $started = [];
25
+	private $count = -1;
26
+
27
+	/**
28
+	 * Starts a debug formatting session.
29
+	 *
30
+	 * @return string
31
+	 */
32
+	public function start(string $id, string $message, string $prefix = 'RUN')
33
+	{
34
+		$this->started[$id] = ['border' => ++$this->count % \count($this->colors)];
35
+
36
+		return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
37
+	}
38
+
39
+	/**
40
+	 * Adds progress to a formatting session.
41
+	 *
42
+	 * @return string
43
+	 */
44
+	public function progress(string $id, string $buffer, bool $error = false, string $prefix = 'OUT', string $errorPrefix = 'ERR')
45
+	{
46
+		$message = '';
47
+
48
+		if ($error) {
49
+			if (isset($this->started[$id]['out'])) {
50
+				$message .= "\n";
51
+				unset($this->started[$id]['out']);
52
+			}
53
+			if (!isset($this->started[$id]['err'])) {
54
+				$message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
55
+				$this->started[$id]['err'] = true;
56
+			}
57
+
58
+			$message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
59
+		} else {
60
+			if (isset($this->started[$id]['err'])) {
61
+				$message .= "\n";
62
+				unset($this->started[$id]['err']);
63
+			}
64
+			if (!isset($this->started[$id]['out'])) {
65
+				$message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
66
+				$this->started[$id]['out'] = true;
67
+			}
68
+
69
+			$message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
70
+		}
71
+
72
+		return $message;
73
+	}
74
+
75
+	/**
76
+	 * Stops a formatting session.
77
+	 *
78
+	 * @return string
79
+	 */
80
+	public function stop(string $id, string $message, bool $successful, string $prefix = 'RES')
81
+	{
82
+		$trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
83
+
84
+		if ($successful) {
85
+			return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
86
+		}
87
+
88
+		$message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
89
+
90
+		unset($this->started[$id]['out'], $this->started[$id]['err']);
91
+
92
+		return $message;
93
+	}
94
+
95
+	private function getBorder(string $id): string
96
+	{
97
+		return sprintf('<bg=%s> </>', $this->colors[$this->started[$id]['border']]);
98
+	}
99
+
100
+	/**
101
+	 * {@inheritdoc}
102
+	 */
103
+	public function getName()
104
+	{
105
+		return 'debug_formatter';
106
+	}
107 107
 }
Please login to merge, or discard this patch.
vendor/symfony/console/Helper/Helper.php 1 patch
Indentation   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -21,158 +21,158 @@
 block discarded – undo
21 21
  */
22 22
 abstract class Helper implements HelperInterface
23 23
 {
24
-    protected $helperSet = null;
25
-
26
-    /**
27
-     * {@inheritdoc}
28
-     */
29
-    public function setHelperSet(HelperSet $helperSet = null)
30
-    {
31
-        $this->helperSet = $helperSet;
32
-    }
33
-
34
-    /**
35
-     * {@inheritdoc}
36
-     */
37
-    public function getHelperSet()
38
-    {
39
-        return $this->helperSet;
40
-    }
41
-
42
-    /**
43
-     * Returns the length of a string, using mb_strwidth if it is available.
44
-     *
45
-     * @deprecated since Symfony 5.3
46
-     *
47
-     * @return int The length of the string
48
-     */
49
-    public static function strlen(?string $string)
50
-    {
51
-        trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::width() or Helper::length() instead.', __METHOD__);
52
-
53
-        return self::width($string);
54
-    }
55
-
56
-    /**
57
-     * Returns the width of a string, using mb_strwidth if it is available.
58
-     * The width is how many characters positions the string will use.
59
-     */
60
-    public static function width(?string $string): int
61
-    {
62
-        $string ?? $string = '';
63
-
64
-        if (preg_match('//u', $string)) {
65
-            return (new UnicodeString($string))->width(false);
66
-        }
67
-
68
-        if (false === $encoding = mb_detect_encoding($string, null, true)) {
69
-            return \strlen($string);
70
-        }
71
-
72
-        return mb_strwidth($string, $encoding);
73
-    }
74
-
75
-    /**
76
-     * Returns the length of a string, using mb_strlen if it is available.
77
-     * The length is related to how many bytes the string will use.
78
-     */
79
-    public static function length(?string $string): int
80
-    {
81
-        $string ?? $string = '';
82
-
83
-        if (preg_match('//u', $string)) {
84
-            return (new UnicodeString($string))->length();
85
-        }
86
-
87
-        if (false === $encoding = mb_detect_encoding($string, null, true)) {
88
-            return \strlen($string);
89
-        }
90
-
91
-        return mb_strlen($string, $encoding);
92
-    }
93
-
94
-    /**
95
-     * Returns the subset of a string, using mb_substr if it is available.
96
-     *
97
-     * @return string The string subset
98
-     */
99
-    public static function substr(?string $string, int $from, int $length = null)
100
-    {
101
-        $string ?? $string = '';
102
-
103
-        if (false === $encoding = mb_detect_encoding($string, null, true)) {
104
-            return substr($string, $from, $length);
105
-        }
106
-
107
-        return mb_substr($string, $from, $length, $encoding);
108
-    }
109
-
110
-    public static function formatTime($secs)
111
-    {
112
-        static $timeFormats = [
113
-            [0, '< 1 sec'],
114
-            [1, '1 sec'],
115
-            [2, 'secs', 1],
116
-            [60, '1 min'],
117
-            [120, 'mins', 60],
118
-            [3600, '1 hr'],
119
-            [7200, 'hrs', 3600],
120
-            [86400, '1 day'],
121
-            [172800, 'days', 86400],
122
-        ];
123
-
124
-        foreach ($timeFormats as $index => $format) {
125
-            if ($secs >= $format[0]) {
126
-                if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
127
-                    || $index == \count($timeFormats) - 1
128
-                ) {
129
-                    if (2 == \count($format)) {
130
-                        return $format[1];
131
-                    }
132
-
133
-                    return floor($secs / $format[2]).' '.$format[1];
134
-                }
135
-            }
136
-        }
137
-    }
138
-
139
-    public static function formatMemory(int $memory)
140
-    {
141
-        if ($memory >= 1024 * 1024 * 1024) {
142
-            return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
143
-        }
144
-
145
-        if ($memory >= 1024 * 1024) {
146
-            return sprintf('%.1f MiB', $memory / 1024 / 1024);
147
-        }
148
-
149
-        if ($memory >= 1024) {
150
-            return sprintf('%d KiB', $memory / 1024);
151
-        }
152
-
153
-        return sprintf('%d B', $memory);
154
-    }
155
-
156
-    /**
157
-     * @deprecated since Symfony 5.3
158
-     */
159
-    public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
160
-    {
161
-        trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::removeDecoration() instead.', __METHOD__);
162
-
163
-        return self::width(self::removeDecoration($formatter, $string));
164
-    }
165
-
166
-    public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
167
-    {
168
-        $isDecorated = $formatter->isDecorated();
169
-        $formatter->setDecorated(false);
170
-        // remove <...> formatting
171
-        $string = $formatter->format($string ?? '');
172
-        // remove already formatted characters
173
-        $string = preg_replace("/\033\[[^m]*m/", '', $string ?? '');
174
-        $formatter->setDecorated($isDecorated);
175
-
176
-        return $string;
177
-    }
24
+	protected $helperSet = null;
25
+
26
+	/**
27
+	 * {@inheritdoc}
28
+	 */
29
+	public function setHelperSet(HelperSet $helperSet = null)
30
+	{
31
+		$this->helperSet = $helperSet;
32
+	}
33
+
34
+	/**
35
+	 * {@inheritdoc}
36
+	 */
37
+	public function getHelperSet()
38
+	{
39
+		return $this->helperSet;
40
+	}
41
+
42
+	/**
43
+	 * Returns the length of a string, using mb_strwidth if it is available.
44
+	 *
45
+	 * @deprecated since Symfony 5.3
46
+	 *
47
+	 * @return int The length of the string
48
+	 */
49
+	public static function strlen(?string $string)
50
+	{
51
+		trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::width() or Helper::length() instead.', __METHOD__);
52
+
53
+		return self::width($string);
54
+	}
55
+
56
+	/**
57
+	 * Returns the width of a string, using mb_strwidth if it is available.
58
+	 * The width is how many characters positions the string will use.
59
+	 */
60
+	public static function width(?string $string): int
61
+	{
62
+		$string ?? $string = '';
63
+
64
+		if (preg_match('//u', $string)) {
65
+			return (new UnicodeString($string))->width(false);
66
+		}
67
+
68
+		if (false === $encoding = mb_detect_encoding($string, null, true)) {
69
+			return \strlen($string);
70
+		}
71
+
72
+		return mb_strwidth($string, $encoding);
73
+	}
74
+
75
+	/**
76
+	 * Returns the length of a string, using mb_strlen if it is available.
77
+	 * The length is related to how many bytes the string will use.
78
+	 */
79
+	public static function length(?string $string): int
80
+	{
81
+		$string ?? $string = '';
82
+
83
+		if (preg_match('//u', $string)) {
84
+			return (new UnicodeString($string))->length();
85
+		}
86
+
87
+		if (false === $encoding = mb_detect_encoding($string, null, true)) {
88
+			return \strlen($string);
89
+		}
90
+
91
+		return mb_strlen($string, $encoding);
92
+	}
93
+
94
+	/**
95
+	 * Returns the subset of a string, using mb_substr if it is available.
96
+	 *
97
+	 * @return string The string subset
98
+	 */
99
+	public static function substr(?string $string, int $from, int $length = null)
100
+	{
101
+		$string ?? $string = '';
102
+
103
+		if (false === $encoding = mb_detect_encoding($string, null, true)) {
104
+			return substr($string, $from, $length);
105
+		}
106
+
107
+		return mb_substr($string, $from, $length, $encoding);
108
+	}
109
+
110
+	public static function formatTime($secs)
111
+	{
112
+		static $timeFormats = [
113
+			[0, '< 1 sec'],
114
+			[1, '1 sec'],
115
+			[2, 'secs', 1],
116
+			[60, '1 min'],
117
+			[120, 'mins', 60],
118
+			[3600, '1 hr'],
119
+			[7200, 'hrs', 3600],
120
+			[86400, '1 day'],
121
+			[172800, 'days', 86400],
122
+		];
123
+
124
+		foreach ($timeFormats as $index => $format) {
125
+			if ($secs >= $format[0]) {
126
+				if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
127
+					|| $index == \count($timeFormats) - 1
128
+				) {
129
+					if (2 == \count($format)) {
130
+						return $format[1];
131
+					}
132
+
133
+					return floor($secs / $format[2]).' '.$format[1];
134
+				}
135
+			}
136
+		}
137
+	}
138
+
139
+	public static function formatMemory(int $memory)
140
+	{
141
+		if ($memory >= 1024 * 1024 * 1024) {
142
+			return sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
143
+		}
144
+
145
+		if ($memory >= 1024 * 1024) {
146
+			return sprintf('%.1f MiB', $memory / 1024 / 1024);
147
+		}
148
+
149
+		if ($memory >= 1024) {
150
+			return sprintf('%d KiB', $memory / 1024);
151
+		}
152
+
153
+		return sprintf('%d B', $memory);
154
+	}
155
+
156
+	/**
157
+	 * @deprecated since Symfony 5.3
158
+	 */
159
+	public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
160
+	{
161
+		trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::removeDecoration() instead.', __METHOD__);
162
+
163
+		return self::width(self::removeDecoration($formatter, $string));
164
+	}
165
+
166
+	public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
167
+	{
168
+		$isDecorated = $formatter->isDecorated();
169
+		$formatter->setDecorated(false);
170
+		// remove <...> formatting
171
+		$string = $formatter->format($string ?? '');
172
+		// remove already formatted characters
173
+		$string = preg_replace("/\033\[[^m]*m/", '', $string ?? '');
174
+		$formatter->setDecorated($isDecorated);
175
+
176
+		return $string;
177
+	}
178 178
 }
Please login to merge, or discard this patch.
vendor/symfony/console/Helper/FormatterHelper.php 1 patch
Indentation   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -20,73 +20,73 @@
 block discarded – undo
20 20
  */
21 21
 class FormatterHelper extends Helper
22 22
 {
23
-    /**
24
-     * Formats a message within a section.
25
-     *
26
-     * @return string The format section
27
-     */
28
-    public function formatSection(string $section, string $message, string $style = 'info')
29
-    {
30
-        return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
31
-    }
23
+	/**
24
+	 * Formats a message within a section.
25
+	 *
26
+	 * @return string The format section
27
+	 */
28
+	public function formatSection(string $section, string $message, string $style = 'info')
29
+	{
30
+		return sprintf('<%s>[%s]</%s> %s', $style, $section, $style, $message);
31
+	}
32 32
 
33
-    /**
34
-     * Formats a message as a block of text.
35
-     *
36
-     * @param string|array $messages The message to write in the block
37
-     *
38
-     * @return string The formatter message
39
-     */
40
-    public function formatBlock($messages, string $style, bool $large = false)
41
-    {
42
-        if (!\is_array($messages)) {
43
-            $messages = [$messages];
44
-        }
33
+	/**
34
+	 * Formats a message as a block of text.
35
+	 *
36
+	 * @param string|array $messages The message to write in the block
37
+	 *
38
+	 * @return string The formatter message
39
+	 */
40
+	public function formatBlock($messages, string $style, bool $large = false)
41
+	{
42
+		if (!\is_array($messages)) {
43
+			$messages = [$messages];
44
+		}
45 45
 
46
-        $len = 0;
47
-        $lines = [];
48
-        foreach ($messages as $message) {
49
-            $message = OutputFormatter::escape($message);
50
-            $lines[] = sprintf($large ? '  %s  ' : ' %s ', $message);
51
-            $len = max(self::width($message) + ($large ? 4 : 2), $len);
52
-        }
46
+		$len = 0;
47
+		$lines = [];
48
+		foreach ($messages as $message) {
49
+			$message = OutputFormatter::escape($message);
50
+			$lines[] = sprintf($large ? '  %s  ' : ' %s ', $message);
51
+			$len = max(self::width($message) + ($large ? 4 : 2), $len);
52
+		}
53 53
 
54
-        $messages = $large ? [str_repeat(' ', $len)] : [];
55
-        for ($i = 0; isset($lines[$i]); ++$i) {
56
-            $messages[] = $lines[$i].str_repeat(' ', $len - self::width($lines[$i]));
57
-        }
58
-        if ($large) {
59
-            $messages[] = str_repeat(' ', $len);
60
-        }
54
+		$messages = $large ? [str_repeat(' ', $len)] : [];
55
+		for ($i = 0; isset($lines[$i]); ++$i) {
56
+			$messages[] = $lines[$i].str_repeat(' ', $len - self::width($lines[$i]));
57
+		}
58
+		if ($large) {
59
+			$messages[] = str_repeat(' ', $len);
60
+		}
61 61
 
62
-        for ($i = 0; isset($messages[$i]); ++$i) {
63
-            $messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
64
-        }
62
+		for ($i = 0; isset($messages[$i]); ++$i) {
63
+			$messages[$i] = sprintf('<%s>%s</%s>', $style, $messages[$i], $style);
64
+		}
65 65
 
66
-        return implode("\n", $messages);
67
-    }
66
+		return implode("\n", $messages);
67
+	}
68 68
 
69
-    /**
70
-     * Truncates a message to the given length.
71
-     *
72
-     * @return string
73
-     */
74
-    public function truncate(string $message, int $length, string $suffix = '...')
75
-    {
76
-        $computedLength = $length - self::width($suffix);
69
+	/**
70
+	 * Truncates a message to the given length.
71
+	 *
72
+	 * @return string
73
+	 */
74
+	public function truncate(string $message, int $length, string $suffix = '...')
75
+	{
76
+		$computedLength = $length - self::width($suffix);
77 77
 
78
-        if ($computedLength > self::width($message)) {
79
-            return $message;
80
-        }
78
+		if ($computedLength > self::width($message)) {
79
+			return $message;
80
+		}
81 81
 
82
-        return self::substr($message, 0, $length).$suffix;
83
-    }
82
+		return self::substr($message, 0, $length).$suffix;
83
+	}
84 84
 
85
-    /**
86
-     * {@inheritdoc}
87
-     */
88
-    public function getName()
89
-    {
90
-        return 'formatter';
91
-    }
85
+	/**
86
+	 * {@inheritdoc}
87
+	 */
88
+	public function getName()
89
+	{
90
+		return 'formatter';
91
+	}
92 92
 }
Please login to merge, or discard this patch.
vendor/symfony/console/Helper/SymfonyQuestionHelper.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -25,85 +25,85 @@
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
vendor/symfony/console/Helper/TableRows.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -16,17 +16,17 @@
 block discarded – undo
16 16
  */
17 17
 class TableRows implements \IteratorAggregate
18 18
 {
19
-    private $generator;
19
+	private $generator;
20 20
 
21
-    public function __construct(callable $generator)
22
-    {
23
-        $this->generator = $generator;
24
-    }
21
+	public function __construct(callable $generator)
22
+	{
23
+		$this->generator = $generator;
24
+	}
25 25
 
26
-    public function getIterator(): \Traversable
27
-    {
28
-        $g = $this->generator;
26
+	public function getIterator(): \Traversable
27
+	{
28
+		$g = $this->generator;
29 29
 
30
-        return $g();
31
-    }
30
+		return $g();
31
+	}
32 32
 }
Please login to merge, or discard this patch.
vendor/symfony/console/Helper/ProgressBar.php 1 patch
Indentation   +590 added lines, -590 removed lines patch added patch discarded remove patch
@@ -26,594 +26,594 @@
 block discarded – undo
26 26
  */
27 27
 final class ProgressBar
28 28
 {
29
-    public const FORMAT_VERBOSE = 'verbose';
30
-    public const FORMAT_VERY_VERBOSE = 'very_verbose';
31
-    public const FORMAT_DEBUG = 'debug';
32
-    public const FORMAT_NORMAL = 'normal';
33
-
34
-    private const FORMAT_VERBOSE_NOMAX = 'verbose_nomax';
35
-    private const FORMAT_VERY_VERBOSE_NOMAX = 'very_verbose_nomax';
36
-    private const FORMAT_DEBUG_NOMAX = 'debug_nomax';
37
-    private const FORMAT_NORMAL_NOMAX = 'normal_nomax';
38
-
39
-    private $barWidth = 28;
40
-    private $barChar;
41
-    private $emptyBarChar = '-';
42
-    private $progressChar = '>';
43
-    private $format;
44
-    private $internalFormat;
45
-    private $redrawFreq = 1;
46
-    private $writeCount;
47
-    private $lastWriteTime;
48
-    private $minSecondsBetweenRedraws = 0;
49
-    private $maxSecondsBetweenRedraws = 1;
50
-    private $output;
51
-    private $step = 0;
52
-    private $max;
53
-    private $startTime;
54
-    private $stepWidth;
55
-    private $percent = 0.0;
56
-    private $formatLineCount;
57
-    private $messages = [];
58
-    private $overwrite = true;
59
-    private $terminal;
60
-    private $previousMessage;
61
-    private $cursor;
62
-
63
-    private static $formatters;
64
-    private static $formats;
65
-
66
-    /**
67
-     * @param int $max Maximum steps (0 if unknown)
68
-     */
69
-    public function __construct(OutputInterface $output, int $max = 0, float $minSecondsBetweenRedraws = 1 / 25)
70
-    {
71
-        if ($output instanceof ConsoleOutputInterface) {
72
-            $output = $output->getErrorOutput();
73
-        }
74
-
75
-        $this->output = $output;
76
-        $this->setMaxSteps($max);
77
-        $this->terminal = new Terminal();
78
-
79
-        if (0 < $minSecondsBetweenRedraws) {
80
-            $this->redrawFreq = null;
81
-            $this->minSecondsBetweenRedraws = $minSecondsBetweenRedraws;
82
-        }
83
-
84
-        if (!$this->output->isDecorated()) {
85
-            // disable overwrite when output does not support ANSI codes.
86
-            $this->overwrite = false;
87
-
88
-            // set a reasonable redraw frequency so output isn't flooded
89
-            $this->redrawFreq = null;
90
-        }
91
-
92
-        $this->startTime = time();
93
-        $this->cursor = new Cursor($output);
94
-    }
95
-
96
-    /**
97
-     * Sets a placeholder formatter for a given name.
98
-     *
99
-     * This method also allow you to override an existing placeholder.
100
-     *
101
-     * @param string   $name     The placeholder name (including the delimiter char like %)
102
-     * @param callable $callable A PHP callable
103
-     */
104
-    public static function setPlaceholderFormatterDefinition(string $name, callable $callable): void
105
-    {
106
-        if (!self::$formatters) {
107
-            self::$formatters = self::initPlaceholderFormatters();
108
-        }
109
-
110
-        self::$formatters[$name] = $callable;
111
-    }
112
-
113
-    /**
114
-     * Gets the placeholder formatter for a given name.
115
-     *
116
-     * @param string $name The placeholder name (including the delimiter char like %)
117
-     *
118
-     * @return callable|null A PHP callable
119
-     */
120
-    public static function getPlaceholderFormatterDefinition(string $name): ?callable
121
-    {
122
-        if (!self::$formatters) {
123
-            self::$formatters = self::initPlaceholderFormatters();
124
-        }
125
-
126
-        return self::$formatters[$name] ?? null;
127
-    }
128
-
129
-    /**
130
-     * Sets a format for a given name.
131
-     *
132
-     * This method also allow you to override an existing format.
133
-     *
134
-     * @param string $name   The format name
135
-     * @param string $format A format string
136
-     */
137
-    public static function setFormatDefinition(string $name, string $format): void
138
-    {
139
-        if (!self::$formats) {
140
-            self::$formats = self::initFormats();
141
-        }
142
-
143
-        self::$formats[$name] = $format;
144
-    }
145
-
146
-    /**
147
-     * Gets the format for a given name.
148
-     *
149
-     * @param string $name The format name
150
-     *
151
-     * @return string|null A format string
152
-     */
153
-    public static function getFormatDefinition(string $name): ?string
154
-    {
155
-        if (!self::$formats) {
156
-            self::$formats = self::initFormats();
157
-        }
158
-
159
-        return self::$formats[$name] ?? null;
160
-    }
161
-
162
-    /**
163
-     * Associates a text with a named placeholder.
164
-     *
165
-     * The text is displayed when the progress bar is rendered but only
166
-     * when the corresponding placeholder is part of the custom format line
167
-     * (by wrapping the name with %).
168
-     *
169
-     * @param string $message The text to associate with the placeholder
170
-     * @param string $name    The name of the placeholder
171
-     */
172
-    public function setMessage(string $message, string $name = 'message')
173
-    {
174
-        $this->messages[$name] = $message;
175
-    }
176
-
177
-    public function getMessage(string $name = 'message')
178
-    {
179
-        return $this->messages[$name];
180
-    }
181
-
182
-    public function getStartTime(): int
183
-    {
184
-        return $this->startTime;
185
-    }
186
-
187
-    public function getMaxSteps(): int
188
-    {
189
-        return $this->max;
190
-    }
191
-
192
-    public function getProgress(): int
193
-    {
194
-        return $this->step;
195
-    }
196
-
197
-    private function getStepWidth(): int
198
-    {
199
-        return $this->stepWidth;
200
-    }
201
-
202
-    public function getProgressPercent(): float
203
-    {
204
-        return $this->percent;
205
-    }
206
-
207
-    public function getBarOffset(): float
208
-    {
209
-        return floor($this->max ? $this->percent * $this->barWidth : (null === $this->redrawFreq ? (int) (min(5, $this->barWidth / 15) * $this->writeCount) : $this->step) % $this->barWidth);
210
-    }
211
-
212
-    public function getEstimated(): float
213
-    {
214
-        if (!$this->step) {
215
-            return 0;
216
-        }
217
-
218
-        return round((time() - $this->startTime) / $this->step * $this->max);
219
-    }
220
-
221
-    public function getRemaining(): float
222
-    {
223
-        if (!$this->step) {
224
-            return 0;
225
-        }
226
-
227
-        return round((time() - $this->startTime) / $this->step * ($this->max - $this->step));
228
-    }
229
-
230
-    public function setBarWidth(int $size)
231
-    {
232
-        $this->barWidth = max(1, $size);
233
-    }
234
-
235
-    public function getBarWidth(): int
236
-    {
237
-        return $this->barWidth;
238
-    }
239
-
240
-    public function setBarCharacter(string $char)
241
-    {
242
-        $this->barChar = $char;
243
-    }
244
-
245
-    public function getBarCharacter(): string
246
-    {
247
-        if (null === $this->barChar) {
248
-            return $this->max ? '=' : $this->emptyBarChar;
249
-        }
250
-
251
-        return $this->barChar;
252
-    }
253
-
254
-    public function setEmptyBarCharacter(string $char)
255
-    {
256
-        $this->emptyBarChar = $char;
257
-    }
258
-
259
-    public function getEmptyBarCharacter(): string
260
-    {
261
-        return $this->emptyBarChar;
262
-    }
263
-
264
-    public function setProgressCharacter(string $char)
265
-    {
266
-        $this->progressChar = $char;
267
-    }
268
-
269
-    public function getProgressCharacter(): string
270
-    {
271
-        return $this->progressChar;
272
-    }
273
-
274
-    public function setFormat(string $format)
275
-    {
276
-        $this->format = null;
277
-        $this->internalFormat = $format;
278
-    }
279
-
280
-    /**
281
-     * Sets the redraw frequency.
282
-     *
283
-     * @param int|null $freq The frequency in steps
284
-     */
285
-    public function setRedrawFrequency(?int $freq)
286
-    {
287
-        $this->redrawFreq = null !== $freq ? max(1, $freq) : null;
288
-    }
289
-
290
-    public function minSecondsBetweenRedraws(float $seconds): void
291
-    {
292
-        $this->minSecondsBetweenRedraws = $seconds;
293
-    }
294
-
295
-    public function maxSecondsBetweenRedraws(float $seconds): void
296
-    {
297
-        $this->maxSecondsBetweenRedraws = $seconds;
298
-    }
299
-
300
-    /**
301
-     * Returns an iterator that will automatically update the progress bar when iterated.
302
-     *
303
-     * @param int|null $max Number of steps to complete the bar (0 if indeterminate), if null it will be inferred from $iterable
304
-     */
305
-    public function iterate(iterable $iterable, int $max = null): iterable
306
-    {
307
-        $this->start($max ?? (is_countable($iterable) ? \count($iterable) : 0));
308
-
309
-        foreach ($iterable as $key => $value) {
310
-            yield $key => $value;
311
-
312
-            $this->advance();
313
-        }
314
-
315
-        $this->finish();
316
-    }
317
-
318
-    /**
319
-     * Starts the progress output.
320
-     *
321
-     * @param int|null $max Number of steps to complete the bar (0 if indeterminate), null to leave unchanged
322
-     */
323
-    public function start(int $max = null)
324
-    {
325
-        $this->startTime = time();
326
-        $this->step = 0;
327
-        $this->percent = 0.0;
328
-
329
-        if (null !== $max) {
330
-            $this->setMaxSteps($max);
331
-        }
332
-
333
-        $this->display();
334
-    }
335
-
336
-    /**
337
-     * Advances the progress output X steps.
338
-     *
339
-     * @param int $step Number of steps to advance
340
-     */
341
-    public function advance(int $step = 1)
342
-    {
343
-        $this->setProgress($this->step + $step);
344
-    }
345
-
346
-    /**
347
-     * Sets whether to overwrite the progressbar, false for new line.
348
-     */
349
-    public function setOverwrite(bool $overwrite)
350
-    {
351
-        $this->overwrite = $overwrite;
352
-    }
353
-
354
-    public function setProgress(int $step)
355
-    {
356
-        if ($this->max && $step > $this->max) {
357
-            $this->max = $step;
358
-        } elseif ($step < 0) {
359
-            $step = 0;
360
-        }
361
-
362
-        $redrawFreq = $this->redrawFreq ?? (($this->max ?: 10) / 10);
363
-        $prevPeriod = (int) ($this->step / $redrawFreq);
364
-        $currPeriod = (int) ($step / $redrawFreq);
365
-        $this->step = $step;
366
-        $this->percent = $this->max ? (float) $this->step / $this->max : 0;
367
-        $timeInterval = microtime(true) - $this->lastWriteTime;
368
-
369
-        // Draw regardless of other limits
370
-        if ($this->max === $step) {
371
-            $this->display();
372
-
373
-            return;
374
-        }
375
-
376
-        // Throttling
377
-        if ($timeInterval < $this->minSecondsBetweenRedraws) {
378
-            return;
379
-        }
380
-
381
-        // Draw each step period, but not too late
382
-        if ($prevPeriod !== $currPeriod || $timeInterval >= $this->maxSecondsBetweenRedraws) {
383
-            $this->display();
384
-        }
385
-    }
386
-
387
-    public function setMaxSteps(int $max)
388
-    {
389
-        $this->format = null;
390
-        $this->max = max(0, $max);
391
-        $this->stepWidth = $this->max ? Helper::width((string) $this->max) : 4;
392
-    }
393
-
394
-    /**
395
-     * Finishes the progress output.
396
-     */
397
-    public function finish(): void
398
-    {
399
-        if (!$this->max) {
400
-            $this->max = $this->step;
401
-        }
402
-
403
-        if ($this->step === $this->max && !$this->overwrite) {
404
-            // prevent double 100% output
405
-            return;
406
-        }
407
-
408
-        $this->setProgress($this->max);
409
-    }
410
-
411
-    /**
412
-     * Outputs the current progress string.
413
-     */
414
-    public function display(): void
415
-    {
416
-        if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
417
-            return;
418
-        }
419
-
420
-        if (null === $this->format) {
421
-            $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
422
-        }
423
-
424
-        $this->overwrite($this->buildLine());
425
-    }
426
-
427
-    /**
428
-     * Removes the progress bar from the current line.
429
-     *
430
-     * This is useful if you wish to write some output
431
-     * while a progress bar is running.
432
-     * Call display() to show the progress bar again.
433
-     */
434
-    public function clear(): void
435
-    {
436
-        if (!$this->overwrite) {
437
-            return;
438
-        }
439
-
440
-        if (null === $this->format) {
441
-            $this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
442
-        }
443
-
444
-        $this->overwrite('');
445
-    }
446
-
447
-    private function setRealFormat(string $format)
448
-    {
449
-        // try to use the _nomax variant if available
450
-        if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
451
-            $this->format = self::getFormatDefinition($format.'_nomax');
452
-        } elseif (null !== self::getFormatDefinition($format)) {
453
-            $this->format = self::getFormatDefinition($format);
454
-        } else {
455
-            $this->format = $format;
456
-        }
457
-
458
-        $this->formatLineCount = substr_count($this->format, "\n");
459
-    }
460
-
461
-    /**
462
-     * Overwrites a previous message to the output.
463
-     */
464
-    private function overwrite(string $message): void
465
-    {
466
-        if ($this->previousMessage === $message) {
467
-            return;
468
-        }
469
-
470
-        $originalMessage = $message;
471
-
472
-        if ($this->overwrite) {
473
-            if (null !== $this->previousMessage) {
474
-                if ($this->output instanceof ConsoleSectionOutput) {
475
-                    $messageLines = explode("\n", $message);
476
-                    $lineCount = \count($messageLines);
477
-                    foreach ($messageLines as $messageLine) {
478
-                        $messageLineLength = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $messageLine));
479
-                        if ($messageLineLength > $this->terminal->getWidth()) {
480
-                            $lineCount += floor($messageLineLength / $this->terminal->getWidth());
481
-                        }
482
-                    }
483
-                    $this->output->clear($lineCount);
484
-                } else {
485
-                    for ($i = 0; $i < $this->formatLineCount; ++$i) {
486
-                        $this->cursor->moveToColumn(1);
487
-                        $this->cursor->clearLine();
488
-                        $this->cursor->moveUp();
489
-                    }
490
-
491
-                    $this->cursor->moveToColumn(1);
492
-                    $this->cursor->clearLine();
493
-                }
494
-            }
495
-        } elseif ($this->step > 0) {
496
-            $message = \PHP_EOL.$message;
497
-        }
498
-
499
-        $this->previousMessage = $originalMessage;
500
-        $this->lastWriteTime = microtime(true);
501
-
502
-        $this->output->write($message);
503
-        ++$this->writeCount;
504
-    }
505
-
506
-    private function determineBestFormat(): string
507
-    {
508
-        switch ($this->output->getVerbosity()) {
509
-            // OutputInterface::VERBOSITY_QUIET: display is disabled anyway
510
-            case OutputInterface::VERBOSITY_VERBOSE:
511
-                return $this->max ? self::FORMAT_VERBOSE : self::FORMAT_VERBOSE_NOMAX;
512
-            case OutputInterface::VERBOSITY_VERY_VERBOSE:
513
-                return $this->max ? self::FORMAT_VERY_VERBOSE : self::FORMAT_VERY_VERBOSE_NOMAX;
514
-            case OutputInterface::VERBOSITY_DEBUG:
515
-                return $this->max ? self::FORMAT_DEBUG : self::FORMAT_DEBUG_NOMAX;
516
-            default:
517
-                return $this->max ? self::FORMAT_NORMAL : self::FORMAT_NORMAL_NOMAX;
518
-        }
519
-    }
520
-
521
-    private static function initPlaceholderFormatters(): array
522
-    {
523
-        return [
524
-            'bar' => function (self $bar, OutputInterface $output) {
525
-                $completeBars = $bar->getBarOffset();
526
-                $display = str_repeat($bar->getBarCharacter(), $completeBars);
527
-                if ($completeBars < $bar->getBarWidth()) {
528
-                    $emptyBars = $bar->getBarWidth() - $completeBars - Helper::length(Helper::removeDecoration($output->getFormatter(), $bar->getProgressCharacter()));
529
-                    $display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
530
-                }
531
-
532
-                return $display;
533
-            },
534
-            'elapsed' => function (self $bar) {
535
-                return Helper::formatTime(time() - $bar->getStartTime());
536
-            },
537
-            'remaining' => function (self $bar) {
538
-                if (!$bar->getMaxSteps()) {
539
-                    throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
540
-                }
541
-
542
-                return Helper::formatTime($bar->getRemaining());
543
-            },
544
-            'estimated' => function (self $bar) {
545
-                if (!$bar->getMaxSteps()) {
546
-                    throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
547
-                }
548
-
549
-                return Helper::formatTime($bar->getEstimated());
550
-            },
551
-            'memory' => function (self $bar) {
552
-                return Helper::formatMemory(memory_get_usage(true));
553
-            },
554
-            'current' => function (self $bar) {
555
-                return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', \STR_PAD_LEFT);
556
-            },
557
-            'max' => function (self $bar) {
558
-                return $bar->getMaxSteps();
559
-            },
560
-            'percent' => function (self $bar) {
561
-                return floor($bar->getProgressPercent() * 100);
562
-            },
563
-        ];
564
-    }
565
-
566
-    private static function initFormats(): array
567
-    {
568
-        return [
569
-            self::FORMAT_NORMAL => ' %current%/%max% [%bar%] %percent:3s%%',
570
-            self::FORMAT_NORMAL_NOMAX => ' %current% [%bar%]',
571
-
572
-            self::FORMAT_VERBOSE => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
573
-            self::FORMAT_VERBOSE_NOMAX => ' %current% [%bar%] %elapsed:6s%',
574
-
575
-            self::FORMAT_VERY_VERBOSE => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
576
-            self::FORMAT_VERY_VERBOSE_NOMAX => ' %current% [%bar%] %elapsed:6s%',
577
-
578
-            self::FORMAT_DEBUG => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
579
-            self::FORMAT_DEBUG_NOMAX => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
580
-        ];
581
-    }
582
-
583
-    private function buildLine(): string
584
-    {
585
-        $regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
586
-        $callback = function ($matches) {
587
-            if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
588
-                $text = $formatter($this, $this->output);
589
-            } elseif (isset($this->messages[$matches[1]])) {
590
-                $text = $this->messages[$matches[1]];
591
-            } else {
592
-                return $matches[0];
593
-            }
594
-
595
-            if (isset($matches[2])) {
596
-                $text = sprintf('%'.$matches[2], $text);
597
-            }
598
-
599
-            return $text;
600
-        };
601
-        $line = preg_replace_callback($regex, $callback, $this->format);
602
-
603
-        // gets string length for each sub line with multiline format
604
-        $linesLength = array_map(function ($subLine) {
605
-            return Helper::width(Helper::removeDecoration($this->output->getFormatter(), rtrim($subLine, "\r")));
606
-        }, explode("\n", $line));
607
-
608
-        $linesWidth = max($linesLength);
609
-
610
-        $terminalWidth = $this->terminal->getWidth();
611
-        if ($linesWidth <= $terminalWidth) {
612
-            return $line;
613
-        }
614
-
615
-        $this->setBarWidth($this->barWidth - $linesWidth + $terminalWidth);
616
-
617
-        return preg_replace_callback($regex, $callback, $this->format);
618
-    }
29
+	public const FORMAT_VERBOSE = 'verbose';
30
+	public const FORMAT_VERY_VERBOSE = 'very_verbose';
31
+	public const FORMAT_DEBUG = 'debug';
32
+	public const FORMAT_NORMAL = 'normal';
33
+
34
+	private const FORMAT_VERBOSE_NOMAX = 'verbose_nomax';
35
+	private const FORMAT_VERY_VERBOSE_NOMAX = 'very_verbose_nomax';
36
+	private const FORMAT_DEBUG_NOMAX = 'debug_nomax';
37
+	private const FORMAT_NORMAL_NOMAX = 'normal_nomax';
38
+
39
+	private $barWidth = 28;
40
+	private $barChar;
41
+	private $emptyBarChar = '-';
42
+	private $progressChar = '>';
43
+	private $format;
44
+	private $internalFormat;
45
+	private $redrawFreq = 1;
46
+	private $writeCount;
47
+	private $lastWriteTime;
48
+	private $minSecondsBetweenRedraws = 0;
49
+	private $maxSecondsBetweenRedraws = 1;
50
+	private $output;
51
+	private $step = 0;
52
+	private $max;
53
+	private $startTime;
54
+	private $stepWidth;
55
+	private $percent = 0.0;
56
+	private $formatLineCount;
57
+	private $messages = [];
58
+	private $overwrite = true;
59
+	private $terminal;
60
+	private $previousMessage;
61
+	private $cursor;
62
+
63
+	private static $formatters;
64
+	private static $formats;
65
+
66
+	/**
67
+	 * @param int $max Maximum steps (0 if unknown)
68
+	 */
69
+	public function __construct(OutputInterface $output, int $max = 0, float $minSecondsBetweenRedraws = 1 / 25)
70
+	{
71
+		if ($output instanceof ConsoleOutputInterface) {
72
+			$output = $output->getErrorOutput();
73
+		}
74
+
75
+		$this->output = $output;
76
+		$this->setMaxSteps($max);
77
+		$this->terminal = new Terminal();
78
+
79
+		if (0 < $minSecondsBetweenRedraws) {
80
+			$this->redrawFreq = null;
81
+			$this->minSecondsBetweenRedraws = $minSecondsBetweenRedraws;
82
+		}
83
+
84
+		if (!$this->output->isDecorated()) {
85
+			// disable overwrite when output does not support ANSI codes.
86
+			$this->overwrite = false;
87
+
88
+			// set a reasonable redraw frequency so output isn't flooded
89
+			$this->redrawFreq = null;
90
+		}
91
+
92
+		$this->startTime = time();
93
+		$this->cursor = new Cursor($output);
94
+	}
95
+
96
+	/**
97
+	 * Sets a placeholder formatter for a given name.
98
+	 *
99
+	 * This method also allow you to override an existing placeholder.
100
+	 *
101
+	 * @param string   $name     The placeholder name (including the delimiter char like %)
102
+	 * @param callable $callable A PHP callable
103
+	 */
104
+	public static function setPlaceholderFormatterDefinition(string $name, callable $callable): void
105
+	{
106
+		if (!self::$formatters) {
107
+			self::$formatters = self::initPlaceholderFormatters();
108
+		}
109
+
110
+		self::$formatters[$name] = $callable;
111
+	}
112
+
113
+	/**
114
+	 * Gets the placeholder formatter for a given name.
115
+	 *
116
+	 * @param string $name The placeholder name (including the delimiter char like %)
117
+	 *
118
+	 * @return callable|null A PHP callable
119
+	 */
120
+	public static function getPlaceholderFormatterDefinition(string $name): ?callable
121
+	{
122
+		if (!self::$formatters) {
123
+			self::$formatters = self::initPlaceholderFormatters();
124
+		}
125
+
126
+		return self::$formatters[$name] ?? null;
127
+	}
128
+
129
+	/**
130
+	 * Sets a format for a given name.
131
+	 *
132
+	 * This method also allow you to override an existing format.
133
+	 *
134
+	 * @param string $name   The format name
135
+	 * @param string $format A format string
136
+	 */
137
+	public static function setFormatDefinition(string $name, string $format): void
138
+	{
139
+		if (!self::$formats) {
140
+			self::$formats = self::initFormats();
141
+		}
142
+
143
+		self::$formats[$name] = $format;
144
+	}
145
+
146
+	/**
147
+	 * Gets the format for a given name.
148
+	 *
149
+	 * @param string $name The format name
150
+	 *
151
+	 * @return string|null A format string
152
+	 */
153
+	public static function getFormatDefinition(string $name): ?string
154
+	{
155
+		if (!self::$formats) {
156
+			self::$formats = self::initFormats();
157
+		}
158
+
159
+		return self::$formats[$name] ?? null;
160
+	}
161
+
162
+	/**
163
+	 * Associates a text with a named placeholder.
164
+	 *
165
+	 * The text is displayed when the progress bar is rendered but only
166
+	 * when the corresponding placeholder is part of the custom format line
167
+	 * (by wrapping the name with %).
168
+	 *
169
+	 * @param string $message The text to associate with the placeholder
170
+	 * @param string $name    The name of the placeholder
171
+	 */
172
+	public function setMessage(string $message, string $name = 'message')
173
+	{
174
+		$this->messages[$name] = $message;
175
+	}
176
+
177
+	public function getMessage(string $name = 'message')
178
+	{
179
+		return $this->messages[$name];
180
+	}
181
+
182
+	public function getStartTime(): int
183
+	{
184
+		return $this->startTime;
185
+	}
186
+
187
+	public function getMaxSteps(): int
188
+	{
189
+		return $this->max;
190
+	}
191
+
192
+	public function getProgress(): int
193
+	{
194
+		return $this->step;
195
+	}
196
+
197
+	private function getStepWidth(): int
198
+	{
199
+		return $this->stepWidth;
200
+	}
201
+
202
+	public function getProgressPercent(): float
203
+	{
204
+		return $this->percent;
205
+	}
206
+
207
+	public function getBarOffset(): float
208
+	{
209
+		return floor($this->max ? $this->percent * $this->barWidth : (null === $this->redrawFreq ? (int) (min(5, $this->barWidth / 15) * $this->writeCount) : $this->step) % $this->barWidth);
210
+	}
211
+
212
+	public function getEstimated(): float
213
+	{
214
+		if (!$this->step) {
215
+			return 0;
216
+		}
217
+
218
+		return round((time() - $this->startTime) / $this->step * $this->max);
219
+	}
220
+
221
+	public function getRemaining(): float
222
+	{
223
+		if (!$this->step) {
224
+			return 0;
225
+		}
226
+
227
+		return round((time() - $this->startTime) / $this->step * ($this->max - $this->step));
228
+	}
229
+
230
+	public function setBarWidth(int $size)
231
+	{
232
+		$this->barWidth = max(1, $size);
233
+	}
234
+
235
+	public function getBarWidth(): int
236
+	{
237
+		return $this->barWidth;
238
+	}
239
+
240
+	public function setBarCharacter(string $char)
241
+	{
242
+		$this->barChar = $char;
243
+	}
244
+
245
+	public function getBarCharacter(): string
246
+	{
247
+		if (null === $this->barChar) {
248
+			return $this->max ? '=' : $this->emptyBarChar;
249
+		}
250
+
251
+		return $this->barChar;
252
+	}
253
+
254
+	public function setEmptyBarCharacter(string $char)
255
+	{
256
+		$this->emptyBarChar = $char;
257
+	}
258
+
259
+	public function getEmptyBarCharacter(): string
260
+	{
261
+		return $this->emptyBarChar;
262
+	}
263
+
264
+	public function setProgressCharacter(string $char)
265
+	{
266
+		$this->progressChar = $char;
267
+	}
268
+
269
+	public function getProgressCharacter(): string
270
+	{
271
+		return $this->progressChar;
272
+	}
273
+
274
+	public function setFormat(string $format)
275
+	{
276
+		$this->format = null;
277
+		$this->internalFormat = $format;
278
+	}
279
+
280
+	/**
281
+	 * Sets the redraw frequency.
282
+	 *
283
+	 * @param int|null $freq The frequency in steps
284
+	 */
285
+	public function setRedrawFrequency(?int $freq)
286
+	{
287
+		$this->redrawFreq = null !== $freq ? max(1, $freq) : null;
288
+	}
289
+
290
+	public function minSecondsBetweenRedraws(float $seconds): void
291
+	{
292
+		$this->minSecondsBetweenRedraws = $seconds;
293
+	}
294
+
295
+	public function maxSecondsBetweenRedraws(float $seconds): void
296
+	{
297
+		$this->maxSecondsBetweenRedraws = $seconds;
298
+	}
299
+
300
+	/**
301
+	 * Returns an iterator that will automatically update the progress bar when iterated.
302
+	 *
303
+	 * @param int|null $max Number of steps to complete the bar (0 if indeterminate), if null it will be inferred from $iterable
304
+	 */
305
+	public function iterate(iterable $iterable, int $max = null): iterable
306
+	{
307
+		$this->start($max ?? (is_countable($iterable) ? \count($iterable) : 0));
308
+
309
+		foreach ($iterable as $key => $value) {
310
+			yield $key => $value;
311
+
312
+			$this->advance();
313
+		}
314
+
315
+		$this->finish();
316
+	}
317
+
318
+	/**
319
+	 * Starts the progress output.
320
+	 *
321
+	 * @param int|null $max Number of steps to complete the bar (0 if indeterminate), null to leave unchanged
322
+	 */
323
+	public function start(int $max = null)
324
+	{
325
+		$this->startTime = time();
326
+		$this->step = 0;
327
+		$this->percent = 0.0;
328
+
329
+		if (null !== $max) {
330
+			$this->setMaxSteps($max);
331
+		}
332
+
333
+		$this->display();
334
+	}
335
+
336
+	/**
337
+	 * Advances the progress output X steps.
338
+	 *
339
+	 * @param int $step Number of steps to advance
340
+	 */
341
+	public function advance(int $step = 1)
342
+	{
343
+		$this->setProgress($this->step + $step);
344
+	}
345
+
346
+	/**
347
+	 * Sets whether to overwrite the progressbar, false for new line.
348
+	 */
349
+	public function setOverwrite(bool $overwrite)
350
+	{
351
+		$this->overwrite = $overwrite;
352
+	}
353
+
354
+	public function setProgress(int $step)
355
+	{
356
+		if ($this->max && $step > $this->max) {
357
+			$this->max = $step;
358
+		} elseif ($step < 0) {
359
+			$step = 0;
360
+		}
361
+
362
+		$redrawFreq = $this->redrawFreq ?? (($this->max ?: 10) / 10);
363
+		$prevPeriod = (int) ($this->step / $redrawFreq);
364
+		$currPeriod = (int) ($step / $redrawFreq);
365
+		$this->step = $step;
366
+		$this->percent = $this->max ? (float) $this->step / $this->max : 0;
367
+		$timeInterval = microtime(true) - $this->lastWriteTime;
368
+
369
+		// Draw regardless of other limits
370
+		if ($this->max === $step) {
371
+			$this->display();
372
+
373
+			return;
374
+		}
375
+
376
+		// Throttling
377
+		if ($timeInterval < $this->minSecondsBetweenRedraws) {
378
+			return;
379
+		}
380
+
381
+		// Draw each step period, but not too late
382
+		if ($prevPeriod !== $currPeriod || $timeInterval >= $this->maxSecondsBetweenRedraws) {
383
+			$this->display();
384
+		}
385
+	}
386
+
387
+	public function setMaxSteps(int $max)
388
+	{
389
+		$this->format = null;
390
+		$this->max = max(0, $max);
391
+		$this->stepWidth = $this->max ? Helper::width((string) $this->max) : 4;
392
+	}
393
+
394
+	/**
395
+	 * Finishes the progress output.
396
+	 */
397
+	public function finish(): void
398
+	{
399
+		if (!$this->max) {
400
+			$this->max = $this->step;
401
+		}
402
+
403
+		if ($this->step === $this->max && !$this->overwrite) {
404
+			// prevent double 100% output
405
+			return;
406
+		}
407
+
408
+		$this->setProgress($this->max);
409
+	}
410
+
411
+	/**
412
+	 * Outputs the current progress string.
413
+	 */
414
+	public function display(): void
415
+	{
416
+		if (OutputInterface::VERBOSITY_QUIET === $this->output->getVerbosity()) {
417
+			return;
418
+		}
419
+
420
+		if (null === $this->format) {
421
+			$this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
422
+		}
423
+
424
+		$this->overwrite($this->buildLine());
425
+	}
426
+
427
+	/**
428
+	 * Removes the progress bar from the current line.
429
+	 *
430
+	 * This is useful if you wish to write some output
431
+	 * while a progress bar is running.
432
+	 * Call display() to show the progress bar again.
433
+	 */
434
+	public function clear(): void
435
+	{
436
+		if (!$this->overwrite) {
437
+			return;
438
+		}
439
+
440
+		if (null === $this->format) {
441
+			$this->setRealFormat($this->internalFormat ?: $this->determineBestFormat());
442
+		}
443
+
444
+		$this->overwrite('');
445
+	}
446
+
447
+	private function setRealFormat(string $format)
448
+	{
449
+		// try to use the _nomax variant if available
450
+		if (!$this->max && null !== self::getFormatDefinition($format.'_nomax')) {
451
+			$this->format = self::getFormatDefinition($format.'_nomax');
452
+		} elseif (null !== self::getFormatDefinition($format)) {
453
+			$this->format = self::getFormatDefinition($format);
454
+		} else {
455
+			$this->format = $format;
456
+		}
457
+
458
+		$this->formatLineCount = substr_count($this->format, "\n");
459
+	}
460
+
461
+	/**
462
+	 * Overwrites a previous message to the output.
463
+	 */
464
+	private function overwrite(string $message): void
465
+	{
466
+		if ($this->previousMessage === $message) {
467
+			return;
468
+		}
469
+
470
+		$originalMessage = $message;
471
+
472
+		if ($this->overwrite) {
473
+			if (null !== $this->previousMessage) {
474
+				if ($this->output instanceof ConsoleSectionOutput) {
475
+					$messageLines = explode("\n", $message);
476
+					$lineCount = \count($messageLines);
477
+					foreach ($messageLines as $messageLine) {
478
+						$messageLineLength = Helper::width(Helper::removeDecoration($this->output->getFormatter(), $messageLine));
479
+						if ($messageLineLength > $this->terminal->getWidth()) {
480
+							$lineCount += floor($messageLineLength / $this->terminal->getWidth());
481
+						}
482
+					}
483
+					$this->output->clear($lineCount);
484
+				} else {
485
+					for ($i = 0; $i < $this->formatLineCount; ++$i) {
486
+						$this->cursor->moveToColumn(1);
487
+						$this->cursor->clearLine();
488
+						$this->cursor->moveUp();
489
+					}
490
+
491
+					$this->cursor->moveToColumn(1);
492
+					$this->cursor->clearLine();
493
+				}
494
+			}
495
+		} elseif ($this->step > 0) {
496
+			$message = \PHP_EOL.$message;
497
+		}
498
+
499
+		$this->previousMessage = $originalMessage;
500
+		$this->lastWriteTime = microtime(true);
501
+
502
+		$this->output->write($message);
503
+		++$this->writeCount;
504
+	}
505
+
506
+	private function determineBestFormat(): string
507
+	{
508
+		switch ($this->output->getVerbosity()) {
509
+			// OutputInterface::VERBOSITY_QUIET: display is disabled anyway
510
+			case OutputInterface::VERBOSITY_VERBOSE:
511
+				return $this->max ? self::FORMAT_VERBOSE : self::FORMAT_VERBOSE_NOMAX;
512
+			case OutputInterface::VERBOSITY_VERY_VERBOSE:
513
+				return $this->max ? self::FORMAT_VERY_VERBOSE : self::FORMAT_VERY_VERBOSE_NOMAX;
514
+			case OutputInterface::VERBOSITY_DEBUG:
515
+				return $this->max ? self::FORMAT_DEBUG : self::FORMAT_DEBUG_NOMAX;
516
+			default:
517
+				return $this->max ? self::FORMAT_NORMAL : self::FORMAT_NORMAL_NOMAX;
518
+		}
519
+	}
520
+
521
+	private static function initPlaceholderFormatters(): array
522
+	{
523
+		return [
524
+			'bar' => function (self $bar, OutputInterface $output) {
525
+				$completeBars = $bar->getBarOffset();
526
+				$display = str_repeat($bar->getBarCharacter(), $completeBars);
527
+				if ($completeBars < $bar->getBarWidth()) {
528
+					$emptyBars = $bar->getBarWidth() - $completeBars - Helper::length(Helper::removeDecoration($output->getFormatter(), $bar->getProgressCharacter()));
529
+					$display .= $bar->getProgressCharacter().str_repeat($bar->getEmptyBarCharacter(), $emptyBars);
530
+				}
531
+
532
+				return $display;
533
+			},
534
+			'elapsed' => function (self $bar) {
535
+				return Helper::formatTime(time() - $bar->getStartTime());
536
+			},
537
+			'remaining' => function (self $bar) {
538
+				if (!$bar->getMaxSteps()) {
539
+					throw new LogicException('Unable to display the remaining time if the maximum number of steps is not set.');
540
+				}
541
+
542
+				return Helper::formatTime($bar->getRemaining());
543
+			},
544
+			'estimated' => function (self $bar) {
545
+				if (!$bar->getMaxSteps()) {
546
+					throw new LogicException('Unable to display the estimated time if the maximum number of steps is not set.');
547
+				}
548
+
549
+				return Helper::formatTime($bar->getEstimated());
550
+			},
551
+			'memory' => function (self $bar) {
552
+				return Helper::formatMemory(memory_get_usage(true));
553
+			},
554
+			'current' => function (self $bar) {
555
+				return str_pad($bar->getProgress(), $bar->getStepWidth(), ' ', \STR_PAD_LEFT);
556
+			},
557
+			'max' => function (self $bar) {
558
+				return $bar->getMaxSteps();
559
+			},
560
+			'percent' => function (self $bar) {
561
+				return floor($bar->getProgressPercent() * 100);
562
+			},
563
+		];
564
+	}
565
+
566
+	private static function initFormats(): array
567
+	{
568
+		return [
569
+			self::FORMAT_NORMAL => ' %current%/%max% [%bar%] %percent:3s%%',
570
+			self::FORMAT_NORMAL_NOMAX => ' %current% [%bar%]',
571
+
572
+			self::FORMAT_VERBOSE => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%',
573
+			self::FORMAT_VERBOSE_NOMAX => ' %current% [%bar%] %elapsed:6s%',
574
+
575
+			self::FORMAT_VERY_VERBOSE => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s%',
576
+			self::FORMAT_VERY_VERBOSE_NOMAX => ' %current% [%bar%] %elapsed:6s%',
577
+
578
+			self::FORMAT_DEBUG => ' %current%/%max% [%bar%] %percent:3s%% %elapsed:6s%/%estimated:-6s% %memory:6s%',
579
+			self::FORMAT_DEBUG_NOMAX => ' %current% [%bar%] %elapsed:6s% %memory:6s%',
580
+		];
581
+	}
582
+
583
+	private function buildLine(): string
584
+	{
585
+		$regex = "{%([a-z\-_]+)(?:\:([^%]+))?%}i";
586
+		$callback = function ($matches) {
587
+			if ($formatter = $this::getPlaceholderFormatterDefinition($matches[1])) {
588
+				$text = $formatter($this, $this->output);
589
+			} elseif (isset($this->messages[$matches[1]])) {
590
+				$text = $this->messages[$matches[1]];
591
+			} else {
592
+				return $matches[0];
593
+			}
594
+
595
+			if (isset($matches[2])) {
596
+				$text = sprintf('%'.$matches[2], $text);
597
+			}
598
+
599
+			return $text;
600
+		};
601
+		$line = preg_replace_callback($regex, $callback, $this->format);
602
+
603
+		// gets string length for each sub line with multiline format
604
+		$linesLength = array_map(function ($subLine) {
605
+			return Helper::width(Helper::removeDecoration($this->output->getFormatter(), rtrim($subLine, "\r")));
606
+		}, explode("\n", $line));
607
+
608
+		$linesWidth = max($linesLength);
609
+
610
+		$terminalWidth = $this->terminal->getWidth();
611
+		if ($linesWidth <= $terminalWidth) {
612
+			return $line;
613
+		}
614
+
615
+		$this->setBarWidth($this->barWidth - $linesWidth + $terminalWidth);
616
+
617
+		return preg_replace_callback($regex, $callback, $this->format);
618
+	}
619 619
 }
Please login to merge, or discard this patch.
vendor/symfony/console/Helper/TableCellStyle.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -18,69 +18,69 @@
 block discarded – undo
18 18
  */
19 19
 class TableCellStyle
20 20
 {
21
-    public const DEFAULT_ALIGN = 'left';
21
+	public const DEFAULT_ALIGN = 'left';
22 22
 
23
-    private $options = [
24
-        'fg' => 'default',
25
-        'bg' => 'default',
26
-        'options' => null,
27
-        'align' => self::DEFAULT_ALIGN,
28
-        'cellFormat' => null,
29
-    ];
23
+	private $options = [
24
+		'fg' => 'default',
25
+		'bg' => 'default',
26
+		'options' => null,
27
+		'align' => self::DEFAULT_ALIGN,
28
+		'cellFormat' => null,
29
+	];
30 30
 
31
-    private $tagOptions = [
32
-        'fg',
33
-        'bg',
34
-        'options',
35
-    ];
31
+	private $tagOptions = [
32
+		'fg',
33
+		'bg',
34
+		'options',
35
+	];
36 36
 
37
-    private $alignMap = [
38
-        'left' => \STR_PAD_RIGHT,
39
-        'center' => \STR_PAD_BOTH,
40
-        'right' => \STR_PAD_LEFT,
41
-    ];
37
+	private $alignMap = [
38
+		'left' => \STR_PAD_RIGHT,
39
+		'center' => \STR_PAD_BOTH,
40
+		'right' => \STR_PAD_LEFT,
41
+	];
42 42
 
43
-    public function __construct(array $options = [])
44
-    {
45
-        if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
46
-            throw new InvalidArgumentException(sprintf('The TableCellStyle does not support the following options: \'%s\'.', implode('\', \'', $diff)));
47
-        }
43
+	public function __construct(array $options = [])
44
+	{
45
+		if ($diff = array_diff(array_keys($options), array_keys($this->options))) {
46
+			throw new InvalidArgumentException(sprintf('The TableCellStyle does not support the following options: \'%s\'.', implode('\', \'', $diff)));
47
+		}
48 48
 
49
-        if (isset($options['align']) && !\array_key_exists($options['align'], $this->alignMap)) {
50
-            throw new InvalidArgumentException(sprintf('Wrong align value. Value must be following: \'%s\'.', implode('\', \'', array_keys($this->alignMap))));
51
-        }
49
+		if (isset($options['align']) && !\array_key_exists($options['align'], $this->alignMap)) {
50
+			throw new InvalidArgumentException(sprintf('Wrong align value. Value must be following: \'%s\'.', implode('\', \'', array_keys($this->alignMap))));
51
+		}
52 52
 
53
-        $this->options = array_merge($this->options, $options);
54
-    }
53
+		$this->options = array_merge($this->options, $options);
54
+	}
55 55
 
56
-    public function getOptions(): array
57
-    {
58
-        return $this->options;
59
-    }
56
+	public function getOptions(): array
57
+	{
58
+		return $this->options;
59
+	}
60 60
 
61
-    /**
62
-     * Gets options we need for tag for example fg, bg.
63
-     *
64
-     * @return string[]
65
-     */
66
-    public function getTagOptions()
67
-    {
68
-        return array_filter(
69
-            $this->getOptions(),
70
-            function ($key) {
71
-                return \in_array($key, $this->tagOptions) && isset($this->options[$key]);
72
-            },
73
-            \ARRAY_FILTER_USE_KEY
74
-        );
75
-    }
61
+	/**
62
+	 * Gets options we need for tag for example fg, bg.
63
+	 *
64
+	 * @return string[]
65
+	 */
66
+	public function getTagOptions()
67
+	{
68
+		return array_filter(
69
+			$this->getOptions(),
70
+			function ($key) {
71
+				return \in_array($key, $this->tagOptions) && isset($this->options[$key]);
72
+			},
73
+			\ARRAY_FILTER_USE_KEY
74
+		);
75
+	}
76 76
 
77
-    public function getPadByAlign()
78
-    {
79
-        return $this->alignMap[$this->getOptions()['align']];
80
-    }
77
+	public function getPadByAlign()
78
+	{
79
+		return $this->alignMap[$this->getOptions()['align']];
80
+	}
81 81
 
82
-    public function getCellFormat(): ?string
83
-    {
84
-        return $this->getOptions()['cellFormat'];
85
-    }
82
+	public function getCellFormat(): ?string
83
+	{
84
+		return $this->getOptions()['cellFormat'];
85
+	}
86 86
 }
Please login to merge, or discard this patch.
vendor/symfony/console/Helper/TableStyle.php 1 patch
Indentation   +338 added lines, -338 removed lines patch added patch discarded remove patch
@@ -23,342 +23,342 @@
 block discarded – undo
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
-    public function setHorizontalBorderChars(string $outside, string $inside = null): self
92
-    {
93
-        $this->horizontalOutsideBorderChar = $outside;
94
-        $this->horizontalInsideBorderChar = $inside ?? $outside;
95
-
96
-        return $this;
97
-    }
98
-
99
-    /**
100
-     * Sets vertical border characters.
101
-     *
102
-     * <code>
103
-     * ╔═══════════════╤══════════════════════════╤══════════════════╗
104
-     * ║ ISBN          │ Title                    │ Author           ║
105
-     * ╠═══════1═══════╪══════════════════════════╪══════════════════╣
106
-     * ║ 99921-58-10-7 │ Divine Comedy            │ Dante Alighieri  ║
107
-     * ║ 9971-5-0210-0 │ A Tale of Two Cities     │ Charles Dickens  ║
108
-     * ╟───────2───────┼──────────────────────────┼──────────────────╢
109
-     * ║ 960-425-059-0 │ The Lord of the Rings    │ J. R. R. Tolkien ║
110
-     * ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie  ║
111
-     * ╚═══════════════╧══════════════════════════╧══════════════════╝
112
-     * </code>
113
-     */
114
-    public function setVerticalBorderChars(string $outside, string $inside = null): self
115
-    {
116
-        $this->verticalOutsideBorderChar = $outside;
117
-        $this->verticalInsideBorderChar = $inside ?? $outside;
118
-
119
-        return $this;
120
-    }
121
-
122
-    /**
123
-     * Gets border characters.
124
-     *
125
-     * @internal
126
-     */
127
-    public function getBorderChars(): array
128
-    {
129
-        return [
130
-            $this->horizontalOutsideBorderChar,
131
-            $this->verticalOutsideBorderChar,
132
-            $this->horizontalInsideBorderChar,
133
-            $this->verticalInsideBorderChar,
134
-        ];
135
-    }
136
-
137
-    /**
138
-     * Sets crossing characters.
139
-     *
140
-     * Example:
141
-     * <code>
142
-     * 1═══════════════2══════════════════════════2══════════════════3
143
-     * ║ ISBN          │ Title                    │ Author           ║
144
-     * 8'══════════════0'═════════════════════════0'═════════════════4'
145
-     * ║ 99921-58-10-7 │ Divine Comedy            │ Dante Alighieri  ║
146
-     * ║ 9971-5-0210-0 │ A Tale of Two Cities     │ Charles Dickens  ║
147
-     * 8───────────────0──────────────────────────0──────────────────4
148
-     * ║ 960-425-059-0 │ The Lord of the Rings    │ J. R. R. Tolkien ║
149
-     * ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie  ║
150
-     * 7═══════════════6══════════════════════════6══════════════════5
151
-     * </code>
152
-     *
153
-     * @param string      $cross          Crossing char (see #0 of example)
154
-     * @param string      $topLeft        Top left char (see #1 of example)
155
-     * @param string      $topMid         Top mid char (see #2 of example)
156
-     * @param string      $topRight       Top right char (see #3 of example)
157
-     * @param string      $midRight       Mid right char (see #4 of example)
158
-     * @param string      $bottomRight    Bottom right char (see #5 of example)
159
-     * @param string      $bottomMid      Bottom mid char (see #6 of example)
160
-     * @param string      $bottomLeft     Bottom left char (see #7 of example)
161
-     * @param string      $midLeft        Mid left char (see #8 of example)
162
-     * @param string|null $topLeftBottom  Top left bottom char (see #8' of example), equals to $midLeft if null
163
-     * @param string|null $topMidBottom   Top mid bottom char (see #0' of example), equals to $cross if null
164
-     * @param string|null $topRightBottom Top right bottom char (see #4' of example), equals to $midRight if null
165
-     */
166
-    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
167
-    {
168
-        $this->crossingChar = $cross;
169
-        $this->crossingTopLeftChar = $topLeft;
170
-        $this->crossingTopMidChar = $topMid;
171
-        $this->crossingTopRightChar = $topRight;
172
-        $this->crossingMidRightChar = $midRight;
173
-        $this->crossingBottomRightChar = $bottomRight;
174
-        $this->crossingBottomMidChar = $bottomMid;
175
-        $this->crossingBottomLeftChar = $bottomLeft;
176
-        $this->crossingMidLeftChar = $midLeft;
177
-        $this->crossingTopLeftBottomChar = $topLeftBottom ?? $midLeft;
178
-        $this->crossingTopMidBottomChar = $topMidBottom ?? $cross;
179
-        $this->crossingTopRightBottomChar = $topRightBottom ?? $midRight;
180
-
181
-        return $this;
182
-    }
183
-
184
-    /**
185
-     * Sets default crossing character used for each cross.
186
-     *
187
-     * @see {@link setCrossingChars()} for setting each crossing individually.
188
-     */
189
-    public function setDefaultCrossingChar(string $char): self
190
-    {
191
-        return $this->setCrossingChars($char, $char, $char, $char, $char, $char, $char, $char, $char);
192
-    }
193
-
194
-    /**
195
-     * Gets crossing character.
196
-     *
197
-     * @return string
198
-     */
199
-    public function getCrossingChar()
200
-    {
201
-        return $this->crossingChar;
202
-    }
203
-
204
-    /**
205
-     * Gets crossing characters.
206
-     *
207
-     * @internal
208
-     */
209
-    public function getCrossingChars(): array
210
-    {
211
-        return [
212
-            $this->crossingChar,
213
-            $this->crossingTopLeftChar,
214
-            $this->crossingTopMidChar,
215
-            $this->crossingTopRightChar,
216
-            $this->crossingMidRightChar,
217
-            $this->crossingBottomRightChar,
218
-            $this->crossingBottomMidChar,
219
-            $this->crossingBottomLeftChar,
220
-            $this->crossingMidLeftChar,
221
-            $this->crossingTopLeftBottomChar,
222
-            $this->crossingTopMidBottomChar,
223
-            $this->crossingTopRightBottomChar,
224
-        ];
225
-    }
226
-
227
-    /**
228
-     * Sets header cell format.
229
-     *
230
-     * @return $this
231
-     */
232
-    public function setCellHeaderFormat(string $cellHeaderFormat)
233
-    {
234
-        $this->cellHeaderFormat = $cellHeaderFormat;
235
-
236
-        return $this;
237
-    }
238
-
239
-    /**
240
-     * Gets header cell format.
241
-     *
242
-     * @return string
243
-     */
244
-    public function getCellHeaderFormat()
245
-    {
246
-        return $this->cellHeaderFormat;
247
-    }
248
-
249
-    /**
250
-     * Sets row cell format.
251
-     *
252
-     * @return $this
253
-     */
254
-    public function setCellRowFormat(string $cellRowFormat)
255
-    {
256
-        $this->cellRowFormat = $cellRowFormat;
257
-
258
-        return $this;
259
-    }
260
-
261
-    /**
262
-     * Gets row cell format.
263
-     *
264
-     * @return string
265
-     */
266
-    public function getCellRowFormat()
267
-    {
268
-        return $this->cellRowFormat;
269
-    }
270
-
271
-    /**
272
-     * Sets row cell content format.
273
-     *
274
-     * @return $this
275
-     */
276
-    public function setCellRowContentFormat(string $cellRowContentFormat)
277
-    {
278
-        $this->cellRowContentFormat = $cellRowContentFormat;
279
-
280
-        return $this;
281
-    }
282
-
283
-    /**
284
-     * Gets row cell content format.
285
-     *
286
-     * @return string
287
-     */
288
-    public function getCellRowContentFormat()
289
-    {
290
-        return $this->cellRowContentFormat;
291
-    }
292
-
293
-    /**
294
-     * Sets table border format.
295
-     *
296
-     * @return $this
297
-     */
298
-    public function setBorderFormat(string $borderFormat)
299
-    {
300
-        $this->borderFormat = $borderFormat;
301
-
302
-        return $this;
303
-    }
304
-
305
-    /**
306
-     * Gets table border format.
307
-     *
308
-     * @return string
309
-     */
310
-    public function getBorderFormat()
311
-    {
312
-        return $this->borderFormat;
313
-    }
314
-
315
-    /**
316
-     * Sets cell padding type.
317
-     *
318
-     * @return $this
319
-     */
320
-    public function setPadType(int $padType)
321
-    {
322
-        if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) {
323
-            throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
324
-        }
325
-
326
-        $this->padType = $padType;
327
-
328
-        return $this;
329
-    }
330
-
331
-    /**
332
-     * Gets cell padding type.
333
-     *
334
-     * @return int
335
-     */
336
-    public function getPadType()
337
-    {
338
-        return $this->padType;
339
-    }
340
-
341
-    public function getHeaderTitleFormat(): string
342
-    {
343
-        return $this->headerTitleFormat;
344
-    }
345
-
346
-    public function setHeaderTitleFormat(string $format): self
347
-    {
348
-        $this->headerTitleFormat = $format;
349
-
350
-        return $this;
351
-    }
352
-
353
-    public function getFooterTitleFormat(): string
354
-    {
355
-        return $this->footerTitleFormat;
356
-    }
357
-
358
-    public function setFooterTitleFormat(string $format): self
359
-    {
360
-        $this->footerTitleFormat = $format;
361
-
362
-        return $this;
363
-    }
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
+	public function setHorizontalBorderChars(string $outside, string $inside = null): self
92
+	{
93
+		$this->horizontalOutsideBorderChar = $outside;
94
+		$this->horizontalInsideBorderChar = $inside ?? $outside;
95
+
96
+		return $this;
97
+	}
98
+
99
+	/**
100
+	 * Sets vertical border characters.
101
+	 *
102
+	 * <code>
103
+	 * ╔═══════════════╤══════════════════════════╤══════════════════╗
104
+	 * ║ ISBN          │ Title                    │ Author           ║
105
+	 * ╠═══════1═══════╪══════════════════════════╪══════════════════╣
106
+	 * ║ 99921-58-10-7 │ Divine Comedy            │ Dante Alighieri  ║
107
+	 * ║ 9971-5-0210-0 │ A Tale of Two Cities     │ Charles Dickens  ║
108
+	 * ╟───────2───────┼──────────────────────────┼──────────────────╢
109
+	 * ║ 960-425-059-0 │ The Lord of the Rings    │ J. R. R. Tolkien ║
110
+	 * ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie  ║
111
+	 * ╚═══════════════╧══════════════════════════╧══════════════════╝
112
+	 * </code>
113
+	 */
114
+	public function setVerticalBorderChars(string $outside, string $inside = null): self
115
+	{
116
+		$this->verticalOutsideBorderChar = $outside;
117
+		$this->verticalInsideBorderChar = $inside ?? $outside;
118
+
119
+		return $this;
120
+	}
121
+
122
+	/**
123
+	 * Gets border characters.
124
+	 *
125
+	 * @internal
126
+	 */
127
+	public function getBorderChars(): array
128
+	{
129
+		return [
130
+			$this->horizontalOutsideBorderChar,
131
+			$this->verticalOutsideBorderChar,
132
+			$this->horizontalInsideBorderChar,
133
+			$this->verticalInsideBorderChar,
134
+		];
135
+	}
136
+
137
+	/**
138
+	 * Sets crossing characters.
139
+	 *
140
+	 * Example:
141
+	 * <code>
142
+	 * 1═══════════════2══════════════════════════2══════════════════3
143
+	 * ║ ISBN          │ Title                    │ Author           ║
144
+	 * 8'══════════════0'═════════════════════════0'═════════════════4'
145
+	 * ║ 99921-58-10-7 │ Divine Comedy            │ Dante Alighieri  ║
146
+	 * ║ 9971-5-0210-0 │ A Tale of Two Cities     │ Charles Dickens  ║
147
+	 * 8───────────────0──────────────────────────0──────────────────4
148
+	 * ║ 960-425-059-0 │ The Lord of the Rings    │ J. R. R. Tolkien ║
149
+	 * ║ 80-902734-1-6 │ And Then There Were None │ Agatha Christie  ║
150
+	 * 7═══════════════6══════════════════════════6══════════════════5
151
+	 * </code>
152
+	 *
153
+	 * @param string      $cross          Crossing char (see #0 of example)
154
+	 * @param string      $topLeft        Top left char (see #1 of example)
155
+	 * @param string      $topMid         Top mid char (see #2 of example)
156
+	 * @param string      $topRight       Top right char (see #3 of example)
157
+	 * @param string      $midRight       Mid right char (see #4 of example)
158
+	 * @param string      $bottomRight    Bottom right char (see #5 of example)
159
+	 * @param string      $bottomMid      Bottom mid char (see #6 of example)
160
+	 * @param string      $bottomLeft     Bottom left char (see #7 of example)
161
+	 * @param string      $midLeft        Mid left char (see #8 of example)
162
+	 * @param string|null $topLeftBottom  Top left bottom char (see #8' of example), equals to $midLeft if null
163
+	 * @param string|null $topMidBottom   Top mid bottom char (see #0' of example), equals to $cross if null
164
+	 * @param string|null $topRightBottom Top right bottom char (see #4' of example), equals to $midRight if null
165
+	 */
166
+	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
167
+	{
168
+		$this->crossingChar = $cross;
169
+		$this->crossingTopLeftChar = $topLeft;
170
+		$this->crossingTopMidChar = $topMid;
171
+		$this->crossingTopRightChar = $topRight;
172
+		$this->crossingMidRightChar = $midRight;
173
+		$this->crossingBottomRightChar = $bottomRight;
174
+		$this->crossingBottomMidChar = $bottomMid;
175
+		$this->crossingBottomLeftChar = $bottomLeft;
176
+		$this->crossingMidLeftChar = $midLeft;
177
+		$this->crossingTopLeftBottomChar = $topLeftBottom ?? $midLeft;
178
+		$this->crossingTopMidBottomChar = $topMidBottom ?? $cross;
179
+		$this->crossingTopRightBottomChar = $topRightBottom ?? $midRight;
180
+
181
+		return $this;
182
+	}
183
+
184
+	/**
185
+	 * Sets default crossing character used for each cross.
186
+	 *
187
+	 * @see {@link setCrossingChars()} for setting each crossing individually.
188
+	 */
189
+	public function setDefaultCrossingChar(string $char): self
190
+	{
191
+		return $this->setCrossingChars($char, $char, $char, $char, $char, $char, $char, $char, $char);
192
+	}
193
+
194
+	/**
195
+	 * Gets crossing character.
196
+	 *
197
+	 * @return string
198
+	 */
199
+	public function getCrossingChar()
200
+	{
201
+		return $this->crossingChar;
202
+	}
203
+
204
+	/**
205
+	 * Gets crossing characters.
206
+	 *
207
+	 * @internal
208
+	 */
209
+	public function getCrossingChars(): array
210
+	{
211
+		return [
212
+			$this->crossingChar,
213
+			$this->crossingTopLeftChar,
214
+			$this->crossingTopMidChar,
215
+			$this->crossingTopRightChar,
216
+			$this->crossingMidRightChar,
217
+			$this->crossingBottomRightChar,
218
+			$this->crossingBottomMidChar,
219
+			$this->crossingBottomLeftChar,
220
+			$this->crossingMidLeftChar,
221
+			$this->crossingTopLeftBottomChar,
222
+			$this->crossingTopMidBottomChar,
223
+			$this->crossingTopRightBottomChar,
224
+		];
225
+	}
226
+
227
+	/**
228
+	 * Sets header cell format.
229
+	 *
230
+	 * @return $this
231
+	 */
232
+	public function setCellHeaderFormat(string $cellHeaderFormat)
233
+	{
234
+		$this->cellHeaderFormat = $cellHeaderFormat;
235
+
236
+		return $this;
237
+	}
238
+
239
+	/**
240
+	 * Gets header cell format.
241
+	 *
242
+	 * @return string
243
+	 */
244
+	public function getCellHeaderFormat()
245
+	{
246
+		return $this->cellHeaderFormat;
247
+	}
248
+
249
+	/**
250
+	 * Sets row cell format.
251
+	 *
252
+	 * @return $this
253
+	 */
254
+	public function setCellRowFormat(string $cellRowFormat)
255
+	{
256
+		$this->cellRowFormat = $cellRowFormat;
257
+
258
+		return $this;
259
+	}
260
+
261
+	/**
262
+	 * Gets row cell format.
263
+	 *
264
+	 * @return string
265
+	 */
266
+	public function getCellRowFormat()
267
+	{
268
+		return $this->cellRowFormat;
269
+	}
270
+
271
+	/**
272
+	 * Sets row cell content format.
273
+	 *
274
+	 * @return $this
275
+	 */
276
+	public function setCellRowContentFormat(string $cellRowContentFormat)
277
+	{
278
+		$this->cellRowContentFormat = $cellRowContentFormat;
279
+
280
+		return $this;
281
+	}
282
+
283
+	/**
284
+	 * Gets row cell content format.
285
+	 *
286
+	 * @return string
287
+	 */
288
+	public function getCellRowContentFormat()
289
+	{
290
+		return $this->cellRowContentFormat;
291
+	}
292
+
293
+	/**
294
+	 * Sets table border format.
295
+	 *
296
+	 * @return $this
297
+	 */
298
+	public function setBorderFormat(string $borderFormat)
299
+	{
300
+		$this->borderFormat = $borderFormat;
301
+
302
+		return $this;
303
+	}
304
+
305
+	/**
306
+	 * Gets table border format.
307
+	 *
308
+	 * @return string
309
+	 */
310
+	public function getBorderFormat()
311
+	{
312
+		return $this->borderFormat;
313
+	}
314
+
315
+	/**
316
+	 * Sets cell padding type.
317
+	 *
318
+	 * @return $this
319
+	 */
320
+	public function setPadType(int $padType)
321
+	{
322
+		if (!\in_array($padType, [\STR_PAD_LEFT, \STR_PAD_RIGHT, \STR_PAD_BOTH], true)) {
323
+			throw new InvalidArgumentException('Invalid padding type. Expected one of (STR_PAD_LEFT, STR_PAD_RIGHT, STR_PAD_BOTH).');
324
+		}
325
+
326
+		$this->padType = $padType;
327
+
328
+		return $this;
329
+	}
330
+
331
+	/**
332
+	 * Gets cell padding type.
333
+	 *
334
+	 * @return int
335
+	 */
336
+	public function getPadType()
337
+	{
338
+		return $this->padType;
339
+	}
340
+
341
+	public function getHeaderTitleFormat(): string
342
+	{
343
+		return $this->headerTitleFormat;
344
+	}
345
+
346
+	public function setHeaderTitleFormat(string $format): self
347
+	{
348
+		$this->headerTitleFormat = $format;
349
+
350
+		return $this;
351
+	}
352
+
353
+	public function getFooterTitleFormat(): string
354
+	{
355
+		return $this->footerTitleFormat;
356
+	}
357
+
358
+	public function setFooterTitleFormat(string $format): self
359
+	{
360
+		$this->footerTitleFormat = $format;
361
+
362
+		return $this;
363
+	}
364 364
 }
Please login to merge, or discard this patch.