YetiForceCompany/YetiForceCRM

View on GitHub
modules/Settings/ModuleManager/models/Library.php

Summary

Maintainability
B
5 hrs
Test Coverage
B
83%

Function download has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    public static function download(string $name): bool
    {
        $returnVal = true;
        if (!static::$libraries[$name]) {
            App\Log::warning('Library does not exist: ' . $name, 'Library');
Severity: Minor
Found in modules/Settings/ModuleManager/models/Library.php - About 2 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

Method download has 41 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function download(string $name): bool
    {
        $returnVal = true;
        if (!static::$libraries[$name]) {
            App\Log::warning('Library does not exist: ' . $name, 'Library');
Severity: Minor
Found in modules/Settings/ModuleManager/models/Library.php - About 1 hr to fix

    Function getAll has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
    Open

        public static function &getAll()
        {
            $libs = [];
            foreach (static::$libraries as $name => $lib) {
                $status = 0;
    Severity: Minor
    Found in modules/Settings/ModuleManager/models/Library.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

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

        public static function checkLibrary($name)
        {
            if (App\Cache::has('checkLibrary', $name)) {
                return App\Cache::get('checkLibrary', $name);
            }
    Severity: Minor
    Found in modules/Settings/ModuleManager/models/Library.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

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

        public static function download(string $name): bool
        {
            $returnVal = true;
            if (!static::$libraries[$name]) {
                App\Log::warning('Library does not exist: ' . $name, 'Library');

    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

    Refactor this function to reduce its Cognitive Complexity from 17 to the 15 allowed.
    Open

        public static function download(string $name): bool

    Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.

    See

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

    class Settings_ModuleManager_Library_Model
    {
        /**
         * List of all installation libraries.
         *

    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

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

                    (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url, ['sink' => $path]);

    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 '109', column '14').
    Open

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

    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 'App\Version' in method 'download'.
    Open

            $mode = \App\Config::developer('MISSING_LIBRARY_DEV_MODE') ? 'developer' : App\Version::get($lib['name']);

    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 '\App\Log' in method 'download'.
    Open

                    \App\Log::endProfile("GET|Library::download|{$url}", 'Library');

    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 'App\Cache' in method 'checkLibrary'.
    Open

                return App\Cache::get('checkLibrary', $name);

    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 '\App\RequestUtil' in method 'download'.
    Open

            if (!file_exists($path) && \App\RequestUtil::isNetConnection()) {

    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 '\App\RequestHttp' in method 'download'.
    Open

                    (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url, ['sink' => $path]);

    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 'App\Log' in method 'download'.
    Open

                        App\Log::trace('Completed downloads library: ' . $name, 'Library');

    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 'App\Cache' in method 'checkLibrary'.
    Open

            if (App\Cache::has('checkLibrary', $name)) {

    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 'App\Log' in method 'download'.
    Open

                        App\Log::warning('Can not connect to the server' . $url, 'Library');

    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 'App\Version' in method 'checkLibrary'.
    Open

                    if (App\Version::check($libVersion['version'], $lib['name'])) {

    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 'App\Cache' in method 'checkLibrary'.
    Open

            App\Cache::save('checkLibrary', $name, $status, App\Cache::LONG);

    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 'App\Log' in method 'download'.
    Open

                App\Log::trace('Started downloading library: ' . $name, 'Library');

    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 '\App\Log' in method 'download'.
    Open

                    \App\Log::beginProfile("GET|Library::download|{$url}", 'Library');

    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 'App\Log' in method 'download'.
    Open

                App\Log::warning('Library does not exist: ' . $name, 'Library');

    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 'App\Version' in method 'getAll'.
    Open

                        if (App\Version::check($libVersion['version'], $lib['name'])) {

    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 '\vtlib\Functions' in method 'download'.
    Open

                \vtlib\Functions::recurseDelete($lib['dir']);

    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 'App\Log' in method 'download'.
    Open

                App\Log::warning('No import file: ' . $name, 'Library');

    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 '\App\Config' in method 'download'.
    Open

            $mode = \App\Config::developer('MISSING_LIBRARY_DEV_MODE') ? 'developer' : App\Version::get($lib['name']);

    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 '\App\Zip' in method 'download'.
    Open

                $zip = \App\Zip::openFile($path, ['checkFiles' => false]);

    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 '\App\Log' in method 'download'.
    Open

                    \App\Log::warning($ex->__toString(), __METHOD__, 'Library');

    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 '\App\Db' in method 'download'.
    Open

                    $db = \App\Db::getInstance();

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

            } else {
                App\Log::warning('No import file: ' . $name, 'Library');
                $returnVal = 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 download uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
    Open

                    } else {
                        App\Log::warning('Can not connect to the server' . $url, 'Library');
                    }

    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

    Define a constant instead of duplicating this literal "version.php" 4 times.
    Open

                if (file_exists($lib['dir'] . 'version.php')) {

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "checkLibrary" 3 times.
    Open

            if (App\Cache::has('checkLibrary', $name)) {

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

    Define a constant instead of duplicating this literal "Library" 8 times.
    Open

                App\Log::warning('Library does not exist: ' . $name, 'Library');

    Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.

    On the other hand, constants can be referenced from many places, but only need to be updated in a single place.

    Noncompliant Code Example

    With the default threshold of 3:

    function run() {
      prepare('action1');                              // Non-Compliant - 'action1' is duplicated 3 times
      execute('action1');
      release('action1');
    }
    

    Compliant Solution

    ACTION_1 = 'action1';
    
    function run() {
      prepare(ACTION_1);
      execute(ACTION_1);
      release(ACTION_1);
    }
    

    Exceptions

    To prevent generating some false-positives, literals having less than 5 characters are excluded.

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

            foreach (static::$libraries as $name => &$lib) {

    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

    Call to method request from undeclared class \GuzzleHttp\Client
    Open

                    (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url, ['sink' => $path]);

    Call to undeclared method \App\Db::createCommand
    Open

                        $db->createCommand()->truncateTable($table)->execute();

    Call to method endProfile from undeclared class \App\Log
    Open

                    \App\Log::endProfile("GET|Library::download|{$url}", 'Library');

    Call to method trace from undeclared class \App\Log
    Open

                App\Log::trace('Started downloading library: ' . $name, 'Library');

    Call to method warning from undeclared class \App\Log
    Open

                    \App\Log::warning($ex->__toString(), __METHOD__, 'Library');

    Call to method __construct from undeclared class \GuzzleHttp\Client
    Open

                    (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url, ['sink' => $path]);

    Argument 1 (fileName) is 'cache/upload/lib_roundcube.zip' but \App\Zip::openFile() takes bool|false defined at /code/app/Zip.php:51
    Open

                $zip = \App\Zip::openFile($path, ['checkFiles' => false]);

    Call to method warning from undeclared class \App\Log
    Open

                App\Log::warning('Library does not exist: ' . $name, 'Library');

    Call to method beginProfile from undeclared class \App\Log
    Open

                    \App\Log::beginProfile("GET|Library::download|{$url}", 'Library');

    Call to method warning from undeclared class \App\Log
    Open

                App\Log::warning('No import file: ' . $name, 'Library');

    Call to method trace from undeclared class \App\Log
    Open

                        App\Log::trace('Completed downloads library: ' . $name, 'Library');

    Call to method warning from undeclared class \App\Log
    Open

                        App\Log::warning('Can not connect to the server' . $url, 'Library');

    Each class must be in a namespace of at least one level (a top-level vendor name)
    Open

    class Settings_ModuleManager_Library_Model

    The class Settings_ModuleManager_Library_Model is not named in CamelCase.
    Open

    class Settings_ModuleManager_Library_Model
    {
        /**
         * List of all installation libraries.
         *

    CamelCaseClassName

    Since: 0.2

    It is considered best practice to use the CamelCase notation to name classes.

    Example

    class class_name {
    }

    Source

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

                    $db = \App\Db::getInstance();

    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

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * List of all installation libraries.

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * Function to check library status.

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param string $name

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                if (is_dir($lib['dir'])) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @throws \App\Exceptions\AppException

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public static function download(string $name): bool

    Spaces must be used to indent lines; tabs are not allowed
    Open

                throw new \App\Exceptions\NoPermitted('LBL_PERMISSION_DENIED', 406);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $lib = static::$libraries[$name];

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (static::$libraries[$name]) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $libs = [];

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * Function to download library.

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    \App\Log::beginProfile("GET|Library::download|{$url}", 'Library');

    Spaces must be used to indent lines; tabs are not allowed
    Open

        const TEMP_DIR = 'cache' . DIRECTORY_SEPARATOR . 'upload';

    Spaces must be used to indent lines; tabs are not allowed
    Open

                return App\Cache::get('checkLibrary', $name);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public static function &getAll()

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $status = 2;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    if (\file_exists($path)) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (App\Cache::has('checkLibrary', $name)) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @return array

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $path = static::TEMP_DIR . DIRECTORY_SEPARATOR . $lib['name'] . '.zip';

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $mode = \App\Config::developer('MISSING_LIBRARY_DEV_MODE') ? 'developer' : App\Version::get($lib['name']);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                } catch (\Exception $ex) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @return bool

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @return bool

    Spaces must be used to indent lines; tabs are not allowed
    Open

                try {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    \App\Log::endProfile("GET|Library::download|{$url}", 'Library');

    Spaces must be used to indent lines; tabs are not allowed
    Open

                        App\Log::warning('Can not connect to the server' . $url, 'Library');

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $status = true;

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @throws \App\Exceptions\NoPermitted

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    (new \GuzzleHttp\Client(\App\RequestHttp::getOptions()))->request('GET', $url, ['sink' => $path]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    } else {

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param string $name

    Spaces must be used to indent lines; tabs are not allowed
    Open

                        $status = false;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $libs[$name] = $lib;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                \vtlib\Functions::recurseDelete($lib['dir']);

    Line exceeds 120 characters; contains 164 characters
    Open

            'roundcube' => ['dir' => 'public_html/modules/OSSMail/roundcube/', 'url' => 'https://github.com/YetiForceCompany/lib_roundcube', 'name' => 'lib_roundcube'],

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public static function checkLibrary($name)

    Spaces must be used to indent lines; tabs are not allowed
    Open

                if (file_exists($lib['dir'] . 'version.php')) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            foreach (static::$libraries as $name => $lib) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                        if (App\Version::check($libVersion['version'], $lib['name'])) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public static function downloadAll()

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $returnVal = true;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                App\Log::warning('Library does not exist: ' . $name, 'Library');

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (!file_exists($path) && \App\RequestUtil::isNetConnection()) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $zip->unzip([$compressedName => $lib['dir']]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                App\Log::warning('No import file: ' . $name, 'Library');

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * Path to save temporary files.

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $libVersion = require $lib['dir'] . 'version.php';

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $status;

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (!static::$libraries[$name]) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $url = $lib['url'] . "/archive/$mode.zip";

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    \App\Log::warning($ex->__toString(), __METHOD__, 'Library');

    Spaces must be used to indent lines; tabs are not allowed
    Open

                if ('roundcube' === $name) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            'roundcube' => ['dir' => 'public_html/modules/OSSMail/roundcube/', 'url' => 'https://github.com/YetiForceCompany/lib_roundcube', 'name' => 'lib_roundcube'],

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            if (file_exists($path) && filesize($path) > 0) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                unlink($path);

    Spaces must be used to indent lines; tabs are not allowed
    Open

            } else {

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public static function update($name)

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    $db = \App\Db::getInstance();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    if (App\Version::check($libVersion['version'], $lib['name'])) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            App\Cache::save('checkLibrary', $name, $status, App\Cache::LONG);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    if (file_exists($lib['dir'] . 'version.php')) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @param string $name

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

            $compressedName = $lib['name'] . '-' . $mode;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                App\Log::trace('Started downloading library: ' . $name, 'Library');

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $returnVal = false;

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

        ];

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @var string

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * Download all missing libraries.

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $status = 0;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $lib['status'] = $status;

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $libs;

    Spaces must be used to indent lines; tabs are not allowed
    Open

            foreach (static::$libraries as $name => &$lib) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                static::download($name);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                        $db->createCommand()->truncateTable($table)->execute();

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $zip = \App\Zip::openFile($path, ['checkFiles' => false]);

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                }

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * Function to update library.

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    foreach (['roundcube_cache', 'roundcube_cache_index', 'roundcube_cache_messages', 'roundcube_cache_shared', 'roundcube_cache_thread'] as $table) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            static::download($name);

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * @var array

    Spaces must be used to indent lines; tabs are not allowed
    Open

        public static $libraries = [

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

        /**

    Spaces must be used to indent lines; tabs are not allowed
    Open

         */

    Spaces must be used to indent lines; tabs are not allowed
    Open

                $lib = static::$libraries[$name];

    Spaces must be used to indent lines; tabs are not allowed
    Open

         * Get a list of all libraries and their statuses.

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

                        $libVersion = require $lib['dir'] . 'version.php';

    Spaces must be used to indent lines; tabs are not allowed
    Open

                            $status = 1;

    Spaces must be used to indent lines; tabs are not allowed
    Open

                    }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Spaces must be used to indent lines; tabs are not allowed
    Open

         *

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

                        App\Log::trace('Completed downloads library: ' . $name, 'Library');

    Spaces must be used to indent lines; tabs are not allowed
    Open

        {

    Line exceeds 120 characters; contains 162 characters
    Open

                    foreach (['roundcube_cache', 'roundcube_cache_index', 'roundcube_cache_messages', 'roundcube_cache_shared', 'roundcube_cache_thread'] as $table) {

    Spaces must be used to indent lines; tabs are not allowed
    Open

            }

    Spaces must be used to indent lines; tabs are not allowed
    Open

            return $returnVal;

    Spaces must be used to indent lines; tabs are not allowed
    Open

        }

    Class name "Settings_ModuleManager_Library_Model" is not in camel caps format
    Open

    class Settings_ModuleManager_Library_Model

    There are no issues that match your filters.

    Category
    Status