TagHelper::helper()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace BeyondCode\TagHelper;
4
5
use BeyondCode\TagHelper\Exceptions\InvalidHelperGiven;
6
7
class TagHelper
8
{
9
    /** @var array */
10
    public $registeredTagHelpers = [];
11
12
    public function getRegisteredTagHelpers(): array
13
    {
14
        return array_map(function ($helper) {
15
            return app($helper);
16
        }, $this->registeredTagHelpers);
17
    }
18
19
    public function helper(string $helper)
20
    {
21
        if (! is_subclass_of($helper, Helper::class)) {
22
            throw InvalidHelperGiven::withHelper($helper);
23
        }
24
25
        $this->registeredTagHelpers[] = $helper;
26
    }
27
}
28