Test Failed
Pull Request — master (#118)
by Jordan
05:02
created

PowOperation::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 2
c 1
b 0
f 0
nc 4
nop 2
dl 0
loc 5
rs 10
1
<?php
2
3
4
namespace Samsara\Fermat\Renderer\Components\Operations;
5
6
7
use Samsara\Fermat\Renderer\Components\Interfaces\ComponentInterface;
8
use Samsara\Fermat\Types\Base\Interfaces\Numbers\NumberInterface;
9
10
class PowOperation implements ComponentInterface
11
{
12
13
    private string $left;
14
    private string $right;
15
16
    public function __construct(NumberInterface|ComponentInterface $left, NumberInterface|ComponentInterface $right)
17
    {
18
19
        $this->left = ($left instanceof NumberInterface ? $left->getValue() : $left->getOutput());
0 ignored issues
show
Bug introduced by
The method getValue() does not exist on Samsara\Fermat\Types\Bas...Numbers\NumberInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Samsara\Fermat\Types\Bas...Numbers\NumberInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

19
        $this->left = ($left instanceof NumberInterface ? $left->/** @scrutinizer ignore-call */ getValue() : $left->getOutput());
Loading history...
20
        $this->right = ($right instanceof NumberInterface ? $right->getValue() : $right->getOutput());
21
22
    }
23
24
    public function getOutput(): string
25
    {
26
        return '{'.$this->left.'}^{'.$this->right.'}';
27
    }
28
}