InvoiceFactory::definition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 19
c 1
b 0
f 0
dl 0
loc 21
rs 9.6333
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Database\Factories\Squareetlabs\VeriFactu\Models;
6
7
use Illuminate\Database\Eloquent\Factories\Factory;
8
use Illuminate\Support\Str;
9
use Squareetlabs\VeriFactu\Models\Invoice;
10
use Squareetlabs\VeriFactu\Enums\InvoiceType;
11
12
class InvoiceFactory extends Factory
13
{
14
    protected $model = Invoice::class;
15
16
    public function definition(): array
17
    {
18
        return [
19
            'uuid' => $this->faker->uuid,
20
            'number' => 'INV-' . $this->faker->unique()->numberBetween(100, 999),
21
            'date' => $this->faker->date(),
22
            'customer_name' => $this->faker->company,
23
            'customer_tax_id' => strtoupper($this->faker->bothify('A########')),
24
            'customer_country' => $this->faker->countryCode,
25
            'issuer_name' => $this->faker->company,
26
            'issuer_tax_id' => strtoupper($this->faker->bothify('B########')),
27
            'issuer_country' => $this->faker->countryCode,
28
            'amount' => $this->faker->randomFloat(2, 100, 1000),
29
            'tax' => $this->faker->randomFloat(2, 10, 200),
30
            'total' => $this->faker->randomFloat(2, 110, 1200),
31
            'type' => $this->faker->randomElement(array_column(InvoiceType::cases(), 'value')),
0 ignored issues
show
Bug introduced by
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

31
            'type' => $this->faker->/** @scrutinizer ignore-call */ randomElement(array_column(InvoiceType::cases(), 'value')),

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...
32
            'external_reference' => $this->faker->optional()->bothify('EXT-####'),
33
            'description' => $this->faker->sentence,
34
            'status' => $this->faker->randomElement(['draft', 'sent', 'paid', 'cancelled']),
35
            'issued_at' => $this->faker->optional()->dateTimeThisYear(),
36
            'cancelled_at' => null,
37
        ];
38
    }
39
}