HasVersion::setVersion()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace VGirol\JsonApiFaker\Factory;
6
7
/**
8
 * Add "version" member to a factory.
9
 */
10
trait HasVersion
11
{
12
    /**
13
     * The "version" member
14
     *
15
     * @var string
16
     */
17
    protected $version;
18
19
    /**
20
     * Set the "version" member
21
     *
22
     * @param string $version
23
     *
24
     * @return static
25
     */
26 30
    public function setVersion(string $version)
27
    {
28 30
        $this->version = $version;
29
30 30
        return $this;
31
    }
32
33
    /**
34
     * Get the "version" member
35
     *
36
     * @return string|null
37
     */
38 9
    public function getVersion(): ?string
39
    {
40 9
        return $this->version;
41
    }
42
43
    /**
44
     * Fill the "version" member with a fake value.
45
     *
46
     * @return static
47
     */
48 18
    public function fakeVersion()
49
    {
50 18
        $faker = \Faker\Factory::create();
51
52 18
        return $this->setVersion(
53 18
            $faker->randomDigitNotNull() . '.' . $faker->randomDigit()
54
        );
55
    }
56
}
57