chamilo/chamilo-lms

View on GitHub
src/CoreBundle/Repository/ResourceRepository.php

Summary

Maintainability
A
0 mins
Test Coverage

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

abstract class ResourceRepository extends ServiceEntityRepository
{
    use NonResourceRepository;
    use RepositoryQueryBuilderTrait;

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

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

        } else {
            $qb
                ->andWhere('l.session = :session')
                ->setParameter('session', $session)
            ;

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

        } else {
            $qb->andWhere('links.group = :group');
            $qb->setParameter('group', $group);
        }

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

        } else {
            $qb
                ->andWhere('l.group = :group')
                ->setParameter('group', $group)
            ;

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

        } else {
            $originalExtension = pathinfo($resourceName, PATHINFO_EXTENSION);
            $originalBasename = basename($resourceName, $originalExtension);
            $slug = \sprintf('%s.%s', $this->slugify->slugify($originalBasename), $originalExtension);
        }

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

            } else {
                $link->setResourceRights(new ArrayCollection());
            }

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

        } else {
            // Load only session resources.
            $qb->andWhere('links.session = :session');
            $qb->setParameter('session', $session);
        }

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

        } else {
            $links = $resourceNode->getResourceLinks();
        }

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

Avoid unused parameters such as '$group'.
Open

        ?CGroup $group = null,

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 '$user'.
Open

        ?User $user = null,

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

Missing function doc comment
Open

    public function addFileFromFileRequest(ResourceInterface $resource, string $fileKey, bool $flush = true): ?ResourceFile

Missing function doc comment
Open

    public function setVisibilityPublished(

Missing function doc comment
Open

    public function updateNodeForResource(ResourceInterface $resource): ResourceNode

Missing function doc comment
Open

    public function getResourceByCreatorFromTitle(

Missing function doc comment
Open

    public function findCourseResourceBySlug(

Missing function doc comment
Open

    public function addFile(ResourceInterface $resource, UploadedFile $file, string $description = '', bool $flush = false): ?ResourceFile

Add a single space around assignment operators
Open

declare(strict_types=1);

Missing function doc comment
Open

    public function getResourcesByLinkedUser(User $user, ?ResourceNode $parentNode = null): QueryBuilder

Declare public methods first,then protected ones and finally private ones
Open

    public function findByTitleAndParentResourceNode(string $title, int $parentResourceNodeId): ?AbstractResource

Missing function doc comment
Open

    public function create(AbstractResource $resource): void

Missing function doc comment
Open

    public function update(AbstractResource|User $resource, bool $andFlush = true): void

Missing function doc comment
Open

    public function getResourceType(): ResourceType

Missing function doc comment
Open

    public function updateResourceFileContent(AbstractResource $resource, string $content): bool

Missing function doc comment
Open

    public function addResourceNode(

Missing function doc comment
Open

    public function addFileFromString(ResourceInterface $resource, string $fileName, string $mimeType, string $content, bool $flush = true): ?ResourceFile

Missing function doc comment
Open

    public function addCourseQueryBuilder(Course $course, QueryBuilder $qb): QueryBuilder

Missing function doc comment
Open

    public function getResourceTypeName(): string

Missing function doc comment
Open

    public function getResources(?ResourceNode $parentNode = null): QueryBuilder

Missing function doc comment
Open

    public function getResourcesByCourseIgnoreVisibility(Course $course, ?Session $session = null, ?CGroup $group = null, ?ResourceNode $parentNode = null): QueryBuilder

Missing function doc comment
Open

    public function getResourceFromResourceNode(int $resourceNodeId): ?ResourceInterface

Missing function doc comment
Open

    public function delete(ResourceInterface $resource): void

Missing function doc comment
Open

    public function getResourceFileUrl(AbstractResource $resource, array $extraParams = [], ?int $referenceType = null): string

Missing function doc comment
Open

    public function setResourceName(AbstractResource $resource, $title): void

Missing function doc comment
Open

    public function isGranted(string $subject, AbstractResource $resource): bool

Missing function doc comment
Open

    public function getResourceNodeFileContent(ResourceNode $resourceNode): string

Missing function doc comment
Open

    public function toggleVisibilityPublishedDraft(AbstractResource $resource): void

Missing function doc comment
Open

    public function addTitleDecoration(AbstractResource $resource, Course $course, ?Session $session = null): string

Abstract class name is not prefixed with "Abstract"
Open

abstract class ResourceRepository extends ServiceEntityRepository

Missing function doc comment
Open

    public function getResourcesByCourse(Course $course, ?Session $session = null, ?CGroup $group = null, ?ResourceNode $parentNode = null, bool $displayOnlyPublished = true, bool $displayOrder = false): QueryBuilder

Missing function doc comment
Open

    public function getResourcesByCreator(User $user, ?ResourceNode $parentNode = null): QueryBuilder

Missing function doc comment
Open

    public function getTotalSpaceByCourse(Course $course, ?CGroup $group = null, ?Session $session = null): int

Missing function doc comment
Open

    public function getResourceFileDownloadUrl(AbstractResource $resource, array $extraParams = [], ?int $referenceType = null): string

Missing function doc comment
Open

    public function getResourceByResourceNode(ResourceNode $resourceNode): ?ResourceInterface

Missing function doc comment
Open

    public function findCourseResourceByTitle(

Missing function doc comment
Open

    public function setVisibilityDraft(

Missing function doc comment
Open

    public function addCourseSessionGroupQueryBuilder(Course $course, ?Session $session = null, ?CGroup $group = null, ?QueryBuilder $qb = null): QueryBuilder

Missing function doc comment
Open

    public function getCount(QueryBuilder $qb): int

Missing function doc comment
Open

    public function addVisibilityQueryBuilder(?QueryBuilder $qb = null, bool $checkStudentView = false, bool $displayOnlyPublished = true): QueryBuilder

Missing function doc comment
Open

    public function findByTitleAndParentResourceNode(string $title, int $parentResourceNodeId): ?AbstractResource

Missing function doc comment
Open

    public function getResourcesByCourseLinkedToUser(

Missing function doc comment
Open

    public function getResourceFileContent(AbstractResource $resource): string

Missing function doc comment
Open

    public function setVisibilityPending(

There are no issues that match your filters.

Category
Status