TypeNamer::nameType()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
/**
4
 * This software package is licensed under `AGPL-3.0-only, proprietary` license[s].
5
 *
6
 * @package maslosoft/manganel
7
 * @license AGPL-3.0-only, proprietary
8
 *
9
 * @copyright Copyright (c) Peter Maselkowski <[email protected]>
10
 * @link https://maslosoft.com/manganel/
11
 */
12
13
namespace Maslosoft\Manganel\Helpers;
14
15
use Maslosoft\Mangan\Helpers\CollectionNamer;
16
use Maslosoft\Manganel\Meta\ManganelMeta;
17
18
/**
19
 * TypeNamer
20
 *
21
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
22
 */
23
class TypeNamer extends CollectionNamer
24
{
25
26 53
	public static function nameType($model)
27
	{
28 53
		$enforcedType = ManganelMeta::create($model)->type()->type;
29 53
		if (!empty($enforcedType))
30
		{
31 1
			$model = new $enforcedType;
32
		}
33 53
		$collectionName = parent::nameCollection($model);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (nameCollection() instead of nameType()). Are you sure this is correct? If so, you might want to change this to $this->nameCollection().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
34 53
		return str_replace('.', '_', $collectionName);
35
	}
36
37
}
38