HasIdentifier   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 7
dl 0
loc 42
ccs 8
cts 8
cp 1
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setId() 0 5 1
A getId() 0 3 1
A fakeIdentifier() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiFaker\Factory;
6
7
/**
8
 * Add "id" member to a factory
9
 */
10
trait HasIdentifier
11
{
12
    /**
13
     * "id" member"
14
     *
15
     * @var int|string|null
16
     */
17
    protected $id;
18
19
    /**
20
     * Set the "id" member.
21
     *
22
     * @param int|string|null $resourceId
23
     * @return static
24
     */
25 105
    public function setId($resourceId)
26
    {
27 105
        $this->id = $resourceId;
28
29 105
        return $this;
30
    }
31
32
    /**
33
     * Get the "id" member.
34
     *
35
     * @return int|string|null
36
     */
37 24
    public function getId()
38
    {
39 24
        return $this->id;
40
    }
41
42
    /**
43
     * Fill the "id" member with a fake value.
44
     *
45
     * @return static
46
     */
47 54
    public function fakeIdentifier()
48
    {
49 54
        $faker = \Faker\Factory::create();
50
51 54
        return $this->setId($faker->numberBetween(1, 100));
52
    }
53
}
54