TargetField   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 44
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A generate() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
namespace WebnetFr\DatabaseAnonymizer;
4
5
use WebnetFr\DatabaseAnonymizer\Generator\GeneratorInterface;
6
7
/**
8
 * Represents the target field within @see TargetTable.
9
 * Contains generator for getting random anonymous values.
10
 *
11
 * @author Vlad Riabchenko <[email protected]>
12
 */
13
class TargetField
14
{
15
    /**
16
     * Name of the field.
17
     *
18
     * @var string
19
     */
20
    private $name;
21
22
    /**
23
     * Random value generator.
24
     *
25
     * @var GeneratorInterface
26
     */
27
    private $generator;
28
29
    /**
30
     * @param string             $name
31
     * @param GeneratorInterface $generator
32
     */
33
    public function __construct(string $name, GeneratorInterface $generator)
34
    {
35
        $this->name = $name;
36
        $this->generator = $generator;
37
    }
38
39
    /**
40
     * Get the name of this field.
41
     *
42
     * @return string
43
     */
44
    public function getName(): string
45
    {
46
        return $this->name;
47
    }
48
49
    /**
50
     * Generate next random value for this field.
51
     *
52
     * @return string|null
53
     */
54
    public function generate()
55
    {
56
        return $this->generator->generate();
57
    }
58
}
59