Passed
Push — master ( f4ac78...d70f6f )
by Paweł
03:02
created

HealthPotion::consume()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 2
crap 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 consume(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