Constant   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 27
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A generate() 0 3 1
A __construct() 0 7 3
1
<?php
2
3
namespace WebnetFr\DatabaseAnonymizer\Generator;
4
5
use WebnetFr\DatabaseAnonymizer\Exception\InvalidConstantException;
6
7
/**
8
 * Generator that always return constant.
9
 *
10
 * @author Vlad Riabchenko <[email protected]>
11
 */
12
class Constant implements GeneratorInterface
13
{
14
    /**
15
     * Arbitrary constant value.
16
     *
17
     * @var mixed
18
     */
19
    private $constant;
20
21
    /**
22
     * @param $constant
23
     */
24
    public function __construct($constant)
25
    {
26
        if (null !== $constant && !\is_string($constant)) {
27
            throw new InvalidConstantException('Constant value must be null or string');
28
        }
29
30
        $this->constant = $constant;
31
    }
32
33
    /**
34
     * {@inheritdoc}
35
     */
36
    public function generate()
37
    {
38
        return $this->constant;
39
    }
40
}
41