Passed
Push — master ( f1c3fb...9dda0c )
by Victor
02:00
created

HasDataTrait::hasData()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
c 0
b 0
f 0
cc 3
eloc 4
nc 3
nop 1
crap 3
1
<?php
2
declare(strict_types=1);
3
4
namespace Shoot\Shoot;
5
6
/**
7
 * A convenience trait for Presenters. It checks if a presentation model already holds data. If so, it might not be
8
 * necessary to perform any action on it.
9
 */
10
trait HasDataTrait
11
{
12
    /**
13
     * Determine whether the presentation model already holds data.
14
     *
15
     * @param PresentationModel $presentationModel The presentation model for which to determine whether it holds data.
16
     *
17
     * @return bool Whether the presentation model already holds data.
18
     */
19 4
    private function hasData(PresentationModel $presentationModel): bool
20
    {
21 4
        foreach ($presentationModel->getVariables() as $value) {
22 4
            if (!empty($value)) {
23 4
                return true;
24
            }
25
        }
26
27 2
        return false;
28
    }
29
}
30