1 | <?php |
||||||
2 | /** |
||||||
3 | * DronePHP (http://www.dronephp.com) |
||||||
4 | * |
||||||
5 | * @link http://github.com/Pleets/DronePHP |
||||||
6 | * @copyright Copyright (c) 2016-2018 Pleets. (http://www.pleets.org) |
||||||
7 | * @license http://www.dronephp.com/license |
||||||
8 | * @author Darío Rivera <[email protected]> |
||||||
9 | */ |
||||||
10 | |||||||
11 | namespace Drone\Exception; |
||||||
12 | |||||||
13 | /** |
||||||
14 | * StorableTrait Trait |
||||||
15 | * |
||||||
16 | * This is a helper tait that provides essential methods to store Exceptions. |
||||||
17 | * All Exceptions that extends from this, will be stored with store() method. |
||||||
18 | */ |
||||||
19 | trait StorableTrait |
||||||
20 | { |
||||||
21 | use \Drone\Error\ErrorTrait; |
||||||
22 | |||||||
23 | /** |
||||||
24 | * Local file when exceptions will be stored |
||||||
25 | * |
||||||
26 | * @var string |
||||||
27 | */ |
||||||
28 | protected $outputFile; |
||||||
29 | |||||||
30 | /** |
||||||
31 | * Returns the outputFile attribute |
||||||
32 | * |
||||||
33 | * @return string |
||||||
34 | */ |
||||||
35 | public function getOutputFile() |
||||||
36 | { |
||||||
37 | return $this->outputFile; |
||||||
38 | } |
||||||
39 | |||||||
40 | /** |
||||||
41 | * Sets outputFile attribute |
||||||
42 | * |
||||||
43 | * @param string $value |
||||||
44 | * |
||||||
45 | * @return null |
||||||
46 | */ |
||||||
47 | public function setOutputFile($value) |
||||||
48 | { |
||||||
49 | $this->outputFile = $value; |
||||||
50 | } |
||||||
51 | |||||||
52 | /** |
||||||
53 | * Stores the exception |
||||||
54 | * |
||||||
55 | * By default exceptions are stored in a JSON file << $this->outputFile >> |
||||||
56 | * |
||||||
57 | * @return string|boolean |
||||||
58 | */ |
||||||
59 | public function store() |
||||||
60 | { |
||||||
61 | $storage = new Storage($this->outputFile); |
||||||
62 | |||||||
63 | $st = $storage->store($this); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
64 | |||||||
65 | if (!$st) { |
||||||
0 ignored issues
–
show
|
|||||||
66 | $_errors = $st->getErrors(); |
||||||
67 | |||||||
68 | foreach ($_errors as $errno => $error) { |
||||||
69 | $this->error($errno, $error); |
||||||
0 ignored issues
–
show
The method
error() does not exist on Exception . It seems like you code against a sub-type of Exception such as Drone\Exception\Exception .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
70 | } |
||||||
71 | } |
||||||
72 | |||||||
73 | return $st; |
||||||
74 | } |
||||||
75 | } |
||||||
76 |