HasVersion   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setVersion() 0 5 1
A getVersion() 0 3 1
A fakeVersion() 0 6 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