Completed
Push — master ( 0b908e...886262 )
by Kevin
02:30
created

AbstractOutput::__invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Groundskeeper\Output;
4
5
use Groundskeeper\Tokens\Token;
6
use Groundskeeper\Tokens\TokenContainer;
7
8
abstract class AbstractOutput
9
{
10
    /**
11
     * Will output HTML from tokens.
12
     *
13
     * @param TokenContainer $tokenContainer
14
     *
15
     * @return string
16
     */
17 21
    public function __invoke(TokenContainer $tokenContainer)
18
    {
19 21
        $output = '';
20 21
        foreach ($tokenContainer->getChildren() as $token) {
21 21
            $output .= $this->getHtmlFromToken($token);
22 21
        }
23
24 21
        return trim($output);
25
    }
26
27
    /**
28
     * Will output an individual token to HTML.
29
     *
30
     * @param Token $token
31
     *
32
     * @return string
33
     */
34
    abstract protected function getHtmlFromToken(Token $token);
35
}
36