Completed
Push — master ( 1c3df8...263070 )
by Sebastian
02:03
created

Result::isOutputRedirected()   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
 * @author  Sebastian Feldmann <[email protected]>
19
 * @link    https://github.com/sebastianfeldmann/cli
20
 * @since   Class available since Release 0.9.0
21
 */
22
class Result
23
{
24
    /**
25
     * Result of executed command.
26
     *
27
     * @var \SebastianFeldmann\Cli\Command\Result
28
     */
29
    private $cmdResult;
30
31
    /**
32
     * Formatted output of executed result.
33
     *
34
     * @var iterable
35
     */
36
    private $formatted;
37
38
    /**
39
     * Result constructor.
40
     *
41
     * @param \SebastianFeldmann\Cli\Command\Result $cmdResult
42
     * @param iterable                              $formatted
43
     */
44 9
    public function __construct(CommandResult $cmdResult, $formatted = [])
45
    {
46 9
        $this->cmdResult = $cmdResult;
47 9
        $this->formatted = $formatted;
48 9
    }
49
50
    /**
51
     * Get the raw command result.
52
     *
53
     * @return \SebastianFeldmann\Cli\Command\Result
54
     */
55 1
    public function getCommandResult() : CommandResult
56
    {
57 1
        return $this->cmdResult;
58
    }
59
60
    /**
61
     * Return true if command execution was successful.
62
     *
63
     * @return bool
64
     */
65 1
    public function isSuccessful() : bool
66
    {
67 1
        return $this->cmdResult->isSuccessful();
68
    }
69
70
    /**
71
     * Return commands output to stdOut.
72
     *
73
     * @return string
74
     */
75 1
    public function getStdOut() : string
76
    {
77 1
        return $this->cmdResult->getStdOut();
78
    }
79
80
    /**
81
     * Return commands error output to stdErr.
82
     *
83
     * @return string
84
     */
85 1
    public function getStdErr() : string
86
    {
87 1
        return $this->cmdResult->getStdErr();
88
    }
89
90
    /**
91
     * Is the output redirected to a file.
92
     *
93
     * @return bool
94
     */
95 2
    public function isOutputRedirected() : bool
96
    {
97 2
        return $this->cmdResult->isOutputRedirected();
98
    }
99
100
    /**
101
     * Return path to the file where the output is redirected to.
102
     *
103
     * @return string
104
     */
105 2
    public function getRedirectPath() : string
106
    {
107 2
        return $this->cmdResult->getRedirectPath();
108
    }
109
110
    /**
111
     * Return cmd output as array.
112
     *
113
     * @return array
114
     */
115 2
    public function getBufferedOutput() : array
116
    {
117 2
        return $this->cmdResult->getStdOutAsArray();
118
    }
119
120
    /**
121
     * Return formatted output.
122
     *
123
     * @return iterable
124
     */
125 1
    public function getFormattedOutput()
126
    {
127 1
        return $this->formatted;
128
    }
129
}
130