Passed
Push — dev ( 98511f...00baf5 )
by Janko
15:17
created

SpacecraftHoldingWebTrait::isHeldByTholianWeb()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Stu\Component\Spacecraft\Trait;
4
5
use Stu\Component\Game\TimeConstants;
0 ignored issues
show
Bug introduced by
The type Stu\Component\Game\TimeConstants 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...
6
7
trait SpacecraftHoldingWebTrait
8
{
9
    use SpacecraftTrait;
10
11 4
    public function isHeldByTholianWeb(): bool
12
    {
13 4
        return $this->getThis()->getHoldingWeb() !== null;
14
    }
15
16 4
    public function getHoldingWebBackgroundStyle(): string
17
    {
18 4
        $holdingWeb = $this->getThis()->getHoldingWeb();
19 4
        if ($holdingWeb === null) {
20 4
            return '';
21
        }
22
23
        if ($holdingWeb->isFinished()) {
24
            $icon =  'web.png';
25
        } else {
26
            $closeTofinish = $holdingWeb->getFinishedTime() - time() < TimeConstants::ONE_HOUR_IN_SECONDS;
27
28
            $icon = $closeTofinish ? 'web_u.png' : 'web_u2.png';
29
        }
30
31
        return sprintf('src="assets/buttons/%s"; class="indexedGraphics" style="z-index: 5;"', $icon);
32
    }
33
34
    public function getHoldingWebImageStyle(): string
35
    {
36
        $holdingWeb = $this->getThis()->getHoldingWeb();
37
        if ($holdingWeb === null) {
38
            return '';
39
        }
40
41
        if ($holdingWeb->isFinished()) {
42
            $icon =  'webfill.png';
43
        } else {
44
            $closeTofinish = $holdingWeb->getFinishedTime() - time() < TimeConstants::ONE_HOUR_IN_SECONDS;
45
46
            $icon = $closeTofinish ? 'web_ufill.png' : 'web_ufill2.png';
47
        }
48
49
        return $icon;
50
    }
51
}
52