repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_documentation_string
stringlengths 1
47.2k
| func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|
ncou/Chiron-Pipeline | src/Pipeline.php | Pipeline.pipeOnTop | public function pipeOnTop($middleware): self
{
array_unshift($this->middlewares, $this->decorate($middleware));
return $this;
} | php | public function pipeOnTop($middleware): self
{
array_unshift($this->middlewares, $this->decorate($middleware));
return $this;
} | TODO : créer aussi une méthode pipeOnTopIf() | https://github.com/ncou/Chiron-Pipeline/blob/dda743d797bc85c24a947dc332f3cfb41f6bf05a/src/Pipeline.php#L94-L99 |
ncou/Chiron-Pipeline | src/Pipeline.php | Pipeline.decorate | private function decorate($middleware): MiddlewareInterface
{
if ($middleware instanceof MiddlewareInterface) {
return $middleware;
} elseif ($middleware instanceof RequestHandlerInterface) {
return new RequestHandlerMiddleware($middleware);
} elseif ($middleware instanceof ResponseInterface) {
return new FixedResponseMiddleware($middleware);
} elseif (is_callable($middleware)) {
return new CallableMiddleware($middleware);
} elseif (is_string($middleware)) {
return new LazyLoadingMiddleware($middleware, $this->container);
} else {
throw new InvalidArgumentException(sprintf(
'Middleware "%s" is neither a string service name, an autoloadable class name, a PHP callable, or an instance of %s/%s/%s',
is_object($middleware) ? get_class($middleware) : gettype($middleware),
MiddlewareInterface::class, ResponseInterface::class, RequestHandlerInterface::class
));
}
} | php | private function decorate($middleware): MiddlewareInterface
{
if ($middleware instanceof MiddlewareInterface) {
return $middleware;
} elseif ($middleware instanceof RequestHandlerInterface) {
return new RequestHandlerMiddleware($middleware);
} elseif ($middleware instanceof ResponseInterface) {
return new FixedResponseMiddleware($middleware);
} elseif (is_callable($middleware)) {
return new CallableMiddleware($middleware);
} elseif (is_string($middleware)) {
return new LazyLoadingMiddleware($middleware, $this->container);
} else {
throw new InvalidArgumentException(sprintf(
'Middleware "%s" is neither a string service name, an autoloadable class name, a PHP callable, or an instance of %s/%s/%s',
is_object($middleware) ? get_class($middleware) : gettype($middleware),
MiddlewareInterface::class, ResponseInterface::class, RequestHandlerInterface::class
));
}
} | TODO : gérer les tableaux de ces type (string|callable...etc) | https://github.com/ncou/Chiron-Pipeline/blob/dda743d797bc85c24a947dc332f3cfb41f6bf05a/src/Pipeline.php#L121-L140 |
ncou/Chiron-Pipeline | src/Pipeline.php | Pipeline.handle | public function handle(ServerRequestInterface $request): ResponseInterface
{
if ($this->index >= count($this->middlewares)) {
throw new OutOfBoundsException('Reached end of middleware stack. Does your controller return a response ?');
}
$middleware = $this->middlewares[$this->index++];
return $middleware->process($request, $this);
} | php | public function handle(ServerRequestInterface $request): ResponseInterface
{
if ($this->index >= count($this->middlewares)) {
throw new OutOfBoundsException('Reached end of middleware stack. Does your controller return a response ?');
}
$middleware = $this->middlewares[$this->index++];
return $middleware->process($request, $this);
} | Execute the middleware stack.
@param ServerRequestInterface $request
@return ResponseInterface | https://github.com/ncou/Chiron-Pipeline/blob/dda743d797bc85c24a947dc332f3cfb41f6bf05a/src/Pipeline.php#L149-L158 |
mlocati/concrete5-translation-library | src/Parser/Cif.php | Cif.parseDirectoryDo | protected function parseDirectoryDo(\Gettext\Translations $translations, $rootDirectory, $relativePath, $subParsersFilter, $exclude3rdParty)
{
$prefix = ($relativePath === '') ? '' : "$relativePath/";
foreach (array_merge(array(''), $this->getDirectoryStructure($rootDirectory, $exclude3rdParty)) as $child) {
$shownDirectory = $prefix.(($child === '') ? '' : "$child/");
$fullDirectoryPath = ($child === '') ? $rootDirectory : "$rootDirectory/$child";
$contents = @scandir($fullDirectoryPath);
if ($contents === false) {
throw new \Exception("Unable to parse directory $fullDirectoryPath");
}
foreach ($contents as $file) {
if ($file[0] !== '.') {
$fullFilePath = "$fullDirectoryPath/$file";
if (preg_match('/^(.*)\.xml$/', $file) && is_file($fullFilePath)) {
static::parseXml($translations, $fullFilePath, $shownDirectory.$file);
}
}
}
}
} | php | protected function parseDirectoryDo(\Gettext\Translations $translations, $rootDirectory, $relativePath, $subParsersFilter, $exclude3rdParty)
{
$prefix = ($relativePath === '') ? '' : "$relativePath/";
foreach (array_merge(array(''), $this->getDirectoryStructure($rootDirectory, $exclude3rdParty)) as $child) {
$shownDirectory = $prefix.(($child === '') ? '' : "$child/");
$fullDirectoryPath = ($child === '') ? $rootDirectory : "$rootDirectory/$child";
$contents = @scandir($fullDirectoryPath);
if ($contents === false) {
throw new \Exception("Unable to parse directory $fullDirectoryPath");
}
foreach ($contents as $file) {
if ($file[0] !== '.') {
$fullFilePath = "$fullDirectoryPath/$file";
if (preg_match('/^(.*)\.xml$/', $file) && is_file($fullFilePath)) {
static::parseXml($translations, $fullFilePath, $shownDirectory.$file);
}
}
}
}
} | {@inheritdoc}
@see \C5TL\Parser::parseDirectoryDo() | https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/Cif.php#L35-L54 |
mlocati/concrete5-translation-library | src/Parser/Cif.php | Cif.parseXml | private static function parseXml(\Gettext\Translations $translations, $realPath, $shownPath)
{
if (@filesize($realPath) !== 0) {
$xml = new \DOMDocument();
if ($xml->load($realPath) === false) {
global $php_errormsg;
if (isset($php_errormsg) && $php_errormsg) {
throw new \Exception("Error loading '$realPath': $php_errormsg");
} else {
throw new \Exception("Error loading '$realPath'");
}
}
switch ($xml->documentElement->tagName) {
case 'concrete5-cif':
case 'styles':
static::parseXmlNode($translations, $shownPath, $xml->documentElement, '');
break;
}
}
} | php | private static function parseXml(\Gettext\Translations $translations, $realPath, $shownPath)
{
if (@filesize($realPath) !== 0) {
$xml = new \DOMDocument();
if ($xml->load($realPath) === false) {
global $php_errormsg;
if (isset($php_errormsg) && $php_errormsg) {
throw new \Exception("Error loading '$realPath': $php_errormsg");
} else {
throw new \Exception("Error loading '$realPath'");
}
}
switch ($xml->documentElement->tagName) {
case 'concrete5-cif':
case 'styles':
static::parseXmlNode($translations, $shownPath, $xml->documentElement, '');
break;
}
}
} | Parses an XML CIF file and extracts translatable strings.
@param \Gettext\Translations $translations
@param string $realPath
@param string $shownPath
@throws \Exception | https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/Cif.php#L65-L84 |
mlocati/concrete5-translation-library | src/Parser/Cif.php | Cif.parseXmlNode | private static function parseXmlNode(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $prePath)
{
$nodeClass = get_class($node);
switch ($nodeClass) {
case 'DOMElement':
break;
case 'DOMText':
case 'DOMCdataSection':
case 'DOMComment':
return;
default:
throw new \Exception("Unknown node class '$nodeClass' in '$filenameRel'");
}
$path = $prePath.'/'.$node->tagName;
$childnodesLimit = null;
switch ($path) {
case '/concrete5-cif':
case '/concrete5-cif/attributecategories':
case '/concrete5-cif/attributecategories/category':
case '/concrete5-cif/attributekeys':
case '/concrete5-cif/attributekeys/attributekey/type':
case '/concrete5-cif/attributekeys/attributekey/type/options':
case '/concrete5-cif/attributesets':
case '/concrete5-cif/attributesets/attributeset/attributekey':
case '/concrete5-cif/attributetypes':
case '/concrete5-cif/attributetypes/attributetype/categories':
case '/concrete5-cif/attributetypes/attributetype/categories/category':
case '/concrete5-cif/blocktypes':
case '/concrete5-cif/blocktypes/blocktype':
case '/concrete5-cif/blocktypesets':
case '/concrete5-cif/blocktypesets/blocktypeset/blocktype':
case '/concrete5-cif/composercontroltypes':
case '/concrete5-cif/conversationeditors':
case '/concrete5-cif/conversationratingtypes':
case '/concrete5-cif/gatheringitemtemplates':
case '/concrete5-cif/gatheringitemtemplates/gatheringitemtemplate/feature':
case '/concrete5-cif/gatheringsources':
case '/concrete5-cif/geolocators':
case '/concrete5-cif/imageeditor_components':
case '/concrete5-cif/imageeditor_controlsets':
case '/concrete5-cif/imageeditor_filters':
case '/concrete5-cif/jobs':
case '/concrete5-cif/jobs/job':
case '/concrete5-cif/jobsets':
case '/concrete5-cif/jobsets/jobset/job':
case '/concrete5-cif/pagefeeds':
case '/concrete5-cif/pages':
case '/concrete5-cif/pages/page/area/block/arealayout':
case '/concrete5-cif/pages/page/area/block/arealayout/columns':
case '/concrete5-cif/pages/page/area/block/arealayout/columns/column':
case '/concrete5-cif/pages/page/area/block/arealayout/columns/column/block/data':
case '/concrete5-cif/pages/page/area/block/data':
case '/concrete5-cif/pages/page/area/block/stack':
case '/concrete5-cif/pages/page/attributes':
case '/concrete5-cif/pages/page/attributes/attributekey':
case '/concrete5-cif/pages/page/attributes/attributekey/topics':
case '/concrete5-cif/pages/page/attributes/attributekey/topics/topic':
case '/concrete5-cif/pages/page/attributes/attributekey/value':
case '/concrete5-cif/pages/page/attributes/attributekey/value/fID':
case '/concrete5-cif/pages/page/attributes/attributekey/value/option':
case '/concrete5-cif/pagetemplates':
case '/concrete5-cif/pagetypecomposercontroltypes':
case '/concrete5-cif/pagetypepublishtargettypes':
case '/concrete5-cif/pagetypes':
case '/concrete5-cif/pagetypes/pagetype/composer':
case '/concrete5-cif/pagetypes/pagetype/composer/formlayout':
case '/concrete5-cif/pagetypes/pagetype/composer/items':
case '/concrete5-cif/pagetypes/pagetype/composer/items/attributekey':
case '/concrete5-cif/pagetypes/pagetype/composer/output':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate/page':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate/page/area/blocks':
case '/concrete5-cif/pagetypes/pagetype/formlayout':
case '/concrete5-cif/pagetypes/pagetype/output':
case '/concrete5-cif/pagetypes/pagetype/output/pagetemplate':
case '/concrete5-cif/pagetypes/pagetype/page/area/block/data':
case '/concrete5-cif/pagetypes/pagetype/page/attributes':
case '/concrete5-cif/pagetypes/pagetype/page/attributes/attribute':
case '/concrete5-cif/pagetypes/pagetype/page/attributes/attributekey':
case '/concrete5-cif/pagetypes/pagetype/pagetemplates':
case '/concrete5-cif/pagetypes/pagetype/pagetemplates/pagetemplate':
case '/concrete5-cif/pagetypes/pagetype/target':
case '/concrete5-cif/permissionaccessentitytypes':
case '/concrete5-cif/permissionaccessentitytypes/permissionaccessentitytype/categories':
case '/concrete5-cif/permissionaccessentitytypes/permissionaccessentitytype/categories/category':
case '/concrete5-cif/permissioncategories':
case '/concrete5-cif/permissioncategories/category':
case '/concrete5-cif/permissionkeys':
case '/concrete5-cif/singlepages':
case '/concrete5-cif/singlepages/page/area/blocks':
case '/concrete5-cif/singlepages/page/attributes':
case '/concrete5-cif/singlepages/page/attributes/attributekey':
case '/concrete5-cif/stacks':
case '/concrete5-cif/stacks/stack/area/block/data':
case '/concrete5-cif/stacks/stack/area/block/link':
case '/concrete5-cif/stacks/stack/area/blocks':
case '/concrete5-cif/systemcaptcha':
case '/concrete5-cif/systemcontenteditorsnippets':
case '/concrete5-cif/taskpermissions':
case '/concrete5-cif/taskpermissions/taskpermission/access':
case '/concrete5-cif/taskpermissions/taskpermission/access/group':
case '/concrete5-cif/themes':
case '/concrete5-cif/themes/theme':
case '/concrete5-cif/thumbnailtypes':
case '/concrete5-cif/trees':
case '/concrete5-cif/trees/tree':
case '/concrete5-cif/workflowprogresscategories':
case '/concrete5-cif/workflowprogresscategories/category':
case '/concrete5-cif/workflowtypes':
case '/styles':
// Skip this node
break;
case '/concrete5-cif/pages/page/area/block/data/record':
// Skip this node and *almost* all its children
$childnodesLimit = array('title');
break;
case '/concrete5-cif/pagefeeds/feed':
// Skip this node and *almost* all its children
$childnodesLimit = array('title', 'description');
break;
case '/concrete5-cif/banned_words':
case '/concrete5-cif/config':
case '/concrete5-cif/expressentities':
case '/concrete5-cif/featurecategories':
case '/concrete5-cif/features':
case '/concrete5-cif/flag_types':
case '/concrete5-cif/gatheringitemtemplatetypes':
case '/concrete5-cif/geolocators/geolocator/option':
case '/concrete5-cif/pages/page/area/block/arealayout/columns/column/block/data/record':
case '/concrete5-cif/pages/page/area/blocks':
case '/concrete5-cif/pages/page/area/style':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate/page/area/block':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate/page/area/blocks/block':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate/page/area/style':
case '/concrete5-cif/pagetypes/pagetype/page/area/block/data/record':
case '/concrete5-cif/permissionkeys/permissionkey/access':
case '/concrete5-cif/singlepages/page/area/blocks/block':
case '/concrete5-cif/sociallinks':
case '/concrete5-cif/stacks/stack/area/block/data/record':
case '/concrete5-cif/stacks/stack/area/blocks/block':
// Skip this node and its children
return;
case '/concrete5-cif/pages/page/area/block':
case '/concrete5-cif/pages/page/area/block/arealayout/columns/column/block':
case '/concrete5-cif/pagetypes/pagetype':
case '/concrete5-cif/pagetypes/pagetype/composer/items/block':
case '/concrete5-cif/pagetypes/pagetype/page/area/block':
case '/concrete5-cif/stacks/stack':
case '/concrete5-cif/stacks/stack/area':
case '/concrete5-cif/stacks/stack/area/block':
case '/concrete5-cif/systemcaptcha/library':
case '/concrete5-cif/workflowtypes/workflowtype':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name');
break;
case '/styles/set':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'StyleSetName');
break;
case '/styles/set/style':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'StyleName');
break;
case '/concrete5-cif/attributekeys/attributekey':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'AttributeKeyName');
break;
case '/concrete5-cif/attributekeys/attributekey/tree':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'TreeName');
break;
case '/concrete5-cif/thumbnailtypes/thumbnailtype':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ThumbnailTypeName');
break;
case '/concrete5-cif/trees/tree/category':
case '/concrete5-cif/trees/tree/topic_category':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'TreeNodeCategoryName');
break;
case '/concrete5-cif/trees/tree/category/topic':
case '/concrete5-cif/trees/tree/topic':
case '/concrete5-cif/trees/tree/topic_category/topic':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'TopicName');
break;
case '/concrete5-cif/attributesets/attributeset':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'AttributeSetName');
break;
case '/concrete5-cif/attributetypes/attributetype':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'AttributeTypeName');
break;
case '/concrete5-cif/permissionaccessentitytypes/permissionaccessentitytype':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PermissionAccessEntityTypeName');
break;
case '/concrete5-cif/systemcontenteditorsnippets/snippet':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'SystemContentEditorSnippetName');
break;
case '/concrete5-cif/blocktypesets/blocktypeset':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'BlockTypeSetName');
break;
case '/concrete5-cif/composercontroltypes/type':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ComposerControlTypeName');
break;
case '/concrete5-cif/gatheringsources/gatheringsource':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'GatheringDataSourceName');
break;
case '/concrete5-cif/gatheringitemtemplates/gatheringitemtemplate':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'GatheringItemTemplateName');
break;
case '/concrete5-cif/conversationeditors/editor':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ConversationEditorName');
break;
case '/concrete5-cif/conversationratingtypes/conversationratingtype':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ConversationRatingTypeName');
break;
case '/concrete5-cif/pages/page':
case '/concrete5-cif/pagetypes/pagetype/page':
case '/concrete5-cif/singlepages/page':
case '/concrete5-cif/taskpermissions/taskpermission':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name');
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'description');
break;
case '/concrete5-cif/permissionkeys/permissionkey':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PermissionKeyName');
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'description', 'PermissionKeyDescription');
break;
case '/concrete5-cif/pages/page/area/block/data/record/title':
static::parseXmlNodeValue($translations, $filenameRel, $node);
break;
case '/concrete5-cif/pagefeeds/feed/title':
static::parseXmlNodeValue($translations, $filenameRel, $node, 'FeedTitle');
break;
case '/concrete5-cif/pagefeeds/feed/description':
static::parseXmlNodeValue($translations, $filenameRel, $node, 'FeedDescription');
break;
case '/concrete5-cif/singlepages/page/attributes/attributekey/value':
switch ($node->parentNode->getAttribute('handle')) {
case 'meta_keywords':
static::readXmlPageKeywords($translations, $filenameRel, $node, $node->parentNode->parentNode->parentNode->getAttribute('path'));
break;
}
break;
case '/concrete5-cif/jobsets/jobset':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'JobSetName');
break;
case '/concrete5-cif/pages/page/area':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate/page/area':
case '/concrete5-cif/pagetypes/pagetype/page/area':
case '/concrete5-cif/singlepages/page/area':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'AreaName');
break;
case '/concrete5-cif/pagetypes/pagetype/output/pagetemplate/page':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTemplatePageName');
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'description', 'PageTemplatePageDescription');
break;
case '/concrete5-cif/attributekeys/attributekey/type/options/option':
$attributeKeyType = (string) $node/*option*/->parentNode/*options*/->parentNode/*type*/->parentNode/*attributekey*/->getAttribute('type');
switch ($attributeKeyType) {
case 'select':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'value', 'SelectAttributeValue');
break;
}
break;
case '/concrete5-cif/pagetemplates/pagetemplate':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTemplateName');
break;
case '/concrete5-cif/imageeditor_controlsets/imageeditor_controlset':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ImageEditorControlSetName');
break;
case '/concrete5-cif/imageeditor_components/imageeditor_component':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ImageEditorComponentName');
break;
case '/concrete5-cif/imageeditor_filters/imageeditor_filter':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ImageEditorFilterName');
break;
case '/concrete5-cif/pagetypepublishtargettypes/type':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTypePublishTargetTypeName');
break;
case '/concrete5-cif/pagetypecomposercontroltypes/type':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTypeComposerControlTypeName');
break;
case '/concrete5-cif/pagetypes/pagetype/formlayout/set':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTypeFormLayoutSetName');
break;
case '/concrete5-cif/pagetypes/pagetype/formlayout/set':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTypeFormLayoutSetName');
break;
case '/concrete5-cif/pagetypes/pagetype/composer/formlayout/set':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTypeComposerFormLayoutSetName');
break;
case '/concrete5-cif/pagetypes/pagetype/formlayout/set/control':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'custom-label', 'PageTypeFormLayoutSetControlCustomLabel');
break;
case '/concrete5-cif/pagetypes/pagetype/composer/formlayout/set/control':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'custom-label', 'PageTypeComposerFormLayoutSetControlCustomLabel');
break;
case '/concrete5-cif/geolocators/geolocator':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'GeolocatorName');
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'description', 'GeolocatorDescription');
break;
default:
if (strpos($filenameRel, 'packages/') === 0) {
return;
}
throw new \Exception('Unknown tag name '.$path.' in '.$filenameRel."\n\nNode:\n".$node->ownerDocument->saveXML($node));
}
if ($node->hasChildNodes()) {
foreach ($node->childNodes as $child) {
if ((!isset($childnodesLimit)) || (is_a($child, '\DOMElement') && in_array((string) $child->tagName, $childnodesLimit, true))) {
static::parseXmlNode($translations, $filenameRel, $child, $path);
}
}
}
} | php | private static function parseXmlNode(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $prePath)
{
$nodeClass = get_class($node);
switch ($nodeClass) {
case 'DOMElement':
break;
case 'DOMText':
case 'DOMCdataSection':
case 'DOMComment':
return;
default:
throw new \Exception("Unknown node class '$nodeClass' in '$filenameRel'");
}
$path = $prePath.'/'.$node->tagName;
$childnodesLimit = null;
switch ($path) {
case '/concrete5-cif':
case '/concrete5-cif/attributecategories':
case '/concrete5-cif/attributecategories/category':
case '/concrete5-cif/attributekeys':
case '/concrete5-cif/attributekeys/attributekey/type':
case '/concrete5-cif/attributekeys/attributekey/type/options':
case '/concrete5-cif/attributesets':
case '/concrete5-cif/attributesets/attributeset/attributekey':
case '/concrete5-cif/attributetypes':
case '/concrete5-cif/attributetypes/attributetype/categories':
case '/concrete5-cif/attributetypes/attributetype/categories/category':
case '/concrete5-cif/blocktypes':
case '/concrete5-cif/blocktypes/blocktype':
case '/concrete5-cif/blocktypesets':
case '/concrete5-cif/blocktypesets/blocktypeset/blocktype':
case '/concrete5-cif/composercontroltypes':
case '/concrete5-cif/conversationeditors':
case '/concrete5-cif/conversationratingtypes':
case '/concrete5-cif/gatheringitemtemplates':
case '/concrete5-cif/gatheringitemtemplates/gatheringitemtemplate/feature':
case '/concrete5-cif/gatheringsources':
case '/concrete5-cif/geolocators':
case '/concrete5-cif/imageeditor_components':
case '/concrete5-cif/imageeditor_controlsets':
case '/concrete5-cif/imageeditor_filters':
case '/concrete5-cif/jobs':
case '/concrete5-cif/jobs/job':
case '/concrete5-cif/jobsets':
case '/concrete5-cif/jobsets/jobset/job':
case '/concrete5-cif/pagefeeds':
case '/concrete5-cif/pages':
case '/concrete5-cif/pages/page/area/block/arealayout':
case '/concrete5-cif/pages/page/area/block/arealayout/columns':
case '/concrete5-cif/pages/page/area/block/arealayout/columns/column':
case '/concrete5-cif/pages/page/area/block/arealayout/columns/column/block/data':
case '/concrete5-cif/pages/page/area/block/data':
case '/concrete5-cif/pages/page/area/block/stack':
case '/concrete5-cif/pages/page/attributes':
case '/concrete5-cif/pages/page/attributes/attributekey':
case '/concrete5-cif/pages/page/attributes/attributekey/topics':
case '/concrete5-cif/pages/page/attributes/attributekey/topics/topic':
case '/concrete5-cif/pages/page/attributes/attributekey/value':
case '/concrete5-cif/pages/page/attributes/attributekey/value/fID':
case '/concrete5-cif/pages/page/attributes/attributekey/value/option':
case '/concrete5-cif/pagetemplates':
case '/concrete5-cif/pagetypecomposercontroltypes':
case '/concrete5-cif/pagetypepublishtargettypes':
case '/concrete5-cif/pagetypes':
case '/concrete5-cif/pagetypes/pagetype/composer':
case '/concrete5-cif/pagetypes/pagetype/composer/formlayout':
case '/concrete5-cif/pagetypes/pagetype/composer/items':
case '/concrete5-cif/pagetypes/pagetype/composer/items/attributekey':
case '/concrete5-cif/pagetypes/pagetype/composer/output':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate/page':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate/page/area/blocks':
case '/concrete5-cif/pagetypes/pagetype/formlayout':
case '/concrete5-cif/pagetypes/pagetype/output':
case '/concrete5-cif/pagetypes/pagetype/output/pagetemplate':
case '/concrete5-cif/pagetypes/pagetype/page/area/block/data':
case '/concrete5-cif/pagetypes/pagetype/page/attributes':
case '/concrete5-cif/pagetypes/pagetype/page/attributes/attribute':
case '/concrete5-cif/pagetypes/pagetype/page/attributes/attributekey':
case '/concrete5-cif/pagetypes/pagetype/pagetemplates':
case '/concrete5-cif/pagetypes/pagetype/pagetemplates/pagetemplate':
case '/concrete5-cif/pagetypes/pagetype/target':
case '/concrete5-cif/permissionaccessentitytypes':
case '/concrete5-cif/permissionaccessentitytypes/permissionaccessentitytype/categories':
case '/concrete5-cif/permissionaccessentitytypes/permissionaccessentitytype/categories/category':
case '/concrete5-cif/permissioncategories':
case '/concrete5-cif/permissioncategories/category':
case '/concrete5-cif/permissionkeys':
case '/concrete5-cif/singlepages':
case '/concrete5-cif/singlepages/page/area/blocks':
case '/concrete5-cif/singlepages/page/attributes':
case '/concrete5-cif/singlepages/page/attributes/attributekey':
case '/concrete5-cif/stacks':
case '/concrete5-cif/stacks/stack/area/block/data':
case '/concrete5-cif/stacks/stack/area/block/link':
case '/concrete5-cif/stacks/stack/area/blocks':
case '/concrete5-cif/systemcaptcha':
case '/concrete5-cif/systemcontenteditorsnippets':
case '/concrete5-cif/taskpermissions':
case '/concrete5-cif/taskpermissions/taskpermission/access':
case '/concrete5-cif/taskpermissions/taskpermission/access/group':
case '/concrete5-cif/themes':
case '/concrete5-cif/themes/theme':
case '/concrete5-cif/thumbnailtypes':
case '/concrete5-cif/trees':
case '/concrete5-cif/trees/tree':
case '/concrete5-cif/workflowprogresscategories':
case '/concrete5-cif/workflowprogresscategories/category':
case '/concrete5-cif/workflowtypes':
case '/styles':
// Skip this node
break;
case '/concrete5-cif/pages/page/area/block/data/record':
// Skip this node and *almost* all its children
$childnodesLimit = array('title');
break;
case '/concrete5-cif/pagefeeds/feed':
// Skip this node and *almost* all its children
$childnodesLimit = array('title', 'description');
break;
case '/concrete5-cif/banned_words':
case '/concrete5-cif/config':
case '/concrete5-cif/expressentities':
case '/concrete5-cif/featurecategories':
case '/concrete5-cif/features':
case '/concrete5-cif/flag_types':
case '/concrete5-cif/gatheringitemtemplatetypes':
case '/concrete5-cif/geolocators/geolocator/option':
case '/concrete5-cif/pages/page/area/block/arealayout/columns/column/block/data/record':
case '/concrete5-cif/pages/page/area/blocks':
case '/concrete5-cif/pages/page/area/style':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate/page/area/block':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate/page/area/blocks/block':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate/page/area/style':
case '/concrete5-cif/pagetypes/pagetype/page/area/block/data/record':
case '/concrete5-cif/permissionkeys/permissionkey/access':
case '/concrete5-cif/singlepages/page/area/blocks/block':
case '/concrete5-cif/sociallinks':
case '/concrete5-cif/stacks/stack/area/block/data/record':
case '/concrete5-cif/stacks/stack/area/blocks/block':
// Skip this node and its children
return;
case '/concrete5-cif/pages/page/area/block':
case '/concrete5-cif/pages/page/area/block/arealayout/columns/column/block':
case '/concrete5-cif/pagetypes/pagetype':
case '/concrete5-cif/pagetypes/pagetype/composer/items/block':
case '/concrete5-cif/pagetypes/pagetype/page/area/block':
case '/concrete5-cif/stacks/stack':
case '/concrete5-cif/stacks/stack/area':
case '/concrete5-cif/stacks/stack/area/block':
case '/concrete5-cif/systemcaptcha/library':
case '/concrete5-cif/workflowtypes/workflowtype':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name');
break;
case '/styles/set':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'StyleSetName');
break;
case '/styles/set/style':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'StyleName');
break;
case '/concrete5-cif/attributekeys/attributekey':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'AttributeKeyName');
break;
case '/concrete5-cif/attributekeys/attributekey/tree':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'TreeName');
break;
case '/concrete5-cif/thumbnailtypes/thumbnailtype':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ThumbnailTypeName');
break;
case '/concrete5-cif/trees/tree/category':
case '/concrete5-cif/trees/tree/topic_category':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'TreeNodeCategoryName');
break;
case '/concrete5-cif/trees/tree/category/topic':
case '/concrete5-cif/trees/tree/topic':
case '/concrete5-cif/trees/tree/topic_category/topic':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'TopicName');
break;
case '/concrete5-cif/attributesets/attributeset':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'AttributeSetName');
break;
case '/concrete5-cif/attributetypes/attributetype':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'AttributeTypeName');
break;
case '/concrete5-cif/permissionaccessentitytypes/permissionaccessentitytype':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PermissionAccessEntityTypeName');
break;
case '/concrete5-cif/systemcontenteditorsnippets/snippet':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'SystemContentEditorSnippetName');
break;
case '/concrete5-cif/blocktypesets/blocktypeset':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'BlockTypeSetName');
break;
case '/concrete5-cif/composercontroltypes/type':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ComposerControlTypeName');
break;
case '/concrete5-cif/gatheringsources/gatheringsource':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'GatheringDataSourceName');
break;
case '/concrete5-cif/gatheringitemtemplates/gatheringitemtemplate':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'GatheringItemTemplateName');
break;
case '/concrete5-cif/conversationeditors/editor':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ConversationEditorName');
break;
case '/concrete5-cif/conversationratingtypes/conversationratingtype':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ConversationRatingTypeName');
break;
case '/concrete5-cif/pages/page':
case '/concrete5-cif/pagetypes/pagetype/page':
case '/concrete5-cif/singlepages/page':
case '/concrete5-cif/taskpermissions/taskpermission':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name');
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'description');
break;
case '/concrete5-cif/permissionkeys/permissionkey':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PermissionKeyName');
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'description', 'PermissionKeyDescription');
break;
case '/concrete5-cif/pages/page/area/block/data/record/title':
static::parseXmlNodeValue($translations, $filenameRel, $node);
break;
case '/concrete5-cif/pagefeeds/feed/title':
static::parseXmlNodeValue($translations, $filenameRel, $node, 'FeedTitle');
break;
case '/concrete5-cif/pagefeeds/feed/description':
static::parseXmlNodeValue($translations, $filenameRel, $node, 'FeedDescription');
break;
case '/concrete5-cif/singlepages/page/attributes/attributekey/value':
switch ($node->parentNode->getAttribute('handle')) {
case 'meta_keywords':
static::readXmlPageKeywords($translations, $filenameRel, $node, $node->parentNode->parentNode->parentNode->getAttribute('path'));
break;
}
break;
case '/concrete5-cif/jobsets/jobset':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'JobSetName');
break;
case '/concrete5-cif/pages/page/area':
case '/concrete5-cif/pagetypes/pagetype/composer/output/pagetemplate/page/area':
case '/concrete5-cif/pagetypes/pagetype/page/area':
case '/concrete5-cif/singlepages/page/area':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'AreaName');
break;
case '/concrete5-cif/pagetypes/pagetype/output/pagetemplate/page':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTemplatePageName');
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'description', 'PageTemplatePageDescription');
break;
case '/concrete5-cif/attributekeys/attributekey/type/options/option':
$attributeKeyType = (string) $node/*option*/->parentNode/*options*/->parentNode/*type*/->parentNode/*attributekey*/->getAttribute('type');
switch ($attributeKeyType) {
case 'select':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'value', 'SelectAttributeValue');
break;
}
break;
case '/concrete5-cif/pagetemplates/pagetemplate':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTemplateName');
break;
case '/concrete5-cif/imageeditor_controlsets/imageeditor_controlset':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ImageEditorControlSetName');
break;
case '/concrete5-cif/imageeditor_components/imageeditor_component':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ImageEditorComponentName');
break;
case '/concrete5-cif/imageeditor_filters/imageeditor_filter':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'ImageEditorFilterName');
break;
case '/concrete5-cif/pagetypepublishtargettypes/type':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTypePublishTargetTypeName');
break;
case '/concrete5-cif/pagetypecomposercontroltypes/type':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTypeComposerControlTypeName');
break;
case '/concrete5-cif/pagetypes/pagetype/formlayout/set':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTypeFormLayoutSetName');
break;
case '/concrete5-cif/pagetypes/pagetype/formlayout/set':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTypeFormLayoutSetName');
break;
case '/concrete5-cif/pagetypes/pagetype/composer/formlayout/set':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'PageTypeComposerFormLayoutSetName');
break;
case '/concrete5-cif/pagetypes/pagetype/formlayout/set/control':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'custom-label', 'PageTypeFormLayoutSetControlCustomLabel');
break;
case '/concrete5-cif/pagetypes/pagetype/composer/formlayout/set/control':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'custom-label', 'PageTypeComposerFormLayoutSetControlCustomLabel');
break;
case '/concrete5-cif/geolocators/geolocator':
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'name', 'GeolocatorName');
static::readXmlNodeAttribute($translations, $filenameRel, $node, 'description', 'GeolocatorDescription');
break;
default:
if (strpos($filenameRel, 'packages/') === 0) {
return;
}
throw new \Exception('Unknown tag name '.$path.' in '.$filenameRel."\n\nNode:\n".$node->ownerDocument->saveXML($node));
}
if ($node->hasChildNodes()) {
foreach ($node->childNodes as $child) {
if ((!isset($childnodesLimit)) || (is_a($child, '\DOMElement') && in_array((string) $child->tagName, $childnodesLimit, true))) {
static::parseXmlNode($translations, $filenameRel, $child, $path);
}
}
}
} | Parse an xml node and retrieves any associated POEntry.
@param \Gettext\Translations $translations Will be populated with found entries
@param string $filenameRel The relative file name of the xml file being read
@param \DOMNode $node The current node
@param string $prePath The path of the node containing the current node
@throws \Exception Throws an \Exception in case of errors | https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/Cif.php#L94-L400 |
mlocati/concrete5-translation-library | src/Parser/Cif.php | Cif.readXmlNodeAttribute | private static function readXmlNodeAttribute(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $attributeName, $context = '')
{
$value = (string) $node->getAttribute($attributeName);
if ($value !== '') {
$translation = $translations->insert($context, $value);
$translation->addReference($filenameRel, $node->getLineNo());
}
} | php | private static function readXmlNodeAttribute(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $attributeName, $context = '')
{
$value = (string) $node->getAttribute($attributeName);
if ($value !== '') {
$translation = $translations->insert($context, $value);
$translation->addReference($filenameRel, $node->getLineNo());
}
} | Parse a node attribute and create a POEntry item if it has a value.
@param \Gettext\Translations $translations Will be populated with found entries
@param string $filenameRel The relative file name of the xml file being read
@param \DOMNode $node The current node
@param string $attributeName The name of the attribute
@param string $context='' The translation context | https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/Cif.php#L409-L416 |
mlocati/concrete5-translation-library | src/Parser/Cif.php | Cif.readXmlPageKeywords | private static function readXmlPageKeywords(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $pageUrl)
{
$keywords = (string) $node->nodeValue;
if ($keywords !== '') {
$translation = $translations->insert('', $keywords);
$translation->addReference($filenameRel, $node->getLineNo());
$pageUrl = (string) $pageUrl;
if ($pageUrl !== '') {
$translation->addExtractedComment("Keywords for page $pageUrl");
}
}
} | php | private static function readXmlPageKeywords(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $pageUrl)
{
$keywords = (string) $node->nodeValue;
if ($keywords !== '') {
$translation = $translations->insert('', $keywords);
$translation->addReference($filenameRel, $node->getLineNo());
$pageUrl = (string) $pageUrl;
if ($pageUrl !== '') {
$translation->addExtractedComment("Keywords for page $pageUrl");
}
}
} | Parse a node attribute which contains the keywords for a page.
@param \Gettext\Translations $translations Will be populated with found entries
@param string $filenameRel The relative file name of the xml file being read
@param \DOMNode $node The current node
@param string $pageUrl The url of the page for which the keywords are for | https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/Cif.php#L424-L435 |
mlocati/concrete5-translation-library | src/Parser/Cif.php | Cif.parseXmlNodeValue | private static function parseXmlNodeValue(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $context = '')
{
$value = (string) $node->nodeValue;
if ($value !== '') {
$translation = $translations->insert($context, $value);
$translation->addReference($filenameRel, $node->getLineNo());
}
} | php | private static function parseXmlNodeValue(\Gettext\Translations $translations, $filenameRel, \DOMNode $node, $context = '')
{
$value = (string) $node->nodeValue;
if ($value !== '') {
$translation = $translations->insert($context, $value);
$translation->addReference($filenameRel, $node->getLineNo());
}
} | Parse a node value and create a POEntry item if it has a value.
@param \Gettext\Translations $translations Will be populated with found entries
@param string $filenameRel The relative file name of the xml file being read
@param \DOMNode $node The current node
@param string $context='' The translation context | https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/Cif.php#L445-L452 |
phavour/phavour | Phavour/Middleware/MiddlewareProcessor.php | MiddlewareProcessor.runBefore | public function runBefore(Request $request, Response $response)
{
foreach ($this->middlewares as $middleware) {
if (class_exists($middleware)) {
$instance = new $middleware($request, $response);
if ($instance instanceof MiddlewareAbstract) {
/* @var $instance MiddlewareAbstract */
$instance->onBefore();
$this->running[] = $instance;
}
}
}
} | php | public function runBefore(Request $request, Response $response)
{
foreach ($this->middlewares as $middleware) {
if (class_exists($middleware)) {
$instance = new $middleware($request, $response);
if ($instance instanceof MiddlewareAbstract) {
/* @var $instance MiddlewareAbstract */
$instance->onBefore();
$this->running[] = $instance;
}
}
}
} | Called by \Phavour\Application, this method runs all
Middleware onBefore methods
@return void | https://github.com/phavour/phavour/blob/2246f78203312eb2e23fdb0f776f790e81b4d20f/Phavour/Middleware/MiddlewareProcessor.php#L67-L79 |
phavour/phavour | Phavour/Middleware/MiddlewareProcessor.php | MiddlewareProcessor.runAfter | public function runAfter()
{
foreach ($this->running as $key => $middleware) {
/* @var $middleware MiddlewareAbstract */
$middleware->onAfter();
unset($this->running[$key]);
}
return;
} | php | public function runAfter()
{
foreach ($this->running as $key => $middleware) {
/* @var $middleware MiddlewareAbstract */
$middleware->onAfter();
unset($this->running[$key]);
}
return;
} | Called by \Phavour\Application, this method runs all
Middleware onBefore methods
@return void | https://github.com/phavour/phavour/blob/2246f78203312eb2e23fdb0f776f790e81b4d20f/Phavour/Middleware/MiddlewareProcessor.php#L86-L95 |
digipolisgent/robo-digipolis-deploy | src/PartialCleanDirs.php | PartialCleanDirs.dirs | public function dirs(array $dirs)
{
foreach ($dirs as $k => $v) {
if (is_numeric($v)) {
$this->dir($k, $v);
continue;
}
$this->dir($v);
}
return $this;
} | php | public function dirs(array $dirs)
{
foreach ($dirs as $k => $v) {
if (is_numeric($v)) {
$this->dir($k, $v);
continue;
}
$this->dir($v);
}
return $this;
} | Add directories to clean.
@param array $dirs
Either an array of directories or an array keyed by directory with the
number of items to keep within this directory as value.
@return $this | https://github.com/digipolisgent/robo-digipolis-deploy/blob/fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab/src/PartialCleanDirs.php#L138-L149 |
digipolisgent/robo-digipolis-deploy | src/PartialCleanDirs.php | PartialCleanDirs.run | public function run()
{
try {
foreach ($this->dirs as $dir => $keep) {
if ($dir) {
$this->printTaskInfo(
sprintf(
'Cleaning directory %s while keeping %d items.',
$dir,
$keep
)
);
$this->cleanDir($dir, $keep);
}
}
} catch (\Exception $e) {
return \Robo\Result::fromException($this, $e);
}
return \Robo\Result::success($this);
} | php | public function run()
{
try {
foreach ($this->dirs as $dir => $keep) {
if ($dir) {
$this->printTaskInfo(
sprintf(
'Cleaning directory %s while keeping %d items.',
$dir,
$keep
)
);
$this->cleanDir($dir, $keep);
}
}
} catch (\Exception $e) {
return \Robo\Result::fromException($this, $e);
}
return \Robo\Result::success($this);
} | {@inheritdoc} | https://github.com/digipolisgent/robo-digipolis-deploy/blob/fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab/src/PartialCleanDirs.php#L192-L211 |
digipolisgent/robo-digipolis-deploy | src/PartialCleanDirs.php | PartialCleanDirs.cleanDir | protected function cleanDir($dir, $keep)
{
$finder = clone $this->finder;
$finder->in($dir);
$finder->depth(0);
$this->doSort($finder);
$items = iterator_to_array($finder->getIterator());
if ($keep) {
array_splice($items, -$keep);
}
while ($items) {
$item = reset($items);
try {
$this->fs->chmod($item, 0777, 0000, true);
} catch (IOException $e) {
// If chmod didn't work and the exception contains a path, try
// to remove anyway.
$path = $e->getPath();
if ($path && realpath($path) !== realpath($item)) {
$this->fs->remove($path);
continue;
}
}
$this->fs->remove($item);
array_shift($items);
}
} | php | protected function cleanDir($dir, $keep)
{
$finder = clone $this->finder;
$finder->in($dir);
$finder->depth(0);
$this->doSort($finder);
$items = iterator_to_array($finder->getIterator());
if ($keep) {
array_splice($items, -$keep);
}
while ($items) {
$item = reset($items);
try {
$this->fs->chmod($item, 0777, 0000, true);
} catch (IOException $e) {
// If chmod didn't work and the exception contains a path, try
// to remove anyway.
$path = $e->getPath();
if ($path && realpath($path) !== realpath($item)) {
$this->fs->remove($path);
continue;
}
}
$this->fs->remove($item);
array_shift($items);
}
} | Clean a directory.
@param string $dir
The directory to clean.
@param int $keep
The number of items to keep. | https://github.com/digipolisgent/robo-digipolis-deploy/blob/fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab/src/PartialCleanDirs.php#L221-L247 |
digipolisgent/robo-digipolis-deploy | src/PartialCleanDirs.php | PartialCleanDirs.doSort | protected function doSort(Finder $finder)
{
switch ($this->sort) {
case static::SORT_NAME:
$finder->sortByName();
break;
case static::SORT_TYPE:
$finder->sortByType();
break;
case static::SORT_ACCESS_TIME:
$finder->sortByAccessedTime();
break;
case static::SORT_MODIFIED_TIME:
$finder->sortByModifiedTime();
break;
case static::SORT_CHANGED_TIME:
$finder->sortByType();
break;
case $this->sort instanceof \Closure:
$finder->sort($this->sort);
break;
}
} | php | protected function doSort(Finder $finder)
{
switch ($this->sort) {
case static::SORT_NAME:
$finder->sortByName();
break;
case static::SORT_TYPE:
$finder->sortByType();
break;
case static::SORT_ACCESS_TIME:
$finder->sortByAccessedTime();
break;
case static::SORT_MODIFIED_TIME:
$finder->sortByModifiedTime();
break;
case static::SORT_CHANGED_TIME:
$finder->sortByType();
break;
case $this->sort instanceof \Closure:
$finder->sort($this->sort);
break;
}
} | Sort the finder.
@param Finder $finder
The finder to sort. | https://github.com/digipolisgent/robo-digipolis-deploy/blob/fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab/src/PartialCleanDirs.php#L255-L282 |
LoggerEssentials/LoggerEssentials | src/Filters/CallbackFilter.php | CallbackFilter.log | public function log($level, $message, array $context = array()) {
$result = call_user_func($this->callback, $level, $message, $context);
if($result) {
$this->logger()->log($level, $message, $context);
}
} | php | public function log($level, $message, array $context = array()) {
$result = call_user_func($this->callback, $level, $message, $context);
if($result) {
$this->logger()->log($level, $message, $context);
}
} | Logs with an arbitrary level.
@param mixed $level
@param string $message
@param array $context
@return void | https://github.com/LoggerEssentials/LoggerEssentials/blob/f32f9b865eacfccced90697f3eb69dc4ad80dc96/src/Filters/CallbackFilter.php#L27-L32 |
bennybi/yii2-cza-base | behaviors/CmsMediaBehavior.php | CmsMediaBehavior.setup | protected function setup() {
if (!$this->_isSetup) {
$defaultConfig = array(
'srcBasePath' => Yii::getAlias('@webroot'),
'dstBasePath' => Yii::$app->czaHelper->folderOrganizer->getEntityUploadPath(true),
'dstUrlBase' => Yii::$app->czaHelper->folderOrganizer->getEntityUploadPath(),
'underOwnerEntityPath' => true,
'createMode' => 0775,
'cachingPath' => '',
);
$this->config = \yii\helpers\ArrayHelper::merge($defaultConfig, $this->config);
$defaultOptions = array(
'isTranslation' => false,
'handleFiles' => true,
'handleImages' => true,
);
$this->options = \yii\helpers\ArrayHelper::merge($defaultOptions, $this->options);
$this->_isSetup = true;
}
} | php | protected function setup() {
if (!$this->_isSetup) {
$defaultConfig = array(
'srcBasePath' => Yii::getAlias('@webroot'),
'dstBasePath' => Yii::$app->czaHelper->folderOrganizer->getEntityUploadPath(true),
'dstUrlBase' => Yii::$app->czaHelper->folderOrganizer->getEntityUploadPath(),
'underOwnerEntityPath' => true,
'createMode' => 0775,
'cachingPath' => '',
);
$this->config = \yii\helpers\ArrayHelper::merge($defaultConfig, $this->config);
$defaultOptions = array(
'isTranslation' => false,
'handleFiles' => true,
'handleImages' => true,
);
$this->options = \yii\helpers\ArrayHelper::merge($defaultOptions, $this->options);
$this->_isSetup = true;
}
} | setup config on flying | https://github.com/bennybi/yii2-cza-base/blob/8257db8034bd948712fa469062921f210f0ba8da/behaviors/CmsMediaBehavior.php#L82-L103 |
phPoirot/AuthSystem | Authenticate/Identifier/aIdentifier.php | aIdentifier.giveIdentity | function giveIdentity(iIdentity $identity)
{
if ($this->identity)
throw new \Exception('Identity is immutable.');
$defIdentity = $this->_newDefaultIdentity();
$defIdentity->import($identity);
if (!$defIdentity->isFulfilled())
throw new \InvalidArgumentException(sprintf(
'Identity (%s) not fulfillment (%s).'
, \Poirot\Std\flatten($identity)
, \Poirot\Std\flatten($defIdentity)
));
$this->identity = $defIdentity;
return $this;
} | php | function giveIdentity(iIdentity $identity)
{
if ($this->identity)
throw new \Exception('Identity is immutable.');
$defIdentity = $this->_newDefaultIdentity();
$defIdentity->import($identity);
if (!$defIdentity->isFulfilled())
throw new \InvalidArgumentException(sprintf(
'Identity (%s) not fulfillment (%s).'
, \Poirot\Std\flatten($identity)
, \Poirot\Std\flatten($defIdentity)
));
$this->identity = $defIdentity;
return $this;
} | Set Immutable Identity
@param iIdentity $identity
@return $this
@throws \Exception immutable error; identity not met requirement | https://github.com/phPoirot/AuthSystem/blob/bb8d02f72a7c2686d7d453021143361fa704a5a6/Authenticate/Identifier/aIdentifier.php#L95-L111 |
phPoirot/AuthSystem | Authenticate/Identifier/aIdentifier.php | aIdentifier.withIdentity | final function withIdentity()
{
if ( !$this->identity && $this->canRecognizeIdentity() ) {
$identity = $this->doRecognizedIdentity();
if ($identity)
## update identity
$this->giveIdentity($identity);
}
if (! $this->identity )
throw new exNotAuthenticated;
return clone $this->identity;
} | php | final function withIdentity()
{
if ( !$this->identity && $this->canRecognizeIdentity() ) {
$identity = $this->doRecognizedIdentity();
if ($identity)
## update identity
$this->giveIdentity($identity);
}
if (! $this->identity )
throw new exNotAuthenticated;
return clone $this->identity;
} | Get Authenticated User Data Copy
- for check that user is signIn the identity must
fulfilled.
- if canRecognizeIdentity extract data from it
this cause identity fulfillment with given data
ie. when user exists in session build identity from that
@return iIdentity
@throws exNotAuthenticated not set or cant recognized | https://github.com/phPoirot/AuthSystem/blob/bb8d02f72a7c2686d7d453021143361fa704a5a6/Authenticate/Identifier/aIdentifier.php#L125-L138 |
phPoirot/AuthSystem | Authenticate/Identifier/aIdentifier.php | aIdentifier.issueException | final function issueException(exAuthentication $exception = null)
{
$callable = ($this->issuer_exception)
? $this->issuer_exception
: $this->doIssueExceptionDefault();
return call_user_func($callable, $exception);
} | php | final function issueException(exAuthentication $exception = null)
{
$callable = ($this->issuer_exception)
? $this->issuer_exception
: $this->doIssueExceptionDefault();
return call_user_func($callable, $exception);
} | Issue To Handle Authentication Exception
usually called when authentication exception rise
to challenge client to login form or something.
@param exAuthentication $exception Maybe support for specific error
@return mixed Result Handle in Dispatch Listener Events | https://github.com/phPoirot/AuthSystem/blob/bb8d02f72a7c2686d7d453021143361fa704a5a6/Authenticate/Identifier/aIdentifier.php#L150-L157 |
phPoirot/AuthSystem | Authenticate/Identifier/aIdentifier.php | aIdentifier.setIssuerException | function setIssuerException(/*callable*/ $callable)
{
if (!is_callable($callable))
throw new \InvalidArgumentException(sprintf(
'Issuer must be callable; given: (%s).'
, \Poirot\Std\flatten($callable)
));
$this->issuer_exception = $callable;
return $this;
} | php | function setIssuerException(/*callable*/ $callable)
{
if (!is_callable($callable))
throw new \InvalidArgumentException(sprintf(
'Issuer must be callable; given: (%s).'
, \Poirot\Std\flatten($callable)
));
$this->issuer_exception = $callable;
return $this;
} | Set Exception Issuer
callable:
function(exAuthentication $e)
@param callable $callable
@return $this | https://github.com/phPoirot/AuthSystem/blob/bb8d02f72a7c2686d7d453021143361fa704a5a6/Authenticate/Identifier/aIdentifier.php#L213-L223 |
soliphp/web | src/Web/Controller.php | Controller.render | protected function render(string $template, array $vars = [])
{
$vars['flash'] = $this->flash;
$this->view->setVars($vars);
$content = $this->view->render($template);
$this->response->setContent($content);
return $this->response;
} | php | protected function render(string $template, array $vars = [])
{
$vars['flash'] = $this->flash;
$this->view->setVars($vars);
$content = $this->view->render($template);
$this->response->setContent($content);
return $this->response;
} | 手工渲染视图
@param string $template 模板路径
@param array $vars 模板变量
@return Response | https://github.com/soliphp/web/blob/40c884ef06afa5739c94f0bffdcc69d3c6c44e96/src/Web/Controller.php#L27-L36 |
soliphp/web | src/Web/Controller.php | Controller.forward | protected function forward(string $controller, array $action = [], array $params = [])
{
return $this->dispatcher->forward([
'handler' => $controller,
'action' => $action,
'params' => $params,
]);
} | php | protected function forward(string $controller, array $action = [], array $params = [])
{
return $this->dispatcher->forward([
'handler' => $controller,
'action' => $action,
'params' => $params,
]);
} | 转发给另一个控制器
@param string $controller
@param array $action
@param array $params | https://github.com/soliphp/web/blob/40c884ef06afa5739c94f0bffdcc69d3c6c44e96/src/Web/Controller.php#L45-L52 |
jlaso/slim-routing-manager | JLaso/SlimRoutingManager/RoutingCacheManager.php | RoutingCacheManager.writeCache | protected function writeCache($class, $content)
{
$date = date("Y-m-d h:i:s");
$content = <<<EOD
<?php
/**
* Generated with RoutingCacheManager
*
* on {$date}
*/
\$app = Slim\Slim::getInstance();
{$content}
EOD;
$fileName = $this->cacheFile($class);
file_put_contents($fileName, $content);
return $fileName;
} | php | protected function writeCache($class, $content)
{
$date = date("Y-m-d h:i:s");
$content = <<<EOD
<?php
/**
* Generated with RoutingCacheManager
*
* on {$date}
*/
\$app = Slim\Slim::getInstance();
{$content}
EOD;
$fileName = $this->cacheFile($class);
file_put_contents($fileName, $content);
return $fileName;
} | This method writes the cache content into cache file
@param $class
@param $content
@return string | https://github.com/jlaso/slim-routing-manager/blob/a9fb697e03377b1694add048418a484ef62eae08/JLaso/SlimRoutingManager/RoutingCacheManager.php#L68-L90 |
php-kit/power-primitives | src/PowerString.php | PowerString.on | static function on (& $src)
{
static $x;
if (!isset($x)) $x = new static;
$x->S =& $src;
return $x;
} | php | static function on (& $src)
{
static $x;
if (!isset($x)) $x = new static;
$x->S =& $src;
return $x;
} | Returns a singleton instance of `PowerString` that modifies the given string.
<p>**Warning:** this method returns **always** the same instance. This is meant to be a wrapper for applying
extension methods to an existing string variable. You should **not** store the instance anywhere, as it will lead
to unexpected problems. If you need to do that, use {@see `PowerString`::of} instead.
@param string $src
@return PowerString | https://github.com/php-kit/power-primitives/blob/98450f8c1c34abe86ef293a4764c62c51852632b/src/PowerString.php#L85-L91 |
php-kit/power-primitives | src/PowerString.php | PowerString.toUnicodeRegex | private static function toUnicodeRegex (& $pattern)
{
$d = $pattern[0];
list ($exp, $flags) = explode ($d, substr ($pattern, 1), 2);
$flags = str_replace ('a', '', $flags, $isGlobal);
$flags = str_replace ('u', '', $flags) . 'u';
$pattern = "$d$exp$d$flags";
return $isGlobal;
} | php | private static function toUnicodeRegex (& $pattern)
{
$d = $pattern[0];
list ($exp, $flags) = explode ($d, substr ($pattern, 1), 2);
$flags = str_replace ('a', '', $flags, $isGlobal);
$flags = str_replace ('u', '', $flags) . 'u';
$pattern = "$d$exp$d$flags";
return $isGlobal;
} | Sets the `u` unicode flag on a regular expression and, if the `a` pseudo-flag is present, it removes it and returns
`true` to signal a global search (find all).
@param string $pattern
@return bool true if the `a` flag was specified. | https://github.com/php-kit/power-primitives/blob/98450f8c1c34abe86ef293a4764c62c51852632b/src/PowerString.php#L100-L108 |
php-kit/power-primitives | src/PowerString.php | PowerString.indexOfPattern | function indexOfPattern ($pattern)
{
self::toUnicodeRegex ($pattern);
if (!preg_match ($pattern, $this->S, $m, PREG_OFFSET_CAPTURE)) return false;
return $m[0][1];
} | php | function indexOfPattern ($pattern)
{
self::toUnicodeRegex ($pattern);
if (!preg_match ($pattern, $this->S, $m, PREG_OFFSET_CAPTURE)) return false;
return $m[0][1];
} | Searches for a pattern on a string and returns the index of the matched substring.
><p>This is a simpler version of {@see search}.
@param string $pattern A regular expression pattern.
@return int The index of the matched substring. | https://github.com/php-kit/power-primitives/blob/98450f8c1c34abe86ef293a4764c62c51852632b/src/PowerString.php#L195-L200 |
php-kit/power-primitives | src/PowerString.php | PowerString.search | function search ($pattern, $from = 0, &$match = null)
{
self::toUnicodeRegex ($pattern);
if (preg_match ($pattern, $this->S, $m, PREG_OFFSET_CAPTURE)) {
list ($match, $ofs) = $m[0];
return $ofs;
}
return false;
} | php | function search ($pattern, $from = 0, &$match = null)
{
self::toUnicodeRegex ($pattern);
if (preg_match ($pattern, $this->S, $m, PREG_OFFSET_CAPTURE)) {
list ($match, $ofs) = $m[0];
return $ofs;
}
return false;
} | Finds the position of the first occurrence of a pattern in the current string.
><p>This is an extended version of {@see indexOfPattern}.
@param string $pattern A regular expression.
@param int $from The position where the search begins, counted from the beginning of the current string.
@param string $match [optional] If a variable is specified, it will be set to the matched substring.
@return int|bool false if no match was found. | https://github.com/php-kit/power-primitives/blob/98450f8c1c34abe86ef293a4764c62c51852632b/src/PowerString.php#L289-L297 |
nasumilu/geometry | src/Operation/AbstractOpEvent.php | AbstractOpEvent.addError | public function addError(OperationError $ex, bool $stopPropagation = false) {
$this->lastError = $ex;
if ($stopPropagation) {
$this->stopPropagation();
}
} | php | public function addError(OperationError $ex, bool $stopPropagation = false) {
$this->lastError = $ex;
if ($stopPropagation) {
$this->stopPropagation();
}
} | Adds an OperationError to the operation events error list.
If the argument <code>$stopPropagation</code> is true than this operation
will stop propagating once complete.
@param \Nasumilu\Geometry\Operation\OperationError $ex
@param bool $stopPropagation | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Operation/AbstractOpEvent.php#L111-L116 |
nasumilu/geometry | src/Operation/AbstractOpEvent.php | AbstractOpEvent.getOption | public function getOption(string $offset) {
if (!$this->hasOption($offset)) {
throw new \InvalidArgumentException(sprintf('Option "%s" not found.', $offset));
}
return $this->options[$offset];
} | php | public function getOption(string $offset) {
if (!$this->hasOption($offset)) {
throw new \InvalidArgumentException(sprintf('Option "%s" not found.', $offset));
}
return $this->options[$offset];
} | Gets the operation's option named <code>$offset</code>.
@param string $offset
@return mixed
@throws \InvalidArgumentException if the options $offset named does not exists. | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Operation/AbstractOpEvent.php#L134-L139 |
nasumilu/geometry | src/Operation/AbstractOpEvent.php | AbstractOpEvent.setOption | public function setOption(string $offset, $value): AbstractOpEvent {
$this->options[$offset] = $value;
return $this;
} | php | public function setOption(string $offset, $value): AbstractOpEvent {
$this->options[$offset] = $value;
return $this;
} | Sets the <code>$offset</code> named options to argument <code>$value</code>.
@param string $offset
@param mixed $value
@return AbstractOpEvent | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Operation/AbstractOpEvent.php#L148-L151 |
nasumilu/geometry | src/Operation/AbstractOpEvent.php | AbstractOpEvent.setResults | public function setResults($results = null, bool $stopPropagation = false) {
$this->result = $results;
if ($stopPropagation) {
$this->stopPropagation();
}
} | php | public function setResults($results = null, bool $stopPropagation = false) {
$this->result = $results;
if ($stopPropagation) {
$this->stopPropagation();
}
} | Sets the operations result.
To stop the operations propagation set <code>$stopPropagation</code> to
true.
@param mixed $results
@param bool $stopPropagation | https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Operation/AbstractOpEvent.php#L232-L237 |
schpill/thin | src/Vertica.php | Vertica.query | public function query($query, $params = null, $fetchResult = false)
{
$this->checkConnection(true);
$this->log('Query: ' . $query);
if(!empty($params)) {
$this->log('Params: ' . print_r($params, true));
}
$start = microtime(true);
if(empty($params)) {
$res = $this->executeQuery($query);
} else {
$res = $this->executePreparedStatement($query, $params);
}
$end = microtime(true);
$this->log("Execution time: " . ($end - $start) . " seconds");
if($fetchResult) {
$this->log('Num Rows: '.odbc_num_rows($res));
$resutlSet = $this->getRows($res);
odbc_free_result($res);
$res = $resutlSet;
$resultSet = null;
$fetch = microtime(true);
$this->log("Fetch time: " . ($fetch - $end) . " seconds");
}
return $res;
} | php | public function query($query, $params = null, $fetchResult = false)
{
$this->checkConnection(true);
$this->log('Query: ' . $query);
if(!empty($params)) {
$this->log('Params: ' . print_r($params, true));
}
$start = microtime(true);
if(empty($params)) {
$res = $this->executeQuery($query);
} else {
$res = $this->executePreparedStatement($query, $params);
}
$end = microtime(true);
$this->log("Execution time: " . ($end - $start) . " seconds");
if($fetchResult) {
$this->log('Num Rows: '.odbc_num_rows($res));
$resutlSet = $this->getRows($res);
odbc_free_result($res);
$res = $resutlSet;
$resultSet = null;
$fetch = microtime(true);
$this->log("Fetch time: " . ($fetch - $end) . " seconds");
}
return $res;
} | Execute a query and return the results
@param string $query
@param array $params
@param bool $fetchResult Return a ressource or a an array
@return resource|array
@throws Exception | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Vertica.php#L36-L66 |
schpill/thin | src/Vertica.php | Vertica.executeQuery | protected function executeQuery($query)
{
$res = @odbc_exec($this->_lnk, $query);
if(!$res) {
$error = odbc_errormsg($this->_lnk);
$this->log('Query failed: '.$error);
throw new Exception('Executing query failed ' . $error, self::QUERY_FAILED);
}
return $res;
} | php | protected function executeQuery($query)
{
$res = @odbc_exec($this->_lnk, $query);
if(!$res) {
$error = odbc_errormsg($this->_lnk);
$this->log('Query failed: '.$error);
throw new Exception('Executing query failed ' . $error, self::QUERY_FAILED);
}
return $res;
} | Execute a query and returns an ODBC result identifier
@param string $query
@return resource
@throws Exception | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Vertica.php#L74-L83 |
schpill/thin | src/Vertica.php | Vertica.executePreparedStatement | protected function executePreparedStatement($query, $params)
{
$res = odbc_prepare($this->_lnk, $query);
if(!$res) {
$error = odbc_errormsg($this->_lnk);
$this->log('Prepare failed: ' . $error);
throw new Exception('Preparing query failed ' . $error, self::PREPARE_FAILED);
}
$res = odbc_execute($res, $params);
if(!$res) {
$error = odbc_errormsg($this->_lnk);
$this->log('Prepared query execution failed: ' . $error);
throw new Exception('Executing prepared query failed ' . $error, self::QUERY_FAILED);
}
return $res;
} | php | protected function executePreparedStatement($query, $params)
{
$res = odbc_prepare($this->_lnk, $query);
if(!$res) {
$error = odbc_errormsg($this->_lnk);
$this->log('Prepare failed: ' . $error);
throw new Exception('Preparing query failed ' . $error, self::PREPARE_FAILED);
}
$res = odbc_execute($res, $params);
if(!$res) {
$error = odbc_errormsg($this->_lnk);
$this->log('Prepared query execution failed: ' . $error);
throw new Exception('Executing prepared query failed ' . $error, self::QUERY_FAILED);
}
return $res;
} | Prepare a query, execute it and return an ODBC result identifier
@param string $query
@param array $params
@return bool|resource
@throws Exception | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Vertica.php#L92-L107 |
schpill/thin | src/Vertica.php | Vertica.checkConnection | protected function checkConnection($reconnect = false)
{
if(empty($this->_lnk)) {
$this->log('CheckConnection: link is not valid');
if($reconnect) {
$this->log('CheckConnection: try to reconnect');
$this->_lnk = @odbc_connect('Driver=' . VERTICA_DRIVER . ';Servername=' . VERTICA_SERVER . ';Database='.VERTICA_DATABASE, VERTICA_USER_ETL, VERTICA_PASS_ETL);
if(!$this->_lnk) {
$this->log('CheckConnection: reconnect failed');
throw new Exception('Connection failed or gone away and can\'t reconnect - '.odbc_errormsg($this->_link), self::CONNECTION_FAILED);
}
$this->log('CheckConnection: reconnected!');
return;
}
throw new Exception('Connection failed or gone away - ' . odbc_errormsg($this->_link), self::CONNECTION_FAILED);
}
} | php | protected function checkConnection($reconnect = false)
{
if(empty($this->_lnk)) {
$this->log('CheckConnection: link is not valid');
if($reconnect) {
$this->log('CheckConnection: try to reconnect');
$this->_lnk = @odbc_connect('Driver=' . VERTICA_DRIVER . ';Servername=' . VERTICA_SERVER . ';Database='.VERTICA_DATABASE, VERTICA_USER_ETL, VERTICA_PASS_ETL);
if(!$this->_lnk) {
$this->log('CheckConnection: reconnect failed');
throw new Exception('Connection failed or gone away and can\'t reconnect - '.odbc_errormsg($this->_link), self::CONNECTION_FAILED);
}
$this->log('CheckConnection: reconnected!');
return;
}
throw new Exception('Connection failed or gone away - ' . odbc_errormsg($this->_link), self::CONNECTION_FAILED);
}
} | Check if the connection failed and try to reconnect if asked
@param bool $reconnect
@throws Exception | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Vertica.php#L128-L144 |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.decode | public static function decode($cookie)
{
$params = (array) json_decode(base64_decode($cookie), true);
return new self((string) array_value($params, 'user_email'),
(string) array_value($params, 'agent'),
(string) array_value($params, 'series'),
(string) array_value($params, 'token'));
} | php | public static function decode($cookie)
{
$params = (array) json_decode(base64_decode($cookie), true);
return new self((string) array_value($params, 'user_email'),
(string) array_value($params, 'agent'),
(string) array_value($params, 'series'),
(string) array_value($params, 'token'));
} | Decodes an encoded remember me cookie string.
@param string $cookie
@return self | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L130-L138 |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.encode | public function encode()
{
$json = json_encode([
'user_email' => $this->email,
'agent' => $this->userAgent,
'series' => $this->series,
'token' => $this->token,
]);
return base64_encode($json);
} | php | public function encode()
{
$json = json_encode([
'user_email' => $this->email,
'agent' => $this->userAgent,
'series' => $this->series,
'token' => $this->token,
]);
return base64_encode($json);
} | Encodes a remember me cookie.
@return string | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L145-L155 |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.isValid | public function isValid()
{
if (!filter_var($this->email, FILTER_VALIDATE_EMAIL)) {
return false;
}
if (empty($this->userAgent)) {
return false;
}
if (empty($this->series)) {
return false;
}
if (empty($this->token)) {
return false;
}
return true;
} | php | public function isValid()
{
if (!filter_var($this->email, FILTER_VALIDATE_EMAIL)) {
return false;
}
if (empty($this->userAgent)) {
return false;
}
if (empty($this->series)) {
return false;
}
if (empty($this->token)) {
return false;
}
return true;
} | Checks if the cookie contains valid values.
@return bool | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L162-L181 |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.verify | public function verify(Request $req, AuthManager $auth)
{
if (!$this->isValid()) {
return false;
}
// verify the user agent matches the one in the request
if ($this->userAgent != $req->agent()) {
return false;
}
// look up the user with a matching email address
try {
$userClass = $auth->getUserClass();
$user = $userClass::where('email', $this->email)
->first();
} catch (ModelException $e) {
// fail open when unable to look up the user
return false;
}
if (!$user) {
return false;
}
// hash series for matching with the db
$seriesHash = $this->hash($this->series);
// First, make sure all of the parameters match, except the token.
// We match the token separately to detect if an older session is
// being used, in which case we cowardly run away.
$expiration = time() - $this->getExpires();
$db = $auth->getApp()['database']->getDefault();
$query = $db->select('token,two_factor_verified')
->from('PersistentSessions')
->where('email', $this->email)
->where('created_at', U::unixToDb($expiration), '>')
->where('series', $seriesHash);
$persistentSession = $query->one();
if ($query->rowCount() !== 1) {
return false;
}
// if there is a match, sign the user in
$tokenHash = $this->hash($this->token);
// Same series, but different token, meaning the user is trying
// to use an older token. It's most likely an attack, so flush
// all sessions.
if (!hash_equals($persistentSession['token'], $tokenHash)) {
$db->delete('PersistentSessions')
->where('email', $this->email)
->execute();
return false;
}
// remove the token once used
$db->delete('PersistentSessions')
->where('email', $this->email)
->where('series', $seriesHash)
->where('token', $tokenHash)
->execute();
// mark the user as 2fa verified
if ($persistentSession['two_factor_verified']) {
$user->markTwoFactorVerified();
}
return $user;
} | php | public function verify(Request $req, AuthManager $auth)
{
if (!$this->isValid()) {
return false;
}
// verify the user agent matches the one in the request
if ($this->userAgent != $req->agent()) {
return false;
}
// look up the user with a matching email address
try {
$userClass = $auth->getUserClass();
$user = $userClass::where('email', $this->email)
->first();
} catch (ModelException $e) {
// fail open when unable to look up the user
return false;
}
if (!$user) {
return false;
}
// hash series for matching with the db
$seriesHash = $this->hash($this->series);
// First, make sure all of the parameters match, except the token.
// We match the token separately to detect if an older session is
// being used, in which case we cowardly run away.
$expiration = time() - $this->getExpires();
$db = $auth->getApp()['database']->getDefault();
$query = $db->select('token,two_factor_verified')
->from('PersistentSessions')
->where('email', $this->email)
->where('created_at', U::unixToDb($expiration), '>')
->where('series', $seriesHash);
$persistentSession = $query->one();
if ($query->rowCount() !== 1) {
return false;
}
// if there is a match, sign the user in
$tokenHash = $this->hash($this->token);
// Same series, but different token, meaning the user is trying
// to use an older token. It's most likely an attack, so flush
// all sessions.
if (!hash_equals($persistentSession['token'], $tokenHash)) {
$db->delete('PersistentSessions')
->where('email', $this->email)
->execute();
return false;
}
// remove the token once used
$db->delete('PersistentSessions')
->where('email', $this->email)
->where('series', $seriesHash)
->where('token', $tokenHash)
->execute();
// mark the user as 2fa verified
if ($persistentSession['two_factor_verified']) {
$user->markTwoFactorVerified();
}
return $user;
} | Looks for a remembered user using this cookie
from an incoming request.
@param Request $req
@param AuthManager $auth
@return UserInterface|false remembered user | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L192-L264 |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.persist | public function persist(UserInterface $user)
{
$session = new PersistentSession();
$session->email = $this->email;
$session->series = $this->hash($this->series);
$session->token = $this->hash($this->token);
$session->user_id = $user->id();
$session->two_factor_verified = $user->isTwoFactorVerified();
try {
$session->save();
} catch (\Exception $e) {
throw new \Exception("Unable to save persistent session for user # {$user->id()}: ".$e->getMessage());
}
return $session;
} | php | public function persist(UserInterface $user)
{
$session = new PersistentSession();
$session->email = $this->email;
$session->series = $this->hash($this->series);
$session->token = $this->hash($this->token);
$session->user_id = $user->id();
$session->two_factor_verified = $user->isTwoFactorVerified();
try {
$session->save();
} catch (\Exception $e) {
throw new \Exception("Unable to save persistent session for user # {$user->id()}: ".$e->getMessage());
}
return $session;
} | Persists this cookie to the database.
@param UserInterface $user
@throws \Exception when the model cannot be saved.
@return PersistentSession | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L275-L291 |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.destroy | function destroy()
{
$seriesHash = $this->hash($this->series);
PersistentSession::where('email', $this->email)
->where('series', $seriesHash)
->delete();
} | php | function destroy()
{
$seriesHash = $this->hash($this->series);
PersistentSession::where('email', $this->email)
->where('series', $seriesHash)
->delete();
} | Destroys the persisted cookie in the data store. | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L296-L302 |
infusephp/auth | src/Libs/RememberMeCookie.php | RememberMeCookie.hash | private function hash($token)
{
$app = Application::getDefault();
$salt = $app['config']->get('app.salt');
return hash_hmac('sha512', $token, $salt);
} | php | private function hash($token)
{
$app = Application::getDefault();
$salt = $app['config']->get('app.salt');
return hash_hmac('sha512', $token, $salt);
} | Hashes a token.
@param string $token
@return string hashed token | https://github.com/infusephp/auth/blob/720280b4b2635572f331afe8d082e3e88cf54eb7/src/Libs/RememberMeCookie.php#L323-L329 |
gplcart/file_manager | handlers/commands/Listing.php | Listing.view | public function view($file, $controller)
{
$this->controller = $controller;
$path = $file->getRealPath();
$params = $controller->getQuery(null, array(), 'array');
$pager_options = array(
'max_pages' => 5,
'query' => $params,
'total' => $this->getTotal($path, $params),
'limit' => $this->controller->getModuleSettings('file_manager', 'limit')
);
$pager = $this->controller->getPager($pager_options);
$params['limit'] = $pager['limit'];
return array(
'file_manager|commands/list' => array(
'pager' => $pager['rendered'],
'filters' => $this->scanner->getFilters(),
'sorters' => $this->scanner->getSorters(),
'files' => $this->getFilesListing($path, $params)
));
} | php | public function view($file, $controller)
{
$this->controller = $controller;
$path = $file->getRealPath();
$params = $controller->getQuery(null, array(), 'array');
$pager_options = array(
'max_pages' => 5,
'query' => $params,
'total' => $this->getTotal($path, $params),
'limit' => $this->controller->getModuleSettings('file_manager', 'limit')
);
$pager = $this->controller->getPager($pager_options);
$params['limit'] = $pager['limit'];
return array(
'file_manager|commands/list' => array(
'pager' => $pager['rendered'],
'filters' => $this->scanner->getFilters(),
'sorters' => $this->scanner->getSorters(),
'files' => $this->getFilesListing($path, $params)
));
} | Returns an array of data used to display the command
@param \SplFileInfo $file
@param \gplcart\core\Controller $controller
@return array | https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/handlers/commands/Listing.php#L59-L83 |
gplcart/file_manager | handlers/commands/Listing.php | Listing.getFilesListing | protected function getFilesListing($path, array $params)
{
$files = $this->getFiles($path, $params);
return $this->prepareFiles($files);
} | php | protected function getFilesListing($path, array $params)
{
$files = $this->getFiles($path, $params);
return $this->prepareFiles($files);
} | Returns an array of scanned and prepared files
@param string $path
@param array $params
@return array | https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/handlers/commands/Listing.php#L91-L95 |
gplcart/file_manager | handlers/commands/Listing.php | Listing.prepareFiles | protected function prepareFiles(array $files)
{
$prepared = array();
foreach ($files as $file) {
$type = $file->getType();
$path = $file->getRealPath();
$relative_path = gplcart_file_relative($path);
$item = array(
'info' => $file,
'type' => $type,
'path' => $relative_path,
'owner' => fileowner($path),
'extension' => $file->getExtension(),
'size' => gplcart_file_size($file->getSize()),
'command' => $type === 'dir' ? 'list' : 'read',
'commands' => $this->command->getAllowed($file),
'permissions' => gplcart_file_perms($file->getPerms())
);
$prepared[$relative_path] = $item;
$prepared[$relative_path]['icon'] = $this->renderIcon($item);
}
return $prepared;
} | php | protected function prepareFiles(array $files)
{
$prepared = array();
foreach ($files as $file) {
$type = $file->getType();
$path = $file->getRealPath();
$relative_path = gplcart_file_relative($path);
$item = array(
'info' => $file,
'type' => $type,
'path' => $relative_path,
'owner' => fileowner($path),
'extension' => $file->getExtension(),
'size' => gplcart_file_size($file->getSize()),
'command' => $type === 'dir' ? 'list' : 'read',
'commands' => $this->command->getAllowed($file),
'permissions' => gplcart_file_perms($file->getPerms())
);
$prepared[$relative_path] = $item;
$prepared[$relative_path]['icon'] = $this->renderIcon($item);
}
return $prepared;
} | Prepares an array of scanned files
@param array $files
@return array | https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/handlers/commands/Listing.php#L102-L128 |
gplcart/file_manager | handlers/commands/Listing.php | Listing.renderIcon | protected function renderIcon(array $item)
{
static $rendered = array();
if (isset($rendered[$item['extension']])) {
return $rendered[$item['extension']];
}
$template = "file_manager|icons/ext/{$item['extension']}";
if ($item['type'] === 'dir') {
$template = 'file_manager|icons/dir';
}
$data = array('item' => $item);
$default = $this->controller->render('file_manager|icons/file', $data);
$rendered[$item['extension']] = $this->controller->render($template, $data, true, $default);
return $rendered[$item['extension']];
} | php | protected function renderIcon(array $item)
{
static $rendered = array();
if (isset($rendered[$item['extension']])) {
return $rendered[$item['extension']];
}
$template = "file_manager|icons/ext/{$item['extension']}";
if ($item['type'] === 'dir') {
$template = 'file_manager|icons/dir';
}
$data = array('item' => $item);
$default = $this->controller->render('file_manager|icons/file', $data);
$rendered[$item['extension']] = $this->controller->render($template, $data, true, $default);
return $rendered[$item['extension']];
} | Returns a rendered icon for the given file extension and type
@param array $item
@return string | https://github.com/gplcart/file_manager/blob/45424e93eafea75d31af6410ac9cf110f08e500a/handlers/commands/Listing.php#L135-L154 |
AbuseIO/collector-common | src/Collector.php | Collector.failed | protected function failed($message)
{
$this->cleanup();
Log::warning(
get_class($this) . ': ' .
'Collector ' . config("{$this->configBase}.collector.name") . ' has ended with errors. ' . $message
);
return [
'errorStatus' => true,
'errorMessage' => $message,
'warningCount' => $this->warningCount,
'data' => false,
];
} | php | protected function failed($message)
{
$this->cleanup();
Log::warning(
get_class($this) . ': ' .
'Collector ' . config("{$this->configBase}.collector.name") . ' has ended with errors. ' . $message
);
return [
'errorStatus' => true,
'errorMessage' => $message,
'warningCount' => $this->warningCount,
'data' => false,
];
} | Return failed
@param string $message
@return array | https://github.com/AbuseIO/collector-common/blob/fe887083371ac50c9112f313b2441b9852dfd263/src/Collector.php#L90-L105 |
AbuseIO/collector-common | src/Collector.php | Collector.success | protected function success()
{
$this->cleanup();
if (empty($this->incidents)) {
Log::warning(
'The collector ' . config("{$this->configBase}.collector.name") . ' did not return any incidents ' .
'which should be investigated for collector and/or configuration errors'
);
}
Log::info(
get_class($this) . ': ' .
'Collector run completed for collector : ' . config("{$this->configBase}.collector.name")
);
return [
'errorStatus' => false,
'errorMessage' => 'Data successfully collected',
'warningCount' => $this->warningCount,
'data' => $this->incidents,
];
} | php | protected function success()
{
$this->cleanup();
if (empty($this->incidents)) {
Log::warning(
'The collector ' . config("{$this->configBase}.collector.name") . ' did not return any incidents ' .
'which should be investigated for collector and/or configuration errors'
);
}
Log::info(
get_class($this) . ': ' .
'Collector run completed for collector : ' . config("{$this->configBase}.collector.name")
);
return [
'errorStatus' => false,
'errorMessage' => 'Data successfully collected',
'warningCount' => $this->warningCount,
'data' => $this->incidents,
];
} | Return success
@return array | https://github.com/AbuseIO/collector-common/blob/fe887083371ac50c9112f313b2441b9852dfd263/src/Collector.php#L111-L133 |
AbuseIO/collector-common | src/Collector.php | Collector.isKnownFeed | protected function isKnownFeed()
{
if (empty(config("{$this->configBase}.feeds.{$this->feedName}"))) {
$this->warningCount++;
Log::warning(
"The feed referred as '{$this->feedName}' is not configured in the collector " .
config("{$this->configBase}.collector.name") .
' therefore skipping processing of this e-mail'
);
return false;
} else {
return true;
}
} | php | protected function isKnownFeed()
{
if (empty(config("{$this->configBase}.feeds.{$this->feedName}"))) {
$this->warningCount++;
Log::warning(
"The feed referred as '{$this->feedName}' is not configured in the collector " .
config("{$this->configBase}.collector.name") .
' therefore skipping processing of this e-mail'
);
return false;
} else {
return true;
}
} | Check if the feed specified is known in the collector config.
@return Boolean Returns true or false | https://github.com/AbuseIO/collector-common/blob/fe887083371ac50c9112f313b2441b9852dfd263/src/Collector.php#L170-L183 |
temp/media-converter | src/Transmuter.php | Transmuter.transmute | public function transmute($inFilename, Specification $targetFormat, $outFilename)
{
$extractedFile = $this->extractor->extract($inFilename, $targetFormat);
if (!$extractedFile) {
return null;
}
$this->converter->convert($extractedFile, $targetFormat, $outFilename);
return $outFilename;
} | php | public function transmute($inFilename, Specification $targetFormat, $outFilename)
{
$extractedFile = $this->extractor->extract($inFilename, $targetFormat);
if (!$extractedFile) {
return null;
}
$this->converter->convert($extractedFile, $targetFormat, $outFilename);
return $outFilename;
} | Transmute file to target format
@param string $inFilename
@param Specification $targetFormat
@param string $outFilename
@return string|null | https://github.com/temp/media-converter/blob/a6e8768c583aa461be568f13e592ae49294e5e33/src/Transmuter.php#L54-L65 |
schpill/thin | src/Html/Attributes.php | Attributes.add | public function add($attribute, $value = array())
{
if(is_array($attribute)) {
foreach($attribute as $k => $v) {
$this->add($k, $v);
}
} else {
if($attribute instanceof \Thin\Html\Attributes) {
$this->add($attribute->getArray());
} else {
$attribute = strval($attribute);
if(!\Thin\Arrays::exists($attribute, $this->attributes)) {
$this->attributes[$attribute] = array();
}
if(is_array($value)) {
foreach($value as $k => $v) {
$value[$k] = strval($v);
}
} else {
if(empty($value) && $value !== '0') {
$value = array();
} else {
$value = array(strval($value));
}
}
foreach($value as $v) {
$this->attributes[$attribute][] = $v;
}
$this->attributes[$attribute] = array_unique($this->attributes[$attribute]);
}
}
return $this;
} | php | public function add($attribute, $value = array())
{
if(is_array($attribute)) {
foreach($attribute as $k => $v) {
$this->add($k, $v);
}
} else {
if($attribute instanceof \Thin\Html\Attributes) {
$this->add($attribute->getArray());
} else {
$attribute = strval($attribute);
if(!\Thin\Arrays::exists($attribute, $this->attributes)) {
$this->attributes[$attribute] = array();
}
if(is_array($value)) {
foreach($value as $k => $v) {
$value[$k] = strval($v);
}
} else {
if(empty($value) && $value !== '0') {
$value = array();
} else {
$value = array(strval($value));
}
}
foreach($value as $v) {
$this->attributes[$attribute][] = $v;
}
$this->attributes[$attribute] = array_unique($this->attributes[$attribute]);
}
}
return $this;
} | Add an attribute or an array thereof. If the attribute already exists, the specified values will be added to it, without overwriting the previous ones. Duplicate values are removed.
@param string|array|\Thin\Html\Attributes $attribute The name of the attribute to add, a name-value array of attributes or an attributes object
@param string|array $value In case the first parametre is a string, value or array of values for the added attribute
@return \Thin\Html\Attributes Provides a fluent interface | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Attributes.php#L19-L54 |
schpill/thin | src/Html/Attributes.php | Attributes.set | public function set($attribute, $value = array())
{
if(is_array($attribute)) {
$this->attributes = array();
foreach($attribute as $k => $v) {
$this->set($k, $v);
}
} else {
if($attribute instanceof \Thin\Html\Attributes) {
$this->attributes = $attribute->getArray();
} else {
$attribute = strval($attribute);
if(is_array($value)) {
foreach($value as $k => $v) {
$value[$k] = strval($v);
}
} else {
if(empty($value) && $value !== '0') {
$value = array();
} else {
$value = array(strval($value));
}
}
$this->attributes[$attribute] = array_unique($value);
}
}
return $this;
} | php | public function set($attribute, $value = array())
{
if(is_array($attribute)) {
$this->attributes = array();
foreach($attribute as $k => $v) {
$this->set($k, $v);
}
} else {
if($attribute instanceof \Thin\Html\Attributes) {
$this->attributes = $attribute->getArray();
} else {
$attribute = strval($attribute);
if(is_array($value)) {
foreach($value as $k => $v) {
$value[$k] = strval($v);
}
} else {
if(empty($value) && $value !== '0') {
$value = array();
} else {
$value = array(strval($value));
}
}
$this->attributes[$attribute] = array_unique($value);
}
}
return $this;
} | Set the value or values of an attribute or an array thereof. Already existent attributes are overwritten.
@param string|array|\Thin\Html\Attributes $attribute The name of the attribute to set, a name-value array of attributes or an attributes object
@param string|array $value In case the first parametre is a string, value or array of values for the set attribute
@return \Thin\Html\Attributes Provides a fluent interface | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Attributes.php#L64-L93 |
schpill/thin | src/Html/Attributes.php | Attributes.remove | public function remove($attribute, $value = null)
{
$attribute = strval($attribute);
if(\Thin\Arrays::exists($attribute, $this->attributes)) {
if(null === $value) {
unset($this->attributes[$attribute]);
} else {
$value = strval($value);
foreach($this->attributes[$attribute] as $k => $v) {
if($v == $value) {
unset($this->attributes[$attribute][$k]);
}
}
}
}
return $this;
} | php | public function remove($attribute, $value = null)
{
$attribute = strval($attribute);
if(\Thin\Arrays::exists($attribute, $this->attributes)) {
if(null === $value) {
unset($this->attributes[$attribute]);
} else {
$value = strval($value);
foreach($this->attributes[$attribute] as $k => $v) {
if($v == $value) {
unset($this->attributes[$attribute][$k]);
}
}
}
}
return $this;
} | Remove an attribute or a value
@param string $attribute The attribute name to remove(or to remove a value from)
@param string $value The value to remove from the attribute. Omit the parametre to remove the entire attribute.
@return \Thin\Html\Attributes Provides a fluent interface | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Attributes.php#L103-L121 |
schpill/thin | src/Html/Attributes.php | Attributes.getArray | public function getArray($attribute = null)
{
if(null === $attribute) {
return $this->attributes;
} else {
$attribute = strval($attribute);
if(ake($attribute, $this->attributes)) {
return $this->attributes[$attribute];
}
}
return null;
} | php | public function getArray($attribute = null)
{
if(null === $attribute) {
return $this->attributes;
} else {
$attribute = strval($attribute);
if(ake($attribute, $this->attributes)) {
return $this->attributes[$attribute];
}
}
return null;
} | Get the entire attributes array or the array of values for a single attribute.
@param string $attribute The attribute whose values are to be retrieved. Omit the parametre to fetch the entire array of attributes.
@return array|null The attribute or attributes or null in case a nonexistent attribute is requested | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Attributes.php#L130-L142 |
schpill/thin | src/Html/Attributes.php | Attributes.getHtml | public function getHtml($attribute = null)
{
if(null !== $attribute) {
$attribute = strval($attribute);
if(\Thin\Arrays::exists($attribute, $this->attributes)) {
return $attribute . '="' . implode(' ', $this->attributes[$attribute]) . '"';
}
} else {
$return = array();
foreach(array_keys($this->attributes) as $attrib) {
$return[] = $this->getHtml($attrib);
}
return implode(' ', $return);
}
return '';
} | php | public function getHtml($attribute = null)
{
if(null !== $attribute) {
$attribute = strval($attribute);
if(\Thin\Arrays::exists($attribute, $this->attributes)) {
return $attribute . '="' . implode(' ', $this->attributes[$attribute]) . '"';
}
} else {
$return = array();
foreach(array_keys($this->attributes) as $attrib) {
$return[] = $this->getHtml($attrib);
}
return implode(' ', $return);
}
return '';
} | Generate the HTML code for the attributes
@param string $attribute The attribute for which HTML code is to be generated. Omit the parametre to generate HTML code for all attributes.
@return string HTML code | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Attributes.php#L151-L167 |
schpill/thin | src/Html/Attributes.php | Attributes.exists | public function exists($attribute, $value = null)
{
$attribute = strval($attribute);
if(\Thin\Arrays::exists($attribute, $this->attributes)) {
if(null === $value || in_array(strval($value), $this->attributes[$attribute])) {
return true;
}
}
return false;
} | php | public function exists($attribute, $value = null)
{
$attribute = strval($attribute);
if(\Thin\Arrays::exists($attribute, $this->attributes)) {
if(null === $value || in_array(strval($value), $this->attributes[$attribute])) {
return true;
}
}
return false;
} | Check whether a given attribute or attribute value exists
@param string $attribute Attribute name whose existence is to be checked
@param string $value The attribute's value to be checked. Omit the parametre to check the existence of the attribute.
@return boolean | https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Attributes.php#L187-L198 |
drakonli/php-imap | src/PhpImap/Dependency/Container/Loader/Basic/BasicDependencyContainerLoader.php | BasicDependencyContainerLoader.loadContainer | public function loadContainer(array $additionalConfigsToLoad)
{
$configsDir = sprintf('%1$s/..%2$s..%2$s..%2$sResources%2$sconfigs', __DIR__, DIRECTORY_SEPARATOR);
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator($configsDir));
$loader->load('services.yml');
$loader->load('parameters.yml');
foreach ($additionalConfigsToLoad as $config) {
$additionalLoader = new YamlFileLoader($container, new FileLocator($config->getPath()));
$additionalLoader->load($config->getPathname());
}
$container->compile();
return $container;
} | php | public function loadContainer(array $additionalConfigsToLoad)
{
$configsDir = sprintf('%1$s/..%2$s..%2$s..%2$sResources%2$sconfigs', __DIR__, DIRECTORY_SEPARATOR);
$container = new ContainerBuilder();
$loader = new YamlFileLoader($container, new FileLocator($configsDir));
$loader->load('services.yml');
$loader->load('parameters.yml');
foreach ($additionalConfigsToLoad as $config) {
$additionalLoader = new YamlFileLoader($container, new FileLocator($config->getPath()));
$additionalLoader->load($config->getPathname());
}
$container->compile();
return $container;
} | @param array|SplFileInfo[] $additionalConfigsToLoad
@return ContainerBuilder | https://github.com/drakonli/php-imap/blob/966dbb5d639897712d1570d62d3ce9bde3376089/src/PhpImap/Dependency/Container/Loader/Basic/BasicDependencyContainerLoader.php#L21-L38 |
tigron/skeleton-migrate | console/run.php | Migrate_Run.execute | protected function execute(InputInterface $input, OutputInterface $output) {
if (!file_exists(\Skeleton\Database\Migration\Config::$migration_directory)) {
$output->writeln('<error>Config::$migration_directory is not set to a valid directory</error>');
return 1;
}
$migration = \Skeleton\Database\Migration::get_by_version($input->getArgument('name'));
try {
$migration->up();
$output->writeln(get_class($migration) . "\t" . ' <info>ok</info>');
} catch (\Exception $e) {
$output->writeln(get_class($migration) . "\t" . ' <error>' . $e->getMessage() . '</error>');
$output->writeln('<comment>' . $e->getTraceAsString() . '</comment>');
return 1;
}
return 0;
} | php | protected function execute(InputInterface $input, OutputInterface $output) {
if (!file_exists(\Skeleton\Database\Migration\Config::$migration_directory)) {
$output->writeln('<error>Config::$migration_directory is not set to a valid directory</error>');
return 1;
}
$migration = \Skeleton\Database\Migration::get_by_version($input->getArgument('name'));
try {
$migration->up();
$output->writeln(get_class($migration) . "\t" . ' <info>ok</info>');
} catch (\Exception $e) {
$output->writeln(get_class($migration) . "\t" . ' <error>' . $e->getMessage() . '</error>');
$output->writeln('<comment>' . $e->getTraceAsString() . '</comment>');
return 1;
}
return 0;
} | Execute the Command
@access protected
@param InputInterface $input
@param OutputInterface $output | https://github.com/tigron/skeleton-migrate/blob/53b6ea56e928d4f925257949e59467d2d9cbafd4/console/run.php#L35-L53 |
PhoxPHP/Glider | src/Query/Builder/Type.php | Type.getStatementType | public static function getStatementType(String $query) : Int
{
$type = 0;
if (preg_match("/^SELECT|select|Select([^ ]+)/", $query)) {
$type = 1;
}
if (preg_match("/^INSERT([^ ]+)/", $query)) {
$type = 2;
}
if (preg_match("/^UPDATE([^ ]+)/", $query)) {
$type = 3;
}
if (preg_match("/^DELETE([^ ]+)/", $query)) {
$type = 4;
}
return $type;
} | php | public static function getStatementType(String $query) : Int
{
$type = 0;
if (preg_match("/^SELECT|select|Select([^ ]+)/", $query)) {
$type = 1;
}
if (preg_match("/^INSERT([^ ]+)/", $query)) {
$type = 2;
}
if (preg_match("/^UPDATE([^ ]+)/", $query)) {
$type = 3;
}
if (preg_match("/^DELETE([^ ]+)/", $query)) {
$type = 4;
}
return $type;
} | This method gets and returns the statement type.
@param $query <String>
@access public
@return <Integer> | https://github.com/PhoxPHP/Glider/blob/17aaf3b7bb6e70ea3ae1f04e30a7690e884bf042/src/Query/Builder/Type.php#L35-L55 |
OpenClassrooms/DoctrineCacheExtensionBundle | DependencyInjection/Compiler/DebugServiceCompilerPass.php | DebugServiceCompilerPass.process | public function process(ContainerBuilder $container)
{
parent::process($container);
foreach ($container->getServiceIds() as $serviceId) {
if (strpos($serviceId, 'doctrine_cache.providers.') === 0) {
$definition = $container->findDefinition($serviceId);
$definition->addMethodCall('setProviderId', [$serviceId]);
}
}
} | php | public function process(ContainerBuilder $container)
{
parent::process($container);
foreach ($container->getServiceIds() as $serviceId) {
if (strpos($serviceId, 'doctrine_cache.providers.') === 0) {
$definition = $container->findDefinition($serviceId);
$definition->addMethodCall('setProviderId', [$serviceId]);
}
}
} | {@inheritdoc} | https://github.com/OpenClassrooms/DoctrineCacheExtensionBundle/blob/c6d1ded7e5a22b20643486cb3fa84cddd86135a5/DependencyInjection/Compiler/DebugServiceCompilerPass.php#L15-L24 |
edrush/extbaser | lib/EdRush/Extbaser/VO/ExtensionBuilderConfiguration.php | ExtensionBuilderConfiguration.getModuleByName | public function getModuleByName($name)
{
foreach ($this->modules as $module) {
/* @var $module Module */
if ($name == $module->getValue()->getName()) {
return $module;
}
}
return false;
} | php | public function getModuleByName($name)
{
foreach ($this->modules as $module) {
/* @var $module Module */
if ($name == $module->getValue()->getName()) {
return $module;
}
}
return false;
} | @param string $name
@return \EdRush\Extbaser\VO\ExtensionBuilderConfiguration\Module|bool | https://github.com/edrush/extbaser/blob/760ae29b8de4b33ac1f06241caeaa8d78bb9cd99/lib/EdRush/Extbaser/VO/ExtensionBuilderConfiguration.php#L60-L70 |
skeeks-cms/cms-search | src/console/controllers/ClearController.php | ClearController.actionPhrase | public function actionPhrase()
{
$this->stdout('phraseLiveTime: ' . \Yii::$app->cmsSearch->phraseLiveTime . "\n");
if (\Yii::$app->cmsSearch->phraseLiveTime) {
$deleted = CmsSearchPhrase::deleteAll([
'<=',
'created_at',
\Yii::$app->formatter->asTimestamp(time()) - (int)\Yii::$app->cmsSearch->phraseLiveTime
]);
$message = \Yii::t('skeeks/search', 'Removing searches') . " :" . $deleted;
\Yii::info($message, 'skeeks/search');
$this->stdout("\t" . $message . "\n");
}
} | php | public function actionPhrase()
{
$this->stdout('phraseLiveTime: ' . \Yii::$app->cmsSearch->phraseLiveTime . "\n");
if (\Yii::$app->cmsSearch->phraseLiveTime) {
$deleted = CmsSearchPhrase::deleteAll([
'<=',
'created_at',
\Yii::$app->formatter->asTimestamp(time()) - (int)\Yii::$app->cmsSearch->phraseLiveTime
]);
$message = \Yii::t('skeeks/search', 'Removing searches') . " :" . $deleted;
\Yii::info($message, 'skeeks/search');
$this->stdout("\t" . $message . "\n");
}
} | Remove old searches | https://github.com/skeeks-cms/cms-search/blob/2fcd8c6343f46938c5cc5829bbb4c9a83593092d/src/console/controllers/ClearController.php#L26-L41 |
diasbruno/stc | lib/stc/DataWriter.php | DataWriter.write_to | private function write_to($file, $data)
{
$handler = fopen($file, "w");
fwrite($handler, $data);
fclose($handler);
} | php | private function write_to($file, $data)
{
$handler = fopen($file, "w");
fwrite($handler, $data);
fclose($handler);
} | Creates the handler and writes the files.
@param $file string | The filename.
@return string | https://github.com/diasbruno/stc/blob/43f62c3b28167bff76274f954e235413a9e9c707/lib/stc/DataWriter.php#L21-L26 |
diasbruno/stc | lib/stc/DataWriter.php | DataWriter.write | public function write($path = '', $file = '', $content = '')
{
$the_path = Application::config()->public_folder() . '/' . $path;
@mkdir($the_path, 0755, true);
$this->write_to($the_path . '/'. $file, $content);
} | php | public function write($path = '', $file = '', $content = '')
{
$the_path = Application::config()->public_folder() . '/' . $path;
@mkdir($the_path, 0755, true);
$this->write_to($the_path . '/'. $file, $content);
} | Write the file.
@param $path string | The path where the file is located.
@param $file string | The filename.
@param $content string | The file content.
@return string | https://github.com/diasbruno/stc/blob/43f62c3b28167bff76274f954e235413a9e9c707/lib/stc/DataWriter.php#L35-L41 |
chenshenchao/palex | main/crypt/RSAPublicKey.php | RsaPublicKey.decrypt | public function decrypt($data) {
if (is_array($data)) return array_map([$this, __FUNCTION__], $data);
$raw = base64_decode($data);
openssl_public_decrypt($raw, $result, $this->key);
return $result;
} | php | public function decrypt($data) {
if (is_array($data)) return array_map([$this, __FUNCTION__], $data);
$raw = base64_decode($data);
openssl_public_decrypt($raw, $result, $this->key);
return $result;
} | encrypt by key.
@param string|array $data: decrypt data reference. | https://github.com/chenshenchao/palex/blob/9d809a876c4a996d3bd38634c4fc2f0a93301838/main/crypt/RSAPublicKey.php#L34-L39 |
RadialCorp/magento-core | src/lib/Radial/RiskService/Sdk/Api.php | Radial_RiskService_Sdk_Api._deserializeResponse | protected function _deserializeResponse($responseData)
{
try {
$this->getResponseBody()->deserialize($responseData);
} catch (Radial_RiskService_Sdk_Exception_Invalid_Payload_Exception $e) {
$logMessage = sprintf('[%s] Error Payload Response Body: %s', __CLASS__, $this->cleanAuthXml($responseData));
Mage::log($logMessage, Zend_Log::WARN);
}
if ($this->_helperConfig->isDebugMode()) {
$logMessage = sprintf('[%s] Response Body: %s', __CLASS__, $this->cleanAuthXml($responseData));
Mage::log($logMessage, Zend_Log::DEBUG);
}
return $this;
} | php | protected function _deserializeResponse($responseData)
{
try {
$this->getResponseBody()->deserialize($responseData);
} catch (Radial_RiskService_Sdk_Exception_Invalid_Payload_Exception $e) {
$logMessage = sprintf('[%s] Error Payload Response Body: %s', __CLASS__, $this->cleanAuthXml($responseData));
Mage::log($logMessage, Zend_Log::WARN);
}
if ($this->_helperConfig->isDebugMode()) {
$logMessage = sprintf('[%s] Response Body: %s', __CLASS__, $this->cleanAuthXml($responseData));
Mage::log($logMessage, Zend_Log::DEBUG);
}
return $this;
} | Deserialized the response xml into response payload if an exception is thrown catch it
and set the error payload and deserialized the response xml into it.
@param string
@return self | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/lib/Radial/RiskService/Sdk/Api.php#L94-L107 |
RadialCorp/magento-core | src/lib/Radial/RiskService/Sdk/Api.php | Radial_RiskService_Sdk_Api._sendRequest | protected function _sendRequest()
{
// clear the old response
$this->_lastRequestsResponse = null;
$httpMethod = strtolower($this->_config->getHttpMethod());
if (!method_exists($this, $httpMethod)) {
throw Mage::exception(
'Radial_RiskService_Sdk_Exception_Unsupported_Http_Action',
sprintf('HTTP action %s not supported.', strtoupper($httpMethod))
);
}
return $this->$httpMethod();
} | php | protected function _sendRequest()
{
// clear the old response
$this->_lastRequestsResponse = null;
$httpMethod = strtolower($this->_config->getHttpMethod());
if (!method_exists($this, $httpMethod)) {
throw Mage::exception(
'Radial_RiskService_Sdk_Exception_Unsupported_Http_Action',
sprintf('HTTP action %s not supported.', strtoupper($httpMethod))
);
}
return $this->$httpMethod();
} | Send get or post CURL request to the API URI.
@return boolean
@throws Radial_RiskService_Sdk_Exception_Unsupported_Http_Action_Exception | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/lib/Radial/RiskService/Sdk/Api.php#L175-L188 |
RadialCorp/magento-core | src/lib/Radial/RiskService/Sdk/Api.php | Radial_RiskService_Sdk_Api._post | protected function _post()
{
$requestXml = $this->getRequestBody()->serialize();
if ($this->_helperConfig->isDebugMode()) {
$logMessage = sprintf('[%s] Request Body: %s', __CLASS__, $this->cleanAuthXml($requestXml));
Mage::log($logMessage, Zend_Log::DEBUG);
}
$xml = simplexml_load_string($requestXml);
if( strcmp($xml->getName(), "RiskAssessmentRequest") === 0)
{
//Note this is a really crude way of doing this, but since this SDK is only for Risk Assess right now... IDC
$hostname = "https://". $this->_config->getEndpoint() . "/v1.0/stores/". $this->_config->getStoreId() . "/risk/fraud/assess.xml";
} elseif ( strcmp($xml->getName(), "RiskOrderConfirmationRequest") === 0 ) {
//Note this is a really crude way of doing this, but since this SDK is only for Risk Assess right now... IDC
$hostname = "https://". $this->_config->getEndpoint() . "/v1.0/stores/". $this->_config->getStoreId() . "/risk/fraud/orderConfirmation.xml";
} else {
throw Mage::exception('Radial_RiskService_Sdk_Exception_Network_Error', "Unsupported Payload - ". $xml->getName());
}
$options = array();
if( $this->_config->getResponseTimeout() )
{
$seconds = (float)$this->_config->getResponseTimeout() / 1000.0;
$options = array( 'timeout' => $seconds );
}
$this->_lastRequestsResponse = Requests::post(
$hostname,
$this->_buildHeader(),
$requestXml,
$options
);
return $this->_lastRequestsResponse->success;
} | php | protected function _post()
{
$requestXml = $this->getRequestBody()->serialize();
if ($this->_helperConfig->isDebugMode()) {
$logMessage = sprintf('[%s] Request Body: %s', __CLASS__, $this->cleanAuthXml($requestXml));
Mage::log($logMessage, Zend_Log::DEBUG);
}
$xml = simplexml_load_string($requestXml);
if( strcmp($xml->getName(), "RiskAssessmentRequest") === 0)
{
//Note this is a really crude way of doing this, but since this SDK is only for Risk Assess right now... IDC
$hostname = "https://". $this->_config->getEndpoint() . "/v1.0/stores/". $this->_config->getStoreId() . "/risk/fraud/assess.xml";
} elseif ( strcmp($xml->getName(), "RiskOrderConfirmationRequest") === 0 ) {
//Note this is a really crude way of doing this, but since this SDK is only for Risk Assess right now... IDC
$hostname = "https://". $this->_config->getEndpoint() . "/v1.0/stores/". $this->_config->getStoreId() . "/risk/fraud/orderConfirmation.xml";
} else {
throw Mage::exception('Radial_RiskService_Sdk_Exception_Network_Error', "Unsupported Payload - ". $xml->getName());
}
$options = array();
if( $this->_config->getResponseTimeout() )
{
$seconds = (float)$this->_config->getResponseTimeout() / 1000.0;
$options = array( 'timeout' => $seconds );
}
$this->_lastRequestsResponse = Requests::post(
$hostname,
$this->_buildHeader(),
$requestXml,
$options
);
return $this->_lastRequestsResponse->success;
} | Send post CURL request.
@return Requests_Response
@throws Requests_Exception | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/lib/Radial/RiskService/Sdk/Api.php#L196-L231 |
RadialCorp/magento-core | src/lib/Radial/RiskService/Sdk/Api.php | Radial_RiskService_Sdk_Api._get | protected function _get()
{
$this->_lastRequestsResponse = Requests::post(
$this->_config->getEndpoint(),
$this->_buildHeader()
);
return $this->_lastRequestsResponse->success;
} | php | protected function _get()
{
$this->_lastRequestsResponse = Requests::post(
$this->_config->getEndpoint(),
$this->_buildHeader()
);
return $this->_lastRequestsResponse->success;
} | Send get CURL request.
@return Requests_Response
@throws Requests_Exception | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/lib/Radial/RiskService/Sdk/Api.php#L252-L259 |
RadialCorp/magento-core | src/lib/Radial/RiskService/Sdk/Api.php | Radial_RiskService_Sdk_Api.cleanAuthXml | public function cleanAuthXml($xml)
{
$xml = preg_replace('#(\<(?:Encrypted)?CardSecurityCode\>).*(\</(?:Encrypted)?CardSecurityCode\>)#', '$1***$2', $xml);
$xml = preg_replace('#(\<(?:Encrypted)?PaymentAccountUniqueId.*?\>).*(\</(?:Encrypted)?PaymentAccountUniqueId\>)#', '$1***$2', $xml);
$xml = preg_replace('#(\<(?:Encrypted)?AccountID.*?\>).*(\</(?:Encrypted)?AccountID\>)#', '$1***$2', $xml);
return $xml;
} | php | public function cleanAuthXml($xml)
{
$xml = preg_replace('#(\<(?:Encrypted)?CardSecurityCode\>).*(\</(?:Encrypted)?CardSecurityCode\>)#', '$1***$2', $xml);
$xml = preg_replace('#(\<(?:Encrypted)?PaymentAccountUniqueId.*?\>).*(\</(?:Encrypted)?PaymentAccountUniqueId\>)#', '$1***$2', $xml);
$xml = preg_replace('#(\<(?:Encrypted)?AccountID.*?\>).*(\</(?:Encrypted)?AccountID\>)#', '$1***$2', $xml);
return $xml;
} | Scrub the auth request XML message of any sensitive data - CVV, CC number.
@param string $xml
@return string | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/lib/Radial/RiskService/Sdk/Api.php#L266-L272 |
xiewulong/yii2-wechat | models/WechatNews.php | WechatNews.getArticles | public function getArticles(&$manager = null) {
$articles = [];
foreach($this->items as $item) {
$item->manager = $manager;
$articles[] = $item->json;
}
return $articles;
} | php | public function getArticles(&$manager = null) {
$articles = [];
foreach($this->items as $item) {
$item->manager = $manager;
$articles[] = $item->json;
}
return $articles;
} | 获取整组图文素材
@method getArticles
@since 0.0.1
@param {object} [&$manager] wechat扩展对象
@return {array}
@example $this->getArticles($manager); | https://github.com/xiewulong/yii2-wechat/blob/e7a209072c9d16bd6ec8d51808439f806c3e56a2/models/WechatNews.php#L30-L38 |
drmvc/router | src/Router/Router.php | Router.set | public function set(array $methods, array $args): RouterInterface
{
list($pattern, $callable) = $args;
$route = new Route($methods, $pattern, $callable);
$this->setRoute($route);
return $this;
} | php | public function set(array $methods, array $args): RouterInterface
{
list($pattern, $callable) = $args;
$route = new Route($methods, $pattern, $callable);
$this->setRoute($route);
return $this;
} | Abstraction of setter
@param array $methods
@param array $args
@return RouterInterface | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L80-L86 |
drmvc/router | src/Router/Router.php | Router.checkMethods | public function checkMethods(array $methods): array
{
return array_map(
function($method) {
$method = strtolower($method);
if (!\in_array($method, self::METHODS, false)) {
throw new Exception("Method \"$method\" is not in allowed list [" . implode(',',
self::METHODS) . ']');
}
return $method;
},
$methods
);
} | php | public function checkMethods(array $methods): array
{
return array_map(
function($method) {
$method = strtolower($method);
if (!\in_array($method, self::METHODS, false)) {
throw new Exception("Method \"$method\" is not in allowed list [" . implode(',',
self::METHODS) . ']');
}
return $method;
},
$methods
);
} | Check if passed methods in allowed list
@param array $methods list of methods for check
@throws Exception
@return array | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L95-L108 |
drmvc/router | src/Router/Router.php | Router.map | public function map(array $methods, string $pattern, $callable): MethodsInterface
{
// Check if method in allowed list
$methods = $this->checkMethods($methods);
// Set new route with parameters
$this->set($methods, [$pattern, $callable]);
return $this;
} | php | public function map(array $methods, string $pattern, $callable): MethodsInterface
{
// Check if method in allowed list
$methods = $this->checkMethods($methods);
// Set new route with parameters
$this->set($methods, [$pattern, $callable]);
return $this;
} | Callable must be only selected methods
@param array $methods
@param string $pattern
@param callable|string $callable
@throws Exception
@return MethodsInterface | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L119-L128 |
drmvc/router | src/Router/Router.php | Router.any | public function any(string $pattern, $callable): MethodsInterface
{
// Set new route with all methods
$this->set(self::METHODS, [$pattern, $callable]);
return $this;
} | php | public function any(string $pattern, $callable): MethodsInterface
{
// Set new route with all methods
$this->set(self::METHODS, [$pattern, $callable]);
return $this;
} | Any method should be callable
@param string $pattern
@param callable|string $callable
@return MethodsInterface | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L137-L143 |
drmvc/router | src/Router/Router.php | Router.setRoute | public function setRoute(RouteInterface $route): RouterInterface
{
$regexp = $route->getRegexp();
$this->_routes[$regexp] = $route;
return $this;
} | php | public function setRoute(RouteInterface $route): RouterInterface
{
$regexp = $route->getRegexp();
$this->_routes[$regexp] = $route;
return $this;
} | Add route into the array of routes
@param RouteInterface $route
@return RouterInterface | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L225-L230 |
drmvc/router | src/Router/Router.php | Router.checkMatches | private function checkMatches(string $uri, string $method): array
{
return array_map(
function($regexp, $route) use ($uri, $method) {
$match = preg_match_all($regexp, $uri, $matches);
// If something found and method is correct
if ($match && $route->checkMethod($method)) {
// Set array of variables
$route->setVariables($matches);
return $route;
}
return null;
},
// Array with keys
$this->getRoutes(true),
// Array with values
$this->getRoutes()
);
} | php | private function checkMatches(string $uri, string $method): array
{
return array_map(
function($regexp, $route) use ($uri, $method) {
$match = preg_match_all($regexp, $uri, $matches);
// If something found and method is correct
if ($match && $route->checkMethod($method)) {
// Set array of variables
$route->setVariables($matches);
return $route;
}
return null;
},
// Array with keys
$this->getRoutes(true),
// Array with values
$this->getRoutes()
);
} | Find route object by URL nad method
@param string $uri
@param string $method
@return array | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L239-L258 |
drmvc/router | src/Router/Router.php | Router.getMatches | private function getMatches(): array
{
// Extract URI of current query
$uri = $this->getRequest()->getUri()->getPath();
// Extract method of current request
$method = $this->getRequest()->getMethod();
$method = strtolower($method);
// Foreach emulation
return $this->checkMatches($uri, $method);
} | php | private function getMatches(): array
{
// Extract URI of current query
$uri = $this->getRequest()->getUri()->getPath();
// Extract method of current request
$method = $this->getRequest()->getMethod();
$method = strtolower($method);
// Foreach emulation
return $this->checkMatches($uri, $method);
} | Find optimal route from array of routes by regexp and uri
@return array | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L265-L276 |
drmvc/router | src/Router/Router.php | Router.getRoute | public function getRoute(): RouteInterface
{
// Find route by regexp and URI
$matches = $this->getMatches();
// Cleanup the array of matches, then reindex array
$matches = array_values(array_filter($matches));
// If we have some classes in result of regexp
$result = !empty($matches)
// Take first from matches
? $matches[0] // Here the Route() object
// Create new object with error inside
: $this->getError();
return $result;
} | php | public function getRoute(): RouteInterface
{
// Find route by regexp and URI
$matches = $this->getMatches();
// Cleanup the array of matches, then reindex array
$matches = array_values(array_filter($matches));
// If we have some classes in result of regexp
$result = !empty($matches)
// Take first from matches
? $matches[0] // Here the Route() object
// Create new object with error inside
: $this->getError();
return $result;
} | Parse URI by Regexp from routes and return single route
@return RouteInterface | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L283-L299 |
drmvc/router | src/Router/Router.php | Router.getRoutes | public function getRoutes(bool $keys = false): array
{
return $keys
? array_keys($this->_routes)
: $this->_routes;
} | php | public function getRoutes(bool $keys = false): array
{
return $keys
? array_keys($this->_routes)
: $this->_routes;
} | Get all available routes
@param bool $keys - Return only keys
@return array | https://github.com/drmvc/router/blob/ecbf5f4380a060af83af23334b9f81054bc6c64c/src/Router/Router.php#L307-L312 |
ekyna/AdminBundle | Table/Type/ResourceTableType.php | ResourceTableType.configureOptions | public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults([
'data_class' => $this->dataClass,
'selector_config' => [
'property_path' => 'id',
'data_map' => ['id', 'name' => null],
]
]);
} | php | public function configureOptions(OptionsResolver $resolver)
{
parent::configureOptions($resolver);
$resolver->setDefaults([
'data_class' => $this->dataClass,
'selector_config' => [
'property_path' => 'id',
'data_map' => ['id', 'name' => null],
]
]);
} | {@inheritdoc} | https://github.com/ekyna/AdminBundle/blob/3f58e253ae9cf651add7f3d587caec80eaea459a/Table/Type/ResourceTableType.php#L31-L42 |
interactivesolutions/honeycomb-scripts | src/app/commands/HCUpdate.php | HCUpdate.handle | public function handle ()
{
$this->call('vendor:publish', ['--force' => true, '--tag' => "public"]);
$this->call('vendor:publish', ['--tag' => "migrations"]);
$this->call('vendor:publish', ['--tag' => "config"]);
if (app()->environment() == 'production') {
$this->call('migrate', ['--force' => true]);
} else {
$this->call('migrate');
}
$this->call('hc:seed');
$this->call('hc:routes');
$this->call('hc:forms');
$this->call('hc:languages');
$this->call('hc:permissions');
$this->call('hc:admin-menu');
File::delete ('bootstrap/cache/config.php');
File::delete ('bootstrap/cache/services.php');
if (app()->environment() == 'production')
$this->call('config:cache');
} | php | public function handle ()
{
$this->call('vendor:publish', ['--force' => true, '--tag' => "public"]);
$this->call('vendor:publish', ['--tag' => "migrations"]);
$this->call('vendor:publish', ['--tag' => "config"]);
if (app()->environment() == 'production') {
$this->call('migrate', ['--force' => true]);
} else {
$this->call('migrate');
}
$this->call('hc:seed');
$this->call('hc:routes');
$this->call('hc:forms');
$this->call('hc:languages');
$this->call('hc:permissions');
$this->call('hc:admin-menu');
File::delete ('bootstrap/cache/config.php');
File::delete ('bootstrap/cache/services.php');
if (app()->environment() == 'production')
$this->call('config:cache');
} | Execute the console command.
@return mixed | https://github.com/interactivesolutions/honeycomb-scripts/blob/be2428ded5219dc612ecc51f43aa4dedff3d034d/src/app/commands/HCUpdate.php#L29-L53 |
matryoshka-model/matryoshka | library/Hydrator/Strategy/SetTypeStrategy.php | SetTypeStrategy.extract | public function extract($value)
{
if ($this->nullable && $value === null) {
return null;
}
settype($value, $this->extractToType);
return $value;
} | php | public function extract($value)
{
if ($this->nullable && $value === null) {
return null;
}
settype($value, $this->extractToType);
return $value;
} | Converts the given value so that it can be extracted by the hydrator.
@param mixed $value The original value.
@return mixed Returns the value that should be extracted. | https://github.com/matryoshka-model/matryoshka/blob/51792df00d9897f556d5a3c53193eed0974ff09d/library/Hydrator/Strategy/SetTypeStrategy.php#L52-L59 |
matryoshka-model/matryoshka | library/Hydrator/Strategy/SetTypeStrategy.php | SetTypeStrategy.hydrate | public function hydrate($value)
{
if ($this->nullable && $value === null) {
return null;
}
settype($value, $this->hydrateToType);
return $value;
} | php | public function hydrate($value)
{
if ($this->nullable && $value === null) {
return null;
}
settype($value, $this->hydrateToType);
return $value;
} | Converts the given value so that it can be hydrated by the hydrator.
@param mixed $value The original value.
@return mixed Returns the value that should be hydrated. | https://github.com/matryoshka-model/matryoshka/blob/51792df00d9897f556d5a3c53193eed0974ff09d/library/Hydrator/Strategy/SetTypeStrategy.php#L67-L74 |
wigedev/farm | src/Utility/ValueMap.php | ValueMap.get | public function get(string $index) : string
{
if (!$this->isValid($index)) {
throw new \InvalidArgumentException('The specified value does not exist');
}
return $this->map[$index];
} | php | public function get(string $index) : string
{
if (!$this->isValid($index)) {
throw new \InvalidArgumentException('The specified value does not exist');
}
return $this->map[$index];
} | Retrieve a value
@param string $index
@return string | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/Utility/ValueMap.php#L22-L28 |
wigedev/farm | src/Utility/ValueMap.php | ValueMap.addValue | public function addValue(string $key, string $value) : void
{
$this->map[$key] = $value;
} | php | public function addValue(string $key, string $value) : void
{
$this->map[$key] = $value;
} | Add a new value to the map
@param string $key
@param string $value | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/Utility/ValueMap.php#L47-L50 |
wigedev/farm | src/Utility/ValueMap.php | ValueMap.deleteValue | public function deleteValue(string $key) : void
{
if (isset($this->map[$key])) {
unset($this->map[$key]);
}
} | php | public function deleteValue(string $key) : void
{
if (isset($this->map[$key])) {
unset($this->map[$key]);
}
} | Delete a value from the map based on the key
@param string $key | https://github.com/wigedev/farm/blob/7a1729ec78628b7e5435e4a42e42d547a07af851/src/Utility/ValueMap.php#L56-L61 |
valu-digital/valuso | src/ValuSo/Broker/ServiceBrokerFactory.php | ServiceBrokerFactory.createService | public function createService(ServiceLocatorInterface $serviceLocator)
{
$evm = $serviceLocator->get('EventManager');
$config = $serviceLocator->get('Config');
$config = empty($config['valu_so']) ? [] : $config['valu_so'];
$cacheConfig = isset($config['cache']) ? $config['cache'] : null;
/**
* Configure loader
*/
$loaderOptions = array(
'locator' => $serviceLocator->createScopedServiceManager()
);
if (!empty($config['services'])) {
$loaderOptions['services'] = $config['services'];
}
unset($config['services']);
if (isset($config['use_main_locator']) && $config['use_main_locator']) {
$peeringManager = $serviceLocator;
} else {
$peeringManager = null;
}
unset($config['use_main_locator']);
// Pass other configurations as service plugin manager configuration
if (!empty($config)) {
if (isset($cacheConfig['enabled']) && !$cacheConfig['enabled']) {
unset($config['cache']);
} elseif (!isset($cacheConfig['adapter']) && isset($cacheConfig['service'])) {
$cache = $serviceLocator->get($cacheConfig['service']);
if ($cache instanceof StorageInterface) {
$config['cache'] = $cache;
}
}
$smConfig = new ServicePluginManagerConfig($config);
$loaderOptions['service_manager'] = $smConfig;
}
// Initialize loader
$loader = new ServiceLoader(
$loaderOptions
);
if ($peeringManager) {
$loader->addPeeringServiceManager($peeringManager);
}
$broker = new ServiceBroker();
$broker->setLoader($loader);
$this->configureQueue($serviceLocator, $config, $broker);
// Attach configured event listeners
if (!empty($config['listeners'])) {
EventManagerConfigurator::configure(
$broker->getEventManager(),
$serviceLocator,
$config['listeners']);
}
$evm->trigger('valu_so.servicebroker.init', $broker);
return $broker;
} | php | public function createService(ServiceLocatorInterface $serviceLocator)
{
$evm = $serviceLocator->get('EventManager');
$config = $serviceLocator->get('Config');
$config = empty($config['valu_so']) ? [] : $config['valu_so'];
$cacheConfig = isset($config['cache']) ? $config['cache'] : null;
/**
* Configure loader
*/
$loaderOptions = array(
'locator' => $serviceLocator->createScopedServiceManager()
);
if (!empty($config['services'])) {
$loaderOptions['services'] = $config['services'];
}
unset($config['services']);
if (isset($config['use_main_locator']) && $config['use_main_locator']) {
$peeringManager = $serviceLocator;
} else {
$peeringManager = null;
}
unset($config['use_main_locator']);
// Pass other configurations as service plugin manager configuration
if (!empty($config)) {
if (isset($cacheConfig['enabled']) && !$cacheConfig['enabled']) {
unset($config['cache']);
} elseif (!isset($cacheConfig['adapter']) && isset($cacheConfig['service'])) {
$cache = $serviceLocator->get($cacheConfig['service']);
if ($cache instanceof StorageInterface) {
$config['cache'] = $cache;
}
}
$smConfig = new ServicePluginManagerConfig($config);
$loaderOptions['service_manager'] = $smConfig;
}
// Initialize loader
$loader = new ServiceLoader(
$loaderOptions
);
if ($peeringManager) {
$loader->addPeeringServiceManager($peeringManager);
}
$broker = new ServiceBroker();
$broker->setLoader($loader);
$this->configureQueue($serviceLocator, $config, $broker);
// Attach configured event listeners
if (!empty($config['listeners'])) {
EventManagerConfigurator::configure(
$broker->getEventManager(),
$serviceLocator,
$config['listeners']);
}
$evm->trigger('valu_so.servicebroker.init', $broker);
return $broker;
} | Create a ServiceBroker
{@see ValuSo\Broker\ServiceBroker} uses {@see Zend\ServiceManager\ServiceManager} internally to initialize service
instances. {@see Zend\Mvc\Service\ServiceManagerConfig} for how to configure service manager.
This factory uses following configuration scheme:
<code>
[
'valu_so' => [
// See Zend\Mvc\Service\ServiceManagerConfig
'initializers' => [...],
// Set true to add main service locator as a peering service manager
'use_main_locator' => <true>|<false>,
// See Zend\Mvc\Service\ServiceManagerConfig
'factories' => [...],
// See Zend\Mvc\Service\ServiceManagerConfig
'invokables' => [...],
// See Zend\Mvc\Service\ServiceManagerConfig
'abstract_factories' => [...],
// See Zend\Mvc\Service\ServiceManagerConfig
'shared' => [...],
// See Zend\Mvc\Service\ServiceManagerConfig
'aliases' => [...],
'cache' => [
'enabled' => true|false,
'adapter' => '<ZendCacheAdapter>',
'service' => '<ServiceNameReturningCacheAdapter',
<adapterConfig> => <value>...
],
'services' => [
'<id>' => [
// Name of the service
'name' => '<ServiceName>',
// [optional] Options passed to service
// when initialized
'options' => [...],
// [optional] Service class (same as
// defining it in 'invokables')
'class' => '<Class>',
// [optional] Factory class (same as
// defining it in 'factories')
'factory' => '<Class>',
// [optional] Service object/closure
'service' => <Object|Closure>,
// [optinal] Priority number,
// defaults to 1, highest
// number is executed first
'priority' => <Priority>
]
]
]
]
</code>
@see \Zend\ServiceManager\FactoryInterface::createService()
@return ServiceBroker | https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Broker/ServiceBrokerFactory.php#L76-L144 |
chilimatic/chilimatic-framework | lib/di/ServiceFactory.php | ServiceFactory.get | public function get($key, $settings = null, $asSingelton = false)
{
if ($this->parser && !$this->parser->parse($key)) {
return null;
}
if ($this->serviceCollection[$key]) {
$this->serviceCollection[$key];
}
if ($asSingelton && isset($this->pseudoSingeltonList)) {
}
return;
} | php | public function get($key, $settings = null, $asSingelton = false)
{
if ($this->parser && !$this->parser->parse($key)) {
return null;
}
if ($this->serviceCollection[$key]) {
$this->serviceCollection[$key];
}
if ($asSingelton && isset($this->pseudoSingeltonList)) {
}
return;
} | @param $key
@param null $settings
@param bool $asSingelton
@return null|void | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/di/ServiceFactory.php#L67-L83 |
prooph/processing | library/Type/Boolean.php | Boolean.setValue | protected function setValue($value)
{
if (! is_bool($value)) {
throw InvalidTypeException::fromMessageAndPrototype("Value must be a boolean", static::prototype());
}
$this->value = $value;
} | php | protected function setValue($value)
{
if (! is_bool($value)) {
throw InvalidTypeException::fromMessageAndPrototype("Value must be a boolean", static::prototype());
}
$this->value = $value;
} | Performs assertions and sets the internal value property on success
@param mixed $value
@throws Exception\InvalidTypeException
@return void | https://github.com/prooph/processing/blob/a2947bccbffeecc4ca93a15e38ab53814e3e53e5/library/Type/Boolean.php#L46-L53 |
pizepei/func | src/str/Str.php | Str.int_rand | public static function int_rand($length,$one='')
{
$str = self::random_pseudo_bytes(32,10,$one);
$strlen = strlen($str)-1;
$results = '';
for($i=1;$i<=$length;$i++){
$results .= $str{mt_rand(0,$strlen)};
}
return $results;
} | php | public static function int_rand($length,$one='')
{
$str = self::random_pseudo_bytes(32,10,$one);
$strlen = strlen($str)-1;
$results = '';
for($i=1;$i<=$length;$i++){
$results .= $str{mt_rand(0,$strlen)};
}
return $results;
} | 获取随机数字
@param $length
@param $crypto_strong | https://github.com/pizepei/func/blob/83d4be52814d8b38c60c736ecdf82e5cd0518b27/src/str/Str.php#L34-L45 |
pizepei/func | src/str/Str.php | Str.random_pseudo_bytes | public static function random_pseudo_bytes($length=32,$tobase=16,$one='')
{
if(function_exists('openssl_random_pseudo_bytes')){
$str = openssl_random_pseudo_bytes($length,$crypto_strong);
if(!$crypto_strong){ throw new \Exception('请检测系统环境');}
return $tobase==16?md5(bin2hex($one.$str)):base_convert(md5(bin2hex($one.$str)),16,$tobase);
}else{
$str = md5($one.str_replace('.', '', uniqid(mt_rand(), true)));
return $tobase==16?$str:base_convert($one.$str,16,$tobase);
}
} | php | public static function random_pseudo_bytes($length=32,$tobase=16,$one='')
{
if(function_exists('openssl_random_pseudo_bytes')){
$str = openssl_random_pseudo_bytes($length,$crypto_strong);
if(!$crypto_strong){ throw new \Exception('请检测系统环境');}
return $tobase==16?md5(bin2hex($one.$str)):base_convert(md5(bin2hex($one.$str)),16,$tobase);
}else{
$str = md5($one.str_replace('.', '', uniqid(mt_rand(), true)));
return $tobase==16?$str:base_convert($one.$str,16,$tobase);
}
} | 随机
@param int $length
@param int $tobase
@param string $one
@return string
@throws \Exception | https://github.com/pizepei/func/blob/83d4be52814d8b38c60c736ecdf82e5cd0518b27/src/str/Str.php#L70-L80 |
pizepei/func | src/str/Str.php | Str.getUuid | public static function getUuid($strtoupper=false,$separator=45,$parameter=false)
{
$charid = md5(($parameter?$parameter:mt_rand(10000,99999)).uniqid(mt_rand(), true));
if($strtoupper){$charid = strtoupper($charid);}
$hyphen = chr($separator);// "-"
$uuid = substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12);
return $uuid;
} | php | public static function getUuid($strtoupper=false,$separator=45,$parameter=false)
{
$charid = md5(($parameter?$parameter:mt_rand(10000,99999)).uniqid(mt_rand(), true));
if($strtoupper){$charid = strtoupper($charid);}
$hyphen = chr($separator);// "-"
$uuid = substr($charid, 0, 8).$hyphen
.substr($charid, 8, 4).$hyphen
.substr($charid,12, 4).$hyphen
.substr($charid,16, 4).$hyphen
.substr($charid,20,12);
return $uuid;
} | 生成uuid方法
@param bool $strtoupper 是否大小写
@param int $separator 分隔符 45 - 0 空字符串
@param bool $parameter true 是否使用空间配置分布式时不同机器上使用不同的值
@return string | https://github.com/pizepei/func/blob/83d4be52814d8b38c60c736ecdf82e5cd0518b27/src/str/Str.php#L89-L100 |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.create | public function create($filename, $content)
{
$filename = str::path($filename);
$this->createDirectory(dirname($filename));
return file_put_contents($filename, $content);
} | php | public function create($filename, $content)
{
$filename = str::path($filename);
$this->createDirectory(dirname($filename));
return file_put_contents($filename, $content);
} | To create file
@param string $filename
@param string $content
@return int | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L20-L27 |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.delete | public function delete($filename)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return @unlink($filename);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | php | public function delete($filename)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return @unlink($filename);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | To delete file
@param string $filename
@return bool
@throws FileNotFoundException | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L37-L44 |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.update | public function update($filename, $content)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return $this->create($filename, $content);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | php | public function update($filename, $content)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return $this->create($filename, $content);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | To update file
@param string $filename
@param string $content
@return int
@throws FileNotFoundException | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L71-L78 |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.get | public function get($filename)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return file_get_contents($filename);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | php | public function get($filename)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return file_get_contents($filename);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | To get file content
@param string $filename
@return string
@throws FileNotFoundException | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L88-L95 |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.append | public function append($filename, $content)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return file_put_contents($filename, $content, FILE_APPEND);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | php | public function append($filename, $content)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return file_put_contents($filename, $content, FILE_APPEND);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | To append file
@param string $filename
@param string $content
@return int
@throws FileNotFoundException | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L106-L113 |
IftekherSunny/Planet-Framework | src/Sun/Filesystem/Filesystem.php | Filesystem.size | public function size($filename)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return filesize($filename);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | php | public function size($filename)
{
if ($this->exists($filename) && $this->isFile($filename)) {
return filesize($filename);
}
throw new FileNotFoundException('File not found in the path [ ' . $filename . ' ].');
} | To get a filesize in byte
@param string $filename
@return int
@throws FileNotFoundException | https://github.com/IftekherSunny/Planet-Framework/blob/530e772fb97695c1c4e1af73f81675f189474d9f/src/Sun/Filesystem/Filesystem.php#L149-L155 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.