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:25
created

Attribute   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 71
rs 10
c 0
b 0
f 0

8 Methods

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