Passed
Push — master ( 64ab61...b96172 )
by Gabor
09:36
created

UserGroupEntityTrait::createUserGroupEntity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * WebHemi.
4
 *
5
 * PHP version 5.6
6
 *
7
 * @copyright 2012 - 2016 Gixx-web (http://www.gixx-web.com)
8
 * @license   https://opensource.org/licenses/MIT The MIT License (MIT)
9
 *
10
 * @link      http://www.gixx-web.com
11
 */
12
namespace WebHemi\Data\Coupler\Traits;
13
14
use DateTime;
15
use WebHemi\Data\Entity\User\UserGroupEntity;
16
17
/**
18
 * Class UserGroupEntityTrait.
19
 */
20
trait UserGroupEntityTrait
21
{
22
    /**
23
     * Creates a new Policy Entity instance form the data.
24
     *
25
     * @param array $data
26
     * @return UserGroupEntity
27
     */
28
    protected function createUserGroupEntity(array $data)
29
    {
30
        /* @var UserGroupEntity $entity */
31
        $entity = parent::getNewEntityInstance(UserGroupEntity::class);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getNewEntityInstance() instead of createUserGroupEntity()). Are you sure this is correct? If so, you might want to change this to $this->getNewEntityInstance().

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...
32
33
        $entity->setUserGroupId($data['id_user_group'])
34
            ->setTitle($data['title'])
35
            ->setDescription($data['description'])
36
            ->setReadOnly($data['is_read_only'])
37
            ->setDateCreated(new DateTime($data['date_created']))
38
            ->setDateModified(new DateTime($data['date_created']));
39
40
        return $entity;
41
    }
42
}
43