Completed
Pull Request — develop (#33)
by Michael
02:17
created

FormatterCollection::format()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Crummy\Phlack\Common\Formatter;
4
5
use Crummy\Phlack\Common\Collection\TypeCollection;
6
7
class FormatterCollection extends TypeCollection implements FormatterInterface
8
{
9
    /**
10
     * @param string $text
11
     *
12
     * @return string
13
     */
14 1
    public function format($text)
15
    {
16
        /** @var FormatterInterface $formatter */
17 1
        foreach ($this->toArray() as $formatter) {
18 1
            $text = $formatter->format($text);
19 1
        }
20
21 1
        return $text;
22
    }
23
24
    /**
25
     * @param $value
26
     *
27
     * @return bool
28
     */
29 11
    public function acceptsType($value)
30
    {
31 11
        return $value instanceof FormatterInterface;
32
    }
33
}
34