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

FormatterCollection   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
c 2
b 1
f 0
lcom 0
cbo 1
dl 0
loc 27
ccs 7
cts 7
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A acceptsType() 0 4 1
A format() 0 9 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