AppStateESS/InternshipInventory

View on GitHub
class/InternshipContractPdfView.php

Summary

Maintainability
D
2 days
Test Coverage

Method generatePdf has 130 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Major
Found in class/InternshipContractPdfView.php - About 5 hrs to fix

Function generatePdf has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
Open

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php - About 1 hr 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 generatePdf() has an NPath complexity of 1152. The configured NPath complexity threshold is 200.
Open

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

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 generatePdf() has 209 lines of code. Current threshold is set to 100. Avoid really long methods.
Open

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

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

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

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 '73', column '26').
Open

        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

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

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

        }else{
            // Too long, need to use two lines, breaks string at whole word around 55 chars
            $addrSup = wordwrap($super_address, 55);
            $superLine1 = substr($addrSup, 0, strpos($addrSup, "\n"));
            $superLine2 = substr($addrSup, strpos($addrSup, "\n"));
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

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 generatePdf uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

            }else{
                //break the string at a word before 50 chars
                $addr = wordwrap($fullAddress, 50);
                $addrFac1 = substr($addr, 0, strpos($addr, "\n"));
                $addrFac2 = substr($addr, strpos($addr, "\n"));
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

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 generatePdf uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
Open

        }else{
            //break the string at a word before 50 chars
            $addr = wordwrap($host_address, 50);
            $addr1 = substr($addr, 0, strpos($addr, "\n"));
            $addr2 = substr($addr, strpos($addr, "\n"));
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

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

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(55, 5, $this->internship->getFullName());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(127, 91);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(190, 97);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(12, 5, $this->internship->getCreditHours());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setSourceFile from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setSourceFile(PHPWS_SOURCE_DIR . 'mod/intern/pdf/Acknowledgment_Updated_202120.pdf');
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Return type of getPdf() is undeclared type \Intern\FPDI
Open

    public function getPdf()
Severity: Minor
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(24, 5, 'X', 0, 0, 'C');
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(168, 69);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(40, 84);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(109, 103);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setFont from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setFont('Times', null, 10);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method addPage from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->addPage();
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method importPage from undeclared class \setasign\Fpdi\Fpdi
Open

        $tplidx = $this->pdf->importPage(1);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method multiCell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->multiCell(60, 3, $d->getName());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(12, 5, $this->internship->getAvgHoursPerWeek());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(73, 6, $this->internship->getCourseTitle());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(147, 97);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method __construct from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(54, 5, $this->internship->getPhoneNumber());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setAutoPageBreak from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setAutoPageBreak(true, 0);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(138, 53);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(85, 69);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(40, 91);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(138, 41);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(54, 5, $this->internship->getEmailAddress() . '@appstate.edu');
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(77, 5, $f->getFax());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(127, 128);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(52, 0, $firstContact->getRelation());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Reference to undeclared constant \PHPWS_SOURCE_DIR
Open

        $this->pdf->setSourceFile(PHPWS_SOURCE_DIR . 'mod/intern/pdf/Acknowledgment_Updated_202120.pdf');
Severity: Minor
Found in class/InternshipContractPdfView.php by phan

Call to method useTemplate from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->useTemplate($tplidx);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(24, 5, 'X', 0, 0, 'C');
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(42, 5, $this->internship->getBannerId());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(27, 6, $this->term->getDescription());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

                $this->pdf->cell(81, 5, $fullAddress);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(77, 0, $h->getSubName());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Reference to undeclared constant \PHPWS_SOURCE_DIR
Open

require_once PHPWS_SOURCE_DIR . 'mod/intern/vendor/autoload.php';
Severity: Minor
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(155, 84);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(22, 103);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(78, 5, $superLine2);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(28, 120);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(75, 5, $super);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(78, 5, $superLine1);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(127, 128);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(52, 0, $firstContact->getPhone());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(113, 125);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(113, 149);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(112, 133);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(137, 174);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(125, 166);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

                $this->pdf->cell(81, 5, $addrFac1);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(77, 5, $host_address);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(77, 5, $addr1);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(59, 273);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(134, 273);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(81, 5, $f->getFullName());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(113, 149);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(33, 5, $s->getSupervisorPhoneNumber());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method addPage from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->addPage();
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(52, 0, $firstContact->getName());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

                $this->pdf->setXY(31, 127);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(29, 141);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(25, 148);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(77, 5, $f->getUsername() . '@appstate.edu');
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

                $this->pdf->setXY(15, 134);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(139, 117);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(71, 6, $h->getMainName());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(40, 5, $s->getSupervisorFaxNumber());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(175, 103);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(30, 5, $this->term->getEndDateFormatted(), 0, 0, 'C');
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(28, 155);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

                $this->pdf->cell(81, 5, $addrFac2);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(172, 273);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(77, 5, $addr2);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(166, 160);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method importPage from undeclared class \setasign\Fpdi\Fpdi
Open

        $tplidx = $this->pdf->importPage(2);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(113, 144);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(78, 5, $super_address);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->setXY(113, 155);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->setXY(125, 160);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method useTemplate from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->useTemplate($tplidx);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(30, 5, $this->term->getStartDateFormatted(), 0, 0, 'C');
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method setXY from undeclared class \setasign\Fpdi\Fpdi
Open

                $this->pdf->setXY(31, 127);
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

            $this->pdf->cell(77, 5, $f->getPhone());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(77,0, $this->internship->getRemoteState());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Call to method cell from undeclared class \setasign\Fpdi\Fpdi
Open

        $this->pdf->cell(72, 5, $s->getSupervisorEmail());
Severity: Critical
Found in class/InternshipContractPdfView.php by phan

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        if(strlen($super_address) < 65){
            // If it's short enough, just write it
            $this->pdf->setXY(113, 149);
            $this->pdf->cell(78, 5, $super_address);
        }else{
Severity: Major
Found in class/InternshipContractPdfView.php and 2 other locations - About 5 hrs to fix
class/InternshipContractPdfView.php on lines 157..171
class/InternshipContractPdfView.php on lines 194..208

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 186.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

            if(strlen($fullAddress) < 51){
                // If it's short enough, just write it
                $this->pdf->setXY(31, 127);
                $this->pdf->cell(81, 5, $fullAddress);
            }else{
Severity: Major
Found in class/InternshipContractPdfView.php and 2 other locations - About 5 hrs to fix
class/InternshipContractPdfView.php on lines 194..208
class/InternshipContractPdfView.php on lines 233..247

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 186.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Similar blocks of code found in 3 locations. Consider refactoring.
Open

        if(strlen($host_address) < 51){
            // If it's short enough, just write it
            $this->pdf->setXY(127, 128);
            $this->pdf->cell(77, 5, $host_address);
        }else{
Severity: Major
Found in class/InternshipContractPdfView.php and 2 other locations - About 5 hrs to fix
class/InternshipContractPdfView.php on lines 157..171
class/InternshipContractPdfView.php on lines 233..247

Duplicated Code

Duplicated code can lead to software that is hard to understand and difficult to change. The Don't Repeat Yourself (DRY) principle states:

Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

When you violate DRY, bugs and maintenance problems are sure to follow. Duplicated code has a tendency to both continue to replicate and also to diverge (leaving bugs as two similar implementations differ in subtle ways).

Tuning

This issue has a mass of 186.

We set useful threshold defaults for the languages we support but you may want to adjust these settings based on your project guidelines.

The threshold configuration represents the minimum mass a code block must have to be analyzed for duplication. The lower the threshold, the more fine-grained the comparison.

If the engine is too easily reporting duplication, try raising the threshold. If you suspect that the engine isn't catching enough duplication, try lowering the threshold. The best setting tends to differ from language to language.

See codeclimate-duplication's documentation for more information about tuning the mass threshold in your .codeclimate.yml.

Refactorings

Further Reading

Avoid variables with short names like $s. Configured minimum length is 3.
Open

        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $h. Configured minimum length is 3.
Open

        $h = $this->internship->getHost();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $f. Configured minimum length is 3.
Open

        $f = $this->internship->getFaculty();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $d. Configured minimum length is 3.
Open

        $d = $this->internship->getDepartment();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

Avoid variables with short names like $i. Configured minimum length is 3.
Open

    public function __construct(Internship $i, Array $emergencyContacts, Term $term)
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

ShortVariable

Since: 0.2

Detects when a field, local, or parameter has a very short name.

Example

class Something {
    private $q = 15; // VIOLATION - Field
    public static function main( array $as ) { // VIOLATION - Formal
        $r = 20 + $this->q; // VIOLATION - Local
        for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
            $r += $this->q;
        }
    }
}

Source https://phpmd.org/rules/naming.html#shortvariable

The variable $host_address is not named in camelCase.
Open

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $host_address is not named in camelCase.
Open

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $host_address is not named in camelCase.
Open

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $super_address is not named in camelCase.
Open

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $host_address is not named in camelCase.
Open

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $super_address is not named in camelCase.
Open

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $super_address is not named in camelCase.
Open

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

The variable $super_address is not named in camelCase.
Open

    private function generatePdf()
    {
        $this->pdf = new \setasign\Fpdi\Fpdi('P', 'mm', 'Letter');
        $h = $this->internship->getHost();
        $s = $this->internship->getSupervisor();
Severity: Minor
Found in class/InternshipContractPdfView.php by phpmd

CamelCaseVariableName

Since: 0.2

It is considered best practice to use the camelCase notation to name variables.

Example

class ClassName {
    public function doSomething() {
        $data_module = new DataModule();
    }
}

Source

There are no issues that match your filters.

Category
Status