Completed
Pull Request — master (#43)
by Jose Manuel
02:54
created

MutationObjectHandler::hasChanged()   A

Complexity

Conditions 5
Paths 4

Size

Total Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 5

Importance

Changes 0
Metric Value
dl 0
loc 16
ccs 8
cts 8
cp 1
rs 9.4222
c 0
b 0
f 0
cc 5
nc 4
nop 0
crap 5
1
<?php
2
3
namespace Softonic\GraphQL\DataObjects\Mutation\Traits;
4
5
use Softonic\GraphQL\DataObjects\Mutation\MutationObject;
6
7
trait MutationObjectHandler
8
{
9 56
    public function hasChanged(): bool
10
    {
11 56
        if ($this->hasChanged) {
0 ignored issues
show
Bug introduced by
The property hasChanged does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
12 52
            return true;
13
        }
14
15 48
        foreach ($this->arguments as $argument) {
0 ignored issues
show
Bug introduced by
The property arguments does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
16 48
            if ($argument instanceof MutationObject && $argument->hasChanged()) {
17 44
                $this->hasChanged = true;
18
19 44
                return true;
20
            }
21
        }
22
23 24
        return false;
24
    }
25
}
26