Passed
Pull Request — master (#2161)
by Janko
25:16 queued 15:11
created

LayerExplorationTrait::hasExplored()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.2098

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 12
ccs 5
cts 7
cp 0.7143
crap 3.2098
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stu\Lib\Trait;
6
7
use Stu\Component\Map\MapEnum;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Map\MapEnum was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Stu\Orm\Entity\LayerInterface;
9
use Stu\Orm\Entity\UserInterface;
10
use Stu\Orm\Entity\UserLayerInterface;
11
12
trait LayerExplorationTrait
13
{
14 4
    protected function hasExplored(UserInterface $user, LayerInterface $layer): bool
15
    {
16 4
        if (!$this->hasSeen($user, $layer)) {
17
            return false;
18
        }
19
20
        /** @var null|UserLayerInterface */
21 4
        $userLayer = $user->getUserLayers()->get($layer->getId());
22
23 4
        return $userLayer === null
24
            ? false
25 4
            : $userLayer->getMappingType() === MapEnum::MAPTYPE_LAYER_EXPLORED;
26
    }
27
28 4
    protected function hasSeen(UserInterface $user, LayerInterface $layer): bool
29
    {
30 4
        return $user->getUserLayers()->containsKey($layer->getId());
31
    }
32
}
33