ManagesModelTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 20
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setModelData() 0 3 1
A getModelData() 0 3 1
1
<?php
2
3
namespace WebTheory\Saveyour\Data\Abstracts;
4
5
trait ManagesModelTrait
6
{
7
    /**
8
     * Method on queried model to get existing data
9
     */
10
    protected string $getMethod;
11
12
    /**
13
     * Method on queried model to set new data
14
     */
15
    protected string $setMethod;
16
17
    protected function getModelData(object $model): ?object
18
    {
19
        return $model->{$this->getMethod}();
20
    }
21
22
    protected function setModelData(object $model, $data): void
23
    {
24
        $model->{$this->setMethod}($data);
25
    }
26
}
27