Error::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 2
b 0
f 1
1
<?php
2
3
namespace LimeSoda\LiveGuard;
4
5
/**
6
 * Class Error
7
 * @package LimeSoda\LiveGuard
8
 */
9
class Error
10
{
11
12
    protected $_exception;
13
    protected $_message;
14
    protected $_firstTraceFile;
15
16
    /**
17
     * @param \Exception $e
18
     */
19
    public function __construct(\Exception $e)
20
    {
21
        $this->_message = $e->getMessage();
22
        $this->_firstTraceFile = $this->setFirstTraceFile($e);
23
    }
24
25
    /**
26
     * @param \Exception $exception
27
     * @return mixed
28
     */
29
    protected function setFirstTraceFile(\Exception $exception)
30
    {
31
        foreach ($exception->getTrace() as $trace) {
32
            return $trace['file'];
33
        }
34
    }
35
36
    /**
37
     * @return string
38
     */
39
    public function getFirstTraceFile()
40
    {
41
        return $this->_firstTraceFile;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public  function getMessage()
48
    {
49
        return $this->_message;
50
    }
51
52
}
53