ResourceAggregate::setResources()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
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 SimpleAcl\Resource;
4
5
use SimpleAcl\Object\ObjectAggregate;
6
use SimpleAcl\Resource;
7
8
/**
9
 * Holds resources.
10
 *
11
 * Allow pass itself to Acl::isAllowed method as $resourceName.
12
 *
13
 * @package SimpleAcl\Resource
14
 */
15 View Code Duplication
class ResourceAggregate extends ObjectAggregate implements ResourceAggregateInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
  /**
18
   * Add resource.
19
   *
20
   * @param \SimpleAcl\Resource $resource
21 8
   */
22
  public function addResource(\SimpleAcl\Resource $resource)
23 8
  {
24 8
    parent::addObject($resource);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (addObject() instead of addResource()). Are you sure this is correct? If so, you might want to change this to $this->addObject().

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...
25
  }
26
27
  /**
28
   * Remove all resources.
29
   *
30 1
   */
31
  public function removeResources()
32 1
  {
33 1
    parent::removeObjects();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (removeObjects() instead of removeResources()). Are you sure this is correct? If so, you might want to change this to $this->removeObjects().

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
  }
35
36
  /**
37
   * Remove resource by name.
38
   *
39
   * @param Object|string $resourceName
40 1
   */
41
  public function removeResource($resourceName)
42 1
  {
43 1
    parent::removeObject($resourceName);
0 ignored issues
show
Bug introduced by
It seems like $resourceName defined by parameter $resourceName on line 41 can also be of type object; however, SimpleAcl\Object\ObjectAggregate::removeObject() does only seem to accept object<SimpleAcl\BaseObject>|string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
Comprehensibility Bug introduced by
It seems like you call parent on a different method (removeObject() instead of removeResource()). Are you sure this is correct? If so, you might want to change this to $this->removeObject().

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...
44
  }
45
46
  /**
47
   * Add resources from array.
48
   *
49
   * @param array $resources
50 1
   */
51
  public function setResources($resources)
52 1
  {
53 1
    parent::setObjects($resources);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (setObjects() instead of setResources()). Are you sure this is correct? If so, you might want to change this to $this->setObjects().

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...
54
  }
55
56
  /**
57
   * Return all resources.
58
   *
59
   * @return array|Resource[]
60 6
   */
61
  public function getResources()
62 6
  {
63
    return parent::getObjects();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getObjects() instead of getResources()). Are you sure this is correct? If so, you might want to change this to $this->getObjects().

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...
64
  }
65
66
  /**
67
   * Return array of names for registered resources.
68
   *
69
   * @return array
70 5
   */
71
  public function getResourcesNames(): array
72 5
  {
73
    return parent::getObjectNames();
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getObjectNames() instead of getResourcesNames()). Are you sure this is correct? If so, you might want to change this to $this->getObjectNames().

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...
74
  }
75
76
  /**
77
   * Return resource by name.
78
   *
79
   * @param Resource|string $resourceName
80
   *
81
   * @return null|Resource
82 3
   */
83
  public function getResource($resourceName)
84 3
  {
85
    return parent::getObject($resourceName);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getObject() instead of getResource()). Are you sure this is correct? If so, you might want to change this to $this->getObject().

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...
86
  }
87
}
88