/** * @param string $symbol * @param int $optionPointPrice * @throws WrongSymbol */ public function __construct(string $symbol, int $optionPointPrice) { if (!SymbolCode::isValid($symbol)) { throw new WrongSymbol($symbol); } $this->symbol = $symbol; $this->optionPointPrice = $optionPointPrice; }
/** * @param int $symbolOffset * @param int $symbolLimit * @return array * @throws ConsoleError */ private function getApplicableSymbols(int $symbolOffset, int $symbolLimit) { $allSymbols = SymbolCode::values(); $symbolsCount = count($allSymbols); if ($symbolOffset > $symbolsCount) { throw new ConsoleError(sprintf('Wrong offset. There are only %d symbol codes.', $symbolsCount)); } return array_slice($allSymbols, $symbolOffset, $symbolLimit); }
public function __construct($symbol) { parent::__construct(sprintf('Symbol %s is invalid. Valid symbols are: %s', $symbol, implode(', ', SymbolCode::values()))); }