File PartRepositoryEloquent.php
has 260 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
namespace App\Repositories;
use Prettus\Repository\Eloquent\BaseRepository;
Method results
has 39 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function results($filters = [])
{
$filters = $this->formatFilters($filters);
$parts = $this->scopeQuery(function ($query) use ($filters) {
Function getTiresPositions
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring. Open
public static function getTiresPositions($tires, $idVehicle)
{
$tiresPositions = [];
$tiresPositions['max_position'] = 0;
if (!empty($tires)) {
- 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 tiresPositionSwap
has 29 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function tiresPositionSwap($data)
{
$parts = [];
$parts[] = $this->getPartIdByTirePosition($data['position1'], $data['vehicle_id']);
$part_id2 = $this->getPartIdByTirePosition($data['position2'], $data['vehicle_id']);
Function setPositions
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function setPositions($parts)
{
if (!empty($parts)) {
foreach ($parts as $index => $part) {
if ($part->part_type != "tire" && $part->part_type != "sensor") {
- 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 setInputs
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function setInputs($inputs)
{
$inputs['entity_key'] = "part";
if (empty($inputs['vehicle_id'])) {
unset($inputs['vehicle_id']);
- 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"