Showing 10 of 113 total issues
File ExportImportService.php
has 353 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace EscolaLms\CoursesImportExport\Services;
use EscolaLms\Categories\Models\Category;
ExportImportService
has 22 functions (exceeds 20 allowed). Consider refactoring. Open
class ExportImportService implements ExportImportServiceContract
{
private CourseRepositoryContract $courseRepository;
private LessonRepositoryContract $lessonRepository;
private TopicRepositoryContract $topicRepository;
Function fixAssetPaths
has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring. Open
public function fixAssetPaths(): array
{
$results = [];
$results = $results + $this->fixPath('image_path');
$results = $results + $this->fixPath('video_path');
- Read upRead up
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 createTopicFromImport
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function createTopicFromImport(array $topicData, string $dirFullPath, int $courseId): ?Model
{
if (!isset($topicData['topicable_type'])) {
return null;
}
Function createTopicFromImport
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
private function createTopicFromImport(array $topicData, string $dirFullPath, int $courseId): ?Model
{
if (!isset($topicData['topicable_type'])) {
return null;
}
- Read upRead up
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 __construct
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
CourseRepositoryContract $courseRepository,
LessonRepositoryContract $lessonRepository,
TopicRepositoryContract $topicRepository,
TopicResourceRepositoryContract $topicResourceRepository,
CategoriesRepositoryContract $categoriesRepository
Function createLessonFromImport
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function createLessonFromImport(array $lessonData, string $dirFullPath): Model
{
$lessonValidator = Validator::make($lessonData, Lesson::$rules);
/** @var Lesson $lesson */
$lesson = $this->lessonRepository->create($lessonValidator->validate());
- Read upRead up
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 createCourseFromImport
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function createCourseFromImport(array $courseData, string $dirFullPath): Model
{
unset($courseData['author_id']);
$courseData = $this->addFilesToArrayBasedOnPath($courseData, $dirFullPath);
- Read upRead up
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
Avoid too many return
statements within this method. Open
return false;
Function export
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function export(User $user, Course $course)
{
if ($user->hasRole('admin')) {
return true;
}
- Read upRead up
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"