SlumberUniquelyReferenced   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 43
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getReference() 0 4 1
A setReference() 0 6 1
1
<?php
2
/**
3
 * File was created 05.10.2015 17:18
4
 */
5
6
namespace PeekAndPoke\Component\Slumber\Data\Addon\PublicReference;
7
8
use PeekAndPoke\Component\Slumber\Annotation\Slumber;
9
10
/**
11
 * Use this to auto fill the public reference of a persisted object when it is saved.
12
 *
13
 * This is a variant of SlumberReferenced. The difference is that the Index on the field will be declared as unique.
14
 *
15
 * @see    SlumberReferenced
16
 * @see    PublicReferenceGenerator
17
 *
18
 * @author Karsten J. Gerber <[email protected]>
19
 */
20
trait SlumberUniquelyReferenced
21
{
22
    /**
23
     * @var string
24
     *
25
     * @see PublicReferenceGenerator
26
     *
27
     * @Slumber\AsString()
28
     *
29
     * @Slumber\Store\AsPublicReference(
30
     *      service = \PeekAndPoke\Component\Slumber\Data\Addon\PublicReference\PublicReferenceGenerator::SERVICE_ID,
31
     *      ofClass = \PeekAndPoke\Component\Slumber\Data\Addon\PublicReference\PublicReferenceGenerator::class,
32
     * )
33
     *
34
     * @Slumber\Store\Indexed(
35
     *     unique     = true,
36
     *     background = true,
37
     *     direction  = "ASC",
38
     *     sparse     = false,
39
     * )
40
     */
41
    protected $reference;
42
43
    /**
44
     * @return string
45
     */
46 2
    public function getReference()
47
    {
48 2
        return $this->reference;
49
    }
50
51
    /**
52
     * @param string $reference
53
     *
54
     * @return $this
55
     */
56 1
    public function setReference($reference)
57
    {
58 1
        $this->reference = $reference;
59
60 1
        return $this;
61
    }
62
}
63