Issues (2963)

database/factories/DeviceFactory.php (1 issue)

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
The call to Faker\Generator::randomElement() has too few arguments starting with 'b'. ( Ignorable by Annotation )

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

27
            'ip' => $this->faker->/** @scrutinizer ignore-call */ randomElement([$this->faker->ipv4, $this->faker->ipv6]),

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.

Loading history...
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