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
partition
stringclasses
1 value
dms-org/common.structure
src/Money/Money.php
Money.asString
public function asString() : string { $fractionDigits = $this->currency->getDefaultFractionDigits(); $wholePart = substr((string)$this->amount, 0, -$fractionDigits) ?: '0'; $fractionalPart = str_pad(substr((string)$this->amount, -$fractionDigits), $fractionDigits, '0', STR_PAD_RIGHT); return $wholePart . '.' . $fractionalPart; }
php
public function asString() : string { $fractionDigits = $this->currency->getDefaultFractionDigits(); $wholePart = substr((string)$this->amount, 0, -$fractionDigits) ?: '0'; $fractionalPart = str_pad(substr((string)$this->amount, -$fractionDigits), $fractionDigits, '0', STR_PAD_RIGHT); return $wholePart . '.' . $fractionalPart; }
[ "public", "function", "asString", "(", ")", ":", "string", "{", "$", "fractionDigits", "=", "$", "this", "->", "currency", "->", "getDefaultFractionDigits", "(", ")", ";", "$", "wholePart", "=", "substr", "(", "(", "string", ")", "$", "this", "->", "amount", ",", "0", ",", "-", "$", "fractionDigits", ")", "?", ":", "'0'", ";", "$", "fractionalPart", "=", "str_pad", "(", "substr", "(", "(", "string", ")", "$", "this", "->", "amount", ",", "-", "$", "fractionDigits", ")", ",", "$", "fractionDigits", ",", "'0'", ",", "STR_PAD_RIGHT", ")", ";", "return", "$", "wholePart", ".", "'.'", ".", "$", "fractionalPart", ";", "}" ]
Returns the monetary value as string. @return string
[ "Returns", "the", "monetary", "value", "as", "string", "." ]
23f122182f60df5ec847047a81a39c8aab019ff1
https://github.com/dms-org/common.structure/blob/23f122182f60df5ec847047a81a39c8aab019ff1/src/Money/Money.php#L190-L199
train
jabernardo/lollipop-php
Library/Cache.php
Cache.getDriver
static private function getDriver() { if (self::$_driver != null) return self::$_driver; $driver = Utils::spare(Config::get('cache.driver'), 'file'); switch (strtolower($driver)) { case 'memcached': self::$_driver = new \Lollipop\Cache\MemcachedAdapter(); break; case 'file': default: self::$_driver = new \Lollipop\Cache\FileAdapter(); break; } return self::$_driver; }
php
static private function getDriver() { if (self::$_driver != null) return self::$_driver; $driver = Utils::spare(Config::get('cache.driver'), 'file'); switch (strtolower($driver)) { case 'memcached': self::$_driver = new \Lollipop\Cache\MemcachedAdapter(); break; case 'file': default: self::$_driver = new \Lollipop\Cache\FileAdapter(); break; } return self::$_driver; }
[ "static", "private", "function", "getDriver", "(", ")", "{", "if", "(", "self", "::", "$", "_driver", "!=", "null", ")", "return", "self", "::", "$", "_driver", ";", "$", "driver", "=", "Utils", "::", "spare", "(", "Config", "::", "get", "(", "'cache.driver'", ")", ",", "'file'", ")", ";", "switch", "(", "strtolower", "(", "$", "driver", ")", ")", "{", "case", "'memcached'", ":", "self", "::", "$", "_driver", "=", "new", "\\", "Lollipop", "\\", "Cache", "\\", "MemcachedAdapter", "(", ")", ";", "break", ";", "case", "'file'", ":", "default", ":", "self", "::", "$", "_driver", "=", "new", "\\", "Lollipop", "\\", "Cache", "\\", "FileAdapter", "(", ")", ";", "break", ";", "}", "return", "self", "::", "$", "_driver", ";", "}" ]
Get cache driver @return object
[ "Get", "cache", "driver" ]
004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5
https://github.com/jabernardo/lollipop-php/blob/004d80b21f7246bb3e08c7b9f74a165b0d3ca0f5/Library/Cache.php#L32-L49
train
zarathustra323/modlr-data
src/Zarathustra/ModlrData/Metadata/Driver/DoctrineMongoDBDriver.php
DoctrineMongoDBDriver.setAttributes
private function setAttributes(ClassMetadataInfo $metadata, Metadata\AttributeInterface $entity) { foreach ($metadata->fieldMappings as $fieldKey => $mapping) { if (isset($mapping['id'])) { // Id field. Skip. continue; } if (isset($mapping['reference'])) { // Relationship. Skip. continue; } if (isset($mapping['inherited']) || isset($mapping['declared'])) { // Inherited. Skip. continue; } if (!isset($mapping['type'])) { // Unable to map. No type. throw new RuntimeException(sprintf('Cannot create an attribute for field "%s" because no data type was found', $fieldKey)); } $entityDataType = isset($mapping['embedded']) ? 'object' : $this->getDataType($mapping['type']); // $this->validator->validateDataType($apiDataType); switch ($entityDataType) { // case 'object': // $attribute = new Metadata\ObjectAttributeMetadata($fieldKey, 'object'); // // @todo This needs some work. How do we determine the child attributes of polymorphic embedded documents? // if (isset($mapping['embedded']) && isset($mapping['targetDocument'])) { // $childMetadata = $this->mf->getMetadataFor($mapping['targetDocument']); // if (false === $this->isPolymorphicType($childMetadata)) { // $this->setAttributes($childMetadata, $attribute); // } // } // break; // case 'array': // $attribute = new Metadata\ArrayAttributeMetadata($fieldKey, 'array', 'mixed'); // break; default: $attribute = new Metadata\AttributeMetadata($fieldKey, $entityDataType); break; } $entity->addAttribute($attribute); } return $entity; }
php
private function setAttributes(ClassMetadataInfo $metadata, Metadata\AttributeInterface $entity) { foreach ($metadata->fieldMappings as $fieldKey => $mapping) { if (isset($mapping['id'])) { // Id field. Skip. continue; } if (isset($mapping['reference'])) { // Relationship. Skip. continue; } if (isset($mapping['inherited']) || isset($mapping['declared'])) { // Inherited. Skip. continue; } if (!isset($mapping['type'])) { // Unable to map. No type. throw new RuntimeException(sprintf('Cannot create an attribute for field "%s" because no data type was found', $fieldKey)); } $entityDataType = isset($mapping['embedded']) ? 'object' : $this->getDataType($mapping['type']); // $this->validator->validateDataType($apiDataType); switch ($entityDataType) { // case 'object': // $attribute = new Metadata\ObjectAttributeMetadata($fieldKey, 'object'); // // @todo This needs some work. How do we determine the child attributes of polymorphic embedded documents? // if (isset($mapping['embedded']) && isset($mapping['targetDocument'])) { // $childMetadata = $this->mf->getMetadataFor($mapping['targetDocument']); // if (false === $this->isPolymorphicType($childMetadata)) { // $this->setAttributes($childMetadata, $attribute); // } // } // break; // case 'array': // $attribute = new Metadata\ArrayAttributeMetadata($fieldKey, 'array', 'mixed'); // break; default: $attribute = new Metadata\AttributeMetadata($fieldKey, $entityDataType); break; } $entity->addAttribute($attribute); } return $entity; }
[ "private", "function", "setAttributes", "(", "ClassMetadataInfo", "$", "metadata", ",", "Metadata", "\\", "AttributeInterface", "$", "entity", ")", "{", "foreach", "(", "$", "metadata", "->", "fieldMappings", "as", "$", "fieldKey", "=>", "$", "mapping", ")", "{", "if", "(", "isset", "(", "$", "mapping", "[", "'id'", "]", ")", ")", "{", "// Id field. Skip.", "continue", ";", "}", "if", "(", "isset", "(", "$", "mapping", "[", "'reference'", "]", ")", ")", "{", "// Relationship. Skip.", "continue", ";", "}", "if", "(", "isset", "(", "$", "mapping", "[", "'inherited'", "]", ")", "||", "isset", "(", "$", "mapping", "[", "'declared'", "]", ")", ")", "{", "// Inherited. Skip.", "continue", ";", "}", "if", "(", "!", "isset", "(", "$", "mapping", "[", "'type'", "]", ")", ")", "{", "// Unable to map. No type.", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'Cannot create an attribute for field \"%s\" because no data type was found'", ",", "$", "fieldKey", ")", ")", ";", "}", "$", "entityDataType", "=", "isset", "(", "$", "mapping", "[", "'embedded'", "]", ")", "?", "'object'", ":", "$", "this", "->", "getDataType", "(", "$", "mapping", "[", "'type'", "]", ")", ";", "// $this->validator->validateDataType($apiDataType);", "switch", "(", "$", "entityDataType", ")", "{", "// case 'object':", "// $attribute = new Metadata\\ObjectAttributeMetadata($fieldKey, 'object');", "// // @todo This needs some work. How do we determine the child attributes of polymorphic embedded documents?", "// if (isset($mapping['embedded']) && isset($mapping['targetDocument'])) {", "// $childMetadata = $this->mf->getMetadataFor($mapping['targetDocument']);", "// if (false === $this->isPolymorphicType($childMetadata)) {", "// $this->setAttributes($childMetadata, $attribute);", "// }", "// }", "// break;", "// case 'array':", "// $attribute = new Metadata\\ArrayAttributeMetadata($fieldKey, 'array', 'mixed');", "// break;", "default", ":", "$", "attribute", "=", "new", "Metadata", "\\", "AttributeMetadata", "(", "$", "fieldKey", ",", "$", "entityDataType", ")", ";", "break", ";", "}", "$", "entity", "->", "addAttribute", "(", "$", "attribute", ")", ";", "}", "return", "$", "entity", ";", "}" ]
Sets the entity attribute metadata from the Doctrine class metadata. @todo Validate data types / handle Doctrine to Modlr conversion. @todo Handle complex attribute types like objects and arrays (embededded docs?) @param ClassMetadataInfo $metadata @param Metadata\AttributeInterface $entity @return Metadata\EntityMetadata @throws RuntimeException If a Doctrine data type was not foind on the Doctrine field mapping.
[ "Sets", "the", "entity", "attribute", "metadata", "from", "the", "Doctrine", "class", "metadata", "." ]
7c2c767216055f75abf8cf22e2200f11998ed24e
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/Driver/DoctrineMongoDBDriver.php#L78-L122
train
zarathustra323/modlr-data
src/Zarathustra/ModlrData/Metadata/Driver/DoctrineMongoDBDriver.php
DoctrineMongoDBDriver.setRelationships
private function setRelationships(ClassMetadataInfo $metadata, Metadata\EntityMetadata $entity) { $allTypes = $this->getAllTypeNames(); foreach ($metadata->fieldMappings as $fieldKey => $mapping) { if (!isset($mapping['reference'])) { // Not a relationship. Skip. continue; } if (!isset($mapping['targetDocument'])) { // No target found. Skip. // @todo Should this throw an Exception? continue; } $type = $this->getTypeForClassName($mapping['targetDocument']); if (!in_array($type, $allTypes)) { throw new RuntimeException(sprintf('No metadata was found for related entity type "%s" as found on relationship field "%s::%s"', $type, $entity->type, $fieldKey)); } $relationship = new Metadata\RelationshipMetadata($fieldKey, $mapping['type'], $type); if (isset($mapping['isInverseSide']) && true === $mapping['isInverseSide']) { $relationship->isInverse = true; } $entity->addRelationship($relationship); } return $entity; }
php
private function setRelationships(ClassMetadataInfo $metadata, Metadata\EntityMetadata $entity) { $allTypes = $this->getAllTypeNames(); foreach ($metadata->fieldMappings as $fieldKey => $mapping) { if (!isset($mapping['reference'])) { // Not a relationship. Skip. continue; } if (!isset($mapping['targetDocument'])) { // No target found. Skip. // @todo Should this throw an Exception? continue; } $type = $this->getTypeForClassName($mapping['targetDocument']); if (!in_array($type, $allTypes)) { throw new RuntimeException(sprintf('No metadata was found for related entity type "%s" as found on relationship field "%s::%s"', $type, $entity->type, $fieldKey)); } $relationship = new Metadata\RelationshipMetadata($fieldKey, $mapping['type'], $type); if (isset($mapping['isInverseSide']) && true === $mapping['isInverseSide']) { $relationship->isInverse = true; } $entity->addRelationship($relationship); } return $entity; }
[ "private", "function", "setRelationships", "(", "ClassMetadataInfo", "$", "metadata", ",", "Metadata", "\\", "EntityMetadata", "$", "entity", ")", "{", "$", "allTypes", "=", "$", "this", "->", "getAllTypeNames", "(", ")", ";", "foreach", "(", "$", "metadata", "->", "fieldMappings", "as", "$", "fieldKey", "=>", "$", "mapping", ")", "{", "if", "(", "!", "isset", "(", "$", "mapping", "[", "'reference'", "]", ")", ")", "{", "// Not a relationship. Skip.", "continue", ";", "}", "if", "(", "!", "isset", "(", "$", "mapping", "[", "'targetDocument'", "]", ")", ")", "{", "// No target found. Skip.", "// @todo Should this throw an Exception?", "continue", ";", "}", "$", "type", "=", "$", "this", "->", "getTypeForClassName", "(", "$", "mapping", "[", "'targetDocument'", "]", ")", ";", "if", "(", "!", "in_array", "(", "$", "type", ",", "$", "allTypes", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'No metadata was found for related entity type \"%s\" as found on relationship field \"%s::%s\"'", ",", "$", "type", ",", "$", "entity", "->", "type", ",", "$", "fieldKey", ")", ")", ";", "}", "$", "relationship", "=", "new", "Metadata", "\\", "RelationshipMetadata", "(", "$", "fieldKey", ",", "$", "mapping", "[", "'type'", "]", ",", "$", "type", ")", ";", "if", "(", "isset", "(", "$", "mapping", "[", "'isInverseSide'", "]", ")", "&&", "true", "===", "$", "mapping", "[", "'isInverseSide'", "]", ")", "{", "$", "relationship", "->", "isInverse", "=", "true", ";", "}", "$", "entity", "->", "addRelationship", "(", "$", "relationship", ")", ";", "}", "return", "$", "entity", ";", "}" ]
Sets the entity relationship metadata from the Doctrine class metadata. @param ClassMetadataInfo $metadata @param Metadata\EntityMetadata $entity @return Metadata\EntityMetadata @throws RuntimeException If the Doctrine target document metadata was not found.
[ "Sets", "the", "entity", "relationship", "metadata", "from", "the", "Doctrine", "class", "metadata", "." ]
7c2c767216055f75abf8cf22e2200f11998ed24e
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/Driver/DoctrineMongoDBDriver.php#L132-L158
train
zarathustra323/modlr-data
src/Zarathustra/ModlrData/Metadata/Driver/DoctrineMongoDBDriver.php
DoctrineMongoDBDriver.getDataType
private function getDataType($doctrineType) { $map = $this->getDoctrineTypeMap(); if (!isset($map[$doctrineType])) { throw new InvalidArgumentException(sprintf('The Doctrine type "%s" is currenty not implemented by the API.', $doctrineType)); } return $map[$doctrineType]; }
php
private function getDataType($doctrineType) { $map = $this->getDoctrineTypeMap(); if (!isset($map[$doctrineType])) { throw new InvalidArgumentException(sprintf('The Doctrine type "%s" is currenty not implemented by the API.', $doctrineType)); } return $map[$doctrineType]; }
[ "private", "function", "getDataType", "(", "$", "doctrineType", ")", "{", "$", "map", "=", "$", "this", "->", "getDoctrineTypeMap", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "map", "[", "$", "doctrineType", "]", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'The Doctrine type \"%s\" is currenty not implemented by the API.'", ",", "$", "doctrineType", ")", ")", ";", "}", "return", "$", "map", "[", "$", "doctrineType", "]", ";", "}" ]
Gets the Modlr field data type from a Doctrine data type. @todo This should be handled by having something register custom data types? @param string $doctrineType @param string @throws InvalidArgumentException If a Doctrine-to-Modlr type conversion was not implemented.
[ "Gets", "the", "Modlr", "field", "data", "type", "from", "a", "Doctrine", "data", "type", "." ]
7c2c767216055f75abf8cf22e2200f11998ed24e
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/Driver/DoctrineMongoDBDriver.php#L168-L175
train
zarathustra323/modlr-data
src/Zarathustra/ModlrData/Metadata/Driver/DoctrineMongoDBDriver.php
DoctrineMongoDBDriver.isPolymorphicType
private function isPolymorphicType(ClassMetadataInfo $metadata) { return in_array($metadata->inheritanceType, $this->getPolymorphicTypes()) && null === $metadata->discriminatorValue; }
php
private function isPolymorphicType(ClassMetadataInfo $metadata) { return in_array($metadata->inheritanceType, $this->getPolymorphicTypes()) && null === $metadata->discriminatorValue; }
[ "private", "function", "isPolymorphicType", "(", "ClassMetadataInfo", "$", "metadata", ")", "{", "return", "in_array", "(", "$", "metadata", "->", "inheritanceType", ",", "$", "this", "->", "getPolymorphicTypes", "(", ")", ")", "&&", "null", "===", "$", "metadata", "->", "discriminatorValue", ";", "}" ]
Determines if a Doctrine object is polymorphic, based on its class metadata. @param ClassMetadataInfo $metadata @return bool
[ "Determines", "if", "a", "Doctrine", "object", "is", "polymorphic", "based", "on", "its", "class", "metadata", "." ]
7c2c767216055f75abf8cf22e2200f11998ed24e
https://github.com/zarathustra323/modlr-data/blob/7c2c767216055f75abf8cf22e2200f11998ed24e/src/Zarathustra/ModlrData/Metadata/Driver/DoctrineMongoDBDriver.php#L207-L210
train
tamago-db/TamagoTipsManagerBundle
Controller/TipsManagerController.php
TipsManagerController.getTipTransUnit
private function getTipTransUnit($locale, $domain, $identifier) { $storage = $this->get('lexik_translation.translation_storage'); try { // Note that getAllByLocaleAndDomain return arrays rather than entities; presumably for performance reasons $transUnits = $storage->getTransUnitsByLocaleAndDomain($locale, $domain); } catch (QueryException $e) { throw new \RuntimeException('Tips database not configured'); } // Throw exception if not tips if (!$total = count($transUnits)) { throw new \RuntimeException('No tips in database'); } // Get a random tip from the array $random = random_int(0, $total-1); // Now retrieve a single TransUnit entity $transUnitId = $transUnits[$random]['id']; $transUnit = $storage->getTransUnitById($transUnitId); // Retrieve meta data $om = $this->getObjectManager(); $tipMetaDataRepository = $om->getRepository('TamagoTipsManagerBundle:TamagoTransUnitMeta'); $tipMetaData = $tipMetaDataRepository->singleton($transUnit, $locale, $identifier); // Increment view count $tipMetaData->setViewCount($tipMetaData->getViewCount() + 1); $om->flush(); return $transUnit; }
php
private function getTipTransUnit($locale, $domain, $identifier) { $storage = $this->get('lexik_translation.translation_storage'); try { // Note that getAllByLocaleAndDomain return arrays rather than entities; presumably for performance reasons $transUnits = $storage->getTransUnitsByLocaleAndDomain($locale, $domain); } catch (QueryException $e) { throw new \RuntimeException('Tips database not configured'); } // Throw exception if not tips if (!$total = count($transUnits)) { throw new \RuntimeException('No tips in database'); } // Get a random tip from the array $random = random_int(0, $total-1); // Now retrieve a single TransUnit entity $transUnitId = $transUnits[$random]['id']; $transUnit = $storage->getTransUnitById($transUnitId); // Retrieve meta data $om = $this->getObjectManager(); $tipMetaDataRepository = $om->getRepository('TamagoTipsManagerBundle:TamagoTransUnitMeta'); $tipMetaData = $tipMetaDataRepository->singleton($transUnit, $locale, $identifier); // Increment view count $tipMetaData->setViewCount($tipMetaData->getViewCount() + 1); $om->flush(); return $transUnit; }
[ "private", "function", "getTipTransUnit", "(", "$", "locale", ",", "$", "domain", ",", "$", "identifier", ")", "{", "$", "storage", "=", "$", "this", "->", "get", "(", "'lexik_translation.translation_storage'", ")", ";", "try", "{", "// Note that getAllByLocaleAndDomain return arrays rather than entities; presumably for performance reasons", "$", "transUnits", "=", "$", "storage", "->", "getTransUnitsByLocaleAndDomain", "(", "$", "locale", ",", "$", "domain", ")", ";", "}", "catch", "(", "QueryException", "$", "e", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Tips database not configured'", ")", ";", "}", "// Throw exception if not tips", "if", "(", "!", "$", "total", "=", "count", "(", "$", "transUnits", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'No tips in database'", ")", ";", "}", "// Get a random tip from the array", "$", "random", "=", "random_int", "(", "0", ",", "$", "total", "-", "1", ")", ";", "// Now retrieve a single TransUnit entity", "$", "transUnitId", "=", "$", "transUnits", "[", "$", "random", "]", "[", "'id'", "]", ";", "$", "transUnit", "=", "$", "storage", "->", "getTransUnitById", "(", "$", "transUnitId", ")", ";", "// Retrieve meta data", "$", "om", "=", "$", "this", "->", "getObjectManager", "(", ")", ";", "$", "tipMetaDataRepository", "=", "$", "om", "->", "getRepository", "(", "'TamagoTipsManagerBundle:TamagoTransUnitMeta'", ")", ";", "$", "tipMetaData", "=", "$", "tipMetaDataRepository", "->", "singleton", "(", "$", "transUnit", ",", "$", "locale", ",", "$", "identifier", ")", ";", "// Increment view count", "$", "tipMetaData", "->", "setViewCount", "(", "$", "tipMetaData", "->", "getViewCount", "(", ")", "+", "1", ")", ";", "$", "om", "->", "flush", "(", ")", ";", "return", "$", "transUnit", ";", "}" ]
Retrieve a random tip from the Lexik translations. Increment view count. @param Request $request @param $domain @param $identifier @return TransUnit
[ "Retrieve", "a", "random", "tip", "from", "the", "Lexik", "translations", ".", "Increment", "view", "count", "." ]
3ce3be82061298426a9278682e859fde9140540a
https://github.com/tamago-db/TamagoTipsManagerBundle/blob/3ce3be82061298426a9278682e859fde9140540a/Controller/TipsManagerController.php#L30-L62
train
tamago-db/TamagoTipsManagerBundle
Controller/TipsManagerController.php
TipsManagerController.indexAction
public function indexAction(Request $request, $domain, $identifier) { $locale = substr($request->getLocale(), 0, 2); // Make sure to use only the two character locale try { $transUnit = $this->getTipTransUnit($locale, $domain, $identifier); $translatedTip = $transUnit->getTranslation($locale); return $this->render('TamagoTipsManagerBundle:Default:index.html.twig', [ 'tip' => $translatedTip, 'identifier' => $identifier ]); } catch (\RuntimeException $e) { // Catch exception and return 204 return new Response(null, Response::HTTP_NO_CONTENT); } }
php
public function indexAction(Request $request, $domain, $identifier) { $locale = substr($request->getLocale(), 0, 2); // Make sure to use only the two character locale try { $transUnit = $this->getTipTransUnit($locale, $domain, $identifier); $translatedTip = $transUnit->getTranslation($locale); return $this->render('TamagoTipsManagerBundle:Default:index.html.twig', [ 'tip' => $translatedTip, 'identifier' => $identifier ]); } catch (\RuntimeException $e) { // Catch exception and return 204 return new Response(null, Response::HTTP_NO_CONTENT); } }
[ "public", "function", "indexAction", "(", "Request", "$", "request", ",", "$", "domain", ",", "$", "identifier", ")", "{", "$", "locale", "=", "substr", "(", "$", "request", "->", "getLocale", "(", ")", ",", "0", ",", "2", ")", ";", "// Make sure to use only the two character locale", "try", "{", "$", "transUnit", "=", "$", "this", "->", "getTipTransUnit", "(", "$", "locale", ",", "$", "domain", ",", "$", "identifier", ")", ";", "$", "translatedTip", "=", "$", "transUnit", "->", "getTranslation", "(", "$", "locale", ")", ";", "return", "$", "this", "->", "render", "(", "'TamagoTipsManagerBundle:Default:index.html.twig'", ",", "[", "'tip'", "=>", "$", "translatedTip", ",", "'identifier'", "=>", "$", "identifier", "]", ")", ";", "}", "catch", "(", "\\", "RuntimeException", "$", "e", ")", "{", "// Catch exception and return 204", "return", "new", "Response", "(", "null", ",", "Response", "::", "HTTP_NO_CONTENT", ")", ";", "}", "}" ]
Render tip page with style and JavaScript. @param Request $request @param $domain @param $identifier @return Response
[ "Render", "tip", "page", "with", "style", "and", "JavaScript", "." ]
3ce3be82061298426a9278682e859fde9140540a
https://github.com/tamago-db/TamagoTipsManagerBundle/blob/3ce3be82061298426a9278682e859fde9140540a/Controller/TipsManagerController.php#L73-L86
train
tamago-db/TamagoTipsManagerBundle
Controller/TipsManagerController.php
TipsManagerController.feedbackAction
public function feedbackAction(Request $request, $id, $feedback, $domain, $identifier) { $locale = substr($request->getLocale(), 0, 2); // Make sure to use only the two character locale $om = $this->getObjectManager(); $repository = $om->getRepository('TamagoTipsManagerBundle:TamagoTransUnitMeta'); $tipMetaData = $repository->findOneBy(['lexikTransUnitId' => $id, 'locale' => $locale, 'identifier' => $identifier]); switch ($feedback) { case 'like': $tipMetaData->setLikes($tipMetaData->getLikes() + 1); break; case 'dislike': $tipMetaData->setDislikes($tipMetaData->getDislikes() + 1); break; } $om->flush(); $transUnit = $this->getTipTransUnit($locale, $domain, $identifier); $translatedTip = $transUnit->getTranslation($locale); return $this->render('TamagoTipsManagerBundle:Default:tip.html.twig', [ 'tip' => $translatedTip, 'identifier' => $identifier ]); }
php
public function feedbackAction(Request $request, $id, $feedback, $domain, $identifier) { $locale = substr($request->getLocale(), 0, 2); // Make sure to use only the two character locale $om = $this->getObjectManager(); $repository = $om->getRepository('TamagoTipsManagerBundle:TamagoTransUnitMeta'); $tipMetaData = $repository->findOneBy(['lexikTransUnitId' => $id, 'locale' => $locale, 'identifier' => $identifier]); switch ($feedback) { case 'like': $tipMetaData->setLikes($tipMetaData->getLikes() + 1); break; case 'dislike': $tipMetaData->setDislikes($tipMetaData->getDislikes() + 1); break; } $om->flush(); $transUnit = $this->getTipTransUnit($locale, $domain, $identifier); $translatedTip = $transUnit->getTranslation($locale); return $this->render('TamagoTipsManagerBundle:Default:tip.html.twig', [ 'tip' => $translatedTip, 'identifier' => $identifier ]); }
[ "public", "function", "feedbackAction", "(", "Request", "$", "request", ",", "$", "id", ",", "$", "feedback", ",", "$", "domain", ",", "$", "identifier", ")", "{", "$", "locale", "=", "substr", "(", "$", "request", "->", "getLocale", "(", ")", ",", "0", ",", "2", ")", ";", "// Make sure to use only the two character locale", "$", "om", "=", "$", "this", "->", "getObjectManager", "(", ")", ";", "$", "repository", "=", "$", "om", "->", "getRepository", "(", "'TamagoTipsManagerBundle:TamagoTransUnitMeta'", ")", ";", "$", "tipMetaData", "=", "$", "repository", "->", "findOneBy", "(", "[", "'lexikTransUnitId'", "=>", "$", "id", ",", "'locale'", "=>", "$", "locale", ",", "'identifier'", "=>", "$", "identifier", "]", ")", ";", "switch", "(", "$", "feedback", ")", "{", "case", "'like'", ":", "$", "tipMetaData", "->", "setLikes", "(", "$", "tipMetaData", "->", "getLikes", "(", ")", "+", "1", ")", ";", "break", ";", "case", "'dislike'", ":", "$", "tipMetaData", "->", "setDislikes", "(", "$", "tipMetaData", "->", "getDislikes", "(", ")", "+", "1", ")", ";", "break", ";", "}", "$", "om", "->", "flush", "(", ")", ";", "$", "transUnit", "=", "$", "this", "->", "getTipTransUnit", "(", "$", "locale", ",", "$", "domain", ",", "$", "identifier", ")", ";", "$", "translatedTip", "=", "$", "transUnit", "->", "getTranslation", "(", "$", "locale", ")", ";", "return", "$", "this", "->", "render", "(", "'TamagoTipsManagerBundle:Default:tip.html.twig'", ",", "[", "'tip'", "=>", "$", "translatedTip", ",", "'identifier'", "=>", "$", "identifier", "]", ")", ";", "}" ]
Record feedback for given tip and return a new tip div block to be rendered via jQuery. @param Request $request @param $id @param $feedback @param $domain @param $identifier @return Response
[ "Record", "feedback", "for", "given", "tip", "and", "return", "a", "new", "tip", "div", "block", "to", "be", "rendered", "via", "jQuery", "." ]
3ce3be82061298426a9278682e859fde9140540a
https://github.com/tamago-db/TamagoTipsManagerBundle/blob/3ce3be82061298426a9278682e859fde9140540a/Controller/TipsManagerController.php#L98-L122
train
tamago-db/TamagoTipsManagerBundle
Controller/TipsManagerController.php
TipsManagerController.statsAction
public function statsAction() { $om = $this->getObjectManager(); $repository = $om->getRepository('TamagoTipsManagerBundle:TamagoTransUnitMeta'); $stats = $repository->stats(); return $this->render('TamagoTipsManagerBundle:Default:stats.html.twig', ['stats' => $stats]); }
php
public function statsAction() { $om = $this->getObjectManager(); $repository = $om->getRepository('TamagoTipsManagerBundle:TamagoTransUnitMeta'); $stats = $repository->stats(); return $this->render('TamagoTipsManagerBundle:Default:stats.html.twig', ['stats' => $stats]); }
[ "public", "function", "statsAction", "(", ")", "{", "$", "om", "=", "$", "this", "->", "getObjectManager", "(", ")", ";", "$", "repository", "=", "$", "om", "->", "getRepository", "(", "'TamagoTipsManagerBundle:TamagoTransUnitMeta'", ")", ";", "$", "stats", "=", "$", "repository", "->", "stats", "(", ")", ";", "return", "$", "this", "->", "render", "(", "'TamagoTipsManagerBundle:Default:stats.html.twig'", ",", "[", "'stats'", "=>", "$", "stats", "]", ")", ";", "}" ]
Render stats page. @return Response
[ "Render", "stats", "page", "." ]
3ce3be82061298426a9278682e859fde9140540a
https://github.com/tamago-db/TamagoTipsManagerBundle/blob/3ce3be82061298426a9278682e859fde9140540a/Controller/TipsManagerController.php#L129-L136
train
bseddon/XPath20
Proxy/ValueProxy.php
ValueProxy.OperatorPlus
public static function OperatorPlus( $val1, $val2 ) { if ( ! $val1 instanceof ValueProxy ) { /** * @var ValueProxyFactory $f */ $f = isset( ValueProxy::$valueFactory[ Type::FromValue( $val1 )->getTypeName() ] ) ? ValueProxy::$valueFactory[ Type::FromValue( $val1 )->getTypeName() ] : null; if ( is_null( $f ) ) return false; $val1 = $f->Create( $val1 instanceof XPath2Item ? $val1->getTypedValue() : $val1 ); } if ( ! $val2 instanceof ValueProxy ) { /** * @var ValueProxyFactory $f */ $f = isset( ValueProxy::$valueFactory[ Type::FromValue( $val2 )->getTypeName() ] ) ? ValueProxy::$valueFactory[ Type::FromValue( $val2 )->getTypeName() ] : null; if ( is_null( $f ) ) return false; $val2 = $f->Create( $val2 ); } switch ( ValueProxy::$conv_t[ $val1->GetValueCode() ][ $val2->GetValueCode() ] ) { case -1: return $val2->Promote( $val1 )->Add( $val2 ); case 0: return $val1->Add( $val2 ); case 1: return $val1->Add( $val1->Promote( $val2 ) ); default: { if ( ValueProxy::$conv_t[ $val2->GetValueCode() ][ $val1->GetValueCode() ] == 1 ) return $val2->Promote( $val1)->Add( $val2 ); throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::BinaryOperatorNotDefined, array( "op:add", SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $val1 ), XmlTypeCardinality::One ), SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $val2 ), XmlTypeCardinality::One ) ) ); } } }
php
public static function OperatorPlus( $val1, $val2 ) { if ( ! $val1 instanceof ValueProxy ) { /** * @var ValueProxyFactory $f */ $f = isset( ValueProxy::$valueFactory[ Type::FromValue( $val1 )->getTypeName() ] ) ? ValueProxy::$valueFactory[ Type::FromValue( $val1 )->getTypeName() ] : null; if ( is_null( $f ) ) return false; $val1 = $f->Create( $val1 instanceof XPath2Item ? $val1->getTypedValue() : $val1 ); } if ( ! $val2 instanceof ValueProxy ) { /** * @var ValueProxyFactory $f */ $f = isset( ValueProxy::$valueFactory[ Type::FromValue( $val2 )->getTypeName() ] ) ? ValueProxy::$valueFactory[ Type::FromValue( $val2 )->getTypeName() ] : null; if ( is_null( $f ) ) return false; $val2 = $f->Create( $val2 ); } switch ( ValueProxy::$conv_t[ $val1->GetValueCode() ][ $val2->GetValueCode() ] ) { case -1: return $val2->Promote( $val1 )->Add( $val2 ); case 0: return $val1->Add( $val2 ); case 1: return $val1->Add( $val1->Promote( $val2 ) ); default: { if ( ValueProxy::$conv_t[ $val2->GetValueCode() ][ $val1->GetValueCode() ] == 1 ) return $val2->Promote( $val1)->Add( $val2 ); throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::BinaryOperatorNotDefined, array( "op:add", SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $val1 ), XmlTypeCardinality::One ), SequenceType::WithTypeCodeAndCardinality( SequenceType::GetXmlTypeCodeFromObject( $val2 ), XmlTypeCardinality::One ) ) ); } } }
[ "public", "static", "function", "OperatorPlus", "(", "$", "val1", ",", "$", "val2", ")", "{", "if", "(", "!", "$", "val1", "instanceof", "ValueProxy", ")", "{", "/**\r\n\t\t\t * @var ValueProxyFactory $f\r\n\t\t\t */", "$", "f", "=", "isset", "(", "ValueProxy", "::", "$", "valueFactory", "[", "Type", "::", "FromValue", "(", "$", "val1", ")", "->", "getTypeName", "(", ")", "]", ")", "?", "ValueProxy", "::", "$", "valueFactory", "[", "Type", "::", "FromValue", "(", "$", "val1", ")", "->", "getTypeName", "(", ")", "]", ":", "null", ";", "if", "(", "is_null", "(", "$", "f", ")", ")", "return", "false", ";", "$", "val1", "=", "$", "f", "->", "Create", "(", "$", "val1", "instanceof", "XPath2Item", "?", "$", "val1", "->", "getTypedValue", "(", ")", ":", "$", "val1", ")", ";", "}", "if", "(", "!", "$", "val2", "instanceof", "ValueProxy", ")", "{", "/**\r\n\t\t\t * @var ValueProxyFactory $f\r\n\t\t\t */", "$", "f", "=", "isset", "(", "ValueProxy", "::", "$", "valueFactory", "[", "Type", "::", "FromValue", "(", "$", "val2", ")", "->", "getTypeName", "(", ")", "]", ")", "?", "ValueProxy", "::", "$", "valueFactory", "[", "Type", "::", "FromValue", "(", "$", "val2", ")", "->", "getTypeName", "(", ")", "]", ":", "null", ";", "if", "(", "is_null", "(", "$", "f", ")", ")", "return", "false", ";", "$", "val2", "=", "$", "f", "->", "Create", "(", "$", "val2", ")", ";", "}", "switch", "(", "ValueProxy", "::", "$", "conv_t", "[", "$", "val1", "->", "GetValueCode", "(", ")", "]", "[", "$", "val2", "->", "GetValueCode", "(", ")", "]", ")", "{", "case", "-", "1", ":", "return", "$", "val2", "->", "Promote", "(", "$", "val1", ")", "->", "Add", "(", "$", "val2", ")", ";", "case", "0", ":", "return", "$", "val1", "->", "Add", "(", "$", "val2", ")", ";", "case", "1", ":", "return", "$", "val1", "->", "Add", "(", "$", "val1", "->", "Promote", "(", "$", "val2", ")", ")", ";", "default", ":", "{", "if", "(", "ValueProxy", "::", "$", "conv_t", "[", "$", "val2", "->", "GetValueCode", "(", ")", "]", "[", "$", "val1", "->", "GetValueCode", "(", ")", "]", "==", "1", ")", "return", "$", "val2", "->", "Promote", "(", "$", "val1", ")", "->", "Add", "(", "$", "val2", ")", ";", "throw", "XPath2Exception", "::", "withErrorCodeAndParams", "(", "\"XPTY0004\"", ",", "Resources", "::", "BinaryOperatorNotDefined", ",", "array", "(", "\"op:add\"", ",", "SequenceType", "::", "WithTypeCodeAndCardinality", "(", "SequenceType", "::", "GetXmlTypeCodeFromObject", "(", "$", "val1", ")", ",", "XmlTypeCardinality", "::", "One", ")", ",", "SequenceType", "::", "WithTypeCodeAndCardinality", "(", "SequenceType", "::", "GetXmlTypeCodeFromObject", "(", "$", "val2", ")", ",", "XmlTypeCardinality", "::", "One", ")", ")", ")", ";", "}", "}", "}" ]
Equivalent of the '+' operator @param ValueProxy $val1 @param ValueProxy $val2 @return \lyquidity\XPath2\Proxy\ValueProxy
[ "Equivalent", "of", "the", "+", "operator" ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/Proxy/ValueProxy.php#L637-L690
train
gplcart/export
controllers/Export.php
Export.doExport
public function doExport() { $this->downloadCsvExport(); $settings = $this->module->getSettings('export'); if (empty($settings['columns'])) { $settings['columns'] = array_keys($settings['header']); } $this->setData('settings', $settings); $this->setData('columns', $settings['header']); $this->setData('stores', $this->store->getList()); $this->submitExport(); $this->setTitleDoExport(); $this->setBreadcrumbDoExport(); $this->outputDoExport(); }
php
public function doExport() { $this->downloadCsvExport(); $settings = $this->module->getSettings('export'); if (empty($settings['columns'])) { $settings['columns'] = array_keys($settings['header']); } $this->setData('settings', $settings); $this->setData('columns', $settings['header']); $this->setData('stores', $this->store->getList()); $this->submitExport(); $this->setTitleDoExport(); $this->setBreadcrumbDoExport(); $this->outputDoExport(); }
[ "public", "function", "doExport", "(", ")", "{", "$", "this", "->", "downloadCsvExport", "(", ")", ";", "$", "settings", "=", "$", "this", "->", "module", "->", "getSettings", "(", "'export'", ")", ";", "if", "(", "empty", "(", "$", "settings", "[", "'columns'", "]", ")", ")", "{", "$", "settings", "[", "'columns'", "]", "=", "array_keys", "(", "$", "settings", "[", "'header'", "]", ")", ";", "}", "$", "this", "->", "setData", "(", "'settings'", ",", "$", "settings", ")", ";", "$", "this", "->", "setData", "(", "'columns'", ",", "$", "settings", "[", "'header'", "]", ")", ";", "$", "this", "->", "setData", "(", "'stores'", ",", "$", "this", "->", "store", "->", "getList", "(", ")", ")", ";", "$", "this", "->", "submitExport", "(", ")", ";", "$", "this", "->", "setTitleDoExport", "(", ")", ";", "$", "this", "->", "setBreadcrumbDoExport", "(", ")", ";", "$", "this", "->", "outputDoExport", "(", ")", ";", "}" ]
Route callback to display the export page
[ "Route", "callback", "to", "display", "the", "export", "page" ]
b4d93c7a2bd6653f12231fb30d36601ea00fc926
https://github.com/gplcart/export/blob/b4d93c7a2bd6653f12231fb30d36601ea00fc926/controllers/Export.php#L41-L60
train
gplcart/export
controllers/Export.php
Export.validateFileExport
protected function validateFileExport() { $directory = gplcart_file_private_module('export'); if (!file_exists($directory) && !mkdir($directory, 0775, true)) { $this->setError('file', $this->text('Unable to create @name', array('@name' => $directory))); return false; } $date = date('d-m-Y--H-i'); $file = gplcart_file_unique("$directory/$date.csv"); if (file_put_contents($file, '') === false) { $this->setError('file', $this->text('Unable to create @name', array('@name' => $file))); return false; } $this->setSubmitted('file', $file); return true; }
php
protected function validateFileExport() { $directory = gplcart_file_private_module('export'); if (!file_exists($directory) && !mkdir($directory, 0775, true)) { $this->setError('file', $this->text('Unable to create @name', array('@name' => $directory))); return false; } $date = date('d-m-Y--H-i'); $file = gplcart_file_unique("$directory/$date.csv"); if (file_put_contents($file, '') === false) { $this->setError('file', $this->text('Unable to create @name', array('@name' => $file))); return false; } $this->setSubmitted('file', $file); return true; }
[ "protected", "function", "validateFileExport", "(", ")", "{", "$", "directory", "=", "gplcart_file_private_module", "(", "'export'", ")", ";", "if", "(", "!", "file_exists", "(", "$", "directory", ")", "&&", "!", "mkdir", "(", "$", "directory", ",", "0775", ",", "true", ")", ")", "{", "$", "this", "->", "setError", "(", "'file'", ",", "$", "this", "->", "text", "(", "'Unable to create @name'", ",", "array", "(", "'@name'", "=>", "$", "directory", ")", ")", ")", ";", "return", "false", ";", "}", "$", "date", "=", "date", "(", "'d-m-Y--H-i'", ")", ";", "$", "file", "=", "gplcart_file_unique", "(", "\"$directory/$date.csv\"", ")", ";", "if", "(", "file_put_contents", "(", "$", "file", ",", "''", ")", "===", "false", ")", "{", "$", "this", "->", "setError", "(", "'file'", ",", "$", "this", "->", "text", "(", "'Unable to create @name'", ",", "array", "(", "'@name'", "=>", "$", "file", ")", ")", ")", ";", "return", "false", ";", "}", "$", "this", "->", "setSubmitted", "(", "'file'", ",", "$", "file", ")", ";", "return", "true", ";", "}" ]
Validates destination directory and file @return boolean
[ "Validates", "destination", "directory", "and", "file" ]
b4d93c7a2bd6653f12231fb30d36601ea00fc926
https://github.com/gplcart/export/blob/b4d93c7a2bd6653f12231fb30d36601ea00fc926/controllers/Export.php#L118-L137
train
gplcart/export
controllers/Export.php
Export.setJobExport
protected function setJobExport() { $submitted = $this->getSubmitted(); $settings = $this->module->getSettings('export'); $settings['columns'] = $submitted['columns']; $settings['options'] = $submitted['options']; $this->module->setSettings('export', $settings); $data = array_merge($settings, $submitted); $data['header'] = array_intersect_key($data['header'], array_flip($data['columns'])); gplcart_file_csv($data['file'], $data['header'], $data['delimiter']); $hash = gplcart_string_encode($data['file']); $total = $this->getTotalProductExport($data['options']); $vars = array('@url' => $this->url('', array('download' => $hash)), '@num' => $total); $finish = $this->text('Exported @num items. <a href="@url">Download</a>', $vars); $job = array( 'data' => $data, 'total' => $total, 'id' => 'export_product', 'redirect_message' => array('finish' => $finish) ); $this->job->submit($job); }
php
protected function setJobExport() { $submitted = $this->getSubmitted(); $settings = $this->module->getSettings('export'); $settings['columns'] = $submitted['columns']; $settings['options'] = $submitted['options']; $this->module->setSettings('export', $settings); $data = array_merge($settings, $submitted); $data['header'] = array_intersect_key($data['header'], array_flip($data['columns'])); gplcart_file_csv($data['file'], $data['header'], $data['delimiter']); $hash = gplcart_string_encode($data['file']); $total = $this->getTotalProductExport($data['options']); $vars = array('@url' => $this->url('', array('download' => $hash)), '@num' => $total); $finish = $this->text('Exported @num items. <a href="@url">Download</a>', $vars); $job = array( 'data' => $data, 'total' => $total, 'id' => 'export_product', 'redirect_message' => array('finish' => $finish) ); $this->job->submit($job); }
[ "protected", "function", "setJobExport", "(", ")", "{", "$", "submitted", "=", "$", "this", "->", "getSubmitted", "(", ")", ";", "$", "settings", "=", "$", "this", "->", "module", "->", "getSettings", "(", "'export'", ")", ";", "$", "settings", "[", "'columns'", "]", "=", "$", "submitted", "[", "'columns'", "]", ";", "$", "settings", "[", "'options'", "]", "=", "$", "submitted", "[", "'options'", "]", ";", "$", "this", "->", "module", "->", "setSettings", "(", "'export'", ",", "$", "settings", ")", ";", "$", "data", "=", "array_merge", "(", "$", "settings", ",", "$", "submitted", ")", ";", "$", "data", "[", "'header'", "]", "=", "array_intersect_key", "(", "$", "data", "[", "'header'", "]", ",", "array_flip", "(", "$", "data", "[", "'columns'", "]", ")", ")", ";", "gplcart_file_csv", "(", "$", "data", "[", "'file'", "]", ",", "$", "data", "[", "'header'", "]", ",", "$", "data", "[", "'delimiter'", "]", ")", ";", "$", "hash", "=", "gplcart_string_encode", "(", "$", "data", "[", "'file'", "]", ")", ";", "$", "total", "=", "$", "this", "->", "getTotalProductExport", "(", "$", "data", "[", "'options'", "]", ")", ";", "$", "vars", "=", "array", "(", "'@url'", "=>", "$", "this", "->", "url", "(", "''", ",", "array", "(", "'download'", "=>", "$", "hash", ")", ")", ",", "'@num'", "=>", "$", "total", ")", ";", "$", "finish", "=", "$", "this", "->", "text", "(", "'Exported @num items. <a href=\"@url\">Download</a>'", ",", "$", "vars", ")", ";", "$", "job", "=", "array", "(", "'data'", "=>", "$", "data", ",", "'total'", "=>", "$", "total", ",", "'id'", "=>", "'export_product'", ",", "'redirect_message'", "=>", "array", "(", "'finish'", "=>", "$", "finish", ")", ")", ";", "$", "this", "->", "job", "->", "submit", "(", "$", "job", ")", ";", "}" ]
Sets up export job
[ "Sets", "up", "export", "job" ]
b4d93c7a2bd6653f12231fb30d36601ea00fc926
https://github.com/gplcart/export/blob/b4d93c7a2bd6653f12231fb30d36601ea00fc926/controllers/Export.php#L142-L171
train
gplcart/export
controllers/Export.php
Export.downloadCsvExport
protected function downloadCsvExport() { $file = $this->getQuery('download'); if (!empty($file)) { $this->download(gplcart_string_decode($file)); } }
php
protected function downloadCsvExport() { $file = $this->getQuery('download'); if (!empty($file)) { $this->download(gplcart_string_decode($file)); } }
[ "protected", "function", "downloadCsvExport", "(", ")", "{", "$", "file", "=", "$", "this", "->", "getQuery", "(", "'download'", ")", ";", "if", "(", "!", "empty", "(", "$", "file", ")", ")", "{", "$", "this", "->", "download", "(", "gplcart_string_decode", "(", "$", "file", ")", ")", ";", "}", "}" ]
Download a created CSV file
[ "Download", "a", "created", "CSV", "file" ]
b4d93c7a2bd6653f12231fb30d36601ea00fc926
https://github.com/gplcart/export/blob/b4d93c7a2bd6653f12231fb30d36601ea00fc926/controllers/Export.php#L176-L183
train
rollerworks-graveyard/metadata
src/Driver/MappingDriverChain.php
MappingDriverChain.loadMetadataForClass
public function loadMetadataForClass(\ReflectionClass $class) { foreach ($this->drivers as $driver) { if (null !== $metadata = $driver->loadMetadataForClass($class)) { return $metadata; } } }
php
public function loadMetadataForClass(\ReflectionClass $class) { foreach ($this->drivers as $driver) { if (null !== $metadata = $driver->loadMetadataForClass($class)) { return $metadata; } } }
[ "public", "function", "loadMetadataForClass", "(", "\\", "ReflectionClass", "$", "class", ")", "{", "foreach", "(", "$", "this", "->", "drivers", "as", "$", "driver", ")", "{", "if", "(", "null", "!==", "$", "metadata", "=", "$", "driver", "->", "loadMetadataForClass", "(", "$", "class", ")", ")", "{", "return", "$", "metadata", ";", "}", "}", "}" ]
Gets class metadata for the given class name. @param \ReflectionClass $class @return ClassMetadata|null Returns null when no metadata is found.
[ "Gets", "class", "metadata", "for", "the", "given", "class", "name", "." ]
5b07f564aad87709ca0d0b3e140e4dc4edf9d375
https://github.com/rollerworks-graveyard/metadata/blob/5b07f564aad87709ca0d0b3e140e4dc4edf9d375/src/Driver/MappingDriverChain.php#L38-L45
train
rollerworks-graveyard/metadata
src/Driver/MappingDriverChain.php
MappingDriverChain.isTransient
public function isTransient($className) { foreach ($this->drivers as $driver) { if (false !== $driver->isTransient($className)) { return true; } } return false; }
php
public function isTransient($className) { foreach ($this->drivers as $driver) { if (false !== $driver->isTransient($className)) { return true; } } return false; }
[ "public", "function", "isTransient", "(", "$", "className", ")", "{", "foreach", "(", "$", "this", "->", "drivers", "as", "$", "driver", ")", "{", "if", "(", "false", "!==", "$", "driver", "->", "isTransient", "(", "$", "className", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Returns whether the class with the specified name should have its metadata loaded. This can be used for cache warming, where all the class metadata gets loaded during the deployment process. @param string $className @return bool
[ "Returns", "whether", "the", "class", "with", "the", "specified", "name", "should", "have", "its", "metadata", "loaded", "." ]
5b07f564aad87709ca0d0b3e140e4dc4edf9d375
https://github.com/rollerworks-graveyard/metadata/blob/5b07f564aad87709ca0d0b3e140e4dc4edf9d375/src/Driver/MappingDriverChain.php#L74-L83
train
comodojo/foundation
src/Comodojo/Foundation/Base/AbstractVersion.php
AbstractVersion.getFullDescription
public function getFullDescription() { return strtr($this->template, [ "{name}" => $this->getName(), "{description}" => $this->getDescription(), "{version}" => $this->getVersion(), "{ascii}" => $this->getAscii() ]); }
php
public function getFullDescription() { return strtr($this->template, [ "{name}" => $this->getName(), "{description}" => $this->getDescription(), "{version}" => $this->getVersion(), "{ascii}" => $this->getAscii() ]); }
[ "public", "function", "getFullDescription", "(", ")", "{", "return", "strtr", "(", "$", "this", "->", "template", ",", "[", "\"{name}\"", "=>", "$", "this", "->", "getName", "(", ")", ",", "\"{description}\"", "=>", "$", "this", "->", "getDescription", "(", ")", ",", "\"{version}\"", "=>", "$", "this", "->", "getVersion", "(", ")", ",", "\"{ascii}\"", "=>", "$", "this", "->", "getAscii", "(", ")", "]", ")", ";", "}" ]
Return a composed-version of nominal values @return string
[ "Return", "a", "composed", "-", "version", "of", "nominal", "values" ]
21ed690e81763ed9e1ef7721a7eb4fcc0fcefc1a
https://github.com/comodojo/foundation/blob/21ed690e81763ed9e1ef7721a7eb4fcc0fcefc1a/src/Comodojo/Foundation/Base/AbstractVersion.php#L137-L146
train
agentmedia/phine-builtin
src/BuiltIn/Modules/Backend/ChangePasswordForm.php
ChangePasswordForm.AddMailSubjectField
private function AddMailSubjectField() { $name = 'MailSubject'; $field = Input::Text($name, $this->changePassword->GetMailSubject()); $this->AddField($field); $this->SetRequired($name); }
php
private function AddMailSubjectField() { $name = 'MailSubject'; $field = Input::Text($name, $this->changePassword->GetMailSubject()); $this->AddField($field); $this->SetRequired($name); }
[ "private", "function", "AddMailSubjectField", "(", ")", "{", "$", "name", "=", "'MailSubject'", ";", "$", "field", "=", "Input", "::", "Text", "(", "$", "name", ",", "$", "this", "->", "changePassword", "->", "GetMailSubject", "(", ")", ")", ";", "$", "this", "->", "AddField", "(", "$", "field", ")", ";", "$", "this", "->", "SetRequired", "(", "$", "name", ")", ";", "}" ]
Adds the field for e-mail field label
[ "Adds", "the", "field", "for", "e", "-", "mail", "field", "label" ]
4dd05bc406a71e997bd4eaa16b12e23dbe62a456
https://github.com/agentmedia/phine-builtin/blob/4dd05bc406a71e997bd4eaa16b12e23dbe62a456/src/BuiltIn/Modules/Backend/ChangePasswordForm.php#L88-L94
train
romm/configuration_object
Classes/Core/Service/ObjectService.php
ObjectService.getObjectProperty
public function getObjectProperty($object, $property) { $result = null; try { $result = ObjectAccess::getProperty($object, $property); } catch (\Exception $exception) { if (false === $exception instanceof SilentExceptionInterface) { throw $exception; } } return $result; }
php
public function getObjectProperty($object, $property) { $result = null; try { $result = ObjectAccess::getProperty($object, $property); } catch (\Exception $exception) { if (false === $exception instanceof SilentExceptionInterface) { throw $exception; } } return $result; }
[ "public", "function", "getObjectProperty", "(", "$", "object", ",", "$", "property", ")", "{", "$", "result", "=", "null", ";", "try", "{", "$", "result", "=", "ObjectAccess", "::", "getProperty", "(", "$", "object", ",", "$", "property", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "exception", ")", "{", "if", "(", "false", "===", "$", "exception", "instanceof", "SilentExceptionInterface", ")", "{", "throw", "$", "exception", ";", "}", "}", "return", "$", "result", ";", "}" ]
This function will try to get a given property for a given object. Its particularity is that if the getter method for this property is used, the method may throw an exception that implements the interface `SilentExceptionInterface`. In that case, the exception is catch and `null` is returned. This allows more flexibility for the developer, who may still throw exceptions in getter methods for implementation concerns, but these exceptions wont block Configuration Object API processing. @see \Romm\ConfigurationObject\Exceptions\SilentExceptionInterface @see \TYPO3\CMS\Extbase\Reflection\ObjectAccess::getProperty() @param object $object @param string $property @return mixed @throws \Exception
[ "This", "function", "will", "try", "to", "get", "a", "given", "property", "for", "a", "given", "object", "." ]
d3a40903386c2e0766bd8279337fe6da45cf5ce3
https://github.com/romm/configuration_object/blob/d3a40903386c2e0766bd8279337fe6da45cf5ce3/Classes/Core/Service/ObjectService.php#L42-L55
train
Polosa/shade-framework-core
app/ServiceContainer.php
ServiceContainer.isRegistered
public function isRegistered($name) { return array_key_exists($name, $this->services) || ( isset($this->serviceProviders[$name]) && $this->serviceProviders[$name] instanceof ServiceProviderInterface ); }
php
public function isRegistered($name) { return array_key_exists($name, $this->services) || ( isset($this->serviceProviders[$name]) && $this->serviceProviders[$name] instanceof ServiceProviderInterface ); }
[ "public", "function", "isRegistered", "(", "$", "name", ")", "{", "return", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "services", ")", "||", "(", "isset", "(", "$", "this", "->", "serviceProviders", "[", "$", "name", "]", ")", "&&", "$", "this", "->", "serviceProviders", "[", "$", "name", "]", "instanceof", "ServiceProviderInterface", ")", ";", "}" ]
Check if service is registered @param string $name Service name @return bool
[ "Check", "if", "service", "is", "registered" ]
d735d3e8e0616fb9cf4ffc25b8425762ed07940f
https://github.com/Polosa/shade-framework-core/blob/d735d3e8e0616fb9cf4ffc25b8425762ed07940f/app/ServiceContainer.php#L121-L129
train
rtens/mockster
src/Mockster.php
Mockster.createFactory
public static function createFactory(callable $configureMockProvider = null) { $factory = new Factory(); $provider = new MockProvider($factory); if ($configureMockProvider) { $configureMockProvider($provider); } $factory->setProvider('StdClass', $provider); return $factory; }
php
public static function createFactory(callable $configureMockProvider = null) { $factory = new Factory(); $provider = new MockProvider($factory); if ($configureMockProvider) { $configureMockProvider($provider); } $factory->setProvider('StdClass', $provider); return $factory; }
[ "public", "static", "function", "createFactory", "(", "callable", "$", "configureMockProvider", "=", "null", ")", "{", "$", "factory", "=", "new", "Factory", "(", ")", ";", "$", "provider", "=", "new", "MockProvider", "(", "$", "factory", ")", ";", "if", "(", "$", "configureMockProvider", ")", "{", "$", "configureMockProvider", "(", "$", "provider", ")", ";", "}", "$", "factory", "->", "setProvider", "(", "'StdClass'", ",", "$", "provider", ")", ";", "return", "$", "factory", ";", "}" ]
Creates a Factory with MockProvider set as default Provider @param callable $configureMockProvider Receives the MockProvider to be configured @return Factory
[ "Creates", "a", "Factory", "with", "MockProvider", "set", "as", "default", "Provider" ]
712a8a8384d7bda03ca5dea2b82d7a7a47b131fe
https://github.com/rtens/mockster/blob/712a8a8384d7bda03ca5dea2b82d7a7a47b131fe/src/Mockster.php#L50-L61
train
Talis90/HtmlMediaFinder
library/HtmlMediaFinder/ProviderHandler/streamcloud.eu/Provider.php
Provider.getDownloadUrl
function getDownloadUrl() { $inputs = self::remoteXpathQuery($this->videoUrl, '/html/body/div[3]/div[2]/div[2]/div[7]/form/input[@name]'); $postFields = []; foreach ($inputs as $input) { $postFields[$input->getAttribute('name')] = $input->getAttribute('value'); } sleep(11); //10 sek wait-time is required $scriptElements = self::remoteXpathQuery($this->videoUrl, '/html/body/div[3]/div[2]/div[2]/div[1]/script[3]', $postFields); $textContent = $scriptElements->item(0)->textContent; preg_match('/file: ".*\..*"/U', $textContent, $matches); $url = substr(reset($matches), 6); return trim($url, '"'); }
php
function getDownloadUrl() { $inputs = self::remoteXpathQuery($this->videoUrl, '/html/body/div[3]/div[2]/div[2]/div[7]/form/input[@name]'); $postFields = []; foreach ($inputs as $input) { $postFields[$input->getAttribute('name')] = $input->getAttribute('value'); } sleep(11); //10 sek wait-time is required $scriptElements = self::remoteXpathQuery($this->videoUrl, '/html/body/div[3]/div[2]/div[2]/div[1]/script[3]', $postFields); $textContent = $scriptElements->item(0)->textContent; preg_match('/file: ".*\..*"/U', $textContent, $matches); $url = substr(reset($matches), 6); return trim($url, '"'); }
[ "function", "getDownloadUrl", "(", ")", "{", "$", "inputs", "=", "self", "::", "remoteXpathQuery", "(", "$", "this", "->", "videoUrl", ",", "'/html/body/div[3]/div[2]/div[2]/div[7]/form/input[@name]'", ")", ";", "$", "postFields", "=", "[", "]", ";", "foreach", "(", "$", "inputs", "as", "$", "input", ")", "{", "$", "postFields", "[", "$", "input", "->", "getAttribute", "(", "'name'", ")", "]", "=", "$", "input", "->", "getAttribute", "(", "'value'", ")", ";", "}", "sleep", "(", "11", ")", ";", "//10 sek wait-time is required", "$", "scriptElements", "=", "self", "::", "remoteXpathQuery", "(", "$", "this", "->", "videoUrl", ",", "'/html/body/div[3]/div[2]/div[2]/div[1]/script[3]'", ",", "$", "postFields", ")", ";", "$", "textContent", "=", "$", "scriptElements", "->", "item", "(", "0", ")", "->", "textContent", ";", "preg_match", "(", "'/file: \".*\\..*\"/U'", ",", "$", "textContent", ",", "$", "matches", ")", ";", "$", "url", "=", "substr", "(", "reset", "(", "$", "matches", ")", ",", "6", ")", ";", "return", "trim", "(", "$", "url", ",", "'\"'", ")", ";", "}" ]
Special provider implementation @return string
[ "Special", "provider", "implementation" ]
fd19212a88d5d3f78d20aeea1accf7be427643b0
https://github.com/Talis90/HtmlMediaFinder/blob/fd19212a88d5d3f78d20aeea1accf7be427643b0/library/HtmlMediaFinder/ProviderHandler/streamcloud.eu/Provider.php#L16-L31
train
miaoxing/plugin
src/BaseModel.php
BaseModel.selectExcept
public function selectExcept($fields) { $fields = array_diff($this->getFields(), is_array($fields) ? $fields : [$fields]); return $this->select($fields); }
php
public function selectExcept($fields) { $fields = array_diff($this->getFields(), is_array($fields) ? $fields : [$fields]); return $this->select($fields); }
[ "public", "function", "selectExcept", "(", "$", "fields", ")", "{", "$", "fields", "=", "array_diff", "(", "$", "this", "->", "getFields", "(", ")", ",", "is_array", "(", "$", "fields", ")", "?", "$", "fields", ":", "[", "$", "fields", "]", ")", ";", "return", "$", "this", "->", "select", "(", "$", "fields", ")", ";", "}" ]
Specifies an item that is not to be returned in the query result. Replaces any previously specified selections, if any. @param string|array $fields @return $this
[ "Specifies", "an", "item", "that", "is", "not", "to", "be", "returned", "in", "the", "query", "result", ".", "Replaces", "any", "previously", "specified", "selections", "if", "any", "." ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/BaseModel.php#L527-L532
train
miaoxing/plugin
src/BaseModel.php
BaseModel.load
public function load($names) { foreach ((array) $names as $name) { // 1. Load relation config $parts = explode('.', $name, 2); $name = $parts[0]; $next = isset($parts[1]) ? $parts[1] : null; if (isset($this->loadedRelations[$name])) { continue; } /** @var BaseModel $related */ $related = $this->$name(); $isColl = $related->isColl(); $serviceName = $this->getClassServiceName($related); $relation = $this->relations[$serviceName]; // 2. Fetch relation record data $ids = $this->getAll($relation['localKey']); $ids = array_unique(array_filter($ids)); if ($ids) { $this->relatedValue = $ids; $related = $this->$name(); $this->relatedValue = null; } else { $related = null; } // 3. Load relation data if (isset($relation['junctionTable'])) { $records = $this->loadBelongsToMany($related, $relation, $name); } elseif ($isColl) { $records = $this->loadHasMany($related, $relation, $name); } else { $records = $this->loadHasOne($related, $relation, $name); } // 4. Load nested relations if ($next && $records) { $records->load($next); } $this->loadedRelations[$name] = true; } return $this; }
php
public function load($names) { foreach ((array) $names as $name) { // 1. Load relation config $parts = explode('.', $name, 2); $name = $parts[0]; $next = isset($parts[1]) ? $parts[1] : null; if (isset($this->loadedRelations[$name])) { continue; } /** @var BaseModel $related */ $related = $this->$name(); $isColl = $related->isColl(); $serviceName = $this->getClassServiceName($related); $relation = $this->relations[$serviceName]; // 2. Fetch relation record data $ids = $this->getAll($relation['localKey']); $ids = array_unique(array_filter($ids)); if ($ids) { $this->relatedValue = $ids; $related = $this->$name(); $this->relatedValue = null; } else { $related = null; } // 3. Load relation data if (isset($relation['junctionTable'])) { $records = $this->loadBelongsToMany($related, $relation, $name); } elseif ($isColl) { $records = $this->loadHasMany($related, $relation, $name); } else { $records = $this->loadHasOne($related, $relation, $name); } // 4. Load nested relations if ($next && $records) { $records->load($next); } $this->loadedRelations[$name] = true; } return $this; }
[ "public", "function", "load", "(", "$", "names", ")", "{", "foreach", "(", "(", "array", ")", "$", "names", "as", "$", "name", ")", "{", "// 1. Load relation config", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "name", ",", "2", ")", ";", "$", "name", "=", "$", "parts", "[", "0", "]", ";", "$", "next", "=", "isset", "(", "$", "parts", "[", "1", "]", ")", "?", "$", "parts", "[", "1", "]", ":", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "loadedRelations", "[", "$", "name", "]", ")", ")", "{", "continue", ";", "}", "/** @var BaseModel $related */", "$", "related", "=", "$", "this", "->", "$", "name", "(", ")", ";", "$", "isColl", "=", "$", "related", "->", "isColl", "(", ")", ";", "$", "serviceName", "=", "$", "this", "->", "getClassServiceName", "(", "$", "related", ")", ";", "$", "relation", "=", "$", "this", "->", "relations", "[", "$", "serviceName", "]", ";", "// 2. Fetch relation record data", "$", "ids", "=", "$", "this", "->", "getAll", "(", "$", "relation", "[", "'localKey'", "]", ")", ";", "$", "ids", "=", "array_unique", "(", "array_filter", "(", "$", "ids", ")", ")", ";", "if", "(", "$", "ids", ")", "{", "$", "this", "->", "relatedValue", "=", "$", "ids", ";", "$", "related", "=", "$", "this", "->", "$", "name", "(", ")", ";", "$", "this", "->", "relatedValue", "=", "null", ";", "}", "else", "{", "$", "related", "=", "null", ";", "}", "// 3. Load relation data", "if", "(", "isset", "(", "$", "relation", "[", "'junctionTable'", "]", ")", ")", "{", "$", "records", "=", "$", "this", "->", "loadBelongsToMany", "(", "$", "related", ",", "$", "relation", ",", "$", "name", ")", ";", "}", "elseif", "(", "$", "isColl", ")", "{", "$", "records", "=", "$", "this", "->", "loadHasMany", "(", "$", "related", ",", "$", "relation", ",", "$", "name", ")", ";", "}", "else", "{", "$", "records", "=", "$", "this", "->", "loadHasOne", "(", "$", "related", ",", "$", "relation", ",", "$", "name", ")", ";", "}", "// 4. Load nested relations", "if", "(", "$", "next", "&&", "$", "records", ")", "{", "$", "records", "->", "load", "(", "$", "next", ")", ";", "}", "$", "this", "->", "loadedRelations", "[", "$", "name", "]", "=", "true", ";", "}", "return", "$", "this", ";", "}" ]
Eager load relations @param string|array $names @return $this|$this[]
[ "Eager", "load", "relations" ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/BaseModel.php#L722-L768
train
miaoxing/plugin
src/BaseModel.php
BaseModel.snake
protected function snake($input) { if (isset(static::$snakeCache[$input])) { return static::$snakeCache[$input]; } $value = $input; if (!ctype_lower($input)) { $value = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $input)); } return static::$snakeCache[$input] = $value; }
php
protected function snake($input) { if (isset(static::$snakeCache[$input])) { return static::$snakeCache[$input]; } $value = $input; if (!ctype_lower($input)) { $value = strtolower(preg_replace('/(?<!^)[A-Z]/', '_$0', $input)); } return static::$snakeCache[$input] = $value; }
[ "protected", "function", "snake", "(", "$", "input", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "snakeCache", "[", "$", "input", "]", ")", ")", "{", "return", "static", "::", "$", "snakeCache", "[", "$", "input", "]", ";", "}", "$", "value", "=", "$", "input", ";", "if", "(", "!", "ctype_lower", "(", "$", "input", ")", ")", "{", "$", "value", "=", "strtolower", "(", "preg_replace", "(", "'/(?<!^)[A-Z]/'", ",", "'_$0'", ",", "$", "input", ")", ")", ";", "}", "return", "static", "::", "$", "snakeCache", "[", "$", "input", "]", "=", "$", "value", ";", "}" ]
Convert a input to snake case @param string $input @return string
[ "Convert", "a", "input", "to", "snake", "case" ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/BaseModel.php#L840-L852
train
miaoxing/plugin
src/BaseModel.php
BaseModel.camel
protected function camel($input) { if (isset(static::$camelCache[$input])) { return static::$camelCache[$input]; } return static::$camelCache[$input] = lcfirst(str_replace(' ', '', ucwords(strtr($input, '_-', ' ')))); }
php
protected function camel($input) { if (isset(static::$camelCache[$input])) { return static::$camelCache[$input]; } return static::$camelCache[$input] = lcfirst(str_replace(' ', '', ucwords(strtr($input, '_-', ' ')))); }
[ "protected", "function", "camel", "(", "$", "input", ")", "{", "if", "(", "isset", "(", "static", "::", "$", "camelCache", "[", "$", "input", "]", ")", ")", "{", "return", "static", "::", "$", "camelCache", "[", "$", "input", "]", ";", "}", "return", "static", "::", "$", "camelCache", "[", "$", "input", "]", "=", "lcfirst", "(", "str_replace", "(", "' '", ",", "''", ",", "ucwords", "(", "strtr", "(", "$", "input", ",", "'_-'", ",", "' '", ")", ")", ")", ")", ";", "}" ]
Convert a input to camel case @param string $input @return string
[ "Convert", "a", "input", "to", "camel", "case" ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/BaseModel.php#L860-L867
train
miaoxing/plugin
src/BaseModel.php
BaseModel.hasColumn
public function hasColumn($name) { $name = $this->filterInputColumn($name); return in_array($name, $this->getFields()); }
php
public function hasColumn($name) { $name = $this->filterInputColumn($name); return in_array($name, $this->getFields()); }
[ "public", "function", "hasColumn", "(", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "filterInputColumn", "(", "$", "name", ")", ";", "return", "in_array", "(", "$", "name", ",", "$", "this", "->", "getFields", "(", ")", ")", ";", "}" ]
Check if column name exists @param string $name @return bool
[ "Check", "if", "column", "name", "exists" ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/BaseModel.php#L963-L968
train
miaoxing/plugin
src/BaseModel.php
BaseModel.isChanged
public function isChanged($field = null) { if ($field) { $field = $this->filterInputColumn($field); return array_key_exists($field, $this->changedData); } return $this->isChanged; }
php
public function isChanged($field = null) { if ($field) { $field = $this->filterInputColumn($field); return array_key_exists($field, $this->changedData); } return $this->isChanged; }
[ "public", "function", "isChanged", "(", "$", "field", "=", "null", ")", "{", "if", "(", "$", "field", ")", "{", "$", "field", "=", "$", "this", "->", "filterInputColumn", "(", "$", "field", ")", ";", "return", "array_key_exists", "(", "$", "field", ",", "$", "this", "->", "changedData", ")", ";", "}", "return", "$", "this", "->", "isChanged", ";", "}" ]
Check if the record's data or specified field is changed @param string $field @return bool
[ "Check", "if", "the", "record", "s", "data", "or", "specified", "field", "is", "changed" ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/BaseModel.php#L1058-L1065
train
miaoxing/plugin
src/BaseModel.php
BaseModel.toRet
public function toRet(array $merge = []) { if ($this->isColl()) { return $this->suc($merge + [ 'data' => $this, 'page' => $this->getSqlPart('page'), 'rows' => $this->getSqlPart('limit'), 'records' => $this->count(), ]); } else { return $this->suc($merge + ['data' => $this]); } }
php
public function toRet(array $merge = []) { if ($this->isColl()) { return $this->suc($merge + [ 'data' => $this, 'page' => $this->getSqlPart('page'), 'rows' => $this->getSqlPart('limit'), 'records' => $this->count(), ]); } else { return $this->suc($merge + ['data' => $this]); } }
[ "public", "function", "toRet", "(", "array", "$", "merge", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "isColl", "(", ")", ")", "{", "return", "$", "this", "->", "suc", "(", "$", "merge", "+", "[", "'data'", "=>", "$", "this", ",", "'page'", "=>", "$", "this", "->", "getSqlPart", "(", "'page'", ")", ",", "'rows'", "=>", "$", "this", "->", "getSqlPart", "(", "'limit'", ")", ",", "'records'", "=>", "$", "this", "->", "count", "(", ")", ",", "]", ")", ";", "}", "else", "{", "return", "$", "this", "->", "suc", "(", "$", "merge", "+", "[", "'data'", "=>", "$", "this", "]", ")", ";", "}", "}" ]
Returns the success result with model data @param array $merge @return array
[ "Returns", "the", "success", "result", "with", "model", "data" ]
f287a1e6c97abba6f06906255b8c26e8ab0afe61
https://github.com/miaoxing/plugin/blob/f287a1e6c97abba6f06906255b8c26e8ab0afe61/src/BaseModel.php#L1118-L1130
train
DreadLabs/VantomasWebsite
src/Disqus/Resource/AbstractResource.php
AbstractResource.getPath
public function getPath(array $parameters) { foreach ($parameters as $parameterName => $parameterValue) { $parameterMethod = 'set' . ucfirst($parameterName); $this->$parameterMethod($parameterValue); } return $this->buildPath(); }
php
public function getPath(array $parameters) { foreach ($parameters as $parameterName => $parameterValue) { $parameterMethod = 'set' . ucfirst($parameterName); $this->$parameterMethod($parameterValue); } return $this->buildPath(); }
[ "public", "function", "getPath", "(", "array", "$", "parameters", ")", "{", "foreach", "(", "$", "parameters", "as", "$", "parameterName", "=>", "$", "parameterValue", ")", "{", "$", "parameterMethod", "=", "'set'", ".", "ucfirst", "(", "$", "parameterName", ")", ";", "$", "this", "->", "$", "parameterMethod", "(", "$", "parameterValue", ")", ";", "}", "return", "$", "this", "->", "buildPath", "(", ")", ";", "}" ]
returns the resource path which is usable by a client @param array $parameters @return string A API query string
[ "returns", "the", "resource", "path", "which", "is", "usable", "by", "a", "client" ]
7f85f2b45bdf5ed9fa9d320c805c416bf99cd668
https://github.com/DreadLabs/VantomasWebsite/blob/7f85f2b45bdf5ed9fa9d320c805c416bf99cd668/src/Disqus/Resource/AbstractResource.php#L51-L60
train
DreadLabs/VantomasWebsite
src/Disqus/Resource/AbstractResource.php
AbstractResource.buildPath
protected function buildPath() { $urlParameters = array(); $parameters = get_object_vars($this); foreach ($parameters as $parameterName => $parameterValue) { if (true === is_null($parameterValue)) { continue; } if ($parameterName === 'apiKey') { $parameterName = 'api_key'; } $urlParameters[] = $this->getPathPartForParameter($parameterName, $parameterValue); } return implode('&', $urlParameters); }
php
protected function buildPath() { $urlParameters = array(); $parameters = get_object_vars($this); foreach ($parameters as $parameterName => $parameterValue) { if (true === is_null($parameterValue)) { continue; } if ($parameterName === 'apiKey') { $parameterName = 'api_key'; } $urlParameters[] = $this->getPathPartForParameter($parameterName, $parameterValue); } return implode('&', $urlParameters); }
[ "protected", "function", "buildPath", "(", ")", "{", "$", "urlParameters", "=", "array", "(", ")", ";", "$", "parameters", "=", "get_object_vars", "(", "$", "this", ")", ";", "foreach", "(", "$", "parameters", "as", "$", "parameterName", "=>", "$", "parameterValue", ")", "{", "if", "(", "true", "===", "is_null", "(", "$", "parameterValue", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "parameterName", "===", "'apiKey'", ")", "{", "$", "parameterName", "=", "'api_key'", ";", "}", "$", "urlParameters", "[", "]", "=", "$", "this", "->", "getPathPartForParameter", "(", "$", "parameterName", ",", "$", "parameterValue", ")", ";", "}", "return", "implode", "(", "'&'", ",", "$", "urlParameters", ")", ";", "}" ]
builds a API query string path @return string
[ "builds", "a", "API", "query", "string", "path" ]
7f85f2b45bdf5ed9fa9d320c805c416bf99cd668
https://github.com/DreadLabs/VantomasWebsite/blob/7f85f2b45bdf5ed9fa9d320c805c416bf99cd668/src/Disqus/Resource/AbstractResource.php#L67-L85
train
DreadLabs/VantomasWebsite
src/Disqus/Resource/AbstractResource.php
AbstractResource.getArrayPathParameter
protected function getArrayPathParameter($parameterName, array $parameterValue) { $urlParameter = array(); foreach ($parameterValue as $parameterValueValue) { $urlParameter[] = $this->getPathParameter($parameterName, $parameterValueValue); } return implode('&', $urlParameter); }
php
protected function getArrayPathParameter($parameterName, array $parameterValue) { $urlParameter = array(); foreach ($parameterValue as $parameterValueValue) { $urlParameter[] = $this->getPathParameter($parameterName, $parameterValueValue); } return implode('&', $urlParameter); }
[ "protected", "function", "getArrayPathParameter", "(", "$", "parameterName", ",", "array", "$", "parameterValue", ")", "{", "$", "urlParameter", "=", "array", "(", ")", ";", "foreach", "(", "$", "parameterValue", "as", "$", "parameterValueValue", ")", "{", "$", "urlParameter", "[", "]", "=", "$", "this", "->", "getPathParameter", "(", "$", "parameterName", ",", "$", "parameterValueValue", ")", ";", "}", "return", "implode", "(", "'&'", ",", "$", "urlParameter", ")", ";", "}" ]
iterates over an array parameter value @param string $parameterName @param array $parameterValue @return string
[ "iterates", "over", "an", "array", "parameter", "value" ]
7f85f2b45bdf5ed9fa9d320c805c416bf99cd668
https://github.com/DreadLabs/VantomasWebsite/blob/7f85f2b45bdf5ed9fa9d320c805c416bf99cd668/src/Disqus/Resource/AbstractResource.php#L158-L167
train
Palmabit-IT/library
src/Palmabit/Library/Models/SingleTableInheritance.php
SingleTableInheritance.prepareAllAttributes
protected function prepareAllAttributes() { static::$all_attributes = static::$my_attributes; $parent = get_class($this); while (($parent = get_parent_class($parent)) != 'Palmabit\Library\Models\SingleTableInheritance') { static::$all_attributes = array_merge(static::$all_attributes, $parent::$my_attributes); } }
php
protected function prepareAllAttributes() { static::$all_attributes = static::$my_attributes; $parent = get_class($this); while (($parent = get_parent_class($parent)) != 'Palmabit\Library\Models\SingleTableInheritance') { static::$all_attributes = array_merge(static::$all_attributes, $parent::$my_attributes); } }
[ "protected", "function", "prepareAllAttributes", "(", ")", "{", "static", "::", "$", "all_attributes", "=", "static", "::", "$", "my_attributes", ";", "$", "parent", "=", "get_class", "(", "$", "this", ")", ";", "while", "(", "(", "$", "parent", "=", "get_parent_class", "(", "$", "parent", ")", ")", "!=", "'Palmabit\\Library\\Models\\SingleTableInheritance'", ")", "{", "static", "::", "$", "all_attributes", "=", "array_merge", "(", "static", "::", "$", "all_attributes", ",", "$", "parent", "::", "$", "my_attributes", ")", ";", "}", "}" ]
Fill the array containing all the attributes that belongs to the class @return void
[ "Fill", "the", "array", "containing", "all", "the", "attributes", "that", "belongs", "to", "the", "class" ]
ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9
https://github.com/Palmabit-IT/library/blob/ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9/src/Palmabit/Library/Models/SingleTableInheritance.php#L67-L73
train
Palmabit-IT/library
src/Palmabit/Library/Models/SingleTableInheritance.php
SingleTableInheritance.newQuery
public function newQuery($excludeDeleted = true) { $builder = parent::newQuery($excludeDeleted); $builder->where(static::$table_type_field, '=', $this->table_type); return $builder; }
php
public function newQuery($excludeDeleted = true) { $builder = parent::newQuery($excludeDeleted); $builder->where(static::$table_type_field, '=', $this->table_type); return $builder; }
[ "public", "function", "newQuery", "(", "$", "excludeDeleted", "=", "true", ")", "{", "$", "builder", "=", "parent", "::", "newQuery", "(", "$", "excludeDeleted", ")", ";", "$", "builder", "->", "where", "(", "static", "::", "$", "table_type_field", ",", "'='", ",", "$", "this", "->", "table_type", ")", ";", "return", "$", "builder", ";", "}" ]
Update newQuery to fetch data of the right type @param boolean $getOnlyMyType @param bool $excludeDeleted @return \Illuminate\Database\Eloquent\Builder|static
[ "Update", "newQuery", "to", "fetch", "data", "of", "the", "right", "type" ]
ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9
https://github.com/Palmabit-IT/library/blob/ec49a3c333eb4e94d9610a0f58d82c9ea1ade4b9/src/Palmabit/Library/Models/SingleTableInheritance.php#L122-L127
train
gingerwfms/ginger-core
src/GingerCore/Repository/AbstractCrudRepository.php
AbstractCrudRepository.delete
public function delete(Resource\ResourceId $resourceId) { $this->crudRepositoryAdapter->deleteResource($this->resourceType, $resourceId); }
php
public function delete(Resource\ResourceId $resourceId) { $this->crudRepositoryAdapter->deleteResource($this->resourceType, $resourceId); }
[ "public", "function", "delete", "(", "Resource", "\\", "ResourceId", "$", "resourceId", ")", "{", "$", "this", "->", "crudRepositoryAdapter", "->", "deleteResource", "(", "$", "this", "->", "resourceType", ",", "$", "resourceId", ")", ";", "}" ]
Delete Resource by it's resource id @param Resource\ResourceId $resourceId @return void @throws \GingerCore\Exception\RuntimeException If deletion could not be performed
[ "Delete", "Resource", "by", "it", "s", "resource", "id" ]
178e699dd1a912ec7b8b4e21f7de51edd2a1c1e8
https://github.com/gingerwfms/ginger-core/blob/178e699dd1a912ec7b8b4e21f7de51edd2a1c1e8/src/GingerCore/Repository/AbstractCrudRepository.php#L66-L69
train
gingerwfms/ginger-core
src/GingerCore/Repository/AbstractCrudRepository.php
AbstractCrudRepository.update
public function update(Resource\ResourceData $resourceData) { return $this->crudRepositoryAdapter->updateResource($this->resourceType, $resourceData); }
php
public function update(Resource\ResourceData $resourceData) { return $this->crudRepositoryAdapter->updateResource($this->resourceType, $resourceData); }
[ "public", "function", "update", "(", "Resource", "\\", "ResourceData", "$", "resourceData", ")", "{", "return", "$", "this", "->", "crudRepositoryAdapter", "->", "updateResource", "(", "$", "this", "->", "resourceType", ",", "$", "resourceData", ")", ";", "}" ]
Update resource data @param Resource\ResourceData $resourceData Contains all data that should be updated @return Resource\ResourceData All data of resource including the updated properties @throws \GingerCore\Exception\RuntimeException If update could not be performed
[ "Update", "resource", "data" ]
178e699dd1a912ec7b8b4e21f7de51edd2a1c1e8
https://github.com/gingerwfms/ginger-core/blob/178e699dd1a912ec7b8b4e21f7de51edd2a1c1e8/src/GingerCore/Repository/AbstractCrudRepository.php#L80-L83
train
gingerwfms/ginger-core
src/GingerCore/Repository/AbstractCrudRepository.php
AbstractCrudRepository.read
public function read(Resource\ResourceId $resourceId) { return $this->crudRepositoryAdapter->getResource($this->resourceType, $resourceId); }
php
public function read(Resource\ResourceId $resourceId) { return $this->crudRepositoryAdapter->getResource($this->resourceType, $resourceId); }
[ "public", "function", "read", "(", "Resource", "\\", "ResourceId", "$", "resourceId", ")", "{", "return", "$", "this", "->", "crudRepositoryAdapter", "->", "getResource", "(", "$", "this", "->", "resourceType", ",", "$", "resourceId", ")", ";", "}" ]
Read data for a single resource @param Resource\ResourceId $resourceId @return ResourceData|null
[ "Read", "data", "for", "a", "single", "resource" ]
178e699dd1a912ec7b8b4e21f7de51edd2a1c1e8
https://github.com/gingerwfms/ginger-core/blob/178e699dd1a912ec7b8b4e21f7de51edd2a1c1e8/src/GingerCore/Repository/AbstractCrudRepository.php#L92-L95
train
stubbles/stubbles-dbal
src/main/php/pdo/PdoQueryResult.php
PdoQueryResult.bindColumn
public function bindColumn($column, &$variable, $type = null): bool { try { return $this->pdoStatement->bindColumn($column, $variable, $type, null, null); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
php
public function bindColumn($column, &$variable, $type = null): bool { try { return $this->pdoStatement->bindColumn($column, $variable, $type, null, null); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
[ "public", "function", "bindColumn", "(", "$", "column", ",", "&", "$", "variable", ",", "$", "type", "=", "null", ")", ":", "bool", "{", "try", "{", "return", "$", "this", "->", "pdoStatement", "->", "bindColumn", "(", "$", "column", ",", "$", "variable", ",", "$", "type", ",", "null", ",", "null", ")", ";", "}", "catch", "(", "PDOException", "$", "pdoe", ")", "{", "throw", "new", "DatabaseException", "(", "$", "pdoe", "->", "getMessage", "(", ")", ",", "$", "pdoe", ")", ";", "}", "}" ]
bind a result column to a variable @param int|string $column column number or name to bind the variable to @param mixed &$variable the variable to bind to the column @param int|string $type optional type of the binded variable @return bool true on success, false on failure @throws \stubbles\db\DatabaseException @see http://php.net/pdostatement-bindColumn
[ "bind", "a", "result", "column", "to", "a", "variable" ]
b42a589025a9e511b40a2798ac84df94d6451c36
https://github.com/stubbles/stubbles-dbal/blob/b42a589025a9e511b40a2798ac84df94d6451c36/src/main/php/pdo/PdoQueryResult.php#L50-L57
train
stubbles/stubbles-dbal
src/main/php/pdo/PdoQueryResult.php
PdoQueryResult.fetch
public function fetch(int $fetchMode = null, array $driverOptions = []) { if (null === $fetchMode) { $fetchMode = PDO::FETCH_ASSOC; } try { return $this->pdoStatement->fetch( $fetchMode, $driverOptions['cursorOrientation'] ?? null, $driverOptions['cursorOffset'] ?? null ); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
php
public function fetch(int $fetchMode = null, array $driverOptions = []) { if (null === $fetchMode) { $fetchMode = PDO::FETCH_ASSOC; } try { return $this->pdoStatement->fetch( $fetchMode, $driverOptions['cursorOrientation'] ?? null, $driverOptions['cursorOffset'] ?? null ); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
[ "public", "function", "fetch", "(", "int", "$", "fetchMode", "=", "null", ",", "array", "$", "driverOptions", "=", "[", "]", ")", "{", "if", "(", "null", "===", "$", "fetchMode", ")", "{", "$", "fetchMode", "=", "PDO", "::", "FETCH_ASSOC", ";", "}", "try", "{", "return", "$", "this", "->", "pdoStatement", "->", "fetch", "(", "$", "fetchMode", ",", "$", "driverOptions", "[", "'cursorOrientation'", "]", "??", "null", ",", "$", "driverOptions", "[", "'cursorOffset'", "]", "??", "null", ")", ";", "}", "catch", "(", "PDOException", "$", "pdoe", ")", "{", "throw", "new", "DatabaseException", "(", "$", "pdoe", "->", "getMessage", "(", ")", ",", "$", "pdoe", ")", ";", "}", "}" ]
fetch a result @param int $fetchMode optional the mode to use for fetching the data @param array $driverOptions optional driver specific arguments @return mixed @throws \stubbles\db\DatabaseException @see http://php.net/pdostatement-fetch
[ "fetch", "a", "result" ]
b42a589025a9e511b40a2798ac84df94d6451c36
https://github.com/stubbles/stubbles-dbal/blob/b42a589025a9e511b40a2798ac84df94d6451c36/src/main/php/pdo/PdoQueryResult.php#L68-L83
train
stubbles/stubbles-dbal
src/main/php/pdo/PdoQueryResult.php
PdoQueryResult.fetchOne
public function fetchOne(int $columnNumber = 0) { try { return $this->pdoStatement->fetchColumn($columnNumber); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
php
public function fetchOne(int $columnNumber = 0) { try { return $this->pdoStatement->fetchColumn($columnNumber); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
[ "public", "function", "fetchOne", "(", "int", "$", "columnNumber", "=", "0", ")", "{", "try", "{", "return", "$", "this", "->", "pdoStatement", "->", "fetchColumn", "(", "$", "columnNumber", ")", ";", "}", "catch", "(", "PDOException", "$", "pdoe", ")", "{", "throw", "new", "DatabaseException", "(", "$", "pdoe", "->", "getMessage", "(", ")", ",", "$", "pdoe", ")", ";", "}", "}" ]
fetch single column from the next row from a result set @param int $columnNumber optional the column number to fetch, default is first column @return string|false @throws \stubbles\db\DatabaseException @see http://php.net/pdostatement-fetchColumn
[ "fetch", "single", "column", "from", "the", "next", "row", "from", "a", "result", "set" ]
b42a589025a9e511b40a2798ac84df94d6451c36
https://github.com/stubbles/stubbles-dbal/blob/b42a589025a9e511b40a2798ac84df94d6451c36/src/main/php/pdo/PdoQueryResult.php#L93-L100
train
stubbles/stubbles-dbal
src/main/php/pdo/PdoQueryResult.php
PdoQueryResult.fetchAll
public function fetchAll(int $fetchMode = null, array $driverOptions = []): array { try { if (null === $fetchMode) { return $this->pdoStatement->fetchAll(); } if (PDO::FETCH_COLUMN == $fetchMode) { return $this->pdoStatement->fetchAll( PDO::FETCH_COLUMN, $driverOptions['columnIndex'] ?? 0 ); } if (PDO::FETCH_CLASS == $fetchMode) { if (!isset($driverOptions['classname'])) { throw new \InvalidArgumentException('Tried to use PDO::FETCH_CLASS but no classname given in driver options.'); } return $this->pdoStatement->fetchAll( PDO::FETCH_CLASS, $driverOptions['classname'], $driverOptions['arguments'] ?? null ); } if (PDO::FETCH_FUNC == $fetchMode) { if (!isset($driverOptions['function'])) { throw new \InvalidArgumentException('Tried to use PDO::FETCH_FUNC but no function given in driver options.'); } return $this->pdoStatement->fetchAll( PDO::FETCH_FUNC, $driverOptions['function'] ); } return $this->pdoStatement->fetchAll($fetchMode); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
php
public function fetchAll(int $fetchMode = null, array $driverOptions = []): array { try { if (null === $fetchMode) { return $this->pdoStatement->fetchAll(); } if (PDO::FETCH_COLUMN == $fetchMode) { return $this->pdoStatement->fetchAll( PDO::FETCH_COLUMN, $driverOptions['columnIndex'] ?? 0 ); } if (PDO::FETCH_CLASS == $fetchMode) { if (!isset($driverOptions['classname'])) { throw new \InvalidArgumentException('Tried to use PDO::FETCH_CLASS but no classname given in driver options.'); } return $this->pdoStatement->fetchAll( PDO::FETCH_CLASS, $driverOptions['classname'], $driverOptions['arguments'] ?? null ); } if (PDO::FETCH_FUNC == $fetchMode) { if (!isset($driverOptions['function'])) { throw new \InvalidArgumentException('Tried to use PDO::FETCH_FUNC but no function given in driver options.'); } return $this->pdoStatement->fetchAll( PDO::FETCH_FUNC, $driverOptions['function'] ); } return $this->pdoStatement->fetchAll($fetchMode); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
[ "public", "function", "fetchAll", "(", "int", "$", "fetchMode", "=", "null", ",", "array", "$", "driverOptions", "=", "[", "]", ")", ":", "array", "{", "try", "{", "if", "(", "null", "===", "$", "fetchMode", ")", "{", "return", "$", "this", "->", "pdoStatement", "->", "fetchAll", "(", ")", ";", "}", "if", "(", "PDO", "::", "FETCH_COLUMN", "==", "$", "fetchMode", ")", "{", "return", "$", "this", "->", "pdoStatement", "->", "fetchAll", "(", "PDO", "::", "FETCH_COLUMN", ",", "$", "driverOptions", "[", "'columnIndex'", "]", "??", "0", ")", ";", "}", "if", "(", "PDO", "::", "FETCH_CLASS", "==", "$", "fetchMode", ")", "{", "if", "(", "!", "isset", "(", "$", "driverOptions", "[", "'classname'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Tried to use PDO::FETCH_CLASS but no classname given in driver options.'", ")", ";", "}", "return", "$", "this", "->", "pdoStatement", "->", "fetchAll", "(", "PDO", "::", "FETCH_CLASS", ",", "$", "driverOptions", "[", "'classname'", "]", ",", "$", "driverOptions", "[", "'arguments'", "]", "??", "null", ")", ";", "}", "if", "(", "PDO", "::", "FETCH_FUNC", "==", "$", "fetchMode", ")", "{", "if", "(", "!", "isset", "(", "$", "driverOptions", "[", "'function'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Tried to use PDO::FETCH_FUNC but no function given in driver options.'", ")", ";", "}", "return", "$", "this", "->", "pdoStatement", "->", "fetchAll", "(", "PDO", "::", "FETCH_FUNC", ",", "$", "driverOptions", "[", "'function'", "]", ")", ";", "}", "return", "$", "this", "->", "pdoStatement", "->", "fetchAll", "(", "$", "fetchMode", ")", ";", "}", "catch", "(", "PDOException", "$", "pdoe", ")", "{", "throw", "new", "DatabaseException", "(", "$", "pdoe", "->", "getMessage", "(", ")", ",", "$", "pdoe", ")", ";", "}", "}" ]
returns an array containing all of the result set rows @param int $fetchMode optional the mode to use for fetching the data @param array $driverOptions optional driver specific arguments @return array @throws \stubbles\db\DatabaseException @throws \InvalidArgumentException @see http://php.net/pdostatement-fetchAll
[ "returns", "an", "array", "containing", "all", "of", "the", "result", "set", "rows" ]
b42a589025a9e511b40a2798ac84df94d6451c36
https://github.com/stubbles/stubbles-dbal/blob/b42a589025a9e511b40a2798ac84df94d6451c36/src/main/php/pdo/PdoQueryResult.php#L112-L153
train
stubbles/stubbles-dbal
src/main/php/pdo/PdoQueryResult.php
PdoQueryResult.next
public function next(): bool { try { return $this->pdoStatement->nextRowset(); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
php
public function next(): bool { try { return $this->pdoStatement->nextRowset(); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
[ "public", "function", "next", "(", ")", ":", "bool", "{", "try", "{", "return", "$", "this", "->", "pdoStatement", "->", "nextRowset", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "pdoe", ")", "{", "throw", "new", "DatabaseException", "(", "$", "pdoe", "->", "getMessage", "(", ")", ",", "$", "pdoe", ")", ";", "}", "}" ]
moves the internal result pointer to the next result row @return bool true on success, false on failure @throws \stubbles\db\DatabaseException @see http://php.net/pdostatement-nextRowset
[ "moves", "the", "internal", "result", "pointer", "to", "the", "next", "result", "row" ]
b42a589025a9e511b40a2798ac84df94d6451c36
https://github.com/stubbles/stubbles-dbal/blob/b42a589025a9e511b40a2798ac84df94d6451c36/src/main/php/pdo/PdoQueryResult.php#L162-L169
train
stubbles/stubbles-dbal
src/main/php/pdo/PdoQueryResult.php
PdoQueryResult.count
public function count(): int { try { return $this->pdoStatement->rowCount(); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
php
public function count(): int { try { return $this->pdoStatement->rowCount(); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
[ "public", "function", "count", "(", ")", ":", "int", "{", "try", "{", "return", "$", "this", "->", "pdoStatement", "->", "rowCount", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "pdoe", ")", "{", "throw", "new", "DatabaseException", "(", "$", "pdoe", "->", "getMessage", "(", ")", ",", "$", "pdoe", ")", ";", "}", "}" ]
returns the number of rows affected by the last SQL statement @return int @throws \stubbles\db\DatabaseException @see http://php.net/pdostatement-rowCount
[ "returns", "the", "number", "of", "rows", "affected", "by", "the", "last", "SQL", "statement" ]
b42a589025a9e511b40a2798ac84df94d6451c36
https://github.com/stubbles/stubbles-dbal/blob/b42a589025a9e511b40a2798ac84df94d6451c36/src/main/php/pdo/PdoQueryResult.php#L178-L185
train
stubbles/stubbles-dbal
src/main/php/pdo/PdoQueryResult.php
PdoQueryResult.free
public function free(): bool { try { return $this->pdoStatement->closeCursor(); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
php
public function free(): bool { try { return $this->pdoStatement->closeCursor(); } catch (PDOException $pdoe) { throw new DatabaseException($pdoe->getMessage(), $pdoe); } }
[ "public", "function", "free", "(", ")", ":", "bool", "{", "try", "{", "return", "$", "this", "->", "pdoStatement", "->", "closeCursor", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "pdoe", ")", "{", "throw", "new", "DatabaseException", "(", "$", "pdoe", "->", "getMessage", "(", ")", ",", "$", "pdoe", ")", ";", "}", "}" ]
releases resources allocated of the result set @return bool true on success, false on failure @throws \stubbles\db\DatabaseException @see http://php.net/pdostatement-closeCursor
[ "releases", "resources", "allocated", "of", "the", "result", "set" ]
b42a589025a9e511b40a2798ac84df94d6451c36
https://github.com/stubbles/stubbles-dbal/blob/b42a589025a9e511b40a2798ac84df94d6451c36/src/main/php/pdo/PdoQueryResult.php#L194-L201
train
PenoaksDev/Milky-Framework
src/Milky/Http/View/ViewFactory.php
ViewFactory.parseClassEvent
protected function parseClassEvent( $class, $prefix ) { if ( Str::contains( $class, '@' ) ) return explode( '@', $class ); $method = Str::contains( $prefix, 'composing' ) ? 'compose' : 'create'; return [$class, $method]; }
php
protected function parseClassEvent( $class, $prefix ) { if ( Str::contains( $class, '@' ) ) return explode( '@', $class ); $method = Str::contains( $prefix, 'composing' ) ? 'compose' : 'create'; return [$class, $method]; }
[ "protected", "function", "parseClassEvent", "(", "$", "class", ",", "$", "prefix", ")", "{", "if", "(", "Str", "::", "contains", "(", "$", "class", ",", "'@'", ")", ")", "return", "explode", "(", "'@'", ",", "$", "class", ")", ";", "$", "method", "=", "Str", "::", "contains", "(", "$", "prefix", ",", "'composing'", ")", "?", "'compose'", ":", "'create'", ";", "return", "[", "$", "class", ",", "$", "method", "]", ";", "}" ]
Parse a class based composer name. @param string $class @param string $prefix @return array
[ "Parse", "a", "class", "based", "composer", "name", "." ]
8afd7156610a70371aa5b1df50b8a212bf7b142c
https://github.com/PenoaksDev/Milky-Framework/blob/8afd7156610a70371aa5b1df50b8a212bf7b142c/src/Milky/Http/View/ViewFactory.php#L495-L503
train
Dhii/placeholder-template
src/AbstractBasePlaceholderTemplate.php
AbstractBasePlaceholderTemplate._render
protected function _render($context = null) { if (is_null($context)) { $context = []; } return $this->_replaceTokens($this->_getPlaceholderTemplate(), $context, $this->_getTokenStart(), $this->_getTokenEnd(), $this->_getDefaultPlaceholderValue()); }
php
protected function _render($context = null) { if (is_null($context)) { $context = []; } return $this->_replaceTokens($this->_getPlaceholderTemplate(), $context, $this->_getTokenStart(), $this->_getTokenEnd(), $this->_getDefaultPlaceholderValue()); }
[ "protected", "function", "_render", "(", "$", "context", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "context", ")", ")", "{", "$", "context", "=", "[", "]", ";", "}", "return", "$", "this", "->", "_replaceTokens", "(", "$", "this", "->", "_getPlaceholderTemplate", "(", ")", ",", "$", "context", ",", "$", "this", "->", "_getTokenStart", "(", ")", ",", "$", "this", "->", "_getTokenEnd", "(", ")", ",", "$", "this", "->", "_getDefaultPlaceholderValue", "(", ")", ")", ";", "}" ]
Renders this template with context. @since [*next-version*] @param BaseContainerInterface|array|ArrayAccess|stdClass|null $context The context, which contains values for this tempalte to render with. @return string The result of rendering.
[ "Renders", "this", "template", "with", "context", "." ]
ab6eb2f98b085dfdf22cf86fd243cd7e6ee68525
https://github.com/Dhii/placeholder-template/blob/ab6eb2f98b085dfdf22cf86fd243cd7e6ee68525/src/AbstractBasePlaceholderTemplate.php#L73-L80
train
zenodorus-tools/core
src/ZenodorusArguments.php
ZenodorusArguments.setProp
protected function setProp(string $property, $value) { if (\property_exists($this, $property)) { $this->{$property} = $value; } }
php
protected function setProp(string $property, $value) { if (\property_exists($this, $property)) { $this->{$property} = $value; } }
[ "protected", "function", "setProp", "(", "string", "$", "property", ",", "$", "value", ")", "{", "if", "(", "\\", "property_exists", "(", "$", "this", ",", "$", "property", ")", ")", "{", "$", "this", "->", "{", "$", "property", "}", "=", "$", "value", ";", "}", "}" ]
Set a property on the ZenodorusArguments object. @param string $property @param mixed $value @return void
[ "Set", "a", "property", "on", "the", "ZenodorusArguments", "object", "." ]
09ce94f460841c1337bb57fc246e74872f5c3aa1
https://github.com/zenodorus-tools/core/blob/09ce94f460841c1337bb57fc246e74872f5c3aa1/src/ZenodorusArguments.php#L23-L28
train
zenodorus-tools/core
src/ZenodorusArguments.php
ZenodorusArguments.get
public function get(string $property, $callback = false) { if (isset($this->processed[$property])) { if ($callback) { return \call_user_func($callback, $this->processed[$property]); } return $this->processed[$property]; } return false; }
php
public function get(string $property, $callback = false) { if (isset($this->processed[$property])) { if ($callback) { return \call_user_func($callback, $this->processed[$property]); } return $this->processed[$property]; } return false; }
[ "public", "function", "get", "(", "string", "$", "property", ",", "$", "callback", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "processed", "[", "$", "property", "]", ")", ")", "{", "if", "(", "$", "callback", ")", "{", "return", "\\", "call_user_func", "(", "$", "callback", ",", "$", "this", "->", "processed", "[", "$", "property", "]", ")", ";", "}", "return", "$", "this", "->", "processed", "[", "$", "property", "]", ";", "}", "return", "false", ";", "}" ]
Get a specific value. You can optionally pass a callback to process this value. @param string $property @param string|function $callback @return mixed
[ "Get", "a", "specific", "value", "." ]
09ce94f460841c1337bb57fc246e74872f5c3aa1
https://github.com/zenodorus-tools/core/blob/09ce94f460841c1337bb57fc246e74872f5c3aa1/src/ZenodorusArguments.php#L52-L63
train
danielgp/common-lib
source/MySQLiByDanielGP.php
MySQLiByDanielGP.connectToMySql
protected function connectToMySql($mySQLconfig) { if (is_null($this->mySQLconnection)) { extract($mySQLconfig); $this->mySQLconnection = new \mysqli($host, $username, $password, $database, $port); if ($this->mySQLconnection->connect_error) { $this->mySQLconnection = null; $erNo = $this->mySQLconnection->connect_errno; $erMsg = $this->mySQLconnection->connect_error; $msg = $this->lclMsgCmn('i18n_Feedback_ConnectionError'); return sprintf($msg, $erNo, $erMsg, $host, $port, $username, $database); } return ''; } }
php
protected function connectToMySql($mySQLconfig) { if (is_null($this->mySQLconnection)) { extract($mySQLconfig); $this->mySQLconnection = new \mysqli($host, $username, $password, $database, $port); if ($this->mySQLconnection->connect_error) { $this->mySQLconnection = null; $erNo = $this->mySQLconnection->connect_errno; $erMsg = $this->mySQLconnection->connect_error; $msg = $this->lclMsgCmn('i18n_Feedback_ConnectionError'); return sprintf($msg, $erNo, $erMsg, $host, $port, $username, $database); } return ''; } }
[ "protected", "function", "connectToMySql", "(", "$", "mySQLconfig", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "mySQLconnection", ")", ")", "{", "extract", "(", "$", "mySQLconfig", ")", ";", "$", "this", "->", "mySQLconnection", "=", "new", "\\", "mysqli", "(", "$", "host", ",", "$", "username", ",", "$", "password", ",", "$", "database", ",", "$", "port", ")", ";", "if", "(", "$", "this", "->", "mySQLconnection", "->", "connect_error", ")", "{", "$", "this", "->", "mySQLconnection", "=", "null", ";", "$", "erNo", "=", "$", "this", "->", "mySQLconnection", "->", "connect_errno", ";", "$", "erMsg", "=", "$", "this", "->", "mySQLconnection", "->", "connect_error", ";", "$", "msg", "=", "$", "this", "->", "lclMsgCmn", "(", "'i18n_Feedback_ConnectionError'", ")", ";", "return", "sprintf", "(", "$", "msg", ",", "$", "erNo", ",", "$", "erMsg", ",", "$", "host", ",", "$", "port", ",", "$", "username", ",", "$", "database", ")", ";", "}", "return", "''", ";", "}", "}" ]
Initiates connection to MySQL @param array $mySQLconfig $mySQLconfig = [ 'host' => MYSQL_HOST, 'port' => MYSQL_PORT, 'username' => MYSQL_USERNAME, 'password' => MYSQL_PASSWORD, 'database' => MYSQL_DATABASE, ]; @return string
[ "Initiates", "connection", "to", "MySQL" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGP.php#L57-L71
train
danielgp/common-lib
source/MySQLiByDanielGP.php
MySQLiByDanielGP.getFieldOutputDate
protected function getFieldOutputDate($value) { $defaultValue = $this->getFieldValue($value); if ($defaultValue == 'NULL') { $defaultValue = date('Y-m-d'); } $inA = [ 'type' => 'text', 'name' => $value['COLUMN_NAME'], 'id' => $value['COLUMN_NAME'], 'value' => $defaultValue, 'size' => 10, 'maxlength' => 10, 'onfocus' => implode('', [ 'javascript:NewCssCal(\'' . $value['COLUMN_NAME'], '\',\'yyyyMMdd\',\'dropdown\',false,\'24\',false);', ]), ]; return $this->setStringIntoShortTag('input', $inA) . $this->setCalendarControl($value['COLUMN_NAME']); }
php
protected function getFieldOutputDate($value) { $defaultValue = $this->getFieldValue($value); if ($defaultValue == 'NULL') { $defaultValue = date('Y-m-d'); } $inA = [ 'type' => 'text', 'name' => $value['COLUMN_NAME'], 'id' => $value['COLUMN_NAME'], 'value' => $defaultValue, 'size' => 10, 'maxlength' => 10, 'onfocus' => implode('', [ 'javascript:NewCssCal(\'' . $value['COLUMN_NAME'], '\',\'yyyyMMdd\',\'dropdown\',false,\'24\',false);', ]), ]; return $this->setStringIntoShortTag('input', $inA) . $this->setCalendarControl($value['COLUMN_NAME']); }
[ "protected", "function", "getFieldOutputDate", "(", "$", "value", ")", "{", "$", "defaultValue", "=", "$", "this", "->", "getFieldValue", "(", "$", "value", ")", ";", "if", "(", "$", "defaultValue", "==", "'NULL'", ")", "{", "$", "defaultValue", "=", "date", "(", "'Y-m-d'", ")", ";", "}", "$", "inA", "=", "[", "'type'", "=>", "'text'", ",", "'name'", "=>", "$", "value", "[", "'COLUMN_NAME'", "]", ",", "'id'", "=>", "$", "value", "[", "'COLUMN_NAME'", "]", ",", "'value'", "=>", "$", "defaultValue", ",", "'size'", "=>", "10", ",", "'maxlength'", "=>", "10", ",", "'onfocus'", "=>", "implode", "(", "''", ",", "[", "'javascript:NewCssCal(\\''", ".", "$", "value", "[", "'COLUMN_NAME'", "]", ",", "'\\',\\'yyyyMMdd\\',\\'dropdown\\',false,\\'24\\',false);'", ",", "]", ")", ",", "]", ";", "return", "$", "this", "->", "setStringIntoShortTag", "(", "'input'", ",", "$", "inA", ")", ".", "$", "this", "->", "setCalendarControl", "(", "$", "value", "[", "'COLUMN_NAME'", "]", ")", ";", "}" ]
Returns a Date field 2 use in a form @param array $value @return string
[ "Returns", "a", "Date", "field", "2", "use", "in", "a", "form" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGP.php#L79-L98
train
danielgp/common-lib
source/MySQLiByDanielGP.php
MySQLiByDanielGP.getMySQLqueryWithParameterIdentifier
protected function getMySQLqueryWithParameterIdentifier($sQuery, $paramIdentifier) { $sReturn = true; if (strpos($sQuery, $paramIdentifier) === false) { $sReturn = false; } return $sReturn; }
php
protected function getMySQLqueryWithParameterIdentifier($sQuery, $paramIdentifier) { $sReturn = true; if (strpos($sQuery, $paramIdentifier) === false) { $sReturn = false; } return $sReturn; }
[ "protected", "function", "getMySQLqueryWithParameterIdentifier", "(", "$", "sQuery", ",", "$", "paramIdentifier", ")", "{", "$", "sReturn", "=", "true", ";", "if", "(", "strpos", "(", "$", "sQuery", ",", "$", "paramIdentifier", ")", "===", "false", ")", "{", "$", "sReturn", "=", "false", ";", "}", "return", "$", "sReturn", ";", "}" ]
Provides a detection if given Query does contain a Parameter that may require statement processing later on @param string $sQuery @param string $paramIdentifier @return boolean
[ "Provides", "a", "detection", "if", "given", "Query", "does", "contain", "a", "Parameter", "that", "may", "require", "statement", "processing", "later", "on" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGP.php#L120-L127
train
danielgp/common-lib
source/MySQLiByDanielGP.php
MySQLiByDanielGP.setMySQLquery2Server
protected function setMySQLquery2Server($sQuery, $sReturnType = null, $ftrs = null) { if (is_null($sReturnType)) { $this->mySQLconnection->query(html_entity_decode($sQuery)); return ''; } elseif (is_null($this->mySQLconnection)) { return ['customError' => $this->lclMsgCmn('i18n_MySQL_ConnectionNotExisting'), 'result' => null]; } $result = $this->mySQLconnection->query(html_entity_decode($sQuery)); if ($result) { return $this->setMySQLquery2ServerConnected(['Result' => $result, 'RType' => $sReturnType, 'F' => $ftrs]); } $erM = [$this->mySQLconnection->errno, $this->mySQLconnection->error]; $cErr = sprintf($this->lclMsgCmn('i18n_MySQL_QueryError'), $erM[0], $erM[1]); return ['customError' => $cErr, 'result' => null]; }
php
protected function setMySQLquery2Server($sQuery, $sReturnType = null, $ftrs = null) { if (is_null($sReturnType)) { $this->mySQLconnection->query(html_entity_decode($sQuery)); return ''; } elseif (is_null($this->mySQLconnection)) { return ['customError' => $this->lclMsgCmn('i18n_MySQL_ConnectionNotExisting'), 'result' => null]; } $result = $this->mySQLconnection->query(html_entity_decode($sQuery)); if ($result) { return $this->setMySQLquery2ServerConnected(['Result' => $result, 'RType' => $sReturnType, 'F' => $ftrs]); } $erM = [$this->mySQLconnection->errno, $this->mySQLconnection->error]; $cErr = sprintf($this->lclMsgCmn('i18n_MySQL_QueryError'), $erM[0], $erM[1]); return ['customError' => $cErr, 'result' => null]; }
[ "protected", "function", "setMySQLquery2Server", "(", "$", "sQuery", ",", "$", "sReturnType", "=", "null", ",", "$", "ftrs", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "sReturnType", ")", ")", "{", "$", "this", "->", "mySQLconnection", "->", "query", "(", "html_entity_decode", "(", "$", "sQuery", ")", ")", ";", "return", "''", ";", "}", "elseif", "(", "is_null", "(", "$", "this", "->", "mySQLconnection", ")", ")", "{", "return", "[", "'customError'", "=>", "$", "this", "->", "lclMsgCmn", "(", "'i18n_MySQL_ConnectionNotExisting'", ")", ",", "'result'", "=>", "null", "]", ";", "}", "$", "result", "=", "$", "this", "->", "mySQLconnection", "->", "query", "(", "html_entity_decode", "(", "$", "sQuery", ")", ")", ";", "if", "(", "$", "result", ")", "{", "return", "$", "this", "->", "setMySQLquery2ServerConnected", "(", "[", "'Result'", "=>", "$", "result", ",", "'RType'", "=>", "$", "sReturnType", ",", "'F'", "=>", "$", "ftrs", "]", ")", ";", "}", "$", "erM", "=", "[", "$", "this", "->", "mySQLconnection", "->", "errno", ",", "$", "this", "->", "mySQLconnection", "->", "error", "]", ";", "$", "cErr", "=", "sprintf", "(", "$", "this", "->", "lclMsgCmn", "(", "'i18n_MySQL_QueryError'", ")", ",", "$", "erM", "[", "0", "]", ",", "$", "erM", "[", "1", "]", ")", ";", "return", "[", "'customError'", "=>", "$", "cErr", ",", "'result'", "=>", "null", "]", ";", "}" ]
Transmit Query to MySQL server and get results back @param string $sQuery @param string $sReturnType @param array $ftrs @return boolean|array|string
[ "Transmit", "Query", "to", "MySQL", "server", "and", "get", "results", "back" ]
627b99b4408414c7cd21a6c8016f6468dc9216b2
https://github.com/danielgp/common-lib/blob/627b99b4408414c7cd21a6c8016f6468dc9216b2/source/MySQLiByDanielGP.php#L137-L152
train
ZeeCoder/good-to-know
src/ZeeCoder/GoodToKnow/ParameterInjector.php
ParameterInjector.addParameter
public function addParameter($key, $data) { if (!is_string($key)) { throw new \RuntimeException('Only strings can be given as parameter keys. Got "' . gettype($key) . '".'); } if (!is_string($data) && !is_callable($data)) { throw new \RuntimeException('The "data" parameter must either be a string or a callable. . Got "' . gettype($key) . '".'); } if (isset($this->parameters[$key])) { throw new \RuntimeException('The parameter key "' . $key . '" is already set.'); } $this->parameters[$key] = $data; return $this; }
php
public function addParameter($key, $data) { if (!is_string($key)) { throw new \RuntimeException('Only strings can be given as parameter keys. Got "' . gettype($key) . '".'); } if (!is_string($data) && !is_callable($data)) { throw new \RuntimeException('The "data" parameter must either be a string or a callable. . Got "' . gettype($key) . '".'); } if (isset($this->parameters[$key])) { throw new \RuntimeException('The parameter key "' . $key . '" is already set.'); } $this->parameters[$key] = $data; return $this; }
[ "public", "function", "addParameter", "(", "$", "key", ",", "$", "data", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'Only strings can be given as parameter keys. Got \"'", ".", "gettype", "(", "$", "key", ")", ".", "'\".'", ")", ";", "}", "if", "(", "!", "is_string", "(", "$", "data", ")", "&&", "!", "is_callable", "(", "$", "data", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'The \"data\" parameter must either be a string or a callable. . Got \"'", ".", "gettype", "(", "$", "key", ")", ".", "'\".'", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "parameters", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'The parameter key \"'", ".", "$", "key", ".", "'\" is already set.'", ")", ";", "}", "$", "this", "->", "parameters", "[", "$", "key", "]", "=", "$", "data", ";", "return", "$", "this", ";", "}" ]
Adds a parameter that can occur in Fact texts. @param string $key This is the key which will be searched for in the text. @param string|Callable $data @throws \RuntimeException if a parameter with the given $key was already added. @return $this
[ "Adds", "a", "parameter", "that", "can", "occur", "in", "Fact", "texts", "." ]
53a8ea6ab4a2cb0f2fd8e1371e7a4a4841be5ede
https://github.com/ZeeCoder/good-to-know/blob/53a8ea6ab4a2cb0f2fd8e1371e7a4a4841be5ede/src/ZeeCoder/GoodToKnow/ParameterInjector.php#L54-L71
train
anime-db/catalog-bundle
src/Plugin/Fill/Search/Search.php
Search.getCatalogItem
public function getCatalogItem($name) { if (!($this->getFiller() instanceof FillerInterface)) { return; } try { $list = $this->search(['name' => $name]); if (count($list) == 1) { return $this->getFiller()->fillFromSearchResult(array_pop($list)); } } catch (\Exception $e) { } // is not a critical error return; }
php
public function getCatalogItem($name) { if (!($this->getFiller() instanceof FillerInterface)) { return; } try { $list = $this->search(['name' => $name]); if (count($list) == 1) { return $this->getFiller()->fillFromSearchResult(array_pop($list)); } } catch (\Exception $e) { } // is not a critical error return; }
[ "public", "function", "getCatalogItem", "(", "$", "name", ")", "{", "if", "(", "!", "(", "$", "this", "->", "getFiller", "(", ")", "instanceof", "FillerInterface", ")", ")", "{", "return", ";", "}", "try", "{", "$", "list", "=", "$", "this", "->", "search", "(", "[", "'name'", "=>", "$", "name", "]", ")", ";", "if", "(", "count", "(", "$", "list", ")", "==", "1", ")", "{", "return", "$", "this", "->", "getFiller", "(", ")", "->", "fillFromSearchResult", "(", "array_pop", "(", "$", "list", ")", ")", ";", "}", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "}", "// is not a critical error", "return", ";", "}" ]
Try search item by name and fill it if can. @param string $name @return EntityItem|null
[ "Try", "search", "item", "by", "name", "and", "fill", "it", "if", "can", "." ]
631b6f92a654e91bee84f46218c52cf42bdb8606
https://github.com/anime-db/catalog-bundle/blob/631b6f92a654e91bee84f46218c52cf42bdb8606/src/Plugin/Fill/Search/Search.php#L124-L139
train
Sectorr/Core
Sectorr/Core/Auth/Auth.php
Auth.user
public static function user() { if (Session::has('user')) { $userModel = Config::get('user'); $model = new $userModel(); return $model->find(Session::get('user')); } return false; }
php
public static function user() { if (Session::has('user')) { $userModel = Config::get('user'); $model = new $userModel(); return $model->find(Session::get('user')); } return false; }
[ "public", "static", "function", "user", "(", ")", "{", "if", "(", "Session", "::", "has", "(", "'user'", ")", ")", "{", "$", "userModel", "=", "Config", "::", "get", "(", "'user'", ")", ";", "$", "model", "=", "new", "$", "userModel", "(", ")", ";", "return", "$", "model", "->", "find", "(", "Session", "::", "get", "(", "'user'", ")", ")", ";", "}", "return", "false", ";", "}" ]
Returns the logged in user's data as an object. @return bool|object
[ "Returns", "the", "logged", "in", "user", "s", "data", "as", "an", "object", "." ]
31df852dc6cc61642b0b87d9f0ae56c8e7da5a27
https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Auth/Auth.php#L18-L27
train
Sectorr/Core
Sectorr/Core/Auth/Auth.php
Auth.attempt
public static function attempt($input) { $userModel = Config::get('user'); $model = new $userModel(); $count = 0; foreach ($input as $field => $value) { if ($field == '_') { unset($input[$field]); } else { $count++; } if ($count == 1) { $primary = $field; } } if (!empty($input)) { $user = $model->where($primary, $input[$primary])->first(); if (! empty($user) && Hash::check($input['password'], $user->password)) { Session::set('user', $user->id); return true; } return false; } }
php
public static function attempt($input) { $userModel = Config::get('user'); $model = new $userModel(); $count = 0; foreach ($input as $field => $value) { if ($field == '_') { unset($input[$field]); } else { $count++; } if ($count == 1) { $primary = $field; } } if (!empty($input)) { $user = $model->where($primary, $input[$primary])->first(); if (! empty($user) && Hash::check($input['password'], $user->password)) { Session::set('user', $user->id); return true; } return false; } }
[ "public", "static", "function", "attempt", "(", "$", "input", ")", "{", "$", "userModel", "=", "Config", "::", "get", "(", "'user'", ")", ";", "$", "model", "=", "new", "$", "userModel", "(", ")", ";", "$", "count", "=", "0", ";", "foreach", "(", "$", "input", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "$", "field", "==", "'_'", ")", "{", "unset", "(", "$", "input", "[", "$", "field", "]", ")", ";", "}", "else", "{", "$", "count", "++", ";", "}", "if", "(", "$", "count", "==", "1", ")", "{", "$", "primary", "=", "$", "field", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "input", ")", ")", "{", "$", "user", "=", "$", "model", "->", "where", "(", "$", "primary", ",", "$", "input", "[", "$", "primary", "]", ")", "->", "first", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "user", ")", "&&", "Hash", "::", "check", "(", "$", "input", "[", "'password'", "]", ",", "$", "user", "->", "password", ")", ")", "{", "Session", "::", "set", "(", "'user'", ",", "$", "user", "->", "id", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}", "}" ]
Attempt to login the user. If succeeds, create a user session. @param $input @return bool
[ "Attempt", "to", "login", "the", "user", ".", "If", "succeeds", "create", "a", "user", "session", "." ]
31df852dc6cc61642b0b87d9f0ae56c8e7da5a27
https://github.com/Sectorr/Core/blob/31df852dc6cc61642b0b87d9f0ae56c8e7da5a27/Sectorr/Core/Auth/Auth.php#L36-L64
train
ARCANESOFT/Auth
src/Http/Requests/Admin/Users/UserFormRequest.php
UserFormRequest.sanitizeUsername
protected function sanitizeUsername() { $username = $this->has('username') ? $this->get('username') : $this->get('first_name').' '.$this->get('last_name'); return Str::slug($username, config('arcanesoft.auth.slug-separator', '.')); }
php
protected function sanitizeUsername() { $username = $this->has('username') ? $this->get('username') : $this->get('first_name').' '.$this->get('last_name'); return Str::slug($username, config('arcanesoft.auth.slug-separator', '.')); }
[ "protected", "function", "sanitizeUsername", "(", ")", "{", "$", "username", "=", "$", "this", "->", "has", "(", "'username'", ")", "?", "$", "this", "->", "get", "(", "'username'", ")", ":", "$", "this", "->", "get", "(", "'first_name'", ")", ".", "' '", ".", "$", "this", "->", "get", "(", "'last_name'", ")", ";", "return", "Str", "::", "slug", "(", "$", "username", ",", "config", "(", "'arcanesoft.auth.slug-separator'", ",", "'.'", ")", ")", ";", "}" ]
Sanitize the username. @return string
[ "Sanitize", "the", "username", "." ]
b33ca82597a76b1e395071f71ae3e51f1ec67e62
https://github.com/ARCANESOFT/Auth/blob/b33ca82597a76b1e395071f71ae3e51f1ec67e62/src/Http/Requests/Admin/Users/UserFormRequest.php#L70-L77
train
MichaelJ2324/PHP-REST-Client
src/Endpoint/Abstracts/AbstractSmartEndpoint.php
AbstractSmartEndpoint.configureDataProperties
protected function configureDataProperties(){ if (isset($this->properties[self::PROPERTY_DATA])){ $this->data->setProperties($this->properties['data']); } return $this; }
php
protected function configureDataProperties(){ if (isset($this->properties[self::PROPERTY_DATA])){ $this->data->setProperties($this->properties['data']); } return $this; }
[ "protected", "function", "configureDataProperties", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "properties", "[", "self", "::", "PROPERTY_DATA", "]", ")", ")", "{", "$", "this", "->", "data", "->", "setProperties", "(", "$", "this", "->", "properties", "[", "'data'", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Passes Data properties to Endpoint Data object @return $this
[ "Passes", "Data", "properties", "to", "Endpoint", "Data", "object" ]
b8a2caaf6456eccaa845ba5c5098608aa9645c92
https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Endpoint/Abstracts/AbstractSmartEndpoint.php#L92-L97
train
ScaraMVC/Framework
src/Scara/Console/ClearCache.php
ClearCache.clear
private function clear($directory, OutputInterface $output) { $handle = opendir($directory); $ignore = ['.', '..', '.gitkeep']; while ($file = readdir($handle)) { if (!in_array($file, $ignore)) { $output->writeln("Clearing file {$file} from the cache"); unlink($directory.$file); } } }
php
private function clear($directory, OutputInterface $output) { $handle = opendir($directory); $ignore = ['.', '..', '.gitkeep']; while ($file = readdir($handle)) { if (!in_array($file, $ignore)) { $output->writeln("Clearing file {$file} from the cache"); unlink($directory.$file); } } }
[ "private", "function", "clear", "(", "$", "directory", ",", "OutputInterface", "$", "output", ")", "{", "$", "handle", "=", "opendir", "(", "$", "directory", ")", ";", "$", "ignore", "=", "[", "'.'", ",", "'..'", ",", "'.gitkeep'", "]", ";", "while", "(", "$", "file", "=", "readdir", "(", "$", "handle", ")", ")", "{", "if", "(", "!", "in_array", "(", "$", "file", ",", "$", "ignore", ")", ")", "{", "$", "output", "->", "writeln", "(", "\"Clearing file {$file} from the cache\"", ")", ";", "unlink", "(", "$", "directory", ".", "$", "file", ")", ";", "}", "}", "}" ]
Handles clearning out files from given location. @param string $directory @param \Symfony\Component\Console\Output\OutputInterface $output @return void
[ "Handles", "clearning", "out", "files", "from", "given", "location", "." ]
199b08b45fadf5dae14ac4732af03b36e15bbef2
https://github.com/ScaraMVC/Framework/blob/199b08b45fadf5dae14ac4732af03b36e15bbef2/src/Scara/Console/ClearCache.php#L53-L63
train
agentmedia/phine-builtin
src/BuiltIn/Logic/Hooks/DeletePageNavigation.php
DeletePageNavigation.BeforeDelete
public function BeforeDelete($item) { $navPages = NavigationPage::Schema()->FetchByPage(false, $item); foreach ($navPages as $navPage) { $item = $navPage->GetItem(); $tree = new TreeBuilder(new NavigationTreeProvider($item->GetNavigation())); $tree->Remove($item); } }
php
public function BeforeDelete($item) { $navPages = NavigationPage::Schema()->FetchByPage(false, $item); foreach ($navPages as $navPage) { $item = $navPage->GetItem(); $tree = new TreeBuilder(new NavigationTreeProvider($item->GetNavigation())); $tree->Remove($item); } }
[ "public", "function", "BeforeDelete", "(", "$", "item", ")", "{", "$", "navPages", "=", "NavigationPage", "::", "Schema", "(", ")", "->", "FetchByPage", "(", "false", ",", "$", "item", ")", ";", "foreach", "(", "$", "navPages", "as", "$", "navPage", ")", "{", "$", "item", "=", "$", "navPage", "->", "GetItem", "(", ")", ";", "$", "tree", "=", "new", "TreeBuilder", "(", "new", "NavigationTreeProvider", "(", "$", "item", "->", "GetNavigation", "(", ")", ")", ")", ";", "$", "tree", "->", "Remove", "(", "$", "item", ")", ";", "}", "}" ]
Deletes the navi items related to the page @param Page $item The page to be deleted
[ "Deletes", "the", "navi", "items", "related", "to", "the", "page" ]
4dd05bc406a71e997bd4eaa16b12e23dbe62a456
https://github.com/agentmedia/phine-builtin/blob/4dd05bc406a71e997bd4eaa16b12e23dbe62a456/src/BuiltIn/Logic/Hooks/DeletePageNavigation.php#L19-L28
train
ComPHPPuebla/restful-extensions
src/ComPHPPuebla/Doctrine/TableGateway/EventListener/HasTimestampListener.php
HasTimestampListener.onInsert
public function onInsert(EventInterface $event) { $values = $event->getParam('values'); $now = new DateTime(); $now = $now->format('Y-m-d h:i:s'); $values['created_at'] = $now; $values['last_updated_at'] = $now; $event->setParam('values', $values); }
php
public function onInsert(EventInterface $event) { $values = $event->getParam('values'); $now = new DateTime(); $now = $now->format('Y-m-d h:i:s'); $values['created_at'] = $now; $values['last_updated_at'] = $now; $event->setParam('values', $values); }
[ "public", "function", "onInsert", "(", "EventInterface", "$", "event", ")", "{", "$", "values", "=", "$", "event", "->", "getParam", "(", "'values'", ")", ";", "$", "now", "=", "new", "DateTime", "(", ")", ";", "$", "now", "=", "$", "now", "->", "format", "(", "'Y-m-d h:i:s'", ")", ";", "$", "values", "[", "'created_at'", "]", "=", "$", "now", ";", "$", "values", "[", "'last_updated_at'", "]", "=", "$", "now", ";", "$", "event", "->", "setParam", "(", "'values'", ",", "$", "values", ")", ";", "}" ]
Add current `DateTime` value for fields `created_at` and `last_updated_at` @param EventInterface $event
[ "Add", "current", "DateTime", "value", "for", "fields", "created_at", "and", "last_updated_at" ]
3dc5e554d7ebe1305eed4cd4ec71a6944316199c
https://github.com/ComPHPPuebla/restful-extensions/blob/3dc5e554d7ebe1305eed4cd4ec71a6944316199c/src/ComPHPPuebla/Doctrine/TableGateway/EventListener/HasTimestampListener.php#L25-L36
train
ComPHPPuebla/restful-extensions
src/ComPHPPuebla/Doctrine/TableGateway/EventListener/HasTimestampListener.php
HasTimestampListener.onUpdate
public function onUpdate(EventInterface $event) { $values = $event->getParam('values'); $now = new DateTime(); $values['last_updated_at'] = $now->format('Y-m-d h:i:s'); $event->setParam('values', $values); }
php
public function onUpdate(EventInterface $event) { $values = $event->getParam('values'); $now = new DateTime(); $values['last_updated_at'] = $now->format('Y-m-d h:i:s'); $event->setParam('values', $values); }
[ "public", "function", "onUpdate", "(", "EventInterface", "$", "event", ")", "{", "$", "values", "=", "$", "event", "->", "getParam", "(", "'values'", ")", ";", "$", "now", "=", "new", "DateTime", "(", ")", ";", "$", "values", "[", "'last_updated_at'", "]", "=", "$", "now", "->", "format", "(", "'Y-m-d h:i:s'", ")", ";", "$", "event", "->", "setParam", "(", "'values'", ",", "$", "values", ")", ";", "}" ]
Add current `DateTime` value for field `last_updated_at` @param EventInterface $event
[ "Add", "current", "DateTime", "value", "for", "field", "last_updated_at" ]
3dc5e554d7ebe1305eed4cd4ec71a6944316199c
https://github.com/ComPHPPuebla/restful-extensions/blob/3dc5e554d7ebe1305eed4cd4ec71a6944316199c/src/ComPHPPuebla/Doctrine/TableGateway/EventListener/HasTimestampListener.php#L43-L51
train
stubbles/stubbles-date
src/main/php/span/Days.php
Days.rewind
public function rewind() { if ($this->datespan instanceof Day) { $this->current = $this->datespan; } else { $this->current = new Day($this->datespan->start()); } }
php
public function rewind() { if ($this->datespan instanceof Day) { $this->current = $this->datespan; } else { $this->current = new Day($this->datespan->start()); } }
[ "public", "function", "rewind", "(", ")", "{", "if", "(", "$", "this", "->", "datespan", "instanceof", "Day", ")", "{", "$", "this", "->", "current", "=", "$", "this", "->", "datespan", ";", "}", "else", "{", "$", "this", "->", "current", "=", "new", "Day", "(", "$", "this", "->", "datespan", "->", "start", "(", ")", ")", ";", "}", "}" ]
returns iteration back to first day of datespan
[ "returns", "iteration", "back", "to", "first", "day", "of", "datespan" ]
98553392bec03affc53a6e3eb7f88408c2720d1c
https://github.com/stubbles/stubbles-date/blob/98553392bec03affc53a6e3eb7f88408c2720d1c/src/main/php/span/Days.php#L85-L92
train
Vectrex/vxPHP
src/Http/HeaderBag.php
HeaderBag.contains
public function contains($key, $value) { return in_array($value, $this->get($key, NULL, FALSE)); }
php
public function contains($key, $value) { return in_array($value, $this->get($key, NULL, FALSE)); }
[ "public", "function", "contains", "(", "$", "key", ",", "$", "value", ")", "{", "return", "in_array", "(", "$", "value", ",", "$", "this", "->", "get", "(", "$", "key", ",", "NULL", ",", "FALSE", ")", ")", ";", "}" ]
Returns TRUE if the given HTTP header contains the given value. @param string $key The HTTP header name @param string $value The HTTP value @return Boolean TRUE if the value is contained in the header, FALSE otherwise
[ "Returns", "TRUE", "if", "the", "given", "HTTP", "header", "contains", "the", "given", "value", "." ]
295c21b00e7ef6085efcdf5b64fabb28d499b5a6
https://github.com/Vectrex/vxPHP/blob/295c21b00e7ef6085efcdf5b64fabb28d499b5a6/src/Http/HeaderBag.php#L189-L193
train
horntell/php-sdk
lib/guzzle/GuzzleHttp/Query.php
Query.fromString
public static function fromString($query, $urlEncoding = true) { static $qp; if (!$qp) { $qp = new QueryParser(); } $q = new static(); if ($urlEncoding !== true) { $q->setEncodingType($urlEncoding); } $qp->parseInto($q, $query, $urlEncoding); return $q; }
php
public static function fromString($query, $urlEncoding = true) { static $qp; if (!$qp) { $qp = new QueryParser(); } $q = new static(); if ($urlEncoding !== true) { $q->setEncodingType($urlEncoding); } $qp->parseInto($q, $query, $urlEncoding); return $q; }
[ "public", "static", "function", "fromString", "(", "$", "query", ",", "$", "urlEncoding", "=", "true", ")", "{", "static", "$", "qp", ";", "if", "(", "!", "$", "qp", ")", "{", "$", "qp", "=", "new", "QueryParser", "(", ")", ";", "}", "$", "q", "=", "new", "static", "(", ")", ";", "if", "(", "$", "urlEncoding", "!==", "true", ")", "{", "$", "q", "->", "setEncodingType", "(", "$", "urlEncoding", ")", ";", "}", "$", "qp", "->", "parseInto", "(", "$", "q", ",", "$", "query", ",", "$", "urlEncoding", ")", ";", "return", "$", "q", ";", "}" ]
Parse a query string into a Query object $urlEncoding is used to control how the query string is parsed and how it is ultimately serialized. The value can be set to one of the following: - true: (default) Parse query strings using RFC 3986 while still converting "+" to " ". - false: Disables URL decoding of the input string and URL encoding when the query string is serialized. - 'RFC3986': Use RFC 3986 URL encoding/decoding - 'RFC1738': Use RFC 1738 URL encoding/decoding @param string $query Query string to parse @param bool|string $urlEncoding Controls how the input string is decoded and encoded. @return self
[ "Parse", "a", "query", "string", "into", "a", "Query", "object" ]
e5205e9396a21b754d5651a8aa5898da5922a1b7
https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Query.php#L38-L54
train
horntell/php-sdk
lib/guzzle/GuzzleHttp/Query.php
Query.duplicateAggregator
public static function duplicateAggregator() { return function (array $data) { return self::walkQuery($data, '', function ($key, $prefix) { return is_int($key) ? $prefix : "{$prefix}[{$key}]"; }); }; }
php
public static function duplicateAggregator() { return function (array $data) { return self::walkQuery($data, '', function ($key, $prefix) { return is_int($key) ? $prefix : "{$prefix}[{$key}]"; }); }; }
[ "public", "static", "function", "duplicateAggregator", "(", ")", "{", "return", "function", "(", "array", "$", "data", ")", "{", "return", "self", "::", "walkQuery", "(", "$", "data", ",", "''", ",", "function", "(", "$", "key", ",", "$", "prefix", ")", "{", "return", "is_int", "(", "$", "key", ")", "?", "$", "prefix", ":", "\"{$prefix}[{$key}]\"", ";", "}", ")", ";", "}", ";", "}" ]
Query string aggregator that does not aggregate nested query string values and allows duplicates in the resulting array. Example: http://test.com?q=1&q=2 @return callable
[ "Query", "string", "aggregator", "that", "does", "not", "aggregate", "nested", "query", "string", "values", "and", "allows", "duplicates", "in", "the", "resulting", "array", "." ]
e5205e9396a21b754d5651a8aa5898da5922a1b7
https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Query.php#L155-L162
train
horntell/php-sdk
lib/guzzle/GuzzleHttp/Query.php
Query.walkQuery
public static function walkQuery(array $query, $keyPrefix, callable $prefixer) { $result = []; foreach ($query as $key => $value) { if ($keyPrefix) { $key = $prefixer($key, $keyPrefix); } if (is_array($value)) { $result += self::walkQuery($value, $key, $prefixer); } elseif (isset($result[$key])) { $result[$key][] = $value; } else { $result[$key] = array($value); } } return $result; }
php
public static function walkQuery(array $query, $keyPrefix, callable $prefixer) { $result = []; foreach ($query as $key => $value) { if ($keyPrefix) { $key = $prefixer($key, $keyPrefix); } if (is_array($value)) { $result += self::walkQuery($value, $key, $prefixer); } elseif (isset($result[$key])) { $result[$key][] = $value; } else { $result[$key] = array($value); } } return $result; }
[ "public", "static", "function", "walkQuery", "(", "array", "$", "query", ",", "$", "keyPrefix", ",", "callable", "$", "prefixer", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "query", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "keyPrefix", ")", "{", "$", "key", "=", "$", "prefixer", "(", "$", "key", ",", "$", "keyPrefix", ")", ";", "}", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "result", "+=", "self", "::", "walkQuery", "(", "$", "value", ",", "$", "key", ",", "$", "prefixer", ")", ";", "}", "elseif", "(", "isset", "(", "$", "result", "[", "$", "key", "]", ")", ")", "{", "$", "result", "[", "$", "key", "]", "[", "]", "=", "$", "value", ";", "}", "else", "{", "$", "result", "[", "$", "key", "]", "=", "array", "(", "$", "value", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Easily create query aggregation functions by providing a key prefix function to this query string array walker. @param array $query Query string to walk @param string $keyPrefix Key prefix (start with '') @param callable $prefixer Function used to create a key prefix @return array
[ "Easily", "create", "query", "aggregation", "functions", "by", "providing", "a", "key", "prefix", "function", "to", "this", "query", "string", "array", "walker", "." ]
e5205e9396a21b754d5651a8aa5898da5922a1b7
https://github.com/horntell/php-sdk/blob/e5205e9396a21b754d5651a8aa5898da5922a1b7/lib/guzzle/GuzzleHttp/Query.php#L198-L215
train
koolkode/config
src/Configuration.php
Configuration.getInteger
public function getInteger($key) { $resolved = false; $value = $this->getByKey($key, $this->data, $resolved); if($resolved) { return (int)$value; } if(func_num_args() > 1) { return func_get_arg(1); } throw new \OutOfBoundsException('Configuration setting not found: "' . $key . '"'); }
php
public function getInteger($key) { $resolved = false; $value = $this->getByKey($key, $this->data, $resolved); if($resolved) { return (int)$value; } if(func_num_args() > 1) { return func_get_arg(1); } throw new \OutOfBoundsException('Configuration setting not found: "' . $key . '"'); }
[ "public", "function", "getInteger", "(", "$", "key", ")", "{", "$", "resolved", "=", "false", ";", "$", "value", "=", "$", "this", "->", "getByKey", "(", "$", "key", ",", "$", "this", "->", "data", ",", "$", "resolved", ")", ";", "if", "(", "$", "resolved", ")", "{", "return", "(", "int", ")", "$", "value", ";", "}", "if", "(", "func_num_args", "(", ")", ">", "1", ")", "{", "return", "func_get_arg", "(", "1", ")", ";", "}", "throw", "new", "\\", "OutOfBoundsException", "(", "'Configuration setting not found: \"'", ".", "$", "key", ".", "'\"'", ")", ";", "}" ]
Get an integer value by key. @param string $key @param integer $default @return integer @throws \OutOfBoundsException When the key was not found and no default value is given.
[ "Get", "an", "integer", "value", "by", "key", "." ]
ad97d80f6e4ae5f8925839488abf2d9bfcb6d7f6
https://github.com/koolkode/config/blob/ad97d80f6e4ae5f8925839488abf2d9bfcb6d7f6/src/Configuration.php#L209-L225
train
koolkode/config
src/Configuration.php
Configuration.getFloat
public function getFloat($key) { $resolved = false; $value = $this->getByKey($key, $this->data, $resolved); if($resolved) { return floatval($value); } if(func_num_args() > 1) { return func_get_arg(1); } throw new \OutOfBoundsException('Configuration setting not found: "' . $key . '"'); }
php
public function getFloat($key) { $resolved = false; $value = $this->getByKey($key, $this->data, $resolved); if($resolved) { return floatval($value); } if(func_num_args() > 1) { return func_get_arg(1); } throw new \OutOfBoundsException('Configuration setting not found: "' . $key . '"'); }
[ "public", "function", "getFloat", "(", "$", "key", ")", "{", "$", "resolved", "=", "false", ";", "$", "value", "=", "$", "this", "->", "getByKey", "(", "$", "key", ",", "$", "this", "->", "data", ",", "$", "resolved", ")", ";", "if", "(", "$", "resolved", ")", "{", "return", "floatval", "(", "$", "value", ")", ";", "}", "if", "(", "func_num_args", "(", ")", ">", "1", ")", "{", "return", "func_get_arg", "(", "1", ")", ";", "}", "throw", "new", "\\", "OutOfBoundsException", "(", "'Configuration setting not found: \"'", ".", "$", "key", ".", "'\"'", ")", ";", "}" ]
Get a floating point value by key. @param string $key @param float $default @return float @throws \OutOfBoundsException When the key was not found and no default value is given.
[ "Get", "a", "floating", "point", "value", "by", "key", "." ]
ad97d80f6e4ae5f8925839488abf2d9bfcb6d7f6
https://github.com/koolkode/config/blob/ad97d80f6e4ae5f8925839488abf2d9bfcb6d7f6/src/Configuration.php#L236-L252
train
nattreid/tracking
src/Tracking.php
Tracking.leave
public function leave(): void { if ($this->canTrack()) { $track = $this->orm->tracking->getLatest($this->user->getUid()); if ($track) { $timeOnPage = time() - $track->inserted->getTimestamp(); if ($timeOnPage < ($this->minTimeBetweenVisits * 60)) { $track->timeOnPage = $timeOnPage; $this->orm->persistAndFlush($track); } } } }
php
public function leave(): void { if ($this->canTrack()) { $track = $this->orm->tracking->getLatest($this->user->getUid()); if ($track) { $timeOnPage = time() - $track->inserted->getTimestamp(); if ($timeOnPage < ($this->minTimeBetweenVisits * 60)) { $track->timeOnPage = $timeOnPage; $this->orm->persistAndFlush($track); } } } }
[ "public", "function", "leave", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "canTrack", "(", ")", ")", "{", "$", "track", "=", "$", "this", "->", "orm", "->", "tracking", "->", "getLatest", "(", "$", "this", "->", "user", "->", "getUid", "(", ")", ")", ";", "if", "(", "$", "track", ")", "{", "$", "timeOnPage", "=", "time", "(", ")", "-", "$", "track", "->", "inserted", "->", "getTimestamp", "(", ")", ";", "if", "(", "$", "timeOnPage", "<", "(", "$", "this", "->", "minTimeBetweenVisits", "*", "60", ")", ")", "{", "$", "track", "->", "timeOnPage", "=", "$", "timeOnPage", ";", "$", "this", "->", "orm", "->", "persistAndFlush", "(", "$", "track", ")", ";", "}", "}", "}", "}" ]
Zaznam odchodu ze stranky
[ "Zaznam", "odchodu", "ze", "stranky" ]
5fc7c993c08774945405c79a393584ef2ed589f7
https://github.com/nattreid/tracking/blob/5fc7c993c08774945405c79a393584ef2ed589f7/src/Tracking.php#L95-L109
train
nattreid/tracking
src/Tracking.php
Tracking.track
public function track(): void { if ($this->canTrack()) { $track = new TrackingEntity; $track->uid = $this->user->getUid(); $track->inserted = new DateTime; $track->url = $this->getParam('url'); $track->referer = $this->getParam('referer'); $track->ip = $this->getIp(); $track->browser = $this->getParam('browser'); $track->utmSource = $this->getParam('utm_source'); $track->utmMedium = $this->getParam('utm_medium'); $track->utmCampaign = $this->getParam('utm_campaign'); $this->orm->persistAndFlush($track); } }
php
public function track(): void { if ($this->canTrack()) { $track = new TrackingEntity; $track->uid = $this->user->getUid(); $track->inserted = new DateTime; $track->url = $this->getParam('url'); $track->referer = $this->getParam('referer'); $track->ip = $this->getIp(); $track->browser = $this->getParam('browser'); $track->utmSource = $this->getParam('utm_source'); $track->utmMedium = $this->getParam('utm_medium'); $track->utmCampaign = $this->getParam('utm_campaign'); $this->orm->persistAndFlush($track); } }
[ "public", "function", "track", "(", ")", ":", "void", "{", "if", "(", "$", "this", "->", "canTrack", "(", ")", ")", "{", "$", "track", "=", "new", "TrackingEntity", ";", "$", "track", "->", "uid", "=", "$", "this", "->", "user", "->", "getUid", "(", ")", ";", "$", "track", "->", "inserted", "=", "new", "DateTime", ";", "$", "track", "->", "url", "=", "$", "this", "->", "getParam", "(", "'url'", ")", ";", "$", "track", "->", "referer", "=", "$", "this", "->", "getParam", "(", "'referer'", ")", ";", "$", "track", "->", "ip", "=", "$", "this", "->", "getIp", "(", ")", ";", "$", "track", "->", "browser", "=", "$", "this", "->", "getParam", "(", "'browser'", ")", ";", "$", "track", "->", "utmSource", "=", "$", "this", "->", "getParam", "(", "'utm_source'", ")", ";", "$", "track", "->", "utmMedium", "=", "$", "this", "->", "getParam", "(", "'utm_medium'", ")", ";", "$", "track", "->", "utmCampaign", "=", "$", "this", "->", "getParam", "(", "'utm_campaign'", ")", ";", "$", "this", "->", "orm", "->", "persistAndFlush", "(", "$", "track", ")", ";", "}", "}" ]
Zaznam prichodu na stranku
[ "Zaznam", "prichodu", "na", "stranku" ]
5fc7c993c08774945405c79a393584ef2ed589f7
https://github.com/nattreid/tracking/blob/5fc7c993c08774945405c79a393584ef2ed589f7/src/Tracking.php#L114-L131
train
nattreid/tracking
src/Tracking.php
Tracking.checkVisits
private function checkVisits(Range $interval): void { foreach ($this->orm->trackingVisits->findCalculateDate($interval) as $date) { if ($date !== null) { $date = $date->setTime(0, 0, 0); $to = $date->modify('+23 hour'); $to = $to->modify('+59 minute'); $to = $to->modify('+59 second'); $pages = $this->orm->tracking->findVisitsHours(new Range($date, $to), true); foreach ($pages as $row) { $trackingVisits = $this->orm->trackingVisits->getByKey(new \DateTime($row->datefield)); if ($trackingVisits === null) { $trackingVisits = new TrackingVisits; } $trackingVisits->datefield = $row->datefield; $trackingVisits->visits = $row->visits; $this->orm->persistAndFlush($trackingVisits); } } } $this->orm->refreshAll(true); }
php
private function checkVisits(Range $interval): void { foreach ($this->orm->trackingVisits->findCalculateDate($interval) as $date) { if ($date !== null) { $date = $date->setTime(0, 0, 0); $to = $date->modify('+23 hour'); $to = $to->modify('+59 minute'); $to = $to->modify('+59 second'); $pages = $this->orm->tracking->findVisitsHours(new Range($date, $to), true); foreach ($pages as $row) { $trackingVisits = $this->orm->trackingVisits->getByKey(new \DateTime($row->datefield)); if ($trackingVisits === null) { $trackingVisits = new TrackingVisits; } $trackingVisits->datefield = $row->datefield; $trackingVisits->visits = $row->visits; $this->orm->persistAndFlush($trackingVisits); } } } $this->orm->refreshAll(true); }
[ "private", "function", "checkVisits", "(", "Range", "$", "interval", ")", ":", "void", "{", "foreach", "(", "$", "this", "->", "orm", "->", "trackingVisits", "->", "findCalculateDate", "(", "$", "interval", ")", "as", "$", "date", ")", "{", "if", "(", "$", "date", "!==", "null", ")", "{", "$", "date", "=", "$", "date", "->", "setTime", "(", "0", ",", "0", ",", "0", ")", ";", "$", "to", "=", "$", "date", "->", "modify", "(", "'+23 hour'", ")", ";", "$", "to", "=", "$", "to", "->", "modify", "(", "'+59 minute'", ")", ";", "$", "to", "=", "$", "to", "->", "modify", "(", "'+59 second'", ")", ";", "$", "pages", "=", "$", "this", "->", "orm", "->", "tracking", "->", "findVisitsHours", "(", "new", "Range", "(", "$", "date", ",", "$", "to", ")", ",", "true", ")", ";", "foreach", "(", "$", "pages", "as", "$", "row", ")", "{", "$", "trackingVisits", "=", "$", "this", "->", "orm", "->", "trackingVisits", "->", "getByKey", "(", "new", "\\", "DateTime", "(", "$", "row", "->", "datefield", ")", ")", ";", "if", "(", "$", "trackingVisits", "===", "null", ")", "{", "$", "trackingVisits", "=", "new", "TrackingVisits", ";", "}", "$", "trackingVisits", "->", "datefield", "=", "$", "row", "->", "datefield", ";", "$", "trackingVisits", "->", "visits", "=", "$", "row", "->", "visits", ";", "$", "this", "->", "orm", "->", "persistAndFlush", "(", "$", "trackingVisits", ")", ";", "}", "}", "}", "$", "this", "->", "orm", "->", "refreshAll", "(", "true", ")", ";", "}" ]
Ulozeni zaznamu pokud jeste nejsou prepocitane @param Range $interval @throws QueryException
[ "Ulozeni", "zaznamu", "pokud", "jeste", "nejsou", "prepocitane" ]
5fc7c993c08774945405c79a393584ef2ed589f7
https://github.com/nattreid/tracking/blob/5fc7c993c08774945405c79a393584ef2ed589f7/src/Tracking.php#L226-L249
train
nattreid/tracking
src/Tracking.php
Tracking.findClicksValue
public function findClicksValue(int $groupId, Range $interval): ?Result { return $this->orm->clickTracking->findClicksByValue($groupId, $interval); }
php
public function findClicksValue(int $groupId, Range $interval): ?Result { return $this->orm->clickTracking->findClicksByValue($groupId, $interval); }
[ "public", "function", "findClicksValue", "(", "int", "$", "groupId", ",", "Range", "$", "interval", ")", ":", "?", "Result", "{", "return", "$", "this", "->", "orm", "->", "clickTracking", "->", "findClicksByValue", "(", "$", "groupId", ",", "$", "interval", ")", ";", "}" ]
Pocet kliku podle hondoty @param int $groupId @param Range $interval @return Result|null
[ "Pocet", "kliku", "podle", "hondoty" ]
5fc7c993c08774945405c79a393584ef2ed589f7
https://github.com/nattreid/tracking/blob/5fc7c993c08774945405c79a393584ef2ed589f7/src/Tracking.php#L285-L288
train
as3io/As3ModlrBundle
DependencyInjection/Configuration.php
Configuration.getAdapterNode
private function getAdapterNode() { $node = $this->createRootNode('adapter'); return $node ->isRequired() ->addDefaultsIfNotSet() ->children() ->enumNode('type') ->values(['jsonapiorg', null]) ->end() ->scalarNode('service')->cannotBeEmpty()->end() ->end() ->validate() ->always(function($v) { $this->validateAdapter($v); return $v; }) ->end() ; }
php
private function getAdapterNode() { $node = $this->createRootNode('adapter'); return $node ->isRequired() ->addDefaultsIfNotSet() ->children() ->enumNode('type') ->values(['jsonapiorg', null]) ->end() ->scalarNode('service')->cannotBeEmpty()->end() ->end() ->validate() ->always(function($v) { $this->validateAdapter($v); return $v; }) ->end() ; }
[ "private", "function", "getAdapterNode", "(", ")", "{", "$", "node", "=", "$", "this", "->", "createRootNode", "(", "'adapter'", ")", ";", "return", "$", "node", "->", "isRequired", "(", ")", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "enumNode", "(", "'type'", ")", "->", "values", "(", "[", "'jsonapiorg'", ",", "null", "]", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'service'", ")", "->", "cannotBeEmpty", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "validate", "(", ")", "->", "always", "(", "function", "(", "$", "v", ")", "{", "$", "this", "->", "validateAdapter", "(", "$", "v", ")", ";", "return", "$", "v", ";", "}", ")", "->", "end", "(", ")", ";", "}" ]
Gets the api adapter configuration node. @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition
[ "Gets", "the", "api", "adapter", "configuration", "node", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/Configuration.php#L62-L81
train
as3io/As3ModlrBundle
DependencyInjection/Configuration.php
Configuration.getMetadataNode
private function getMetadataNode() { $node = $this->createRootNode('metadata'); return $node ->addDefaultsIfNotSet() ->children() ->arrayNode('drivers') ->defaultValue(['default' => ['type' => 'yml']]) ->useAttributeAsKey('name') ->prototype('array') ->performNoDeepMerging() ->children() ->enumNode('type')->defaultValue('yml') ->values(['yml', null]) ->end() ->scalarNode('service')->cannotBeEmpty()->end() ->arrayNode('parameters') ->performNoDeepMerging() ->prototype('variable')->end() ->end() ->end() ->end() ->validate() ->always(function($v) { $this->validateMetadataDrivers($v); return $v; }) ->end() ->end() ->arrayNode('cache') ->canBeDisabled() ->children() ->enumNode('type')->defaultValue('file') ->values(['file', 'binary_file', 'redis', null]) ->end() ->scalarNode('service')->cannotBeEmpty()->end() ->arrayNode('parameters') ->performNoDeepMerging() ->prototype('variable')->end() ->end() ->end() ->validate() ->always(function($v) { $this->validateMetadataCache($v); return $v; }) ->end() ->end() ->end() ; }
php
private function getMetadataNode() { $node = $this->createRootNode('metadata'); return $node ->addDefaultsIfNotSet() ->children() ->arrayNode('drivers') ->defaultValue(['default' => ['type' => 'yml']]) ->useAttributeAsKey('name') ->prototype('array') ->performNoDeepMerging() ->children() ->enumNode('type')->defaultValue('yml') ->values(['yml', null]) ->end() ->scalarNode('service')->cannotBeEmpty()->end() ->arrayNode('parameters') ->performNoDeepMerging() ->prototype('variable')->end() ->end() ->end() ->end() ->validate() ->always(function($v) { $this->validateMetadataDrivers($v); return $v; }) ->end() ->end() ->arrayNode('cache') ->canBeDisabled() ->children() ->enumNode('type')->defaultValue('file') ->values(['file', 'binary_file', 'redis', null]) ->end() ->scalarNode('service')->cannotBeEmpty()->end() ->arrayNode('parameters') ->performNoDeepMerging() ->prototype('variable')->end() ->end() ->end() ->validate() ->always(function($v) { $this->validateMetadataCache($v); return $v; }) ->end() ->end() ->end() ; }
[ "private", "function", "getMetadataNode", "(", ")", "{", "$", "node", "=", "$", "this", "->", "createRootNode", "(", "'metadata'", ")", ";", "return", "$", "node", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "arrayNode", "(", "'drivers'", ")", "->", "defaultValue", "(", "[", "'default'", "=>", "[", "'type'", "=>", "'yml'", "]", "]", ")", "->", "useAttributeAsKey", "(", "'name'", ")", "->", "prototype", "(", "'array'", ")", "->", "performNoDeepMerging", "(", ")", "->", "children", "(", ")", "->", "enumNode", "(", "'type'", ")", "->", "defaultValue", "(", "'yml'", ")", "->", "values", "(", "[", "'yml'", ",", "null", "]", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'service'", ")", "->", "cannotBeEmpty", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'parameters'", ")", "->", "performNoDeepMerging", "(", ")", "->", "prototype", "(", "'variable'", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "validate", "(", ")", "->", "always", "(", "function", "(", "$", "v", ")", "{", "$", "this", "->", "validateMetadataDrivers", "(", "$", "v", ")", ";", "return", "$", "v", ";", "}", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'cache'", ")", "->", "canBeDisabled", "(", ")", "->", "children", "(", ")", "->", "enumNode", "(", "'type'", ")", "->", "defaultValue", "(", "'file'", ")", "->", "values", "(", "[", "'file'", ",", "'binary_file'", ",", "'redis'", ",", "null", "]", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'service'", ")", "->", "cannotBeEmpty", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'parameters'", ")", "->", "performNoDeepMerging", "(", ")", "->", "prototype", "(", "'variable'", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "validate", "(", ")", "->", "always", "(", "function", "(", "$", "v", ")", "{", "$", "this", "->", "validateMetadataCache", "(", "$", "v", ")", ";", "return", "$", "v", ";", "}", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "}" ]
Gets the metadata configuration node. @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition
[ "Gets", "the", "metadata", "configuration", "node", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/Configuration.php#L88-L146
train
as3io/As3ModlrBundle
DependencyInjection/Configuration.php
Configuration.getPersistersNode
private function getPersistersNode() { $node = $this->createRootNode('persisters'); return $node ->isRequired() ->useAttributeAsKey('name') ->prototype('array') ->children() ->enumNode('type') ->values(['mongodb', null]) ->end() ->scalarNode('service')->cannotBeEmpty()->end() ->arrayNode('parameters') ->performNoDeepMerging() ->prototype('variable')->end() ->end() ->end() ->end() ->validate() ->always(function($v) { $this->validatePersisters($v); return $v; }) ->end() ; }
php
private function getPersistersNode() { $node = $this->createRootNode('persisters'); return $node ->isRequired() ->useAttributeAsKey('name') ->prototype('array') ->children() ->enumNode('type') ->values(['mongodb', null]) ->end() ->scalarNode('service')->cannotBeEmpty()->end() ->arrayNode('parameters') ->performNoDeepMerging() ->prototype('variable')->end() ->end() ->end() ->end() ->validate() ->always(function($v) { $this->validatePersisters($v); return $v; }) ->end() ; }
[ "private", "function", "getPersistersNode", "(", ")", "{", "$", "node", "=", "$", "this", "->", "createRootNode", "(", "'persisters'", ")", ";", "return", "$", "node", "->", "isRequired", "(", ")", "->", "useAttributeAsKey", "(", "'name'", ")", "->", "prototype", "(", "'array'", ")", "->", "children", "(", ")", "->", "enumNode", "(", "'type'", ")", "->", "values", "(", "[", "'mongodb'", ",", "null", "]", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'service'", ")", "->", "cannotBeEmpty", "(", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'parameters'", ")", "->", "performNoDeepMerging", "(", ")", "->", "prototype", "(", "'variable'", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "validate", "(", ")", "->", "always", "(", "function", "(", "$", "v", ")", "{", "$", "this", "->", "validatePersisters", "(", "$", "v", ")", ";", "return", "$", "v", ";", "}", ")", "->", "end", "(", ")", ";", "}" ]
Gets the persisters configuration node. @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition
[ "Gets", "the", "persisters", "configuration", "node", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/Configuration.php#L153-L180
train
as3io/As3ModlrBundle
DependencyInjection/Configuration.php
Configuration.getRestNode
private function getRestNode() { $node = $this->createRootNode('rest'); return $node ->addDefaultsIfNotSet() ->children() ->scalarNode('root_endpoint')->isRequired()->cannotBeEmpty()->defaultValue('modlr/api') ->validate() ->always(function($v) { $v = $this->formatRestEndpoint($v); return $v; }) ->end() ->end() ->booleanNode('debug')->defaultValue(false)->end() ->end() ; }
php
private function getRestNode() { $node = $this->createRootNode('rest'); return $node ->addDefaultsIfNotSet() ->children() ->scalarNode('root_endpoint')->isRequired()->cannotBeEmpty()->defaultValue('modlr/api') ->validate() ->always(function($v) { $v = $this->formatRestEndpoint($v); return $v; }) ->end() ->end() ->booleanNode('debug')->defaultValue(false)->end() ->end() ; }
[ "private", "function", "getRestNode", "(", ")", "{", "$", "node", "=", "$", "this", "->", "createRootNode", "(", "'rest'", ")", ";", "return", "$", "node", "->", "addDefaultsIfNotSet", "(", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'root_endpoint'", ")", "->", "isRequired", "(", ")", "->", "cannotBeEmpty", "(", ")", "->", "defaultValue", "(", "'modlr/api'", ")", "->", "validate", "(", ")", "->", "always", "(", "function", "(", "$", "v", ")", "{", "$", "v", "=", "$", "this", "->", "formatRestEndpoint", "(", "$", "v", ")", ";", "return", "$", "v", ";", "}", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "booleanNode", "(", "'debug'", ")", "->", "defaultValue", "(", "false", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "}" ]
Gets the rest configuration node. @return \Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition
[ "Gets", "the", "rest", "configuration", "node", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/Configuration.php#L187-L205
train
as3io/As3ModlrBundle
DependencyInjection/Configuration.php
Configuration.validateLibClassExists
private function validateLibClassExists($subClass, $path) { $class = Utility::getLibraryClass($subClass); if (false === class_exists($class)) { throw new InvalidConfigurationException(sprintf('The library class "%s" was not found for "%s" - was the library installed?', $class, $path)); } }
php
private function validateLibClassExists($subClass, $path) { $class = Utility::getLibraryClass($subClass); if (false === class_exists($class)) { throw new InvalidConfigurationException(sprintf('The library class "%s" was not found for "%s" - was the library installed?', $class, $path)); } }
[ "private", "function", "validateLibClassExists", "(", "$", "subClass", ",", "$", "path", ")", "{", "$", "class", "=", "Utility", "::", "getLibraryClass", "(", "$", "subClass", ")", ";", "if", "(", "false", "===", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "InvalidConfigurationException", "(", "sprintf", "(", "'The library class \"%s\" was not found for \"%s\" - was the library installed?'", ",", "$", "class", ",", "$", "path", ")", ")", ";", "}", "}" ]
Validates that a library class name exists. @param string $subClass @param string $path @throws InvalidConfigurationException
[ "Validates", "that", "a", "library", "class", "name", "exists", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/Configuration.php#L268-L274
train
as3io/As3ModlrBundle
DependencyInjection/Configuration.php
Configuration.validateMetadataCache
private function validateMetadataCache(array $config) { if (false === $config['enabled']) { return $this; } $this->validateTypeAndService($config, 'as3_modlr.metadata.cache'); switch ($config['type']) { case 'redis': $this->validateMetadataCacheRedis($config); break; default: break; } return $this; }
php
private function validateMetadataCache(array $config) { if (false === $config['enabled']) { return $this; } $this->validateTypeAndService($config, 'as3_modlr.metadata.cache'); switch ($config['type']) { case 'redis': $this->validateMetadataCacheRedis($config); break; default: break; } return $this; }
[ "private", "function", "validateMetadataCache", "(", "array", "$", "config", ")", "{", "if", "(", "false", "===", "$", "config", "[", "'enabled'", "]", ")", "{", "return", "$", "this", ";", "}", "$", "this", "->", "validateTypeAndService", "(", "$", "config", ",", "'as3_modlr.metadata.cache'", ")", ";", "switch", "(", "$", "config", "[", "'type'", "]", ")", "{", "case", "'redis'", ":", "$", "this", "->", "validateMetadataCacheRedis", "(", "$", "config", ")", ";", "break", ";", "default", ":", "break", ";", "}", "return", "$", "this", ";", "}" ]
Validates the metadata cache config. @param array $config @return self @throws InvalidConfigurationException
[ "Validates", "the", "metadata", "cache", "config", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/Configuration.php#L283-L298
train
as3io/As3ModlrBundle
DependencyInjection/Configuration.php
Configuration.validateMetadataDrivers
private function validateMetadataDrivers(array $drivers) { foreach ($drivers as $name => $config) { $this->validateTypeAndService($config, sprintf('as3_modlr.metadata.drivers.%s', $name)); } return $this; }
php
private function validateMetadataDrivers(array $drivers) { foreach ($drivers as $name => $config) { $this->validateTypeAndService($config, sprintf('as3_modlr.metadata.drivers.%s', $name)); } return $this; }
[ "private", "function", "validateMetadataDrivers", "(", "array", "$", "drivers", ")", "{", "foreach", "(", "$", "drivers", "as", "$", "name", "=>", "$", "config", ")", "{", "$", "this", "->", "validateTypeAndService", "(", "$", "config", ",", "sprintf", "(", "'as3_modlr.metadata.drivers.%s'", ",", "$", "name", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Validates the metadata drivers config. @param array $drivers @return self @throws InvalidConfigurationException
[ "Validates", "the", "metadata", "drivers", "config", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/Configuration.php#L320-L326
train
as3io/As3ModlrBundle
DependencyInjection/Configuration.php
Configuration.validatePersisters
private function validatePersisters(array $persisters) { foreach ($persisters as $name => $config) { $this->validateTypeAndService($config, sprintf('as3_modlr.persisters.%s', $name)); switch ($config['type']) { case 'mongodb': $this->validateLibClassExists('Persister\MongoDb\Persister', sprintf('as3_modlr.persisters.%s.type', $name)); $this->validatePersisterMongoDb($config); break; default: break; } } }
php
private function validatePersisters(array $persisters) { foreach ($persisters as $name => $config) { $this->validateTypeAndService($config, sprintf('as3_modlr.persisters.%s', $name)); switch ($config['type']) { case 'mongodb': $this->validateLibClassExists('Persister\MongoDb\Persister', sprintf('as3_modlr.persisters.%s.type', $name)); $this->validatePersisterMongoDb($config); break; default: break; } } }
[ "private", "function", "validatePersisters", "(", "array", "$", "persisters", ")", "{", "foreach", "(", "$", "persisters", "as", "$", "name", "=>", "$", "config", ")", "{", "$", "this", "->", "validateTypeAndService", "(", "$", "config", ",", "sprintf", "(", "'as3_modlr.persisters.%s'", ",", "$", "name", ")", ")", ";", "switch", "(", "$", "config", "[", "'type'", "]", ")", "{", "case", "'mongodb'", ":", "$", "this", "->", "validateLibClassExists", "(", "'Persister\\MongoDb\\Persister'", ",", "sprintf", "(", "'as3_modlr.persisters.%s.type'", ",", "$", "name", ")", ")", ";", "$", "this", "->", "validatePersisterMongoDb", "(", "$", "config", ")", ";", "break", ";", "default", ":", "break", ";", "}", "}", "}" ]
Validates the persisters config. @param array $persisters @return self @throws InvalidConfigurationException
[ "Validates", "the", "persisters", "config", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/Configuration.php#L348-L361
train
as3io/As3ModlrBundle
DependencyInjection/Configuration.php
Configuration.validateSearchClients
private function validateSearchClients(array $clients) { foreach ($clients as $name => $config) { $this->validateTypeAndService($config, sprintf('as3_modlr.search_clients.%s', $name)); switch ($config['type']) { case 'elastic': $this->validateLibClassExists('Search\Elastic\Client', sprintf('as3_modlr.search_clients.%s.type', $name)); break; default: break; } } }
php
private function validateSearchClients(array $clients) { foreach ($clients as $name => $config) { $this->validateTypeAndService($config, sprintf('as3_modlr.search_clients.%s', $name)); switch ($config['type']) { case 'elastic': $this->validateLibClassExists('Search\Elastic\Client', sprintf('as3_modlr.search_clients.%s.type', $name)); break; default: break; } } }
[ "private", "function", "validateSearchClients", "(", "array", "$", "clients", ")", "{", "foreach", "(", "$", "clients", "as", "$", "name", "=>", "$", "config", ")", "{", "$", "this", "->", "validateTypeAndService", "(", "$", "config", ",", "sprintf", "(", "'as3_modlr.search_clients.%s'", ",", "$", "name", ")", ")", ";", "switch", "(", "$", "config", "[", "'type'", "]", ")", "{", "case", "'elastic'", ":", "$", "this", "->", "validateLibClassExists", "(", "'Search\\Elastic\\Client'", ",", "sprintf", "(", "'as3_modlr.search_clients.%s.type'", ",", "$", "name", ")", ")", ";", "break", ";", "default", ":", "break", ";", "}", "}", "}" ]
Validates the search clients config. @param array $clients @return self @throws InvalidConfigurationException
[ "Validates", "the", "search", "clients", "config", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/Configuration.php#L370-L382
train
as3io/As3ModlrBundle
DependencyInjection/Configuration.php
Configuration.validateTypeAndService
private function validateTypeAndService(array $config, $path) { if (!isset($config['type']) && !isset($config['service'])) { throw new InvalidConfigurationException(sprintf('You must set one of "type" or "service" for "%s"', $path)); } if (isset($config['type']) && isset($config['service'])) { throw new InvalidConfigurationException(sprintf('You cannot set both "type" and "service" for "%s" - please choose one.', $path)); } }
php
private function validateTypeAndService(array $config, $path) { if (!isset($config['type']) && !isset($config['service'])) { throw new InvalidConfigurationException(sprintf('You must set one of "type" or "service" for "%s"', $path)); } if (isset($config['type']) && isset($config['service'])) { throw new InvalidConfigurationException(sprintf('You cannot set both "type" and "service" for "%s" - please choose one.', $path)); } }
[ "private", "function", "validateTypeAndService", "(", "array", "$", "config", ",", "$", "path", ")", "{", "if", "(", "!", "isset", "(", "$", "config", "[", "'type'", "]", ")", "&&", "!", "isset", "(", "$", "config", "[", "'service'", "]", ")", ")", "{", "throw", "new", "InvalidConfigurationException", "(", "sprintf", "(", "'You must set one of \"type\" or \"service\" for \"%s\"'", ",", "$", "path", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "config", "[", "'type'", "]", ")", "&&", "isset", "(", "$", "config", "[", "'service'", "]", ")", ")", "{", "throw", "new", "InvalidConfigurationException", "(", "sprintf", "(", "'You cannot set both \"type\" and \"service\" for \"%s\" - please choose one.'", ",", "$", "path", ")", ")", ";", "}", "}" ]
Validates a configuration that uses type and service as options. @param array $config @param string $path @throws InvalidArgumentException
[ "Validates", "a", "configuration", "that", "uses", "type", "and", "service", "as", "options", "." ]
7ce2abb7390c7eaf4081c5b7e00b96e7001774a4
https://github.com/as3io/As3ModlrBundle/blob/7ce2abb7390c7eaf4081c5b7e00b96e7001774a4/DependencyInjection/Configuration.php#L391-L399
train
MichaelJ2324/PHP-REST-Client
src/Client/AbstractClient.php
AbstractClient.setCurrentEndpoint
protected function setCurrentEndpoint(EndpointInterface $Endpoint) { if (isset($this->currentEndPoint)){ unset($this->lastEndPoint); $this->lastEndPoint = $this->currentEndPoint; unset($this->currentEndPoint); } $this->currentEndPoint = $Endpoint; return $this; }
php
protected function setCurrentEndpoint(EndpointInterface $Endpoint) { if (isset($this->currentEndPoint)){ unset($this->lastEndPoint); $this->lastEndPoint = $this->currentEndPoint; unset($this->currentEndPoint); } $this->currentEndPoint = $Endpoint; return $this; }
[ "protected", "function", "setCurrentEndpoint", "(", "EndpointInterface", "$", "Endpoint", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "currentEndPoint", ")", ")", "{", "unset", "(", "$", "this", "->", "lastEndPoint", ")", ";", "$", "this", "->", "lastEndPoint", "=", "$", "this", "->", "currentEndPoint", ";", "unset", "(", "$", "this", "->", "currentEndPoint", ")", ";", "}", "$", "this", "->", "currentEndPoint", "=", "$", "Endpoint", ";", "return", "$", "this", ";", "}" ]
Rotates current Endpoint to Last Endpoint, and sets Current Endpoint with passed in Endpoint @param EndpointInterface $Endpoint @return self
[ "Rotates", "current", "Endpoint", "to", "Last", "Endpoint", "and", "sets", "Current", "Endpoint", "with", "passed", "in", "Endpoint" ]
b8a2caaf6456eccaa845ba5c5098608aa9645c92
https://github.com/MichaelJ2324/PHP-REST-Client/blob/b8a2caaf6456eccaa845ba5c5098608aa9645c92/src/Client/AbstractClient.php#L183-L192
train
CraryPrimitiveMan/php-resque
src/core/Job.php
Job.reserve
public static function reserve($queue) { $payload = Resque::pop($queue); if(!is_array($payload)) { return false; } return new Job($queue, $payload); }
php
public static function reserve($queue) { $payload = Resque::pop($queue); if(!is_array($payload)) { return false; } return new Job($queue, $payload); }
[ "public", "static", "function", "reserve", "(", "$", "queue", ")", "{", "$", "payload", "=", "Resque", "::", "pop", "(", "$", "queue", ")", ";", "if", "(", "!", "is_array", "(", "$", "payload", ")", ")", "{", "return", "false", ";", "}", "return", "new", "Job", "(", "$", "queue", ",", "$", "payload", ")", ";", "}" ]
Find the next available job from the specified queue and return an instance of Job for it. @param string $queue The name of the queue to check for a job in. @return null|object Null when there aren't any waiting jobs, instance of Job when a job was found.
[ "Find", "the", "next", "available", "job", "from", "the", "specified", "queue", "and", "return", "an", "instance", "of", "Job", "for", "it", "." ]
eff3beba81b7f5e8d6fddb8d24c8dcde6553e209
https://github.com/CraryPrimitiveMan/php-resque/blob/eff3beba81b7f5e8d6fddb8d24c8dcde6553e209/src/core/Job.php#L89-L97
train
Linkvalue-Interne/MajoraGeneratorBundle
src/Majora/Bundle/GeneratorBundle/Generator/FileGenerator.php
FileGenerator.generatePath
protected function generatePath(SplFileInfo $fileinfo, $skeletonPath, $targetPath, Inflector $inflector) { return $inflector->translate(sprintf('%s%s', $targetPath, str_replace($skeletonPath, '', $fileinfo->getRealPath()) )); }
php
protected function generatePath(SplFileInfo $fileinfo, $skeletonPath, $targetPath, Inflector $inflector) { return $inflector->translate(sprintf('%s%s', $targetPath, str_replace($skeletonPath, '', $fileinfo->getRealPath()) )); }
[ "protected", "function", "generatePath", "(", "SplFileInfo", "$", "fileinfo", ",", "$", "skeletonPath", ",", "$", "targetPath", ",", "Inflector", "$", "inflector", ")", "{", "return", "$", "inflector", "->", "translate", "(", "sprintf", "(", "'%s%s'", ",", "$", "targetPath", ",", "str_replace", "(", "$", "skeletonPath", ",", "''", ",", "$", "fileinfo", "->", "getRealPath", "(", ")", ")", ")", ")", ";", "}" ]
generate targer file path from source path. @param SplFileInfo $fileinfo @param string $skeletonPath @param string $targetPath @param Inflector $inflector @return string
[ "generate", "targer", "file", "path", "from", "source", "path", "." ]
9f745c1f64e913df90d86b4fd0770121c563552d
https://github.com/Linkvalue-Interne/MajoraGeneratorBundle/blob/9f745c1f64e913df90d86b4fd0770121c563552d/src/Majora/Bundle/GeneratorBundle/Generator/FileGenerator.php#L73-L79
train
Linkvalue-Interne/MajoraGeneratorBundle
src/Majora/Bundle/GeneratorBundle/Generator/FileGenerator.php
FileGenerator.getMetadata
protected function getMetadata($templateFileContent) { $regex = '/\@MajoraGenerator\((.+)\)/'; $templateFileMetadata = array('force_generation' => false); if (!preg_match_all($regex, $templateFileContent, $matches, PREG_SET_ORDER)) { return $templateFileMetadata; } foreach ($matches as $match) { if (null === $metadata = json_decode($match[1], true)) { throw new \InvalidArgumentException(sprintf( 'Invalid annotation json data, error %s : %s', json_last_error(), json_last_error_msg() )); } $templateFileMetadata = array_replace_recursive( $templateFileMetadata, $metadata ); } return $templateFileMetadata; }
php
protected function getMetadata($templateFileContent) { $regex = '/\@MajoraGenerator\((.+)\)/'; $templateFileMetadata = array('force_generation' => false); if (!preg_match_all($regex, $templateFileContent, $matches, PREG_SET_ORDER)) { return $templateFileMetadata; } foreach ($matches as $match) { if (null === $metadata = json_decode($match[1], true)) { throw new \InvalidArgumentException(sprintf( 'Invalid annotation json data, error %s : %s', json_last_error(), json_last_error_msg() )); } $templateFileMetadata = array_replace_recursive( $templateFileMetadata, $metadata ); } return $templateFileMetadata; }
[ "protected", "function", "getMetadata", "(", "$", "templateFileContent", ")", "{", "$", "regex", "=", "'/\\@MajoraGenerator\\((.+)\\)/'", ";", "$", "templateFileMetadata", "=", "array", "(", "'force_generation'", "=>", "false", ")", ";", "if", "(", "!", "preg_match_all", "(", "$", "regex", ",", "$", "templateFileContent", ",", "$", "matches", ",", "PREG_SET_ORDER", ")", ")", "{", "return", "$", "templateFileMetadata", ";", "}", "foreach", "(", "$", "matches", "as", "$", "match", ")", "{", "if", "(", "null", "===", "$", "metadata", "=", "json_decode", "(", "$", "match", "[", "1", "]", ",", "true", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Invalid annotation json data, error %s : %s'", ",", "json_last_error", "(", ")", ",", "json_last_error_msg", "(", ")", ")", ")", ";", "}", "$", "templateFileMetadata", "=", "array_replace_recursive", "(", "$", "templateFileMetadata", ",", "$", "metadata", ")", ";", "}", "return", "$", "templateFileMetadata", ";", "}" ]
parse metadata from given template content. @param string $templateFileContent @return array<alias, array>
[ "parse", "metadata", "from", "given", "template", "content", "." ]
9f745c1f64e913df90d86b4fd0770121c563552d
https://github.com/Linkvalue-Interne/MajoraGeneratorBundle/blob/9f745c1f64e913df90d86b4fd0770121c563552d/src/Majora/Bundle/GeneratorBundle/Generator/FileGenerator.php#L88-L111
train
Linkvalue-Interne/MajoraGeneratorBundle
src/Majora/Bundle/GeneratorBundle/Generator/FileGenerator.php
FileGenerator.generateDir
protected function generateDir($destDirPath) { // don't override dirs if ($this->filesystem->exists($destDirPath)) { return; } $this->filesystem->mkdir($destDirPath); $this->logger->info(sprintf('dir created: %s', $destDirPath)); }
php
protected function generateDir($destDirPath) { // don't override dirs if ($this->filesystem->exists($destDirPath)) { return; } $this->filesystem->mkdir($destDirPath); $this->logger->info(sprintf('dir created: %s', $destDirPath)); }
[ "protected", "function", "generateDir", "(", "$", "destDirPath", ")", "{", "// don't override dirs", "if", "(", "$", "this", "->", "filesystem", "->", "exists", "(", "$", "destDirPath", ")", ")", "{", "return", ";", "}", "$", "this", "->", "filesystem", "->", "mkdir", "(", "$", "destDirPath", ")", ";", "$", "this", "->", "logger", "->", "info", "(", "sprintf", "(", "'dir created: %s'", ",", "$", "destDirPath", ")", ")", ";", "}" ]
generate dest dir. @param string $destDirPath
[ "generate", "dest", "dir", "." ]
9f745c1f64e913df90d86b4fd0770121c563552d
https://github.com/Linkvalue-Interne/MajoraGeneratorBundle/blob/9f745c1f64e913df90d86b4fd0770121c563552d/src/Majora/Bundle/GeneratorBundle/Generator/FileGenerator.php#L118-L127
train
Linkvalue-Interne/MajoraGeneratorBundle
src/Majora/Bundle/GeneratorBundle/Generator/FileGenerator.php
FileGenerator.modify
public function modify(SplFileInfo $generatedFile, SplFileInfo $templateFile, array $modifiers, Inflector $inflector) { foreach ($modifiers as $modifierAlias => $modifierData) { if ($modifier = $this->contentModifiers->get($modifierAlias)) { $this->filesystem->dumpFile( $generatedFile->getRealPath(), $modifier->modify( $generatedFile, is_array($modifierData) ? $modifierData : array(), $inflector, $templateFile ) ); } } }
php
public function modify(SplFileInfo $generatedFile, SplFileInfo $templateFile, array $modifiers, Inflector $inflector) { foreach ($modifiers as $modifierAlias => $modifierData) { if ($modifier = $this->contentModifiers->get($modifierAlias)) { $this->filesystem->dumpFile( $generatedFile->getRealPath(), $modifier->modify( $generatedFile, is_array($modifierData) ? $modifierData : array(), $inflector, $templateFile ) ); } } }
[ "public", "function", "modify", "(", "SplFileInfo", "$", "generatedFile", ",", "SplFileInfo", "$", "templateFile", ",", "array", "$", "modifiers", ",", "Inflector", "$", "inflector", ")", "{", "foreach", "(", "$", "modifiers", "as", "$", "modifierAlias", "=>", "$", "modifierData", ")", "{", "if", "(", "$", "modifier", "=", "$", "this", "->", "contentModifiers", "->", "get", "(", "$", "modifierAlias", ")", ")", "{", "$", "this", "->", "filesystem", "->", "dumpFile", "(", "$", "generatedFile", "->", "getRealPath", "(", ")", ",", "$", "modifier", "->", "modify", "(", "$", "generatedFile", ",", "is_array", "(", "$", "modifierData", ")", "?", "$", "modifierData", ":", "array", "(", ")", ",", "$", "inflector", ",", "$", "templateFile", ")", ")", ";", "}", "}", "}" ]
run content modifiers on given file content. @param SplFileInfo $generatedFile @param SplFileInfo $templateFile @param array $modifiers @param Inflector $inflector @return string
[ "run", "content", "modifiers", "on", "given", "file", "content", "." ]
9f745c1f64e913df90d86b4fd0770121c563552d
https://github.com/Linkvalue-Interne/MajoraGeneratorBundle/blob/9f745c1f64e913df90d86b4fd0770121c563552d/src/Majora/Bundle/GeneratorBundle/Generator/FileGenerator.php#L139-L154
train
bseddon/XPath20
lyquidity/Log.php
Log.createLog
public function createLog( $handler, $name, $ident, $conf = null, $level = null ) { $this->log = \Log::singleton( $handler, $name, $ident, $conf, $level ); }
php
public function createLog( $handler, $name, $ident, $conf = null, $level = null ) { $this->log = \Log::singleton( $handler, $name, $ident, $conf, $level ); }
[ "public", "function", "createLog", "(", "$", "handler", ",", "$", "name", ",", "$", "ident", ",", "$", "conf", "=", "null", ",", "$", "level", "=", "null", ")", "{", "$", "this", "->", "log", "=", "\\", "Log", "::", "singleton", "(", "$", "handler", ",", "$", "name", ",", "$", "ident", ",", "$", "conf", ",", "$", "level", ")", ";", "}" ]
This creates a specific type of log instance @param string $handler The type of Log handler to construct @param string $name The name of the log resource to which the events will be logged. Defaults to an empty string. @param string $ident An identification string that will be included in all log events logged by this handler. This value defaults to an empty string and can be changed at runtime using the ``setIdent()`` method. @param array $conf Associative array of key-value pairs that are used to specify any handler-specific settings. @param int $level Log messages up to and including this level. This value defaults to ``PEAR_LOG_DEBUG``. See `Log Levels`_ and `Log Level Masks`_. @return void
[ "This", "creates", "a", "specific", "type", "of", "log", "instance" ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/lyquidity/Log.php#L95-L98
train
bseddon/XPath20
lyquidity/Log.php
Log.fromXPath2Exception
public function fromXPath2Exception( $ex ) { if ( ! $this->log ) return; return $this->log->warning( $ex->ErrorCode . " " . $ex->getMessage() ); }
php
public function fromXPath2Exception( $ex ) { if ( ! $this->log ) return; return $this->log->warning( $ex->ErrorCode . " " . $ex->getMessage() ); }
[ "public", "function", "fromXPath2Exception", "(", "$", "ex", ")", "{", "if", "(", "!", "$", "this", "->", "log", ")", "return", ";", "return", "$", "this", "->", "log", "->", "warning", "(", "$", "ex", "->", "ErrorCode", ".", "\" \"", ".", "$", "ex", "->", "getMessage", "(", ")", ")", ";", "}" ]
A convenience function for logging a event about an XPath conformance issue. It will log a message at the PEAR_LOG_DEBUG log level. PEAR_LOG_WARNING @param XPath2Exception $ex An exception reference @return boolean True if the message was successfully logged.
[ "A", "convenience", "function", "for", "logging", "a", "event", "about", "an", "XPath", "conformance", "issue", ".", "It", "will", "log", "a", "message", "at", "the", "PEAR_LOG_DEBUG", "log", "level", "." ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/lyquidity/Log.php#L244-L248
train
bseddon/XPath20
lyquidity/Log.php
Log.setDebugLog
public function setDebugLog() { $logConsole = \Log::singleton( 'console', '', 'console', array( 'lineFormat' => '%{timestamp} [%{priority}] %{message}', 'timeFormat' => '%Y-%m-%d %H:%M:%S', ) ); $logError = \Log::singleton( 'error_log', PEAR_LOG_TYPE_SYSTEM, 'error_log', array( 'lineFormat' => '[%{priority}] %{message}', ) ); $logComposite = Log::singleton( 'composite' ); $logComposite->addChild( $logConsole ); $logComposite->addChild( $logError ); $this->setLog( $logComposite ); }
php
public function setDebugLog() { $logConsole = \Log::singleton( 'console', '', 'console', array( 'lineFormat' => '%{timestamp} [%{priority}] %{message}', 'timeFormat' => '%Y-%m-%d %H:%M:%S', ) ); $logError = \Log::singleton( 'error_log', PEAR_LOG_TYPE_SYSTEM, 'error_log', array( 'lineFormat' => '[%{priority}] %{message}', ) ); $logComposite = Log::singleton( 'composite' ); $logComposite->addChild( $logConsole ); $logComposite->addChild( $logError ); $this->setLog( $logComposite ); }
[ "public", "function", "setDebugLog", "(", ")", "{", "$", "logConsole", "=", "\\", "Log", "::", "singleton", "(", "'console'", ",", "''", ",", "'console'", ",", "array", "(", "'lineFormat'", "=>", "'%{timestamp} [%{priority}] %{message}'", ",", "'timeFormat'", "=>", "'%Y-%m-%d %H:%M:%S'", ",", ")", ")", ";", "$", "logError", "=", "\\", "Log", "::", "singleton", "(", "'error_log'", ",", "PEAR_LOG_TYPE_SYSTEM", ",", "'error_log'", ",", "array", "(", "'lineFormat'", "=>", "'[%{priority}] %{message}'", ",", ")", ")", ";", "$", "logComposite", "=", "Log", "::", "singleton", "(", "'composite'", ")", ";", "$", "logComposite", "->", "addChild", "(", "$", "logConsole", ")", ";", "$", "logComposite", "->", "addChild", "(", "$", "logError", ")", ";", "$", "this", "->", "setLog", "(", "$", "logComposite", ")", ";", "}" ]
Set log output for console and error_log @return void
[ "Set", "log", "output", "for", "console", "and", "error_log" ]
69882b6efffaa5470a819d5fdd2f6473ddeb046d
https://github.com/bseddon/XPath20/blob/69882b6efffaa5470a819d5fdd2f6473ddeb046d/lyquidity/Log.php#L270-L290
train
gplcart/ga_report
Main.php
Main.hookDashboardHandlers
public function hookDashboardHandlers(array &$handlers) { $weight = count($handlers); $model = $this->getModel(); $settings = $this->module->getSettings('ga_report'); foreach ($model->getHandlers() as $id => $handler) { if (!in_array($id, $settings['dashboard'])) { continue; } $weight++; $report = $model->get($handler, $settings); $handlers["ga_$id"] = array( 'status' => true, 'weight' => $weight, 'title' => $handler['name'], 'template' => $handler['template'], 'handlers' => array( 'data' => function () use ($handler, $report, $settings) { return array( 'report' => $report, 'handler' => $handler, 'settings' => $settings ); } ) ); } }
php
public function hookDashboardHandlers(array &$handlers) { $weight = count($handlers); $model = $this->getModel(); $settings = $this->module->getSettings('ga_report'); foreach ($model->getHandlers() as $id => $handler) { if (!in_array($id, $settings['dashboard'])) { continue; } $weight++; $report = $model->get($handler, $settings); $handlers["ga_$id"] = array( 'status' => true, 'weight' => $weight, 'title' => $handler['name'], 'template' => $handler['template'], 'handlers' => array( 'data' => function () use ($handler, $report, $settings) { return array( 'report' => $report, 'handler' => $handler, 'settings' => $settings ); } ) ); } }
[ "public", "function", "hookDashboardHandlers", "(", "array", "&", "$", "handlers", ")", "{", "$", "weight", "=", "count", "(", "$", "handlers", ")", ";", "$", "model", "=", "$", "this", "->", "getModel", "(", ")", ";", "$", "settings", "=", "$", "this", "->", "module", "->", "getSettings", "(", "'ga_report'", ")", ";", "foreach", "(", "$", "model", "->", "getHandlers", "(", ")", "as", "$", "id", "=>", "$", "handler", ")", "{", "if", "(", "!", "in_array", "(", "$", "id", ",", "$", "settings", "[", "'dashboard'", "]", ")", ")", "{", "continue", ";", "}", "$", "weight", "++", ";", "$", "report", "=", "$", "model", "->", "get", "(", "$", "handler", ",", "$", "settings", ")", ";", "$", "handlers", "[", "\"ga_$id\"", "]", "=", "array", "(", "'status'", "=>", "true", ",", "'weight'", "=>", "$", "weight", ",", "'title'", "=>", "$", "handler", "[", "'name'", "]", ",", "'template'", "=>", "$", "handler", "[", "'template'", "]", ",", "'handlers'", "=>", "array", "(", "'data'", "=>", "function", "(", ")", "use", "(", "$", "handler", ",", "$", "report", ",", "$", "settings", ")", "{", "return", "array", "(", "'report'", "=>", "$", "report", ",", "'handler'", "=>", "$", "handler", ",", "'settings'", "=>", "$", "settings", ")", ";", "}", ")", ")", ";", "}", "}" ]
Implements hook "dashboard.handlers" @param array $handlers
[ "Implements", "hook", "dashboard", ".", "handlers" ]
856a480e394bb3feaeea4785ccccad56abaac499
https://github.com/gplcart/ga_report/blob/856a480e394bb3feaeea4785ccccad56abaac499/Main.php#L72-L104
train
gplcart/ga_report
Main.php
Main.hookConstructControllerBackend
public function hookConstructControllerBackend($controller) { if ($controller->isQuery('ga.update')) { $store_id = $controller->getQuery('ga.update.store_id', ''); $handler_id = $controller->getQuery('ga.update.handler_id', ''); $this->getModel()->clearCache($handler_id, $store_id); $controller->redirect(); } }
php
public function hookConstructControllerBackend($controller) { if ($controller->isQuery('ga.update')) { $store_id = $controller->getQuery('ga.update.store_id', ''); $handler_id = $controller->getQuery('ga.update.handler_id', ''); $this->getModel()->clearCache($handler_id, $store_id); $controller->redirect(); } }
[ "public", "function", "hookConstructControllerBackend", "(", "$", "controller", ")", "{", "if", "(", "$", "controller", "->", "isQuery", "(", "'ga.update'", ")", ")", "{", "$", "store_id", "=", "$", "controller", "->", "getQuery", "(", "'ga.update.store_id'", ",", "''", ")", ";", "$", "handler_id", "=", "$", "controller", "->", "getQuery", "(", "'ga.update.handler_id'", ",", "''", ")", ";", "$", "this", "->", "getModel", "(", ")", "->", "clearCache", "(", "$", "handler_id", ",", "$", "store_id", ")", ";", "$", "controller", "->", "redirect", "(", ")", ";", "}", "}" ]
Implements hook "construct.controller.backend" @param \gplcart\core\controllers\backend\Controller $controller
[ "Implements", "hook", "construct", ".", "controller", ".", "backend" ]
856a480e394bb3feaeea4785ccccad56abaac499
https://github.com/gplcart/ga_report/blob/856a480e394bb3feaeea4785ccccad56abaac499/Main.php#L110-L118
train
gplcart/ga_report
Main.php
Main.getReport
public function getReport($handler, $settings = null) { if (!is_array($handler)) { $handler = $this->getHandler($handler); } if (!isset($settings)) { $settings = $this->module->getSettings('ga_report'); } return $this->getModel()->get($handler, $settings); }
php
public function getReport($handler, $settings = null) { if (!is_array($handler)) { $handler = $this->getHandler($handler); } if (!isset($settings)) { $settings = $this->module->getSettings('ga_report'); } return $this->getModel()->get($handler, $settings); }
[ "public", "function", "getReport", "(", "$", "handler", ",", "$", "settings", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "handler", ")", ")", "{", "$", "handler", "=", "$", "this", "->", "getHandler", "(", "$", "handler", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "settings", ")", ")", "{", "$", "settings", "=", "$", "this", "->", "module", "->", "getSettings", "(", "'ga_report'", ")", ";", "}", "return", "$", "this", "->", "getModel", "(", ")", "->", "get", "(", "$", "handler", ",", "$", "settings", ")", ";", "}" ]
Returns an array of Google Anylytics report @param array|string $handler Either an array of handler data or a handler ID @param array|null $settings An array of settings. If not provided, the module settings will be used @return array
[ "Returns", "an", "array", "of", "Google", "Anylytics", "report" ]
856a480e394bb3feaeea4785ccccad56abaac499
https://github.com/gplcart/ga_report/blob/856a480e394bb3feaeea4785ccccad56abaac499/Main.php#L145-L156
train
dmj/PicaRecord
src/HAB/Pica/Record/AuthorityRecord.php
AuthorityRecord.setPPN
public function setPPN ($ppn) { $ppnField = $this->getFirstMatchingField('003@/00'); if ($ppnField) { $ppnSubfield = $ppnField->getNthSubfield('0', 0); if ($ppnSubfield) { $ppnSubfield->setValue($ppn); } else { $ppnField->append(new Subfield('0', $ppn)); } } else { $this->append(new Field('003@', 0, array(new Subfield('0', $ppn)))); } }
php
public function setPPN ($ppn) { $ppnField = $this->getFirstMatchingField('003@/00'); if ($ppnField) { $ppnSubfield = $ppnField->getNthSubfield('0', 0); if ($ppnSubfield) { $ppnSubfield->setValue($ppn); } else { $ppnField->append(new Subfield('0', $ppn)); } } else { $this->append(new Field('003@', 0, array(new Subfield('0', $ppn)))); } }
[ "public", "function", "setPPN", "(", "$", "ppn", ")", "{", "$", "ppnField", "=", "$", "this", "->", "getFirstMatchingField", "(", "'003@/00'", ")", ";", "if", "(", "$", "ppnField", ")", "{", "$", "ppnSubfield", "=", "$", "ppnField", "->", "getNthSubfield", "(", "'0'", ",", "0", ")", ";", "if", "(", "$", "ppnSubfield", ")", "{", "$", "ppnSubfield", "->", "setValue", "(", "$", "ppn", ")", ";", "}", "else", "{", "$", "ppnField", "->", "append", "(", "new", "Subfield", "(", "'0'", ",", "$", "ppn", ")", ")", ";", "}", "}", "else", "{", "$", "this", "->", "append", "(", "new", "Field", "(", "'003@'", ",", "0", ",", "array", "(", "new", "Subfield", "(", "'0'", ",", "$", "ppn", ")", ")", ")", ")", ";", "}", "}" ]
Set the Pica production number. Create a field 003@/00 if necessary. @param string $ppn Pica production number @return void
[ "Set", "the", "Pica", "production", "number", "." ]
bd5577b9a4333aa6156398b94cc870a9377061b8
https://github.com/dmj/PicaRecord/blob/bd5577b9a4333aa6156398b94cc870a9377061b8/src/HAB/Pica/Record/AuthorityRecord.php#L78-L91
train
bound1ess/essence
src/Essence/Essence.php
Essence.getMatcherConfiguration
public function getMatcherConfiguration($matcherClass) { if ( ! array_key_exists($matcherClass, $this->configuration["matcher_settings"])) { return null; } $configuration = $this->configuration["matcher_settings"][$matcherClass]; unset($this->configuration["matcher_settings"][$matcherClass]); return $configuration; }
php
public function getMatcherConfiguration($matcherClass) { if ( ! array_key_exists($matcherClass, $this->configuration["matcher_settings"])) { return null; } $configuration = $this->configuration["matcher_settings"][$matcherClass]; unset($this->configuration["matcher_settings"][$matcherClass]); return $configuration; }
[ "public", "function", "getMatcherConfiguration", "(", "$", "matcherClass", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "matcherClass", ",", "$", "this", "->", "configuration", "[", "\"matcher_settings\"", "]", ")", ")", "{", "return", "null", ";", "}", "$", "configuration", "=", "$", "this", "->", "configuration", "[", "\"matcher_settings\"", "]", "[", "$", "matcherClass", "]", ";", "unset", "(", "$", "this", "->", "configuration", "[", "\"matcher_settings\"", "]", "[", "$", "matcherClass", "]", ")", ";", "return", "$", "configuration", ";", "}" ]
Returns the configuration for the given matcher, or null. @param string $matcherClass @return array|null
[ "Returns", "the", "configuration", "for", "the", "given", "matcher", "or", "null", "." ]
b773d3f17e192d7c7184ffd3640c668e7d74f69b
https://github.com/bound1ess/essence/blob/b773d3f17e192d7c7184ffd3640c668e7d74f69b/src/Essence/Essence.php#L131-L142
train
bound1ess/essence
src/Essence/Essence.php
Essence.configure
public function configure(Closure $callback) { if ( ! is_array($configuration = $callback($this->configuration))) { throw new Exceptions\InvalidConfigurationException($configuration); } $this->configuration = array_merge($this->defaultConfiguration, $configuration); }
php
public function configure(Closure $callback) { if ( ! is_array($configuration = $callback($this->configuration))) { throw new Exceptions\InvalidConfigurationException($configuration); } $this->configuration = array_merge($this->defaultConfiguration, $configuration); }
[ "public", "function", "configure", "(", "Closure", "$", "callback", ")", "{", "if", "(", "!", "is_array", "(", "$", "configuration", "=", "$", "callback", "(", "$", "this", "->", "configuration", ")", ")", ")", "{", "throw", "new", "Exceptions", "\\", "InvalidConfigurationException", "(", "$", "configuration", ")", ";", "}", "$", "this", "->", "configuration", "=", "array_merge", "(", "$", "this", "->", "defaultConfiguration", ",", "$", "configuration", ")", ";", "}" ]
Configures Essence via the given Closure. @throws Essence\Exceptions\InvalidConfiguraitonException @param Closure $callback @return void
[ "Configures", "Essence", "via", "the", "given", "Closure", "." ]
b773d3f17e192d7c7184ffd3640c668e7d74f69b
https://github.com/bound1ess/essence/blob/b773d3f17e192d7c7184ffd3640c668e7d74f69b/src/Essence/Essence.php#L163-L170
train
bound1ess/essence
src/Essence/Essence.php
Essence.setBuilder
public function setBuilder(AssertionBuilder $builder) { if ( ! is_null($this->builder) and $this->configuration["implicit_validation"]) { $this->go(); } $this->builders[] = $builder; $this->builder = $builder; }
php
public function setBuilder(AssertionBuilder $builder) { if ( ! is_null($this->builder) and $this->configuration["implicit_validation"]) { $this->go(); } $this->builders[] = $builder; $this->builder = $builder; }
[ "public", "function", "setBuilder", "(", "AssertionBuilder", "$", "builder", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "builder", ")", "and", "$", "this", "->", "configuration", "[", "\"implicit_validation\"", "]", ")", "{", "$", "this", "->", "go", "(", ")", ";", "}", "$", "this", "->", "builders", "[", "]", "=", "$", "builder", ";", "$", "this", "->", "builder", "=", "$", "builder", ";", "}" ]
Replaces the stored AssertionBuilder instance with the given one. @see Essence\Essence::$builder @see Essence\Essence::$builders @see Essence\Essence::getBuilder @param Essence\AssertionBuilder $builder @return void
[ "Replaces", "the", "stored", "AssertionBuilder", "instance", "with", "the", "given", "one", "." ]
b773d3f17e192d7c7184ffd3640c668e7d74f69b
https://github.com/bound1ess/essence/blob/b773d3f17e192d7c7184ffd3640c668e7d74f69b/src/Essence/Essence.php#L229-L237
train