Completed
Push — master ( da0ab4...8ffee5 )
by Vincent
03:47
created

HasIdentifier::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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