File H5PRepository.php
has 678 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace EscolaLms\HeadlessH5P\Repositories;
use EscolaLms\HeadlessH5P\Exceptions\H5PException;
H5PRepository
has 65 functions (exceeds 20 allowed). Consider refactoring. Confirmed
class H5PRepository implements H5PFrameworkInterface
{
private H5PLibraryLanguageRepositoryContract $h5PLibraryLanguageRepository;
Function fixContentParamsMetadataLibraryTitle
has a Cognitive Complexity of 27 (exceeds 5 allowed). Consider refactoring. Open
private function fixContentParamsMetadataLibraryTitle($content)
{
$defaultTitle = isset($this->mainData['title']) ? $this->mainData['title'] : 'New Content (from file)';
if (is_array($content['library'])) {
- 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 fixContentParamsMetadataLibraryTitle
has 55 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function fixContentParamsMetadataLibraryTitle($content)
{
$defaultTitle = isset($this->mainData['title']) ? $this->mainData['title'] : 'New Content (from file)';
if (is_array($content['library'])) {
Method saveLibraryUsage
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function saveLibraryUsage($contentId, $librariesInUse)
{
$contentLibraries = array_map(function ($value) use ($contentId) {
$contentLibrary = H5PContentLibrary::query()
->where([
Method replaceContentTypeCache
has 30 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function replaceContentTypeCache($contentTypeCache)
{
$data = [];
foreach ($contentTypeCache->contentTypes as $ct) {
$data[] = [
Method saveLibraryData
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Confirmed
public function saveLibraryData(&$libraryData, $new = true)
{
$library = [
'name' => $libraryData['machineName'],
'title' => $libraryData['title'],
Method fetchExternalData
has 27 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function fetchExternalData($url, $data = null, $blocking = true, $stream = null, $fullData = false, $headers = [], $files = [], $method = 'POST')
{
@set_time_limit(0);
$options = [
'timeout' => !empty($blocking) ? 30 : 0.01,
Method fetchExternalData
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
public function fetchExternalData($url, $data = null, $blocking = true, $stream = null, $fullData = false, $headers = [], $files = [], $method = 'POST')
Function fetchExternalData
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function fetchExternalData($url, $data = null, $blocking = true, $stream = null, $fullData = false, $headers = [], $files = [], $method = 'POST')
{
@set_time_limit(0);
$options = [
'timeout' => !empty($blocking) ? 30 : 0.01,
- 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 true;
Avoid too many return
statements within this method. Open
return true;
Avoid too many return
statements within this method. Open
return false;
Function additionalTranslations
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
private function additionalTranslations(array $libraryLanguages, H5PLibrary $library): array
{
$additionalLanguageCodes = ['pl'];
foreach ($additionalLanguageCodes as $languageCode) {
if (!isset($libraryLanguages[$languageCode])) {
- 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"