DefaultCodCountry::getCode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Inspirum\Balikobot\Model\Country;
6
7
use Inspirum\Arrayable\BaseModel;
8
9
/**
10
 * @extends \Inspirum\Arrayable\BaseModel<string,mixed>
11
 */
12
final class DefaultCodCountry extends BaseModel implements CodCountry
13
{
14 5
    public function __construct(
15
        private readonly string $code,
16
        private readonly string $currencyCode,
17
        private readonly float $maxPrice,
18
    ) {
19 5
    }
20
21 1
    public function getCode(): string
22
    {
23 1
        return $this->code;
24
    }
25
26 1
    public function getCurrencyCode(): string
27
    {
28 1
        return $this->currencyCode;
29
    }
30
31 1
    public function getMaxPrice(): float
32
    {
33 1
        return $this->maxPrice;
34
    }
35
36
    /** @inheritDoc */
37 2
    public function __toArray(): array
38
    {
39 2
        return [
0 ignored issues
show
Bug Best Practice introduced by
The expression return array('code' => $...ce' => $this->maxPrice) returns the type array<string,double|string> which is incompatible with the return type mandated by Inspirum\Arrayable\BaseModel::__toArray() of Inspirum\Arrayable\TValue[].

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
40 2
            'code' => $this->code,
41 2
            'currencyCode' => $this->currencyCode,
42 2
            'maxPrice' => $this->maxPrice,
43 2
        ];
44
    }
45
}
46