HasDataTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A hasData() 0 9 3
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoot\Shoot\Utilities;
5
6
use Shoot\Shoot\PresentationModel;
7
8
/**
9
 * A convenience trait for Presenters. It checks if a presentation model already holds data. If so, it might not be
10
 * necessary to perform any action on it.
11
 */
12
trait HasDataTrait
13
{
14
    /**
15
     * Returns whether the presentation model already holds data.
16
     *
17
     * @param PresentationModel $presentationModel
18
     *
19
     * @return bool
20
     */
21 2
    private function hasData(PresentationModel $presentationModel): bool
22
    {
23 2
        foreach ($presentationModel->getVariables() as $value) {
24 2
            if (!empty($value)) {
25 2
                return true;
26
            }
27
        }
28
29 1
        return false;
30
    }
31
}
32