ConsoleProgressWriter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * This file is part of plumphp/plum-console.
5
 *
6
 * (c) Florian Eckerstorfer <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Plum\PlumConsole;
13
14
use Plum\Plum\Writer\WriterInterface;
15
use Symfony\Component\Console\Helper\ProgressBar;
16
17
/**
18
 * ConsoleProgressWriter.
19
 *
20
 * @author    Florian Eckerstorfer <[email protected]>
21
 * @copyright 2014-2015 Florian Eckerstorfer
22
 */
23
class ConsoleProgressWriter implements WriterInterface
24
{
25
    /** @var ProgressBar */
26
    protected $progressBar;
27
28
    /**
29
     * @param ProgressBar $progressBar
30
     *
31
     * @codeCoverageIgnore
32
     */
33
    public function __construct(ProgressBar $progressBar)
34
    {
35
        $this->progressBar = $progressBar;
36
    }
37
38
    /**
39
     * Write the given item.
40
     *
41
     * @param mixed $item
42
     */
43 1
    public function writeItem($item)
44
    {
45 1
        $this->progressBar->advance();
46 1
    }
47
48
    /**
49
     * Prepare the writer.
50
     */
51 1
    public function prepare()
52
    {
53 1
        $this->progressBar->start();
54 1
    }
55
56
    /**
57
     * Finish the writer.
58
     */
59 1
    public function finish()
60
    {
61 1
        $this->progressBar->finish();
62 1
    }
63
}
64