GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#55)
by Arthur
02:21 queued 55s
created

Attribute::optional()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: arthur
5
 * Date: 25.03.19
6
 * Time: 20:15.
7
 */
8
9
namespace Spatie\DataTransferObject;
10
11
use Closure;
12
13
/**
14
 * Class Attribute.
15
 */
16
class Attribute
17
{
18
    /**
19
     * @var Attribute
20
     */
21
    protected $property;
22
23
    /**
24
     * PropertyFactory constructor.
25
     * @param Property $property
26
     */
27
    public function __construct(Property $property)
28
    {
29
        $this->property = $property;
0 ignored issues
show
Documentation Bug introduced by
It seems like $property of type object<Spatie\DataTransferObject\Property> is incompatible with the declared type object<Spatie\DataTransferObject\Attribute> of property $property.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
30
    }
31
32
    /**
33
     * @return Attribute
34
     */
35
    public function required(): self
36
    {
37
        $this->property->setRequired(true);
0 ignored issues
show
Bug introduced by
The method setRequired() does not exist on Spatie\DataTransferObject\Attribute. Did you maybe mean required()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
38
39
        return $this;
40
    }
41
42
    /**
43
     * @return Attribute
44
     */
45
    public function optional(): self
46
    {
47
        $this->property->setRequired(false);
0 ignored issues
show
Bug introduced by
The method setRequired() does not exist on Spatie\DataTransferObject\Attribute. Did you maybe mean required()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
48
49
        return $this;
50
    }
51
52
    /**
53
     * @param $rules
54
     * @return Attribute
55
     */
56
    public function rule($rules): self
57
    {
58
        $this->property->addRule($rules);
0 ignored issues
show
Bug introduced by
The method addRule() does not seem to exist on object<Spatie\DataTransferObject\Attribute>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
59
60
        return $this;
61
    }
62
63
    /**
64
     * @return Attribute
65
     */
66
    public function nullable(): self
67
    {
68
        $this->property->setNullable(false);
0 ignored issues
show
Bug introduced by
The method setNullable() does not exist on Spatie\DataTransferObject\Attribute. Did you maybe mean nullable()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
69
70
        return $this;
71
    }
72
73
    /**
74
     * @param $value
75
     * @return Attribute
76
     */
77
    public function default($value): self
78
    {
79
        $this->property->setDefault($value);
0 ignored issues
show
Bug introduced by
The method setDefault() does not exist on Spatie\DataTransferObject\Attribute. Did you maybe mean default()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
80
81
        return $this;
82
    }
83
84
    /**
85
     * @param Closure $callback
86
     * @return Attribute
87
     */
88
    public function constraint(Closure $callback): self
89
    {
90
        $this->property->addConstraint($callback);
0 ignored issues
show
Bug introduced by
The method addConstraint() does not exist on Spatie\DataTransferObject\Attribute. Did you maybe mean constraint()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
91
92
        return $this;
93
    }
94
95
    /**
96
     * @return Property
97
     */
98
    public function getProperty(): Property
99
    {
100
        return $this->property;
101
    }
102
}
103