Showing 16 of 16 total issues
File TimeSeries.php
has 332 lines of code (exceeds 250 allowed). Consider refactoring. Open
<?php
declare(strict_types=1);
namespace Palicao\PhpRedisTimeSeries;
TimeSeries
has 21 functions (exceeds 20 allowed). Consider refactoring. Open
final class TimeSeries
{
public const DUPLICATE_POLICY_BLOCK = 'BLOCK';
public const DUPLICATE_POLICY_FIRST = 'FIRST';
public const DUPLICATE_POLICY_LAST = 'LAST';
Method connectIfNeeded
has 32 lines of code (exceeds 25 allowed). Consider refactoring. Open
private function connectIfNeeded(): void
{
if ($this->redis->isConnected()) {
return;
}
Method toRedisParams
has 28 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function toRedisParams(): array
{
$params = [];
foreach ($this->filters as $filter) {
switch ($filter[1]) {
Method __construct
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
DateTimeInterface $lastTimestamp,
int $retentionTime = 0,
int $chunkCount = 0,
int $maxSamplesPerChunk = 0,
array $labels = [],
Method multiRangeRaw
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
Filter $filter,
?DateTimeInterface $from = null,
?DateTimeInterface $to = null,
?int $count = null,
?AggregationRule $rule = null,
Method fromRedis
has 7 arguments (exceeds 4 allowed). Consider refactoring. Open
int $lastTimestamp,
int $retentionTime = 0,
int $chunkCount = 0,
int $maxSamplesPerChunk = 0,
array $labels = [],
Method create
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
string $key,
?int $retentionMs = null,
array $labels = [],
bool $uncompressed = false,
?int $chunkSize = null,
Method add
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Sample $sample,
?int $retentionMs = null,
array $labels = [],
bool $uncompressed = false,
?int $chunkSize = null,
Method multiRangeWithLabels
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Filter $filter,
?DateTimeInterface $from = null,
?DateTimeInterface $to = null,
?int $count = null,
?AggregationRule $rule = null,
Function toRedisParams
has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring. Open
public function toRedisParams(): array
{
$params = [];
foreach ($this->filters as $filter) {
switch ($filter[1]) {
- 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 multiRange
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
Filter $filter,
?DateTimeInterface $from = null,
?DateTimeInterface $to = null,
?int $count = null,
?AggregationRule $rule = null,
Method range
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
string $key,
?DateTimeInterface $from = null,
?DateTimeInterface $to = null,
?int $count = null,
?AggregationRule $rule = null,
Method incrementOrDecrementBy
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
string $op,
Sample $sample,
?int $resetMs = null,
?int $retentionMs = null,
array $labels = []
Function authenticate
has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring. Open
private function authenticate(?string $username, ?string $password): void
{
try {
if ($password) {
if ($username) {
- 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 add
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function add(string $label, int $operation, $value = null): self
{
if (!in_array($operation, self::OPERATIONS, true)) {
throw new InvalidFilterOperationException('Operation is not valid');
}
- 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"