| Total Complexity | 8 |
| Total Lines | 48 |
| Duplicated Lines | 0 % |
| Coverage | 0% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | class TradesCounter |
||
| 14 | { |
||
| 15 | protected const VOLUME = 'volume'; |
||
| 16 | |||
| 17 | /** @var string */ |
||
| 18 | private $pair; |
||
| 19 | |||
| 20 | /**@var EventCounterDeprecated[] */ |
||
| 21 | private $counters = []; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * TradesCounter constructor. |
||
| 25 | * @param string $pair |
||
| 26 | */ |
||
| 27 | public function __construct(string $pair) |
||
| 28 | { |
||
| 29 | foreach (PERIODS as $length => $groupBy) { |
||
| 30 | $this->counters[$length] = new EventCounterDeprecated($length, $groupBy); |
||
| 31 | } |
||
| 32 | $this->pair = $pair; |
||
| 33 | } |
||
| 34 | |||
| 35 | public function countTrade(Trade $trade): Trade |
||
| 36 | { |
||
| 37 | if ($this->pair !== $trade->pair) { |
||
| 38 | throw new \RuntimeException('DataInconsistency'); // todo update message |
||
| 39 | } |
||
| 40 | foreach (PERIODS as $length => $groupBy) { |
||
| 41 | $this->counters[$length]->addEvent($trade->timestamp); |
||
| 42 | } |
||
| 43 | // $this->counters[static::VOLUME]->addTrade($trade); |
||
| 44 | |||
| 45 | return $trade; |
||
| 46 | } |
||
| 47 | |||
| 48 | public function trades(int $timePeriod): int |
||
| 51 | } |
||
| 52 | |||
| 53 | public function volume(int $timePeriod): float |
||
| 56 | } |
||
| 57 | |||
| 58 | public function avgPrice(int $timePeriod): float |
||
| 63 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.