Function generateEntry
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring. Open
private function generateEntry($company, $tireSensor, $ideal_pressure)
{
if (!$this->hasPressureIssue($company, $tireSensor, $ideal_pressure)) {
$tireSensor = TireSensor::where('part_id', $tireSensor->part_id)
->where('created_at', '<', $tireSensor->created_at)
- 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 generateEntry
has 31 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function generateEntry($company, $tireSensor, $ideal_pressure)
{
if (!$this->hasPressureIssue($company, $tireSensor, $ideal_pressure)) {
$tireSensor = TireSensor::where('part_id', $tireSensor->part_id)
->where('created_at', '<', $tireSensor->created_at)
Avoid deeply nested control flow statements. Open
if (!empty($part->part_id)) {
PartEntry::forceCreate([
"part_id" => $part->part_id,
"entry_id" => $entry->id,
]);
Avoid using static access to class '\App\Entities\TireSensor' in method 'checkTireCondition'. Open
$tireSensor = TireSensor::find($tiresensor_id);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Facades\Lang' in method 'getAlertType'. Open
$alertType['description'] = Lang::get('mails.HighPressure');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Facades\Lang' in method 'getAlertType'. Open
$alertType['type'] = Lang::get('mails.Temperature');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Facades\Lang' in method 'getAlertType'. Open
$alertType['description'] = Lang::get('mails.LowPressure');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Entities\Entry' in method 'generateEntry'. Open
$entry = Entry::forceCreate([
"company_id" => $company->id,
"entry_type_id" => $entry_type->id,
"datetime_ini" => date("Y-m-d H:i:s"),
"cost" => 1,
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Facades\Lang' in method 'getAlertType'. Open
$alertType['type'] = Lang::get('mails.Pressure');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Entities\Part' in method 'generateEntry'. Open
$part = Part::find($tireSensor->part_id);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Entities\PartEntry' in method 'generateEntry'. Open
PartEntry::forceCreate([
"part_id" => $part->part_id,
"entry_id" => $entry->id,
]);
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Facades\Lang' in method 'getAlertType'. Open
$alertType['type'] = Lang::get('mails.Pressure');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\Illuminate\Support\Facades\Lang' in method 'getAlertType'. Open
$alertType['description'] = Lang::get('mails.HighTemperature');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
The parameter $ideal_pressure is not named in camelCase. Open
private function generateEntry($company, $tireSensor, $ideal_pressure)
{
if (!$this->hasPressureIssue($company, $tireSensor, $ideal_pressure)) {
$tireSensor = TireSensor::where('part_id', $tireSensor->part_id)
->where('created_at', '<', $tireSensor->created_at)
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $company_id is not named in camelCase. Open
public function checkTireCondition($company_id, $tiresensor_id, $vehicle_id)
{
$tireSensor = TireSensor::find($tiresensor_id);
$company = Company::where('id', $company_id)->first();
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $tiresensor_id is not named in camelCase. Open
public function checkTireCondition($company_id, $tiresensor_id, $vehicle_id)
{
$tireSensor = TireSensor::find($tiresensor_id);
$company = Company::where('id', $company_id)->first();
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $ideal_pressure is not named in camelCase. Open
public function getAlertType($company, $tireSensor, $ideal_pressure)
{
$alertType = [];
if ((((1 - $company->delta_pressure) * $ideal_pressure) - 1.5) > $tireSensor->pressure) {
$alertType['type'] = Lang::get('mails.Pressure');
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $ideal_pressure is not named in camelCase. Open
private function hasPressureIssue($company, $tireSensor, $ideal_pressure)
{
$alertType = $this->getAlertType($company, $tireSensor, $ideal_pressure);
if (empty($alertType['id']) ||
($alertType['id'] != 'High Pressure' && $alertType['id'] != 'Low Pressure')) {
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The parameter $vehicle_id is not named in camelCase. Open
public function checkTireCondition($company_id, $tiresensor_id, $vehicle_id)
{
$tireSensor = TireSensor::find($tiresensor_id);
$company = Company::where('id', $company_id)->first();
- Read upRead up
- Exclude checks
CamelCaseParameterName
Since: 0.2
It is considered best practice to use the camelCase notation to name parameters.
Example
class ClassName {
public function doSomething($user_name) {
}
}
Source
The variable $ideal_pressure is not named in camelCase. Open
private function generateEntry($company, $tireSensor, $ideal_pressure)
{
if (!$this->hasPressureIssue($company, $tireSensor, $ideal_pressure)) {
$tireSensor = TireSensor::where('part_id', $tireSensor->part_id)
->where('created_at', '<', $tireSensor->created_at)
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $company_id is not named in camelCase. Open
public function checkTireCondition($company_id, $tiresensor_id, $vehicle_id)
{
$tireSensor = TireSensor::find($tiresensor_id);
$company = Company::where('id', $company_id)->first();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $ideal_pressure is not named in camelCase. Open
public function checkTireCondition($company_id, $tiresensor_id, $vehicle_id)
{
$tireSensor = TireSensor::find($tiresensor_id);
$company = Company::where('id', $company_id)->first();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $ideal_pressure is not named in camelCase. Open
public function checkTireCondition($company_id, $tiresensor_id, $vehicle_id)
{
$tireSensor = TireSensor::find($tiresensor_id);
$company = Company::where('id', $company_id)->first();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $ideal_pressure is not named in camelCase. Open
public function checkTireCondition($company_id, $tiresensor_id, $vehicle_id)
{
$tireSensor = TireSensor::find($tiresensor_id);
$company = Company::where('id', $company_id)->first();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $ideal_pressure is not named in camelCase. Open
public function checkTireCondition($company_id, $tiresensor_id, $vehicle_id)
{
$tireSensor = TireSensor::find($tiresensor_id);
$company = Company::where('id', $company_id)->first();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $ideal_pressure is not named in camelCase. Open
public function getAlertType($company, $tireSensor, $ideal_pressure)
{
$alertType = [];
if ((((1 - $company->delta_pressure) * $ideal_pressure) - 1.5) > $tireSensor->pressure) {
$alertType['type'] = Lang::get('mails.Pressure');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $entry_type is not named in camelCase. Open
private function generateEntry($company, $tireSensor, $ideal_pressure)
{
if (!$this->hasPressureIssue($company, $tireSensor, $ideal_pressure)) {
$tireSensor = TireSensor::where('part_id', $tireSensor->part_id)
->where('created_at', '<', $tireSensor->created_at)
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $tiresensor_id is not named in camelCase. Open
public function checkTireCondition($company_id, $tiresensor_id, $vehicle_id)
{
$tireSensor = TireSensor::find($tiresensor_id);
$company = Company::where('id', $company_id)->first();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $vehicle_id is not named in camelCase. Open
public function checkTireCondition($company_id, $tiresensor_id, $vehicle_id)
{
$tireSensor = TireSensor::find($tiresensor_id);
$company = Company::where('id', $company_id)->first();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $ideal_pressure is not named in camelCase. Open
private function hasPressureIssue($company, $tireSensor, $ideal_pressure)
{
$alertType = $this->getAlertType($company, $tireSensor, $ideal_pressure);
if (empty($alertType['id']) ||
($alertType['id'] != 'High Pressure' && $alertType['id'] != 'Low Pressure')) {
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $ideal_pressure is not named in camelCase. Open
public function getAlertType($company, $tireSensor, $ideal_pressure)
{
$alertType = [];
if ((((1 - $company->delta_pressure) * $ideal_pressure) - 1.5) > $tireSensor->pressure) {
$alertType['type'] = Lang::get('mails.Pressure');
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $ideal_pressure is not named in camelCase. Open
public function checkTireCondition($company_id, $tiresensor_id, $vehicle_id)
{
$tireSensor = TireSensor::find($tiresensor_id);
$company = Company::where('id', $company_id)->first();
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $entry_type is not named in camelCase. Open
private function generateEntry($company, $tireSensor, $ideal_pressure)
{
if (!$this->hasPressureIssue($company, $tireSensor, $ideal_pressure)) {
$tireSensor = TireSensor::where('part_id', $tireSensor->part_id)
->where('created_at', '<', $tireSensor->created_at)
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $entry_type is not named in camelCase. Open
private function generateEntry($company, $tireSensor, $ideal_pressure)
{
if (!$this->hasPressureIssue($company, $tireSensor, $ideal_pressure)) {
$tireSensor = TireSensor::where('part_id', $tireSensor->part_id)
->where('created_at', '<', $tireSensor->created_at)
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $ideal_pressure is not named in camelCase. Open
private function generateEntry($company, $tireSensor, $ideal_pressure)
{
if (!$this->hasPressureIssue($company, $tireSensor, $ideal_pressure)) {
$tireSensor = TireSensor::where('part_id', $tireSensor->part_id)
->where('created_at', '<', $tireSensor->created_at)
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}