/** * @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; }
/** * 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; }
/** * 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; }
/** {@inheritdoc} */ public function outdent($amount = 1) { Assert::isInteger($amount); $this->indentationAmount -= $amount; $this->indentationAmount = $this->indentationAmount < 0 ? 0 : $this->indentationAmount; return $this; }
/** * 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(); }
/** * 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; }
/** * @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; }
/** * 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); }
/** * @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; }
/** * 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; }
/** * 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); }
/** * 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; }
/** {@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; }
/** {@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; }
/** * 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; }
/** * 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; }
/** * 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; }
/** * @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); }
/** * 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); }
/** * 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]; }
/** * 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; }
/** * 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; }
/** * 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]); }
/** * @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]); }
/** * @covers Brickoo\Component\Common\Assert::isInteger * @expectedException \InvalidArgumentException */ public function testIsIntegerThrowsInvalidArgumentException() { Assert::isInteger(new \stdClass()); }
/** * @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; }
/** * 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 ?: []; }
/** {@inheritDoc} */ public function log($messages, $severity) { Assert::isInteger($severity); if (!is_array($messages)) { $messages = [$messages]; } $this->sendMessages($messages, $severity); return $this; }
/** * @param integer $bufferLength bellow or equal zero turns the buffer off * @throws \InvalidArgumentException */ public function __construct($bufferLength = 0) { Assert::isInteger($bufferLength); $this->initializeBuffer($bufferLength); }