HasTraitsWithCasts   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 15
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCasts() 0 13 3
1
<?php
2
3
namespace IproSync\Models;
4
5
trait HasTraitsWithCasts
6
{
7 3
    public function getCasts()
8
    {
9 3
        $class = static::class;
10
11 3
        foreach (class_uses_recursive($class) as $trait) {
12 3
            $method = 'get'.class_basename($trait).'CastsAttr';
13
14 3
            if (method_exists($class, $method)) {
15 3
                $this->casts = array_merge($this->casts, $this->{$method}());
0 ignored issues
show
Bug Best Practice introduced by
The property casts does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
16
            }
17
        }
18
19 3
        return parent::getCasts();
20
    }
21
}
22