mambax7/publisher

View on GitHub
class/Jsonld.php

Summary

Maintainability
A
1 hr
Test Coverage

Method getArticle has 38 lines of code (exceeds 25 allowed). Consider refactoring.
Open

    public static function getArticle(Item $itemObj, Category $categoryObj, \XoopsUser $xoopsUser, Helper $helper)
    {
        $itemImage = $itemObj->getVar('image');
        if (isset($itemImage)) {
            $imageHandler = xoops_getHandler('image');
Severity: Minor
Found in class/Jsonld.php - About 1 hr to fix

    Avoid using undefined variables such as '$schema' which will lead to PHP notices.
    Open

                $ret = '<script type="application/ld+json">' . json_encode($schema, \JSON_PRETTY_PRINT | \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES) . '</script>';
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$schema' which will lead to PHP notices.
    Open

                $schema['@type']    = 'Article';
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$schema' which will lead to PHP notices.
    Open

                $schema['@context'] = 'https://schema.org/';
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$schema' which will lead to PHP notices.
    Open

                $schema['publisher'] = self::getOrganization($xoopsConfig, $xoops_url);
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Avoid using undefined variables such as '$schema' which will lead to PHP notices.
    Open

                    $schema['author'] = self::getAuthor($xoopsUser);
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    UndefinedVariable

    Since: 2.8.0

    Detects when a variable is used that has not been defined before.

    Example

    class Foo
    {
        private function bar()
        {
            // $message is undefined
            echo $message;
        }
    }

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

    Missing class import via use statement (line '66', column '33').
    Open

                $criteria     = new \Criteria('image_id', $itemObj->getVar('image'));
    Severity: Minor
    Found in class/Jsonld.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

    Avoid using static access to class 'XoopsModules\Publisher\Helper' in method 'getItem'.
    Open

            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class 'XoopsModules\Publisher\Helper' in method 'getAuthoritem'.
    Open

            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class 'XoopsModules\Publisher\Helper' in method 'getIndex'.
    Open

            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid using static access to class 'XoopsModules\Publisher\Helper' in method 'getCategory'.
    Open

            $helper = Helper::getInstance();
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    StaticAccess

    Since: 1.4.0

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

    Example

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

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

    Avoid unused parameters such as '$settings'.
    Open

        public static function getBreadcrumbs(?array $data, $settings = null)
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

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

    Avoid unused parameters such as '$data'.
    Open

        public static function getBreadcrumbs(?array $data, $settings = null)
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    UnusedFormalParameter

    Since: 0.2

    Avoid passing parameters to methods or constructors and then not using those parameters.

    Example

    class Foo
    {
        private function bar($howdy)
        {
            // $howdy is not used
        }
    }

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

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

                global $xoopsConfig, $xoopsUser, $xoops_url;
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    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

    The parameter $xoops_url is not named in camelCase.
    Open

        public static function getWebsite($xoopsConfig, $xoops_url)
        {
            $website = [
                "@context" => "https://schema.org",
                "@type"    => "WebSite",
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $xoops_url is not named in camelCase.
    Open

        public static function getAuthoritem($xoopsUser, array $xoopsConfig, string $xoops_url)
        {
            $ret    = '';
            $helper = Helper::getInstance();
            if ($helper->getConfig('generate_jsonld')) {
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $xoops_url is not named in camelCase.
    Open

        public static function getIndex($xoopsConfig, $xoopsUser, $xoops_url)
        {
            $ret    = '';
            $helper = Helper::getInstance();
    
    
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    The parameter $xoops_url is not named in camelCase.
    Open

        public static function getOrganization(array $xoopsConfig, string $xoops_url)
        {
            $organization = [
                "@context" => "https://schema.org",
                "@type"    => "Organization",
    Severity: Minor
    Found in class/Jsonld.php by phpmd

    CamelCaseParameterName

    Since: 0.2

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

    Example

    class ClassName {
        public function doSomething($user_name) {
        }
    }

    Source

    Expected 1 blank line at end of file; 2 found
    Open

    }
    Severity: Minor
    Found in class/Jsonld.php by phpcodesniffer

    The variable $xoops_url is not named in camelCase.
    Open

        public static function getOrganization(array $xoopsConfig, string $xoops_url)
        {
            $organization = [
                "@context" => "https://schema.org",
                "@type"    => "Organization",
    Severity: Minor
    Found in class/Jsonld.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 $xoops_url is not named in camelCase.
    Open

        public static function getItem(Item $itemObj, Category $categoryObj): string
        {
            $ret    = '';
            $helper = Helper::getInstance();
            if ($helper->getConfig('generate_jsonld')) {
    Severity: Minor
    Found in class/Jsonld.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 $xoops_url is not named in camelCase.
    Open

        public static function getIndex($xoopsConfig, $xoopsUser, $xoops_url)
        {
            $ret    = '';
            $helper = Helper::getInstance();
    
    
    Severity: Minor
    Found in class/Jsonld.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 $xoops_url is not named in camelCase.
    Open

        public static function getItem(Item $itemObj, Category $categoryObj): string
        {
            $ret    = '';
            $helper = Helper::getInstance();
            if ($helper->getConfig('generate_jsonld')) {
    Severity: Minor
    Found in class/Jsonld.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 $xoops_url is not named in camelCase.
    Open

        public static function getCategory(Category $categoryObj)
        {
            $ret    = '';
            $helper = Helper::getInstance();
            if ($helper->getConfig('generate_jsonld')) {
    Severity: Minor
    Found in class/Jsonld.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 $xoops_url is not named in camelCase.
    Open

        public static function getOrganization(array $xoopsConfig, string $xoops_url)
        {
            $organization = [
                "@context" => "https://schema.org",
                "@type"    => "Organization",
    Severity: Minor
    Found in class/Jsonld.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 $xoops_url is not named in camelCase.
    Open

        public static function getCategory(Category $categoryObj)
        {
            $ret    = '';
            $helper = Helper::getInstance();
            if ($helper->getConfig('generate_jsonld')) {
    Severity: Minor
    Found in class/Jsonld.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 $xoops_url is not named in camelCase.
    Open

        public static function getWebsite($xoopsConfig, $xoops_url)
        {
            $website = [
                "@context" => "https://schema.org",
                "@type"    => "WebSite",
    Severity: Minor
    Found in class/Jsonld.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 $xoops_url is not named in camelCase.
    Open

        public static function getAuthoritem($xoopsUser, array $xoopsConfig, string $xoops_url)
        {
            $ret    = '';
            $helper = Helper::getInstance();
            if ($helper->getConfig('generate_jsonld')) {
    Severity: Minor
    Found in class/Jsonld.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