Kylob/BootPress

View on GitHub
src/Upload/Component.php

Summary

Maintainability
C
1 day
Test Coverage

file accesses the super-global variable $_FILES.
Open

    public function file($field, array $options = array())
    {
        $page = Page::html();

        // View
Severity: Minor
Found in src/Upload/Component.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

file accesses the super-global variable $_FILES.
Open

    public function file($field, array $options = array())
    {
        $page = Page::html();

        // View
Severity: Minor
Found in src/Upload/Component.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

file accesses the super-global variable $_SERVER.
Open

    public function file($field, array $options = array())
    {
        $page = Page::html();

        // View
Severity: Minor
Found in src/Upload/Component.php by phpmd

Superglobals

Since: 0.2

Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.

Example

class Foo {
    public function bar() {
        $name = $_POST['foo'];
    }
}

Source

Method file has 107 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public function file($field, array $options = array())
    {
        $page = Page::html();

        // View
Severity: Major
Found in src/Upload/Component.php - About 4 hrs to fix

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

        public function file($field, array $options = array())
        {
            $page = Page::html();
    
            // View
    Severity: Minor
    Found in src/Upload/Component.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

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

        public static function bootstrap(Form $form)
        {
            if (is_null(self::$folder)) {
                $dir = str_replace('\\', '/', __DIR__).'/uploads/';
                if (!is_dir($dir) && !mkdir($dir, 0755, true)) {
    Severity: Minor
    Found in src/Upload/Component.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 file() contains an exit expression.
    Open

                return (is_file($file)) ? $page->send(Asset::dispatch($file)) : exit;
    Severity: Minor
    Found in src/Upload/Component.php by phpmd

    ExitExpression

    Since: 0.2

    An exit-expression within regular code is untestable and therefore it should be avoided. Consider to move the exit-expression into some kind of startup script where an error/exception code is returned to the calling environment.

    Example

    class Foo {
        public function bar($param)  {
            if ($param === 42) {
                exit(23);
            }
        }
    }

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

    Blank line found at start of control structure
    Open

            if ($blueimp = $page->request->files->get('blueimp') && $page->get('submitted') == $this->form->header['name']) {
    Severity: Minor
    Found in src/Upload/Component.php by phpcodesniffer

    End of line character is invalid; expected "\n" but found "\r\n"
    Open

    <?php
    Severity: Minor
    Found in src/Upload/Component.php by phpcodesniffer

    There are no issues that match your filters.

    Category
    Status