Completed
Push — master ( ae2bec...c19c38 )
by Steve
01:59
created

Plain::renderDice()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace MeadSteve\DiceApi\Renderer;
4
5
use MeadSteve\DiceApi\Dice;
6
7
class Plain implements DiceRenderer
8
{
9
    public function renderDice(array $diceCollection)
10
    {
11
        $diceHtmlParts = array_map([$this, 'textForSingleDice'], $diceCollection);
12
        return implode(', ', $diceHtmlParts);
13
    }
14
15
    /**
16
     * @return string
17
     */
18
    public function contentType() : string
19
    {
20
        return "text/string";
21
    }
22
23
    public function urlPrefix(): string
24
    {
25
        return "string";
26
    }
27
28
    public function textForSingleDice(Dice $dice)
29
    {
30
        return "{$dice->name()} : {$dice->roll()}";
31
    }
32
}
33