Test Failed
Pull Request — main (#30)
by Peter
09:21 queued 06:39
created

FakeCarDataProvider::getVehicleSeatCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 1
cts 1
cp 1
crap 1
rs 10
1
<?php
2
3
namespace Faker\Provider;
4
5
use Exception;
6
7
class FakeCarDataProvider implements FakeCarDataProviderInterface
8
{
9
    protected $vehicleData;
10
11
    public function __construct($vehicleData = null)
12 19
    {
13
        $this->vehicleData = $vehicleData ?: FakeCarData::class;
14 19
    }
15
16
    /**
17
     * @throws Exception
18
     */
19
    public function getVehicleBrand(): string
20 5
    {
21
        return (string) FakeCarHelper::getRandomElementFromArray(array_keys($this->vehicleData::$brandsWithModels));
22 5
    }
23
24
    /**
25
     * @throws Exception
26
     */
27
    public function getVehicleModel(?string $brand = null): string
28 4
    {
29
        $brandsWithModels = $this->vehicleData::$brandsWithModels;
30 4
31
        return (string) FakeCarHelper::getRandomElementFromArray($brandsWithModels[$brand ?: $this->getVehicleBrand()]);
32 4
    }
33
34
    public function getBrandsWithModels(): array
35 4
    {
36
        return $this->vehicleData::$brandsWithModels;
37 4
    }
38
39
    /**
40
     * @throws Exception
41
     */
42
    public function getVehicleType(): string
43 2
    {
44
        return FakeCarHelper::getArrayData($this->vehicleData::$vehicleTypes);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Faker\Provider\Fa...icleData::vehicleTypes) could return the type array which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
45 2
    }
46
47
    /**
48
     * @throws Exception
49
     */
50
    public function getVehicleFuelType(int $count = 1): string|array
51 1
    {
52
        return FakeCarHelper::getArrayData($this->vehicleData::$vehicleFuelTypes, $count);
53 1
    }
54
55
    /**
56
     * @throws Exception
57
     */
58
    public function getVehicleDoorCount(): int
59 1
    {
60
        return FakeCarHelper::getArrayData($this->vehicleData::$vehicleDoorCount);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Faker\Provider\Fa...Data::vehicleDoorCount) also could return the type array|string which is incompatible with the return type mandated by Faker\Provider\FakeCarDa...::getVehicleDoorCount() of integer.
Loading history...
61 1
    }
62
63
    /**
64
     * @throws Exception
65
     */
66
    public function getVehicleSeatCount(): int
67 1
    {
68
        return FakeCarHelper::getArrayData($this->vehicleData::$vehicleSeatCount);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Faker\Provider\Fa...Data::vehicleSeatCount) also could return the type array|string which is incompatible with the return type mandated by Faker\Provider\FakeCarDa...::getVehicleSeatCount() of integer.
Loading history...
69 1
    }
70
71
    /**
72
     * @throws Exception
73
     */
74
    public function getVehicleProperties(int $count = 0): array
75 1
    {
76
        return FakeCarHelper::getArrayData($this->vehicleData::$vehicleProperties, $count);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Faker\Provider\Fa...icleProperties, $count) could return the type string which is incompatible with the type-hinted return array. Consider adding an additional type-check to rule them out.
Loading history...
77 1
    }
78
79
    /**
80
     * @throws Exception
81
     */
82
    public function getVehicleGearBoxType(): string
83 1
    {
84
        return FakeCarHelper::getArrayData($this->vehicleData::$vehicleGearBoxType);
0 ignored issues
show
Bug Best Practice introduced by
The expression return Faker\Provider\Fa...ta::vehicleGearBoxType) could return the type array which is incompatible with the type-hinted return string. Consider adding an additional type-check to rule them out.
Loading history...
85 1
    }
86
87
    /**
88
     * @throws Exception
89
     */
90
    public function getVehicleEnginePower(): string
91 1
    {
92
        ['range' => $range, 'unit' => $unit] = $this->vehicleData::$vehicleEnginePower;
93 1
94 1
        return FakeCarHelper::getRangeWithUnit($range, $unit);
95
    }
96
97
    /**
98
     * @throws Exception
99
     */
100 1
    public function getVehicleEnginePowerValue(): string
101
    {
102 1
        ['range' => $range] = $this->vehicleData::$vehicleEnginePower;
103 1
104
        return FakeCarHelper::getRange($range);
105
    }
106
107
    /**
108
     * @throws Exception
109
     */
110
    public function getVehicleEngineTorque(): string
111
    {
112
        ['range' => $range, 'unit' => $unit] = $this->vehicleData::$vehicleEngineTorque;
113
114
        return FakeCarHelper::getRangeWithUnit($range, $unit);
115
    }
116
117
    /**
118
     * @throws Exception
119
     */
120
    public function getVehicleEngineTorqueValue(): string
121
    {
122
        ['range' => $range] = $this->vehicleData::$vehicleEngineTorque;
123
124
        return FakeCarHelper::getRange($range);
125
    }
126
}
127