mambax7/extgallery

View on GitHub
class/PublicPhotoHandler.php

Summary

Maintainability
C
1 day
Test Coverage

getUserAlbumPhotoPage accesses the super-global variable $GLOBALS.
Open

    public function getUserAlbumPhotoPage($userId, $start, $sortby, $orderby)
    {
        $catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory');

        $criteria = new CriteriaCompo();
Severity: Minor
Found in class/PublicPhotoHandler.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

getUserAlbumPhotoPage accesses the super-global variable $GLOBALS.
Open

    public function getUserAlbumPhotoPage($userId, $start, $sortby, $orderby)
    {
        $catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory');

        $criteria = new CriteriaCompo();
Severity: Minor
Found in class/PublicPhotoHandler.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

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

    public function getUserAlbumNextPhoto($userId, $photoDate)
    {
        $catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory');

        $criteria = new CriteriaCompo();
Severity: Major
Found in class/PublicPhotoHandler.php and 3 other locations - About 3 hrs to fix
class/PhotoHandler.php on lines 245..259
class/PhotoHandler.php on lines 267..281
class/PublicPhotoHandler.php on lines 116..130

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 148.

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 4 locations. Consider refactoring.
Open

    public function getUserAlbumPrevPhoto($userId, $photoDate)
    {
        $catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory');

        $criteria = new CriteriaCompo();
Severity: Major
Found in class/PublicPhotoHandler.php and 3 other locations - About 3 hrs to fix
class/PhotoHandler.php on lines 245..259
class/PhotoHandler.php on lines 267..281
class/PublicPhotoHandler.php on lines 138..152

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 148.

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 2 locations. Consider refactoring.
Open

    public function getUserAlbumCurrentPhotoPlace($userId, $photoDate)
    {
        $catHandler = Extgallery\Helper::getInstance()->getHandler('PublicCategory');

        $criteria = new CriteriaCompo();
Severity: Major
Found in class/PublicPhotoHandler.php and 1 other location - About 2 hrs to fix
class/PhotoHandler.php on lines 289..302

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 139.

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 $db. Configured minimum length is 3.
Open

    public function __construct(XoopsDatabase $db = null)
Severity: Minor
Found in class/PublicPhotoHandler.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

There must be one blank line after the last USE statement; 4 found;
Open

use XoopsObject;
Severity: Minor
Found in class/PublicPhotoHandler.php by phpcodesniffer

Line exceeds 120 characters; contains 121 characters
Open

        if (\is_file(XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/large/large_' . $photo->getVar('photo_name'))) {
Severity: Minor
Found in class/PublicPhotoHandler.php by phpcodesniffer

Line exceeds 120 characters; contains 121 characters
Open

        if (\is_file(XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/thumb/thumb_' . $photo->getVar('photo_name'))) {
Severity: Minor
Found in class/PublicPhotoHandler.php by phpcodesniffer

Line exceeds 120 characters; contains 126 characters
Open

            && \is_file(XOOPS_ROOT_PATH . '/uploads/extgallery/public-photo/original/' . $photo->getVar('photo_orig_name'))) {
Severity: Minor
Found in class/PublicPhotoHandler.php by phpcodesniffer

Line exceeds 120 characters; contains 159 characters
Open

        $sql = 'SELECT photo_id FROM ' . $this->db->prefix('extgallery_publicphoto') . ' ' . $criteria->renderWhere() . ' ORDER BY photo_date, photo_id DESC;';
Severity: Minor
Found in class/PublicPhotoHandler.php by phpcodesniffer

There are no issues that match your filters.

Category
Status