PresetOutput::getHelperSet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * AnimeDb package.
4
 *
5
 * @author    Peter Gribanov <[email protected]>
6
 * @copyright Copyright (c) 2011, Peter Gribanov
7
 * @license   http://opensource.org/licenses/GPL-3.0 GPL v3
8
 */
9
10
namespace AnimeDb\Bundle\CatalogBundle\Console\Progress;
11
12
use Symfony\Component\Console\Helper\ProgressHelper;
13
use Symfony\Component\Console\Helper\HelperInterface;
14
use Symfony\Component\Console\Output\OutputInterface;
15
use Symfony\Component\Console\Helper\HelperSet;
16
17
/**
18
 * Preset output for ProgressHelper.
19
 *
20
 * @author  Peter Gribanov <[email protected]>
21
 */
22
class PresetOutput implements HelperInterface
23
{
24
    /**
25
     * @var ProgressHelper
26
     */
27
    protected $progress;
28
29
    /**
30
     * @var OutputInterface
31
     */
32
    protected $output;
33
34
    /**
35
     * @param ProgressHelper $progress
36
     * @param OutputInterface $output
37
     */
38 19
    public function __construct(ProgressHelper $progress, OutputInterface $output)
39
    {
40 19
        $this->progress = $progress;
41 19
        $this->output = $output;
42 19
    }
43
44
    /**
45
     * Sets the helper set associated with this helper.
46
     *
47
     * @param HelperSet $helperSet
48
     */
49 2
    public function setHelperSet(HelperSet $helperSet = null)
50
    {
51 2
        $this->progress->setHelperSet($helperSet);
52 2
    }
53
54
    /**
55
     * Gets the helper set associated with this helper.
56
     *
57
     * @return HelperSet
58
     */
59 1
    public function getHelperSet()
60
    {
61 1
        return $this->progress->getHelperSet();
62
    }
63
64
    /**
65
     * Sets the progress bar width.
66
     *
67
     * @param int $size The progress bar size
68
     */
69 1
    public function setBarWidth($size)
70
    {
71 1
        $this->progress->setBarWidth($size);
72 1
    }
73
74
    /**
75
     * Sets the bar character.
76
     *
77
     * @param string $char A character
78
     */
79 1
    public function setBarCharacter($char)
80
    {
81 1
        $this->progress->setBarCharacter($char);
82 1
    }
83
84
    /**
85
     * Sets the empty bar character.
86
     *
87
     * @param string $char A character
88
     */
89 1
    public function setEmptyBarCharacter($char)
90
    {
91 1
        $this->progress->setEmptyBarCharacter($char);
92 1
    }
93
94
    /**
95
     * Sets the progress bar character.
96
     *
97
     * @param string $char A character
98
     */
99 1
    public function setProgressCharacter($char)
100
    {
101 1
        $this->progress->setProgressCharacter($char);
102 1
    }
103
104
    /**
105
     * Sets the progress bar format.
106
     *
107
     * @param string $format The format
108
     */
109 1
    public function setFormat($format)
110
    {
111 1
        $this->progress->setFormat($format);
112 1
    }
113
114
    /**
115
     * Sets the redraw frequency.
116
     *
117
     * @param int $freq The frequency in steps
118
     */
119 1
    public function setRedrawFrequency($freq)
120
    {
121 1
        $this->progress->setRedrawFrequency($freq);
122 1
    }
123
124
    /**
125
     * Starts the progress output.
126
     *
127
     * @param int|null $max Maximum steps
128
     */
129 1
    public function start($max = null)
130
    {
131 1
        $this->progress->start($this->output, $max);
132 1
    }
133
134
    /**
135
     * Advances the progress output X steps.
136
     *
137
     * @param int $step Number of steps to advance
138
     * @param bool $redraw Whether to redraw or not
139
     *
140
     * @throws \LogicException
141
     */
142 2
    public function advance($step = 1, $redraw = false)
143
    {
144 2
        $this->progress->advance($step, $redraw);
145 2
    }
146
147
    /**
148
     * Sets the current progress.
149
     *
150
     * @param int $current The current progress
151
     * @param bool $redraw Whether to redraw or not
152
     *
153
     * @throws \LogicException
154
     */
155 2
    public function setCurrent($current, $redraw = false)
156
    {
157 2
        $this->progress->setCurrent($current, $redraw);
158 2
    }
159
160
    /**
161
     * Outputs the current progress string.
162
     *
163
     * @param bool $finish Forces the end result
164
     *
165
     * @throws \LogicException
166
     */
167 2
    public function display($finish = false)
168
    {
169 2
        $this->progress->display($finish);
170 2
    }
171
172
    /**
173
     * Finishes the progress output.
174
     */
175 1
    public function finish()
176
    {
177 1
        $this->progress->finish();
178 1
    }
179
180
    /**
181
     * @return string
182
     */
183 1
    public function getName()
184
    {
185 1
        return $this->progress->getName();
186
    }
187
}
188