Test Failed
Push — main ( e1affe...2e6d72 )
by Dimitri
14:06
created

ViewDecoratorTrait::decorate()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
nc 3
nop 1
dl 0
loc 11
ccs 3
cts 3
cp 1
crap 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of Blitz PHP framework.
5
 *
6
 * (c) 2022 Dimitri Sitchet Tomkeu <[email protected]>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace BlitzPHP\View;
13
14
use BlitzPHP\Exceptions\ViewException;
15
16
trait ViewDecoratorTrait
17
{
18
    /**
19
     * Exécute la sortie générée via tous les décorateurs de vue déclarés.
20
     */
21
    protected function decorate(string $output): string
22
    {
23
        foreach (config('view.decorators') as $decorator) {
24
            if (! is_subclass_of($decorator, ViewDecoratorInterface::class, true)) {
25 2
                throw ViewException::invalidDecorator($decorator);
26
            }
27
28 2
            $output = $decorator::decorate($output);
29
        }
30
31 2
        return $output;
32
    }
33
}
34