1 | <?php |
||
2 | |||
3 | namespace Database\Factories; |
||
4 | |||
5 | use App\Models\Device; |
||
6 | use Illuminate\Database\Eloquent\Factories\Factory; |
||
7 | |||
8 | /** @extends Factory<Device> */ |
||
9 | class DeviceFactory extends Factory |
||
10 | { |
||
11 | /** |
||
12 | * The name of the factory's corresponding model. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $model = Device::class; |
||
17 | |||
18 | /** |
||
19 | * Define the model's default state. |
||
20 | * |
||
21 | * @return array |
||
22 | */ |
||
23 | public function definition() |
||
24 | { |
||
25 | return [ |
||
26 | 'hostname' => $this->faker->domainWord . '-' . $this->faker->domainWord . '-' . $this->faker->domainWord . '.' . $this->faker->domainName, |
||
27 | 'ip' => $this->faker->randomElement([$this->faker->ipv4, $this->faker->ipv6]), |
||
0 ignored issues
–
show
|
|||
28 | 'type' => $this->faker->randomElement([ |
||
29 | 'appliance', |
||
30 | 'camera', |
||
31 | 'collaboration', |
||
32 | 'encoder', |
||
33 | 'environment', |
||
34 | 'firewall', |
||
35 | 'loadbalancer', |
||
36 | 'management', |
||
37 | 'network', |
||
38 | 'power', |
||
39 | 'printer', |
||
40 | 'proxy', |
||
41 | 'sensor', |
||
42 | 'server', |
||
43 | 'storage', |
||
44 | 'timing', |
||
45 | 'wireless', |
||
46 | 'workstation', |
||
47 | ]), |
||
48 | 'status' => $status = random_int(0, 1), |
||
49 | 'status_reason' => $status == 0 ? $this->faker->randomElement(['snmp', 'icmp']) : '', // allow invalid states? |
||
50 | ]; |
||
51 | } |
||
52 | } |
||
53 |
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.