Showing 93 of 93 total issues
Similar blocks of code found in 2 locations. Consider refactoring. Open
if (!empty($find['movie_results']) && \count($find['movie_results']) === 1) {
$item = $find['movie_results'][0];
$oTitle->isAdult = isset($item['adult']) ? (bool)$item['adult'] : false;
$oTitle->title = $item['title'];
- Read upRead up
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 245.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
} elseif (!empty($find['tv_results']) && \count($find['tv_results']) === 1) {
$item = $find['tv_results'][0];
$oTitle->isAdult = isset($item['adult']) ? (bool)$item['adult'] : false;
$oTitle->title = $item['name'];
- Read upRead up
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 245.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$oResp = $this->oClient->getAdapter()->useCache(
function () use ($imdbId) {
$oCurl = new Curl();
$oCurl->setUserAgent(UserAgent::random());
$oCurl->setHeader('Accept-Language', $this->oClient->getLang());
- Read upRead up
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 215.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Similar blocks of code found in 2 locations. Consider refactoring. Open
$oResp = $this->oClient->getAdapter()->useCache(
function () use ($title) {
$oCurl = new Curl();
$oCurl->setUserAgent(UserAgent::random());
$oCurl->setHeader('Accept-Language', $this->oClient->getLang());
- Read upRead up
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 215.
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
- Extract Method
- Extract Class
- Form Template Method
- Introduce Null Object
- Pull Up Method
- Pull Up Field
- Substitute Algorithm
Further Reading
- Don't Repeat Yourself on the C2 Wiki
- Duplicated Code on SourceMaking
- Refactoring: Improving the Design of Existing Code by Martin Fowler. Duplicated Code, p76
Function searchByTitleNative
has a Cognitive Complexity of 41 (exceeds 5 allowed). Consider refactoring. Open
public function searchByTitleNative(string $title): array
{
try {
/**
* @var Title[] $answer
- 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 searchByTitleNative
has 102 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function searchByTitleNative(string $title): array
{
try {
/**
* @var Title[] $answer
Method getTvShow
has 68 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getTvShow(int $id): TvShowTitle
{
try {
$tData = $this->oTmdbClient
->getTvApi()
File Tmdb.php
has 279 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* xMDB-API
*
* Copyright © 2017 pudelek.org.pl
Method getByImdbId
has 60 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getByImdbId(string $imdbId = null)
{
try {
$this->oLog->info(sprintf('Searching: %s', $imdbId));
if ($imdbId === null || $imdbId === '') {
Method getMovie
has 57 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getMovie(int $id): Model\Tmdb\Movie\Title
{
try {
$tData = $this->oTmdbClient->getMoviesApi()->getMovie($id, [
'language' => $this->oClient->getLang(),
File Imdb.php
has 255 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
/**
* xMDB-API
*
* Copyright © 2017 pudelek.org.pl
Method getRating
has 40 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getRating(string $imdbId): Rating
{
try {
$searchUrl = 'http://p.media-imdb.com/static-content/documents/v1/title/'
. $imdbId
The class Title has 20 fields. Consider redesigning Title to keep the number of fields under 15. Open
class Title
{
/**
* @var string
*/
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
The class Title has 26 fields. Consider redesigning Title to keep the number of fields under 15. Open
class Title
{
/**
* @var integer
*/
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
The class Title has 28 fields. Consider redesigning Title to keep the number of fields under 15. Open
class Title
{
/**
* @var integer
*/
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
The class Info has 18 fields. Consider redesigning Info to keep the number of fields under 15. Open
class Info
{
/**
* @var string
*/
- Read upRead up
- Exclude checks
TooManyFields
Since: 0.1
Classes that have too many fields could be redesigned to have fewer fields, possibly through some nested object grouping of some of the information. For example, a class with city/state/zip fields could instead have one Address field.
Example
class Person {
protected $one;
private $two;
private $three;
[... many more fields ...]
}
Source https://phpmd.org/rules/codesize.html#toomanyfields
Method searchByTitle
has 37 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function searchByTitle(string $title)
{
try {
/**
* @var Title[] $answer
Method create
has 34 lines of code (exceeds 25 allowed). Consider refactoring. Open
public static function create(\stdClass $oData)
{
$oTitle = new static();
$oTitle->title = $oData->Title;
$oTitle->titleOrg = $oData->Title;
Method getByImdbId
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getByImdbId(string $imdbId, Ratio $oRatio = null)
{
try {
$oResp = $this->oClient->getAdapter()->useCache(
function () use ($imdbId) {
Method searchByTitleApi
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function searchByTitleApi(string $title): array
{
try {
$answer = [];
$tList = $this->getApiTitleSearch()->search($title, [