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

HasDataTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A hasData() 0 9 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