Completed
Push — master ( b74454...1c3df8 )
by Sebastian
01:54
created

Result::getBufferedOutput()   A

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
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of SebastianFeldmann\Cli.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace SebastianFeldmann\Cli\Command\Runner;
11
12
use SebastianFeldmann\Cli\Command\Result as CommandResult;
13
14
/**
15
 * Class Result
16
 *
17
 * @package SebastianFeldmann\Cli
18
 */
19
class Result
20
{
21
    /**
22
     * @var \SebastianFeldmann\Cli\Command\Result
23
     */
24
    private $cmdResult;
25
26
    /**
27
     * @var iterable
28
     */
29
    private $formatted;
30
31
    /**
32
     * Result constructor.
33
     *
34
     * @param \SebastianFeldmann\Cli\Command\Result $cmdResult
35
     * @param iterable                              $formatted
36
     */
37 7
    public function __construct(CommandResult $cmdResult, $formatted = [])
38
    {
39 7
        $this->cmdResult = $cmdResult;
40 7
        $this->formatted = $formatted;
41 7
    }
42
43
    /**
44
     * Get the raw command result.
45
     *
46
     * @return \SebastianFeldmann\Cli\Command\Result
47
     */
48 1
    public function getCommandResult() : CommandResult
49
    {
50 1
        return $this->cmdResult;
51
    }
52
53
    /**
54
     * Return true if command execution was successful.
55
     *
56
     * @return bool
57
     */
58 1
    public function isSuccessful() : bool
59
    {
60 1
        return $this->cmdResult->isSuccessful();
61
    }
62
63
    /**
64
     * Return commands output to stdOut.
65
     *
66
     * @return string
67
     */
68 1
    public function getStdOut() : string
69
    {
70 1
        return $this->cmdResult->getStdOut();
71
    }
72
73
    /**
74
     * Return commands error output to stdErr.
75
     *
76
     * @return string
77
     */
78 1
    public function getStdErr() : string
79
    {
80 1
        return $this->cmdResult->getStdErr();
81
    }
82
83
    /**
84
     * Return cmd output as array.
85
     *
86
     * @return array
87
     */
88 2
    public function getBufferedOutput() : array
89
    {
90 2
        return $this->cmdResult->getStdOutAsArray();
91
    }
92
93
    /**
94
     * Return formatted output.
95
     *
96
     * @return iterable
97
     */
98 1
    public function getFormattedOutput()
99
    {
100 1
        return $this->formatted;
101
    }
102
}
103