Completed
Push — master ( d89681...8e123d )
by Andreas
20s
created

ResultKeeper::addError()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/*
4
 * Copyright (c) Andreas Heigl<[email protected]
5
 *
6
 * Licensed under the MIT License. See LICENSE.md file in the project root
7
 * for full license information.
8
 */
9
10
namespace Callingallpapers\ResultKeeper;
11
12
use Symfony\Component\Console\Output\OutputInterface;
13
14
class ResultKeeper
15
{
16
    private $errors = [];
17
18
    private $failures = [];
19
20
    private $updated = [];
21
22
    private $created = [];
23
24
    public function add(Result $result)
25
    {
26
        switch (get_class($result)) {
27
            case Error::class:
28
                $this->addError($result);
0 ignored issues
show
Compatibility introduced by
$result of type object<Callingallpapers\ResultKeeper\Result> is not a sub-type of object<Callingallpapers\ResultKeeper\Error>. It seems like you assume a concrete implementation of the interface Callingallpapers\ResultKeeper\Result to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
29
                break;
30
            case Failure::class:
31
                $this->addFailure($result);
0 ignored issues
show
Compatibility introduced by
$result of type object<Callingallpapers\ResultKeeper\Result> is not a sub-type of object<Callingallpapers\ResultKeeper\Failure>. It seems like you assume a concrete implementation of the interface Callingallpapers\ResultKeeper\Result to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
32
                break;
33
            case Created::class:
34
                $this->addCreated($result);
0 ignored issues
show
Compatibility introduced by
$result of type object<Callingallpapers\ResultKeeper\Result> is not a sub-type of object<Callingallpapers\ResultKeeper\Created>. It seems like you assume a concrete implementation of the interface Callingallpapers\ResultKeeper\Result to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
35
                break;
36
            case Updated::class:
37
                $this->addUpdated($result);
0 ignored issues
show
Compatibility introduced by
$result of type object<Callingallpapers\ResultKeeper\Result> is not a sub-type of object<Callingallpapers\ResultKeeper\Updated>. It seems like you assume a concrete implementation of the interface Callingallpapers\ResultKeeper\Result to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
38
                break;
39
            default:
40
        }
41
    }
42
43
    public function addError(Error $error) : void
44
    {
45
        $this->errors[] = $error;
46
    }
47
48
    public function addFailure(Failure $failure) : void
49
    {
50
        $this->failures[] = $failure;
51
    }
52
53
    public function addCreated(Created $created) : void
54
    {
55
        $this->created[] = $created;
56
    }
57
    public function addUpdated(Updated $updated) : void
58
    {
59
        $this->updated[] = $updated;
60
    }
61
62
    /**
63
     * @return \Callingallpapers\ResultKeeper\Created[]
64
     */
65
    public function getCreated() : array
66
    {
67
        return $this->created;
68
    }
69
70
    /**
71
     * @return \Callingallpapers\ResultKeeper\Updated[]
72
     */
73
    public function getUpdated() : array
74
    {
75
        return $this->updated;
76
    }
77
78
    /**
79
     * @return \Callingallpapers\ResultKeeper\Failure[]
80
     */
81
    public function getFailed() : array
82
    {
83
        return $this->failures;
84
    }
85
86
    /**
87
     * @return \Callingallpapers\ResultKeeper\Error[]
88
     */
89
    public function getErrored() : array
90
    {
91
        return $this->errors;
92
    }
93
}
94