rhosocial/yii2-organization

View on GitHub
Member.php

Summary

Maintainability
C
1 day
Test Coverage

The class Member has an overall complexity of 59 which is very high. The configured complexity threshold is 50.
Open

class Member extends BaseBlameableModel
{
    public $createdByAttribute = 'organization_guid';
    public $updatedByAttribute = false;
    public $hostClass = Organization::class;
Severity: Minor
Found in Member.php by phpmd

Member has 27 functions (exceeds 20 allowed). Consider refactoring.
Open

class Member extends BaseBlameableModel
{
    public $createdByAttribute = 'organization_guid';
    public $updatedByAttribute = false;
    public $hostClass = Organization::class;
Severity: Minor
Found in Member.php - About 3 hrs to fix

    File Member.php has 279 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    <?php
    
    /**
     *  _   __ __ _____ _____ ___  ____  _____
     * | | / // // ___//_  _//   ||  __||_   _|
    Severity: Minor
    Found in Member.php - About 2 hrs to fix

      Method revokeRole has 27 lines of code (exceeds 25 allowed). Consider refactoring.
      Open

          public function revokeRole($role)
          {
              $user = $this->memberUser;
              if (!$user) {
                  throw new InvalidValueException('Invalid User');
      Severity: Minor
      Found in Member.php - About 1 hr to fix

        Method revokeAdministrator has 26 lines of code (exceeds 25 allowed). Consider refactoring.
        Open

            public function revokeAdministrator()
            {
                $host = $this->organization;
                /* @var $host Organization */
                if ($this->isCreator()) {
        Severity: Minor
        Found in Member.php - About 1 hr to fix

          Method assignAdministrator has 26 lines of code (exceeds 25 allowed). Consider refactoring.
          Open

              public function assignAdministrator()
              {
                  $host = $this->organization;
                  /* @var $host Organization */
                  if ($this->isCreator()) {
          Severity: Minor
          Found in Member.php - About 1 hr to fix

            Function revokeRole has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
            Open

                public function revokeRole($role)
                {
                    $user = $this->memberUser;
                    if (!$user) {
                        throw new InvalidValueException('Invalid User');
            Severity: Minor
            Found in Member.php - About 35 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function assignAdministrator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function assignAdministrator()
                {
                    $host = $this->organization;
                    /* @var $host Organization */
                    if ($this->isCreator()) {
            Severity: Minor
            Found in Member.php - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            Function revokeAdministrator has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
            Open

                public function revokeAdministrator()
                {
                    $host = $this->organization;
                    /* @var $host Organization */
                    if ($this->isCreator()) {
            Severity: Minor
            Found in Member.php - About 25 mins to fix

            Cognitive Complexity

            Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

            A method's cognitive complexity is based on a few simple rules:

            • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
            • Code is considered more complex for each "break in the linear flow of the code"
            • Code is considered more complex when "flow breaking structures are nested"

            Further reading

            The class Member has a coupling between objects value of 17. Consider to reduce the number of dependencies under 13.
            Open

            class Member extends BaseBlameableModel
            {
                public $createdByAttribute = 'organization_guid';
                public $updatedByAttribute = false;
                public $hostClass = Organization::class;
            Severity: Minor
            Found in Member.php by phpmd

            CouplingBetweenObjects

            Since: 1.1.0

            A class with too many dependencies has negative impacts on several quality aspects of a class. This includes quality criteria like stability, maintainability and understandability

            Example

            class Foo {
                /**
                 * @var \foo\bar\X
                 */
                private $x = null;
            
                /**
                 * @var \foo\bar\Y
                 */
                private $y = null;
            
                /**
                 * @var \foo\bar\Z
                 */
                private $z = null;
            
                public function setFoo(\Foo $foo) {}
                public function setBar(\Bar $bar) {}
                public function setBaz(\Baz $baz) {}
            
                /**
                 * @return \SplObjectStorage
                 * @throws \OutOfRangeException
                 * @throws \InvalidArgumentException
                 * @throws \ErrorException
                 */
                public function process(\Iterator $it) {}
            
                // ...
            }

            Source https://phpmd.org/rules/design.html#couplingbetweenobjects

            Avoid using static access to class '\Yii' in method 'assignAdministrator'.
            Open

                        Yii::error($ex->getMessage(), __METHOD__);
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'attributeLabels'.
            Open

                        'role' => Yii::t('organization', 'Role'),
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'revokeAdministrator'.
            Open

                        throw new InvalidCallException(Yii::t('organization', 'The user is already a creator.'));
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'assignAdministrator'.
            Open

                        throw new InvalidCallException(Yii::t('organization', 'The user is already a creator.'));
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'assignAdministrator'.
            Open

                        throw new InvalidCallException(Yii::t('organization', 'The user is already an administrator.'));
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'attributeLabels'.
            Open

                        $this->memberAttribute => Yii::t('organization', 'User GUID'),
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'attributeLabels'.
            Open

                        $this->descriptionAttribute => Yii::t('organization', 'Description'),
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'attributeLabels'.
            Open

                        $this->createdAtAttribute => Yii::t('organization', 'Join Time'),
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'attributeLabels'.
            Open

                        $this->idAttribute => Yii::t('user', 'ID'),
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'attributeLabels'.
            Open

                        $this->ipAttribute => Yii::t('user', 'IP Address'),
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'attributeLabels'.
            Open

                        $this->contentAttribute => Yii::t('user', 'Nickname'),
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'revokeAdministrator'.
            Open

                        throw new InvalidCallException(Yii::t('organization', 'The user is not administrator yet.'));
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'attributeLabels'.
            Open

                        $this->guidAttribute => Yii::t('user', 'GUID'),
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'attributeLabels'.
            Open

                        'position' => Yii::t('organization', 'Member Position'),
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'attributeLabels'.
            Open

                        $this->ipTypeAttribute => Yii::t('user', 'IP Address Type'),
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'revokeAdministrator'.
            Open

                        Yii::error($ex->getMessage(), __METHOD__);
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'assignAdministrator'.
            Open

                            throw new IntegrityException(Yii::t('organization', 'Failed to assign administrator.'));
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'revokeRole'.
            Open

                        Yii::error($ex->getMessage(), __METHOD__);
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'attributeLabels'.
            Open

                        $this->updatedAtAttribute => Yii::t('user', 'Last Updated Time'),
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Avoid using static access to class '\Yii' in method 'attributeLabels'.
            Open

                        $this->createdByAttribute => Yii::t('organization', 'Organization GUID'),
            Severity: Minor
            Found in Member.php by phpmd

            StaticAccess

            Since: 1.4.0

            Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.

            Example

            class Foo
            {
                public function bar()
                {
                    Bar::baz();
                }
            }

            Source https://phpmd.org/rules/cleancode.html#staticaccess

            Line exceeds 120 characters; contains 126 characters
            Open

                    return $this->hasOne($this->memberUserClass, [$this->getNoInitMemberUser()->guidAttribute => $this->memberAttribute]);
            Severity: Minor
            Found in Member.php by phpcodesniffer

            Line exceeds 120 characters; contains 135 characters
            Open

                    return array_merge($this->getMemberUserRules(), $this->getMemberRoleRules(), $this->getMemberPositionRules(), parent::rules());
            Severity: Minor
            Found in Member.php by phpcodesniffer

            Whitespace found at end of line
            Open

             * 
            Severity: Minor
            Found in Member.php by phpcodesniffer

            There are no issues that match your filters.

            Category
            Status