예제 #1
0
 /**
  * @param resource $streamResource
  * @param integer $numberOfRetries
  * @throws \InvalidArgumentException
  */
 public function __construct($streamResource, $numberOfRetries = 3)
 {
     Assert::isResource($streamResource);
     Assert::isInteger($numberOfRetries);
     $this->streamResource = $streamResource;
     $this->numberOfRetries = $numberOfRetries;
 }
예제 #2
0
 /**
  * Class constructor.
  * @param integer $minLength
  * @param null|Integer $maxLength
  */
 public function __construct($minLength, $maxLength = null)
 {
     Assert::isInteger($minLength);
     Assert::isInteger($maxLength);
     $this->minLength = $minLength;
     $this->maxLength = $maxLength;
 }
예제 #3
0
 /**
  * Class constructor.
  * @param string $hostname
  * @param integer $portNumber
  */
 public function __construct($hostname, $portNumber = 80)
 {
     Assert::isString($hostname);
     Assert::isInteger($portNumber);
     $this->hostname = $hostname;
     $this->portNumber = $portNumber;
 }
예제 #4
0
 /** {@inheritdoc} */
 public function outdent($amount = 1)
 {
     Assert::isInteger($amount);
     $this->indentationAmount -= $amount;
     $this->indentationAmount = $this->indentationAmount < 0 ? 0 : $this->indentationAmount;
     return $this;
 }
예제 #5
0
 /**
  * Class constructor.
  * @param mixed $dependency
  * @param integer $scope
  * @param null|\Brickoo\Component\IoC\Definition\Container\ArgumentDefinitionContainer $argumentsContainer
  * @param null|\Brickoo\Component\IoC\Definition\Container\InjectionDefinitionContainer $injectionsContainer
  */
 public function __construct($dependency, $scope = self::SCOPE_PROTOTYPE, ArgumentDefinitionContainer $argumentsContainer = null, InjectionDefinitionContainer $injectionsContainer = null)
 {
     Assert::isInteger($scope);
     $this->scope = $scope;
     $this->setDependency($dependency);
     $this->argumentsContainer = $argumentsContainer ?: new ArgumentDefinitionContainer();
     $this->injectionsContainer = $injectionsContainer ?: new InjectionDefinitionContainer();
 }
예제 #6
0
 /**
  * Class constructor.
  * @param integer $status the http status
  * @throws \InvalidArgumentException
  * @throws \Brickoo\Component\Http\Exception\InvalidHttpStatusException
  */
 public function __construct($status)
 {
     Assert::isInteger($status);
     if (!$this->isValid($status)) {
         throw new InvalidHttpStatusException($status);
     }
     $this->status = $status;
 }
예제 #7
0
 /**
  * @param string $messageName
  * @param integer $priority
  * @param callable $callback
  */
 public function __construct($messageName, $priority, callable $callback)
 {
     Assert::isString($messageName);
     Assert::isInteger($priority);
     $this->messageName = $messageName;
     $this->priority = $priority;
     $this->callback = $callback;
 }
예제 #8
0
 /**
  * Return the read bytes from the stream.
  * @param integer $bytes
  * @throws \InvalidArgumentException
  * @throws \Brickoo\Component\IO\Stream\Exception\InvalidResourceHandleException
  * @return string the read content
  */
 public function read($bytes = 1024)
 {
     Assert::isInteger($bytes);
     if (!is_resource($this->streamResource)) {
         throw new InvalidResourceHandleException();
     }
     return (string) fread($this->streamResource, $bytes);
 }
예제 #9
0
 /**
  * @param string $filename
  * @param integer $mode
  * @param boolean $useIncludePath
  * @param array $context
  * @throws \InvalidArgumentException
  */
 public function __construct($filename, $mode, $useIncludePath = false, array $context = array())
 {
     Assert::isString($filename);
     Assert::isInteger($mode);
     Assert::isBoolean($useIncludePath);
     $this->filename = $filename;
     $this->mode = $mode;
     $this->useIncludePath = $useIncludePath;
     $this->context = $context;
 }
예제 #10
0
 /**
  * Class constructor.
  * @param integer $target
  * @param string $targetLocation
  * @param string $name the annotation name
  * @param array $values the annotation values
  */
 public function __construct($target, $targetLocation, $name, array $values = [])
 {
     Assert::isInteger($target);
     Assert::isString($targetLocation);
     Assert::isString($name);
     $this->target = $target;
     $this->targetLocation = $targetLocation;
     $this->name = $name;
     $this->values = $values;
 }
예제 #11
0
 /**
  * Class constructor.
  * @param string $name
  * @param string $filePath
  * @param integer $fileSize
  * @param integer $errorCode
  * @throws \InvalidArgumentException
  */
 public function __construct($name, $filePath, $fileSize, $errorCode)
 {
     Assert::isString($name);
     Assert::isString($filePath);
     Assert::isInteger($fileSize);
     Assert::isInteger($errorCode);
     $this->name = $name;
     $this->filePath = $filePath;
     $this->fileSize = $fileSize;
     $this->errorCode = $errorCode;
 }
 /**
  * Returns the annotations definitions matching the target
  * as an iterable array object.
  * @param integer $target
  * @return \ArrayIterator
  */
 public function filter($target)
 {
     Assert::isInteger($target);
     $annotationsDefinitions = [];
     foreach ($this->definitionsCollection as $annotationDefinition) {
         if ($annotationDefinition->isTarget($target)) {
             $annotationsDefinitions[] = $annotationDefinition;
         }
     }
     return new ArrayIterator($annotationsDefinitions);
 }
예제 #13
0
 /**
  * Class constructor.
  * @param string $address
  * @param integer $port
  * @param integer $timeout
  * @param integer $connectionType
  * @param array $context
  */
 public function __construct($address, $port, $timeout = 30, $connectionType = STREAM_CLIENT_CONNECT, array $context = array())
 {
     Assert::isString($address);
     Assert::isInteger($timeout);
     Assert::isInteger($connectionType);
     $this->serverAddress = $address;
     $this->serverPort = $port;
     $this->connectionTimeout = $timeout;
     $this->connectionType = $connectionType;
     $this->context = $context;
 }
예제 #14
0
 /** {@inheritDoc} */
 public function set($identifier, $content, $lifetime)
 {
     Assert::isString($identifier);
     Assert::isInteger($lifetime);
     if ($this->serializeCacheContent) {
         $content = serialize($content);
     }
     $file = fopen($this->getCacheFilePath($identifier), "w");
     fwrite($file, date(self::LIFETIME_FORMAT, time() + $lifetime) . $content);
     fclose($file);
     return $this;
 }
예제 #15
0
 /** {@inheritDoc} */
 public function log($messages, $severity)
 {
     Assert::isInteger($severity);
     if (!is_array($messages)) {
         $messages = [$messages];
     }
     $logMessage = $this->convertToLogMessage($messages, $severity);
     $location = $this->logsDirectory . date("Y-m-d") . ".log";
     $file = fopen($location, "a");
     fwrite($file, $logMessage);
     fclose($file);
     return $this;
 }
예제 #16
0
 /**
  * Sets the content hold by the given identifier.
  * If the identifier already exists the content will be replaced.
  * @param string $identifier the identifier which holds the content
  * @param mixed $content the content to store
  * @param integer $lifetime the lifetime of the stored content
  * @throws \InvalidArgumentException if an argument is not valid
  * @throws \Brickoo\Component\Storage\Exception\AdapterNotFoundException
  * @return \Brickoo\Component\Storage\StorageProxy
  */
 public function set($identifier, $content, $lifetime)
 {
     Assert::isString($identifier);
     Assert::isInteger($lifetime);
     $this->getAdapter()->set($identifier, $content, $lifetime);
     return $this;
 }
예제 #17
0
 /**
  * Class constructor.
  * @param \Brickoo\Component\Storage\StorageProxy $storageProxy
  * @param integer $listenerPriority the listener priority
  */
 public function __construct(StorageProxy $storageProxy, $listenerPriority = 0)
 {
     Assert::isInteger($listenerPriority);
     $this->storageProxy = $storageProxy;
     $this->listenerPriority = $listenerPriority;
 }
예제 #18
0
 /**
  * Set the maximum age of the cookie storage.
  * @param integer $maxAge
  * @throws \InvalidArgumentException
  * @return \Brickoo\Component\Http\Header\SetCookieHeaderField
  */
 public function setMaxAge($maxAge)
 {
     Assert::isInteger($maxAge);
     $this->maxAge = $maxAge;
     return $this;
 }
예제 #19
0
 /**
  * @param \Brickoo\Component\IO\Stream\Stream $stream
  * @param integer $bufferLength default buffer length 255 bytes
  * @throws \InvalidArgumentException
  */
 public function __construct(Stream $stream, $bufferLength = 255)
 {
     Assert::isInteger($bufferLength);
     $this->stream = $stream;
     $this->initializeBuffer($bufferLength);
 }
예제 #20
0
 /**
  * Moves the stream pointer from the end
  * position forward to the offset.
  * @param integer $offset
  * @throws \Brickoo\Component\IO\Stream\Exception\InvalidResourceHandleException
  * @return boolean success of movement
  */
 public function seekEnd($offset)
 {
     Assert::isInteger($offset);
     return $this->processSeek($offset, SEEK_END);
 }
예제 #21
0
 /**
  * Returns the phrase for the status code.
  * @param integer $statusCode
  * @throws \Brickoo\Component\Http\Exception\StatusCodeUnknownException
  * @return string the status code phrase
  */
 public function getPhrase($statusCode)
 {
     Assert::isInteger($statusCode);
     if (!$this->hasPhrase($statusCode)) {
         throw new StatusCodeUnknownException($statusCode);
     }
     return $this->statusPhrases[$statusCode];
 }
예제 #22
0
 /**
  * Checks if the annotation matches a target.
  * @param integer $target
  * @return boolean check result
  */
 public function isTarget($target)
 {
     Assert::isInteger($target);
     return $this->getTarget() == $target;
 }
예제 #23
0
 /**
  * Set the cache content lifetime.
  * @param integer $lifetime
  * @throws \InvalidArgumentException
  * @return \Brickoo\Component\Storage\Messaging\Message\StorageMessage
  */
 public function setLifetime($lifetime)
 {
     Assert::isInteger($lifetime);
     $this->setParam(self::PARAM_LIFETIME, $lifetime);
     return $this;
 }
예제 #24
0
 /**
  * Returns an annotations iterator matching the target.
  * @param integer $target
  * @throws \InvalidArgumentException
  * @throws \Brickoo\Component\Annotation\Exception\InvalidTargetException
  * @return \ArrayIterator
  */
 public function getAnnotationsByTarget($target)
 {
     Assert::isInteger($target);
     if (!$this->isTargetValid($target)) {
         throw new InvalidTargetException($target);
     }
     return new ArrayIterator($this->annotations[$target]);
 }
예제 #25
0
 /**
  * @param array $messages
  * @param integer $severity
  */
 public function __construct(array $messages, $severity)
 {
     Assert::isInteger($severity);
     parent::__construct(Messages::LOG, null, [self::PARAM_LOG_MESSAGES => $messages, self::PARAM_LOG_SEVERITY => $severity]);
 }
예제 #26
0
 /**
  * @covers Brickoo\Component\Common\Assert::isInteger
  * @expectedException \InvalidArgumentException
  */
 public function testIsIntegerThrowsInvalidArgumentException()
 {
     Assert::isInteger(new \stdClass());
 }
예제 #27
0
 /**
  * @param \Brickoo\Component\Log\Logger $logger
  * @param integer $priority the priority level
  */
 public function __construct(Logger $logger, $priority = 0)
 {
     Assert::isInteger($priority);
     $this->logger = $logger;
     $this->listenerPriority = $priority;
 }
예제 #28
0
 /**
  * Parse the document comment to extract annotations.
  * @param string $target
  * @param string $targetLocation
  * @param string $docComment
  * @throws \InvalidArgumentException
  * @return \Brickoo\Component\Annotation\Annotation[]
  */
 public function parse($target, $targetLocation, $docComment)
 {
     Assert::isInteger($target);
     Assert::isString($targetLocation);
     Assert::isString($docComment);
     $annotations = null;
     if (($annotationsMatches = $this->getAnnotationsMatches($this->annotationPrefix, $docComment)) && !empty($annotationsMatches[self::REGEX_CAPTURE_ANNOTATION])) {
         $annotations = $this->convertAnnotations($target, $targetLocation, $this->getAnnotationList($annotationsMatches));
     }
     return $annotations ?: [];
 }
예제 #29
0
 /** {@inheritDoc} */
 public function log($messages, $severity)
 {
     Assert::isInteger($severity);
     if (!is_array($messages)) {
         $messages = [$messages];
     }
     $this->sendMessages($messages, $severity);
     return $this;
 }
예제 #30
0
 /**
  * @param integer $bufferLength bellow or equal zero turns the buffer off
  * @throws \InvalidArgumentException
  */
 public function __construct($bufferLength = 0)
 {
     Assert::isInteger($bufferLength);
     $this->initializeBuffer($bufferLength);
 }