Completed
Push — master ( 1f7de4...f57612 )
by Nikolas
07:35
created

FailedResult::getDetails()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 3
eloc 10
nc 3
nop 0
1
<?php
2
namespace rtens\domin\execution;
3
4
class FailedResult implements ExecutionResult {
5
6
    private $exception;
7
8
    public function __construct(\Exception $exception) {
9
        $this->exception = $exception;
10
    }
11
12
    /**
13
     * @return string|null
14
     */
15
    public function getMessage() {
16
        return $this->exception->getMessage();
17
    }
18
19
    /**
20
     * @return \Exception
21
     */
22
    public function getException() {
23
        return $this->exception;
24
    }
25
26
    public function getDetails() {
27
        $details = '';
28
        $exception = $this->exception;
29
30
        while ($exception) {
31
            $details .= $details ? 'Caused by: ' : 'Exception: ';
32
            $details .= $this->exception->getMessage() . "\n" .
33
                "In " . $this->exception->getFile() . '(' . $this->exception->getLine() . ")\n" .
34
                $this->exception->getTraceAsString() . "\n\n";
35
36
            $exception = $exception->getPrevious();
37
        }
38
        return $details;
39
    }
40
}