Assert\Assertion::min PHP Method

min() public static method

Assert that a value is at least as big as a given limit
public static min ( mixed $value, mixed $minValue, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$minValue mixed
$message string | null
$propertyPath string | null
return boolean
    public static function min($value, $minValue, $message = null, $propertyPath = null)
    {
        static::numeric($value, $message, $propertyPath);
        if ($value < $minValue) {
            $message = sprintf($message ?: 'Number "%s" was expected to be at least "%s".', static::stringify($value), static::stringify($minValue));
            throw static::createException($value, $message, static::INVALID_MIN, $propertyPath, array('min' => $minValue));
        }
        return true;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Create service with name
  *
  * @param ServiceLocatorInterface $serviceLocator
  * @param string $name
  * @param string $requestedName
  * @throws \LogicException
  * @return mixed
  */
 public function createServiceWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName)
 {
     /** @var $env Environment */
     $env = $serviceLocator->get(Definition::SERVICE_ENVIRONMENT);
     $nameParts = explode('.', $requestedName);
     Assertion::min(count($nameParts), 3, sprintf("Given service bus alias %s is invalid. Format should be processing.(command|event)_bus.[target]", $requestedName));
     $busType = $nameParts[1];
     unset($nameParts[0]);
     unset($nameParts[1]);
     $address = implode('.', $nameParts);
     $busConfig = $this->getChannelConfigFor($env, $address);
     $target = $this->getTargetFromAddress($address);
     $bus = $busType === "command_bus" ? new CommandBus() : new EventBus();
     $bus->utilize($this->getForwardToMessageDispatcher());
     $bus->utilize($this->getToMessageTranslator());
     $bus->utilize($this->getHandleWorkflowMessageStrategy());
     $bus->utilize($this->getInvokeProcessorStrategy());
     $bus->utilize(new ServiceLocatorProxy(Zf2ServiceManagerProxy::proxy($serviceLocator)));
     $messageHandler = $busConfig->stringValue('message_dispatcher', $target);
     if (!empty($messageHandler)) {
         $bus->utilize(new SingleTargetMessageRouter($messageHandler));
     } else {
         throw new \LogicException("Missing a message handler for the bus " . $requestedName);
     }
     foreach ($busConfig->arrayValue('utils') as $busUtil) {
         if (is_string($busUtil)) {
             $busUtil = $serviceLocator->get($busUtil);
         }
         $bus->utilize($busUtil);
     }
     return $bus;
 }
All Usage Examples Of Assert\Assertion::min