/** * @param string $name * @param int $value * @param int $min * @param int $max * @return bool * @throws ExceptionCommand */ protected function isValidIntegerInterval($name, $value, $min, $max) { if ($value < $min || $value > $max) { throw ExceptionCommand::invalidIntegerParameter($name, $value, $min, $max); } return true; }
/** * @param $barCodeSelection * @return bool * @throws \Epl\ExceptionCommand */ protected function isValidBarCodeSelection($barCodeSelection) { foreach ($this->getAvailableBarCodeSelection() as $availableBarCode) { if ($availableBarCode === (string) $barCodeSelection) { return true; } } throw ExceptionCommand::invalidBarCodeSelection($barCodeSelection); }
/** * @param $countryCode * @return bool * @throws \Epl\ExceptionCommand */ protected function isValidKDUCountryCode($countryCode) { foreach ($this->availableKDUCountryCode as $code) { if ($code === (string) $countryCode) { return true; } } throw ExceptionCommand::invalidKDUCountryCode($countryCode); }
/** * @param $additionalOption * @return bool * @throws \Epl\ExceptionCommand */ protected function isValidTypeFeedSettings($additionalOption) { if ($additionalOption === 'f' || $additionalOption === 'r' || $additionalOption === 'i') { return true; } throw ExceptionCommand::invalidHardwareAdditionalOptionForFeedSettings($additionalOption); }
/** * 0 = normal * 1 = 90 degrees * 2 = 180 degrees * 3 = 270 degrees * @param int $degree * @param $asianFont * @throw ExceptionCommand * @return int */ private function rotationConvertFromDegree($degree, $asianFont) { switch ($degree) { case 90: if ($asianFont) { return 5; } return 1; case 180: if ($asianFont) { return 6; } return 2; case 270: if ($asianFont) { return 7; } return 3; case 0: if ($asianFont) { return 4; } return 0; default: throw ExceptionCommand::invalidDegree($degree); } }
/** * @param string $data * @param integer $width in bytes or (pixels/8) * @param integer $height in bits or pixels * * @throws ExceptionCommand */ private function isValidData($data, $width, $height) { // Actual data size in bytes $actualDataSize = strlen($data) / 8; // Calculated data size in bytes $calculatedDataSize = $width * ($height / 8); if ($actualDataSize !== $calculatedDataSize) { throw ExceptionCommand::invalidDataSize($actualDataSize, $calculatedDataSize); } }