/** * Check a module argument format * * @param string $paramValue * * @throws \InvalidArgumentException * @throws \RuntimeException */ protected function checkModuleArgument($paramValue) { if (!preg_match('#^([a-z]+):([\\+-]?[0-9]+|up|down)$#i', $paramValue, $matches)) { throw new \InvalidArgumentException('Arguments must be in format moduleName:[+|-]position where position is an integer or up or down.'); } $this->moduleQuery->clear(); $module = $this->moduleQuery->findOneByCode($matches[1]); if ($module === null) { throw new \RuntimeException(sprintf('%s module does not exists. Try to refresh first.', $matches[1])); } $this->modulesList[] = $matches[1]; $this->positionsList[] = $matches[2]; }