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
01:23
created

Attribute::required()   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
class Attribute
14
{
15
    /**
16
     * @var Attribute
17
     */
18
    protected $property;
19
20
    /**
21
     * PropertyFactory constructor.
22
     * @param Property $property
23
     */
24
    public function __construct(Property $property)
25
    {
26
        $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...
27
    }
28
29
    public function required(): self
30
    {
31
        $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...
32
33
        return $this;
34
    }
35
36
    public function optional(): self
37
    {
38
        $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...
39
40
        return $this;
41
    }
42
43
    public function rule($rules): self
44
    {
45
        $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...
46
47
        return $this;
48
    }
49
50
    public function nullable(): self
51
    {
52
        $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...
53
54
        return $this;
55
    }
56
57
    public function default($value): self
58
    {
59
        $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...
60
61
        return $this;
62
    }
63
64
    public function constraint(Closure $callback): self
65
    {
66
        $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...
67
68
        return $this;
69
    }
70
71
    public function getProperty(): Property
72
    {
73
        return $this->property;
74
    }
75
}
76