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;
- Read upRead up
- Exclude checks
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)
;
- Read upRead up
- Exclude checks
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);
}
- Read upRead up
- Exclude checks
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)
;
- Read upRead up
- Exclude checks
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);
}
- Read upRead up
- Exclude checks
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());
}
- Read upRead up
- Exclude checks
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);
}
- Read upRead up
- Exclude checks
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();
}
- Read upRead up
- Exclude checks
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,
- Read upRead up
- Exclude checks
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,
- Read upRead up
- Exclude checks
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
- Exclude checks
Missing function doc comment Open
public function setVisibilityPublished(
- Exclude checks
Missing function doc comment Open
public function updateNodeForResource(ResourceInterface $resource): ResourceNode
- Exclude checks
Missing function doc comment Open
public function getResourceByCreatorFromTitle(
- Exclude checks
Missing function doc comment Open
public function findCourseResourceBySlug(
- Exclude checks
Missing function doc comment Open
public function addFile(ResourceInterface $resource, UploadedFile $file, string $description = '', bool $flush = false): ?ResourceFile
- Exclude checks
Add a single space around assignment operators Open
declare(strict_types=1);
- Exclude checks
Missing function doc comment Open
public function getResourcesByLinkedUser(User $user, ?ResourceNode $parentNode = null): QueryBuilder
- Exclude checks
Declare public methods first,then protected ones and finally private ones Open
public function findByTitleAndParentResourceNode(string $title, int $parentResourceNodeId): ?AbstractResource
- Exclude checks
Missing function doc comment Open
public function create(AbstractResource $resource): void
- Exclude checks
Missing function doc comment Open
public function update(AbstractResource|User $resource, bool $andFlush = true): void
- Exclude checks
Missing function doc comment Open
public function getResourceType(): ResourceType
- Exclude checks
Missing function doc comment Open
public function updateResourceFileContent(AbstractResource $resource, string $content): bool
- Exclude checks
Missing function doc comment Open
public function addResourceNode(
- Exclude checks
Missing function doc comment Open
public function addFileFromString(ResourceInterface $resource, string $fileName, string $mimeType, string $content, bool $flush = true): ?ResourceFile
- Exclude checks
Missing function doc comment Open
public function addCourseQueryBuilder(Course $course, QueryBuilder $qb): QueryBuilder
- Exclude checks
Missing function doc comment Open
public function getResourceTypeName(): string
- Exclude checks
Missing function doc comment Open
public function getResources(?ResourceNode $parentNode = null): QueryBuilder
- Exclude checks
Missing function doc comment Open
public function getResourcesByCourseIgnoreVisibility(Course $course, ?Session $session = null, ?CGroup $group = null, ?ResourceNode $parentNode = null): QueryBuilder
- Exclude checks
Missing function doc comment Open
public function getResourceFromResourceNode(int $resourceNodeId): ?ResourceInterface
- Exclude checks
Missing function doc comment Open
public function delete(ResourceInterface $resource): void
- Exclude checks
Missing function doc comment Open
public function getResourceFileUrl(AbstractResource $resource, array $extraParams = [], ?int $referenceType = null): string
- Exclude checks
Missing function doc comment Open
public function setResourceName(AbstractResource $resource, $title): void
- Exclude checks
Missing function doc comment Open
public function isGranted(string $subject, AbstractResource $resource): bool
- Exclude checks
Missing function doc comment Open
public function getResourceNodeFileContent(ResourceNode $resourceNode): string
- Exclude checks
Missing function doc comment Open
public function toggleVisibilityPublishedDraft(AbstractResource $resource): void
- Exclude checks
Missing function doc comment Open
public function addTitleDecoration(AbstractResource $resource, Course $course, ?Session $session = null): string
- Exclude checks
Abstract class name is not prefixed with "Abstract" Open
abstract class ResourceRepository extends ServiceEntityRepository
- Exclude checks
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
- Exclude checks
Missing function doc comment Open
public function getResourcesByCreator(User $user, ?ResourceNode $parentNode = null): QueryBuilder
- Exclude checks
Missing function doc comment Open
public function getTotalSpaceByCourse(Course $course, ?CGroup $group = null, ?Session $session = null): int
- Exclude checks
Missing function doc comment Open
public function getResourceFileDownloadUrl(AbstractResource $resource, array $extraParams = [], ?int $referenceType = null): string
- Exclude checks
Missing function doc comment Open
public function getResourceByResourceNode(ResourceNode $resourceNode): ?ResourceInterface
- Exclude checks
Missing function doc comment Open
public function findCourseResourceByTitle(
- Exclude checks
Missing function doc comment Open
public function setVisibilityDraft(
- Exclude checks
Missing function doc comment Open
public function addCourseSessionGroupQueryBuilder(Course $course, ?Session $session = null, ?CGroup $group = null, ?QueryBuilder $qb = null): QueryBuilder
- Exclude checks
Missing function doc comment Open
public function getCount(QueryBuilder $qb): int
- Exclude checks
Missing function doc comment Open
public function addVisibilityQueryBuilder(?QueryBuilder $qb = null, bool $checkStudentView = false, bool $displayOnlyPublished = true): QueryBuilder
- Exclude checks
Missing function doc comment Open
public function findByTitleAndParentResourceNode(string $title, int $parentResourceNodeId): ?AbstractResource
- Exclude checks
Missing function doc comment Open
public function getResourcesByCourseLinkedToUser(
- Exclude checks
Missing function doc comment Open
public function getResourceFileContent(AbstractResource $resource): string
- Exclude checks
Missing function doc comment Open
public function setVisibilityPending(
- Exclude checks