HasDataTrait::hasData()   A
last analyzed

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
cc 3
eloc 4
nc 3
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
ccs 5
cts 5
cp 1
crap 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