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

HasVersion::getVersion()   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 "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