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

FailedResult   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 6
c 2
b 0
f 0
lcom 1
cbo 0
dl 0
loc 37
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getMessage() 0 3 1
A getException() 0 3 1
A getDetails() 0 14 3
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
}