Passed
Push — master ( 82efe3...775557 )
by Paweł
03:11
created

HealthPotion   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 10
c 1
b 0
f 1
dl 0
loc 18
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A use() 0 6 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AardsGerds\Game\Inventory\Alchemy\Potion;
6
7
use AardsGerds\Game\Build\Attribute\Health;
8
use AardsGerds\Game\Inventory\Coin;
9
use AardsGerds\Game\Player\Player;
10
use AardsGerds\Game\Player\PlayerAction;
11
12
final class HealthPotion extends Potion
13
{
14 3
    public function __construct()
15
    {
16 3
        parent::__construct(
17 3
            'Health Potion',
18 3
            'This herbs combination will regenerate 40 health.',
19 3
            new Coin(20),
20 3
            new Coin(50),
21
        );
22 3
    }
23
24 1
    public function use(Player $player, PlayerAction $playerAction): void
25
    {
26 1
        $player->heal(new Health(40));
27 1
        $player->getInventory()->remove($this);
28
29 1
        $playerAction->tell('You feel better now.');
30 1
    }
31
}
32