AppStateESS/InternshipInventory

View on GitHub
class/DataProvider/Student/WebServiceDataProvider.php

Summary

Maintainability
C
1 day
Test Coverage

Function plugStudentValues has a Cognitive Complexity of 26 (exceeds 5 allowed). Consider refactoring.
Open

    protected function plugStudentValues(&$student, \stdClass $data){
        /**********************
        * Basic Demographics *
        **********************/
        $student->setStudentId($data->bannerID);
Severity: Minor
Found in class/DataProvider/Student/WebServiceDataProvider.php - About 3 hrs 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 WebServiceDataProvider has an overall complexity of 52 which is very high. The configured complexity threshold is 50.
Open

class WebServiceDataProvider extends StudentDataProvider {

    protected $currentUserName;

    private $apiKey;

Method plugStudentValues has 53 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    protected function plugStudentValues(&$student, \stdClass $data){
        /**********************
        * Basic Demographics *
        **********************/
        $student->setStudentId($data->bannerID);
Severity: Major
Found in class/DataProvider/Student/WebServiceDataProvider.php - About 2 hrs to fix

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

    public function getStudent($studentId){
        if($studentId === null || $studentId == ''){
            throw new \InvalidArgumentException('Missing student ID.');
        }

Severity: Minor
Found in class/DataProvider/Student/WebServiceDataProvider.php - About 1 hr to fix

Function getStudent has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
Open

    public function getStudent($studentId){
        if($studentId === null || $studentId == ''){
            throw new \InvalidArgumentException('Missing student ID.');
        }

Severity: Minor
Found in class/DataProvider/Student/WebServiceDataProvider.php - About 45 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 getCreditHours has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getCreditHours(string $studentId, string $term){
        if($studentId === null || $studentId == ''){
            throw new \InvalidArgumentException('Missing student ID.');
        }

Severity: Minor
Found in class/DataProvider/Student/WebServiceDataProvider.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 getFacultyMember has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Open

    public function getFacultyMember($facultyId){
        if($facultyId === null || $facultyId == ''){
            throw new \InvalidArgumentException('Missing student ID.');
        }

Severity: Minor
Found in class/DataProvider/Student/WebServiceDataProvider.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 method plugStudentValues() has an NPath complexity of 77760. The configured NPath complexity threshold is 200.
Open

    protected function plugStudentValues(&$student, \stdClass $data){
        /**********************
        * Basic Demographics *
        **********************/
        $student->setStudentId($data->bannerID);

NPathComplexity

Since: 0.1

The NPath complexity of a method is the number of acyclic execution paths through that method. A threshold of 200 is generally considered the point where measures should be taken to reduce complexity.

Example

class Foo {
    function bar() {
        // lots of complicated code
    }
}

Source https://phpmd.org/rules/codesize.html#npathcomplexity

The method plugStudentValues() has a Cyclomatic Complexity of 24. The configured cyclomatic complexity threshold is 10.
Open

    protected function plugStudentValues(&$student, \stdClass $data){
        /**********************
        * Basic Demographics *
        **********************/
        $student->setStudentId($data->bannerID);

CyclomaticComplexity

Since: 0.1

Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.

Example

// Cyclomatic Complexity = 11
class Foo {
1   public function example() {
2       if ($a == $b) {
3           if ($a1 == $b1) {
                fiddle();
4           } elseif ($a2 == $b2) {
                fiddle();
            } else {
                fiddle();
            }
5       } elseif ($c == $d) {
6           while ($c == $d) {
                fiddle();
            }
7        } elseif ($e == $f) {
8           for ($n = 0; $n < $h; $n++) {
                fiddle();
            }
        } else {
            switch ($z) {
9               case 1:
                    fiddle();
                    break;
10              case 2:
                    fiddle();
                    break;
11              case 3:
                    fiddle();
                    break;
                default:
                    fiddle();
                    break;
            }
        }
    }
}

Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity

Missing class import via use statement (line '115', column '23').
Open

            throw new \InvalidArgumentException('Missing student term.');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '144', column '23').
Open

            throw new \InvalidArgumentException('Missing student ID.');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '62', column '23').
Open

            throw new \InvalidArgumentException('Missing student ID.');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '149', column '23').
Open

            throw new \BannerPermissionException('You do not have permission to access student data.');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '100', column '23').
Open

            throw new \Intern\Exception\StudentNotFoundException("Missing student data: $studentId");

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '81', column '23').
Open

            throw new \Intern\Exception\StudentNotFoundException("Could not locate student: $studentId");

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '120', column '23').
Open

            throw new \BannerPermissionException('You do not have permission to access student data.');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '163', column '23').
Open

            throw new \Intern\Exception\StudentNotFoundException("Could not locate faculty member with id: $facultyId");

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '67', column '23').
Open

            throw new \BannerPermissionException('You do not have permission to access student data.');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Missing class import via use statement (line '111', column '23').
Open

            throw new \InvalidArgumentException('Missing student ID.');

MissingImport

Since: 2.7.0

Importing all external classes in a file through use statements makes them clearly visible.

Example

function make() {
    return new \stdClass();
}

Source http://phpmd.org/rules/cleancode.html#MissingImport

Avoid using static access to class '\Current_User' in method 'getFacultyMember'.
Open

        if(!\Current_User::isLogged()){

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 '\Current_User' in method 'getCreditHours'.
Open

        if(!\Current_User::isLogged()){

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

The method plugStudentValues uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $student->setStudentFlag(false);
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid using static access to class '\Intern\LevelFactory' in method 'plugStudentValues'.
Open

            $newLevel = LevelFactory::saveNewCode($data->studentLevel);

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 '\PHPWS_Core' in method 'logRequest'.
Open

        \PHPWS_Core::log($msg, 'curlapi.log', 'CURLAPI');

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

The method plugStudentValues uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $student->setStaffFlag(false);
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method plugStudentValues uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            // If the campus isn't set, then defalt to main campus
            $student->setCampus(Student::MAIN_CAMPUS);
            //\NQ::simple('intern', \Intern\UI\NotifyUI::WARNING, "Campus not found for this student in banner so Main Campus was initially selected.");
            //\NQ::close();

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

The method plugStudentValues uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        } else {
            $student->setConfidentialFlag(true);
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid using static access to class '\Intern\LevelFactory' in method 'plugStudentValues'.
Open

        if(isset($data->studentLevel) && LevelFactory::checkLevelExist($data->studentLevel)){

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 '\PHPWS_Settings' in method '__construct'.
Open

        $this->apiKey = \PHPWS_Settings::get('intern', 'wsdlUri');

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 '\Current_User' in method 'getStudent'.
Open

        if(!\Current_User::isLogged()){

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

The method getCreditHours uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        }else{
            return null;
        }

ElseExpression

Since: 1.4.0

An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.

Example

class Foo
{
    public function bar($flag)
    {
        if ($flag) {
            // one branch
        } else {
            // another branch
        }
    }
}

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

Avoid unused local variables such as '$params'.
Open

        $params = array('BannerID' => $facultyId, 'UserName' => $this->currentUserName);

UnusedLocalVariable

Since: 0.2

Detects when a local variable is declared and/or assigned, but not used.

Example

class Foo {
    public function doSomething()
    {
        $i = 5; // Unused
    }
}

Source https://phpmd.org/rules/unusedcode.html#unusedlocalvariable

TODO found
Open

        // TODO: Maybe be smarter about which result we use?

Call to method __construct from undeclared class \BannerPermissionException (Did you mean class \Intern\Exception\BannerPermissionException)
Open

            throw new \BannerPermissionException('You do not have permission to access student data.');

Call to method isLogged from undeclared class \Current_User
Open

        if(!\Current_User::isLogged()){

Doc-block of $data in plugFacultyValues contains phpdoc param type \Intern\DataProvider\Student\stdClass which is incompatible with the param type \stdClass declared in the signature
Open

    * @param stdClass $data

Declaration of function getStudent(string $studentId) : \Intern\Student should be compatible with function getStudent(string $studentId) : \Intern\DataProvider\Student\Intern\Student defined in /code/class/DataProvider/Student/StudentDataProvider.php:39
Open

    public function getStudent($studentId){

Call to method get from undeclared class \PHPWS_Settings
Open

        $this->apiKey = \PHPWS_Settings::get('intern', 'wsdlUri');

Call to method isLogged from undeclared class \Current_User
Open

        if(!\Current_User::isLogged()){

Returning type null but getCreditHours() is declared to return int
Open

            return null;

Doc-block of $data in plugStudentValues contains phpdoc param type \Intern\DataProvider\Student\stdClass which is incompatible with the param type \stdClass declared in the signature
Open

    * @param stdClass $data

Call to method __construct from undeclared class \BannerPermissionException (Did you mean class \Intern\Exception\BannerPermissionException)
Open

            throw new \BannerPermissionException('You do not have permission to access student data.');

Call to method log from undeclared class \PHPWS_Core
Open

        \PHPWS_Core::log($msg, 'curlapi.log', 'CURLAPI');

Reference to undeclared property \Intern\DataProvider\Student\WebServiceDataProvider->client
Open

        return $this->client->GetInternInfo($params);

Return type of getFacultyMember() is undeclared type \Intern\DataProvider\Student\stdClass (Did you mean class \stdClass)
Open

    public function getFacultyMember($facultyId){

Call to method __construct from undeclared class \BannerPermissionException (Did you mean class \Intern\Exception\BannerPermissionException)
Open

            throw new \BannerPermissionException('You do not have permission to access student data.');

Call to method isLogged from undeclared class \Current_User
Open

        if(!\Current_User::isLogged()){

There are no issues that match your filters.

Category
Status