Generator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A from() 0 3 1
A __construct() 0 4 2
1
<?php
2
3
namespace ByTIC\Namefy;
4
5
use ByTIC\Namefy\Strategies\AbstractStrategy;
6
use ByTIC\Namefy\Strategies\ByTICStrategy;
7
8
/**
9
 * Class Generator
10
 * @package ByTIC\Namefy
11
 */
12
class Generator
13
{
14
    use Generator\HasStrategy;
15
16
    /**
17
     * Generator constructor.
18
     * @param null|string|AbstractStrategy $strategy
19
     */
20
    public function __construct($strategy = null)
21
    {
22
        $strategy = (empty($strategy)) ? ByTICStrategy::class : $strategy;
23
        $this->setStrategy($strategy);
24
    }
25
26
    /**
27
     * @param $name
28
     * @param $type
29
     * @return Name
30
     */
31
    public function from($name, $type): Name
32
    {
33
        return NameFactory::from($name, $type, $this->getStrategy());
0 ignored issues
show
Bug introduced by
It seems like $this->getStrategy() can also be of type null; however, parameter $strategy of ByTIC\Namefy\NameFactory::from() does only seem to accept ByTIC\Namefy\Strategies\AbstractStrategy, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

33
        return NameFactory::from($name, $type, /** @scrutinizer ignore-type */ $this->getStrategy());
Loading history...
34
    }
35
}
36