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

SpacecraftHoldingWebTrait   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 30%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 21
c 1
b 0
f 0
dl 0
loc 43
ccs 6
cts 20
cp 0.3
rs 10
wmc 9

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isHeldByTholianWeb() 0 3 1
A getHoldingWebBackgroundStyle() 0 16 4
A getHoldingWebImageStyle() 0 16 4
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