sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function setJsonBody($data)
{
$body = json_encode($data, JSON_UNESCAPED_UNICODE);
$this->setHeader('content-type', 'application/json');
$this->setBody($body);
} | Set http request body as Json
@param mixed $data json data | entailment |
public function addPostField($key, $value)
{
$this->setMethod('POST');
$this->setBody(null);
if (!is_array($value)) {
$this->_postFields[$key] = strval($value);
} else {
$value = $this->formatArrayField($value);
foreach ($value as $k => $v) {
... | Add field for the request use POST
@param string $key field name.
@param mixed $value field value, array supported. | entailment |
public function addPostFile($key, $file, $content = null)
{
$this->setMethod('POST');
$this->setBody(null);
if ($content === null && is_file($file)) {
$content = @file_get_contents($file);
}
$this->_postFiles[$key] = [basename($file), $content];
} | Add file to be uploaded for request use POST
@param string $key field name.
@param string $file file path to be uploaded.
@param string $content file content, default to null and read from file. | entailment |
protected function getPostBody()
{
$data = '';
if (count($this->_postFiles) > 0) {
$boundary = md5($this->_rawUrl . microtime());
foreach ($this->_postFields as $k => $v) {
$data .= '--' . $boundary . Client::CRLF . 'Content-Disposition: form-data; name="' . $... | Combine request body from post fields & files
@return string request body content | entailment |
protected static function getIp($host)
{
if (!isset(self::$_dns[$host])) {
self::$_dns[$host] = gethostbyname($host);
}
return self::$_dns[$host];
} | get ip address | entailment |
private function formatArrayField($arr, $pk = null)
{
$ret = [];
foreach ($arr as $k => $v) {
if ($pk !== null) {
$k = $pk . $k;
}
if (is_array($v)) {
$ret = array_merge($ret, $this->formatArrayField($v, $k . ']['));
} e... | format array field (convert N-DIM(n>=2) array => 2-DIM array) | entailment |
public function run()
{
/** @var BackendTemplate|object $objTemplate */
$objTemplate = new \BackendTemplate('mod_visitors_be_stat_details_referrer');
$objTemplate->theme = \Backend::getTheme();
$objTemplate->base = \Environment::get('base');
$objTemplate->language = $GLOBALS['TL_LANGUAG... | Run the controller and parse the template
@return Response | entailment |
public function send(string $request): string
{
$stream = fopen(trim($this->url), 'rb', false, $this->buildContext($request));
if (!is_resource($stream)) {
throw new ConnectionFailureException('Unable to establish a connection');
}
$this->headers = $this->getDefaultHead... | Send request
@param string $request
@return string | entailment |
protected function determine() {
$this->checkPlatform();
$this->checkBrowsers();
$this->checkForAol();
$this->reduceVersion(); //modified for compatibility
$this->checkPlatformVersion(); //add BugBuster
} | Protected routine to calculate and determine what the browser is in use (including platform) | entailment |
protected function reduceVersion() {
if ($this->_version === self::VERSION_UNKNOWN) {
return ;
}
if (stripos($this->_version,'.') !== false ) {
$this->_version = substr($this->_version,0,stripos($this->_version,'.')+2);
}
} | Modify version for compatibility | entailment |
protected function checkBrowsers() {
return (
// well-known, well-used
// Special Notes:
// (1) Opera must be checked before FireFox due to the odd
// user agents used in some older versions of Opera
// (2) WebTV is strapped onto Internet Explorer so we must
// check for WebTV before IE
/... | Protected routine to determine the browser type
http://www.useragentstring.com/index.php
@return boolean True if the browser was detected otherwise false | entailment |
protected function checkBrowserInternetExplorer()
{
$match = '';
// Test for v1 - v1.5 IE
if( stripos($this->_agent,'microsoft internet explorer') !== false )
{
$this->setBrowser(self::BROWSER_IE);
$this->setVersion('1.0');
$aresult = stristr($this->_agent, '/');
... | Determine if the browser is Internet Explorer or not (last updated 1.7)
@return boolean True if the browser is Internet Explorer otherwise false | entailment |
protected function checkBrowserOpera() {
if( stripos($this->_agent,'opera mini') !== false ) {
$resultant = stristr($this->_agent, 'opera mini');
if( preg_match('/\//',$resultant) ) {
$aresult = explode('/',$resultant);
$aversion = explode(' ',$aresult[1]);
$this->setVersion($avers... | Determine if the browser is Opera or not (last updated 1.7)
@return boolean True if the browser is Opera otherwise false | entailment |
protected function checkBrowserChrome() {
if( stripos($this->_agent,'Chrome') !== false ) {
$aresult = explode('/',stristr($this->_agent,'Chrome'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->setBrowser(self::BROWSER_CHROME);
return true;
}
... | Determine if the browser is Chrome or not (last updated 1.7)
@return boolean True if the browser is Chrome otherwise false | entailment |
protected function checkBrowserVivaldi() {
if( stripos($this->_agent,'Vivaldi') !== false ) {
$aresult = explode('/',stristr($this->_agent,'Vivaldi'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->setBrowser(self::BROWSER_VIVALDI);... | Determine if the browser is Vivaldi or not
@return boolean True if the browser is Vivaldi otherwise false | entailment |
protected function checkBrowserDooble() {
if( stripos($this->_agent,'Dooble') !== false ) {
$aresult = explode('/',stristr($this->_agent,'Dooble'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->setBrowser(self::BROWSER_DOOBLE);
... | Determine if the browser is Dooble (1.x) or not
@return boolean True if the browser is Dooble otherwise false | entailment |
protected function checkBrowserQtWebBrowser() {
if( stripos($this->_agent,'QtWebEngine') !== false ) {
$aresult = explode('/',stristr($this->_agent,'QtWebEngine'));
$aversion = explode('.',$aresult[1]);
$this->setVersion($aversion[0]);
$this->setBrowser(self::BRO... | Determine if the browser is QtWebBrowser or not
@return boolean True if the browser is QtWebBrowser otherwise false | entailment |
protected function checkBrowserSongbird() {
if( stripos($this->_agent,'Songbird') !== false ) {
$aversion = explode('/',stristr($this->_agent,'Songbird'));
$this->setVersion($aversion[1]);
$this->setBrowser(self::BROWSER_SONGBIRD);
return true;
}
return false;
} | Determine if the browser is Songbird or not, add by BugBuster
@return boolean True if the browser is Songbird otherwise false | entailment |
protected function checkBrowserSeaMonkey() {
if( stripos($this->_agent,'SeaMonkey') !== false ) {
$aversion = explode('/',stristr($this->_agent,'SeaMonkey'));
$this->setVersion($aversion[1]);
$this->setBrowser(self::BROWSER_SEAMONKEY);
return true;
}
return false;
} | Determine if the browser is Songbird or not, add by BugBuster
@return boolean True if the browser is Songbird otherwise false | entailment |
protected function checkBrowserTOnline() {
if( stripos($this->_agent,'T-Online Browser') !== false ) {
$this->setBrowser(self::BROWSER_TONLINE);
return true;
}
return false;
} | Determine if the browser is T-Online Browser or not, add by BugBuster
@return boolean True if the browser is T-Online Browser otherwise false | entailment |
protected function checkBrowserAndroidSamsungGalaxy()
{
if( stripos($this->_agent,'Android') !== false )
{
$this->setVersion(self::VERSION_UNKNOWN);
$this->setMobile(true);
if( stripos($this->_agent,'GT-I9000') !== false )
{
$this->setBrowser(self::BROW... | Determine if the browser is Android and Samsung Galaxy or not, add by BugBuster
@return boolean True if the browser is Samsung Galaxy otherwise false | entailment |
protected function checkBrowserAndroidHTCDesire()
{
if( stripos($this->_agent,'Android') !== false )
{
if( stripos($this->_agent,'HTC_DesireHD') !== false )
{
$this->setVersion(self::VERSION_UNKNOWN);
$this->setMobile(true);
$th... | Determine if the browser is Android and HTC Desire or not, add by BugBuster
@return boolean True if the browser is HTC Desire otherwise false | entailment |
protected function checkBrowserAndroidHTCMagic()
{
if( stripos($this->_agent,'Android') !== false )
{
if( stripos($this->_agent,'HTC Magic') !== false )
{
$this->setVersion(self::VERSION_UNKNOWN);
$this->setMobile(true);
$this->... | Determine if the browser is Android and HTC Magic or not, add by BugBuster
@return boolean True if the browser is HTC Magic otherwise false | entailment |
protected function checkBrowserAndroidHTCNexusOne()
{
if( stripos($this->_agent,'Android') !== false )
{
if( stripos($this->_agent,'Nexus One') !== false )
{
$this->setVersion(self::VERSION_UNKNOWN);
$this->setMobile(true);
$thi... | Determine if the browser is Android and HTC Nexus One (4Google) or not, add by BugBuster
@return boolean True if the browser is HTC Nexus One otherwise false | entailment |
protected function checkBrowserAndroidSamsungNexusS()
{
if( stripos($this->_agent,'Android') !== false )
{
if( stripos($this->_agent,'Nexus S Build') !== false )
{
$this->setVersion(self::VERSION_UNKNOWN);
$this->setMobile(true);
... | Determine if the browser is Android and Samsung Nexus S (4Google) or not, add by BugBuster
@return boolean True if the browser is Samsung Nexus S otherwise false | entailment |
protected function checkBrowserAndroidHTCWildfire()
{
if( stripos($this->_agent,'Android') !== false )
{
if( stripos($this->_agent,'HTC_WildfireS_A510e') !== false )
{
$this->setVersion(self::VERSION_UNKNOWN);
$this->setMobile(true);
... | Determine if the browser is Android and HTC WildfireS A510e or not, add by BugBuster
@return boolean True if the browser is HTC WildfireS A510e otherwise false | entailment |
protected function checkBrowserAndroidHTCSensation()
{
if( stripos($this->_agent,'Android') !== false ||
stripos($this->_agent,'Macintosh') !== false )
{
if( stripos($this->_agent,'HTC_SensationXE') !== false ||
stripos($this->_agent,'HTC Sensation XE') !== false )
... | Determine if the browser is Android and HTC Sensation or not, add by BugBuster
@return boolean True if the browser is HTC Sensation otherwise false | entailment |
protected function checkBrowserChromePlus() {
if( stripos($this->_agent,'ChromePlus') !== false ) {
$aresult = explode('/',stristr($this->_agent,'ChromePlus'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->setBrowser(self::BROWSER_CHROME_PLUS);
return ... | Determine if the browser is ChromePlus or not, add by BugBuster
@return boolean True if the browser is ChromePlus otherwise false | entailment |
protected function checkBrowserCoolNovo() {
if( stripos($this->_agent,'CoolNovo') !== false ) {
$aresult = explode('/',stristr($this->_agent,'CoolNovo'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->setBrowser(self::BROWSER_COOL_N... | Determine if the browser is CoolNovo (previous ChromePlus) or not, add by BugBuster
@return boolean True if the browser is CoolNovo otherwise false | entailment |
protected function checkBrowserMaxthon() {
if( stripos($this->_agent,'Maxthon') !== false ) {
$aresult = explode('/',stristr($this->_agent,'Maxthon'));
$aversion = explode(' ',$aresult[1]);
$this->setVersion($aversion[0]);
$this->setBrowser(self::BROWSER_COOL_MAXT... | Determine if the browser is Maxthon or not, add by BugBuster
@return boolean True if the browser is Maxthon otherwise false | entailment |
protected function checkBrowserHTTPRequest2() {
if( stripos($this->_agent,'HTTP_Request2') !== false ) {
$aversion = explode('/',stristr($this->_agent,'HTTP_Request2'));
$this->setVersion($aversion[1]);
$this->setBrowser(self::BROWSER_HTTP_REQUEST2);
return true;
}
return false;
... | Determine if the browser is Pear HTTP_Request2 or not, add by BugBuster
@return boolean True if the browser is Pear HTTP_Request2 otherwise false | entailment |
protected function checkBrowserAndroidAcerA500()
{
if( stripos($this->_agent,'Android') !== false )
{
if( stripos($this->_agent,'A500 Build') !== false )
{
$this->setVersion(self::VERSION_UNKNOWN);
$this->setMobile(true);
$this-... | Determine if the browser is an Acer Iconia A500 Tablet or not, add by BugBuster
@return boolean True if the browser is an Acer Iconia A500 Tablet otherwise false | entailment |
protected function checkBrowserAndroidAcerA501()
{
if( stripos($this->_agent,'Android') !== false )
{
if( stripos($this->_agent,'A501 Build') !== false )
{
$this->setVersion(self::VERSION_UNKNOWN);
$this->setMobile(true);
$this-... | Determine if the browser is an Acer A501 Tablet or not, add by BugBuster
@return boolean True if the browser is an Acer A501 Tablet otherwise false | entailment |
protected function checkBrowserAndroidThinkPadTablet()
{
if( stripos($this->_agent,'Android') !== false )
{
if( stripos($this->_agent,'ThinkPad Tablet') !== false )
{
$this->setVersion(self::VERSION_UNKNOWN);
$this->setMobile(true);
... | Determine if the browser is a Lenovo ThinkPad Tablet or not, add by BugBuster
@return boolean True if the browser is a Lenovo ThinkPad Tablet otherwise false | entailment |
protected function checkBrowserAndroidXoomTablet()
{
if( stripos($this->_agent,'Android') !== false )
{
if( stripos($this->_agent,'Xoom Build') !== false )
{
$this->setVersion(self::VERSION_UNKNOWN);
$this->setMobile(true);
$thi... | Determine if the browser is a Motorola Xoom Tablet or not, add by BugBuster
@return boolean True if the browser is a Motorola Xoom Tablet otherwise false | entailment |
protected function checkBrowserAndroidAsusTransfomerPad()
{
if( stripos($this->_agent,'Android') !== false )
{
if( stripos($this->_agent,'ASUS Transformer Pad') !== false )
{
$this->setVersion(self::VERSION_UNKNOWN);
$this->setMobile(true);
... | Determine if the browser is a Asus Transfomer Pad or not, add by BugBuster
@return boolean True if the browser is a Asus Transfomer Pad otherwise false | entailment |
protected function checkBrowserAndroidKindleFire()
{
if( stripos($this->_agent,'Android') !== false )
{
if( stripos($this->_agent,'Silk') !== false )
{
$this->setVersion(self::VERSION_UNKNOWN);
$this->setBrowser(self::BROWSER_KINDLE_FIRE);
... | Determine if the browser is a Kindle Fire with Silk Browser (Safari) or not, add by BugBuster
@return boolean True if the browser is a Kindle Fire otherwise false | entailment |
protected function checkPlatform()
{
if( stripos($this->_agent, 'iPad') !== false )
{
$this->_platform = self::PLATFORM_APPLE; // iOS folgt spaeter
}
elseif( stripos($this->_agent, 'iPod') !== false )
{
$this->_platform = self::PLATFORM_APPLE; // iOS folgt spaeter
... | Determine the user's platform (last updated 1.7) | entailment |
public function getPlatformVersion() {
if ($this->_platformVersion === self::PLATFORM_UNKNOWN )
{
$this->_platformVersion = $this->_platform;
}
return $this->_platformVersion;
} | The name of the platform. All return types are from the class contants
Fallback platformVersion with platform if platformVersion unknown
@return string Platformversion of the browser | entailment |
protected function checkPlatformVersion()
{
// based on browscap.ini
if ($this->_platform == self::PLATFORM_WINDOWS)
{
/*if( stripos($this->_agent, 'windows NT 7.1') !== false ) {
$this->_platform = self::PLATFORM_WINDOWS_7;
}
else*/
if( stripos($... | Improved checkPlatform with Windows Plattform Details
and Mac OS X
BugBuster (Glen Langer) | entailment |
protected function setLang()
{
$array = explode(",", $this->_accept_language);
$ca = count($array);
for($i = 0; $i < $ca; $i++)
{
//Konqueror
$array[$i] = str_replace(" ", null, $array[$i]);
$array[$i] = substr($array[$i], 0, 2);
$arr... | Ermittle akzeptierten Sprachen
@return bool true
@access protected | entailment |
public function parse(string $data): InvokeSpec
{
$payload = @json_decode($data, true);
if (!is_array($payload)) {
return new InvokeSpec([new Error(new ParseErrorException())], true);
}
$units = [];
// Single request
if ($this->isSingleRequest($payload)... | Parse request data
@param string $data
@return InvokeSpec | entailment |
private function decodeCall($record): AbstractInvoke
{
$record = $this->preParse($record);
if ($this->isValidCall($record)) {
$unit = new Invoke($record['id'], $record['method'], $record['params'] ?? []);
} elseif ($this->isValidNotification($record)) {
$unit = new N... | @param $record
@return AbstractInvoke | entailment |
private function isValidNotification($payload): bool
{
if (!is_array($payload)) {
return false;
}
$headerValid = array_key_exists('jsonrpc', $payload) && $payload['jsonrpc'] === '2.0';
$methodValid = array_key_exists('method', $payload) && is_string($payload['method']);... | @param array $payload
@return bool | entailment |
private function preParse($record)
{
$container = $this->preParse->handle(new ParserContainer($this, $record));
if ($container instanceof ParserContainer) {
return $container->getValue();
}
throw new \RuntimeException();
} | @param mixed $record
@return mixed | entailment |
public function generate()
{
if (TL_MODE == 'BE')
{
$objTemplate = new \BackendTemplate('be_wildcard');
$objTemplate->wildcard = '### VISITORS LIST ###';
$objTemplate->title = $this->headline;
$objTemplate->id = $this->id;
$objTemplate->link = $this->name;
$objTemplate-... | Display a wildcard in the back end
@return string | entailment |
protected function compile()
{ //visitors_template
$objVisitors = \Database::getInstance()
->prepare("SELECT
tl_visitors.id AS id,
visitors_name,
visitors_startdate,
visi... | Generate module | entailment |
public function handle(
string $method = null,
string $path = null,
$action,
array $arguments = [],
ContainerInterface $di = null
) {
$this->di = $di;
if (is_null($action)) {
return;
}
if (is_callable($action)) {
if (i... | Handle the action for a route and return the results.
@param string $method the request method.
@param string $path that was matched.
@param string|array $action base for the callable.
@param array $arguments optional argumen... | entailment |
public function getHandlerType(
$action,
ContainerInterface $di = null
) {
if (is_null($action)) {
return "null";
}
if (is_callable($action)) {
return "callable";
}
if (is_string($action) && class_exists($action)) {
$calla... | Get an informative string representing the handler type.
@param string|array $action base for the callable.
@param ContainerInjectableInterface $di container with services.
@return string as the type of handler. | entailment |
protected function isControllerAction(
string $method = null,
string $path = null,
string $class
) {
$method = ucfirst(strtolower($method));
$args = explode("/", $path);
$action = array_shift($args);
$action = empty($action) ? "index" : $action;
$actio... | Check if items can be used to call a controller action, verify
that the controller exists, the action has a class-method to call.
@param string $method the request method.
@param string $path the matched path, base for the controller action
and the arguments.
@param string $class the controller class
@return array... | entailment |
protected function handleAsControllerAction(array $callable)
{
$class = $callable[0];
$action = $callable[1];
$args = $callable[2];
$obj = new $class();
$refl = new \ReflectionClass($class);
$diInterface = "Anax\Commons\ContainerInjectableInterface";
$appInte... | Call the controller action with optional arguments and call
initialisation methods if available.
@param string $callable with details on what controller action to call.
@return mixed result from the handler. | entailment |
protected function handleAsCallable(
$action,
array $arguments
) {
if (is_array($action)
&& isset($action[0])
&& isset($action[1])
&& is_string($action[0])
&& is_string($action[1])
&& class_exists($action[0])
) {
... | Handle as callable support callables where the method is not static.
@param string|array $action base for the callable
@param array $arguments optional arguments
@param ContainerInjectableInterface $di container with services
@return mixed as the result from the route ... | entailment |
protected function handleUsingDi(
$action,
array $arguments,
ContainerInterface $di
) {
if (!$di->has($action[0])) {
throw new ConfigurationException("Routehandler '{$action[0]}' not loaded in di.");
}
$service = $di->get($action[0]);
if (!is_... | Load callable as a service from the $di container.
@param string|array $action base for the callable
@param array $arguments optional arguments
@param ContainerInjectableInterface $di container with services
@return mixed as the result from the route handler. | entailment |
public function fromReflection(ReflectionClass $reflectionClass) : array
{
$class = new Class_($reflectionClass->getShortName());
$statements = array($class);
if ($parentClass = $reflectionClass->getParentClass()) {
$class->extends = new FullyQualified($parentClass->getName... | @param \ReflectionClass $reflectionClass
@return \PhpParser\Node[] | entailment |
protected function buildProperty(ReflectionProperty $reflectionProperty) : Node\Stmt\Property
{
$propertyBuilder = new Property($reflectionProperty->getName());
if ($reflectionProperty->isPublic()) {
$propertyBuilder->makePublic();
}
if ($reflectionProperty->isProtected... | @param ReflectionProperty $reflectionProperty
@return Node\Stmt\Property | entailment |
protected function buildMethod(ReflectionMethod $reflectionMethod) : Node\Stmt\ClassMethod
{
$methodBuilder = new Method($reflectionMethod->getName());
if ($reflectionMethod->isPublic()) {
$methodBuilder->makePublic();
}
if ($reflectionMethod->isProtected()) {
... | @param ReflectionMethod $reflectionMethod
@return \PhpParser\Node\Stmt\ClassMethod | entailment |
protected function buildParameter(ReflectionParameter $reflectionParameter) : Node\Param
{
$parameterBuilder = new Param($reflectionParameter->getName());
if ($reflectionParameter->isPassedByReference()) {
$parameterBuilder->makeByRef();
}
if ($reflectionParameter->isAr... | @param ReflectionParameter $reflectionParameter
@return Node\Param | entailment |
private function checkPartAsArgument($rulePart, $queryPart, &$args)
{
if (substr($rulePart, -1) == "}"
&& !is_null($queryPart)
) {
$part = substr($rulePart, 1, -1);
$pos = strpos($part, ":");
$type = null;
if ($pos !== false) {
... | Check if part of route is a argument and optionally match type
as a requirement {argument:type}.
@param string $rulePart the rule part to check.
@param string $queryPart the query part to check.
@param array &$args add argument to args array if matched
@return boolean | entailment |
private function checkPartMatchingType($value, $type)
{
switch ($type) {
case "digit":
return ctype_digit($value);
break;
case "hex":
return ctype_xdigit($value);
break;
case "alpha":
return... | Check if value is matching a certain type of values.
@param string $value the value to check.
@param array $type the expected type to check against.
@return boolean | entailment |
private function matchPart($rulePart, $queryPart, &$args)
{
$match = false;
$first = isset($rulePart[0]) ? $rulePart[0] : '';
switch ($first) {
case '*':
$match = true;
break;
case '{':
$match = $this->checkPartAsArgume... | Match part of rule and query.
@param string $rulePart the rule part to check.
@param string $queryPart the query part to check.
@param array &$args add argument to args array if matched
@return boolean | entailment |
private function matchRequestMethod(
string $method = null,
array $supported = null
) {
if ($supported && !in_array($method, $supported)) {
return false;
}
return true;
} | Check if the request method matches.
@param string $method as request method.
@param string $supported as request methods that are valid.
@return boolean true if request method matches | entailment |
public function match(
string $mount = null,
string $relativePath = null,
string $absolutePath = null,
string $query,
array $methodSupported = null,
string $method = null
) {
$this->arguments = [];
$this->methodMatched = null;
$this->pathMatche... | Check if the route matches a query and request method.
@param string $mount of the current route being matched.
@param string $relativePath of the current route being matched.
@param string $absolutePath of the current route being matched.
@param string $query to match against
@param array $... | entailment |
public function enterNode(Node $node)
{
if ($node instanceof Namespace_) {
if ($this->namespace) {
throw new UnexpectedValueException('Multiple nested namespaces discovered (invalid AST?)');
}
$this->namespace = $node;
}
if ($node instanc... | @param \PhpParser\Node $node
@return null
@throws Exception\UnexpectedValueException if more than one class is found | entailment |
public function leaveNode(Node $node)
{
if ($node instanceof Namespace_) {
$namespace = $this->currentNamespace;
$replacedInNamespace = $this->replacedInNamespace;
$this->currentNamespace = null;
$this->replacedInNamespace = null;
... | Replaces (if matching) the given node to comply with the new given name
@param \PhpParser\Node $node
@todo can be abstracted away into a visitor that allows to modify the matched node via a callback
@return array|null|\PhpParser\Node\Stmt\Class_|\PhpParser\Node\Stmt\Namespace_|null | entailment |
private function namespaceMatches() : bool
{
$currentNamespace = ($this->currentNamespace && is_array($this->currentNamespace->name->parts))
? $this->currentNamespace->name->toString()
: '';
return $currentNamespace === $this->reflectedClass->getNamespaceName();
} | Checks if the current namespace matches with the one provided with the reflection class
@return bool | entailment |
public function pathInfoFilter($path, $options = false)
{
if ($options) {
$output = pathinfo($path, $options);
} else {
$output = pathinfo($path);
}
return $output;
} | php pathinfo() wrapper -- http://php.net/manual/en/function.pathinfo.php
@param $path
@param bool $options
@return mixed | entailment |
public function baseNameFilter($path, $suffix = false)
{
if ($suffix) {
$output = basename($path, $suffix);
} else {
$output = basename($path);
}
return $output;
} | php basename() wrapper -- http://php.net/manual/en/function.basename.php
@param $path
@param bool $suffix
@return string | entailment |
public function swapExtensionFilter($path_or_url, $extension)
{
$path = $this->decomposeUrl($path_or_url);
$path_parts = pathinfo($path['path']);
$new_path = $path_parts['filename'] . "." . $extension;
if (!empty($path_parts['dirname']) && $path_parts['dirname'] !== ".") {
... | Swap the file extension on a passed url or path
@param $path_or_url
@param $extension
@return string | entailment |
public function swapDirectoryFilter($path_or_url, $directory)
{
$path = $this->decomposeUrl($path_or_url);
$path_parts = pathinfo($path['path']);
$new_path = $directory . DIRECTORY_SEPARATOR . $path_parts['basename'];
$output = $path['prefix'] . $new_path . $path['suffix'];
... | Swap the file directory on a passed url or path
@param $path_or_url
@param $directory
@return string | entailment |
public function appendSuffixFilter($path_or_url, $suffix)
{
$path = $this->decomposeUrl($path_or_url);
$path_parts = pathinfo($path['path']);
$new_path = $path_parts['filename'] . $suffix . "." . $path_parts['extension'];
if (!empty($path_parts['dirname']) && $path_parts['dirname'] !... | Append a suffix a passed url or path
@param $path_or_url
@param $suffix
@return string | entailment |
private function decomposeUrl($path_or_url)
{
$result = array();
if (filter_var($path_or_url, FILTER_VALIDATE_URL)) {
$url_parts = parse_url($path_or_url);
$result['prefix'] = $url_parts['scheme'] . "://" . $url_parts['host'];
$result['path'] = $url_parts['path']... | Decompose a url into a prefix, path, and suffix
@param $path_or_url
@return array | entailment |
public function add(Interceptor $element)
{
if ($this->next) {
$this->next->add($element);
} else {
$this->next = $element;
}
return $this;
} | @param Interceptor $element
@return $this | entailment |
public function handle(AbstractContainer $container): AbstractContainer
{
// Execute callback and pass result next chain
if (is_callable($this->callback)) {
$result = call_user_func($this->callback, $container);
if (!$this->next) {
return $result;
... | @param AbstractContainer $container
@return mixed | entailment |
public function toggleVisibility($intId, $blnVisible)
{
// Check permissions to publish
if (!$this->User->isAdmin && !$this->User->hasAccess('tl_visitors::published', 'alexf'))
{
\System::getContainer()
->get('monolog.logger.contao')
->log(LogLevel... | Disable/enable a counter
@param integer
@param boolean | entailment |
public function get(QueryCacheBuilder $builder, $columns = ['*'])
{
if (!$this->enabled()) {
return $this->performQuery($builder, $columns);
}
$key = $this->generateKey($builder, $columns);
$cache = $this->getCache($builder);
return $cache->remember($key, $this... | Gets the model results.
@param QueryCacheBuilder $builder
@param array $columns
@return Collection | entailment |
protected function getCache(QueryCacheBuilder $builder)
{
return $this->isTaggable() ? Cache::store($this->store)->tags($this->getTag($builder)) : Cache::store($this->store);
} | Gets a Cache instance.
@return Cache | entailment |
protected function generateKey(QueryCacheBuilder $builder, array $columns)
{
$sql = $builder->select($columns)->toSql();
$whereClause = serialize($builder->getBindings());
return sha1($sql.$whereClause);
} | Generates the cache key.
@param QueryCacheBuilder $builder
@param array $columns
@return string | entailment |
public function flush($tag)
{
if ($this->isTaggable()) {
return Cache::tags($tag)->flush();
}
return Cache::flush();
} | Flushes the cache for a model.
@param $tag
@return mixed | entailment |
public function toObject($value)
{
if (!is_array($value)) {
throw new TypeCastException('Is not array');
}
foreach ($this->rules as $class => $rule) {
if ($this->isMatch($rule, $value)) {
return $this->createInstance($class, $value);
}
... | @param mixed $value Array
@return mixed Instance of registered class | entailment |
public function toArray($value)
{
if (!is_object($value)) {
throw new TypeCastException('Is not object');
}
foreach ($this->rules as $class => $rule)
{
if (get_class($value) === $class) {
return $this->createMap($class, $value);
}
... | @param mixed $value Instance of registered class
@return array | entailment |
private function isMatch(Rule $expected, array $value): bool
{
return 0 === count(array_diff(array_keys($expected->getReflectedMap()), array_keys($value)));
} | @param Rule $expected Transform rule
@param array $value Raw unknown value
@return bool | entailment |
private function createInstance(string $class, array $data)
{
$rule = $this->rules[$class];
$reflectionClass = new \ReflectionClass($class);
$object = $reflectionClass->newInstanceWithoutConstructor();
$reflectionObject = new \ReflectionObject($object);
foreach ($rule->getM... | @param string $class
@param array $data
@return object | entailment |
private function createMap(string $class, $object)
{
$rule = $this->rules[$class];
$reflectionObject = new \ReflectionObject($object);
$result = [];
foreach ($rule->getMap() as $property => $key) {
$reflectionProperty = $reflectionObject->getProperty($property);
... | @param string $class
@param object $object
@return array | entailment |
public function addRoutes(array $routes) : object
{
if (!(isset($routes["routes"]) && is_array($routes["routes"]))) {
throw new ConfigurationException("No routes found, missing key 'routes' in configuration array.");
}
foreach ($routes["routes"] as $route) {
if ($rou... | Add routes from an array where the array looks like this:
[
"mount" => null|string, // Where to mount the routes
"routes" => [ // All routes in this array
[
"info" => "Just say hi.",
"method" => null,
"path" => "hi",
"handler" => function () {
return "Hi.";
},
]
]
]
@throws ConfigurationException
@param arr... | entailment |
private function createMountPath(
string $mount1 = null,
string $mount2 = null
) {
$mount = null;
if ($mount1 && $mount2) {
$mount = rtrim($mount1, "/") . "/" . rtrim($mount2, "/");
return $mount;
}
if ($mount1) {
$mount = $mount1;... | Prepare the mount string from configuration, use $mount1 or $mount2,
the latter supersedes the first.
@param string $mount1 first suggestion to mount path.
@param string $mount2 second suggestion to mount path, ovverides
the first.
@return string|null as mount path. | entailment |
public function addRoute(
$method,
$mount = null,
$path = null,
$handler = null,
string $info = null
) : void {
if (!is_array($path)) {
$path = [$path];
}
foreach ($path as $thePath) {
$route = new Route();
$route->... | Add a route with a request method, a path rule to match and an action
as the callback. Adding several path rules (array) results in several
routes being created.
@param string|array $method as request method to support
@param string $mount prefix to $path
@param string|array $pat... | entailment |
public function addInternalRoute(
string $path = null,
$handler,
string $info = null
) : void {
$route = new Route();
$route->set(null, null, $path, $handler, $info);
$this->internalRoutes[$path] = $route;
} | Add an internal route to the router, this route is not exposed to the
browser and the end user.
@param string $path for this route
@param string|array|callable $handler for this path, callable or equal
@param string $info description of the route
@return void. | entailment |
public function handle($path, $method = null)
{
try {
$match = false;
foreach ($this->routes as $route) {
if ($route->match($path, $method)) {
$this->lastRoute = $route;
$match = true;
$results = $route->hand... | Handle the routes and match them towards the request, dispatch them
when a match is made. Each route handler may throw exceptions that
may redirect to an internal route for error handling.
Several routes can match and if the routehandler does not break
execution flow, the route matching will carry on.
Only the last rou... | entailment |
public function handleInternal(string $path, string $message = null)
{
$route = $this->internalRoutes[$path]
?? $this->internalRoutes[null]
?? null;
if (!$route) {
throw new NotFoundException("No internal route to handle: " . $path);
}
$this->err... | Handle an internal route, the internal routes are not exposed to the
end user.
@param string $path for this route.
@param string $message with additional details.
@throws \Anax\Route\Exception\NotFoundException
@return mixed from the route handler. | entailment |
public function addController($mount = null, $handler = null, $info = null)
{
$this->addRoute(null, $mount, null, $handler, $info);
} | Add a route having a controller as a handler.
@param string|array $mount point for this controller.
@param string|callable $handler a callback handler for the controller.
@param string $info description of the route.
@return void. | entailment |
public function any($method = null, $path = null, $handler = null, $info = null)
{
$this->addRoute($method, null, $path, $handler, $info);
} | Add a route to the router by its method(s), path(s) and a callback.
@param string|array $method as request method to support
@param string|array $path for this route.
@param string|callable $handler a callback handler for the route.
@param string $info description of the route
@return void. | entailment |
public function add($path = null, $handler = null, $info = null)
{
$this->addRoute(null, null, $path, $handler, $info);
} | Add a route to the router by its path(s) and a callback for any
request method .
@param string|array $path for this route.
@param string|callable $handler a callback handler for the route.
@param string $info description of the route
@return void | entailment |
public function always($handler, $info = null)
{
$this->addRoute(null, null, null, $handler, $info);
} | Add a default route which will be applied for any path and any
request method.
@param string|callable $handler a callback handler for the route.
@param string $info description of the route
@return void | entailment |
public function all($method, $handler, $info = null)
{
$this->addRoute($method, null, null, $handler, $info);
} | Add a default route which will be applied for any path, if the choosen
request method is matching.
@param string|array $method as request method to support
@param string|callable $handler a callback handler for the route.
@param string $info description of the route
@return void | entailment |
public function get($path, $handler, $info = null)
{
$this->addRoute(["GET"], null, $path, $handler, $info);
} | Shortcut to add a GET route for the http request method GET.
@param string|array $path for this route.
@param string|callable $handler a callback handler for the route.
@param string $info description of the route
@return void | entailment |
public function post($path, $handler, $info = null)
{
$this->addRoute(["POST"], null, $path, $handler, $info);
} | Shortcut to add a POST route for the http request method POST.
@param string|array $path for this route.
@param string|callable $handler a callback handler for the route.
@param string $info description of the route
@return void | entailment |
public function put($path, $handler, $info = null)
{
$this->addRoute(["PUT"], null, $path, $handler, $info);
} | Shortcut to add a PUT route for the http request method PUT.
@param string|array $path for this route.
@param string|callable $handler a callback handler for the route.
@param string $info description of the route
@return void | entailment |
public function patch($path, $handler, $info = null)
{
$this->addRoute(["PATCH"], null, $path, $handler, $info);
} | Shortcut to add a PATCH route for the http request method PATCH.
@param string|array $path for this route.
@param string|callable $handler a callback handler for the route.
@param string $info description of the route
@return void | entailment |
public function delete($path, $handler, $info = null)
{
$this->addRoute(["DELETE"], null, $path, $handler, $info);
} | Shortcut to add a DELETE route for the http request method DELETE.
@param string|array $path for this route.
@param string|callable $handler a callback handler for the route.
@param string $info description of the route
@return void | entailment |
public function options($path, $handler, $info = null)
{
$this->addRoute(["OPTIONS"], null, $path, $handler, $info);
} | Shortcut to add a OPTIONS route for the http request method OPTIONS.
@param string|array $path for this route.
@param string|callable $handler a callback handler for the route.
@param string $info description of the route
@return void | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.