Method onQueryExecutedEvent
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function onQueryExecutedEvent(QueryExecuted $query): void
{
if ('auto' === $this->config->get('elastic-apm-laravel.spans.querylog.enabled')) {
if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
return;
Avoid using static access to class '\Jasny\DB\MySQL\QuerySplitter' in method 'getQueryName'. Open
$tables = QuerySplitter::splitTables($sql);
- 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 '\Jasny\DB\MySQL\QuerySplitter' in method 'getQueryName'. Open
$query_type = QuerySplitter::getQueryType($sql);
- 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
Merge this if statement with the enclosing one. Open
if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
- Read upRead up
- Exclude checks
Merging collapsible if
statements increases the code's readability.
Noncompliant Code Example
if (condition1) { if (condition2) { ... } }
Compliant Solution
if (condition1 && condition2) { ... }
The variable $start_time is not named in camelCase. Open
private function onQueryExecutedEvent(QueryExecuted $query): void
{
if ('auto' === $this->config->get('elastic-apm-laravel.spans.querylog.enabled')) {
if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
return;
- 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 $end_time is not named in camelCase. Open
private function onQueryExecutedEvent(QueryExecuted $query): void
{
if ('auto' === $this->config->get('elastic-apm-laravel.spans.querylog.enabled')) {
if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
return;
- 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 $end_time is not named in camelCase. Open
private function onQueryExecutedEvent(QueryExecuted $query): void
{
if ('auto' === $this->config->get('elastic-apm-laravel.spans.querylog.enabled')) {
if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
return;
- 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 $query_type is not named in camelCase. Open
private function getQueryName(string $sql): string
{
$fallback = 'Eloquent Query';
try {
- 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 $query_type is not named in camelCase. Open
private function getQueryName(string $sql): string
{
$fallback = 'Eloquent Query';
try {
- 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 $query_type is not named in camelCase. Open
private function getQueryName(string $sql): string
{
$fallback = 'Eloquent Query';
try {
- 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 $start_time is not named in camelCase. Open
private function onQueryExecutedEvent(QueryExecuted $query): void
{
if ('auto' === $this->config->get('elastic-apm-laravel.spans.querylog.enabled')) {
if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
return;
- 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 $start_time is not named in camelCase. Open
private function onQueryExecutedEvent(QueryExecuted $query): void
{
if ('auto' === $this->config->get('elastic-apm-laravel.spans.querylog.enabled')) {
if ($query->time < $this->config->get('elastic-apm-laravel.spans.querylog.threshold')) {
return;
- 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();
}
}