Passed
Branch master (33b347)
by Sébastien
06:52
created

SimpleInfector::getClassName()   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 1
crap 1
1
<?php
2
3
namespace Bdf\Prime\Schema\Inflector;
4
5
use Doctrine\Inflector\Inflector as InflectorObject;
6
use Doctrine\Inflector\InflectorFactory;
7
8
/**
9
 * SimpleInfector
10
 */
11
class SimpleInfector implements InflectorInterface
12
{
13
    /**
14
     * The inflector instance
15
     *
16
     * @var InflectorObject
17
     */
18
    private $inflector;
19
20 2
    public function __construct(?InflectorObject $inflector = null)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
21
    {
22 2
        $this->inflector = $inflector ?? InflectorFactory::create()->build();
0 ignored issues
show
Coding Style introduced by
Operation must be bracketed
Loading history...
23 2
    }
24
25
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $table should have a doc-comment as per coding-style.
Loading history...
26
     * {@inheritdoc}
27
     */
28 2
    public function getClassName($table)
29
    {
30 2
        return $this->inflector->classify($this->inflector->singularize(strtolower($table)));
31
    }
32
33
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $table should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $field should have a doc-comment as per coding-style.
Loading history...
34
     * {@inheritdoc}
35
     */
36 2
    public function getPropertyName($table, $field)
0 ignored issues
show
Coding Style introduced by
The method parameter $table is never used
Loading history...
37
    {
38 2
        return $this->inflector->camelize(strtolower($field));
39
    }
40
41
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $table should have a doc-comment as per coding-style.
Loading history...
42
     * {@inheritdoc}
43
     */
44 2
    public function getSequenceName($table)
45
    {
46 2
        return "${table}_seq";
47
    }
48
}