/** * 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; }
/** * Return the corresponding FQ classpath. * @param string $headerFieldName * @return string * @throws \Brickoo\Component\Http\Header\Aggregator\Exception\HeaderFieldClassNotFoundException */ public function getClass($headerFieldName) { Assert::isString($headerFieldName); if (!$this->hasClass($headerFieldName)) { throw new HeaderFieldClassNotFoundException($headerFieldName); } return "Brickoo\\Component\\Http\\Header\\" . $this->map[$headerFieldName]; }
/** * Class constructor. * @param string $version the http version * @throws \InvalidArgumentException * @throws \Brickoo\Component\Http\Exception\InvalidHttpVersionException */ public function __construct($version) { Assert::isString($version); if (!$this->isValid($version)) { throw new InvalidHttpVersionException($version); } $this->version = $version; }
/** {@inheritDoc} */ public function delete($identifier) { Assert::isString($identifier); if (array_key_exists($identifier, $this->cacheValues)) { unset($this->cacheValues[$identifier]); } return $this; }
/** * @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; }
/** * Class constructor * @param string $method the http method * @throws \Brickoo\Component\Http\Exception\InvalidHttpMethodException */ public function __construct($method) { Assert::isString($method); if (!$this->isValid($method)) { throw new InvalidHttpMethodException($method); } $this->method = $method; }
/** * Class constructor * @param string $matchingPath * @param \Brickoo\Component\Routing\Route\RoutePathRegexGenerator $regexGenerator */ public function __construct($matchingPath, RoutePathRegexGenerator $regexGenerator) { Assert::isString($matchingPath); $this->matchingPath = $matchingPath; $this->regexGenerator = $regexGenerator; $this->routeParameters = []; $this->pathParameters = []; }
/** * Class constructor. * @param \Brickoo\Component\IO\Stream\SocketStream $socketStream * @param string $hostname the hostname of the machine running * @param integer $facility the facility of the sending messages, default USER_0 * @throws \InvalidArgumentException if an argument is not valid */ public function __construct(SocketStream $socketStream, $hostname, $facility = self::FACILITY_USER_0) { Assert::isString($hostname); Assert::isInteger($facility); $this->socketStream = $socketStream; $this->hostname = $hostname; $this->facility = $facility; }
/** * Class constructor. * @param string $name * @param string $type * @param boolean $required * @throws \InvalidArgumentException */ public function __construct($name, $type, $required = true) { Assert::isString($name); Assert::isString($type); Assert::isBoolean($required); $this->name = $name; $this->type = $type; $this->required = $required; }
/** * @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 $annotationName * @param integer $target * @param boolean $required * @throws \InvalidArgumentException */ public function __construct($annotationName, $target = Annotation::TARGET_CLASS, $required = true) { Assert::isString($annotationName); Assert::isInteger($target); Assert::isBoolean($required); $this->target = $target; $this->annotationName = $annotationName; $this->required = $required; $this->requiredParameters = []; $this->optionalParameters = []; }
/** * Returns the injection definition matching a target. * @param string $target * @return array the target matching injection definitions. */ public function getByTarget($target) { Assert::isString($target); $injections = []; foreach ($this->getAll() as $injection) { if ($injection->isTarget($target)) { $injections[] = $injection; } } return $injections; }
/** * 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; }
/** * Class constructor. * @param string $scheme the uri protocol scheme * @param \Brickoo\Component\Http\UriAuthority $authority * @param string $path the uri path * @param \Brickoo\Component\Http\UriQuery $query * @param string $fragment */ public function __construct($scheme, UriAuthority $authority, $path, UriQuery $query, $fragment) { Assert::isString($scheme); Assert::isString($path); Assert::isString($fragment); $this->scheme = $scheme; $this->authority = $authority; $this->path = $path; $this->query = $query; $this->fragment = $fragment; }
/** * Imports the query parameters from the extracted key/value pairs. * @param string $query the query to extract the pairs from * @throws \InvalidArgumentException if the argument is not valid * @return \Brickoo\Component\Http\UriQuery */ public function fromString($query) { Assert::isString($query); if (($position = strpos($query, "?")) !== false) { $query = substr($query, $position + 1); } parse_str(rawurldecode($query), $importedQueryParameters); if (is_array($importedQueryParameters)) { $this->fromArray($importedQueryParameters); } return $this; }
/** * Builds an uri string based on the parameters provided. * @param string $routeName the route to use for the build * @param array $pathParameters the path parameters as key/value pairs * @param string $queryString * @throws \Brickoo\Component\Routing\Route\Exception\PathNotValidException * @internal param string $queryParameters the query parameters * @return string the built uri */ public function build($routeName, array $pathParameters = [], $queryString = "") { Assert::isString($routeName); Assert::isString($queryString); $route = $this->router->getRoute($routeName); $expectedPath = $this->getExpectedRoutePath($route, $pathParameters); $matches = []; if (preg_match_all($this->regexGenerator->generate($route), $expectedPath, $matches) === 0) { throw new PathNotValidException($routeName, $expectedPath); } return $this->createUriString($expectedPath, $queryString); }
/** * Class constructor. * @param string $routingPath the routing directory path * @param string $routingFilename the route filename to look for * @param boolean $searchRecursively flag to search recursively * @throws \InvalidArgumentException if an argument is not valid */ public function __construct($routingPath, $routingFilename, $searchRecursively = false) { Assert::isString($routingPath); Assert::isString($routingFilename); Assert::isBoolean($searchRecursively); if (empty($routingPath)) { throw new InvalidArgumentException("The routing path cannot be empty."); } if (empty($routingFilename)) { throw new InvalidArgumentException("The routing filename cannot be empty."); } $this->routingPath = $routingPath; $this->routingFilename = $routingFilename; $this->searchRecursively = $searchRecursively; }
/** * Deletes the stored content which is hold by the identifier. * Removes the local stored content. * @param string $identifier the identifier which holds the content * @throws \InvalidArgumentException if an argument is not valid * @return \Brickoo\Component\Storage\StorageProxy */ public function delete($identifier) { Assert::isString($identifier); $this->executeIterationCallback(function (Adapter $readyAdapter) use($identifier) { $readyAdapter->delete($identifier); return null; }); return $this; }
/** {@inheritDoc} */ public function matches($value) { Assert::isString($value); $valueLength = strlen($value); return $valueLength >= $this->minLength && ($this->maxLength === null || $valueLength <= $this->maxLength); }
/** * Class constructor. * @param string $expectedType the values expected type * @throws \InvalidArgumentException if an argument is not valid. */ public function __construct($expectedType) { Assert::isString($expectedType); parent::__construct("ctype_" . $expectedType); }
/** * Set the cache message identifier. * @param string $identifier * @throws \InvalidArgumentException * @return \Brickoo\Component\Storage\Messaging\Message\StorageMessage */ public function setIdentifier($identifier) { Assert::isString($identifier); $this->setParam(self::PARAM_IDENTIFIER, $identifier); return $this; }
/** * Class constructor. * @param string $functionName * @throws \InvalidArgumentException if an argument is not valid. */ public function __construct($functionName) { Assert::isString($functionName); Assert::isFunctionAvailable($functionName); $this->callFunctionName = $functionName; }
/** * Checks if the route is available. * @param string $routeName the route unique name * @param string $collectionName the route collections name * @throws \InvalidArgumentException if an argument is not valid * @return boolean */ public function hasRoute($routeName, $collectionName = "") { Assert::isString($collectionName); Assert::isString($routeName); try { $this->getRoute($routeName, $collectionName); return true; } catch (RouteNotFoundException $exception) { return false; } }
/** * Class constructor. * @param string $className */ public function __construct($className) { Assert::isString($className); $this->className = $className; $this->annotations = [Annotation::TARGET_CLASS => [], Annotation::TARGET_METHOD => [], Annotation::TARGET_PROPERTY => []]; }
/** * Checks if the injection matches a target. * @param string $target * @return boolean check result */ public function isTarget($target) { Assert::isString($target); return $this->getTarget() == $target; }
/** * Check if the form has an input file. * @param string $formFileFieldName * @return boolean check result */ public function hasFile($formFileFieldName) { Assert::isString($formFileFieldName); return $this->hasField($formFileFieldName) && $this->formFields[$formFileFieldName] instanceof HttpFormFile; }
/** * Checks if the identifier is currently locked. * @param string $identifier the identifier to check * @return boolean check result */ public function isLocked($identifier) { Assert::isString($identifier); return array_key_exists($identifier, $this->locked); }
/** * Class constructor. * @param string $logsDirectory the directory to store the log messages */ public function __construct($logsDirectory) { Assert::isString($logsDirectory); $this->logsDirectory = rtrim($logsDirectory, "\\/") . DIRECTORY_SEPARATOR; $this->severityDescription = [Logger::SEVERITY_EMERGENCY => "Emergency", Logger::SEVERITY_ALERT => "Alert", Logger::SEVERITY_CRITICAL => "Critical", Logger::SEVERITY_ERROR => "Error", Logger::SEVERITY_WARNING => "Warning", Logger::SEVERITY_NOTICE => "Notice", Logger::SEVERITY_INFO => "Info", Logger::SEVERITY_DEBUG => "Debug"]; }
/** * Class constructor. * @param string $compareValue */ public function __construct($compareValue) { Assert::isString($compareValue); $this->compareValue = $compareValue; }