for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* User: alec
* Date: 05.11.18
* Time: 17:05
*/
declare(strict_types=1);
namespace AlecRabbit;
use AlecRabbit\Event\EventCounterDeprecated;
use AlecRabbit\Structures\Trade;
class TradesAggregator
{
private const PERIODS = [
P_01MIN => P_01MIN,
P_03MIN => P_01MIN,
P_05MIN => P_01MIN,
P_15MIN => P_05MIN,
P_30MIN => P_05MIN,
P_45MIN => P_05MIN,
P_01HOUR => P_15MIN,
P_02HOUR => P_15MIN,
P_03HOUR => P_15MIN,
P_04HOUR => P_15MIN,
P_01DAY => P_01HOUR,
];
/** @var string */
private $pair;
/**@var EventCounterDeprecated[] */
private $counters = [];
* TradesCounter constructor.
* @param string $pair
public function __construct(string $pair)
foreach (static::PERIODS as $length => $groupBy) {
$this->counters[$length] = new EventCounterDeprecated($length, $groupBy);
}
$this->pair = $pair;
public function countTrade(Trade $trade): Trade
if ($this->pair !== $trade->pair) {
throw new \RuntimeException('DataInconsistency'); // todo update message
$this->counters[$length]->addEvent($trade->timestamp);
return $trade;
public function trades(int $timePeriod): int
return $this->counters[$timePeriod]->getCalculatedEvents();
public function volume(int $timePeriod): float
$timePeriod
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function volume(/** @scrutinizer ignore-unused */ int $timePeriod): float
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
return 0.1;
public function avgPrice(int $timePeriod): float
public function avgPrice(/** @scrutinizer ignore-unused */ int $timePeriod): float
return 8500;
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.