id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
31,000
jkphl/micrometa
src/Micrometa/Ports/Item/Item.php
Item.isOfProfiledTypes
protected function isOfProfiledTypes($profile, array $names, ProfiledNamesList $types) { // Run through all query types /** @var \stdClass $queryType */ foreach ($types as $queryType) { if ($this->isTypeInNames($queryType, $profile, $names)) { return true; } } return false; }
php
protected function isOfProfiledTypes($profile, array $names, ProfiledNamesList $types) { // Run through all query types /** @var \stdClass $queryType */ foreach ($types as $queryType) { if ($this->isTypeInNames($queryType, $profile, $names)) { return true; } } return false; }
[ "protected", "function", "isOfProfiledTypes", "(", "$", "profile", ",", "array", "$", "names", ",", "ProfiledNamesList", "$", "types", ")", "{", "// Run through all query types", "/** @var \\stdClass $queryType */", "foreach", "(", "$", "types", "as", "$", "queryType", ")", "{", "if", "(", "$", "this", "->", "isTypeInNames", "(", "$", "queryType", ",", "$", "profile", ",", "$", "names", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Return whether an aliased item type is contained in a set of query types @param string $profile Type profile @param array $names Aliased type names @param ProfiledNamesList $types Query types @return bool Item type is contained in the set of query types
[ "Return", "whether", "an", "aliased", "item", "type", "is", "contained", "in", "a", "set", "of", "query", "types" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Ports/Item/Item.php#L187-L198
31,001
jkphl/micrometa
src/Micrometa/Ports/Item/Item.php
Item.isTypeInNames
protected function isTypeInNames($type, $profile, array $names) { return in_array($type->name, $names) && (($type->profile === null) ? true : ($type->profile == $profile)); }
php
protected function isTypeInNames($type, $profile, array $names) { return in_array($type->name, $names) && (($type->profile === null) ? true : ($type->profile == $profile)); }
[ "protected", "function", "isTypeInNames", "(", "$", "type", ",", "$", "profile", ",", "array", "$", "names", ")", "{", "return", "in_array", "(", "$", "type", "->", "name", ",", "$", "names", ")", "&&", "(", "(", "$", "type", "->", "profile", "===", "null", ")", "?", "true", ":", "(", "$", "type", "->", "profile", "==", "$", "profile", ")", ")", ";", "}" ]
Test whether a type is contained in a list of names @param \stdClass $type Type @param string $profile Type profile @param array $names Aliased type names @return bool Type is contained in names list
[ "Test", "whether", "a", "type", "is", "contained", "in", "a", "list", "of", "names" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Ports/Item/Item.php#L209-L213
31,002
jkphl/micrometa
src/Micrometa/Ports/Item/Item.php
Item.getFirstProperty
public function getFirstProperty(...$properties) { /** @var ProfiledNamesList $properties */ $properties = ProfiledNamesFactory::createFromArguments(func_get_args()); // Prepare a default exception $exception = new OutOfBoundsException( OutOfBoundsException::NO_MATCHING_PROPERTIES_STR, OutOfBoundsException::NO_MATCHING_PROPERTIES ); // Run through all properties foreach ($properties as $property) { try { return (array)$this->getProperty($property->name, $property->profile); } catch (OutOfBoundsException $exception) { continue; } } throw $exception; }
php
public function getFirstProperty(...$properties) { /** @var ProfiledNamesList $properties */ $properties = ProfiledNamesFactory::createFromArguments(func_get_args()); // Prepare a default exception $exception = new OutOfBoundsException( OutOfBoundsException::NO_MATCHING_PROPERTIES_STR, OutOfBoundsException::NO_MATCHING_PROPERTIES ); // Run through all properties foreach ($properties as $property) { try { return (array)$this->getProperty($property->name, $property->profile); } catch (OutOfBoundsException $exception) { continue; } } throw $exception; }
[ "public", "function", "getFirstProperty", "(", "...", "$", "properties", ")", "{", "/** @var ProfiledNamesList $properties */", "$", "properties", "=", "ProfiledNamesFactory", "::", "createFromArguments", "(", "func_get_args", "(", ")", ")", ";", "// Prepare a default exception", "$", "exception", "=", "new", "OutOfBoundsException", "(", "OutOfBoundsException", "::", "NO_MATCHING_PROPERTIES_STR", ",", "OutOfBoundsException", "::", "NO_MATCHING_PROPERTIES", ")", ";", "// Run through all properties", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "try", "{", "return", "(", "array", ")", "$", "this", "->", "getProperty", "(", "$", "property", "->", "name", ",", "$", "property", "->", "profile", ")", ";", "}", "catch", "(", "OutOfBoundsException", "$", "exception", ")", "{", "continue", ";", "}", "}", "throw", "$", "exception", ";", "}" ]
Get all values of the first available property in a stack The property stack can be specified in a variety of ways, @see ProfiledNamesFactory::createFromArguments() @param array $properties Properties @return ValueInterface[]|array Property values @throws InvalidArgumentException If no property name was given @throws OutOfBoundsException If none of the requested properties is known @api
[ "Get", "all", "values", "of", "the", "first", "available", "property", "in", "a", "stack" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Ports/Item/Item.php#L227-L248
31,003
jkphl/micrometa
src/Micrometa/Ports/Item/Item.php
Item.getProperties
public function getProperties() { $propertyList = (new PropertyListFactory())->create(); foreach ($this->item->getProperties() as $propertyName => $propertyValues) { $propertyList[$propertyName] = array_map([$this, 'getPropertyValue'], $propertyValues); } return $propertyList; }
php
public function getProperties() { $propertyList = (new PropertyListFactory())->create(); foreach ($this->item->getProperties() as $propertyName => $propertyValues) { $propertyList[$propertyName] = array_map([$this, 'getPropertyValue'], $propertyValues); } return $propertyList; }
[ "public", "function", "getProperties", "(", ")", "{", "$", "propertyList", "=", "(", "new", "PropertyListFactory", "(", ")", ")", "->", "create", "(", ")", ";", "foreach", "(", "$", "this", "->", "item", "->", "getProperties", "(", ")", "as", "$", "propertyName", "=>", "$", "propertyValues", ")", "{", "$", "propertyList", "[", "$", "propertyName", "]", "=", "array_map", "(", "[", "$", "this", ",", "'getPropertyValue'", "]", ",", "$", "propertyValues", ")", ";", "}", "return", "$", "propertyList", ";", "}" ]
Return all properties @return PropertyListInterface Properties @api
[ "Return", "all", "properties" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Ports/Item/Item.php#L256-L264
31,004
jkphl/micrometa
src/Micrometa/Ports/Parser.php
Parser.createDom
protected function createDom($uri, $source = null, array $httpOptions = []) { return (($source !== null) && strlen(trim($source))) ? Dom::createFromString($source) : Dom::createFromUri($uri, $httpOptions); }
php
protected function createDom($uri, $source = null, array $httpOptions = []) { return (($source !== null) && strlen(trim($source))) ? Dom::createFromString($source) : Dom::createFromUri($uri, $httpOptions); }
[ "protected", "function", "createDom", "(", "$", "uri", ",", "$", "source", "=", "null", ",", "array", "$", "httpOptions", "=", "[", "]", ")", "{", "return", "(", "(", "$", "source", "!==", "null", ")", "&&", "strlen", "(", "trim", "(", "$", "source", ")", ")", ")", "?", "Dom", "::", "createFromString", "(", "$", "source", ")", ":", "Dom", "::", "createFromUri", "(", "$", "uri", ",", "$", "httpOptions", ")", ";", "}" ]
Create the DOM document to parse @param string $uri URI @param string|null $source Source code @param array $httpOptions HTTP request options @return \DOMDocument DOM document
[ "Create", "the", "DOM", "document", "to", "parse" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Ports/Parser.php#L127-L131
31,005
jkphl/micrometa
src/Micrometa/Ports/Parser.php
Parser.extractItems
protected function extractItems(\DOMDocument $dom, \Generator $parsers) { $items = []; $extractor = new ExtractorService(); foreach ($parsers as $parser) { $results = $extractor->extract($dom, $parser); $items = array_merge($items, ItemFactory::createFromApplicationItems($results->getItems())); } return $items; }
php
protected function extractItems(\DOMDocument $dom, \Generator $parsers) { $items = []; $extractor = new ExtractorService(); foreach ($parsers as $parser) { $results = $extractor->extract($dom, $parser); $items = array_merge($items, ItemFactory::createFromApplicationItems($results->getItems())); } return $items; }
[ "protected", "function", "extractItems", "(", "\\", "DOMDocument", "$", "dom", ",", "\\", "Generator", "$", "parsers", ")", "{", "$", "items", "=", "[", "]", ";", "$", "extractor", "=", "new", "ExtractorService", "(", ")", ";", "foreach", "(", "$", "parsers", "as", "$", "parser", ")", "{", "$", "results", "=", "$", "extractor", "->", "extract", "(", "$", "dom", ",", "$", "parser", ")", ";", "$", "items", "=", "array_merge", "(", "$", "items", ",", "ItemFactory", "::", "createFromApplicationItems", "(", "$", "results", "->", "getItems", "(", ")", ")", ")", ";", "}", "return", "$", "items", ";", "}" ]
Extract all items from a DOM using particular parsers @param \DOMDocument $dom DOM document @param \Generator $parsers Parsers @return ItemInterface[] Items
[ "Extract", "all", "items", "from", "a", "DOM", "using", "particular", "parsers" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Ports/Parser.php#L141-L151
31,006
jkphl/micrometa
src/Micrometa/Application/Factory/AliasFactory.php
AliasFactory.createAliases
public function createAliases($name) { $aliases = [$name]; // Sanitize the name if it isn't usable as PHP function name if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $name)) { $name = preg_replace('/^[^a-zA-Z_\x7f-\xff]+(.*)?/', '$1', $name); $aliases[] = lcfirst( implode( '', array_map('ucfirst', preg_split('/[^a-zA-Z0-9_\x7f-\xff]+/', $name)) ) ); } return $aliases; }
php
public function createAliases($name) { $aliases = [$name]; // Sanitize the name if it isn't usable as PHP function name if (!preg_match('/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*$/', $name)) { $name = preg_replace('/^[^a-zA-Z_\x7f-\xff]+(.*)?/', '$1', $name); $aliases[] = lcfirst( implode( '', array_map('ucfirst', preg_split('/[^a-zA-Z0-9_\x7f-\xff]+/', $name)) ) ); } return $aliases; }
[ "public", "function", "createAliases", "(", "$", "name", ")", "{", "$", "aliases", "=", "[", "$", "name", "]", ";", "// Sanitize the name if it isn't usable as PHP function name", "if", "(", "!", "preg_match", "(", "'/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/'", ",", "$", "name", ")", ")", "{", "$", "name", "=", "preg_replace", "(", "'/^[^a-zA-Z_\\x7f-\\xff]+(.*)?/'", ",", "'$1'", ",", "$", "name", ")", ";", "$", "aliases", "[", "]", "=", "lcfirst", "(", "implode", "(", "''", ",", "array_map", "(", "'ucfirst'", ",", "preg_split", "(", "'/[^a-zA-Z0-9_\\x7f-\\xff]+/'", ",", "$", "name", ")", ")", ")", ")", ";", "}", "return", "$", "aliases", ";", "}" ]
Create aliases for a particular name @param string $name Name @return string[] Name aliases (including the name itself as first item)
[ "Create", "aliases", "for", "a", "particular", "name" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Application/Factory/AliasFactory.php#L54-L70
31,007
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD.php
JsonLD.parseDocument
protected function parseDocument($jsonLDDocSource) { // Unserialize the JSON-LD document $jsonLDDoc = @json_decode($jsonLDDocSource); // If this is not a valid JSON document: Return if (!is_object($jsonLDDoc) && !is_array($jsonLDDoc)) { $this->logger->error('Skipping invalid JSON-LD document'); return []; } // Parse the document return array_filter( is_array($jsonLDDoc) ? array_map([$this, 'parseRootNode'], $jsonLDDoc) : [$this->parseRootNode($jsonLDDoc)] ); }
php
protected function parseDocument($jsonLDDocSource) { // Unserialize the JSON-LD document $jsonLDDoc = @json_decode($jsonLDDocSource); // If this is not a valid JSON document: Return if (!is_object($jsonLDDoc) && !is_array($jsonLDDoc)) { $this->logger->error('Skipping invalid JSON-LD document'); return []; } // Parse the document return array_filter( is_array($jsonLDDoc) ? array_map([$this, 'parseRootNode'], $jsonLDDoc) : [$this->parseRootNode($jsonLDDoc)] ); }
[ "protected", "function", "parseDocument", "(", "$", "jsonLDDocSource", ")", "{", "// Unserialize the JSON-LD document", "$", "jsonLDDoc", "=", "@", "json_decode", "(", "$", "jsonLDDocSource", ")", ";", "// If this is not a valid JSON document: Return", "if", "(", "!", "is_object", "(", "$", "jsonLDDoc", ")", "&&", "!", "is_array", "(", "$", "jsonLDDoc", ")", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "'Skipping invalid JSON-LD document'", ")", ";", "return", "[", "]", ";", "}", "// Parse the document", "return", "array_filter", "(", "is_array", "(", "$", "jsonLDDoc", ")", "?", "array_map", "(", "[", "$", "this", ",", "'parseRootNode'", "]", ",", "$", "jsonLDDoc", ")", ":", "[", "$", "this", "->", "parseRootNode", "(", "$", "jsonLDDoc", ")", "]", ")", ";", "}" ]
Parse a JSON-LD document @param string $jsonLDDocSource JSON-LD document @return array Items
[ "Parse", "a", "JSON", "-", "LD", "document" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD.php#L135-L152
31,008
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD.php
JsonLD.parseRootNode
protected function parseRootNode($jsonLDRoot) { $item = null; try { $jsonDLDocument = JsonLDParser::getDocument($jsonLDRoot, ['documentLoader' => $this->contextLoader]); // Run through all nodes to parse the first one /** @var Node $node */ foreach ($jsonDLDocument->getGraph()->getNodes() as $node) { $item = $this->parseNode($node); break; } } catch (JsonLdException $exception) { $this->logger->error($exception->getMessage(), ['exception' => $exception]); } return $item; }
php
protected function parseRootNode($jsonLDRoot) { $item = null; try { $jsonDLDocument = JsonLDParser::getDocument($jsonLDRoot, ['documentLoader' => $this->contextLoader]); // Run through all nodes to parse the first one /** @var Node $node */ foreach ($jsonDLDocument->getGraph()->getNodes() as $node) { $item = $this->parseNode($node); break; } } catch (JsonLdException $exception) { $this->logger->error($exception->getMessage(), ['exception' => $exception]); } return $item; }
[ "protected", "function", "parseRootNode", "(", "$", "jsonLDRoot", ")", "{", "$", "item", "=", "null", ";", "try", "{", "$", "jsonDLDocument", "=", "JsonLDParser", "::", "getDocument", "(", "$", "jsonLDRoot", ",", "[", "'documentLoader'", "=>", "$", "this", "->", "contextLoader", "]", ")", ";", "// Run through all nodes to parse the first one", "/** @var Node $node */", "foreach", "(", "$", "jsonDLDocument", "->", "getGraph", "(", ")", "->", "getNodes", "(", ")", "as", "$", "node", ")", "{", "$", "item", "=", "$", "this", "->", "parseNode", "(", "$", "node", ")", ";", "break", ";", "}", "}", "catch", "(", "JsonLdException", "$", "exception", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "$", "exception", "->", "getMessage", "(", ")", ",", "[", "'exception'", "=>", "$", "exception", "]", ")", ";", "}", "return", "$", "item", ";", "}" ]
Parse a JSON-LD root node @param \stdClass $jsonLDRoot JSON-LD root node
[ "Parse", "a", "JSON", "-", "LD", "root", "node" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD.php#L159-L177
31,009
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD.php
JsonLD.parseNode
protected function parseNode(NodeInterface $node) { return (object)[ 'type' => $this->parseNodeType($node), 'id' => $node->getId() ?: null, 'properties' => $this->parseNodeProperties($node), ]; }
php
protected function parseNode(NodeInterface $node) { return (object)[ 'type' => $this->parseNodeType($node), 'id' => $node->getId() ?: null, 'properties' => $this->parseNodeProperties($node), ]; }
[ "protected", "function", "parseNode", "(", "NodeInterface", "$", "node", ")", "{", "return", "(", "object", ")", "[", "'type'", "=>", "$", "this", "->", "parseNodeType", "(", "$", "node", ")", ",", "'id'", "=>", "$", "node", "->", "getId", "(", ")", "?", ":", "null", ",", "'properties'", "=>", "$", "this", "->", "parseNodeProperties", "(", "$", "node", ")", ",", "]", ";", "}" ]
Parse a JSON-LD node @param NodeInterface $node Node @return \stdClass Item
[ "Parse", "a", "JSON", "-", "LD", "node" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD.php#L186-L193
31,010
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD.php
JsonLD.parseNodeType
protected function parseNodeType(NodeInterface $node) { /** @var Node $itemType */ return ($itemType = $node->getType()) ? [$this->vocabularyCache->expandIRI($itemType->getId())] : []; }
php
protected function parseNodeType(NodeInterface $node) { /** @var Node $itemType */ return ($itemType = $node->getType()) ? [$this->vocabularyCache->expandIRI($itemType->getId())] : []; }
[ "protected", "function", "parseNodeType", "(", "NodeInterface", "$", "node", ")", "{", "/** @var Node $itemType */", "return", "(", "$", "itemType", "=", "$", "node", "->", "getType", "(", ")", ")", "?", "[", "$", "this", "->", "vocabularyCache", "->", "expandIRI", "(", "$", "itemType", "->", "getId", "(", ")", ")", "]", ":", "[", "]", ";", "}" ]
Parse the type of a JSON-LD node @param NodeInterface $node Node @return array Item type
[ "Parse", "the", "type", "of", "a", "JSON", "-", "LD", "node" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD.php#L202-L206
31,011
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD.php
JsonLD.parseNodeProperties
protected function parseNodeProperties(NodeInterface $node) { $properties = []; // Run through all node properties foreach ($node->getProperties() as $name => $property) { // Skip the node type if ($name === Node::TYPE) { continue; } // Initialize the property (if necessary) $this->initializeNodeProperty($name, $properties); // Parse and process the property value $this->processNodeProperty($name, $this->parse($property), $properties); } return $properties; }
php
protected function parseNodeProperties(NodeInterface $node) { $properties = []; // Run through all node properties foreach ($node->getProperties() as $name => $property) { // Skip the node type if ($name === Node::TYPE) { continue; } // Initialize the property (if necessary) $this->initializeNodeProperty($name, $properties); // Parse and process the property value $this->processNodeProperty($name, $this->parse($property), $properties); } return $properties; }
[ "protected", "function", "parseNodeProperties", "(", "NodeInterface", "$", "node", ")", "{", "$", "properties", "=", "[", "]", ";", "// Run through all node properties", "foreach", "(", "$", "node", "->", "getProperties", "(", ")", "as", "$", "name", "=>", "$", "property", ")", "{", "// Skip the node type", "if", "(", "$", "name", "===", "Node", "::", "TYPE", ")", "{", "continue", ";", "}", "// Initialize the property (if necessary)", "$", "this", "->", "initializeNodeProperty", "(", "$", "name", ",", "$", "properties", ")", ";", "// Parse and process the property value", "$", "this", "->", "processNodeProperty", "(", "$", "name", ",", "$", "this", "->", "parse", "(", "$", "property", ")", ",", "$", "properties", ")", ";", "}", "return", "$", "properties", ";", "}" ]
Parse the properties of a JSON-LD node @param NodeInterface $node Node @return array Item properties
[ "Parse", "the", "properties", "of", "a", "JSON", "-", "LD", "node" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD.php#L215-L234
31,012
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD.php
JsonLD.processNodeProperty
protected function processNodeProperty($name, $value, array &$properties) { // If this is a nested item if (is_object($value)) { $this->processNodePropertyObject($name, $value, $properties); // Else: If this is a value list } elseif (is_array($value)) { foreach ($value as $listValue) { $this->processNodeProperty($name, $listValue, $properties); } // Else: If the value is not empty } elseif ($value) { $properties[$name]->values[] = $value; } }
php
protected function processNodeProperty($name, $value, array &$properties) { // If this is a nested item if (is_object($value)) { $this->processNodePropertyObject($name, $value, $properties); // Else: If this is a value list } elseif (is_array($value)) { foreach ($value as $listValue) { $this->processNodeProperty($name, $listValue, $properties); } // Else: If the value is not empty } elseif ($value) { $properties[$name]->values[] = $value; } }
[ "protected", "function", "processNodeProperty", "(", "$", "name", ",", "$", "value", ",", "array", "&", "$", "properties", ")", "{", "// If this is a nested item", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "this", "->", "processNodePropertyObject", "(", "$", "name", ",", "$", "value", ",", "$", "properties", ")", ";", "// Else: If this is a value list", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "listValue", ")", "{", "$", "this", "->", "processNodeProperty", "(", "$", "name", ",", "$", "listValue", ",", "$", "properties", ")", ";", "}", "// Else: If the value is not empty", "}", "elseif", "(", "$", "value", ")", "{", "$", "properties", "[", "$", "name", "]", "->", "values", "[", "]", "=", "$", "value", ";", "}", "}" ]
Process a property value @param string $name Property name @param \stdClass|array|string $value Property value @param array $properties Item properties
[ "Process", "a", "property", "value" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD.php#L257-L273
31,013
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD.php
JsonLD.processNodePropertyObject
protected function processNodePropertyObject($name, $value, array &$properties) { if (!empty($value->type) || !empty($value->lang)) { $properties[$name]->values[] = $value; // @type = @id } elseif (!empty($value->id)) { $properties[$name]->values[] = $value->id; } }
php
protected function processNodePropertyObject($name, $value, array &$properties) { if (!empty($value->type) || !empty($value->lang)) { $properties[$name]->values[] = $value; // @type = @id } elseif (!empty($value->id)) { $properties[$name]->values[] = $value->id; } }
[ "protected", "function", "processNodePropertyObject", "(", "$", "name", ",", "$", "value", ",", "array", "&", "$", "properties", ")", "{", "if", "(", "!", "empty", "(", "$", "value", "->", "type", ")", "||", "!", "empty", "(", "$", "value", "->", "lang", ")", ")", "{", "$", "properties", "[", "$", "name", "]", "->", "values", "[", "]", "=", "$", "value", ";", "// @type = @id", "}", "elseif", "(", "!", "empty", "(", "$", "value", "->", "id", ")", ")", "{", "$", "properties", "[", "$", "name", "]", "->", "values", "[", "]", "=", "$", "value", "->", "id", ";", "}", "}" ]
Process a property value object @param string $name Property name @param \stdClass $value Property value @param array $properties Properties
[ "Process", "a", "property", "value", "object" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD.php#L282-L291
31,014
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD.php
JsonLD.parse
protected function parse($jsonLD) { // If it's a node object if ($jsonLD instanceof NodeInterface) { return $this->parseNode($jsonLD); // Else if it's a language tagged string } elseif ($jsonLD instanceof LanguageTaggedString) { return $this->parseLanguageTaggedString($jsonLD); // Else if it's a typed value } elseif ($jsonLD instanceof TypedValue) { return $this->parseTypedValue($jsonLD); } // Else if it's a list of items return array_map([$this, 'parse'], $jsonLD); }
php
protected function parse($jsonLD) { // If it's a node object if ($jsonLD instanceof NodeInterface) { return $this->parseNode($jsonLD); // Else if it's a language tagged string } elseif ($jsonLD instanceof LanguageTaggedString) { return $this->parseLanguageTaggedString($jsonLD); // Else if it's a typed value } elseif ($jsonLD instanceof TypedValue) { return $this->parseTypedValue($jsonLD); } // Else if it's a list of items return array_map([$this, 'parse'], $jsonLD); }
[ "protected", "function", "parse", "(", "$", "jsonLD", ")", "{", "// If it's a node object", "if", "(", "$", "jsonLD", "instanceof", "NodeInterface", ")", "{", "return", "$", "this", "->", "parseNode", "(", "$", "jsonLD", ")", ";", "// Else if it's a language tagged string", "}", "elseif", "(", "$", "jsonLD", "instanceof", "LanguageTaggedString", ")", "{", "return", "$", "this", "->", "parseLanguageTaggedString", "(", "$", "jsonLD", ")", ";", "// Else if it's a typed value", "}", "elseif", "(", "$", "jsonLD", "instanceof", "TypedValue", ")", "{", "return", "$", "this", "->", "parseTypedValue", "(", "$", "jsonLD", ")", ";", "}", "// Else if it's a list of items", "return", "array_map", "(", "[", "$", "this", ",", "'parse'", "]", ",", "$", "jsonLD", ")", ";", "}" ]
Parse a JSON-LD fragment @param NodeInterface|LanguageTaggedString|TypedValue|array $jsonLD JSON-LD fragment @return \stdClass|string|array Parsed fragment
[ "Parse", "a", "JSON", "-", "LD", "fragment" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD.php#L300-L317
31,015
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/ProfiledNamesFactory.php
ProfiledNamesFactory.createFromArguments
public static function createFromArguments(array $args) { $profiledNames = []; $profile = false; // Consume and register all given names and profiles while (count($args)) { $profiledNames[] = self::consumeProfiledName($args, $profile); } return new ProfiledNamesList($profiledNames); }
php
public static function createFromArguments(array $args) { $profiledNames = []; $profile = false; // Consume and register all given names and profiles while (count($args)) { $profiledNames[] = self::consumeProfiledName($args, $profile); } return new ProfiledNamesList($profiledNames); }
[ "public", "static", "function", "createFromArguments", "(", "array", "$", "args", ")", "{", "$", "profiledNames", "=", "[", "]", ";", "$", "profile", "=", "false", ";", "// Consume and register all given names and profiles", "while", "(", "count", "(", "$", "args", ")", ")", "{", "$", "profiledNames", "[", "]", "=", "self", "::", "consumeProfiledName", "(", "$", "args", ",", "$", "profile", ")", ";", "}", "return", "new", "ProfiledNamesList", "(", "$", "profiledNames", ")", ";", "}" ]
Create a list of profiled names from method arguments The method takes an arbitrary number of arguments and tries to parse them as profiled names. Arguments may be strings, arrays or objects. String values are interpreted as names — with one exception: If the first two arguments are both strings, the second one is taken as profile IRI. Optionally following string arguments are taken as names again, assuming to share the same profile: createFromArguments($name1 [, $profile]) createFromArguments($name1, $profile1, $name2, $profile2 ...) Arrays arguments are expected to have at least one argument which is taken as name. If present, the second argument is used as profile (otherwise an empty profile is assumed): createFromArguments(array($name [, $profile])) Object values are expected to have a "name" and an optional "profile" property: createFromArguments((object)array('name' => $name [, 'profile' => $profile])) When an array or object argument is consumed, the profile value will be used for any following string argument. You can "reset" the profile to another value by specifying another array or object value in this case. createFromArguments(array($name1, $profile1), $name2, $name3 ...) @param array $args Arguments @return ProfiledNamesList Profiled names @see Item::isOfType() @see Item::getFirstProperty() @see ItemList::getFirstItem() @see ItemList::getItems()
[ "Create", "a", "list", "of", "profiled", "names", "from", "method", "arguments" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/ProfiledNamesFactory.php#L88-L99
31,016
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/ProfiledNamesFactory.php
ProfiledNamesFactory.consumeProfiledName
protected static function consumeProfiledName(&$args, &$profile) { $profiledName = new \stdClass(); $profiledName->profile = $profile; // Get the first argument $arg = array_shift($args); // If it's not a scalar argument if (!is_scalar($arg)) { return self::consumeNonScalarProfiledName($arg, $profile); } if (($profile === false) && is_string(current($args))) { $profile = array_shift($args); } return self::createProfiledNameFromString(strval($arg), $profile); }
php
protected static function consumeProfiledName(&$args, &$profile) { $profiledName = new \stdClass(); $profiledName->profile = $profile; // Get the first argument $arg = array_shift($args); // If it's not a scalar argument if (!is_scalar($arg)) { return self::consumeNonScalarProfiledName($arg, $profile); } if (($profile === false) && is_string(current($args))) { $profile = array_shift($args); } return self::createProfiledNameFromString(strval($arg), $profile); }
[ "protected", "static", "function", "consumeProfiledName", "(", "&", "$", "args", ",", "&", "$", "profile", ")", "{", "$", "profiledName", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "profiledName", "->", "profile", "=", "$", "profile", ";", "// Get the first argument", "$", "arg", "=", "array_shift", "(", "$", "args", ")", ";", "// If it's not a scalar argument", "if", "(", "!", "is_scalar", "(", "$", "arg", ")", ")", "{", "return", "self", "::", "consumeNonScalarProfiledName", "(", "$", "arg", ",", "$", "profile", ")", ";", "}", "if", "(", "(", "$", "profile", "===", "false", ")", "&&", "is_string", "(", "current", "(", "$", "args", ")", ")", ")", "{", "$", "profile", "=", "array_shift", "(", "$", "args", ")", ";", "}", "return", "self", "::", "createProfiledNameFromString", "(", "strval", "(", "$", "arg", ")", ",", "$", "profile", ")", ";", "}" ]
Create a single profiled name by argument consumption @param array $args Arguments @param string|boolean|null $profile Profile @return \stdClass Profiled name
[ "Create", "a", "single", "profiled", "name", "by", "argument", "consumption" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/ProfiledNamesFactory.php#L109-L127
31,017
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/ProfiledNamesFactory.php
ProfiledNamesFactory.consumeNonScalarProfiledName
protected static function consumeNonScalarProfiledName($arg, &$profile) { // If it's an object argument if (is_object($arg)) { return self::createProfiledNameFromObject($arg, $profile); } // Else: It must be an array return self::createProfiledNameFromArray($arg, $profile); }
php
protected static function consumeNonScalarProfiledName($arg, &$profile) { // If it's an object argument if (is_object($arg)) { return self::createProfiledNameFromObject($arg, $profile); } // Else: It must be an array return self::createProfiledNameFromArray($arg, $profile); }
[ "protected", "static", "function", "consumeNonScalarProfiledName", "(", "$", "arg", ",", "&", "$", "profile", ")", "{", "// If it's an object argument", "if", "(", "is_object", "(", "$", "arg", ")", ")", "{", "return", "self", "::", "createProfiledNameFromObject", "(", "$", "arg", ",", "$", "profile", ")", ";", "}", "// Else: It must be an array", "return", "self", "::", "createProfiledNameFromArray", "(", "$", "arg", ",", "$", "profile", ")", ";", "}" ]
Create a profiled name by consuming a non-scalar argument @param \stdClass|array $arg Argument @param string|boolean|null $profile Profile @return \stdClass Profiled name
[ "Create", "a", "profiled", "name", "by", "consuming", "a", "non", "-", "scalar", "argument" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/ProfiledNamesFactory.php#L137-L146
31,018
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/ProfiledNamesFactory.php
ProfiledNamesFactory.createProfiledNameFromObject
protected static function createProfiledNameFromObject($arg, &$profile) { // If the name is invalid if (!isset($arg->name)) { throw new InvalidArgumentException( InvalidArgumentException::INVALID_TYPE_PROPERTY_NAME_STR, InvalidArgumentException::INVALID_TYPE_PROPERTY_NAME ); } if (isset($arg->profile)) { $profile = trim($arg->profile) ?: null; } return self::createProfiledNameFromString($arg->name, $profile); }
php
protected static function createProfiledNameFromObject($arg, &$profile) { // If the name is invalid if (!isset($arg->name)) { throw new InvalidArgumentException( InvalidArgumentException::INVALID_TYPE_PROPERTY_NAME_STR, InvalidArgumentException::INVALID_TYPE_PROPERTY_NAME ); } if (isset($arg->profile)) { $profile = trim($arg->profile) ?: null; } return self::createProfiledNameFromString($arg->name, $profile); }
[ "protected", "static", "function", "createProfiledNameFromObject", "(", "$", "arg", ",", "&", "$", "profile", ")", "{", "// If the name is invalid", "if", "(", "!", "isset", "(", "$", "arg", "->", "name", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "InvalidArgumentException", "::", "INVALID_TYPE_PROPERTY_NAME_STR", ",", "InvalidArgumentException", "::", "INVALID_TYPE_PROPERTY_NAME", ")", ";", "}", "if", "(", "isset", "(", "$", "arg", "->", "profile", ")", ")", "{", "$", "profile", "=", "trim", "(", "$", "arg", "->", "profile", ")", "?", ":", "null", ";", "}", "return", "self", "::", "createProfiledNameFromString", "(", "$", "arg", "->", "name", ",", "$", "profile", ")", ";", "}" ]
Create a profiled name from an object argument @param \stdClass $arg Object argument @param string|boolean|null $profile Profile @return \stdClass Profiled name @throws InvalidArgumentException If the name is missing
[ "Create", "a", "profiled", "name", "from", "an", "object", "argument" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/ProfiledNamesFactory.php#L157-L172
31,019
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/ProfiledNamesFactory.php
ProfiledNamesFactory.createProfiledNameFromString
protected static function createProfiledNameFromString($name, $profile) { // If the name is invalid if (!strlen(trim($name))) { throw new InvalidArgumentException( InvalidArgumentException::INVALID_TYPE_PROPERTY_NAME_STR, InvalidArgumentException::INVALID_TYPE_PROPERTY_NAME ); } return (object)[ 'name' => trim($name), 'profile' => trim($profile) ?: null, ]; }
php
protected static function createProfiledNameFromString($name, $profile) { // If the name is invalid if (!strlen(trim($name))) { throw new InvalidArgumentException( InvalidArgumentException::INVALID_TYPE_PROPERTY_NAME_STR, InvalidArgumentException::INVALID_TYPE_PROPERTY_NAME ); } return (object)[ 'name' => trim($name), 'profile' => trim($profile) ?: null, ]; }
[ "protected", "static", "function", "createProfiledNameFromString", "(", "$", "name", ",", "$", "profile", ")", "{", "// If the name is invalid", "if", "(", "!", "strlen", "(", "trim", "(", "$", "name", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "InvalidArgumentException", "::", "INVALID_TYPE_PROPERTY_NAME_STR", ",", "InvalidArgumentException", "::", "INVALID_TYPE_PROPERTY_NAME", ")", ";", "}", "return", "(", "object", ")", "[", "'name'", "=>", "trim", "(", "$", "name", ")", ",", "'profile'", "=>", "trim", "(", "$", "profile", ")", "?", ":", "null", ",", "]", ";", "}" ]
Create a profiled name from string arguments @param string $name Name @param string|boolean|null $profile Profile @return \stdClass Profiled name @throws InvalidArgumentException If the name is invalid
[ "Create", "a", "profiled", "name", "from", "string", "arguments" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/ProfiledNamesFactory.php#L183-L197
31,020
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/ProfiledNamesFactory.php
ProfiledNamesFactory.createProfiledNameFromArray
protected static function createProfiledNameFromArray(array $arg, &$profile) { // If it's an associative array containing a "name" key if (array_key_exists('name', $arg)) { return self::createProfiledNameFromObject((object)$arg, $profile); } // If the argument has two items at least if (count($arg) > 1) { $name = array_shift($arg); $profile = trim(array_shift($arg)) ?: null; return self::createProfiledNameFromString($name, $profile); } throw new InvalidArgumentException( InvalidArgumentException::INVALID_TYPE_PROPERTY_ARRAY_STR, InvalidArgumentException::INVALID_TYPE_PROPERTY_ARRAY ); }
php
protected static function createProfiledNameFromArray(array $arg, &$profile) { // If it's an associative array containing a "name" key if (array_key_exists('name', $arg)) { return self::createProfiledNameFromObject((object)$arg, $profile); } // If the argument has two items at least if (count($arg) > 1) { $name = array_shift($arg); $profile = trim(array_shift($arg)) ?: null; return self::createProfiledNameFromString($name, $profile); } throw new InvalidArgumentException( InvalidArgumentException::INVALID_TYPE_PROPERTY_ARRAY_STR, InvalidArgumentException::INVALID_TYPE_PROPERTY_ARRAY ); }
[ "protected", "static", "function", "createProfiledNameFromArray", "(", "array", "$", "arg", ",", "&", "$", "profile", ")", "{", "// If it's an associative array containing a \"name\" key", "if", "(", "array_key_exists", "(", "'name'", ",", "$", "arg", ")", ")", "{", "return", "self", "::", "createProfiledNameFromObject", "(", "(", "object", ")", "$", "arg", ",", "$", "profile", ")", ";", "}", "// If the argument has two items at least", "if", "(", "count", "(", "$", "arg", ")", ">", "1", ")", "{", "$", "name", "=", "array_shift", "(", "$", "arg", ")", ";", "$", "profile", "=", "trim", "(", "array_shift", "(", "$", "arg", ")", ")", "?", ":", "null", ";", "return", "self", "::", "createProfiledNameFromString", "(", "$", "name", ",", "$", "profile", ")", ";", "}", "throw", "new", "InvalidArgumentException", "(", "InvalidArgumentException", "::", "INVALID_TYPE_PROPERTY_ARRAY_STR", ",", "InvalidArgumentException", "::", "INVALID_TYPE_PROPERTY_ARRAY", ")", ";", "}" ]
Create a profiled name from an array argument @param array $arg Array argument @param string|boolean|null $profile Profile @return \stdClass Profiled name @throws InvalidArgumentException If the array definition is invalid
[ "Create", "a", "profiled", "name", "from", "an", "array", "argument" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/ProfiledNamesFactory.php#L208-L227
31,021
jkphl/micrometa
src/Micrometa/Domain/Factory/IriFactory.php
IriFactory.create
public static function create($iri) { // Cast as item type object if only a string is given if (is_string($iri)) { $iri = (object)['profile' => '', 'name' => $iri]; } // If the IRI is invalid if (!self::validateIriStructure($iri)) { throw new InvalidArgumentException( InvalidArgumentException::INVALID_IRI_STR, InvalidArgumentException::INVALID_IRI ); } return new Iri($iri->profile, $iri->name); }
php
public static function create($iri) { // Cast as item type object if only a string is given if (is_string($iri)) { $iri = (object)['profile' => '', 'name' => $iri]; } // If the IRI is invalid if (!self::validateIriStructure($iri)) { throw new InvalidArgumentException( InvalidArgumentException::INVALID_IRI_STR, InvalidArgumentException::INVALID_IRI ); } return new Iri($iri->profile, $iri->name); }
[ "public", "static", "function", "create", "(", "$", "iri", ")", "{", "// Cast as item type object if only a string is given", "if", "(", "is_string", "(", "$", "iri", ")", ")", "{", "$", "iri", "=", "(", "object", ")", "[", "'profile'", "=>", "''", ",", "'name'", "=>", "$", "iri", "]", ";", "}", "// If the IRI is invalid", "if", "(", "!", "self", "::", "validateIriStructure", "(", "$", "iri", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "InvalidArgumentException", "::", "INVALID_IRI_STR", ",", "InvalidArgumentException", "::", "INVALID_IRI", ")", ";", "}", "return", "new", "Iri", "(", "$", "iri", "->", "profile", ",", "$", "iri", "->", "name", ")", ";", "}" ]
Validate and sanitize an IRI @param Iri|\stdClass|string $iri IRI @return Iri Sanitized IRI @throws InvalidArgumentException If the IRI is invalid
[ "Validate", "and", "sanitize", "an", "IRI" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Factory/IriFactory.php#L58-L74
31,022
jkphl/micrometa
src/Micrometa/Domain/Factory/IriFactory.php
IriFactory.validateIriStructure
protected static function validateIriStructure($iri) { return is_object($iri) && isset($iri->profile) && isset($iri->name); }
php
protected static function validateIriStructure($iri) { return is_object($iri) && isset($iri->profile) && isset($iri->name); }
[ "protected", "static", "function", "validateIriStructure", "(", "$", "iri", ")", "{", "return", "is_object", "(", "$", "iri", ")", "&&", "isset", "(", "$", "iri", "->", "profile", ")", "&&", "isset", "(", "$", "iri", "->", "name", ")", ";", "}" ]
Test if an object has a valid IRI structure @param \stdClass $iri IRI @return bool Is a valid IRI
[ "Test", "if", "an", "object", "has", "a", "valid", "IRI", "structure" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Factory/IriFactory.php#L83-L86
31,023
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/ParserFactory.php
ParserFactory.createParsersFromFormats
public static function createParsersFromFormats($formats, UriInterface $uri, LoggerInterface $logger) { $formatBits = intval($formats); // Run through all registered parsers and yield the requested instances foreach (self::$parsers as $parserFormat => $parserClass) { if ($parserFormat & $formatBits) { yield $parserFormat => new $parserClass($uri, $logger); } } }
php
public static function createParsersFromFormats($formats, UriInterface $uri, LoggerInterface $logger) { $formatBits = intval($formats); // Run through all registered parsers and yield the requested instances foreach (self::$parsers as $parserFormat => $parserClass) { if ($parserFormat & $formatBits) { yield $parserFormat => new $parserClass($uri, $logger); } } }
[ "public", "static", "function", "createParsersFromFormats", "(", "$", "formats", ",", "UriInterface", "$", "uri", ",", "LoggerInterface", "$", "logger", ")", "{", "$", "formatBits", "=", "intval", "(", "$", "formats", ")", ";", "// Run through all registered parsers and yield the requested instances", "foreach", "(", "self", "::", "$", "parsers", "as", "$", "parserFormat", "=>", "$", "parserClass", ")", "{", "if", "(", "$", "parserFormat", "&", "$", "formatBits", ")", "{", "yield", "$", "parserFormat", "=>", "new", "$", "parserClass", "(", "$", "uri", ",", "$", "logger", ")", ";", "}", "}", "}" ]
Create a list of parsers from a formats bitmask @param int $formats Parser format bitmask @param UriInterface $uri Base Uri @param LoggerInterface $logger Logger @return \Generator Parser generator
[ "Create", "a", "list", "of", "parsers", "from", "a", "formats", "bitmask" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/ParserFactory.php#L77-L87
31,024
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/LinkType.php
LinkType.parseLinkType
protected function parseLinkType($relAttr) { $type = []; foreach (preg_split('/\040+/', $relAttr) as $rel) { $type[] = (object)['name' => $rel, 'profile' => self::HTML_PROFILE_URI]; } return $type; }
php
protected function parseLinkType($relAttr) { $type = []; foreach (preg_split('/\040+/', $relAttr) as $rel) { $type[] = (object)['name' => $rel, 'profile' => self::HTML_PROFILE_URI]; } return $type; }
[ "protected", "function", "parseLinkType", "(", "$", "relAttr", ")", "{", "$", "type", "=", "[", "]", ";", "foreach", "(", "preg_split", "(", "'/\\040+/'", ",", "$", "relAttr", ")", "as", "$", "rel", ")", "{", "$", "type", "[", "]", "=", "(", "object", ")", "[", "'name'", "=>", "$", "rel", ",", "'profile'", "=>", "self", "::", "HTML_PROFILE_URI", "]", ";", "}", "return", "$", "type", ";", "}" ]
Process the item types @param string $relAttr rel attribute value @return array Item types
[ "Process", "the", "item", "types" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/LinkType.php#L93-L101
31,025
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/LinkType.php
LinkType.parseProperties
protected function parseProperties(\DOMElement $linkType) { $properties = []; /** * @var string $attributeName Attribute name * @var \DOMAttr $attribute Attribute */ foreach ($linkType->attributes as $attributeName => $attribute) { if (!in_array($attributeName, ['rel', 'id'])) { $profile = $attribute->lookupNamespaceUri($attribute->prefix ?: null); $property = (object)[ 'name' => $attributeName, 'profile' => $profile, 'values' => $this->parseAttributeValue($profile, $attributeName, $attribute->value), ]; $properties[] = $property; } } return $properties; }
php
protected function parseProperties(\DOMElement $linkType) { $properties = []; /** * @var string $attributeName Attribute name * @var \DOMAttr $attribute Attribute */ foreach ($linkType->attributes as $attributeName => $attribute) { if (!in_array($attributeName, ['rel', 'id'])) { $profile = $attribute->lookupNamespaceUri($attribute->prefix ?: null); $property = (object)[ 'name' => $attributeName, 'profile' => $profile, 'values' => $this->parseAttributeValue($profile, $attributeName, $attribute->value), ]; $properties[] = $property; } } return $properties; }
[ "protected", "function", "parseProperties", "(", "\\", "DOMElement", "$", "linkType", ")", "{", "$", "properties", "=", "[", "]", ";", "/**\n * @var string $attributeName Attribute name\n * @var \\DOMAttr $attribute Attribute\n */", "foreach", "(", "$", "linkType", "->", "attributes", "as", "$", "attributeName", "=>", "$", "attribute", ")", "{", "if", "(", "!", "in_array", "(", "$", "attributeName", ",", "[", "'rel'", ",", "'id'", "]", ")", ")", "{", "$", "profile", "=", "$", "attribute", "->", "lookupNamespaceUri", "(", "$", "attribute", "->", "prefix", "?", ":", "null", ")", ";", "$", "property", "=", "(", "object", ")", "[", "'name'", "=>", "$", "attributeName", ",", "'profile'", "=>", "$", "profile", ",", "'values'", "=>", "$", "this", "->", "parseAttributeValue", "(", "$", "profile", ",", "$", "attributeName", ",", "$", "attribute", "->", "value", ")", ",", "]", ";", "$", "properties", "[", "]", "=", "$", "property", ";", "}", "}", "return", "$", "properties", ";", "}" ]
Parse the LinkType attributes @param \DOMElement $linkType LinkType element @return array Properties
[ "Parse", "the", "LinkType", "attributes" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/LinkType.php#L110-L130
31,026
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/LinkType.php
LinkType.parseAttributeValue
protected function parseAttributeValue($profile, $attribute, $value) { // If it's a HTML attribute if ($profile == LinkType::HTML_PROFILE_URI) { switch ($attribute) { // Space delimited lists case 'sizes': return array_filter(preg_split('/\040+/', $value)); // Space or comma delimited lists case 'charset': return array_filter(preg_split('/[,\040]+/', $value)); } } return [$value]; }
php
protected function parseAttributeValue($profile, $attribute, $value) { // If it's a HTML attribute if ($profile == LinkType::HTML_PROFILE_URI) { switch ($attribute) { // Space delimited lists case 'sizes': return array_filter(preg_split('/\040+/', $value)); // Space or comma delimited lists case 'charset': return array_filter(preg_split('/[,\040]+/', $value)); } } return [$value]; }
[ "protected", "function", "parseAttributeValue", "(", "$", "profile", ",", "$", "attribute", ",", "$", "value", ")", "{", "// If it's a HTML attribute", "if", "(", "$", "profile", "==", "LinkType", "::", "HTML_PROFILE_URI", ")", "{", "switch", "(", "$", "attribute", ")", "{", "// Space delimited lists", "case", "'sizes'", ":", "return", "array_filter", "(", "preg_split", "(", "'/\\040+/'", ",", "$", "value", ")", ")", ";", "// Space or comma delimited lists", "case", "'charset'", ":", "return", "array_filter", "(", "preg_split", "(", "'/[,\\040]+/'", ",", "$", "value", ")", ")", ";", "}", "}", "return", "[", "$", "value", "]", ";", "}" ]
Parse an attribute value @param string $profile Profile @param string $attribute Attribute name @param string $value Attribute value @return array Attribute values
[ "Parse", "an", "attribute", "value" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/LinkType.php#L141-L156
31,027
jkphl/micrometa
src/Micrometa/Domain/Item/PropertyList.php
PropertyList.offsetUnset
public function offsetUnset($iri) { throw new ErrorException( sprintf(ErrorException::CANNOT_UNSET_PROPERTY_STR, $iri), ErrorException::CANNOT_UNSET_PROPERTY, E_WARNING ); }
php
public function offsetUnset($iri) { throw new ErrorException( sprintf(ErrorException::CANNOT_UNSET_PROPERTY_STR, $iri), ErrorException::CANNOT_UNSET_PROPERTY, E_WARNING ); }
[ "public", "function", "offsetUnset", "(", "$", "iri", ")", "{", "throw", "new", "ErrorException", "(", "sprintf", "(", "ErrorException", "::", "CANNOT_UNSET_PROPERTY_STR", ",", "$", "iri", ")", ",", "ErrorException", "::", "CANNOT_UNSET_PROPERTY", ",", "E_WARNING", ")", ";", "}" ]
Unset a property @param \stdClass|string $iri IRI @throws ErrorException
[ "Unset", "a", "property" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Item/PropertyList.php#L83-L90
31,028
jkphl/micrometa
src/Micrometa/Domain/Item/PropertyList.php
PropertyList.offsetExists
public function offsetExists($iri) { $iri = IriFactory::create($iri); try { ($iri->profile !== '') ? $this->getProfiledPropertyCursor($iri) : $this->getPropertyCursor($iri->name); return true; } catch (OutOfBoundsException $exception) { return false; } }
php
public function offsetExists($iri) { $iri = IriFactory::create($iri); try { ($iri->profile !== '') ? $this->getProfiledPropertyCursor($iri) : $this->getPropertyCursor($iri->name); return true; } catch (OutOfBoundsException $exception) { return false; } }
[ "public", "function", "offsetExists", "(", "$", "iri", ")", "{", "$", "iri", "=", "IriFactory", "::", "create", "(", "$", "iri", ")", ";", "try", "{", "(", "$", "iri", "->", "profile", "!==", "''", ")", "?", "$", "this", "->", "getProfiledPropertyCursor", "(", "$", "iri", ")", ":", "$", "this", "->", "getPropertyCursor", "(", "$", "iri", "->", "name", ")", ";", "return", "true", ";", "}", "catch", "(", "OutOfBoundsException", "$", "exception", ")", "{", "return", "false", ";", "}", "}" ]
Return whether a property exists @param \stdClass|Iri|string $iri IRI @return boolean Property exists
[ "Return", "whether", "a", "property", "exists" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Item/PropertyList.php#L176-L187
31,029
jkphl/micrometa
src/Micrometa/Domain/Item/PropertyList.php
PropertyList.getProfiledPropertyCursor
protected function getProfiledPropertyCursor($iri) { $iriStr = strval($iri); // If the property name is unknown if (!isset($this->nameToCursor[$iriStr])) { $this->handleUnknownName($iriStr); } return $this->nameToCursor[$iriStr]; }
php
protected function getProfiledPropertyCursor($iri) { $iriStr = strval($iri); // If the property name is unknown if (!isset($this->nameToCursor[$iriStr])) { $this->handleUnknownName($iriStr); } return $this->nameToCursor[$iriStr]; }
[ "protected", "function", "getProfiledPropertyCursor", "(", "$", "iri", ")", "{", "$", "iriStr", "=", "strval", "(", "$", "iri", ")", ";", "// If the property name is unknown", "if", "(", "!", "isset", "(", "$", "this", "->", "nameToCursor", "[", "$", "iriStr", "]", ")", ")", "{", "$", "this", "->", "handleUnknownName", "(", "$", "iriStr", ")", ";", "}", "return", "$", "this", "->", "nameToCursor", "[", "$", "iriStr", "]", ";", "}" ]
Get a particular property cursor by its profiled name @param Iri $iri IRI @return int Property cursor @throws OutOfBoundsException If the property name is unknown
[ "Get", "a", "particular", "property", "cursor", "by", "its", "profiled", "name" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Item/PropertyList.php#L197-L207
31,030
jkphl/micrometa
src/Micrometa/Ports/Item/ItemList.php
ItemList.getFirstItem
public function getFirstItem(...$types) { $items = $this->getItems(...$types); // If there are no matching items if (!count($items)) { throw new OutOfBoundsException( OutOfBoundsException::NO_MATCHING_ITEMS_STR, OutOfBoundsException::NO_MATCHING_ITEMS ); } return $items[0]; }
php
public function getFirstItem(...$types) { $items = $this->getItems(...$types); // If there are no matching items if (!count($items)) { throw new OutOfBoundsException( OutOfBoundsException::NO_MATCHING_ITEMS_STR, OutOfBoundsException::NO_MATCHING_ITEMS ); } return $items[0]; }
[ "public", "function", "getFirstItem", "(", "...", "$", "types", ")", "{", "$", "items", "=", "$", "this", "->", "getItems", "(", "...", "$", "types", ")", ";", "// If there are no matching items", "if", "(", "!", "count", "(", "$", "items", ")", ")", "{", "throw", "new", "OutOfBoundsException", "(", "OutOfBoundsException", "::", "NO_MATCHING_ITEMS_STR", ",", "OutOfBoundsException", "::", "NO_MATCHING_ITEMS", ")", ";", "}", "return", "$", "items", "[", "0", "]", ";", "}" ]
Return the first item, optionally of particular types @param array ...$types Item types @return ItemInterface Item @throws OutOfBoundsException If there are no matching items @api
[ "Return", "the", "first", "item", "optionally", "of", "particular", "types" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Ports/Item/ItemList.php#L210-L223
31,031
jkphl/micrometa
src/Micrometa/Ports/Item/ItemList.php
ItemList.getItemByTypeAndIndex
protected function getItemByTypeAndIndex($type, $index) { $typeItems = $this->getItems($type); // If the item index is out of bounds if (count($typeItems) <= $index) { throw new OutOfBoundsException( sprintf(OutOfBoundsException::INVALID_ITEM_INDEX_STR, $index), OutOfBoundsException::INVALID_ITEM_INDEX ); } return $typeItems[$index]; }
php
protected function getItemByTypeAndIndex($type, $index) { $typeItems = $this->getItems($type); // If the item index is out of bounds if (count($typeItems) <= $index) { throw new OutOfBoundsException( sprintf(OutOfBoundsException::INVALID_ITEM_INDEX_STR, $index), OutOfBoundsException::INVALID_ITEM_INDEX ); } return $typeItems[$index]; }
[ "protected", "function", "getItemByTypeAndIndex", "(", "$", "type", ",", "$", "index", ")", "{", "$", "typeItems", "=", "$", "this", "->", "getItems", "(", "$", "type", ")", ";", "// If the item index is out of bounds", "if", "(", "count", "(", "$", "typeItems", ")", "<=", "$", "index", ")", "{", "throw", "new", "OutOfBoundsException", "(", "sprintf", "(", "OutOfBoundsException", "::", "INVALID_ITEM_INDEX_STR", ",", "$", "index", ")", ",", "OutOfBoundsException", "::", "INVALID_ITEM_INDEX", ")", ";", "}", "return", "$", "typeItems", "[", "$", "index", "]", ";", "}" ]
Return an item by type and index @param string $type Item type @param int $index Item index @return ItemInterface Item @throws OutOfBoundsException If the item index is out of bounds
[ "Return", "an", "item", "by", "type", "and", "index" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Ports/Item/ItemList.php#L297-L310
31,032
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php
VocabularyCache.getDocument
public function getDocument($url) { $urlHash = $this->getCacheHash($url, self::SLOT_DOC); // Try to retrieve the document from the cache if (Cache::getAdapter()->hasItem($urlHash)) { return Cache::getAdapter()->getItem($urlHash)->get(); } return null; }
php
public function getDocument($url) { $urlHash = $this->getCacheHash($url, self::SLOT_DOC); // Try to retrieve the document from the cache if (Cache::getAdapter()->hasItem($urlHash)) { return Cache::getAdapter()->getItem($urlHash)->get(); } return null; }
[ "public", "function", "getDocument", "(", "$", "url", ")", "{", "$", "urlHash", "=", "$", "this", "->", "getCacheHash", "(", "$", "url", ",", "self", "::", "SLOT_DOC", ")", ";", "// Try to retrieve the document from the cache", "if", "(", "Cache", "::", "getAdapter", "(", ")", "->", "hasItem", "(", "$", "urlHash", ")", ")", "{", "return", "Cache", "::", "getAdapter", "(", ")", "->", "getItem", "(", "$", "urlHash", ")", "->", "get", "(", ")", ";", "}", "return", "null", ";", "}" ]
Return a cached document @param string $url URL @return RemoteDocument|null Cached document
[ "Return", "a", "cached", "document" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php#L88-L98
31,033
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php
VocabularyCache.setDocument
public function setDocument($url, RemoteDocument $document) { // Process the context if (isset($document->document->{'@context'}) && is_object($document->document->{'@context'})) { $this->processContext((array)$document->document->{'@context'}); } // Save the document to the cache $docUrlHash = $this->getCacheHash($url, self::SLOT_DOC); $cachedDocument = Cache::getAdapter()->getItem($docUrlHash); $cachedDocument->set($document); Cache::getAdapter()->save($cachedDocument); // Return the document return $document; }
php
public function setDocument($url, RemoteDocument $document) { // Process the context if (isset($document->document->{'@context'}) && is_object($document->document->{'@context'})) { $this->processContext((array)$document->document->{'@context'}); } // Save the document to the cache $docUrlHash = $this->getCacheHash($url, self::SLOT_DOC); $cachedDocument = Cache::getAdapter()->getItem($docUrlHash); $cachedDocument->set($document); Cache::getAdapter()->save($cachedDocument); // Return the document return $document; }
[ "public", "function", "setDocument", "(", "$", "url", ",", "RemoteDocument", "$", "document", ")", "{", "// Process the context", "if", "(", "isset", "(", "$", "document", "->", "document", "->", "{", "'@context'", "}", ")", "&&", "is_object", "(", "$", "document", "->", "document", "->", "{", "'@context'", "}", ")", ")", "{", "$", "this", "->", "processContext", "(", "(", "array", ")", "$", "document", "->", "document", "->", "{", "'@context'", "}", ")", ";", "}", "// Save the document to the cache", "$", "docUrlHash", "=", "$", "this", "->", "getCacheHash", "(", "$", "url", ",", "self", "::", "SLOT_DOC", ")", ";", "$", "cachedDocument", "=", "Cache", "::", "getAdapter", "(", ")", "->", "getItem", "(", "$", "docUrlHash", ")", ";", "$", "cachedDocument", "->", "set", "(", "$", "document", ")", ";", "Cache", "::", "getAdapter", "(", ")", "->", "save", "(", "$", "cachedDocument", ")", ";", "// Return the document", "return", "$", "document", ";", "}" ]
Cache a document @param string $url URL @param RemoteDocument $document Document @return RemoteDocument Document
[ "Cache", "a", "document" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php#L121-L136
31,034
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php
VocabularyCache.processContext
protected function processContext(array $context) { $prefices = []; $vocabularyCache = Cache::getAdapter()->getItem(self::SLOT_VOCABS); $vocabularies = $vocabularyCache->isHit() ? $vocabularyCache->get() : []; // Run through all vocabulary terms foreach ($context as $name => $definition) { // Skip JSON-LD reserved terms if ($this->isReservedTokens($name, $definition)) { continue; } // Process this prefix / vocabulary term $this->processPrefixVocabularyTerm($name, $definition, $prefices, $vocabularies); } $vocabularyCache->set($vocabularies); Cache::getAdapter()->save($vocabularyCache); }
php
protected function processContext(array $context) { $prefices = []; $vocabularyCache = Cache::getAdapter()->getItem(self::SLOT_VOCABS); $vocabularies = $vocabularyCache->isHit() ? $vocabularyCache->get() : []; // Run through all vocabulary terms foreach ($context as $name => $definition) { // Skip JSON-LD reserved terms if ($this->isReservedTokens($name, $definition)) { continue; } // Process this prefix / vocabulary term $this->processPrefixVocabularyTerm($name, $definition, $prefices, $vocabularies); } $vocabularyCache->set($vocabularies); Cache::getAdapter()->save($vocabularyCache); }
[ "protected", "function", "processContext", "(", "array", "$", "context", ")", "{", "$", "prefices", "=", "[", "]", ";", "$", "vocabularyCache", "=", "Cache", "::", "getAdapter", "(", ")", "->", "getItem", "(", "self", "::", "SLOT_VOCABS", ")", ";", "$", "vocabularies", "=", "$", "vocabularyCache", "->", "isHit", "(", ")", "?", "$", "vocabularyCache", "->", "get", "(", ")", ":", "[", "]", ";", "// Run through all vocabulary terms", "foreach", "(", "$", "context", "as", "$", "name", "=>", "$", "definition", ")", "{", "// Skip JSON-LD reserved terms", "if", "(", "$", "this", "->", "isReservedTokens", "(", "$", "name", ",", "$", "definition", ")", ")", "{", "continue", ";", "}", "// Process this prefix / vocabulary term", "$", "this", "->", "processPrefixVocabularyTerm", "(", "$", "name", ",", "$", "definition", ",", "$", "prefices", ",", "$", "vocabularies", ")", ";", "}", "$", "vocabularyCache", "->", "set", "(", "$", "vocabularies", ")", ";", "Cache", "::", "getAdapter", "(", ")", "->", "save", "(", "$", "vocabularyCache", ")", ";", "}" ]
Process a context vocabulary @param array $context Context
[ "Process", "a", "context", "vocabulary" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php#L143-L162
31,035
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php
VocabularyCache.processPrefix
protected function processPrefix($name, $definition, array &$prefices, array &$vocabularies) { $prefices[$name] = $definition; // Register the vocabulary if (!isset($vocabularies[$definition])) { $vocabularies[$definition] = []; } }
php
protected function processPrefix($name, $definition, array &$prefices, array &$vocabularies) { $prefices[$name] = $definition; // Register the vocabulary if (!isset($vocabularies[$definition])) { $vocabularies[$definition] = []; } }
[ "protected", "function", "processPrefix", "(", "$", "name", ",", "$", "definition", ",", "array", "&", "$", "prefices", ",", "array", "&", "$", "vocabularies", ")", "{", "$", "prefices", "[", "$", "name", "]", "=", "$", "definition", ";", "// Register the vocabulary", "if", "(", "!", "isset", "(", "$", "vocabularies", "[", "$", "definition", "]", ")", ")", "{", "$", "vocabularies", "[", "$", "definition", "]", "=", "[", "]", ";", "}", "}" ]
Process a vocabulary prefix @param string $name Prefix name @param string $definition Prefix definition @param array $prefices Prefix register @param array $vocabularies Vocabulary register
[ "Process", "a", "vocabulary", "prefix" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php#L219-L227
31,036
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php
VocabularyCache.processVocabularyTerm
protected function processVocabularyTerm($definition, array &$prefices, array &$vocabularies) { $prefixName = explode(':', $definition->{'@id'}, 2); if (count($prefixName) == 2) { if (isset($prefices[$prefixName[0]])) { $vocabularies[$prefices[$prefixName[0]]][$prefixName[1]] = true; } } }
php
protected function processVocabularyTerm($definition, array &$prefices, array &$vocabularies) { $prefixName = explode(':', $definition->{'@id'}, 2); if (count($prefixName) == 2) { if (isset($prefices[$prefixName[0]])) { $vocabularies[$prefices[$prefixName[0]]][$prefixName[1]] = true; } } }
[ "protected", "function", "processVocabularyTerm", "(", "$", "definition", ",", "array", "&", "$", "prefices", ",", "array", "&", "$", "vocabularies", ")", "{", "$", "prefixName", "=", "explode", "(", "':'", ",", "$", "definition", "->", "{", "'@id'", "}", ",", "2", ")", ";", "if", "(", "count", "(", "$", "prefixName", ")", "==", "2", ")", "{", "if", "(", "isset", "(", "$", "prefices", "[", "$", "prefixName", "[", "0", "]", "]", ")", ")", "{", "$", "vocabularies", "[", "$", "prefices", "[", "$", "prefixName", "[", "0", "]", "]", "]", "[", "$", "prefixName", "[", "1", "]", "]", "=", "true", ";", "}", "}", "}" ]
Process a vocabulary term @param \stdClass $definition Term definition @param array $prefices Prefix register @param array $vocabularies Vocabulary register
[ "Process", "a", "vocabulary", "term" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php#L248-L256
31,037
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php
VocabularyCache.expandIRI
public function expandIRI($name) { $iri = (object)['name' => $name, 'profile' => '']; $vocabularies = Cache::getAdapter()->getItem(self::SLOT_VOCABS); // Run through all vocabularies if ($vocabularies->isHit()) { $this->matchVocabularies($name, $vocabularies->get(), $iri); } return $iri; }
php
public function expandIRI($name) { $iri = (object)['name' => $name, 'profile' => '']; $vocabularies = Cache::getAdapter()->getItem(self::SLOT_VOCABS); // Run through all vocabularies if ($vocabularies->isHit()) { $this->matchVocabularies($name, $vocabularies->get(), $iri); } return $iri; }
[ "public", "function", "expandIRI", "(", "$", "name", ")", "{", "$", "iri", "=", "(", "object", ")", "[", "'name'", "=>", "$", "name", ",", "'profile'", "=>", "''", "]", ";", "$", "vocabularies", "=", "Cache", "::", "getAdapter", "(", ")", "->", "getItem", "(", "self", "::", "SLOT_VOCABS", ")", ";", "// Run through all vocabularies", "if", "(", "$", "vocabularies", "->", "isHit", "(", ")", ")", "{", "$", "this", "->", "matchVocabularies", "(", "$", "name", ",", "$", "vocabularies", "->", "get", "(", ")", ",", "$", "iri", ")", ";", "}", "return", "$", "iri", ";", "}" ]
Create an IRI from a name considering the known vocabularies @param string $name Name @return \stdClass IRI
[ "Create", "an", "IRI", "from", "a", "name", "considering", "the", "known", "vocabularies" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php#L265-L276
31,038
jkphl/micrometa
src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php
VocabularyCache.matchVocabularies
protected function matchVocabularies($name, array $vocabularies, &$iri) { // Run through all vocabularies foreach ($vocabularies as $profile => $terms) { $profileLength = strlen($profile); // If the name matches the profile and the remaining string is a registered term if (!strncasecmp($profile, $name, $profileLength) && !empty($terms[substr($name, $profileLength)])) { $iri->profile = $profile; $iri->name = substr($name, $profileLength); return; } } }
php
protected function matchVocabularies($name, array $vocabularies, &$iri) { // Run through all vocabularies foreach ($vocabularies as $profile => $terms) { $profileLength = strlen($profile); // If the name matches the profile and the remaining string is a registered term if (!strncasecmp($profile, $name, $profileLength) && !empty($terms[substr($name, $profileLength)])) { $iri->profile = $profile; $iri->name = substr($name, $profileLength); return; } } }
[ "protected", "function", "matchVocabularies", "(", "$", "name", ",", "array", "$", "vocabularies", ",", "&", "$", "iri", ")", "{", "// Run through all vocabularies", "foreach", "(", "$", "vocabularies", "as", "$", "profile", "=>", "$", "terms", ")", "{", "$", "profileLength", "=", "strlen", "(", "$", "profile", ")", ";", "// If the name matches the profile and the remaining string is a registered term", "if", "(", "!", "strncasecmp", "(", "$", "profile", ",", "$", "name", ",", "$", "profileLength", ")", "&&", "!", "empty", "(", "$", "terms", "[", "substr", "(", "$", "name", ",", "$", "profileLength", ")", "]", ")", ")", "{", "$", "iri", "->", "profile", "=", "$", "profile", ";", "$", "iri", "->", "name", "=", "substr", "(", "$", "name", ",", "$", "profileLength", ")", ";", "return", ";", "}", "}", "}" ]
Match a name with the known vocabularies @param string $name Name @param array $vocabularies Vocabularies @param \stdClass $iri IRI
[ "Match", "a", "name", "with", "the", "known", "vocabularies" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Parser/JsonLD/VocabularyCache.php#L285-L299
31,039
jkphl/micrometa
src/Micrometa/Domain/Item/ItemSetupTrait.php
ItemSetupTrait.setup
protected function setup( PropertyListFactoryInterface $propertyListFactory, array $type, array $properties, $itemId, $itemLanguage ) { $this->propertyListFactory = $propertyListFactory; $this->type = $this->valTypes($type); $this->properties = $this->valProperties($properties); $this->itemId = $itemId ?: null; $this->itemLanguage = $itemLanguage ?: null; }
php
protected function setup( PropertyListFactoryInterface $propertyListFactory, array $type, array $properties, $itemId, $itemLanguage ) { $this->propertyListFactory = $propertyListFactory; $this->type = $this->valTypes($type); $this->properties = $this->valProperties($properties); $this->itemId = $itemId ?: null; $this->itemLanguage = $itemLanguage ?: null; }
[ "protected", "function", "setup", "(", "PropertyListFactoryInterface", "$", "propertyListFactory", ",", "array", "$", "type", ",", "array", "$", "properties", ",", "$", "itemId", ",", "$", "itemLanguage", ")", "{", "$", "this", "->", "propertyListFactory", "=", "$", "propertyListFactory", ";", "$", "this", "->", "type", "=", "$", "this", "->", "valTypes", "(", "$", "type", ")", ";", "$", "this", "->", "properties", "=", "$", "this", "->", "valProperties", "(", "$", "properties", ")", ";", "$", "this", "->", "itemId", "=", "$", "itemId", "?", ":", "null", ";", "$", "this", "->", "itemLanguage", "=", "$", "itemLanguage", "?", ":", "null", ";", "}" ]
Setup the item @param PropertyListFactoryInterface $propertyListFactory Property list factory @param string[]|\stdClass[] $type Item type(s) @param \stdClass[] $properties Item properties @param string $itemId Item ID @param string $itemLanguage Item language
[ "Setup", "the", "item" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Item/ItemSetupTrait.php#L96-L108
31,040
jkphl/micrometa
src/Micrometa/Domain/Item/ItemSetupTrait.php
ItemSetupTrait.valTypes
protected function valTypes(array $types) { $nonEmptyTypes = array_filter(array_map([$this, 'valType'], $types)); // If there are no valid types if (!count($nonEmptyTypes)) { throw new InvalidArgumentException( InvalidArgumentException::EMPTY_TYPES_STR, InvalidArgumentException::EMPTY_TYPES ); } return array_values($nonEmptyTypes); }
php
protected function valTypes(array $types) { $nonEmptyTypes = array_filter(array_map([$this, 'valType'], $types)); // If there are no valid types if (!count($nonEmptyTypes)) { throw new InvalidArgumentException( InvalidArgumentException::EMPTY_TYPES_STR, InvalidArgumentException::EMPTY_TYPES ); } return array_values($nonEmptyTypes); }
[ "protected", "function", "valTypes", "(", "array", "$", "types", ")", "{", "$", "nonEmptyTypes", "=", "array_filter", "(", "array_map", "(", "[", "$", "this", ",", "'valType'", "]", ",", "$", "types", ")", ")", ";", "// If there are no valid types", "if", "(", "!", "count", "(", "$", "nonEmptyTypes", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "InvalidArgumentException", "::", "EMPTY_TYPES_STR", ",", "InvalidArgumentException", "::", "EMPTY_TYPES", ")", ";", "}", "return", "array_values", "(", "$", "nonEmptyTypes", ")", ";", "}" ]
Validate and sanitize the item types @param string[]|\stdClass[] $types Item types @return array Validated item types @throws InvalidArgumentException If there are no valid types
[ "Validate", "and", "sanitize", "the", "item", "types" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Item/ItemSetupTrait.php#L118-L131
31,041
jkphl/micrometa
src/Micrometa/Domain/Item/ItemSetupTrait.php
ItemSetupTrait.valProperties
protected function valProperties(array $properties) { $validatedProperties = $this->propertyListFactory->create(); // Run through all validated properties foreach (array_filter(array_map([$this, 'valProp'], $properties)) as $property) { $validatedProperties->add($property); } return $validatedProperties; }
php
protected function valProperties(array $properties) { $validatedProperties = $this->propertyListFactory->create(); // Run through all validated properties foreach (array_filter(array_map([$this, 'valProp'], $properties)) as $property) { $validatedProperties->add($property); } return $validatedProperties; }
[ "protected", "function", "valProperties", "(", "array", "$", "properties", ")", "{", "$", "validatedProperties", "=", "$", "this", "->", "propertyListFactory", "->", "create", "(", ")", ";", "// Run through all validated properties", "foreach", "(", "array_filter", "(", "array_map", "(", "[", "$", "this", ",", "'valProp'", "]", ",", "$", "properties", ")", ")", "as", "$", "property", ")", "{", "$", "validatedProperties", "->", "add", "(", "$", "property", ")", ";", "}", "return", "$", "validatedProperties", ";", "}" ]
Validate the item properties @param array $properties Item properties @return PropertyListInterface Validated item properties @throws InvalidArgumentException If the property name is empty
[ "Validate", "the", "item", "properties" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Item/ItemSetupTrait.php#L141-L151
31,042
jkphl/micrometa
src/Micrometa/Domain/Item/ItemSetupTrait.php
ItemSetupTrait.valProp
protected function valProp($property) { // Validate the property structure $this->valPropStructure($property); // If the property has values if (count($property->values)) { // Validate the property name $property->name = $this->valPropName($property); // Validate the property values $property->values = $this->valPropValues($property->values); // If the property has significant values if (count($property->values)) { return $property; } } return null; }
php
protected function valProp($property) { // Validate the property structure $this->valPropStructure($property); // If the property has values if (count($property->values)) { // Validate the property name $property->name = $this->valPropName($property); // Validate the property values $property->values = $this->valPropValues($property->values); // If the property has significant values if (count($property->values)) { return $property; } } return null; }
[ "protected", "function", "valProp", "(", "$", "property", ")", "{", "// Validate the property structure", "$", "this", "->", "valPropStructure", "(", "$", "property", ")", ";", "// If the property has values", "if", "(", "count", "(", "$", "property", "->", "values", ")", ")", "{", "// Validate the property name", "$", "property", "->", "name", "=", "$", "this", "->", "valPropName", "(", "$", "property", ")", ";", "// Validate the property values", "$", "property", "->", "values", "=", "$", "this", "->", "valPropValues", "(", "$", "property", "->", "values", ")", ";", "// If the property has significant values", "if", "(", "count", "(", "$", "property", "->", "values", ")", ")", "{", "return", "$", "property", ";", "}", "}", "return", "null", ";", "}" ]
Validate a single property @param \stdClass $property Property @return \stdClass Validated property
[ "Validate", "a", "single", "property" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Item/ItemSetupTrait.php#L160-L180
31,043
jkphl/micrometa
src/Micrometa/Domain/Item/ItemSetupTrait.php
ItemSetupTrait.valPropStructure
protected function valPropStructure($property) { // If the property object is invalid if (!is_object($property) || !$this->valPropProperties($property)) { throw new InvalidArgumentException( InvalidArgumentException::INVALID_PROPERTY_STR, InvalidArgumentException::INVALID_PROPERTY ); } }
php
protected function valPropStructure($property) { // If the property object is invalid if (!is_object($property) || !$this->valPropProperties($property)) { throw new InvalidArgumentException( InvalidArgumentException::INVALID_PROPERTY_STR, InvalidArgumentException::INVALID_PROPERTY ); } }
[ "protected", "function", "valPropStructure", "(", "$", "property", ")", "{", "// If the property object is invalid", "if", "(", "!", "is_object", "(", "$", "property", ")", "||", "!", "$", "this", "->", "valPropProperties", "(", "$", "property", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "InvalidArgumentException", "::", "INVALID_PROPERTY_STR", ",", "InvalidArgumentException", "::", "INVALID_PROPERTY", ")", ";", "}", "}" ]
Validate the structure of a property object @param \stdClass $property Property object @throws InvalidArgumentException If the property object is invalid
[ "Validate", "the", "structure", "of", "a", "property", "object" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Item/ItemSetupTrait.php#L189-L198
31,044
jkphl/micrometa
src/Micrometa/Domain/Item/ItemSetupTrait.php
ItemSetupTrait.valPropProperties
protected function valPropProperties($property) { return isset($property->profile) && isset($property->name) && isset($property->values) && is_array($property->values); }
php
protected function valPropProperties($property) { return isset($property->profile) && isset($property->name) && isset($property->values) && is_array($property->values); }
[ "protected", "function", "valPropProperties", "(", "$", "property", ")", "{", "return", "isset", "(", "$", "property", "->", "profile", ")", "&&", "isset", "(", "$", "property", "->", "name", ")", "&&", "isset", "(", "$", "property", "->", "values", ")", "&&", "is_array", "(", "$", "property", "->", "values", ")", ";", "}" ]
Validate the properties of a property @param \stdClass $property Property @return bool Property properties are valid
[ "Validate", "the", "properties", "of", "a", "property" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Item/ItemSetupTrait.php#L207-L213
31,045
jkphl/micrometa
src/Micrometa/Domain/Item/ItemSetupTrait.php
ItemSetupTrait.valPropValues
protected function valPropValues(array $values) { $validPropertyValues = []; // Run through all property values /** @var ValueInterface $value */ foreach ($values as $value) { $this->procPropValue($value, $validPropertyValues); } return $validPropertyValues; }
php
protected function valPropValues(array $values) { $validPropertyValues = []; // Run through all property values /** @var ValueInterface $value */ foreach ($values as $value) { $this->procPropValue($value, $validPropertyValues); } return $validPropertyValues; }
[ "protected", "function", "valPropValues", "(", "array", "$", "values", ")", "{", "$", "validPropertyValues", "=", "[", "]", ";", "// Run through all property values", "/** @var ValueInterface $value */", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", "this", "->", "procPropValue", "(", "$", "value", ",", "$", "validPropertyValues", ")", ";", "}", "return", "$", "validPropertyValues", ";", "}" ]
Validate a list of property values @param array $values Property values @return array Validated property values @throws InvalidArgumentException If the value is not a nested item
[ "Validate", "a", "list", "of", "property", "values" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Item/ItemSetupTrait.php#L245-L256
31,046
jkphl/micrometa
src/Micrometa/Domain/Item/ItemSetupTrait.php
ItemSetupTrait.valType
protected function valType($type) { $type = IriFactory::create($type); return strlen($type->name) ? $type : null; }
php
protected function valType($type) { $type = IriFactory::create($type); return strlen($type->name) ? $type : null; }
[ "protected", "function", "valType", "(", "$", "type", ")", "{", "$", "type", "=", "IriFactory", "::", "create", "(", "$", "type", ")", ";", "return", "strlen", "(", "$", "type", "->", "name", ")", "?", "$", "type", ":", "null", ";", "}" ]
Validate a single item type @param \stdClass|Iri|string $type Item type @return Iri|null Validated item type @throws InvalidArgumentException If the item type object is invalid
[ "Validate", "a", "single", "item", "type" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Item/ItemSetupTrait.php#L288-L293
31,047
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php
MicroformatsFactory.createItem
protected static function createItem(array $item) { $microformatItem = ['type' => self::createTypes($item['type']), 'lang' => null]; self::processProperties($item, $microformatItem); self::processValue($item, $microformatItem); self::processChildren($item, $microformatItem); return (object)$microformatItem; }
php
protected static function createItem(array $item) { $microformatItem = ['type' => self::createTypes($item['type']), 'lang' => null]; self::processProperties($item, $microformatItem); self::processValue($item, $microformatItem); self::processChildren($item, $microformatItem); return (object)$microformatItem; }
[ "protected", "static", "function", "createItem", "(", "array", "$", "item", ")", "{", "$", "microformatItem", "=", "[", "'type'", "=>", "self", "::", "createTypes", "(", "$", "item", "[", "'type'", "]", ")", ",", "'lang'", "=>", "null", "]", ";", "self", "::", "processProperties", "(", "$", "item", ",", "$", "microformatItem", ")", ";", "self", "::", "processValue", "(", "$", "item", ",", "$", "microformatItem", ")", ";", "self", "::", "processChildren", "(", "$", "item", ",", "$", "microformatItem", ")", ";", "return", "(", "object", ")", "$", "microformatItem", ";", "}" ]
Refine an item @param array $item Item @return \stdClass Refined Microformats item
[ "Refine", "an", "item" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php#L62-L70
31,048
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php
MicroformatsFactory.processProperties
protected static function processProperties(array $item, array &$microformatItem) { // Create the properties (if any) if (isset($item['properties']) && is_array($item['properties'])) { $microformatItem['properties'] = self::createProperties($item['properties'], $microformatItem['lang']); } }
php
protected static function processProperties(array $item, array &$microformatItem) { // Create the properties (if any) if (isset($item['properties']) && is_array($item['properties'])) { $microformatItem['properties'] = self::createProperties($item['properties'], $microformatItem['lang']); } }
[ "protected", "static", "function", "processProperties", "(", "array", "$", "item", ",", "array", "&", "$", "microformatItem", ")", "{", "// Create the properties (if any)", "if", "(", "isset", "(", "$", "item", "[", "'properties'", "]", ")", "&&", "is_array", "(", "$", "item", "[", "'properties'", "]", ")", ")", "{", "$", "microformatItem", "[", "'properties'", "]", "=", "self", "::", "createProperties", "(", "$", "item", "[", "'properties'", "]", ",", "$", "microformatItem", "[", "'lang'", "]", ")", ";", "}", "}" ]
Process the item properties @param array $item Item @param array $microformatItem Refined Microformats item
[ "Process", "the", "item", "properties" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php#L95-L101
31,049
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php
MicroformatsFactory.createProperties
protected static function createProperties(array $properties, &$lang) { // Extract the language (if present) $properties = self::createLanguage($properties, $lang); $mfProperties = []; foreach ($properties as $propertyName => $propertyValues) { // Process property values if (is_array($propertyValues)) { $mfProperties[] = (object)[ 'profile' => self::MF2_PROFILE_URI, 'name' => $propertyName, 'values' => self::createProperty($propertyValues) ]; } } return $mfProperties; }
php
protected static function createProperties(array $properties, &$lang) { // Extract the language (if present) $properties = self::createLanguage($properties, $lang); $mfProperties = []; foreach ($properties as $propertyName => $propertyValues) { // Process property values if (is_array($propertyValues)) { $mfProperties[] = (object)[ 'profile' => self::MF2_PROFILE_URI, 'name' => $propertyName, 'values' => self::createProperty($propertyValues) ]; } } return $mfProperties; }
[ "protected", "static", "function", "createProperties", "(", "array", "$", "properties", ",", "&", "$", "lang", ")", "{", "// Extract the language (if present)", "$", "properties", "=", "self", "::", "createLanguage", "(", "$", "properties", ",", "$", "lang", ")", ";", "$", "mfProperties", "=", "[", "]", ";", "foreach", "(", "$", "properties", "as", "$", "propertyName", "=>", "$", "propertyValues", ")", "{", "// Process property values", "if", "(", "is_array", "(", "$", "propertyValues", ")", ")", "{", "$", "mfProperties", "[", "]", "=", "(", "object", ")", "[", "'profile'", "=>", "self", "::", "MF2_PROFILE_URI", ",", "'name'", "=>", "$", "propertyName", ",", "'values'", "=>", "self", "::", "createProperty", "(", "$", "propertyValues", ")", "]", ";", "}", "}", "return", "$", "mfProperties", ";", "}" ]
Refine the item properties @param array $properties Properties @param string $lang Item language @return array Refined properties
[ "Refine", "the", "item", "properties" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php#L111-L129
31,050
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php
MicroformatsFactory.createLanguage
protected static function createLanguage(array $values, &$lang) { // If this is an alternate values list if (isset($values['lang'])) { if (is_string($values['lang'])) { $lang = trim($values['lang']) ?: null; } unset($values['lang']); } return $values; }
php
protected static function createLanguage(array $values, &$lang) { // If this is an alternate values list if (isset($values['lang'])) { if (is_string($values['lang'])) { $lang = trim($values['lang']) ?: null; } unset($values['lang']); } return $values; }
[ "protected", "static", "function", "createLanguage", "(", "array", "$", "values", ",", "&", "$", "lang", ")", "{", "// If this is an alternate values list", "if", "(", "isset", "(", "$", "values", "[", "'lang'", "]", ")", ")", "{", "if", "(", "is_string", "(", "$", "values", "[", "'lang'", "]", ")", ")", "{", "$", "lang", "=", "trim", "(", "$", "values", "[", "'lang'", "]", ")", "?", ":", "null", ";", "}", "unset", "(", "$", "values", "[", "'lang'", "]", ")", ";", "}", "return", "$", "values", ";", "}" ]
Extract a language value from a value list @param array $values Value list @param string $lang Language @return array Remaining values
[ "Extract", "a", "language", "value", "from", "a", "value", "list" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php#L139-L150
31,051
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php
MicroformatsFactory.createProperty
protected static function createProperty(array $propertyValues) { return array_map( function($propertyValue) { if (is_array($propertyValue)) { return isset($propertyValue['type']) ? self::createItem($propertyValue) : self::tagLanguage($propertyValue); } return $propertyValue; }, $propertyValues ); }
php
protected static function createProperty(array $propertyValues) { return array_map( function($propertyValue) { if (is_array($propertyValue)) { return isset($propertyValue['type']) ? self::createItem($propertyValue) : self::tagLanguage($propertyValue); } return $propertyValue; }, $propertyValues ); }
[ "protected", "static", "function", "createProperty", "(", "array", "$", "propertyValues", ")", "{", "return", "array_map", "(", "function", "(", "$", "propertyValue", ")", "{", "if", "(", "is_array", "(", "$", "propertyValue", ")", ")", "{", "return", "isset", "(", "$", "propertyValue", "[", "'type'", "]", ")", "?", "self", "::", "createItem", "(", "$", "propertyValue", ")", ":", "self", "::", "tagLanguage", "(", "$", "propertyValue", ")", ";", "}", "return", "$", "propertyValue", ";", "}", ",", "$", "propertyValues", ")", ";", "}" ]
Refine the item property values @param array $propertyValues Property values @return array Refined property values
[ "Refine", "the", "item", "property", "values" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php#L159-L172
31,052
jkphl/micrometa
src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php
MicroformatsFactory.processChildren
protected static function processChildren(array $item, array &$microformatItem) { if (isset($item['children']) && is_array($item['children'])) { $microformatItem['children'] = self::createFromParserResult($item['children']); } }
php
protected static function processChildren(array $item, array &$microformatItem) { if (isset($item['children']) && is_array($item['children'])) { $microformatItem['children'] = self::createFromParserResult($item['children']); } }
[ "protected", "static", "function", "processChildren", "(", "array", "$", "item", ",", "array", "&", "$", "microformatItem", ")", "{", "if", "(", "isset", "(", "$", "item", "[", "'children'", "]", ")", "&&", "is_array", "(", "$", "item", "[", "'children'", "]", ")", ")", "{", "$", "microformatItem", "[", "'children'", "]", "=", "self", "::", "createFromParserResult", "(", "$", "item", "[", "'children'", "]", ")", ";", "}", "}" ]
Process the nested item children @param array $item Item @param array $microformatItem Refined Microformats item
[ "Process", "the", "nested", "item", "children" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Factory/MicroformatsFactory.php#L222-L227
31,053
jkphl/micrometa
src/Micrometa/Application/Factory/ItemFactory.php
ItemFactory.processPropertyValue
protected function processPropertyValue($propertyValue) { // If this is an item value if (is_object($propertyValue) && isset($propertyValue->type)) { return $this->__invoke($propertyValue); // Else these are alternate values } elseif (is_array($propertyValue)) { return new AlternateValues(array_map([$this, __METHOD__], $propertyValue)); } list($propertyValue, $language) = $this->processLanguageTaggedPropertyValue($propertyValue); return new StringValue($propertyValue, $language); }
php
protected function processPropertyValue($propertyValue) { // If this is an item value if (is_object($propertyValue) && isset($propertyValue->type)) { return $this->__invoke($propertyValue); // Else these are alternate values } elseif (is_array($propertyValue)) { return new AlternateValues(array_map([$this, __METHOD__], $propertyValue)); } list($propertyValue, $language) = $this->processLanguageTaggedPropertyValue($propertyValue); return new StringValue($propertyValue, $language); }
[ "protected", "function", "processPropertyValue", "(", "$", "propertyValue", ")", "{", "// If this is an item value", "if", "(", "is_object", "(", "$", "propertyValue", ")", "&&", "isset", "(", "$", "propertyValue", "->", "type", ")", ")", "{", "return", "$", "this", "->", "__invoke", "(", "$", "propertyValue", ")", ";", "// Else these are alternate values", "}", "elseif", "(", "is_array", "(", "$", "propertyValue", ")", ")", "{", "return", "new", "AlternateValues", "(", "array_map", "(", "[", "$", "this", ",", "__METHOD__", "]", ",", "$", "propertyValue", ")", ")", ";", "}", "list", "(", "$", "propertyValue", ",", "$", "language", ")", "=", "$", "this", "->", "processLanguageTaggedPropertyValue", "(", "$", "propertyValue", ")", ";", "return", "new", "StringValue", "(", "$", "propertyValue", ",", "$", "language", ")", ";", "}" ]
Prepare a single property value @param mixed $propertyValue Property Value @return ValueInterface Value
[ "Prepare", "a", "single", "property", "value" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Application/Factory/ItemFactory.php#L86-L100
31,054
jkphl/micrometa
src/Micrometa/Application/Factory/ItemFactory.php
ItemFactory.normalizeEmptyValue
protected function normalizeEmptyValue(\stdClass $item, $property) { return isset($item->$property) ? $item->$property : null; }
php
protected function normalizeEmptyValue(\stdClass $item, $property) { return isset($item->$property) ? $item->$property : null; }
[ "protected", "function", "normalizeEmptyValue", "(", "\\", "stdClass", "$", "item", ",", "$", "property", ")", "{", "return", "isset", "(", "$", "item", "->", "$", "property", ")", "?", "$", "item", "->", "$", "property", ":", "null", ";", "}" ]
Normalize an empty item value @param \stdClass $item Item @param string $property Property name @return string|null Normalized property value
[ "Normalize", "an", "empty", "item", "value" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Application/Factory/ItemFactory.php#L170-L173
31,055
jkphl/micrometa
src/Micrometa/Application/Factory/ItemFactory.php
ItemFactory.getProperties
protected function getProperties(\stdClass $item) { $properties = []; if (isset($item->properties) && is_array($item->properties)) { foreach ($item->properties as $property) { $this->processProperty($properties, $property); } } return $properties; }
php
protected function getProperties(\stdClass $item) { $properties = []; if (isset($item->properties) && is_array($item->properties)) { foreach ($item->properties as $property) { $this->processProperty($properties, $property); } } return $properties; }
[ "protected", "function", "getProperties", "(", "\\", "stdClass", "$", "item", ")", "{", "$", "properties", "=", "[", "]", ";", "if", "(", "isset", "(", "$", "item", "->", "properties", ")", "&&", "is_array", "(", "$", "item", "->", "properties", ")", ")", "{", "foreach", "(", "$", "item", "->", "properties", "as", "$", "property", ")", "{", "$", "this", "->", "processProperty", "(", "$", "properties", ",", "$", "property", ")", ";", "}", "}", "return", "$", "properties", ";", "}" ]
Prepare item properties @param \stdClass $item Item @return array Properties
[ "Prepare", "item", "properties" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Application/Factory/ItemFactory.php#L182-L192
31,056
jkphl/micrometa
src/Micrometa/Application/Factory/ItemFactory.php
ItemFactory.processProperty
protected function processProperty(array &$properties, $property) { try { if ($this->validatePropertyStructure($property)) { $property->values = $this->getPropertyValues($property->values); if (count($property->values)) { $properties[] = $property; } } } catch (InvalidArgumentException $exception) { // Skip this property } }
php
protected function processProperty(array &$properties, $property) { try { if ($this->validatePropertyStructure($property)) { $property->values = $this->getPropertyValues($property->values); if (count($property->values)) { $properties[] = $property; } } } catch (InvalidArgumentException $exception) { // Skip this property } }
[ "protected", "function", "processProperty", "(", "array", "&", "$", "properties", ",", "$", "property", ")", "{", "try", "{", "if", "(", "$", "this", "->", "validatePropertyStructure", "(", "$", "property", ")", ")", "{", "$", "property", "->", "values", "=", "$", "this", "->", "getPropertyValues", "(", "$", "property", "->", "values", ")", ";", "if", "(", "count", "(", "$", "property", "->", "values", ")", ")", "{", "$", "properties", "[", "]", "=", "$", "property", ";", "}", "}", "}", "catch", "(", "InvalidArgumentException", "$", "exception", ")", "{", "// Skip this property", "}", "}" ]
Process a property @param array $properties Properties @param \stdClass $property Property
[ "Process", "a", "property" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Application/Factory/ItemFactory.php#L200-L212
31,057
jkphl/micrometa
src/Micrometa/Application/Factory/ItemFactory.php
ItemFactory.validatePropertyStructure
protected function validatePropertyStructure($property) { return is_object($property) && isset($property->profile) && isset($property->name) && isset($property->values); }
php
protected function validatePropertyStructure($property) { return is_object($property) && isset($property->profile) && isset($property->name) && isset($property->values); }
[ "protected", "function", "validatePropertyStructure", "(", "$", "property", ")", "{", "return", "is_object", "(", "$", "property", ")", "&&", "isset", "(", "$", "property", "->", "profile", ")", "&&", "isset", "(", "$", "property", "->", "name", ")", "&&", "isset", "(", "$", "property", "->", "values", ")", ";", "}" ]
Validate if an object is a valid property @param \stdClass $property Property @return bool Is a valid property
[ "Validate", "if", "an", "object", "is", "a", "valid", "property" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Application/Factory/ItemFactory.php#L221-L224
31,058
jkphl/micrometa
src/Micrometa/Application/Factory/ItemFactory.php
ItemFactory.getPropertyValues
protected function getPropertyValues($propertyValues) { // If it's not a list of property values if (!is_array($propertyValues)) { throw new InvalidArgumentException( InvalidArgumentException::INVALID_PROPERTY_VALUES_STR, InvalidArgumentException::INVALID_PROPERTY_VALUES ); } return array_map([$this, 'processPropertyValue'], $propertyValues); }
php
protected function getPropertyValues($propertyValues) { // If it's not a list of property values if (!is_array($propertyValues)) { throw new InvalidArgumentException( InvalidArgumentException::INVALID_PROPERTY_VALUES_STR, InvalidArgumentException::INVALID_PROPERTY_VALUES ); } return array_map([$this, 'processPropertyValue'], $propertyValues); }
[ "protected", "function", "getPropertyValues", "(", "$", "propertyValues", ")", "{", "// If it's not a list of property values", "if", "(", "!", "is_array", "(", "$", "propertyValues", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "InvalidArgumentException", "::", "INVALID_PROPERTY_VALUES_STR", ",", "InvalidArgumentException", "::", "INVALID_PROPERTY_VALUES", ")", ";", "}", "return", "array_map", "(", "[", "$", "this", ",", "'processPropertyValue'", "]", ",", "$", "propertyValues", ")", ";", "}" ]
Prepare item property values @param array $propertyValues Property values @return array Expanded property values @throws InvalidArgumentException If it's not a list of property values
[ "Prepare", "item", "property", "values" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Application/Factory/ItemFactory.php#L234-L245
31,059
jkphl/micrometa
src/Micrometa/Application/Factory/ItemFactory.php
ItemFactory.processLanguageTaggedPropertyValue
protected function processLanguageTaggedPropertyValue($propertyValue) { $language = null; if (is_object($propertyValue)) { // If this is an invalid language tagged object if (!isset($propertyValue->lang) || !isset($propertyValue->value)) { throw new RuntimeException( RuntimeException::INVALID_LANGUAGE_TAGGED_VALUE_STR, RuntimeException::INVALID_LANGUAGE_TAGGED_VALUE ); } $language = $propertyValue->lang; $propertyValue = $propertyValue->value; } return [$propertyValue, $language]; }
php
protected function processLanguageTaggedPropertyValue($propertyValue) { $language = null; if (is_object($propertyValue)) { // If this is an invalid language tagged object if (!isset($propertyValue->lang) || !isset($propertyValue->value)) { throw new RuntimeException( RuntimeException::INVALID_LANGUAGE_TAGGED_VALUE_STR, RuntimeException::INVALID_LANGUAGE_TAGGED_VALUE ); } $language = $propertyValue->lang; $propertyValue = $propertyValue->value; } return [$propertyValue, $language]; }
[ "protected", "function", "processLanguageTaggedPropertyValue", "(", "$", "propertyValue", ")", "{", "$", "language", "=", "null", ";", "if", "(", "is_object", "(", "$", "propertyValue", ")", ")", "{", "// If this is an invalid language tagged object", "if", "(", "!", "isset", "(", "$", "propertyValue", "->", "lang", ")", "||", "!", "isset", "(", "$", "propertyValue", "->", "value", ")", ")", "{", "throw", "new", "RuntimeException", "(", "RuntimeException", "::", "INVALID_LANGUAGE_TAGGED_VALUE_STR", ",", "RuntimeException", "::", "INVALID_LANGUAGE_TAGGED_VALUE", ")", ";", "}", "$", "language", "=", "$", "propertyValue", "->", "lang", ";", "$", "propertyValue", "=", "$", "propertyValue", "->", "value", ";", "}", "return", "[", "$", "propertyValue", ",", "$", "language", "]", ";", "}" ]
Process a language tagged property value @param string|\stdClass $propertyValue Property value @return array Language and property value @throws RuntimeException If this is an invalid language tagged value
[ "Process", "a", "language", "tagged", "property", "value" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Application/Factory/ItemFactory.php#L255-L272
31,060
jkphl/micrometa
src/Micrometa/Ports/Item/ItemObjectModel.php
ItemObjectModel.link
public function link($type = null, $index = null) { // One-time caching of link elements if ($this->links === null) { $this->cacheLinkTypeItems(); } // Find the matching LinkType items $links = ($type === null) ? $this->links->getItems() : $this->links->getItems($type); // Return link item(s) return ($index === null) ? new ItemList($links) : $this->getLinkIndex($links, $type, $index); }
php
public function link($type = null, $index = null) { // One-time caching of link elements if ($this->links === null) { $this->cacheLinkTypeItems(); } // Find the matching LinkType items $links = ($type === null) ? $this->links->getItems() : $this->links->getItems($type); // Return link item(s) return ($index === null) ? new ItemList($links) : $this->getLinkIndex($links, $type, $index); }
[ "public", "function", "link", "(", "$", "type", "=", "null", ",", "$", "index", "=", "null", ")", "{", "// One-time caching of link elements", "if", "(", "$", "this", "->", "links", "===", "null", ")", "{", "$", "this", "->", "cacheLinkTypeItems", "(", ")", ";", "}", "// Find the matching LinkType items", "$", "links", "=", "(", "$", "type", "===", "null", ")", "?", "$", "this", "->", "links", "->", "getItems", "(", ")", ":", "$", "this", "->", "links", "->", "getItems", "(", "$", "type", ")", ";", "// Return link item(s)", "return", "(", "$", "index", "===", "null", ")", "?", "new", "ItemList", "(", "$", "links", ")", ":", "$", "this", "->", "getLinkIndex", "(", "$", "links", ",", "$", "type", ",", "$", "index", ")", ";", "}" ]
Return all link declarations of a particular type @param string|null $type Link type @param int|null $index Optional: particular index @return ItemInterface|ItemListInterface Single LinkType item or list of LinkType items @api
[ "Return", "all", "link", "declarations", "of", "a", "particular", "type" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Ports/Item/ItemObjectModel.php#L84-L96
31,061
jkphl/micrometa
src/Micrometa/Ports/Item/ItemObjectModel.php
ItemObjectModel.cacheLinkTypeItems
protected function cacheLinkTypeItems() { $links = []; foreach ($this->items as $item) { if ($item->getFormat() == LinkType::FORMAT) { $links[] = $item; } } $this->links = new ItemList($links); }
php
protected function cacheLinkTypeItems() { $links = []; foreach ($this->items as $item) { if ($item->getFormat() == LinkType::FORMAT) { $links[] = $item; } } $this->links = new ItemList($links); }
[ "protected", "function", "cacheLinkTypeItems", "(", ")", "{", "$", "links", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "if", "(", "$", "item", "->", "getFormat", "(", ")", "==", "LinkType", "::", "FORMAT", ")", "{", "$", "links", "[", "]", "=", "$", "item", ";", "}", "}", "$", "this", "->", "links", "=", "new", "ItemList", "(", "$", "links", ")", ";", "}" ]
One-time caching of LinkType items
[ "One", "-", "time", "caching", "of", "LinkType", "items" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Ports/Item/ItemObjectModel.php#L101-L110
31,062
jkphl/micrometa
src/Micrometa/Ports/Item/ItemObjectModel.php
ItemObjectModel.getLinkIndex
protected function getLinkIndex(array $links, $type, $index) { // If the link index is out of bounds if (!is_int($index) || !array_key_exists($index, $links)) { throw new OutOfBoundsException( sprintf(OutOfBoundsException::INVALID_LINK_TYPE_INDEX_STR, $index, $type), OutOfBoundsException::INVALID_LINK_TYPE_INDEX ); } return $links[$index]; }
php
protected function getLinkIndex(array $links, $type, $index) { // If the link index is out of bounds if (!is_int($index) || !array_key_exists($index, $links)) { throw new OutOfBoundsException( sprintf(OutOfBoundsException::INVALID_LINK_TYPE_INDEX_STR, $index, $type), OutOfBoundsException::INVALID_LINK_TYPE_INDEX ); } return $links[$index]; }
[ "protected", "function", "getLinkIndex", "(", "array", "$", "links", ",", "$", "type", ",", "$", "index", ")", "{", "// If the link index is out of bounds", "if", "(", "!", "is_int", "(", "$", "index", ")", "||", "!", "array_key_exists", "(", "$", "index", ",", "$", "links", ")", ")", "{", "throw", "new", "OutOfBoundsException", "(", "sprintf", "(", "OutOfBoundsException", "::", "INVALID_LINK_TYPE_INDEX_STR", ",", "$", "index", ",", "$", "type", ")", ",", "OutOfBoundsException", "::", "INVALID_LINK_TYPE_INDEX", ")", ";", "}", "return", "$", "links", "[", "$", "index", "]", ";", "}" ]
Return a particular link item by index @param ItemInterface[] $links Link items @param string|null $type Link type @param int $index Link item index @return ItemInterface Link item @throws OutOfBoundsException If the link index is out of bounds
[ "Return", "a", "particular", "link", "item", "by", "index" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Ports/Item/ItemObjectModel.php#L122-L133
31,063
jkphl/micrometa
src/Micrometa/Infrastructure/Logger/ExceptionLogger.php
ExceptionLogger.addRecord
public function addRecord($level, $message, array $context = []) { if ($this->isTriggered($level)) { throw $this->getContextException($context) ?: new RuntimeException($message, $level); } return parent::addRecord($level, $message, $context); }
php
public function addRecord($level, $message, array $context = []) { if ($this->isTriggered($level)) { throw $this->getContextException($context) ?: new RuntimeException($message, $level); } return parent::addRecord($level, $message, $context); }
[ "public", "function", "addRecord", "(", "$", "level", ",", "$", "message", ",", "array", "$", "context", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "isTriggered", "(", "$", "level", ")", ")", "{", "throw", "$", "this", "->", "getContextException", "(", "$", "context", ")", "?", ":", "new", "RuntimeException", "(", "$", "message", ",", "$", "level", ")", ";", "}", "return", "parent", "::", "addRecord", "(", "$", "level", ",", "$", "message", ",", "$", "context", ")", ";", "}" ]
Throws an exception for all messages with error level or higher @param mixed $level The log level @param string $message The log message @param array $context The log context @return Boolean Whether the record has been processed @throws \Exception Exception that occured @throws \RuntimeException Log message as exception
[ "Throws", "an", "exception", "for", "all", "messages", "with", "error", "level", "or", "higher" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Infrastructure/Logger/ExceptionLogger.php#L78-L85
31,064
jkphl/micrometa
src/Micrometa/Domain/Item/Item.php
Item.getProperty
public function getProperty($name, $profile = null) { $iri = IriFactory::create( (($profile === null) || is_object($name)) ? $name : (object)[ 'profile' => $profile, 'name' => $name ] ); return $this->properties->offsetGet($iri); }
php
public function getProperty($name, $profile = null) { $iri = IriFactory::create( (($profile === null) || is_object($name)) ? $name : (object)[ 'profile' => $profile, 'name' => $name ] ); return $this->properties->offsetGet($iri); }
[ "public", "function", "getProperty", "(", "$", "name", ",", "$", "profile", "=", "null", ")", "{", "$", "iri", "=", "IriFactory", "::", "create", "(", "(", "(", "$", "profile", "===", "null", ")", "||", "is_object", "(", "$", "name", ")", ")", "?", "$", "name", ":", "(", "object", ")", "[", "'profile'", "=>", "$", "profile", ",", "'name'", "=>", "$", "name", "]", ")", ";", "return", "$", "this", "->", "properties", "->", "offsetGet", "(", "$", "iri", ")", ";", "}" ]
Return the values of a particular property @param string|\stdClass|Iri $name Property name @param string|null $profile Property profile @return array Item property values
[ "Return", "the", "values", "of", "a", "particular", "property" ]
eb7d5159a7f43b352d13b370a4269c17e1a23d3e
https://github.com/jkphl/micrometa/blob/eb7d5159a7f43b352d13b370a4269c17e1a23d3e/src/Micrometa/Domain/Item/Item.php#L129-L141
31,065
wikimedia/slimapp
src/Mailer.php
Mailer.createMailer
protected function createMailer( $settings = null ) { $settings = is_array( $settings ) ? $settings : []; $mailer = new PHPMailer( true ); foreach ( array_merge( $this->settings, $settings ) as $key => $value ) { $mailer->set( $key, $value ); } return $mailer; }
php
protected function createMailer( $settings = null ) { $settings = is_array( $settings ) ? $settings : []; $mailer = new PHPMailer( true ); foreach ( array_merge( $this->settings, $settings ) as $key => $value ) { $mailer->set( $key, $value ); } return $mailer; }
[ "protected", "function", "createMailer", "(", "$", "settings", "=", "null", ")", "{", "$", "settings", "=", "is_array", "(", "$", "settings", ")", "?", "$", "settings", ":", "[", "]", ";", "$", "mailer", "=", "new", "PHPMailer", "(", "true", ")", ";", "foreach", "(", "array_merge", "(", "$", "this", "->", "settings", ",", "$", "settings", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "mailer", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "return", "$", "mailer", ";", "}" ]
Create and configure a PHPMailer instance. @param array $settings Configuration settings @return PHPMailer New mailer configured with default, instance and local settings
[ "Create", "and", "configure", "a", "PHPMailer", "instance", "." ]
9fd0deba96f635c96d28d59d1f761283f62842d4
https://github.com/wikimedia/slimapp/blob/9fd0deba96f635c96d28d59d1f761283f62842d4/src/Mailer.php#L98-L105
31,066
cedx/yii2-mustache
lib/Loader.php
Loader.load
function load($name): string { if (!isset($this->views[$name])) { $cacheKey = [__CLASS__, $name]; $viewRenderer = $this->viewRenderer; /** @var \yii\caching\Cache $cache */ $cache = $viewRenderer->cache; if ($viewRenderer->enableCaching && $cache->exists($cacheKey)) $output = $cache->get($cacheKey); else { $path = FileHelper::localize($this->findViewFile($name)); if (!is_file($path)) throw new InvalidCallException("The view file '$path' does not exist."); $output = @file_get_contents($path); if ($viewRenderer->enableCaching) $cache->set($cacheKey, $output, $viewRenderer->cachingDuration); } $this->views[$name] = $output; } return $this->views[$name]; }
php
function load($name): string { if (!isset($this->views[$name])) { $cacheKey = [__CLASS__, $name]; $viewRenderer = $this->viewRenderer; /** @var \yii\caching\Cache $cache */ $cache = $viewRenderer->cache; if ($viewRenderer->enableCaching && $cache->exists($cacheKey)) $output = $cache->get($cacheKey); else { $path = FileHelper::localize($this->findViewFile($name)); if (!is_file($path)) throw new InvalidCallException("The view file '$path' does not exist."); $output = @file_get_contents($path); if ($viewRenderer->enableCaching) $cache->set($cacheKey, $output, $viewRenderer->cachingDuration); } $this->views[$name] = $output; } return $this->views[$name]; }
[ "function", "load", "(", "$", "name", ")", ":", "string", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "views", "[", "$", "name", "]", ")", ")", "{", "$", "cacheKey", "=", "[", "__CLASS__", ",", "$", "name", "]", ";", "$", "viewRenderer", "=", "$", "this", "->", "viewRenderer", ";", "/** @var \\yii\\caching\\Cache $cache */", "$", "cache", "=", "$", "viewRenderer", "->", "cache", ";", "if", "(", "$", "viewRenderer", "->", "enableCaching", "&&", "$", "cache", "->", "exists", "(", "$", "cacheKey", ")", ")", "$", "output", "=", "$", "cache", "->", "get", "(", "$", "cacheKey", ")", ";", "else", "{", "$", "path", "=", "FileHelper", "::", "localize", "(", "$", "this", "->", "findViewFile", "(", "$", "name", ")", ")", ";", "if", "(", "!", "is_file", "(", "$", "path", ")", ")", "throw", "new", "InvalidCallException", "(", "\"The view file '$path' does not exist.\"", ")", ";", "$", "output", "=", "@", "file_get_contents", "(", "$", "path", ")", ";", "if", "(", "$", "viewRenderer", "->", "enableCaching", ")", "$", "cache", "->", "set", "(", "$", "cacheKey", ",", "$", "output", ",", "$", "viewRenderer", "->", "cachingDuration", ")", ";", "}", "$", "this", "->", "views", "[", "$", "name", "]", "=", "$", "output", ";", "}", "return", "$", "this", "->", "views", "[", "$", "name", "]", ";", "}" ]
Loads the view with the specified name. @param string $name The view name. @return string The view contents. @throws InvalidCallException Unable to locate the view file.
[ "Loads", "the", "view", "with", "the", "specified", "name", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/Loader.php#L31-L52
31,067
cedx/yii2-mustache
lib/Loader.php
Loader.findViewFile
protected function findViewFile(string $name): string { if (!mb_strlen($name)) throw new InvalidArgumentException('The view name is empty.'); $controller = \Yii::$app->controller; if (mb_substr($name, 0, 2) == '//') $file = \Yii::$app->viewPath.DIRECTORY_SEPARATOR.ltrim($name, '/'); else if ($name[0] == '/') { if (!$controller) throw new InvalidCallException("Unable to locate the view '$name': no active controller."); $file = $controller->module->viewPath.DIRECTORY_SEPARATOR.ltrim($name, '/'); } else { $viewPath = $controller ? $controller->viewPath : \Yii::$app->viewPath; $file = \Yii::getAlias("$viewPath/$name"); } $view = \Yii::$app->view; if ($view && $view->theme) $file = $view->theme->applyTo($file); if (!mb_strlen(pathinfo($file, PATHINFO_EXTENSION))) $file .= '.'.($view ? $view->defaultExtension : 'mustache'); return $file; }
php
protected function findViewFile(string $name): string { if (!mb_strlen($name)) throw new InvalidArgumentException('The view name is empty.'); $controller = \Yii::$app->controller; if (mb_substr($name, 0, 2) == '//') $file = \Yii::$app->viewPath.DIRECTORY_SEPARATOR.ltrim($name, '/'); else if ($name[0] == '/') { if (!$controller) throw new InvalidCallException("Unable to locate the view '$name': no active controller."); $file = $controller->module->viewPath.DIRECTORY_SEPARATOR.ltrim($name, '/'); } else { $viewPath = $controller ? $controller->viewPath : \Yii::$app->viewPath; $file = \Yii::getAlias("$viewPath/$name"); } $view = \Yii::$app->view; if ($view && $view->theme) $file = $view->theme->applyTo($file); if (!mb_strlen(pathinfo($file, PATHINFO_EXTENSION))) $file .= '.'.($view ? $view->defaultExtension : 'mustache'); return $file; }
[ "protected", "function", "findViewFile", "(", "string", "$", "name", ")", ":", "string", "{", "if", "(", "!", "mb_strlen", "(", "$", "name", ")", ")", "throw", "new", "InvalidArgumentException", "(", "'The view name is empty.'", ")", ";", "$", "controller", "=", "\\", "Yii", "::", "$", "app", "->", "controller", ";", "if", "(", "mb_substr", "(", "$", "name", ",", "0", ",", "2", ")", "==", "'//'", ")", "$", "file", "=", "\\", "Yii", "::", "$", "app", "->", "viewPath", ".", "DIRECTORY_SEPARATOR", ".", "ltrim", "(", "$", "name", ",", "'/'", ")", ";", "else", "if", "(", "$", "name", "[", "0", "]", "==", "'/'", ")", "{", "if", "(", "!", "$", "controller", ")", "throw", "new", "InvalidCallException", "(", "\"Unable to locate the view '$name': no active controller.\"", ")", ";", "$", "file", "=", "$", "controller", "->", "module", "->", "viewPath", ".", "DIRECTORY_SEPARATOR", ".", "ltrim", "(", "$", "name", ",", "'/'", ")", ";", "}", "else", "{", "$", "viewPath", "=", "$", "controller", "?", "$", "controller", "->", "viewPath", ":", "\\", "Yii", "::", "$", "app", "->", "viewPath", ";", "$", "file", "=", "\\", "Yii", "::", "getAlias", "(", "\"$viewPath/$name\"", ")", ";", "}", "$", "view", "=", "\\", "Yii", "::", "$", "app", "->", "view", ";", "if", "(", "$", "view", "&&", "$", "view", "->", "theme", ")", "$", "file", "=", "$", "view", "->", "theme", "->", "applyTo", "(", "$", "file", ")", ";", "if", "(", "!", "mb_strlen", "(", "pathinfo", "(", "$", "file", ",", "PATHINFO_EXTENSION", ")", ")", ")", "$", "file", ".=", "'.'", ".", "(", "$", "view", "?", "$", "view", "->", "defaultExtension", ":", "'mustache'", ")", ";", "return", "$", "file", ";", "}" ]
Finds the view file based on the given view name. @param string $name The view name. @return string The view file path. @throws \BadMethodCallException Unable to locate the view file.
[ "Finds", "the", "view", "file", "based", "on", "the", "given", "view", "name", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/Loader.php#L60-L79
31,068
pulsarvp/vps-tools
src/log/LogstashTarget.php
LogstashTarget.parseText
private function parseText ($text) { $type = gettype($text); switch ($type) { case 'array': return $text; case 'string': return [ '@message' => $text ]; case 'object': return get_object_vars($text); default: return [ '@message' => \Yii::t('log', "Warning, wrong log message type '{$type}'") ]; } }
php
private function parseText ($text) { $type = gettype($text); switch ($type) { case 'array': return $text; case 'string': return [ '@message' => $text ]; case 'object': return get_object_vars($text); default: return [ '@message' => \Yii::t('log', "Warning, wrong log message type '{$type}'") ]; } }
[ "private", "function", "parseText", "(", "$", "text", ")", "{", "$", "type", "=", "gettype", "(", "$", "text", ")", ";", "switch", "(", "$", "type", ")", "{", "case", "'array'", ":", "return", "$", "text", ";", "case", "'string'", ":", "return", "[", "'@message'", "=>", "$", "text", "]", ";", "case", "'object'", ":", "return", "get_object_vars", "(", "$", "text", ")", ";", "default", ":", "return", "[", "'@message'", "=>", "\\", "Yii", "::", "t", "(", "'log'", ",", "\"Warning, wrong log message type '{$type}'\"", ")", "]", ";", "}", "}" ]
Convert's any type of log message to array. @param mixed $text Input log message. @return array
[ "Convert", "s", "any", "type", "of", "log", "message", "to", "array", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/log/LogstashTarget.php#L94-L108
31,069
cedx/yii2-mustache
lib/Cache.php
Cache.cache
function cache($key, $value): void { $viewRenderer = $this->viewRenderer; if (!$viewRenderer->enableCaching) eval("?>$value"); else { /** @var \yii\caching\Cache $cache */ $cache = $viewRenderer->cache; $cache->set([__CLASS__, $key], $value, $viewRenderer->cachingDuration); $this->load($key); } }
php
function cache($key, $value): void { $viewRenderer = $this->viewRenderer; if (!$viewRenderer->enableCaching) eval("?>$value"); else { /** @var \yii\caching\Cache $cache */ $cache = $viewRenderer->cache; $cache->set([__CLASS__, $key], $value, $viewRenderer->cachingDuration); $this->load($key); } }
[ "function", "cache", "(", "$", "key", ",", "$", "value", ")", ":", "void", "{", "$", "viewRenderer", "=", "$", "this", "->", "viewRenderer", ";", "if", "(", "!", "$", "viewRenderer", "->", "enableCaching", ")", "eval", "(", "\"?>$value\"", ")", ";", "else", "{", "/** @var \\yii\\caching\\Cache $cache */", "$", "cache", "=", "$", "viewRenderer", "->", "cache", ";", "$", "cache", "->", "set", "(", "[", "__CLASS__", ",", "$", "key", "]", ",", "$", "value", ",", "$", "viewRenderer", "->", "cachingDuration", ")", ";", "$", "this", "->", "load", "(", "$", "key", ")", ";", "}", "}" ]
Caches and loads a compiled view. @param string $key The key identifying the view to be cached. @param string $value The view to be cached.
[ "Caches", "and", "loads", "a", "compiled", "view", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/Cache.php#L17-L26
31,070
cedx/yii2-mustache
lib/Cache.php
Cache.load
function load($key): bool { $cacheKey = [__CLASS__, $key]; $viewRenderer = $this->viewRenderer; /** @var \yii\caching\Cache $cache */ $cache = $viewRenderer->cache; if (!$viewRenderer->enableCaching || !$cache->exists($cacheKey)) return false; eval("?>{$cache->get($cacheKey)}"); return true; }
php
function load($key): bool { $cacheKey = [__CLASS__, $key]; $viewRenderer = $this->viewRenderer; /** @var \yii\caching\Cache $cache */ $cache = $viewRenderer->cache; if (!$viewRenderer->enableCaching || !$cache->exists($cacheKey)) return false; eval("?>{$cache->get($cacheKey)}"); return true; }
[ "function", "load", "(", "$", "key", ")", ":", "bool", "{", "$", "cacheKey", "=", "[", "__CLASS__", ",", "$", "key", "]", ";", "$", "viewRenderer", "=", "$", "this", "->", "viewRenderer", ";", "/** @var \\yii\\caching\\Cache $cache */", "$", "cache", "=", "$", "viewRenderer", "->", "cache", ";", "if", "(", "!", "$", "viewRenderer", "->", "enableCaching", "||", "!", "$", "cache", "->", "exists", "(", "$", "cacheKey", ")", ")", "return", "false", ";", "eval", "(", "\"?>{$cache->get($cacheKey)}\"", ")", ";", "return", "true", ";", "}" ]
Loads a compiled view from cache. @param string $key The key identifying the view to be loaded. @return bool `true` if the view was successfully loaded, otherwise `false`.
[ "Loads", "a", "compiled", "view", "from", "cache", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/Cache.php#L42-L52
31,071
pulsarvp/vps-tools
src/net/CurlResponse.php
CurlResponse.getHeader
public function getHeader ($name) { if (is_array($this->_headers)) { foreach ($this->_headers as $header) { $data = explode(': ', $header); if (count($data) == 2 and $data[ 0 ] == $name) return $data[ 1 ]; } } return null; }
php
public function getHeader ($name) { if (is_array($this->_headers)) { foreach ($this->_headers as $header) { $data = explode(': ', $header); if (count($data) == 2 and $data[ 0 ] == $name) return $data[ 1 ]; } } return null; }
[ "public", "function", "getHeader", "(", "$", "name", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "_headers", ")", ")", "{", "foreach", "(", "$", "this", "->", "_headers", "as", "$", "header", ")", "{", "$", "data", "=", "explode", "(", "': '", ",", "$", "header", ")", ";", "if", "(", "count", "(", "$", "data", ")", "==", "2", "and", "$", "data", "[", "0", "]", "==", "$", "name", ")", "return", "$", "data", "[", "1", "]", ";", "}", "}", "return", "null", ";", "}" ]
Finds header by its name. @param $name @return null
[ "Finds", "header", "by", "its", "name", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/net/CurlResponse.php#L64-L77
31,072
pulsarvp/vps-tools
src/net/CurlResponse.php
CurlResponse.getStatus
public function getStatus () { if (!$this->_status) { $this->_status = self::S_UNKNOWN; $headers = array_reverse($this->_headers); foreach ($headers as $header) { preg_match("/HTTP\/1.1 (\d{3})/", $header, $match); if (isset($match[ 1 ])) { $this->_status = (int) $match[ 1 ]; break; } } } return $this->_status; }
php
public function getStatus () { if (!$this->_status) { $this->_status = self::S_UNKNOWN; $headers = array_reverse($this->_headers); foreach ($headers as $header) { preg_match("/HTTP\/1.1 (\d{3})/", $header, $match); if (isset($match[ 1 ])) { $this->_status = (int) $match[ 1 ]; break; } } } return $this->_status; }
[ "public", "function", "getStatus", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_status", ")", "{", "$", "this", "->", "_status", "=", "self", "::", "S_UNKNOWN", ";", "$", "headers", "=", "array_reverse", "(", "$", "this", "->", "_headers", ")", ";", "foreach", "(", "$", "headers", "as", "$", "header", ")", "{", "preg_match", "(", "\"/HTTP\\/1.1 (\\d{3})/\"", ",", "$", "header", ",", "$", "match", ")", ";", "if", "(", "isset", "(", "$", "match", "[", "1", "]", ")", ")", "{", "$", "this", "->", "_status", "=", "(", "int", ")", "$", "match", "[", "1", "]", ";", "break", ";", "}", "}", "}", "return", "$", "this", "->", "_status", ";", "}" ]
Returns response status. @return int
[ "Returns", "response", "status", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/net/CurlResponse.php#L94-L113
31,073
pulsarvp/vps-tools
src/net/CurlResponse.php
CurlResponse.fromCurl
public function fromCurl ($response, $curl) { $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); $this->_body = substr($response, $headerSize); $headers = substr($response, 0, $headerSize); $headers = str_replace("\r", "", $headers); $headers = str_replace("\n\n", "\n", $headers); $headers = trim($headers, "\n"); $this->_headers = explode("\n", $headers); return $this; }
php
public function fromCurl ($response, $curl) { $headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE); $this->_body = substr($response, $headerSize); $headers = substr($response, 0, $headerSize); $headers = str_replace("\r", "", $headers); $headers = str_replace("\n\n", "\n", $headers); $headers = trim($headers, "\n"); $this->_headers = explode("\n", $headers); return $this; }
[ "public", "function", "fromCurl", "(", "$", "response", ",", "$", "curl", ")", "{", "$", "headerSize", "=", "curl_getinfo", "(", "$", "curl", ",", "CURLINFO_HEADER_SIZE", ")", ";", "$", "this", "->", "_body", "=", "substr", "(", "$", "response", ",", "$", "headerSize", ")", ";", "$", "headers", "=", "substr", "(", "$", "response", ",", "0", ",", "$", "headerSize", ")", ";", "$", "headers", "=", "str_replace", "(", "\"\\r\"", ",", "\"\"", ",", "$", "headers", ")", ";", "$", "headers", "=", "str_replace", "(", "\"\\n\\n\"", ",", "\"\\n\"", ",", "$", "headers", ")", ";", "$", "headers", "=", "trim", "(", "$", "headers", ",", "\"\\n\"", ")", ";", "$", "this", "->", "_headers", "=", "explode", "(", "\"\\n\"", ",", "$", "headers", ")", ";", "return", "$", "this", ";", "}" ]
Parse response from cURL response. Sets body and headers. @param $response @param $curl @return CurlResponse
[ "Parse", "response", "from", "cURL", "response", ".", "Sets", "body", "and", "headers", "." ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/net/CurlResponse.php#L123-L135
31,074
radig/auditable
Model/Behavior/AuditableBehavior.php
AuditableBehavior.setup
public function setup(Model $Model, $config = array()) { if (!is_array($config) || isset($config[0])) { $config = $this->defaults; } if (isset($config['priority'])) { unset($config['priority']); } $this->settings[$Model->alias] = array_merge($this->defaults, $config); if ($this->settings[$Model->alias]['auditSql']) { $this->QueryLogSource->enable($Model); } }
php
public function setup(Model $Model, $config = array()) { if (!is_array($config) || isset($config[0])) { $config = $this->defaults; } if (isset($config['priority'])) { unset($config['priority']); } $this->settings[$Model->alias] = array_merge($this->defaults, $config); if ($this->settings[$Model->alias]['auditSql']) { $this->QueryLogSource->enable($Model); } }
[ "public", "function", "setup", "(", "Model", "$", "Model", ",", "$", "config", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_array", "(", "$", "config", ")", "||", "isset", "(", "$", "config", "[", "0", "]", ")", ")", "{", "$", "config", "=", "$", "this", "->", "defaults", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'priority'", "]", ")", ")", "{", "unset", "(", "$", "config", "[", "'priority'", "]", ")", ";", "}", "$", "this", "->", "settings", "[", "$", "Model", "->", "alias", "]", "=", "array_merge", "(", "$", "this", "->", "defaults", ",", "$", "config", ")", ";", "if", "(", "$", "this", "->", "settings", "[", "$", "Model", "->", "alias", "]", "[", "'auditSql'", "]", ")", "{", "$", "this", "->", "QueryLogSource", "->", "enable", "(", "$", "Model", ")", ";", "}", "}" ]
Chamado pelo CakePHP para iniciar o behavior @param Model $Model @param array $config Opções de configurações: auditSql : bool. Habilita ou não o log das queries skip : array. Lista com nome das ações que devem ser ignoradas pelo log. fields : array. Aceita os dois índices abaixo - created : string. Nome do campo presente em cada modelo para armazenar quem criou o registro - modified : string. Nome do campo presente em cada modelo para armazenar quem alterou o registro
[ "Chamado", "pelo", "CakePHP", "para", "iniciar", "o", "behavior" ]
af8b5031522ebd6d69daa0e694a65c1cb2935b48
https://github.com/radig/auditable/blob/af8b5031522ebd6d69daa0e694a65c1cb2935b48/Model/Behavior/AuditableBehavior.php#L126-L141
31,075
cedx/yii2-mustache
lib/helpers/Format.php
Format.getBoolean
function getBoolean(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { return HtmlHelper::encode(\Yii::$app->formatter->asBoolean($helper->render($value))); }; }
php
function getBoolean(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { return HtmlHelper::encode(\Yii::$app->formatter->asBoolean($helper->render($value))); }; }
[ "function", "getBoolean", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "return", "HtmlHelper", "::", "encode", "(", "\\", "Yii", "::", "$", "app", "->", "formatter", "->", "asBoolean", "(", "$", "helper", "->", "render", "(", "$", "value", ")", ")", ")", ";", "}", ";", "}" ]
Returns a helper function formatting a value as boolean. @return \Closure A function formatting a value as boolean.
[ "Returns", "a", "helper", "function", "formatting", "a", "value", "as", "boolean", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Format.php#L25-L29
31,076
cedx/yii2-mustache
lib/helpers/Format.php
Format.getCurrency
function getCurrency(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', [ 'currency' => null, 'options' => [], 'textOptions' => [] ]); return HtmlHelper::encode(\Yii::$app->formatter->asCurrency( $args['value'], $args['currency'], $args['options'], $args['textOptions'] )); }; }
php
function getCurrency(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', [ 'currency' => null, 'options' => [], 'textOptions' => [] ]); return HtmlHelper::encode(\Yii::$app->formatter->asCurrency( $args['value'], $args['currency'], $args['options'], $args['textOptions'] )); }; }
[ "function", "getCurrency", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", "render", "(", "$", "value", ")", ",", "'value'", ",", "[", "'currency'", "=>", "null", ",", "'options'", "=>", "[", "]", ",", "'textOptions'", "=>", "[", "]", "]", ")", ";", "return", "HtmlHelper", "::", "encode", "(", "\\", "Yii", "::", "$", "app", "->", "formatter", "->", "asCurrency", "(", "$", "args", "[", "'value'", "]", ",", "$", "args", "[", "'currency'", "]", ",", "$", "args", "[", "'options'", "]", ",", "$", "args", "[", "'textOptions'", "]", ")", ")", ";", "}", ";", "}" ]
Returns a helper function formatting a value as currency number. @return \Closure A function formatting a value as currency number.
[ "Returns", "a", "helper", "function", "formatting", "a", "value", "as", "currency", "number", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Format.php#L35-L50
31,077
cedx/yii2-mustache
lib/helpers/Format.php
Format.getDate
function getDate(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', ['format' => null]); return HtmlHelper::encode(\Yii::$app->formatter->asDate($args['value'], $args['format'])); }; }
php
function getDate(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', ['format' => null]); return HtmlHelper::encode(\Yii::$app->formatter->asDate($args['value'], $args['format'])); }; }
[ "function", "getDate", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", "render", "(", "$", "value", ")", ",", "'value'", ",", "[", "'format'", "=>", "null", "]", ")", ";", "return", "HtmlHelper", "::", "encode", "(", "\\", "Yii", "::", "$", "app", "->", "formatter", "->", "asDate", "(", "$", "args", "[", "'value'", "]", ",", "$", "args", "[", "'format'", "]", ")", ")", ";", "}", ";", "}" ]
Returns a helper function formatting a value as date. @return \Closure A function formatting a value as date.
[ "Returns", "a", "helper", "function", "formatting", "a", "value", "as", "date", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Format.php#L56-L61
31,078
cedx/yii2-mustache
lib/helpers/Format.php
Format.getDateTime
function getDateTime(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', ['format' => null]); return HtmlHelper::encode(\Yii::$app->formatter->asDatetime($args['value'], $args['format'])); }; }
php
function getDateTime(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', ['format' => null]); return HtmlHelper::encode(\Yii::$app->formatter->asDatetime($args['value'], $args['format'])); }; }
[ "function", "getDateTime", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", "render", "(", "$", "value", ")", ",", "'value'", ",", "[", "'format'", "=>", "null", "]", ")", ";", "return", "HtmlHelper", "::", "encode", "(", "\\", "Yii", "::", "$", "app", "->", "formatter", "->", "asDatetime", "(", "$", "args", "[", "'value'", "]", ",", "$", "args", "[", "'format'", "]", ")", ")", ";", "}", ";", "}" ]
Returns a helper function formatting a value as datetime. @return \Closure A function formatting a value as datetime.
[ "Returns", "a", "helper", "function", "formatting", "a", "value", "as", "datetime", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Format.php#L67-L72
31,079
cedx/yii2-mustache
lib/helpers/Format.php
Format.getDecimal
function getDecimal(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', [ 'decimals' => null, 'options' => [], 'textOptions' => [] ]); return HtmlHelper::encode(\Yii::$app->formatter->asDecimal( $args['value'], $args['decimals'], $args['options'], $args['textOptions'] )); }; }
php
function getDecimal(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', [ 'decimals' => null, 'options' => [], 'textOptions' => [] ]); return HtmlHelper::encode(\Yii::$app->formatter->asDecimal( $args['value'], $args['decimals'], $args['options'], $args['textOptions'] )); }; }
[ "function", "getDecimal", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", "render", "(", "$", "value", ")", ",", "'value'", ",", "[", "'decimals'", "=>", "null", ",", "'options'", "=>", "[", "]", ",", "'textOptions'", "=>", "[", "]", "]", ")", ";", "return", "HtmlHelper", "::", "encode", "(", "\\", "Yii", "::", "$", "app", "->", "formatter", "->", "asDecimal", "(", "$", "args", "[", "'value'", "]", ",", "$", "args", "[", "'decimals'", "]", ",", "$", "args", "[", "'options'", "]", ",", "$", "args", "[", "'textOptions'", "]", ")", ")", ";", "}", ";", "}" ]
Returns a helper function formatting a value as decimal number. @return \Closure A function formatting a value as decimal number.
[ "Returns", "a", "helper", "function", "formatting", "a", "value", "as", "decimal", "number", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Format.php#L78-L93
31,080
cedx/yii2-mustache
lib/helpers/Format.php
Format.getInteger
function getInteger(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', [ 'options' => [], 'textOptions' => [] ]); return HtmlHelper::encode(\Yii::$app->formatter->asInteger( $args['value'], $args['options'], $args['textOptions'] )); }; }
php
function getInteger(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', [ 'options' => [], 'textOptions' => [] ]); return HtmlHelper::encode(\Yii::$app->formatter->asInteger( $args['value'], $args['options'], $args['textOptions'] )); }; }
[ "function", "getInteger", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", "render", "(", "$", "value", ")", ",", "'value'", ",", "[", "'options'", "=>", "[", "]", ",", "'textOptions'", "=>", "[", "]", "]", ")", ";", "return", "HtmlHelper", "::", "encode", "(", "\\", "Yii", "::", "$", "app", "->", "formatter", "->", "asInteger", "(", "$", "args", "[", "'value'", "]", ",", "$", "args", "[", "'options'", "]", ",", "$", "args", "[", "'textOptions'", "]", ")", ")", ";", "}", ";", "}" ]
Returns a helper function formatting a value as integer number by removing any decimal digits without rounding. @return \Closure A function formatting a value as integer number without rounding.
[ "Returns", "a", "helper", "function", "formatting", "a", "value", "as", "integer", "number", "by", "removing", "any", "decimal", "digits", "without", "rounding", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Format.php#L99-L112
31,081
cedx/yii2-mustache
lib/helpers/Format.php
Format.getNtext
function getNtext(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { if (!isset($value)) return \Yii::$app->formatter->nullDisplay; return preg_replace('/\r?\n/', '<br>', HtmlHelper::encode($helper->render($value))); }; }
php
function getNtext(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { if (!isset($value)) return \Yii::$app->formatter->nullDisplay; return preg_replace('/\r?\n/', '<br>', HtmlHelper::encode($helper->render($value))); }; }
[ "function", "getNtext", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "if", "(", "!", "isset", "(", "$", "value", ")", ")", "return", "\\", "Yii", "::", "$", "app", "->", "formatter", "->", "nullDisplay", ";", "return", "preg_replace", "(", "'/\\r?\\n/'", ",", "'<br>'", ",", "HtmlHelper", "::", "encode", "(", "$", "helper", "->", "render", "(", "$", "value", ")", ")", ")", ";", "}", ";", "}" ]
Returns a helper function formatting a value as HTML-encoded plain text with newlines converted into breaks. @return \Closure A function formatting a value as HTML-encoded text with newlines converted into breaks.
[ "Returns", "a", "helper", "function", "formatting", "a", "value", "as", "HTML", "-", "encoded", "plain", "text", "with", "newlines", "converted", "into", "breaks", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Format.php#L118-L123
31,082
cedx/yii2-mustache
lib/helpers/Format.php
Format.getPercent
function getPercent(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', [ 'decimals' => null, 'options' => [], 'textOptions' => [] ]); return HtmlHelper::encode(\Yii::$app->formatter->asPercent( $args['value'], $args['decimals'], $args['options'], $args['textOptions'] )); }; }
php
function getPercent(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', [ 'decimals' => null, 'options' => [], 'textOptions' => [] ]); return HtmlHelper::encode(\Yii::$app->formatter->asPercent( $args['value'], $args['decimals'], $args['options'], $args['textOptions'] )); }; }
[ "function", "getPercent", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", "render", "(", "$", "value", ")", ",", "'value'", ",", "[", "'decimals'", "=>", "null", ",", "'options'", "=>", "[", "]", ",", "'textOptions'", "=>", "[", "]", "]", ")", ";", "return", "HtmlHelper", "::", "encode", "(", "\\", "Yii", "::", "$", "app", "->", "formatter", "->", "asPercent", "(", "$", "args", "[", "'value'", "]", ",", "$", "args", "[", "'decimals'", "]", ",", "$", "args", "[", "'options'", "]", ",", "$", "args", "[", "'textOptions'", "]", ")", ")", ";", "}", ";", "}" ]
Returns a helper function formatting a value as percent number with `%` sign. @return \Closure A function formatting a value as percent number.
[ "Returns", "a", "helper", "function", "formatting", "a", "value", "as", "percent", "number", "with", "%", "sign", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Format.php#L129-L144
31,083
cedx/yii2-mustache
lib/helpers/Format.php
Format.getTime
function getTime(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', ['format' => null]); return HtmlHelper::encode(\Yii::$app->formatter->asTime($args['value'], $args['format'])); }; }
php
function getTime(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $args = $this->parseArguments($helper->render($value), 'value', ['format' => null]); return HtmlHelper::encode(\Yii::$app->formatter->asTime($args['value'], $args['format'])); }; }
[ "function", "getTime", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", "render", "(", "$", "value", ")", ",", "'value'", ",", "[", "'format'", "=>", "null", "]", ")", ";", "return", "HtmlHelper", "::", "encode", "(", "\\", "Yii", "::", "$", "app", "->", "formatter", "->", "asTime", "(", "$", "args", "[", "'value'", "]", ",", "$", "args", "[", "'format'", "]", ")", ")", ";", "}", ";", "}" ]
Returns a helper function formatting a value as time. @return \Closure A function formatting a value as time.
[ "Returns", "a", "helper", "function", "formatting", "a", "value", "as", "time", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/Format.php#L150-L155
31,084
wikimedia/slimapp
src/HeaderMiddleware.php
HeaderMiddleware.call
public function call() { $resp = $this->app->response; foreach ( $this->headers as $name => $value ) { if ( is_callable( $value ) ) { $value = $value( $this->app ); } if ( $value !== null ) { $resp->header( $name, $value ); } } $this->next->call(); }
php
public function call() { $resp = $this->app->response; foreach ( $this->headers as $name => $value ) { if ( is_callable( $value ) ) { $value = $value( $this->app ); } if ( $value !== null ) { $resp->header( $name, $value ); } } $this->next->call(); }
[ "public", "function", "call", "(", ")", "{", "$", "resp", "=", "$", "this", "->", "app", "->", "response", ";", "foreach", "(", "$", "this", "->", "headers", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "is_callable", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "value", "(", "$", "this", "->", "app", ")", ";", "}", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "resp", "->", "header", "(", "$", "name", ",", "$", "value", ")", ";", "}", "}", "$", "this", "->", "next", "->", "call", "(", ")", ";", "}" ]
Add configured headers to response.
[ "Add", "configured", "headers", "to", "response", "." ]
9fd0deba96f635c96d28d59d1f761283f62842d4
https://github.com/wikimedia/slimapp/blob/9fd0deba96f635c96d28d59d1f761283f62842d4/src/HeaderMiddleware.php#L55-L68
31,085
bearcms/bearframework-addon
classes/BearCMS/Internal/Data2/Comments.php
Comments.getList
public function getList() { $list = Internal\Data::getList('bearcms/comments/thread/'); $result = new \IvoPetkov\DataList(); foreach ($list as $value) { $rawData = json_decode($value, true); $tempCollection = Internal\Data\Comments::createCommentsCollection($rawData['comments'], $rawData['id']); foreach ($tempCollection as $dataObject) { $result[] = $dataObject; } } return $result; }
php
public function getList() { $list = Internal\Data::getList('bearcms/comments/thread/'); $result = new \IvoPetkov\DataList(); foreach ($list as $value) { $rawData = json_decode($value, true); $tempCollection = Internal\Data\Comments::createCommentsCollection($rawData['comments'], $rawData['id']); foreach ($tempCollection as $dataObject) { $result[] = $dataObject; } } return $result; }
[ "public", "function", "getList", "(", ")", "{", "$", "list", "=", "Internal", "\\", "Data", "::", "getList", "(", "'bearcms/comments/thread/'", ")", ";", "$", "result", "=", "new", "\\", "IvoPetkov", "\\", "DataList", "(", ")", ";", "foreach", "(", "$", "list", "as", "$", "value", ")", "{", "$", "rawData", "=", "json_decode", "(", "$", "value", ",", "true", ")", ";", "$", "tempCollection", "=", "Internal", "\\", "Data", "\\", "Comments", "::", "createCommentsCollection", "(", "$", "rawData", "[", "'comments'", "]", ",", "$", "rawData", "[", "'id'", "]", ")", ";", "foreach", "(", "$", "tempCollection", "as", "$", "dataObject", ")", "{", "$", "result", "[", "]", "=", "$", "dataObject", ";", "}", "}", "return", "$", "result", ";", "}" ]
Retrieves a list of all comments @return \IvoPetkov\DataList|\BearCMS\Internal\Data2\Comment[] List containing all comments data
[ "Retrieves", "a", "list", "of", "all", "comments" ]
7ef131b81aac26070a2b937dd67f530a6caa02f0
https://github.com/bearcms/bearframework-addon/blob/7ef131b81aac26070a2b937dd67f530a6caa02f0/classes/BearCMS/Internal/Data2/Comments.php#L26-L38
31,086
oradwell/covers-validator
src/Handler/InputHandler.php
InputHandler.handleInput
public static function handleInput(InputInterface $input) { $configOption = $input->getOption('configuration'); $configFile = ConfigLocator::locate($configOption); $configuration = ConfigLoader::loadConfig($configFile); $phpunit = $configuration->getPHPUnitConfiguration(); if (null !== $input->getOption('bootstrap')) { $phpunit['bootstrap'] = $input->getOption('bootstrap'); } if (isset($phpunit['bootstrap'])) { FileLoader::loadFile($phpunit['bootstrap']); } return $configuration; }
php
public static function handleInput(InputInterface $input) { $configOption = $input->getOption('configuration'); $configFile = ConfigLocator::locate($configOption); $configuration = ConfigLoader::loadConfig($configFile); $phpunit = $configuration->getPHPUnitConfiguration(); if (null !== $input->getOption('bootstrap')) { $phpunit['bootstrap'] = $input->getOption('bootstrap'); } if (isset($phpunit['bootstrap'])) { FileLoader::loadFile($phpunit['bootstrap']); } return $configuration; }
[ "public", "static", "function", "handleInput", "(", "InputInterface", "$", "input", ")", "{", "$", "configOption", "=", "$", "input", "->", "getOption", "(", "'configuration'", ")", ";", "$", "configFile", "=", "ConfigLocator", "::", "locate", "(", "$", "configOption", ")", ";", "$", "configuration", "=", "ConfigLoader", "::", "loadConfig", "(", "$", "configFile", ")", ";", "$", "phpunit", "=", "$", "configuration", "->", "getPHPUnitConfiguration", "(", ")", ";", "if", "(", "null", "!==", "$", "input", "->", "getOption", "(", "'bootstrap'", ")", ")", "{", "$", "phpunit", "[", "'bootstrap'", "]", "=", "$", "input", "->", "getOption", "(", "'bootstrap'", ")", ";", "}", "if", "(", "isset", "(", "$", "phpunit", "[", "'bootstrap'", "]", ")", ")", "{", "FileLoader", "::", "loadFile", "(", "$", "phpunit", "[", "'bootstrap'", "]", ")", ";", "}", "return", "$", "configuration", ";", "}" ]
Handle console input @param InputInterface $input @return Configuration
[ "Handle", "console", "input" ]
1bc9db0e4846d80ad38b14662b6e48edaa7d289f
https://github.com/oradwell/covers-validator/blob/1bc9db0e4846d80ad38b14662b6e48edaa7d289f/src/Handler/InputHandler.php#L19-L35
31,087
wikimedia/slimapp
src/Auth/AuthManager.php
AuthManager.authenticate
public function authenticate( $uname, $password ) { $user = $this->manager->getUserData( $uname ); $check = Password::comparePasswordToHash( $password, $user->getPassword() ); if ( $check && !$user->isBlocked() ) { $this->login( $user ); return true; } else { return false; } }
php
public function authenticate( $uname, $password ) { $user = $this->manager->getUserData( $uname ); $check = Password::comparePasswordToHash( $password, $user->getPassword() ); if ( $check && !$user->isBlocked() ) { $this->login( $user ); return true; } else { return false; } }
[ "public", "function", "authenticate", "(", "$", "uname", ",", "$", "password", ")", "{", "$", "user", "=", "$", "this", "->", "manager", "->", "getUserData", "(", "$", "uname", ")", ";", "$", "check", "=", "Password", "::", "comparePasswordToHash", "(", "$", "password", ",", "$", "user", "->", "getPassword", "(", ")", ")", ";", "if", "(", "$", "check", "&&", "!", "$", "user", "->", "isBlocked", "(", ")", ")", "{", "$", "this", "->", "login", "(", "$", "user", ")", ";", "return", "true", ";", "}", "else", "{", "return", "false", ";", "}", "}" ]
Attempt to authenticate a user. @param string $uname Username @param string $password Password @return bool True if authentication is successful, false otherwise
[ "Attempt", "to", "authenticate", "a", "user", "." ]
9fd0deba96f635c96d28d59d1f761283f62842d4
https://github.com/wikimedia/slimapp/blob/9fd0deba96f635c96d28d59d1f761283f62842d4/src/Auth/AuthManager.php#L101-L111
31,088
wikimedia/slimapp
src/Auth/AuthManager.php
AuthManager.login
public function login( UserData $user ) { // clear session foreach ( $_SESSION as $key => $value ) { unset( $_SESSION[$key] ); } // generate new session id session_regenerate_id( true ); // store user info in session $this->setUser( $user ); }
php
public function login( UserData $user ) { // clear session foreach ( $_SESSION as $key => $value ) { unset( $_SESSION[$key] ); } // generate new session id session_regenerate_id( true ); // store user info in session $this->setUser( $user ); }
[ "public", "function", "login", "(", "UserData", "$", "user", ")", "{", "// clear session", "foreach", "(", "$", "_SESSION", "as", "$", "key", "=>", "$", "value", ")", "{", "unset", "(", "$", "_SESSION", "[", "$", "key", "]", ")", ";", "}", "// generate new session id", "session_regenerate_id", "(", "true", ")", ";", "// store user info in session", "$", "this", "->", "setUser", "(", "$", "user", ")", ";", "}" ]
Add authentication. @param UserData $user
[ "Add", "authentication", "." ]
9fd0deba96f635c96d28d59d1f761283f62842d4
https://github.com/wikimedia/slimapp/blob/9fd0deba96f635c96d28d59d1f761283f62842d4/src/Auth/AuthManager.php#L118-L129
31,089
wikimedia/slimapp
src/Auth/AuthManager.php
AuthManager.logout
public function logout() { // clear session foreach ( $_SESSION as $key => $value ) { unset( $_SESSION[$key] ); } // delete the session cookie on the client if ( ini_get( 'session.use_cookies' ) ) { $params = session_get_cookie_params(); setcookie( session_name(), '', time() - 42000, $params['path'], $params['domain'], $params['secure'], $params['httponly'] ); } // destroy local session storage session_destroy(); // generate new session id session_regenerate_id( true ); }
php
public function logout() { // clear session foreach ( $_SESSION as $key => $value ) { unset( $_SESSION[$key] ); } // delete the session cookie on the client if ( ini_get( 'session.use_cookies' ) ) { $params = session_get_cookie_params(); setcookie( session_name(), '', time() - 42000, $params['path'], $params['domain'], $params['secure'], $params['httponly'] ); } // destroy local session storage session_destroy(); // generate new session id session_regenerate_id( true ); }
[ "public", "function", "logout", "(", ")", "{", "// clear session", "foreach", "(", "$", "_SESSION", "as", "$", "key", "=>", "$", "value", ")", "{", "unset", "(", "$", "_SESSION", "[", "$", "key", "]", ")", ";", "}", "// delete the session cookie on the client", "if", "(", "ini_get", "(", "'session.use_cookies'", ")", ")", "{", "$", "params", "=", "session_get_cookie_params", "(", ")", ";", "setcookie", "(", "session_name", "(", ")", ",", "''", ",", "time", "(", ")", "-", "42000", ",", "$", "params", "[", "'path'", "]", ",", "$", "params", "[", "'domain'", "]", ",", "$", "params", "[", "'secure'", "]", ",", "$", "params", "[", "'httponly'", "]", ")", ";", "}", "// destroy local session storage", "session_destroy", "(", ")", ";", "// generate new session id", "session_regenerate_id", "(", "true", ")", ";", "}" ]
Remove authentication.
[ "Remove", "authentication", "." ]
9fd0deba96f635c96d28d59d1f761283f62842d4
https://github.com/wikimedia/slimapp/blob/9fd0deba96f635c96d28d59d1f761283f62842d4/src/Auth/AuthManager.php#L134-L153
31,090
EmchBerger/cube-custom-fields-bundle
src/Command/CustomFieldUpdateCommand.php
CustomFieldUpdateCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getContainer()->get('doctrine.orm.entity_manager'); // disable the CustomFieldLinkedEntityListener during the execution of the command (to prevent loops) $listenerInst = null; foreach ($em->getEventManager()->getListeners() as $event => $listeners) { foreach ($listeners as $hash => $listener) { if ($listener instanceof \CubeTools\CubeCustomFieldsBundle\EventListener\CustomFieldLinkedEntityListener) { $listenerInst = $listener; break 2; } } } $evm = $em->getEventManager(); $evm->removeEventListener(array('onFlush'), $listenerInst); // datetime custom fields $datetimeCf = $em->getRepository('CubeCustomFieldsBundle:DatetimeCustomField')->findAll(); $this->updateCfEntities($datetimeCf); $em->flush(); // text custom fields $textCf = $em->getRepository('CubeCustomFieldsBundle:TextCustomField')->findAll(); $this->updateCfEntities($textCf); $em->flush(); // textarea custom fields $textareaCf = $em->getRepository('CubeCustomFieldsBundle:TextareaCustomField')->findAll(); $this->updateCfEntities($textareaCf); $em->flush(); // entity custom fields $entityCf = $em->getRepository('CubeCustomFieldsBundle:EntityCustomField')->findAll(); $this->updateCfEntities($entityCf); $em->flush(); }
php
protected function execute(InputInterface $input, OutputInterface $output) { $em = $this->getContainer()->get('doctrine.orm.entity_manager'); // disable the CustomFieldLinkedEntityListener during the execution of the command (to prevent loops) $listenerInst = null; foreach ($em->getEventManager()->getListeners() as $event => $listeners) { foreach ($listeners as $hash => $listener) { if ($listener instanceof \CubeTools\CubeCustomFieldsBundle\EventListener\CustomFieldLinkedEntityListener) { $listenerInst = $listener; break 2; } } } $evm = $em->getEventManager(); $evm->removeEventListener(array('onFlush'), $listenerInst); // datetime custom fields $datetimeCf = $em->getRepository('CubeCustomFieldsBundle:DatetimeCustomField')->findAll(); $this->updateCfEntities($datetimeCf); $em->flush(); // text custom fields $textCf = $em->getRepository('CubeCustomFieldsBundle:TextCustomField')->findAll(); $this->updateCfEntities($textCf); $em->flush(); // textarea custom fields $textareaCf = $em->getRepository('CubeCustomFieldsBundle:TextareaCustomField')->findAll(); $this->updateCfEntities($textareaCf); $em->flush(); // entity custom fields $entityCf = $em->getRepository('CubeCustomFieldsBundle:EntityCustomField')->findAll(); $this->updateCfEntities($entityCf); $em->flush(); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "em", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'doctrine.orm.entity_manager'", ")", ";", "// disable the CustomFieldLinkedEntityListener during the execution of the command (to prevent loops)", "$", "listenerInst", "=", "null", ";", "foreach", "(", "$", "em", "->", "getEventManager", "(", ")", "->", "getListeners", "(", ")", "as", "$", "event", "=>", "$", "listeners", ")", "{", "foreach", "(", "$", "listeners", "as", "$", "hash", "=>", "$", "listener", ")", "{", "if", "(", "$", "listener", "instanceof", "\\", "CubeTools", "\\", "CubeCustomFieldsBundle", "\\", "EventListener", "\\", "CustomFieldLinkedEntityListener", ")", "{", "$", "listenerInst", "=", "$", "listener", ";", "break", "2", ";", "}", "}", "}", "$", "evm", "=", "$", "em", "->", "getEventManager", "(", ")", ";", "$", "evm", "->", "removeEventListener", "(", "array", "(", "'onFlush'", ")", ",", "$", "listenerInst", ")", ";", "// datetime custom fields", "$", "datetimeCf", "=", "$", "em", "->", "getRepository", "(", "'CubeCustomFieldsBundle:DatetimeCustomField'", ")", "->", "findAll", "(", ")", ";", "$", "this", "->", "updateCfEntities", "(", "$", "datetimeCf", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "// text custom fields", "$", "textCf", "=", "$", "em", "->", "getRepository", "(", "'CubeCustomFieldsBundle:TextCustomField'", ")", "->", "findAll", "(", ")", ";", "$", "this", "->", "updateCfEntities", "(", "$", "textCf", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "// textarea custom fields", "$", "textareaCf", "=", "$", "em", "->", "getRepository", "(", "'CubeCustomFieldsBundle:TextareaCustomField'", ")", "->", "findAll", "(", ")", ";", "$", "this", "->", "updateCfEntities", "(", "$", "textareaCf", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "// entity custom fields", "$", "entityCf", "=", "$", "em", "->", "getRepository", "(", "'CubeCustomFieldsBundle:EntityCustomField'", ")", "->", "findAll", "(", ")", ";", "$", "this", "->", "updateCfEntities", "(", "$", "entityCf", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "}" ]
Cleans up access rights @param InputInterface $input @param OutputInterface $output @return boolean
[ "Cleans", "up", "access", "rights" ]
7c87f9e8e0f7a5f50536d0d801c04a0ba6de3414
https://github.com/EmchBerger/cube-custom-fields-bundle/blob/7c87f9e8e0f7a5f50536d0d801c04a0ba6de3414/src/Command/CustomFieldUpdateCommand.php#L32-L68
31,091
pulsarvp/vps-tools
src/modules/apiapp/widgets/ApiappWidget.php
ApiappWidget.addApp
private function addApp () { $appNew = new Apiapp(); if (Yii::$app->request->post('method') == 'apiapp') { $post = Yii::$app->request->post(); if ($post[ 'id' ]) $appNew = Apiapp::findOne($post[ 'id' ]); $appNew->setAttributes([ 'name' => $post[ 'name' ] ]); $appNew->token = StringHelper::random(16); if ($appNew->validate()) { $appNew->save(); if (!$post[ 'id' ]) Yii::$app->session->set('viewID', $appNew->id); $url = Yii::$app->request->referrer . '#' . $appNew->name; $appNew->setAttributes([ 'name' => '', 'token' => '' ]); LogManager::info(Yii::tr('User {user} has created API application {name}.', [ 'user' => Html::a(Yii::$app->user->identity->name, Url::toRoute([ 'user/view', 'id' => Yii::$app->user->id ])), 'name' => $post[ 'name' ] ])); Yii::$app->response->redirect($url); Yii::$app->end(); } } return $appNew; }
php
private function addApp () { $appNew = new Apiapp(); if (Yii::$app->request->post('method') == 'apiapp') { $post = Yii::$app->request->post(); if ($post[ 'id' ]) $appNew = Apiapp::findOne($post[ 'id' ]); $appNew->setAttributes([ 'name' => $post[ 'name' ] ]); $appNew->token = StringHelper::random(16); if ($appNew->validate()) { $appNew->save(); if (!$post[ 'id' ]) Yii::$app->session->set('viewID', $appNew->id); $url = Yii::$app->request->referrer . '#' . $appNew->name; $appNew->setAttributes([ 'name' => '', 'token' => '' ]); LogManager::info(Yii::tr('User {user} has created API application {name}.', [ 'user' => Html::a(Yii::$app->user->identity->name, Url::toRoute([ 'user/view', 'id' => Yii::$app->user->id ])), 'name' => $post[ 'name' ] ])); Yii::$app->response->redirect($url); Yii::$app->end(); } } return $appNew; }
[ "private", "function", "addApp", "(", ")", "{", "$", "appNew", "=", "new", "Apiapp", "(", ")", ";", "if", "(", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", "'method'", ")", "==", "'apiapp'", ")", "{", "$", "post", "=", "Yii", "::", "$", "app", "->", "request", "->", "post", "(", ")", ";", "if", "(", "$", "post", "[", "'id'", "]", ")", "$", "appNew", "=", "Apiapp", "::", "findOne", "(", "$", "post", "[", "'id'", "]", ")", ";", "$", "appNew", "->", "setAttributes", "(", "[", "'name'", "=>", "$", "post", "[", "'name'", "]", "]", ")", ";", "$", "appNew", "->", "token", "=", "StringHelper", "::", "random", "(", "16", ")", ";", "if", "(", "$", "appNew", "->", "validate", "(", ")", ")", "{", "$", "appNew", "->", "save", "(", ")", ";", "if", "(", "!", "$", "post", "[", "'id'", "]", ")", "Yii", "::", "$", "app", "->", "session", "->", "set", "(", "'viewID'", ",", "$", "appNew", "->", "id", ")", ";", "$", "url", "=", "Yii", "::", "$", "app", "->", "request", "->", "referrer", ".", "'#'", ".", "$", "appNew", "->", "name", ";", "$", "appNew", "->", "setAttributes", "(", "[", "'name'", "=>", "''", ",", "'token'", "=>", "''", "]", ")", ";", "LogManager", "::", "info", "(", "Yii", "::", "tr", "(", "'User {user} has created API application {name}.'", ",", "[", "'user'", "=>", "Html", "::", "a", "(", "Yii", "::", "$", "app", "->", "user", "->", "identity", "->", "name", ",", "Url", "::", "toRoute", "(", "[", "'user/view'", ",", "'id'", "=>", "Yii", "::", "$", "app", "->", "user", "->", "id", "]", ")", ")", ",", "'name'", "=>", "$", "post", "[", "'name'", "]", "]", ")", ")", ";", "Yii", "::", "$", "app", "->", "response", "->", "redirect", "(", "$", "url", ")", ";", "Yii", "::", "$", "app", "->", "end", "(", ")", ";", "}", "}", "return", "$", "appNew", ";", "}" ]
Add new app and token
[ "Add", "new", "app", "and", "token" ]
bb51fd5f68669edbd2801b52a9edeebaa756eec2
https://github.com/pulsarvp/vps-tools/blob/bb51fd5f68669edbd2801b52a9edeebaa756eec2/src/modules/apiapp/widgets/ApiappWidget.php#L68-L95
31,092
shimabox/SMBArrayto
src/SMB/Arrayto/Base.php
Base.setRows
public function setRows(array $rows) { $this->downloader->setRows($rows); $this->outputter->setRows($rows); $this->writer->setRows($rows); return $this; }
php
public function setRows(array $rows) { $this->downloader->setRows($rows); $this->outputter->setRows($rows); $this->writer->setRows($rows); return $this; }
[ "public", "function", "setRows", "(", "array", "$", "rows", ")", "{", "$", "this", "->", "downloader", "->", "setRows", "(", "$", "rows", ")", ";", "$", "this", "->", "outputter", "->", "setRows", "(", "$", "rows", ")", ";", "$", "this", "->", "writer", "->", "setRows", "(", "$", "rows", ")", ";", "return", "$", "this", ";", "}" ]
Set the row to be written @param array $rows @return \SMB\Arrayto\Base
[ "Set", "the", "row", "to", "be", "written" ]
7ecacc0c15994c02224bbd3efe055d3bce243971
https://github.com/shimabox/SMBArrayto/blob/7ecacc0c15994c02224bbd3efe055d3bce243971/src/SMB/Arrayto/Base.php#L62-L69
31,093
shimabox/SMBArrayto
src/SMB/Arrayto/Base.php
Base.addRow
public function addRow($rows) { $this->downloader->addRow($rows); $this->outputter->addRow($rows); $this->writer->addRow($rows); return $this; }
php
public function addRow($rows) { $this->downloader->addRow($rows); $this->outputter->addRow($rows); $this->writer->addRow($rows); return $this; }
[ "public", "function", "addRow", "(", "$", "rows", ")", "{", "$", "this", "->", "downloader", "->", "addRow", "(", "$", "rows", ")", ";", "$", "this", "->", "outputter", "->", "addRow", "(", "$", "rows", ")", ";", "$", "this", "->", "writer", "->", "addRow", "(", "$", "rows", ")", ";", "return", "$", "this", ";", "}" ]
Add the row to be written @param mixed $rows @return \SMB\Arrayto\Base
[ "Add", "the", "row", "to", "be", "written" ]
7ecacc0c15994c02224bbd3efe055d3bce243971
https://github.com/shimabox/SMBArrayto/blob/7ecacc0c15994c02224bbd3efe055d3bce243971/src/SMB/Arrayto/Base.php#L91-L98
31,094
shimabox/SMBArrayto
src/SMB/Arrayto/Base.php
Base.setAllowDuplicateKey
public function setAllowDuplicateKey($toAllow) { $this->downloader->setAllowDuplicateKey($toAllow); $this->outputter->setAllowDuplicateKey($toAllow); $this->writer->setAllowDuplicateKey($toAllow); return $this; }
php
public function setAllowDuplicateKey($toAllow) { $this->downloader->setAllowDuplicateKey($toAllow); $this->outputter->setAllowDuplicateKey($toAllow); $this->writer->setAllowDuplicateKey($toAllow); return $this; }
[ "public", "function", "setAllowDuplicateKey", "(", "$", "toAllow", ")", "{", "$", "this", "->", "downloader", "->", "setAllowDuplicateKey", "(", "$", "toAllow", ")", ";", "$", "this", "->", "outputter", "->", "setAllowDuplicateKey", "(", "$", "toAllow", ")", ";", "$", "this", "->", "writer", "->", "setAllowDuplicateKey", "(", "$", "toAllow", ")", ";", "return", "$", "this", ";", "}" ]
Whether to allow duplicate keys @param boolean $toAllow @return \SMB\Arrayto\Base
[ "Whether", "to", "allow", "duplicate", "keys" ]
7ecacc0c15994c02224bbd3efe055d3bce243971
https://github.com/shimabox/SMBArrayto/blob/7ecacc0c15994c02224bbd3efe055d3bce243971/src/SMB/Arrayto/Base.php#L119-L126
31,095
EmchBerger/cube-custom-fields-bundle
src/Utils/CustomFieldRepoService.php
CustomFieldRepoService.getEntitiesIdsForCustomFieldId
public function getEntitiesIdsForCustomFieldId($entityClass, $customFieldId) { $qb = $this->mr->getManager()->getRepository($entityClass)->createQueryBuilder('e'); $qb->join('e.customFields', 'cf') ->select('e.id') ->where('cf.id = :id') ->setParameter('id', $customFieldId); $result = $qb->getQuery()->getScalarResult(); return array_column($result, 'id'); }
php
public function getEntitiesIdsForCustomFieldId($entityClass, $customFieldId) { $qb = $this->mr->getManager()->getRepository($entityClass)->createQueryBuilder('e'); $qb->join('e.customFields', 'cf') ->select('e.id') ->where('cf.id = :id') ->setParameter('id', $customFieldId); $result = $qb->getQuery()->getScalarResult(); return array_column($result, 'id'); }
[ "public", "function", "getEntitiesIdsForCustomFieldId", "(", "$", "entityClass", ",", "$", "customFieldId", ")", "{", "$", "qb", "=", "$", "this", "->", "mr", "->", "getManager", "(", ")", "->", "getRepository", "(", "$", "entityClass", ")", "->", "createQueryBuilder", "(", "'e'", ")", ";", "$", "qb", "->", "join", "(", "'e.customFields'", ",", "'cf'", ")", "->", "select", "(", "'e.id'", ")", "->", "where", "(", "'cf.id = :id'", ")", "->", "setParameter", "(", "'id'", ",", "$", "customFieldId", ")", ";", "$", "result", "=", "$", "qb", "->", "getQuery", "(", ")", "->", "getScalarResult", "(", ")", ";", "return", "array_column", "(", "$", "result", ",", "'id'", ")", ";", "}" ]
Retrieves all entities from a given class which are linked to a specific CustomField @param string $entityClass Must be an entity stored in the database @param int $customFieldId The ID of the customField base entity to match with @return array Contains all found entity IDs which point to the customFieldId
[ "Retrieves", "all", "entities", "from", "a", "given", "class", "which", "are", "linked", "to", "a", "specific", "CustomField" ]
7c87f9e8e0f7a5f50536d0d801c04a0ba6de3414
https://github.com/EmchBerger/cube-custom-fields-bundle/blob/7c87f9e8e0f7a5f50536d0d801c04a0ba6de3414/src/Utils/CustomFieldRepoService.php#L36-L46
31,096
EmchBerger/cube-custom-fields-bundle
src/Utils/CustomFieldRepoService.php
CustomFieldRepoService.addAnyCustomFieldId
public function addAnyCustomFieldId($customFieldId, $firstRootAlias, $qb) { $alias = 'cf' . $this->parameterCount; $qb->join($firstRootAlias . '.customFields', $alias); $qb->andWhere($alias . '.fieldId = :fieldId' . $this->parameterCount); $qb->setParameter('fieldId' . $this->parameterCount, $customFieldId); $this->parameterCount++; return $qb; }
php
public function addAnyCustomFieldId($customFieldId, $firstRootAlias, $qb) { $alias = 'cf' . $this->parameterCount; $qb->join($firstRootAlias . '.customFields', $alias); $qb->andWhere($alias . '.fieldId = :fieldId' . $this->parameterCount); $qb->setParameter('fieldId' . $this->parameterCount, $customFieldId); $this->parameterCount++; return $qb; }
[ "public", "function", "addAnyCustomFieldId", "(", "$", "customFieldId", ",", "$", "firstRootAlias", ",", "$", "qb", ")", "{", "$", "alias", "=", "'cf'", ".", "$", "this", "->", "parameterCount", ";", "$", "qb", "->", "join", "(", "$", "firstRootAlias", ".", "'.customFields'", ",", "$", "alias", ")", ";", "$", "qb", "->", "andWhere", "(", "$", "alias", ".", "'.fieldId = :fieldId'", ".", "$", "this", "->", "parameterCount", ")", ";", "$", "qb", "->", "setParameter", "(", "'fieldId'", ".", "$", "this", "->", "parameterCount", ",", "$", "customFieldId", ")", ";", "$", "this", "->", "parameterCount", "++", ";", "return", "$", "qb", ";", "}" ]
Method looking for records, where any value of custom field is set. @param string $customFieldId @param string $firstRootAlias @param \Doctrine\ORM\QueryBuilder $qb @return \Doctrine\ORM\QueryBuilder
[ "Method", "looking", "for", "records", "where", "any", "value", "of", "custom", "field", "is", "set", "." ]
7c87f9e8e0f7a5f50536d0d801c04a0ba6de3414
https://github.com/EmchBerger/cube-custom-fields-bundle/blob/7c87f9e8e0f7a5f50536d0d801c04a0ba6de3414/src/Utils/CustomFieldRepoService.php#L76-L85
31,097
EmchBerger/cube-custom-fields-bundle
src/Utils/CustomFieldRepoService.php
CustomFieldRepoService.addNoneCustomFieldId
public function addNoneCustomFieldId($customFieldId, $firstRootAlias, $qb) { $entities = $this->addAnyCustomFieldIdQueryResult($customFieldId, $firstRootAlias, $qb); $qb->andWhere($firstRootAlias . sprintf('.id NOT IN (:notAny%s)', $this->parameterCount)) ->setParameter('notAny' . $this->parameterCount, $entities); $this->parameterCount++; return $qb; }
php
public function addNoneCustomFieldId($customFieldId, $firstRootAlias, $qb) { $entities = $this->addAnyCustomFieldIdQueryResult($customFieldId, $firstRootAlias, $qb); $qb->andWhere($firstRootAlias . sprintf('.id NOT IN (:notAny%s)', $this->parameterCount)) ->setParameter('notAny' . $this->parameterCount, $entities); $this->parameterCount++; return $qb; }
[ "public", "function", "addNoneCustomFieldId", "(", "$", "customFieldId", ",", "$", "firstRootAlias", ",", "$", "qb", ")", "{", "$", "entities", "=", "$", "this", "->", "addAnyCustomFieldIdQueryResult", "(", "$", "customFieldId", ",", "$", "firstRootAlias", ",", "$", "qb", ")", ";", "$", "qb", "->", "andWhere", "(", "$", "firstRootAlias", ".", "sprintf", "(", "'.id NOT IN (:notAny%s)'", ",", "$", "this", "->", "parameterCount", ")", ")", "->", "setParameter", "(", "'notAny'", ".", "$", "this", "->", "parameterCount", ",", "$", "entities", ")", ";", "$", "this", "->", "parameterCount", "++", ";", "return", "$", "qb", ";", "}" ]
Method looking for records, where no value of custom field is set. @param string $customFieldId @param string $firstRootAlias @param \Doctrine\ORM\QueryBuilder $qb @return \Doctrine\ORM\QueryBuilder
[ "Method", "looking", "for", "records", "where", "no", "value", "of", "custom", "field", "is", "set", "." ]
7c87f9e8e0f7a5f50536d0d801c04a0ba6de3414
https://github.com/EmchBerger/cube-custom-fields-bundle/blob/7c87f9e8e0f7a5f50536d0d801c04a0ba6de3414/src/Utils/CustomFieldRepoService.php#L96-L104
31,098
EmchBerger/cube-custom-fields-bundle
src/Utils/CustomFieldRepoService.php
CustomFieldRepoService.getEntitiesIdsForCustomFieldIds
public function getEntitiesIdsForCustomFieldIds($entityClass, $customFieldIds) { if (!count($customFieldIds)) { return array(); } $qb = $this->getEntitiesIdsForCustomFieldIdsQb($entityClass, $customFieldIds); $result = $qb->getQuery()->getScalarResult(); return array_column($result, 'id'); }
php
public function getEntitiesIdsForCustomFieldIds($entityClass, $customFieldIds) { if (!count($customFieldIds)) { return array(); } $qb = $this->getEntitiesIdsForCustomFieldIdsQb($entityClass, $customFieldIds); $result = $qb->getQuery()->getScalarResult(); return array_column($result, 'id'); }
[ "public", "function", "getEntitiesIdsForCustomFieldIds", "(", "$", "entityClass", ",", "$", "customFieldIds", ")", "{", "if", "(", "!", "count", "(", "$", "customFieldIds", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "qb", "=", "$", "this", "->", "getEntitiesIdsForCustomFieldIdsQb", "(", "$", "entityClass", ",", "$", "customFieldIds", ")", ";", "$", "result", "=", "$", "qb", "->", "getQuery", "(", ")", "->", "getScalarResult", "(", ")", ";", "return", "array_column", "(", "$", "result", ",", "'id'", ")", ";", "}" ]
Retrieves all entities from a given class which are linked to a set of CustomField @param string $entityClass Must be an entity stored in the database @param array $customFieldIds The array of IDs of the customField base entities to match with @return array Contains all found entity IDs which point to any of the customFields in customFieldIds
[ "Retrieves", "all", "entities", "from", "a", "given", "class", "which", "are", "linked", "to", "a", "set", "of", "CustomField" ]
7c87f9e8e0f7a5f50536d0d801c04a0ba6de3414
https://github.com/EmchBerger/cube-custom-fields-bundle/blob/7c87f9e8e0f7a5f50536d0d801c04a0ba6de3414/src/Utils/CustomFieldRepoService.php#L114-L125
31,099
cedx/yii2-mustache
lib/helpers/I18N.php
I18N.getTranslate
function getTranslate(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $defaultArgs = [ 'category' => $this->defaultCategory, 'language' => null, 'params' => [] ]; $output = trim($value); $isJSON = mb_substr($output, 0, 1) == '{' && mb_substr($output, mb_strlen($output) - 1) == '}'; if ($isJSON) $args = $this->parseArguments($helper->render($value), 'message', $defaultArgs); else { /** @var string[] $parts */ $parts = explode($this->argumentSeparator, $output, 2); $length = count($parts); if (!$length) throw new InvalidCallException('Invalid translation format.'); $args = ArrayHelper::merge($defaultArgs, [ 'category' => $length == 1 ? $this->defaultCategory : rtrim($parts[0]), 'message' => ltrim($parts[$length - 1]) ]); } return \Yii::t($args['category'], $args['message'], $args['params'], $args['language']); }; }
php
function getTranslate(): \Closure { return function($value, \Mustache_LambdaHelper $helper) { $defaultArgs = [ 'category' => $this->defaultCategory, 'language' => null, 'params' => [] ]; $output = trim($value); $isJSON = mb_substr($output, 0, 1) == '{' && mb_substr($output, mb_strlen($output) - 1) == '}'; if ($isJSON) $args = $this->parseArguments($helper->render($value), 'message', $defaultArgs); else { /** @var string[] $parts */ $parts = explode($this->argumentSeparator, $output, 2); $length = count($parts); if (!$length) throw new InvalidCallException('Invalid translation format.'); $args = ArrayHelper::merge($defaultArgs, [ 'category' => $length == 1 ? $this->defaultCategory : rtrim($parts[0]), 'message' => ltrim($parts[$length - 1]) ]); } return \Yii::t($args['category'], $args['message'], $args['params'], $args['language']); }; }
[ "function", "getTranslate", "(", ")", ":", "\\", "Closure", "{", "return", "function", "(", "$", "value", ",", "\\", "Mustache_LambdaHelper", "$", "helper", ")", "{", "$", "defaultArgs", "=", "[", "'category'", "=>", "$", "this", "->", "defaultCategory", ",", "'language'", "=>", "null", ",", "'params'", "=>", "[", "]", "]", ";", "$", "output", "=", "trim", "(", "$", "value", ")", ";", "$", "isJSON", "=", "mb_substr", "(", "$", "output", ",", "0", ",", "1", ")", "==", "'{'", "&&", "mb_substr", "(", "$", "output", ",", "mb_strlen", "(", "$", "output", ")", "-", "1", ")", "==", "'}'", ";", "if", "(", "$", "isJSON", ")", "$", "args", "=", "$", "this", "->", "parseArguments", "(", "$", "helper", "->", "render", "(", "$", "value", ")", ",", "'message'", ",", "$", "defaultArgs", ")", ";", "else", "{", "/** @var string[] $parts */", "$", "parts", "=", "explode", "(", "$", "this", "->", "argumentSeparator", ",", "$", "output", ",", "2", ")", ";", "$", "length", "=", "count", "(", "$", "parts", ")", ";", "if", "(", "!", "$", "length", ")", "throw", "new", "InvalidCallException", "(", "'Invalid translation format.'", ")", ";", "$", "args", "=", "ArrayHelper", "::", "merge", "(", "$", "defaultArgs", ",", "[", "'category'", "=>", "$", "length", "==", "1", "?", "$", "this", "->", "defaultCategory", ":", "rtrim", "(", "$", "parts", "[", "0", "]", ")", ",", "'message'", "=>", "ltrim", "(", "$", "parts", "[", "$", "length", "-", "1", "]", ")", "]", ")", ";", "}", "return", "\\", "Yii", "::", "t", "(", "$", "args", "[", "'category'", "]", ",", "$", "args", "[", "'message'", "]", ",", "$", "args", "[", "'params'", "]", ",", "$", "args", "[", "'language'", "]", ")", ";", "}", ";", "}" ]
Returns a function translating a message. @return \Closure A function translating a message. @throws InvalidCallException The specified message has an invalid format.
[ "Returns", "a", "function", "translating", "a", "message", "." ]
20c961e65e74a0bacbe992dd7fdb28319f58a919
https://github.com/cedx/yii2-mustache/blob/20c961e65e74a0bacbe992dd7fdb28319f58a919/lib/helpers/I18N.php#L31-L57