AbstractComponent::createAndShow()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace pjpawel\Magis\Helper;
4
5
abstract class AbstractComponent implements ComponentInterface
6
{
7
8
    abstract public function show(): string;
9
10
    /**
11
     * @param mixed ...$args
12
     * @return string
13
     * @throws \ReflectionException
14
     */
15
    public static function createAndShow(mixed ...$args): string
16
    {
17
        /** @var array<int,mixed> $args */
18
        $component = new \ReflectionClass(static::class);
19
        $componentObject = $component->newInstanceArgs($args);
20
        /** @var static $componentObject */
21
        return $componentObject->show();
22
    }
23
}