id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
240,800
themichaelhall/bluemvc-core
src/Collections/RequestCookieCollection.php
RequestCookieCollection.set
public function set(string $name, RequestCookieInterface $requestCookie): void { $this->requestCookies[$name] = $requestCookie; }
php
public function set(string $name, RequestCookieInterface $requestCookie): void { $this->requestCookies[$name] = $requestCookie; }
[ "public", "function", "set", "(", "string", "$", "name", ",", "RequestCookieInterface", "$", "requestCookie", ")", ":", "void", "{", "$", "this", "->", "requestCookies", "[", "$", "name", "]", "=", "$", "requestCookie", ";", "}" ]
Sets a request cookie by name. @since 1.0.0 @param string $name The name. @param RequestCookieInterface $requestCookie The request cookie.
[ "Sets", "a", "request", "cookie", "by", "name", "." ]
cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680
https://github.com/themichaelhall/bluemvc-core/blob/cbc8ccf8ed4f15ec6105837b29c2bd3db3f93680/src/Collections/RequestCookieCollection.php#L113-L116
240,801
chilimatic/transformer-component
src/TransformerFactory.php
TransformerFactory.make
public function make($name, $options) { if (!$name || !is_string($name)) { return null; } if (isset($this->objTemplates[$name])) { return clone $this->objTemplates[$name]; } if (!$this->namespaceTransformer) { $this->namespaceTransformer = $this->objTemplates[self::NAMESPACE_TRANSFORMER] = new PrependNamespace(); } $className = $this->namespaceTransformer->transform($name, ['namespace' => __NAMESPACE__]); if (!class_exists($className, true)) { return null; } $this->objTemplates[$name] = new $className(); return clone $this->objTemplates[$name]; }
php
public function make($name, $options) { if (!$name || !is_string($name)) { return null; } if (isset($this->objTemplates[$name])) { return clone $this->objTemplates[$name]; } if (!$this->namespaceTransformer) { $this->namespaceTransformer = $this->objTemplates[self::NAMESPACE_TRANSFORMER] = new PrependNamespace(); } $className = $this->namespaceTransformer->transform($name, ['namespace' => __NAMESPACE__]); if (!class_exists($className, true)) { return null; } $this->objTemplates[$name] = new $className(); return clone $this->objTemplates[$name]; }
[ "public", "function", "make", "(", "$", "name", ",", "$", "options", ")", "{", "if", "(", "!", "$", "name", "||", "!", "is_string", "(", "$", "name", ")", ")", "{", "return", "null", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "objTemplates", "[", "$", "name", "]", ")", ")", "{", "return", "clone", "$", "this", "->", "objTemplates", "[", "$", "name", "]", ";", "}", "if", "(", "!", "$", "this", "->", "namespaceTransformer", ")", "{", "$", "this", "->", "namespaceTransformer", "=", "$", "this", "->", "objTemplates", "[", "self", "::", "NAMESPACE_TRANSFORMER", "]", "=", "new", "PrependNamespace", "(", ")", ";", "}", "$", "className", "=", "$", "this", "->", "namespaceTransformer", "->", "transform", "(", "$", "name", ",", "[", "'namespace'", "=>", "__NAMESPACE__", "]", ")", ";", "if", "(", "!", "class_exists", "(", "$", "className", ",", "true", ")", ")", "{", "return", "null", ";", "}", "$", "this", "->", "objTemplates", "[", "$", "name", "]", "=", "new", "$", "className", "(", ")", ";", "return", "clone", "$", "this", "->", "objTemplates", "[", "$", "name", "]", ";", "}" ]
the name is expected to prepend the subnamespace "string" or "time" or something similar -> otherwise a config based mapping would be required @param string $name @param array $options @return IFlyWeightTransformer|null
[ "the", "name", "is", "expected", "to", "prepend", "the", "subnamespace", "string", "or", "time", "or", "something", "similar", "-", ">", "otherwise", "a", "config", "based", "mapping", "would", "be", "required" ]
1d20cda19531bb3d3476666793906680ee523363
https://github.com/chilimatic/transformer-component/blob/1d20cda19531bb3d3476666793906680ee523363/src/TransformerFactory.php#L32-L55
240,802
phossa2/libs
src/Phossa2/Db/Traits/ConnectTrait.php
ConnectTrait.setDefaultAttributes
protected function setDefaultAttributes() { if (!empty($this->attributes)) { foreach ($this->attributes as $attr => $val) { $this->realSetAttribute($attr, $val); } } }
php
protected function setDefaultAttributes() { if (!empty($this->attributes)) { foreach ($this->attributes as $attr => $val) { $this->realSetAttribute($attr, $val); } } }
[ "protected", "function", "setDefaultAttributes", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "attributes", ")", ")", "{", "foreach", "(", "$", "this", "->", "attributes", "as", "$", "attr", "=>", "$", "val", ")", "{", "$", "this", "->", "realSetAttribute", "(", "$", "attr", ",", "$", "val", ")", ";", "}", "}", "}" ]
Set default attributes @access protected
[ "Set", "default", "attributes" ]
921e485c8cc29067f279da2cdd06f47a9bddd115
https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Db/Traits/ConnectTrait.php#L154-L161
240,803
johnniewalker/xandria
src/DAccess/AbstractMapperCollection.php
AbstractMapperCollection.doAdd
protected function doAdd($object) { $this->notifyAccess(); $this->objectsArray[$this->total] = $object; $this->total++; }
php
protected function doAdd($object) { $this->notifyAccess(); $this->objectsArray[$this->total] = $object; $this->total++; }
[ "protected", "function", "doAdd", "(", "$", "object", ")", "{", "$", "this", "->", "notifyAccess", "(", ")", ";", "$", "this", "->", "objectsArray", "[", "$", "this", "->", "total", "]", "=", "$", "object", ";", "$", "this", "->", "total", "++", ";", "}" ]
leave the type checking of the arg to the concrete subclasses - to avoid being forced to create an DomainEntityAbstract if i don't want to
[ "leave", "the", "type", "checking", "of", "the", "arg", "to", "the", "concrete", "subclasses", "-", "to", "avoid", "being", "forced", "to", "create", "an", "DomainEntityAbstract", "if", "i", "don", "t", "want", "to" ]
c846b5aa2b55015f1d110024fe71a4e53829e660
https://github.com/johnniewalker/xandria/blob/c846b5aa2b55015f1d110024fe71a4e53829e660/src/DAccess/AbstractMapperCollection.php#L77-L82
240,804
gossi/trixionary
src/model/Base/Reference.php
Reference.countVideos
public function countVideos(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collVideosPartial && !$this->isNew(); if (null === $this->collVideos || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collVideos) { return 0; } if ($partial && !$criteria) { return count($this->getVideos()); } $query = ChildVideoQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByReference($this) ->count($con); } return count($this->collVideos); }
php
public function countVideos(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collVideosPartial && !$this->isNew(); if (null === $this->collVideos || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collVideos) { return 0; } if ($partial && !$criteria) { return count($this->getVideos()); } $query = ChildVideoQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByReference($this) ->count($con); } return count($this->collVideos); }
[ "public", "function", "countVideos", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collVideosPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collVideos", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collVideos", ")", "{", "return", "0", ";", "}", "if", "(", "$", "partial", "&&", "!", "$", "criteria", ")", "{", "return", "count", "(", "$", "this", "->", "getVideos", "(", ")", ")", ";", "}", "$", "query", "=", "ChildVideoQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "if", "(", "$", "distinct", ")", "{", "$", "query", "->", "distinct", "(", ")", ";", "}", "return", "$", "query", "->", "filterByReference", "(", "$", "this", ")", "->", "count", "(", "$", "con", ")", ";", "}", "return", "count", "(", "$", "this", "->", "collVideos", ")", ";", "}" ]
Returns the number of related Video objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related Video objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "Video", "objects", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Reference.php#L2419-L2442
240,805
gossi/trixionary
src/model/Base/Reference.php
Reference.getSkillReferences
public function getSkillReferences(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collSkillReferencesPartial && !$this->isNew(); if (null === $this->collSkillReferences || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collSkillReferences) { // return empty collection $this->initSkillReferences(); } else { $collSkillReferences = ChildSkillReferenceQuery::create(null, $criteria) ->filterByReference($this) ->find($con); if (null !== $criteria) { if (false !== $this->collSkillReferencesPartial && count($collSkillReferences)) { $this->initSkillReferences(false); foreach ($collSkillReferences as $obj) { if (false == $this->collSkillReferences->contains($obj)) { $this->collSkillReferences->append($obj); } } $this->collSkillReferencesPartial = true; } return $collSkillReferences; } if ($partial && $this->collSkillReferences) { foreach ($this->collSkillReferences as $obj) { if ($obj->isNew()) { $collSkillReferences[] = $obj; } } } $this->collSkillReferences = $collSkillReferences; $this->collSkillReferencesPartial = false; } } return $this->collSkillReferences; }
php
public function getSkillReferences(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collSkillReferencesPartial && !$this->isNew(); if (null === $this->collSkillReferences || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collSkillReferences) { // return empty collection $this->initSkillReferences(); } else { $collSkillReferences = ChildSkillReferenceQuery::create(null, $criteria) ->filterByReference($this) ->find($con); if (null !== $criteria) { if (false !== $this->collSkillReferencesPartial && count($collSkillReferences)) { $this->initSkillReferences(false); foreach ($collSkillReferences as $obj) { if (false == $this->collSkillReferences->contains($obj)) { $this->collSkillReferences->append($obj); } } $this->collSkillReferencesPartial = true; } return $collSkillReferences; } if ($partial && $this->collSkillReferences) { foreach ($this->collSkillReferences as $obj) { if ($obj->isNew()) { $collSkillReferences[] = $obj; } } } $this->collSkillReferences = $collSkillReferences; $this->collSkillReferencesPartial = false; } } return $this->collSkillReferences; }
[ "public", "function", "getSkillReferences", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collSkillReferencesPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collSkillReferences", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collSkillReferences", ")", "{", "// return empty collection", "$", "this", "->", "initSkillReferences", "(", ")", ";", "}", "else", "{", "$", "collSkillReferences", "=", "ChildSkillReferenceQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "filterByReference", "(", "$", "this", ")", "->", "find", "(", "$", "con", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "if", "(", "false", "!==", "$", "this", "->", "collSkillReferencesPartial", "&&", "count", "(", "$", "collSkillReferences", ")", ")", "{", "$", "this", "->", "initSkillReferences", "(", "false", ")", ";", "foreach", "(", "$", "collSkillReferences", "as", "$", "obj", ")", "{", "if", "(", "false", "==", "$", "this", "->", "collSkillReferences", "->", "contains", "(", "$", "obj", ")", ")", "{", "$", "this", "->", "collSkillReferences", "->", "append", "(", "$", "obj", ")", ";", "}", "}", "$", "this", "->", "collSkillReferencesPartial", "=", "true", ";", "}", "return", "$", "collSkillReferences", ";", "}", "if", "(", "$", "partial", "&&", "$", "this", "->", "collSkillReferences", ")", "{", "foreach", "(", "$", "this", "->", "collSkillReferences", "as", "$", "obj", ")", "{", "if", "(", "$", "obj", "->", "isNew", "(", ")", ")", "{", "$", "collSkillReferences", "[", "]", "=", "$", "obj", ";", "}", "}", "}", "$", "this", "->", "collSkillReferences", "=", "$", "collSkillReferences", ";", "$", "this", "->", "collSkillReferencesPartial", "=", "false", ";", "}", "}", "return", "$", "this", "->", "collSkillReferences", ";", "}" ]
Gets an array of ChildSkillReference objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildReference is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @return ObjectCollection|ChildSkillReference[] List of ChildSkillReference objects @throws PropelException
[ "Gets", "an", "array", "of", "ChildSkillReference", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Reference.php#L2576-L2618
240,806
gossi/trixionary
src/model/Base/Reference.php
Reference.getSkillReferencesJoinSkill
public function getSkillReferencesJoinSkill(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillReferenceQuery::create(null, $criteria); $query->joinWith('Skill', $joinBehavior); return $this->getSkillReferences($query, $con); }
php
public function getSkillReferencesJoinSkill(Criteria $criteria = null, ConnectionInterface $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildSkillReferenceQuery::create(null, $criteria); $query->joinWith('Skill', $joinBehavior); return $this->getSkillReferences($query, $con); }
[ "public", "function", "getSkillReferencesJoinSkill", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ",", "$", "joinBehavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "ChildSkillReferenceQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "$", "query", "->", "joinWith", "(", "'Skill'", ",", "$", "joinBehavior", ")", ";", "return", "$", "this", "->", "getSkillReferences", "(", "$", "query", ",", "$", "con", ")", ";", "}" ]
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this Reference is new, it will return an empty collection; or if this Reference has previously been saved, it will retrieve related SkillReferences from storage. This method is protected by default in order to keep the public api reasonable. You can provide public methods for those you actually need in Reference. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return ObjectCollection|ChildSkillReference[] List of ChildSkillReference objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "Reference", "is", "new", "it", "will", "return", "an", "empty", "collection", ";", "or", "if", "this", "Reference", "has", "previously", "been", "saved", "it", "will", "retrieve", "related", "SkillReferences", "from", "storage", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Reference.php#L2757-L2763
240,807
gossi/trixionary
src/model/Base/Reference.php
Reference.getSkills
public function getSkills(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collSkillsPartial && !$this->isNew(); if (null === $this->collSkills || null !== $criteria || $partial) { if ($this->isNew()) { // return empty collection if (null === $this->collSkills) { $this->initSkills(); } } else { $query = ChildSkillQuery::create(null, $criteria) ->filterByReference($this); $collSkills = $query->find($con); if (null !== $criteria) { return $collSkills; } if ($partial && $this->collSkills) { //make sure that already added objects gets added to the list of the database. foreach ($this->collSkills as $obj) { if (!$collSkills->contains($obj)) { $collSkills[] = $obj; } } } $this->collSkills = $collSkills; $this->collSkillsPartial = false; } } return $this->collSkills; }
php
public function getSkills(Criteria $criteria = null, ConnectionInterface $con = null) { $partial = $this->collSkillsPartial && !$this->isNew(); if (null === $this->collSkills || null !== $criteria || $partial) { if ($this->isNew()) { // return empty collection if (null === $this->collSkills) { $this->initSkills(); } } else { $query = ChildSkillQuery::create(null, $criteria) ->filterByReference($this); $collSkills = $query->find($con); if (null !== $criteria) { return $collSkills; } if ($partial && $this->collSkills) { //make sure that already added objects gets added to the list of the database. foreach ($this->collSkills as $obj) { if (!$collSkills->contains($obj)) { $collSkills[] = $obj; } } } $this->collSkills = $collSkills; $this->collSkillsPartial = false; } } return $this->collSkills; }
[ "public", "function", "getSkills", "(", "Criteria", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collSkillsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collSkills", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", ")", "{", "// return empty collection", "if", "(", "null", "===", "$", "this", "->", "collSkills", ")", "{", "$", "this", "->", "initSkills", "(", ")", ";", "}", "}", "else", "{", "$", "query", "=", "ChildSkillQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "filterByReference", "(", "$", "this", ")", ";", "$", "collSkills", "=", "$", "query", "->", "find", "(", "$", "con", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "return", "$", "collSkills", ";", "}", "if", "(", "$", "partial", "&&", "$", "this", "->", "collSkills", ")", "{", "//make sure that already added objects gets added to the list of the database.", "foreach", "(", "$", "this", "->", "collSkills", "as", "$", "obj", ")", "{", "if", "(", "!", "$", "collSkills", "->", "contains", "(", "$", "obj", ")", ")", "{", "$", "collSkills", "[", "]", "=", "$", "obj", ";", "}", "}", "}", "$", "this", "->", "collSkills", "=", "$", "collSkills", ";", "$", "this", "->", "collSkillsPartial", "=", "false", ";", "}", "}", "return", "$", "this", "->", "collSkills", ";", "}" ]
Gets a collection of ChildSkill objects related by a many-to-many relationship to the current object by way of the kk_trixionary_skill_reference cross-reference table. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildReference is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria Optional query object to filter the query @param ConnectionInterface $con Optional connection object @return ObjectCollection|ChildSkill[] List of ChildSkill objects
[ "Gets", "a", "collection", "of", "ChildSkill", "objects", "related", "by", "a", "many", "-", "to", "-", "many", "relationship", "to", "the", "current", "object", "by", "way", "of", "the", "kk_trixionary_skill_reference", "cross", "-", "reference", "table", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Reference.php#L2821-L2854
240,808
gossi/trixionary
src/model/Base/Reference.php
Reference.removeSkill
public function removeSkill(ChildSkill $skill) { if ($this->getSkills()->contains($skill)) { $skillReference = new ChildSkillReference(); $skillReference->setSkill($skill); if ($skill->isReferencesLoaded()) { //remove the back reference if available $skill->getReferences()->removeObject($this); } $skillReference->setReference($this); $this->removeSkillReference(clone $skillReference); $skillReference->clear(); $this->collSkills->remove($this->collSkills->search($skill)); if (null === $this->skillsScheduledForDeletion) { $this->skillsScheduledForDeletion = clone $this->collSkills; $this->skillsScheduledForDeletion->clear(); } $this->skillsScheduledForDeletion->push($skill); } return $this; }
php
public function removeSkill(ChildSkill $skill) { if ($this->getSkills()->contains($skill)) { $skillReference = new ChildSkillReference(); $skillReference->setSkill($skill); if ($skill->isReferencesLoaded()) { //remove the back reference if available $skill->getReferences()->removeObject($this); } $skillReference->setReference($this); $this->removeSkillReference(clone $skillReference); $skillReference->clear(); $this->collSkills->remove($this->collSkills->search($skill)); if (null === $this->skillsScheduledForDeletion) { $this->skillsScheduledForDeletion = clone $this->collSkills; $this->skillsScheduledForDeletion->clear(); } $this->skillsScheduledForDeletion->push($skill); } return $this; }
[ "public", "function", "removeSkill", "(", "ChildSkill", "$", "skill", ")", "{", "if", "(", "$", "this", "->", "getSkills", "(", ")", "->", "contains", "(", "$", "skill", ")", ")", "{", "$", "skillReference", "=", "new", "ChildSkillReference", "(", ")", ";", "$", "skillReference", "->", "setSkill", "(", "$", "skill", ")", ";", "if", "(", "$", "skill", "->", "isReferencesLoaded", "(", ")", ")", "{", "//remove the back reference if available", "$", "skill", "->", "getReferences", "(", ")", "->", "removeObject", "(", "$", "this", ")", ";", "}", "$", "skillReference", "->", "setReference", "(", "$", "this", ")", ";", "$", "this", "->", "removeSkillReference", "(", "clone", "$", "skillReference", ")", ";", "$", "skillReference", "->", "clear", "(", ")", ";", "$", "this", "->", "collSkills", "->", "remove", "(", "$", "this", "->", "collSkills", "->", "search", "(", "$", "skill", ")", ")", ";", "if", "(", "null", "===", "$", "this", "->", "skillsScheduledForDeletion", ")", "{", "$", "this", "->", "skillsScheduledForDeletion", "=", "clone", "$", "this", "->", "collSkills", ";", "$", "this", "->", "skillsScheduledForDeletion", "->", "clear", "(", ")", ";", "}", "$", "this", "->", "skillsScheduledForDeletion", "->", "push", "(", "$", "skill", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove skill of this object through the kk_trixionary_skill_reference cross reference table. @param ChildSkill $skill @return ChildReference The current object (for fluent API support)
[ "Remove", "skill", "of", "this", "object", "through", "the", "kk_trixionary_skill_reference", "cross", "reference", "table", "." ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/Reference.php#L2979-L3005
240,809
bmdevel/php-index
classes/Index.php
Index.search
public function search($key) { $binarySearch = new BinarySearch($this); $result = $binarySearch->search($key); if (\is_null($result) || $result->getKey() != $key) { return null; } return $result; }
php
public function search($key) { $binarySearch = new BinarySearch($this); $result = $binarySearch->search($key); if (\is_null($result) || $result->getKey() != $key) { return null; } return $result; }
[ "public", "function", "search", "(", "$", "key", ")", "{", "$", "binarySearch", "=", "new", "BinarySearch", "(", "$", "this", ")", ";", "$", "result", "=", "$", "binarySearch", "->", "search", "(", "$", "key", ")", ";", "if", "(", "\\", "is_null", "(", "$", "result", ")", "||", "$", "result", "->", "getKey", "(", ")", "!=", "$", "key", ")", "{", "return", "null", ";", "}", "return", "$", "result", ";", "}" ]
Searches for the container with that key Returns null if the key wasn't found. @param string $key Key in the index @return Result @throws ReadDataIndexException
[ "Searches", "for", "the", "container", "with", "that", "key" ]
6a6b476f1706b9524bfb34f6ce0963b1aea91259
https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/Index.php#L74-L83
240,810
bmdevel/php-index
classes/Index.php
Index.searchRange
public function searchRange(Range $range) { $iterator = $this->getIterator(); // find start $start = null; $binarySearch = new BinarySearch($this); $startHint = $binarySearch->search($range->getMin()); if ($startHint == null) { return new RangeIterator($iterator, Range::getEmptyRange()); } $iterator->setOffset($startHint->getOffset(), Parser::HINT_RESULT_BOUNDARY); if (! $range->contains($startHint->getKey()) && $startHint->getKey() <= $range->getMin()) { // shift $startHint higher foreach ($iterator as $result) { if ($range->contains($result->getKey())) { $start = $result; break; } } } else { // shift $startHint lower if ($range->contains($startHint->getKey())) { $start = $startHint; } $iterator->setDirection(KeyReader::DIRECTION_BACKWARD); foreach ($iterator as $result) { // Skip everything which is too big if (! $range->contains($result->getKey() && $result->getKey() >= $range->getMax())) { continue; } // shift the start left until no more key is included if ($range->contains($result->getKey())) { $start = $result; } else { break; } } } if (is_null($start)) { return new RangeIterator($iterator, Range::getEmptyRange()); } $iterator = $this->getIterator(); $iterator->setOffset($start->getOffset(), Parser::HINT_RESULT_BOUNDARY); return new RangeIterator($iterator, $range); }
php
public function searchRange(Range $range) { $iterator = $this->getIterator(); // find start $start = null; $binarySearch = new BinarySearch($this); $startHint = $binarySearch->search($range->getMin()); if ($startHint == null) { return new RangeIterator($iterator, Range::getEmptyRange()); } $iterator->setOffset($startHint->getOffset(), Parser::HINT_RESULT_BOUNDARY); if (! $range->contains($startHint->getKey()) && $startHint->getKey() <= $range->getMin()) { // shift $startHint higher foreach ($iterator as $result) { if ($range->contains($result->getKey())) { $start = $result; break; } } } else { // shift $startHint lower if ($range->contains($startHint->getKey())) { $start = $startHint; } $iterator->setDirection(KeyReader::DIRECTION_BACKWARD); foreach ($iterator as $result) { // Skip everything which is too big if (! $range->contains($result->getKey() && $result->getKey() >= $range->getMax())) { continue; } // shift the start left until no more key is included if ($range->contains($result->getKey())) { $start = $result; } else { break; } } } if (is_null($start)) { return new RangeIterator($iterator, Range::getEmptyRange()); } $iterator = $this->getIterator(); $iterator->setOffset($start->getOffset(), Parser::HINT_RESULT_BOUNDARY); return new RangeIterator($iterator, $range); }
[ "public", "function", "searchRange", "(", "Range", "$", "range", ")", "{", "$", "iterator", "=", "$", "this", "->", "getIterator", "(", ")", ";", "// find start", "$", "start", "=", "null", ";", "$", "binarySearch", "=", "new", "BinarySearch", "(", "$", "this", ")", ";", "$", "startHint", "=", "$", "binarySearch", "->", "search", "(", "$", "range", "->", "getMin", "(", ")", ")", ";", "if", "(", "$", "startHint", "==", "null", ")", "{", "return", "new", "RangeIterator", "(", "$", "iterator", ",", "Range", "::", "getEmptyRange", "(", ")", ")", ";", "}", "$", "iterator", "->", "setOffset", "(", "$", "startHint", "->", "getOffset", "(", ")", ",", "Parser", "::", "HINT_RESULT_BOUNDARY", ")", ";", "if", "(", "!", "$", "range", "->", "contains", "(", "$", "startHint", "->", "getKey", "(", ")", ")", "&&", "$", "startHint", "->", "getKey", "(", ")", "<=", "$", "range", "->", "getMin", "(", ")", ")", "{", "// shift $startHint higher", "foreach", "(", "$", "iterator", "as", "$", "result", ")", "{", "if", "(", "$", "range", "->", "contains", "(", "$", "result", "->", "getKey", "(", ")", ")", ")", "{", "$", "start", "=", "$", "result", ";", "break", ";", "}", "}", "}", "else", "{", "// shift $startHint lower", "if", "(", "$", "range", "->", "contains", "(", "$", "startHint", "->", "getKey", "(", ")", ")", ")", "{", "$", "start", "=", "$", "startHint", ";", "}", "$", "iterator", "->", "setDirection", "(", "KeyReader", "::", "DIRECTION_BACKWARD", ")", ";", "foreach", "(", "$", "iterator", "as", "$", "result", ")", "{", "// Skip everything which is too big", "if", "(", "!", "$", "range", "->", "contains", "(", "$", "result", "->", "getKey", "(", ")", "&&", "$", "result", "->", "getKey", "(", ")", ">=", "$", "range", "->", "getMax", "(", ")", ")", ")", "{", "continue", ";", "}", "// shift the start left until no more key is included", "if", "(", "$", "range", "->", "contains", "(", "$", "result", "->", "getKey", "(", ")", ")", ")", "{", "$", "start", "=", "$", "result", ";", "}", "else", "{", "break", ";", "}", "}", "}", "if", "(", "is_null", "(", "$", "start", ")", ")", "{", "return", "new", "RangeIterator", "(", "$", "iterator", ",", "Range", "::", "getEmptyRange", "(", ")", ")", ";", "}", "$", "iterator", "=", "$", "this", "->", "getIterator", "(", ")", ";", "$", "iterator", "->", "setOffset", "(", "$", "start", "->", "getOffset", "(", ")", ",", "Parser", "::", "HINT_RESULT_BOUNDARY", ")", ";", "return", "new", "RangeIterator", "(", "$", "iterator", ",", "$", "range", ")", ";", "}" ]
Searches a range @param Range $range @return RangeIterator
[ "Searches", "a", "range" ]
6a6b476f1706b9524bfb34f6ce0963b1aea91259
https://github.com/bmdevel/php-index/blob/6a6b476f1706b9524bfb34f6ce0963b1aea91259/classes/Index.php#L92-L151
240,811
phproberto/joomla-common
src/Object/Object.php
Object.get
public function get($property, $default = null) { if (!$this->has($property)) { return $default; } return null !== $this->data[$property] ? $this->data[$property] : $default; }
php
public function get($property, $default = null) { if (!$this->has($property)) { return $default; } return null !== $this->data[$property] ? $this->data[$property] : $default; }
[ "public", "function", "get", "(", "$", "property", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "property", ")", ")", "{", "return", "$", "default", ";", "}", "return", "null", "!==", "$", "this", "->", "data", "[", "$", "property", "]", "?", "$", "this", "->", "data", "[", "$", "property", "]", ":", "$", "default", ";", "}" ]
Get property of the object @param string $property Name of the property to retrieve @param mixed $default Default value if property does not exist @return mixed
[ "Get", "property", "of", "the", "object" ]
bbb37df453bfcb545c3a2c6f14340f0a27e448b2
https://github.com/phproberto/joomla-common/blob/bbb37df453bfcb545c3a2c6f14340f0a27e448b2/src/Object/Object.php#L84-L92
240,812
eghojansu/nutrition
src/SQL/Mapper.php
Mapper.copyfrom
public function copyfrom($var,$func=NULL) { if (is_string($var)) { $var = Base::instance()->get($var); } if ($func) { $var = call_user_func($func, $var); } foreach ($var as $key=>$val) { if ( array_key_exists($key, $this->fields) || array_key_exists($key, $this->extras) ) { $this->set($key,$val); } } }
php
public function copyfrom($var,$func=NULL) { if (is_string($var)) { $var = Base::instance()->get($var); } if ($func) { $var = call_user_func($func, $var); } foreach ($var as $key=>$val) { if ( array_key_exists($key, $this->fields) || array_key_exists($key, $this->extras) ) { $this->set($key,$val); } } }
[ "public", "function", "copyfrom", "(", "$", "var", ",", "$", "func", "=", "NULL", ")", "{", "if", "(", "is_string", "(", "$", "var", ")", ")", "{", "$", "var", "=", "Base", "::", "instance", "(", ")", "->", "get", "(", "$", "var", ")", ";", "}", "if", "(", "$", "func", ")", "{", "$", "var", "=", "call_user_func", "(", "$", "func", ",", "$", "var", ")", ";", "}", "foreach", "(", "$", "var", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "fields", ")", "||", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "extras", ")", ")", "{", "$", "this", "->", "set", "(", "$", "key", ",", "$", "val", ")", ";", "}", "}", "}" ]
Override parent method to accept custom property assigment @param mixed $var @param callable $func @return void
[ "Override", "parent", "method", "to", "accept", "custom", "property", "assigment" ]
3941c62aeb6dafda55349a38dd4107d521f8964a
https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/SQL/Mapper.php#L188-L204
240,813
chigix/chiji-frontend
src/Annotation/RequireAnnotation.php
RequireAnnotation.parse
public function parse($param_str) { $file = new File(trim($param_str), $this->getScope()->getFile()->getAbsoluteFile()->getParent()); if (!$file->exists()) { throw new ResourceNotFoundException($param_str, $this->getScope(), $this->getOccursPos(), "The Requirement File Not Exists"); } if (is_null($require_resource = $this->getParentProject()->getResourceByFile($file))) { throw new \Chigi\Chiji\Exception\ProjectMemberNotFoundException("ERROR: UNREGISTERED Resource File: " + $file->getAbsolutePath()); } if ($this->getScope() instanceof RequiresMapInterface) { $this->getScope()->getRequires()->addResource($require_resource); } }
php
public function parse($param_str) { $file = new File(trim($param_str), $this->getScope()->getFile()->getAbsoluteFile()->getParent()); if (!$file->exists()) { throw new ResourceNotFoundException($param_str, $this->getScope(), $this->getOccursPos(), "The Requirement File Not Exists"); } if (is_null($require_resource = $this->getParentProject()->getResourceByFile($file))) { throw new \Chigi\Chiji\Exception\ProjectMemberNotFoundException("ERROR: UNREGISTERED Resource File: " + $file->getAbsolutePath()); } if ($this->getScope() instanceof RequiresMapInterface) { $this->getScope()->getRequires()->addResource($require_resource); } }
[ "public", "function", "parse", "(", "$", "param_str", ")", "{", "$", "file", "=", "new", "File", "(", "trim", "(", "$", "param_str", ")", ",", "$", "this", "->", "getScope", "(", ")", "->", "getFile", "(", ")", "->", "getAbsoluteFile", "(", ")", "->", "getParent", "(", ")", ")", ";", "if", "(", "!", "$", "file", "->", "exists", "(", ")", ")", "{", "throw", "new", "ResourceNotFoundException", "(", "$", "param_str", ",", "$", "this", "->", "getScope", "(", ")", ",", "$", "this", "->", "getOccursPos", "(", ")", ",", "\"The Requirement File Not Exists\"", ")", ";", "}", "if", "(", "is_null", "(", "$", "require_resource", "=", "$", "this", "->", "getParentProject", "(", ")", "->", "getResourceByFile", "(", "$", "file", ")", ")", ")", "{", "throw", "new", "\\", "Chigi", "\\", "Chiji", "\\", "Exception", "\\", "ProjectMemberNotFoundException", "(", "\"ERROR: UNREGISTERED Resource File: \"", "+", "$", "file", "->", "getAbsolutePath", "(", ")", ")", ";", "}", "if", "(", "$", "this", "->", "getScope", "(", ")", "instanceof", "RequiresMapInterface", ")", "{", "$", "this", "->", "getScope", "(", ")", "->", "getRequires", "(", ")", "->", "addResource", "(", "$", "require_resource", ")", ";", "}", "}" ]
Parse the path param in the require annotation to an Resource File Object. @param string $param_str The String as params following the command name @throws ResourceNotFoundException
[ "Parse", "the", "path", "param", "in", "the", "require", "annotation", "to", "an", "Resource", "File", "Object", "." ]
5407f98c21ee99f8bbef43c97a231c0f81ed3e74
https://github.com/chigix/chiji-frontend/blob/5407f98c21ee99f8bbef43c97a231c0f81ed3e74/src/Annotation/RequireAnnotation.php#L38-L49
240,814
bishopb/vanilla
applications/dashboard/models/tiny_diff.php
Tiny_diff.compare
public function compare($old, $new, $mode = 'normal') { // Mixed if ( $mode === 'mixed') { // Insert characters $ins_begin = '<ins>+ '; $ins_end = '</ins>' . PHP_EOL; // Delete characters $del_begin = '<del>- '; $del_end = '</del>' . PHP_EOL; } // HTML mode elseif ( $mode === 'html' ) { // Insert characters $ins_begin = '<ins>'; $ins_end = '</ins>' . PHP_EOL; // Delete characters $del_begin = '<del>'; $del_end = '</del>' . PHP_EOL; } // Normal mode else { // Insert characters $ins_begin = '+ '; $ins_end = PHP_EOL; // Delete characters $del_begin = '- '; $del_end = PHP_EOL; } // Turn the strings into an array so it's a bit easier to parse them $diff = $this->diff(explode(PHP_EOL, $old), explode(PHP_EOL, $new)); $result = ''; if ($mode == 'raw') return $diff; foreach($diff as $line) { if(is_array($line)) { $result .= !empty($line['del']) ? $del_begin . implode(PHP_EOL, $line['del']) . $del_end : ''; $result .= !empty($line['ins']) ? $ins_begin . implode(PHP_EOL, $line['ins']) . $ins_end : ''; } else { $result .= $line . PHP_EOL; } } // Return the result return $result; }
php
public function compare($old, $new, $mode = 'normal') { // Mixed if ( $mode === 'mixed') { // Insert characters $ins_begin = '<ins>+ '; $ins_end = '</ins>' . PHP_EOL; // Delete characters $del_begin = '<del>- '; $del_end = '</del>' . PHP_EOL; } // HTML mode elseif ( $mode === 'html' ) { // Insert characters $ins_begin = '<ins>'; $ins_end = '</ins>' . PHP_EOL; // Delete characters $del_begin = '<del>'; $del_end = '</del>' . PHP_EOL; } // Normal mode else { // Insert characters $ins_begin = '+ '; $ins_end = PHP_EOL; // Delete characters $del_begin = '- '; $del_end = PHP_EOL; } // Turn the strings into an array so it's a bit easier to parse them $diff = $this->diff(explode(PHP_EOL, $old), explode(PHP_EOL, $new)); $result = ''; if ($mode == 'raw') return $diff; foreach($diff as $line) { if(is_array($line)) { $result .= !empty($line['del']) ? $del_begin . implode(PHP_EOL, $line['del']) . $del_end : ''; $result .= !empty($line['ins']) ? $ins_begin . implode(PHP_EOL, $line['ins']) . $ins_end : ''; } else { $result .= $line . PHP_EOL; } } // Return the result return $result; }
[ "public", "function", "compare", "(", "$", "old", ",", "$", "new", ",", "$", "mode", "=", "'normal'", ")", "{", "// Mixed", "if", "(", "$", "mode", "===", "'mixed'", ")", "{", "// Insert characters", "$", "ins_begin", "=", "'<ins>+ '", ";", "$", "ins_end", "=", "'</ins>'", ".", "PHP_EOL", ";", "// Delete characters", "$", "del_begin", "=", "'<del>- '", ";", "$", "del_end", "=", "'</del>'", ".", "PHP_EOL", ";", "}", "// HTML mode", "elseif", "(", "$", "mode", "===", "'html'", ")", "{", "// Insert characters", "$", "ins_begin", "=", "'<ins>'", ";", "$", "ins_end", "=", "'</ins>'", ".", "PHP_EOL", ";", "// Delete characters", "$", "del_begin", "=", "'<del>'", ";", "$", "del_end", "=", "'</del>'", ".", "PHP_EOL", ";", "}", "// Normal mode", "else", "{", "// Insert characters", "$", "ins_begin", "=", "'+ '", ";", "$", "ins_end", "=", "PHP_EOL", ";", "// Delete characters", "$", "del_begin", "=", "'- '", ";", "$", "del_end", "=", "PHP_EOL", ";", "}", "// Turn the strings into an array so it's a bit easier to parse them", "$", "diff", "=", "$", "this", "->", "diff", "(", "explode", "(", "PHP_EOL", ",", "$", "old", ")", ",", "explode", "(", "PHP_EOL", ",", "$", "new", ")", ")", ";", "$", "result", "=", "''", ";", "if", "(", "$", "mode", "==", "'raw'", ")", "return", "$", "diff", ";", "foreach", "(", "$", "diff", "as", "$", "line", ")", "{", "if", "(", "is_array", "(", "$", "line", ")", ")", "{", "$", "result", ".=", "!", "empty", "(", "$", "line", "[", "'del'", "]", ")", "?", "$", "del_begin", ".", "implode", "(", "PHP_EOL", ",", "$", "line", "[", "'del'", "]", ")", ".", "$", "del_end", ":", "''", ";", "$", "result", ".=", "!", "empty", "(", "$", "line", "[", "'ins'", "]", ")", "?", "$", "ins_begin", ".", "implode", "(", "PHP_EOL", ",", "$", "line", "[", "'ins'", "]", ")", ".", "$", "ins_end", ":", "''", ";", "}", "else", "{", "$", "result", ".=", "$", "line", ".", "PHP_EOL", ";", "}", "}", "// Return the result", "return", "$", "result", ";", "}" ]
Compare two strings and return the difference @access public @param string $old The first block of data @param string $new The second block of data @param string $mode The mode to use. Possible values are normal, html and mixed @return string
[ "Compare", "two", "strings", "and", "return", "the", "difference" ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/tiny_diff.php#L44-L102
240,815
bishopb/vanilla
applications/dashboard/models/tiny_diff.php
Tiny_diff.diff
private function diff($old, $new) { $maxlen = 0; // Go through each old line. foreach($old as $old_line => $old_value) { // Get the new lines that match the old line $new_lines = array_keys($new, $old_value); // Go through each new line number foreach($new_lines as $new_line) { $matrix[$old_line][$new_line] = isset($matrix[$old_line - 1][$new_line - 1]) ? $matrix[$old_line - 1][$new_line - 1] + 1 : 1; if($matrix[$old_line][$new_line] > $maxlen) { $maxlen = $matrix[$old_line][$new_line]; $old_max = $old_line + 1 - $maxlen; $new_max = $new_line + 1 - $maxlen; } } } if($maxlen == 0) { return array(array('del'=>$old, 'ins'=>$new)); } return array_merge( self::diff(array_slice($old, 0, $old_max), array_slice($new, 0, $new_max)), array_slice($new, $new_max, $maxlen), self::diff(array_slice($old, $old_max + $maxlen), array_slice($new, $new_max + $maxlen)) ); }
php
private function diff($old, $new) { $maxlen = 0; // Go through each old line. foreach($old as $old_line => $old_value) { // Get the new lines that match the old line $new_lines = array_keys($new, $old_value); // Go through each new line number foreach($new_lines as $new_line) { $matrix[$old_line][$new_line] = isset($matrix[$old_line - 1][$new_line - 1]) ? $matrix[$old_line - 1][$new_line - 1] + 1 : 1; if($matrix[$old_line][$new_line] > $maxlen) { $maxlen = $matrix[$old_line][$new_line]; $old_max = $old_line + 1 - $maxlen; $new_max = $new_line + 1 - $maxlen; } } } if($maxlen == 0) { return array(array('del'=>$old, 'ins'=>$new)); } return array_merge( self::diff(array_slice($old, 0, $old_max), array_slice($new, 0, $new_max)), array_slice($new, $new_max, $maxlen), self::diff(array_slice($old, $old_max + $maxlen), array_slice($new, $new_max + $maxlen)) ); }
[ "private", "function", "diff", "(", "$", "old", ",", "$", "new", ")", "{", "$", "maxlen", "=", "0", ";", "// Go through each old line.", "foreach", "(", "$", "old", "as", "$", "old_line", "=>", "$", "old_value", ")", "{", "// Get the new lines that match the old line", "$", "new_lines", "=", "array_keys", "(", "$", "new", ",", "$", "old_value", ")", ";", "// Go through each new line number", "foreach", "(", "$", "new_lines", "as", "$", "new_line", ")", "{", "$", "matrix", "[", "$", "old_line", "]", "[", "$", "new_line", "]", "=", "isset", "(", "$", "matrix", "[", "$", "old_line", "-", "1", "]", "[", "$", "new_line", "-", "1", "]", ")", "?", "$", "matrix", "[", "$", "old_line", "-", "1", "]", "[", "$", "new_line", "-", "1", "]", "+", "1", ":", "1", ";", "if", "(", "$", "matrix", "[", "$", "old_line", "]", "[", "$", "new_line", "]", ">", "$", "maxlen", ")", "{", "$", "maxlen", "=", "$", "matrix", "[", "$", "old_line", "]", "[", "$", "new_line", "]", ";", "$", "old_max", "=", "$", "old_line", "+", "1", "-", "$", "maxlen", ";", "$", "new_max", "=", "$", "new_line", "+", "1", "-", "$", "maxlen", ";", "}", "}", "}", "if", "(", "$", "maxlen", "==", "0", ")", "{", "return", "array", "(", "array", "(", "'del'", "=>", "$", "old", ",", "'ins'", "=>", "$", "new", ")", ")", ";", "}", "return", "array_merge", "(", "self", "::", "diff", "(", "array_slice", "(", "$", "old", ",", "0", ",", "$", "old_max", ")", ",", "array_slice", "(", "$", "new", ",", "0", ",", "$", "new_max", ")", ")", ",", "array_slice", "(", "$", "new", ",", "$", "new_max", ",", "$", "maxlen", ")", ",", "self", "::", "diff", "(", "array_slice", "(", "$", "old", ",", "$", "old_max", "+", "$", "maxlen", ")", ",", "array_slice", "(", "$", "new", ",", "$", "new_max", "+", "$", "maxlen", ")", ")", ")", ";", "}" ]
Diff function. Contributed by Dan Horrigan who again took it from Paul Butler. @author Paul Butler @link http://github.com/paulgb/simplediff/blob/master/simplediff.php @access private @param string $old The old block of data @param string $new The new block of data
[ "Diff", "function", ".", "Contributed", "by", "Dan", "Horrigan", "who", "again", "took", "it", "from", "Paul", "Butler", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/tiny_diff.php#L115-L145
240,816
GodsDev/backyard
GodsDev/Backyard/BackyardGeo.php
BackyardGeo.getRoughDistance
public function getRoughDistance($clientLng, $clientLat, $poiLng, $poiLat) { $result = abs($clientLng - $poiLng) + abs($clientLat - $poiLat); $this->BackyardError->log(5, "client({$clientLng}, {$clientLat}) poi({$poiLng}, {$poiLat}) roughDistance = {$result}"); return $result; }
php
public function getRoughDistance($clientLng, $clientLat, $poiLng, $poiLat) { $result = abs($clientLng - $poiLng) + abs($clientLat - $poiLat); $this->BackyardError->log(5, "client({$clientLng}, {$clientLat}) poi({$poiLng}, {$poiLat}) roughDistance = {$result}"); return $result; }
[ "public", "function", "getRoughDistance", "(", "$", "clientLng", ",", "$", "clientLat", ",", "$", "poiLng", ",", "$", "poiLat", ")", "{", "$", "result", "=", "abs", "(", "$", "clientLng", "-", "$", "poiLng", ")", "+", "abs", "(", "$", "clientLat", "-", "$", "poiLat", ")", ";", "$", "this", "->", "BackyardError", "->", "log", "(", "5", ",", "\"client({$clientLng}, {$clientLat}) poi({$poiLng}, {$poiLat}) roughDistance = {$result}\"", ")", ";", "return", "$", "result", ";", "}" ]
1 ~ 100km @param float $clientLng @param float $clientLat @param float $poiLng @param float $poiLat @return float
[ "1", "~", "100km" ]
992da766a50fca04e9c6e963cbe98d37e3d47f8f
https://github.com/GodsDev/backyard/blob/992da766a50fca04e9c6e963cbe98d37e3d47f8f/GodsDev/Backyard/BackyardGeo.php#L100-L105
240,817
hegotecnologia/support
src/Domain/ServiceProvider.php
ServiceProvider.register
public function register() { // Register Sub Providers $this->registerSubProviders(collect($this->subProviders)); // Register bindings. $this->registerBindings(collect($this->bindings)); // Register migrations. $this->registerMigrations(collect($this->migrations)); // Register seeders. $this->registerSeeders(collect($this->seeders)); // Register model factories. $this->registerFactories(collect($this->factories)); }
php
public function register() { // Register Sub Providers $this->registerSubProviders(collect($this->subProviders)); // Register bindings. $this->registerBindings(collect($this->bindings)); // Register migrations. $this->registerMigrations(collect($this->migrations)); // Register seeders. $this->registerSeeders(collect($this->seeders)); // Register model factories. $this->registerFactories(collect($this->factories)); }
[ "public", "function", "register", "(", ")", "{", "// Register Sub Providers", "$", "this", "->", "registerSubProviders", "(", "collect", "(", "$", "this", "->", "subProviders", ")", ")", ";", "// Register bindings.", "$", "this", "->", "registerBindings", "(", "collect", "(", "$", "this", "->", "bindings", ")", ")", ";", "// Register migrations.", "$", "this", "->", "registerMigrations", "(", "collect", "(", "$", "this", "->", "migrations", ")", ")", ";", "// Register seeders.", "$", "this", "->", "registerSeeders", "(", "collect", "(", "$", "this", "->", "seeders", ")", ")", ";", "// Register model factories.", "$", "this", "->", "registerFactories", "(", "collect", "(", "$", "this", "->", "factories", ")", ")", ";", "}" ]
Register the current Domain.
[ "Register", "the", "current", "Domain", "." ]
3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc
https://github.com/hegotecnologia/support/blob/3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc/src/Domain/ServiceProvider.php#L60-L72
240,818
hegotecnologia/support
src/Domain/ServiceProvider.php
ServiceProvider.registerSubProviders
protected function registerSubProviders(Collection $subProviders) { $subProviders->each(function ($provider) { $this->app->register($provider); }); }
php
protected function registerSubProviders(Collection $subProviders) { $subProviders->each(function ($provider) { $this->app->register($provider); }); }
[ "protected", "function", "registerSubProviders", "(", "Collection", "$", "subProviders", ")", "{", "$", "subProviders", "->", "each", "(", "function", "(", "$", "provider", ")", "{", "$", "this", "->", "app", "->", "register", "(", "$", "provider", ")", ";", "}", ")", ";", "}" ]
Register domain sub providers. @param Collection $subProviders
[ "Register", "domain", "sub", "providers", "." ]
3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc
https://github.com/hegotecnologia/support/blob/3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc/src/Domain/ServiceProvider.php#L79-L84
240,819
hegotecnologia/support
src/Domain/ServiceProvider.php
ServiceProvider.registerBindings
protected function registerBindings(Collection $bindings) { $bindings->each(function ($concretion, $abstraction) { $this->app->bind($abstraction, $concretion); }); }
php
protected function registerBindings(Collection $bindings) { $bindings->each(function ($concretion, $abstraction) { $this->app->bind($abstraction, $concretion); }); }
[ "protected", "function", "registerBindings", "(", "Collection", "$", "bindings", ")", "{", "$", "bindings", "->", "each", "(", "function", "(", "$", "concretion", ",", "$", "abstraction", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "$", "abstraction", ",", "$", "concretion", ")", ";", "}", ")", ";", "}" ]
Register the defined domain bindings. @param Collection $bindings
[ "Register", "the", "defined", "domain", "bindings", "." ]
3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc
https://github.com/hegotecnologia/support/blob/3862bdf82dd7d3a6f0cec1afd2a04531bd75e0cc/src/Domain/ServiceProvider.php#L91-L96
240,820
martinhej/robocloud
src/robocloud/Kinesis/RobocloudKinesisClient.php
RobocloudKinesisClient.getKinesisClient
public function getKinesisClient($type) { if (!empty($this->clients[$type])) { return $this->clients[$type]; } $config = [ 'version' => $this->config['api_version'], 'region' => $this->config['region'], ]; $config['credentials'] = [ 'key' => $this->config[$type]['key'], 'secret' => $this->config[$type]['secret'], ]; $sdk = new Sdk(); $this->clients[$type] = $sdk->createKinesis($config); return $this->clients[$type]; }
php
public function getKinesisClient($type) { if (!empty($this->clients[$type])) { return $this->clients[$type]; } $config = [ 'version' => $this->config['api_version'], 'region' => $this->config['region'], ]; $config['credentials'] = [ 'key' => $this->config[$type]['key'], 'secret' => $this->config[$type]['secret'], ]; $sdk = new Sdk(); $this->clients[$type] = $sdk->createKinesis($config); return $this->clients[$type]; }
[ "public", "function", "getKinesisClient", "(", "$", "type", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "clients", "[", "$", "type", "]", ")", ")", "{", "return", "$", "this", "->", "clients", "[", "$", "type", "]", ";", "}", "$", "config", "=", "[", "'version'", "=>", "$", "this", "->", "config", "[", "'api_version'", "]", ",", "'region'", "=>", "$", "this", "->", "config", "[", "'region'", "]", ",", "]", ";", "$", "config", "[", "'credentials'", "]", "=", "[", "'key'", "=>", "$", "this", "->", "config", "[", "$", "type", "]", "[", "'key'", "]", ",", "'secret'", "=>", "$", "this", "->", "config", "[", "$", "type", "]", "[", "'secret'", "]", ",", "]", ";", "$", "sdk", "=", "new", "Sdk", "(", ")", ";", "$", "this", "->", "clients", "[", "$", "type", "]", "=", "$", "sdk", "->", "createKinesis", "(", "$", "config", ")", ";", "return", "$", "this", "->", "clients", "[", "$", "type", "]", ";", "}" ]
Gets the Kinesis client. @param string $type The client type [producer, consumer]. @return \Aws\Kinesis\KinesisClient
[ "Gets", "the", "Kinesis", "client", "." ]
108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229
https://github.com/martinhej/robocloud/blob/108dfbc2b6e9aca2a87795c3e7518cbf1cf5d229/src/robocloud/Kinesis/RobocloudKinesisClient.php#L38-L59
240,821
dsi-agpt/minibus
src/Minibus/Controller/IndexController.php
IndexController.preDispatch
public function preDispatch(MvcEvent $e) { if ($this->zfcUserAuthentication ()->hasIdentity ()) { $userName = $this->zfcUserAuthentication ()->getIdentity ()->getUsername (); } else { $userName = 'anonymous'; } $this->layout ()->setVariable ( 'dataTypes', $this->getDataTypesHandler ()->getDataTypes () ); $this->layout ()->setVariable ( 'userName', $userName ); $this->layout ()->setVariable ( 'action', $this->params ( 'action' ) ); $this->layout ()->setVariable ( 'authService', $this->getFileAuthService () ); $this->layout ()->setVariable ( 'jqueryUiTheme', $this->getJqueryUiTheme () ); $controller = $this->params ( 'controller' ); $controller = explode ( '\\', $controller ); $controller = array_pop ( $controller ); $controller = strtolower ( $controller ); $this->layout ()->setVariable ( 'controller', $controller ); }
php
public function preDispatch(MvcEvent $e) { if ($this->zfcUserAuthentication ()->hasIdentity ()) { $userName = $this->zfcUserAuthentication ()->getIdentity ()->getUsername (); } else { $userName = 'anonymous'; } $this->layout ()->setVariable ( 'dataTypes', $this->getDataTypesHandler ()->getDataTypes () ); $this->layout ()->setVariable ( 'userName', $userName ); $this->layout ()->setVariable ( 'action', $this->params ( 'action' ) ); $this->layout ()->setVariable ( 'authService', $this->getFileAuthService () ); $this->layout ()->setVariable ( 'jqueryUiTheme', $this->getJqueryUiTheme () ); $controller = $this->params ( 'controller' ); $controller = explode ( '\\', $controller ); $controller = array_pop ( $controller ); $controller = strtolower ( $controller ); $this->layout ()->setVariable ( 'controller', $controller ); }
[ "public", "function", "preDispatch", "(", "MvcEvent", "$", "e", ")", "{", "if", "(", "$", "this", "->", "zfcUserAuthentication", "(", ")", "->", "hasIdentity", "(", ")", ")", "{", "$", "userName", "=", "$", "this", "->", "zfcUserAuthentication", "(", ")", "->", "getIdentity", "(", ")", "->", "getUsername", "(", ")", ";", "}", "else", "{", "$", "userName", "=", "'anonymous'", ";", "}", "$", "this", "->", "layout", "(", ")", "->", "setVariable", "(", "'dataTypes'", ",", "$", "this", "->", "getDataTypesHandler", "(", ")", "->", "getDataTypes", "(", ")", ")", ";", "$", "this", "->", "layout", "(", ")", "->", "setVariable", "(", "'userName'", ",", "$", "userName", ")", ";", "$", "this", "->", "layout", "(", ")", "->", "setVariable", "(", "'action'", ",", "$", "this", "->", "params", "(", "'action'", ")", ")", ";", "$", "this", "->", "layout", "(", ")", "->", "setVariable", "(", "'authService'", ",", "$", "this", "->", "getFileAuthService", "(", ")", ")", ";", "$", "this", "->", "layout", "(", ")", "->", "setVariable", "(", "'jqueryUiTheme'", ",", "$", "this", "->", "getJqueryUiTheme", "(", ")", ")", ";", "$", "controller", "=", "$", "this", "->", "params", "(", "'controller'", ")", ";", "$", "controller", "=", "explode", "(", "'\\\\'", ",", "$", "controller", ")", ";", "$", "controller", "=", "array_pop", "(", "$", "controller", ")", ";", "$", "controller", "=", "strtolower", "(", "$", "controller", ")", ";", "$", "this", "->", "layout", "(", ")", "->", "setVariable", "(", "'controller'", ",", "$", "controller", ")", ";", "}" ]
Avant l'action @param MvcEvent $e
[ "Avant", "l", "action" ]
8262e3d398b8ca30b02ad5665834b46b7a85f1a6
https://github.com/dsi-agpt/minibus/blob/8262e3d398b8ca30b02ad5665834b46b7a85f1a6/src/Minibus/Controller/IndexController.php#L40-L56
240,822
monomelodies/ornament
src/Collection.php
Collection.isDirty
public function isDirty() { if (count($this) != $this->_original) { return true; } if (count($this->_deleted)) { return true; } foreach ($this as $model) { if (is_object($model) && ($model->isDirty() || $model->isNew()) ) { return true; } } return false; }
php
public function isDirty() { if (count($this) != $this->_original) { return true; } if (count($this->_deleted)) { return true; } foreach ($this as $model) { if (is_object($model) && ($model->isDirty() || $model->isNew()) ) { return true; } } return false; }
[ "public", "function", "isDirty", "(", ")", "{", "if", "(", "count", "(", "$", "this", ")", "!=", "$", "this", "->", "_original", ")", "{", "return", "true", ";", "}", "if", "(", "count", "(", "$", "this", "->", "_deleted", ")", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "this", "as", "$", "model", ")", "{", "if", "(", "is_object", "(", "$", "model", ")", "&&", "(", "$", "model", "->", "isDirty", "(", ")", "||", "$", "model", "->", "isNew", "(", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if the collection is "dirty", i.e. its contents have changed since the last save. @return boolean true if dirty, otherwise false.
[ "Check", "if", "the", "collection", "is", "dirty", "i", ".", "e", ".", "its", "contents", "have", "changed", "since", "the", "last", "save", "." ]
d7d070ad11f5731be141cf55c2756accaaf51402
https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Collection.php#L60-L76
240,823
monomelodies/ornament
src/Collection.php
Collection.markClean
public function markClean() { foreach ($this as $model) { if (is_object($model)) { $model->markClean(); } } $this->_original = count($this); }
php
public function markClean() { foreach ($this as $model) { if (is_object($model)) { $model->markClean(); } } $this->_original = count($this); }
[ "public", "function", "markClean", "(", ")", "{", "foreach", "(", "$", "this", "as", "$", "model", ")", "{", "if", "(", "is_object", "(", "$", "model", ")", ")", "{", "$", "model", "->", "markClean", "(", ")", ";", "}", "}", "$", "this", "->", "_original", "=", "count", "(", "$", "this", ")", ";", "}" ]
Mark the collection as "clean", i.e. in pristine state. @return void
[ "Mark", "the", "collection", "as", "clean", "i", ".", "e", ".", "in", "pristine", "state", "." ]
d7d070ad11f5731be141cf55c2756accaaf51402
https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Collection.php#L83-L91
240,824
monomelodies/ornament
src/Collection.php
Collection.jsonSerialize
public function jsonSerialize() { $out = []; foreach ($this as $model) { if (!is_object($model)) { continue; } if ($model instanceof JsonSerializable) { $out[] = $model->jsonSerialize(); } else { $out[] = (object)(array)$model; } } return $out; }
php
public function jsonSerialize() { $out = []; foreach ($this as $model) { if (!is_object($model)) { continue; } if ($model instanceof JsonSerializable) { $out[] = $model->jsonSerialize(); } else { $out[] = (object)(array)$model; } } return $out; }
[ "public", "function", "jsonSerialize", "(", ")", "{", "$", "out", "=", "[", "]", ";", "foreach", "(", "$", "this", "as", "$", "model", ")", "{", "if", "(", "!", "is_object", "(", "$", "model", ")", ")", "{", "continue", ";", "}", "if", "(", "$", "model", "instanceof", "JsonSerializable", ")", "{", "$", "out", "[", "]", "=", "$", "model", "->", "jsonSerialize", "(", ")", ";", "}", "else", "{", "$", "out", "[", "]", "=", "(", "object", ")", "(", "array", ")", "$", "model", ";", "}", "}", "return", "$", "out", ";", "}" ]
Export the Collection as a regular PHP array for Json serialization. @return array The Collection represented as an array.
[ "Export", "the", "Collection", "as", "a", "regular", "PHP", "array", "for", "Json", "serialization", "." ]
d7d070ad11f5731be141cf55c2756accaaf51402
https://github.com/monomelodies/ornament/blob/d7d070ad11f5731be141cf55c2756accaaf51402/src/Collection.php#L98-L112
240,825
G4MR/Configs
src/Item.php
Item.get
public function get($key, $default = null) { if(!is_string($key) || empty($key)) { return $default; } //split string into array $item_pieces = explode('.', $key); //let igorw check if array item exists return igorw\get_in($this->data, $item_pieces, $default); }
php
public function get($key, $default = null) { if(!is_string($key) || empty($key)) { return $default; } //split string into array $item_pieces = explode('.', $key); //let igorw check if array item exists return igorw\get_in($this->data, $item_pieces, $default); }
[ "public", "function", "get", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "is_string", "(", "$", "key", ")", "||", "empty", "(", "$", "key", ")", ")", "{", "return", "$", "default", ";", "}", "//split string into array", "$", "item_pieces", "=", "explode", "(", "'.'", ",", "$", "key", ")", ";", "//let igorw check if array item exists", "return", "igorw", "\\", "get_in", "(", "$", "this", "->", "data", ",", "$", "item_pieces", ",", "$", "default", ")", ";", "}" ]
Gets item from array if it exists else return default value @param string $item dot notation config_file.array.item @param mixed $default value if it doesn't exist @return mixed
[ "Gets", "item", "from", "array", "if", "it", "exists", "else", "return", "default", "value" ]
3e5d13f822cb5c9e2f5a1f946d9107f534570b6a
https://github.com/G4MR/Configs/blob/3e5d13f822cb5c9e2f5a1f946d9107f534570b6a/src/Item.php#L30-L41
240,826
vinala/kernel
src/Database/Seeder.php
Seeder.execute
protected static function execute($seeder) { $data = self::fill($seeder); // $table = new DBTable($seeder->table); return $table->insert($data); }
php
protected static function execute($seeder) { $data = self::fill($seeder); // $table = new DBTable($seeder->table); return $table->insert($data); }
[ "protected", "static", "function", "execute", "(", "$", "seeder", ")", "{", "$", "data", "=", "self", "::", "fill", "(", "$", "seeder", ")", ";", "//", "$", "table", "=", "new", "DBTable", "(", "$", "seeder", "->", "table", ")", ";", "return", "$", "table", "->", "insert", "(", "$", "data", ")", ";", "}" ]
Execute thh seeder.
[ "Execute", "thh", "seeder", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Seeder.php#L54-L61
240,827
vinala/kernel
src/Database/Seeder.php
Seeder.fill
public static function fill($seeder) { $data = []; // if ($seeder->count <= 0) { foreach ($seeder->data() as $value) { // Collection::push($data, $value); array_push($data, $value); } } else { for ($i = 0; $i < $seeder->count; $i++) { // Collection::push($data, $seeder->data()); array_push($data, $seeder->data()); } } // return $data; }
php
public static function fill($seeder) { $data = []; // if ($seeder->count <= 0) { foreach ($seeder->data() as $value) { // Collection::push($data, $value); array_push($data, $value); } } else { for ($i = 0; $i < $seeder->count; $i++) { // Collection::push($data, $seeder->data()); array_push($data, $seeder->data()); } } // return $data; }
[ "public", "static", "function", "fill", "(", "$", "seeder", ")", "{", "$", "data", "=", "[", "]", ";", "//", "if", "(", "$", "seeder", "->", "count", "<=", "0", ")", "{", "foreach", "(", "$", "seeder", "->", "data", "(", ")", "as", "$", "value", ")", "{", "// Collection::push($data, $value);", "array_push", "(", "$", "data", ",", "$", "value", ")", ";", "}", "}", "else", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "seeder", "->", "count", ";", "$", "i", "++", ")", "{", "// Collection::push($data, $seeder->data());", "array_push", "(", "$", "data", ",", "$", "seeder", "->", "data", "(", ")", ")", ";", "}", "}", "//", "return", "$", "data", ";", "}" ]
Fill data.
[ "Fill", "data", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Database/Seeder.php#L66-L83
240,828
agencms/auth
src/Controllers/PasswordController.php
PasswordController.request
public function request(Request $request) { $user = User::whereEmail($request->email)->firstOrFail(); $user->sendResetPasswordNotification($this->broker()->createToken($user), $request); return response()->json('Password request successful', 200); }
php
public function request(Request $request) { $user = User::whereEmail($request->email)->firstOrFail(); $user->sendResetPasswordNotification($this->broker()->createToken($user), $request); return response()->json('Password request successful', 200); }
[ "public", "function", "request", "(", "Request", "$", "request", ")", "{", "$", "user", "=", "User", "::", "whereEmail", "(", "$", "request", "->", "email", ")", "->", "firstOrFail", "(", ")", ";", "$", "user", "->", "sendResetPasswordNotification", "(", "$", "this", "->", "broker", "(", ")", "->", "createToken", "(", "$", "user", ")", ",", "$", "request", ")", ";", "return", "response", "(", ")", "->", "json", "(", "'Password request successful'", ",", "200", ")", ";", "}" ]
Send an email to the registered email address with a reset password link @param Request $request @return \Illuminate\Http\RedirectResponse|\Illuminate\Http\JsonResponse
[ "Send", "an", "email", "to", "the", "registered", "email", "address", "with", "a", "reset", "password", "link" ]
a255988180c461c1ccbc62e2ab3660d379e6e072
https://github.com/agencms/auth/blob/a255988180c461c1ccbc62e2ab3660d379e6e072/src/Controllers/PasswordController.php#L21-L27
240,829
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/Scores.php
Scores.createNew
public function createNew( string $attribute, string $name, float $value ) : array { return $this->sendPost( sprintf('/profiles/%s/scores', $this->userName), [], [ 'attribute' => $attribute, 'name' => $name, 'value' => $value ] ); }
php
public function createNew( string $attribute, string $name, float $value ) : array { return $this->sendPost( sprintf('/profiles/%s/scores', $this->userName), [], [ 'attribute' => $attribute, 'name' => $name, 'value' => $value ] ); }
[ "public", "function", "createNew", "(", "string", "$", "attribute", ",", "string", "$", "name", ",", "float", "$", "value", ")", ":", "array", "{", "return", "$", "this", "->", "sendPost", "(", "sprintf", "(", "'/profiles/%s/scores'", ",", "$", "this", "->", "userName", ")", ",", "[", "]", ",", "[", "'attribute'", "=>", "$", "attribute", ",", "'name'", "=>", "$", "name", ",", "'value'", "=>", "$", "value", "]", ")", ";", "}" ]
Creates a new score for the given source. @param string $attribute @param string $name @param float $value @return array Response
[ "Creates", "a", "new", "score", "for", "the", "given", "source", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Scores.php#L20-L34
240,830
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/Scores.php
Scores.upsertOne
public function upsertOne( string $attribute, string $name, float $value ) : array { return $this->sendPut( sprintf('/profiles/%s/scores', $this->userName), [], [ 'attribute' => $attribute, 'name' => $name, 'value' => $value ] ); }
php
public function upsertOne( string $attribute, string $name, float $value ) : array { return $this->sendPut( sprintf('/profiles/%s/scores', $this->userName), [], [ 'attribute' => $attribute, 'name' => $name, 'value' => $value ] ); }
[ "public", "function", "upsertOne", "(", "string", "$", "attribute", ",", "string", "$", "name", ",", "float", "$", "value", ")", ":", "array", "{", "return", "$", "this", "->", "sendPut", "(", "sprintf", "(", "'/profiles/%s/scores'", ",", "$", "this", "->", "userName", ")", ",", "[", "]", ",", "[", "'attribute'", "=>", "$", "attribute", ",", "'name'", "=>", "$", "name", ",", "'value'", "=>", "$", "value", "]", ")", ";", "}" ]
Tries to update a score and if it doesnt exists, creates a new score. @param string $attribute @param string $name @param float $value @return array Response
[ "Tries", "to", "update", "a", "score", "and", "if", "it", "doesnt", "exists", "creates", "a", "new", "score", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Scores.php#L45-L59
240,831
veridu/idos-sdk-php
src/idOS/Endpoint/Profile/Scores.php
Scores.updateOne
public function updateOne(string $attribute, string $name, float $value) : array { return $this->sendPatch( sprintf('/profiles/%s/scores/%s', $this->userName, $name), [], [ 'attribute' => $attribute, 'value' => $value ] ); }
php
public function updateOne(string $attribute, string $name, float $value) : array { return $this->sendPatch( sprintf('/profiles/%s/scores/%s', $this->userName, $name), [], [ 'attribute' => $attribute, 'value' => $value ] ); }
[ "public", "function", "updateOne", "(", "string", "$", "attribute", ",", "string", "$", "name", ",", "float", "$", "value", ")", ":", "array", "{", "return", "$", "this", "->", "sendPatch", "(", "sprintf", "(", "'/profiles/%s/scores/%s'", ",", "$", "this", "->", "userName", ",", "$", "name", ")", ",", "[", "]", ",", "[", "'attribute'", "=>", "$", "attribute", ",", "'value'", "=>", "$", "value", "]", ")", ";", "}" ]
Updates a score in the given profile. @param string $attribute @param string $name @param float $value @return array Response
[ "Updates", "a", "score", "in", "the", "given", "profile", "." ]
e56757bed10404756f2f0485a4b7f55794192008
https://github.com/veridu/idos-sdk-php/blob/e56757bed10404756f2f0485a4b7f55794192008/src/idOS/Endpoint/Profile/Scores.php#L97-L106
240,832
DaoAndCo/cakephp-cachecleaner
src/Shell/ClearShell.php
ClearShell.all
public function all() { foreach ( $this->tasks as $task => $option ) { $task = $this->taskClassname($task); $this->$task->all(); } }
php
public function all() { foreach ( $this->tasks as $task => $option ) { $task = $this->taskClassname($task); $this->$task->all(); } }
[ "public", "function", "all", "(", ")", "{", "foreach", "(", "$", "this", "->", "tasks", "as", "$", "task", "=>", "$", "option", ")", "{", "$", "task", "=", "$", "this", "->", "taskClassname", "(", "$", "task", ")", ";", "$", "this", "->", "$", "task", "->", "all", "(", ")", ";", "}", "}" ]
Execute all tasks
[ "Execute", "all", "tasks" ]
b4a05a003c3e0e55671eb315f900511cfcd295d6
https://github.com/DaoAndCo/cakephp-cachecleaner/blob/b4a05a003c3e0e55671eb315f900511cfcd295d6/src/Shell/ClearShell.php#L67-L73
240,833
whackashoe/bstall
src/Whackashoe/Bstall/Bstall.php
Bstall.make
public function make($name="default", $width=100, $height=100, $bgcolor=0xFFFFFF) { $bstall = new Bstall; $this->width = $width; $this->height = $height; $this->bgcolor = $bgcolor; $this->load($name); return View::make('bstall::canvas', [ 'name' => $name, 'width' => $this->width, 'height' => $this->height, 'canvas' => json_encode($this->canvas, true) ]); }
php
public function make($name="default", $width=100, $height=100, $bgcolor=0xFFFFFF) { $bstall = new Bstall; $this->width = $width; $this->height = $height; $this->bgcolor = $bgcolor; $this->load($name); return View::make('bstall::canvas', [ 'name' => $name, 'width' => $this->width, 'height' => $this->height, 'canvas' => json_encode($this->canvas, true) ]); }
[ "public", "function", "make", "(", "$", "name", "=", "\"default\"", ",", "$", "width", "=", "100", ",", "$", "height", "=", "100", ",", "$", "bgcolor", "=", "0xFFFFFF", ")", "{", "$", "bstall", "=", "new", "Bstall", ";", "$", "this", "->", "width", "=", "$", "width", ";", "$", "this", "->", "height", "=", "$", "height", ";", "$", "this", "->", "bgcolor", "=", "$", "bgcolor", ";", "$", "this", "->", "load", "(", "$", "name", ")", ";", "return", "View", "::", "make", "(", "'bstall::canvas'", ",", "[", "'name'", "=>", "$", "name", ",", "'width'", "=>", "$", "this", "->", "width", ",", "'height'", "=>", "$", "this", "->", "height", ",", "'canvas'", "=>", "json_encode", "(", "$", "this", "->", "canvas", ",", "true", ")", "]", ")", ";", "}" ]
Print stall's canvas @param string $name @param int $width @param int $height @param int $bgcolor @return Illuminate\View\View
[ "Print", "stall", "s", "canvas" ]
f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe
https://github.com/whackashoe/bstall/blob/f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe/src/Whackashoe/Bstall/Bstall.php#L41-L55
240,834
whackashoe/bstall
src/Whackashoe/Bstall/Bstall.php
Bstall.load
public function load($name) { $stall = $this->redis->get("bstall_{$name}"); if(is_null($stall)) { $this->clean(); $this->save($name); } else { $canvas = unserialize($stall); $this->canvas = $canvas; } }
php
public function load($name) { $stall = $this->redis->get("bstall_{$name}"); if(is_null($stall)) { $this->clean(); $this->save($name); } else { $canvas = unserialize($stall); $this->canvas = $canvas; } }
[ "public", "function", "load", "(", "$", "name", ")", "{", "$", "stall", "=", "$", "this", "->", "redis", "->", "get", "(", "\"bstall_{$name}\"", ")", ";", "if", "(", "is_null", "(", "$", "stall", ")", ")", "{", "$", "this", "->", "clean", "(", ")", ";", "$", "this", "->", "save", "(", "$", "name", ")", ";", "}", "else", "{", "$", "canvas", "=", "unserialize", "(", "$", "stall", ")", ";", "$", "this", "->", "canvas", "=", "$", "canvas", ";", "}", "}" ]
Load or initialize a stall @param string $name @return void
[ "Load", "or", "initialize", "a", "stall" ]
f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe
https://github.com/whackashoe/bstall/blob/f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe/src/Whackashoe/Bstall/Bstall.php#L64-L75
240,835
whackashoe/bstall
src/Whackashoe/Bstall/Bstall.php
Bstall.clean
public function clean() { $this->canvas = []; for($y=0; $y < $this->height; $y++) { array_push($this->canvas, []); for($x=0; $x < $this->width; $x++) { $this->canvas[$y][$x] = $this->bgcolor; } } }
php
public function clean() { $this->canvas = []; for($y=0; $y < $this->height; $y++) { array_push($this->canvas, []); for($x=0; $x < $this->width; $x++) { $this->canvas[$y][$x] = $this->bgcolor; } } }
[ "public", "function", "clean", "(", ")", "{", "$", "this", "->", "canvas", "=", "[", "]", ";", "for", "(", "$", "y", "=", "0", ";", "$", "y", "<", "$", "this", "->", "height", ";", "$", "y", "++", ")", "{", "array_push", "(", "$", "this", "->", "canvas", ",", "[", "]", ")", ";", "for", "(", "$", "x", "=", "0", ";", "$", "x", "<", "$", "this", "->", "width", ";", "$", "x", "++", ")", "{", "$", "this", "->", "canvas", "[", "$", "y", "]", "[", "$", "x", "]", "=", "$", "this", "->", "bgcolor", ";", "}", "}", "}" ]
Cleans the stall, replacing each pixel with the set background color @param string $name @return void
[ "Cleans", "the", "stall", "replacing", "each", "pixel", "with", "the", "set", "background", "color" ]
f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe
https://github.com/whackashoe/bstall/blob/f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe/src/Whackashoe/Bstall/Bstall.php#L96-L107
240,836
whackashoe/bstall
src/Whackashoe/Bstall/Bstall.php
Bstall.write
public function write($x, $y, $color) { if(isset($this->canvas[$y][$x])) { $this->canvas[$y][$x] = $color; } }
php
public function write($x, $y, $color) { if(isset($this->canvas[$y][$x])) { $this->canvas[$y][$x] = $color; } }
[ "public", "function", "write", "(", "$", "x", ",", "$", "y", ",", "$", "color", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "canvas", "[", "$", "y", "]", "[", "$", "x", "]", ")", ")", "{", "$", "this", "->", "canvas", "[", "$", "y", "]", "[", "$", "x", "]", "=", "$", "color", ";", "}", "}" ]
Scribble onto the stall @param int $x @param int $y @param int $color @return void
[ "Scribble", "onto", "the", "stall" ]
f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe
https://github.com/whackashoe/bstall/blob/f8b04d0fb5cb6b7b55396fe8749a1cf9c8b846fe/src/Whackashoe/Bstall/Bstall.php#L118-L123
240,837
jsiefer/class-mocker
src/next.php
next.parent
public static function parent() { if (!self::$activeTraitMethod) { throw new \BadMethodCallException("next:parent() call is only allowed in trait calls"); } $arguments = func_get_args(); return call_user_func(self::$activeTraitMethod, $arguments); }
php
public static function parent() { if (!self::$activeTraitMethod) { throw new \BadMethodCallException("next:parent() call is only allowed in trait calls"); } $arguments = func_get_args(); return call_user_func(self::$activeTraitMethod, $arguments); }
[ "public", "static", "function", "parent", "(", ")", "{", "if", "(", "!", "self", "::", "$", "activeTraitMethod", ")", "{", "throw", "new", "\\", "BadMethodCallException", "(", "\"next:parent() call is only allowed in trait calls\"", ")", ";", "}", "$", "arguments", "=", "func_get_args", "(", ")", ";", "return", "call_user_func", "(", "self", "::", "$", "activeTraitMethod", ",", "$", "arguments", ")", ";", "}" ]
Allows call to parent trait method if it got overwritten @return mixed @see \JSiefer\ClassMocker\Mock\BaseMock::__callTraitMethods()
[ "Allows", "call", "to", "parent", "trait", "method", "if", "it", "got", "overwritten" ]
a355fc9bece8e6f27fbfd09b1631234f7d73a791
https://github.com/jsiefer/class-mocker/blob/a355fc9bece8e6f27fbfd09b1631234f7d73a791/src/next.php#L70-L78
240,838
academic/VipaImportBundle
Importer/PKP/ArticleStatisticImporter.php
ArticleStatisticImporter.importArticleStatistics
public function importArticleStatistics() { $pendingImports = $this->em->getRepository('ImportBundle:PendingStatisticImport')->findAll(); $this->consoleOutput->writeln("Importing article statistics..."); foreach ($pendingImports as $import) { $this->importArticleStatistic($import->getOldId(), $import->getArticle()->getId()); $this->em->remove($import); $this->em->flush($import); } }
php
public function importArticleStatistics() { $pendingImports = $this->em->getRepository('ImportBundle:PendingStatisticImport')->findAll(); $this->consoleOutput->writeln("Importing article statistics..."); foreach ($pendingImports as $import) { $this->importArticleStatistic($import->getOldId(), $import->getArticle()->getId()); $this->em->remove($import); $this->em->flush($import); } }
[ "public", "function", "importArticleStatistics", "(", ")", "{", "$", "pendingImports", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'ImportBundle:PendingStatisticImport'", ")", "->", "findAll", "(", ")", ";", "$", "this", "->", "consoleOutput", "->", "writeln", "(", "\"Importing article statistics...\"", ")", ";", "foreach", "(", "$", "pendingImports", "as", "$", "import", ")", "{", "$", "this", "->", "importArticleStatistic", "(", "$", "import", "->", "getOldId", "(", ")", ",", "$", "import", "->", "getArticle", "(", ")", "->", "getId", "(", ")", ")", ";", "$", "this", "->", "em", "->", "remove", "(", "$", "import", ")", ";", "$", "this", "->", "em", "->", "flush", "(", "$", "import", ")", ";", "}", "}" ]
Imports article statistics whose import are pending.
[ "Imports", "article", "statistics", "whose", "import", "are", "pending", "." ]
cee7d9e51613706a4fd6e2eade44041ce1af9ad3
https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/ArticleStatisticImporter.php#L15-L25
240,839
academic/VipaImportBundle
Importer/PKP/ArticleStatisticImporter.php
ArticleStatisticImporter.importArticleStatistic
public function importArticleStatistic($oldId, $newId) { $article = $this->em->getRepository('VipaJournalBundle:Article')->find($newId); if (!$article) { $this->consoleOutput->writeln("Couldn't find #" . $newId . " on the new database."); return; } $this->consoleOutput->writeln("Reading view statistics for #" . $oldId . "..."); $viewStatsSql = "SELECT DATE(view_time) AS date, COUNT(*) as view FROM " . "article_view_stats WHERE article_id = :id GROUP BY DATE(view_time)"; $viewStatsStatement = $this->dbalConnection->prepare($viewStatsSql); $viewStatsStatement->bindValue('id', $oldId); $viewStatsStatement->execute(); $this->consoleOutput->writeln("Reading download statistics for #" . $oldId . "..."); $downloadStatsSql = "SELECT DATE(download_time) AS date, COUNT(*) as download FROM " . "article_download_stats WHERE article_id = :id GROUP BY DATE(download_time)"; $downloadStatsStatement = $this->dbalConnection->prepare($downloadStatsSql); $downloadStatsStatement->bindValue('id', $oldId); $downloadStatsStatement->execute(); $pkpViewStats = $viewStatsStatement->fetchAll(); $pkpDownloadStats = $downloadStatsStatement->fetchAll(); foreach ($pkpViewStats as $stat) { $articleFileStatistic = new ArticleStatistic(); $articleFileStatistic->setArticle($article); $articleFileStatistic->setDate(DateTime::createFromFormat('Y-m-d', $stat['date'])); $articleFileStatistic->setView($stat['view']); $this->em->persist($articleFileStatistic); } if (!$article->getArticleFiles()->isEmpty()) { foreach ($pkpDownloadStats as $stat) { $articleFileStatistic = new ArticleFileStatistic(); $articleFileStatistic->setArticleFile($article->getArticleFiles()->first()); $articleFileStatistic->setDate(DateTime::createFromFormat('Y-m-d', $stat['date'])); $articleFileStatistic->setDownload($stat['download']); $this->em->persist($articleFileStatistic); } } $this->em->flush(); }
php
public function importArticleStatistic($oldId, $newId) { $article = $this->em->getRepository('VipaJournalBundle:Article')->find($newId); if (!$article) { $this->consoleOutput->writeln("Couldn't find #" . $newId . " on the new database."); return; } $this->consoleOutput->writeln("Reading view statistics for #" . $oldId . "..."); $viewStatsSql = "SELECT DATE(view_time) AS date, COUNT(*) as view FROM " . "article_view_stats WHERE article_id = :id GROUP BY DATE(view_time)"; $viewStatsStatement = $this->dbalConnection->prepare($viewStatsSql); $viewStatsStatement->bindValue('id', $oldId); $viewStatsStatement->execute(); $this->consoleOutput->writeln("Reading download statistics for #" . $oldId . "..."); $downloadStatsSql = "SELECT DATE(download_time) AS date, COUNT(*) as download FROM " . "article_download_stats WHERE article_id = :id GROUP BY DATE(download_time)"; $downloadStatsStatement = $this->dbalConnection->prepare($downloadStatsSql); $downloadStatsStatement->bindValue('id', $oldId); $downloadStatsStatement->execute(); $pkpViewStats = $viewStatsStatement->fetchAll(); $pkpDownloadStats = $downloadStatsStatement->fetchAll(); foreach ($pkpViewStats as $stat) { $articleFileStatistic = new ArticleStatistic(); $articleFileStatistic->setArticle($article); $articleFileStatistic->setDate(DateTime::createFromFormat('Y-m-d', $stat['date'])); $articleFileStatistic->setView($stat['view']); $this->em->persist($articleFileStatistic); } if (!$article->getArticleFiles()->isEmpty()) { foreach ($pkpDownloadStats as $stat) { $articleFileStatistic = new ArticleFileStatistic(); $articleFileStatistic->setArticleFile($article->getArticleFiles()->first()); $articleFileStatistic->setDate(DateTime::createFromFormat('Y-m-d', $stat['date'])); $articleFileStatistic->setDownload($stat['download']); $this->em->persist($articleFileStatistic); } } $this->em->flush(); }
[ "public", "function", "importArticleStatistic", "(", "$", "oldId", ",", "$", "newId", ")", "{", "$", "article", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'VipaJournalBundle:Article'", ")", "->", "find", "(", "$", "newId", ")", ";", "if", "(", "!", "$", "article", ")", "{", "$", "this", "->", "consoleOutput", "->", "writeln", "(", "\"Couldn't find #\"", ".", "$", "newId", ".", "\" on the new database.\"", ")", ";", "return", ";", "}", "$", "this", "->", "consoleOutput", "->", "writeln", "(", "\"Reading view statistics for #\"", ".", "$", "oldId", ".", "\"...\"", ")", ";", "$", "viewStatsSql", "=", "\"SELECT DATE(view_time) AS date, COUNT(*) as view FROM \"", ".", "\"article_view_stats WHERE article_id = :id GROUP BY DATE(view_time)\"", ";", "$", "viewStatsStatement", "=", "$", "this", "->", "dbalConnection", "->", "prepare", "(", "$", "viewStatsSql", ")", ";", "$", "viewStatsStatement", "->", "bindValue", "(", "'id'", ",", "$", "oldId", ")", ";", "$", "viewStatsStatement", "->", "execute", "(", ")", ";", "$", "this", "->", "consoleOutput", "->", "writeln", "(", "\"Reading download statistics for #\"", ".", "$", "oldId", ".", "\"...\"", ")", ";", "$", "downloadStatsSql", "=", "\"SELECT DATE(download_time) AS date, COUNT(*) as download FROM \"", ".", "\"article_download_stats WHERE article_id = :id GROUP BY DATE(download_time)\"", ";", "$", "downloadStatsStatement", "=", "$", "this", "->", "dbalConnection", "->", "prepare", "(", "$", "downloadStatsSql", ")", ";", "$", "downloadStatsStatement", "->", "bindValue", "(", "'id'", ",", "$", "oldId", ")", ";", "$", "downloadStatsStatement", "->", "execute", "(", ")", ";", "$", "pkpViewStats", "=", "$", "viewStatsStatement", "->", "fetchAll", "(", ")", ";", "$", "pkpDownloadStats", "=", "$", "downloadStatsStatement", "->", "fetchAll", "(", ")", ";", "foreach", "(", "$", "pkpViewStats", "as", "$", "stat", ")", "{", "$", "articleFileStatistic", "=", "new", "ArticleStatistic", "(", ")", ";", "$", "articleFileStatistic", "->", "setArticle", "(", "$", "article", ")", ";", "$", "articleFileStatistic", "->", "setDate", "(", "DateTime", "::", "createFromFormat", "(", "'Y-m-d'", ",", "$", "stat", "[", "'date'", "]", ")", ")", ";", "$", "articleFileStatistic", "->", "setView", "(", "$", "stat", "[", "'view'", "]", ")", ";", "$", "this", "->", "em", "->", "persist", "(", "$", "articleFileStatistic", ")", ";", "}", "if", "(", "!", "$", "article", "->", "getArticleFiles", "(", ")", "->", "isEmpty", "(", ")", ")", "{", "foreach", "(", "$", "pkpDownloadStats", "as", "$", "stat", ")", "{", "$", "articleFileStatistic", "=", "new", "ArticleFileStatistic", "(", ")", ";", "$", "articleFileStatistic", "->", "setArticleFile", "(", "$", "article", "->", "getArticleFiles", "(", ")", "->", "first", "(", ")", ")", ";", "$", "articleFileStatistic", "->", "setDate", "(", "DateTime", "::", "createFromFormat", "(", "'Y-m-d'", ",", "$", "stat", "[", "'date'", "]", ")", ")", ";", "$", "articleFileStatistic", "->", "setDownload", "(", "$", "stat", "[", "'download'", "]", ")", ";", "$", "this", "->", "em", "->", "persist", "(", "$", "articleFileStatistic", ")", ";", "}", "}", "$", "this", "->", "em", "->", "flush", "(", ")", ";", "}" ]
Imports the given article's statistics @param int $oldId Old ID of the article @param int $newId New ID of the article @throws \Doctrine\DBAL\DBALException
[ "Imports", "the", "given", "article", "s", "statistics" ]
cee7d9e51613706a4fd6e2eade44041ce1af9ad3
https://github.com/academic/VipaImportBundle/blob/cee7d9e51613706a4fd6e2eade44041ce1af9ad3/Importer/PKP/ArticleStatisticImporter.php#L33-L77
240,840
n0m4dz/laracasa
Zend/Gdata.php
Zend_Gdata.getFeed
public function getFeed($location, $className = 'Zend_Gdata_Feed') { if (is_string($location)) { $uri = $location; } elseif ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'You must specify the location as either a string URI ' . 'or a child of Zend_Gdata_Query'); } return parent::getFeed($uri, $className); }
php
public function getFeed($location, $className = 'Zend_Gdata_Feed') { if (is_string($location)) { $uri = $location; } elseif ($location instanceof Zend_Gdata_Query) { $uri = $location->getQueryUrl(); } else { require_once 'Zend/Gdata/App/InvalidArgumentException.php'; throw new Zend_Gdata_App_InvalidArgumentException( 'You must specify the location as either a string URI ' . 'or a child of Zend_Gdata_Query'); } return parent::getFeed($uri, $className); }
[ "public", "function", "getFeed", "(", "$", "location", ",", "$", "className", "=", "'Zend_Gdata_Feed'", ")", "{", "if", "(", "is_string", "(", "$", "location", ")", ")", "{", "$", "uri", "=", "$", "location", ";", "}", "elseif", "(", "$", "location", "instanceof", "Zend_Gdata_Query", ")", "{", "$", "uri", "=", "$", "location", "->", "getQueryUrl", "(", ")", ";", "}", "else", "{", "require_once", "'Zend/Gdata/App/InvalidArgumentException.php'", ";", "throw", "new", "Zend_Gdata_App_InvalidArgumentException", "(", "'You must specify the location as either a string URI '", ".", "'or a child of Zend_Gdata_Query'", ")", ";", "}", "return", "parent", "::", "getFeed", "(", "$", "uri", ",", "$", "className", ")", ";", "}" ]
Retrieve feed as string or object @param mixed $location The location as string or Zend_Gdata_Query @param string $className The class type to use for returning the feed @throws Zend_Gdata_App_InvalidArgumentException @return string|Zend_Gdata_App_Feed Returns string only if the object mapping has been disabled explicitly by passing false to the useObjectMapping() function.
[ "Retrieve", "feed", "as", "string", "or", "object" ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata.php#L150-L163
240,841
n0m4dz/laracasa
Zend/Gdata.php
Zend_Gdata.performHttpRequest
public function performHttpRequest($method, $url, $headers = array(), $body = null, $contentType = null, $remainingRedirects = null) { if ($this->_httpClient instanceof Zend_Gdata_HttpClient) { $filterResult = $this->_httpClient->filterHttpRequest($method, $url, $headers, $body, $contentType); $method = $filterResult['method']; $url = $filterResult['url']; $body = $filterResult['body']; $headers = $filterResult['headers']; $contentType = $filterResult['contentType']; return $this->_httpClient->filterHttpResponse(parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects)); } else { return parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects); } }
php
public function performHttpRequest($method, $url, $headers = array(), $body = null, $contentType = null, $remainingRedirects = null) { if ($this->_httpClient instanceof Zend_Gdata_HttpClient) { $filterResult = $this->_httpClient->filterHttpRequest($method, $url, $headers, $body, $contentType); $method = $filterResult['method']; $url = $filterResult['url']; $body = $filterResult['body']; $headers = $filterResult['headers']; $contentType = $filterResult['contentType']; return $this->_httpClient->filterHttpResponse(parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects)); } else { return parent::performHttpRequest($method, $url, $headers, $body, $contentType, $remainingRedirects); } }
[ "public", "function", "performHttpRequest", "(", "$", "method", ",", "$", "url", ",", "$", "headers", "=", "array", "(", ")", ",", "$", "body", "=", "null", ",", "$", "contentType", "=", "null", ",", "$", "remainingRedirects", "=", "null", ")", "{", "if", "(", "$", "this", "->", "_httpClient", "instanceof", "Zend_Gdata_HttpClient", ")", "{", "$", "filterResult", "=", "$", "this", "->", "_httpClient", "->", "filterHttpRequest", "(", "$", "method", ",", "$", "url", ",", "$", "headers", ",", "$", "body", ",", "$", "contentType", ")", ";", "$", "method", "=", "$", "filterResult", "[", "'method'", "]", ";", "$", "url", "=", "$", "filterResult", "[", "'url'", "]", ";", "$", "body", "=", "$", "filterResult", "[", "'body'", "]", ";", "$", "headers", "=", "$", "filterResult", "[", "'headers'", "]", ";", "$", "contentType", "=", "$", "filterResult", "[", "'contentType'", "]", ";", "return", "$", "this", "->", "_httpClient", "->", "filterHttpResponse", "(", "parent", "::", "performHttpRequest", "(", "$", "method", ",", "$", "url", ",", "$", "headers", ",", "$", "body", ",", "$", "contentType", ",", "$", "remainingRedirects", ")", ")", ";", "}", "else", "{", "return", "parent", "::", "performHttpRequest", "(", "$", "method", ",", "$", "url", ",", "$", "headers", ",", "$", "body", ",", "$", "contentType", ",", "$", "remainingRedirects", ")", ";", "}", "}" ]
Performs a HTTP request using the specified method. Overrides the definition in the parent (Zend_Gdata_App) and uses the Zend_Gdata_HttpClient functionality to filter the HTTP requests and responses. @param string $method The HTTP method for the request - 'GET', 'POST', 'PUT', 'DELETE' @param string $url The URL to which this request is being performed, or null if found in $data @param array $headers An associative array of HTTP headers for this request @param string $body The body of the HTTP request @param string $contentType The value for the content type of the request body @param int $remainingRedirects Number of redirects to follow if requests results in one @return Zend_Http_Response The response object
[ "Performs", "a", "HTTP", "request", "using", "the", "specified", "method", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata.php#L210-L223
240,842
n0m4dz/laracasa
Zend/Gdata.php
Zend_Gdata.isAuthenticated
public function isAuthenticated() { $client = parent::getHttpClient(); if ($client->getClientLoginToken() || $client->getAuthSubToken() ) { return true; } return false; }
php
public function isAuthenticated() { $client = parent::getHttpClient(); if ($client->getClientLoginToken() || $client->getAuthSubToken() ) { return true; } return false; }
[ "public", "function", "isAuthenticated", "(", ")", "{", "$", "client", "=", "parent", "::", "getHttpClient", "(", ")", ";", "if", "(", "$", "client", "->", "getClientLoginToken", "(", ")", "||", "$", "client", "->", "getAuthSubToken", "(", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Determines whether service object is authenticated. @return boolean True if service object is authenticated, false otherwise.
[ "Determines", "whether", "service", "object", "is", "authenticated", "." ]
6141f0c16c7d4453275e3b74be5041f336085c91
https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata.php#L230-L240
240,843
wasabi-cms/cms
src/View/Helper/CmsPageHelper.php
CmsPageHelper.renderTree
public function renderTree($pages, $closedPages, $langId, $level = null) { if (empty($pages)) { $newPageLink = $this->Html->link( __d('wasabi_cms', 'Please add your first Page'), [ 'plugin' => 'Wasabi/Cms', 'controller' => 'Pages', 'action' => 'add' ], [ 'title' => __d('wasabi_cms', 'Add your first Page') ] ); return '<li class="center">' . __d('wasabi_cms', 'There are no pages yet. {0}.', $newPageLink) . '</li>'; } $output = ''; $depth = ($level !== null) ? $level : 1; foreach ($pages as $page) { $closed = false; $classes = ['page']; if (in_array($page->id, $closedPages)) { $closed = true; $classes[] = 'closed'; } $pageRow = $this->_View->element('Wasabi/Cms.../Pages/__page-row', [ 'page' => $page, 'closed' => $closed, 'langId' => $langId ]); if (!empty($page->children)) { $pageRow .= '<ul' . ($closed ? ' style="display: none;"' : '') . '>' . $this->renderTree($page->children, $closedPages, $langId, $depth + 1) . '</ul>'; } else { $classes[] = 'no-children'; } $output .= '<li class="' . join(' ', $classes) . '" data-cms-page-id="' . $page->id . '">' . $pageRow . '</li>'; } return $output; }
php
public function renderTree($pages, $closedPages, $langId, $level = null) { if (empty($pages)) { $newPageLink = $this->Html->link( __d('wasabi_cms', 'Please add your first Page'), [ 'plugin' => 'Wasabi/Cms', 'controller' => 'Pages', 'action' => 'add' ], [ 'title' => __d('wasabi_cms', 'Add your first Page') ] ); return '<li class="center">' . __d('wasabi_cms', 'There are no pages yet. {0}.', $newPageLink) . '</li>'; } $output = ''; $depth = ($level !== null) ? $level : 1; foreach ($pages as $page) { $closed = false; $classes = ['page']; if (in_array($page->id, $closedPages)) { $closed = true; $classes[] = 'closed'; } $pageRow = $this->_View->element('Wasabi/Cms.../Pages/__page-row', [ 'page' => $page, 'closed' => $closed, 'langId' => $langId ]); if (!empty($page->children)) { $pageRow .= '<ul' . ($closed ? ' style="display: none;"' : '') . '>' . $this->renderTree($page->children, $closedPages, $langId, $depth + 1) . '</ul>'; } else { $classes[] = 'no-children'; } $output .= '<li class="' . join(' ', $classes) . '" data-cms-page-id="' . $page->id . '">' . $pageRow . '</li>'; } return $output; }
[ "public", "function", "renderTree", "(", "$", "pages", ",", "$", "closedPages", ",", "$", "langId", ",", "$", "level", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "pages", ")", ")", "{", "$", "newPageLink", "=", "$", "this", "->", "Html", "->", "link", "(", "__d", "(", "'wasabi_cms'", ",", "'Please add your first Page'", ")", ",", "[", "'plugin'", "=>", "'Wasabi/Cms'", ",", "'controller'", "=>", "'Pages'", ",", "'action'", "=>", "'add'", "]", ",", "[", "'title'", "=>", "__d", "(", "'wasabi_cms'", ",", "'Add your first Page'", ")", "]", ")", ";", "return", "'<li class=\"center\">'", ".", "__d", "(", "'wasabi_cms'", ",", "'There are no pages yet. {0}.'", ",", "$", "newPageLink", ")", ".", "'</li>'", ";", "}", "$", "output", "=", "''", ";", "$", "depth", "=", "(", "$", "level", "!==", "null", ")", "?", "$", "level", ":", "1", ";", "foreach", "(", "$", "pages", "as", "$", "page", ")", "{", "$", "closed", "=", "false", ";", "$", "classes", "=", "[", "'page'", "]", ";", "if", "(", "in_array", "(", "$", "page", "->", "id", ",", "$", "closedPages", ")", ")", "{", "$", "closed", "=", "true", ";", "$", "classes", "[", "]", "=", "'closed'", ";", "}", "$", "pageRow", "=", "$", "this", "->", "_View", "->", "element", "(", "'Wasabi/Cms.../Pages/__page-row'", ",", "[", "'page'", "=>", "$", "page", ",", "'closed'", "=>", "$", "closed", ",", "'langId'", "=>", "$", "langId", "]", ")", ";", "if", "(", "!", "empty", "(", "$", "page", "->", "children", ")", ")", "{", "$", "pageRow", ".=", "'<ul'", ".", "(", "$", "closed", "?", "' style=\"display: none;\"'", ":", "''", ")", ".", "'>'", ".", "$", "this", "->", "renderTree", "(", "$", "page", "->", "children", ",", "$", "closedPages", ",", "$", "langId", ",", "$", "depth", "+", "1", ")", ".", "'</ul>'", ";", "}", "else", "{", "$", "classes", "[", "]", "=", "'no-children'", ";", "}", "$", "output", ".=", "'<li class=\"'", ".", "join", "(", "' '", ",", "$", "classes", ")", ".", "'\" data-cms-page-id=\"'", ".", "$", "page", "->", "id", ".", "'\">'", ".", "$", "pageRow", ".", "'</li>'", ";", "}", "return", "$", "output", ";", "}" ]
Renders a complete tree of pages without the toplevel ul element. @param array $pages @param array $closedPages @param integer $langId @param integer|null $level @return string
[ "Renders", "a", "complete", "tree", "of", "pages", "without", "the", "toplevel", "ul", "element", "." ]
2787b6422ea1d719cf49951b3253fd0ac31d22ca
https://github.com/wasabi-cms/cms/blob/2787b6422ea1d719cf49951b3253fd0ac31d22ca/src/View/Helper/CmsPageHelper.php#L34-L77
240,844
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement._toBoolean
protected function _toBoolean($value) { $value = strtolower((string)$value); $result = ($value != 'false') && ($value != 'off') && !empty($value); return $result; }
php
protected function _toBoolean($value) { $value = strtolower((string)$value); $result = ($value != 'false') && ($value != 'off') && !empty($value); return $result; }
[ "protected", "function", "_toBoolean", "(", "$", "value", ")", "{", "$", "value", "=", "strtolower", "(", "(", "string", ")", "$", "value", ")", ";", "$", "result", "=", "(", "$", "value", "!=", "'false'", ")", "&&", "(", "$", "value", "!=", "'off'", ")", "&&", "!", "empty", "(", "$", "value", ")", ";", "return", "$", "result", ";", "}" ]
Get boolean value @param string $value @return bool
[ "Get", "boolean", "value" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L66-L74
240,845
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.quoteXpathValue
public static function quoteXpathValue($string) { if (strpos($string, "'") === false) { return "'$string'"; } if (strpos($string, '"') === false) { return '"' . $string . '"'; } // String contains ' and " -> need to use concat ... $parts = explode("'", $string); $quoted = implode('\', "\'", \'', $parts); return "concat('$quoted')"; }
php
public static function quoteXpathValue($string) { if (strpos($string, "'") === false) { return "'$string'"; } if (strpos($string, '"') === false) { return '"' . $string . '"'; } // String contains ' and " -> need to use concat ... $parts = explode("'", $string); $quoted = implode('\', "\'", \'', $parts); return "concat('$quoted')"; }
[ "public", "static", "function", "quoteXpathValue", "(", "$", "string", ")", "{", "if", "(", "strpos", "(", "$", "string", ",", "\"'\"", ")", "===", "false", ")", "{", "return", "\"'$string'\"", ";", "}", "if", "(", "strpos", "(", "$", "string", ",", "'\"'", ")", "===", "false", ")", "{", "return", "'\"'", ".", "$", "string", ".", "'\"'", ";", "}", "// String contains ' and \" -> need to use concat ...", "$", "parts", "=", "explode", "(", "\"'\"", ",", "$", "string", ")", ";", "$", "quoted", "=", "implode", "(", "'\\', \"\\'\", \\''", ",", "$", "parts", ")", ";", "return", "\"concat('$quoted')\"", ";", "}" ]
Quote the given value for an xpath expression This will also automatically enclose the string @param string $string @return string
[ "Quote", "the", "given", "value", "for", "an", "xpath", "expression" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L152-L167
240,846
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.getPath
public function getPath() { $stack = array($this->getName()); $current = $this; while ($parent = $current->getParent()) { array_unshift($stack, $parent->getName()); $current = $parent; } return implode('/', $stack); }
php
public function getPath() { $stack = array($this->getName()); $current = $this; while ($parent = $current->getParent()) { array_unshift($stack, $parent->getName()); $current = $parent; } return implode('/', $stack); }
[ "public", "function", "getPath", "(", ")", "{", "$", "stack", "=", "array", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "$", "current", "=", "$", "this", ";", "while", "(", "$", "parent", "=", "$", "current", "->", "getParent", "(", ")", ")", "{", "array_unshift", "(", "$", "stack", ",", "$", "parent", "->", "getName", "(", ")", ")", ";", "$", "current", "=", "$", "parent", ";", "}", "return", "implode", "(", "'/'", ",", "$", "stack", ")", ";", "}" ]
returns the path name @return string
[ "returns", "the", "path", "name" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L241-L252
240,847
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.toValue
public function toValue($type = null, $valueAttribute = null) { $value = ($valueAttribute)? (string)$this[$valueAttribute] : (string)$this; $type = ($type)?: (string)$this['type']; switch ($type) { case 'int': $value = (int)$value; break; case 'float': $value = (float)$value; break; case 'bool': $value = $this->_toBoolean($value); break; case 'double': $value = (double)$value; break; case 'null': $value = null; break; case 'array': $value = $this->toArray(true); break; } return $value; }
php
public function toValue($type = null, $valueAttribute = null) { $value = ($valueAttribute)? (string)$this[$valueAttribute] : (string)$this; $type = ($type)?: (string)$this['type']; switch ($type) { case 'int': $value = (int)$value; break; case 'float': $value = (float)$value; break; case 'bool': $value = $this->_toBoolean($value); break; case 'double': $value = (double)$value; break; case 'null': $value = null; break; case 'array': $value = $this->toArray(true); break; } return $value; }
[ "public", "function", "toValue", "(", "$", "type", "=", "null", ",", "$", "valueAttribute", "=", "null", ")", "{", "$", "value", "=", "(", "$", "valueAttribute", ")", "?", "(", "string", ")", "$", "this", "[", "$", "valueAttribute", "]", ":", "(", "string", ")", "$", "this", ";", "$", "type", "=", "(", "$", "type", ")", "?", ":", "(", "string", ")", "$", "this", "[", "'type'", "]", ";", "switch", "(", "$", "type", ")", "{", "case", "'int'", ":", "$", "value", "=", "(", "int", ")", "$", "value", ";", "break", ";", "case", "'float'", ":", "$", "value", "=", "(", "float", ")", "$", "value", ";", "break", ";", "case", "'bool'", ":", "$", "value", "=", "$", "this", "->", "_toBoolean", "(", "$", "value", ")", ";", "break", ";", "case", "'double'", ":", "$", "value", "=", "(", "double", ")", "$", "value", ";", "break", ";", "case", "'null'", ":", "$", "value", "=", "null", ";", "break", ";", "case", "'array'", ":", "$", "value", "=", "$", "this", "->", "toArray", "(", "true", ")", ";", "break", ";", "}", "return", "$", "value", ";", "}" ]
To php value @param string $type @return mixed
[ "To", "php", "value" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L271-L303
240,848
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.toArray
public function toArray($force = true) { if (!$force && !$this->hasChildren()) { return $this->toValue(); } $data = array(); foreach ($this->children() as $name => $child) { $data[$name] = $child->toArray(false); } return $data; }
php
public function toArray($force = true) { if (!$force && !$this->hasChildren()) { return $this->toValue(); } $data = array(); foreach ($this->children() as $name => $child) { $data[$name] = $child->toArray(false); } return $data; }
[ "public", "function", "toArray", "(", "$", "force", "=", "true", ")", "{", "if", "(", "!", "$", "force", "&&", "!", "$", "this", "->", "hasChildren", "(", ")", ")", "{", "return", "$", "this", "->", "toValue", "(", ")", ";", "}", "$", "data", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "children", "(", ")", "as", "$", "name", "=>", "$", "child", ")", "{", "$", "data", "[", "$", "name", "]", "=", "$", "child", "->", "toArray", "(", "false", ")", ";", "}", "return", "$", "data", ";", "}" ]
convert to array @return string
[ "convert", "to", "array" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L310-L322
240,849
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.toPhpValue
public function toPhpValue($type = null, $serviceLocator = null) { if (!$type) { $type = $this->getName(); } switch ($type) { case 'array': $value = array(); if (!isset($this->item)) { return $value; } foreach ($this->item as $item) { if (!($type = (string)$item['type'])) { $type = 'string'; } // Instance must be defined in subtag if (($type == 'instance') && !$item->{$type}) { $current = null; } else { $current = ($item->{$type})? $item->{$type}->toPhpValue($type, $serviceLocator) : $item->toPhpValue($type, $serviceLocator); } if (!isset($item['key']) && !isset($item['index'])) { $value[] = $current; continue; } $key = (isset($item['key']))? (string)$item['key'] : intval((string)$item['index']); $value[$key] = $current; } break; case 'null': $value = null; break; case 'instance': $class = (string)$this['class']; $value = null; if (($serviceLocator instanceof ServiceLocatorInterface) && ($serviceLocator->has($class))) { $value = $serviceLocator->get($class); break; } if ($serviceLocator instanceof DependencyInjectionInterface) { $options = array(); if (isset($this->options)) { $options = $this->options->toPhpValue('array', $serviceLocator); } $value = $serviceLocator->newInstance($class, $options); break; } break; default: $value = $this->toValue($type); break; } return $value; }
php
public function toPhpValue($type = null, $serviceLocator = null) { if (!$type) { $type = $this->getName(); } switch ($type) { case 'array': $value = array(); if (!isset($this->item)) { return $value; } foreach ($this->item as $item) { if (!($type = (string)$item['type'])) { $type = 'string'; } // Instance must be defined in subtag if (($type == 'instance') && !$item->{$type}) { $current = null; } else { $current = ($item->{$type})? $item->{$type}->toPhpValue($type, $serviceLocator) : $item->toPhpValue($type, $serviceLocator); } if (!isset($item['key']) && !isset($item['index'])) { $value[] = $current; continue; } $key = (isset($item['key']))? (string)$item['key'] : intval((string)$item['index']); $value[$key] = $current; } break; case 'null': $value = null; break; case 'instance': $class = (string)$this['class']; $value = null; if (($serviceLocator instanceof ServiceLocatorInterface) && ($serviceLocator->has($class))) { $value = $serviceLocator->get($class); break; } if ($serviceLocator instanceof DependencyInjectionInterface) { $options = array(); if (isset($this->options)) { $options = $this->options->toPhpValue('array', $serviceLocator); } $value = $serviceLocator->newInstance($class, $options); break; } break; default: $value = $this->toValue($type); break; } return $value; }
[ "public", "function", "toPhpValue", "(", "$", "type", "=", "null", ",", "$", "serviceLocator", "=", "null", ")", "{", "if", "(", "!", "$", "type", ")", "{", "$", "type", "=", "$", "this", "->", "getName", "(", ")", ";", "}", "switch", "(", "$", "type", ")", "{", "case", "'array'", ":", "$", "value", "=", "array", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "item", ")", ")", "{", "return", "$", "value", ";", "}", "foreach", "(", "$", "this", "->", "item", "as", "$", "item", ")", "{", "if", "(", "!", "(", "$", "type", "=", "(", "string", ")", "$", "item", "[", "'type'", "]", ")", ")", "{", "$", "type", "=", "'string'", ";", "}", "// Instance must be defined in subtag", "if", "(", "(", "$", "type", "==", "'instance'", ")", "&&", "!", "$", "item", "->", "{", "$", "type", "}", ")", "{", "$", "current", "=", "null", ";", "}", "else", "{", "$", "current", "=", "(", "$", "item", "->", "{", "$", "type", "}", ")", "?", "$", "item", "->", "{", "$", "type", "}", "->", "toPhpValue", "(", "$", "type", ",", "$", "serviceLocator", ")", ":", "$", "item", "->", "toPhpValue", "(", "$", "type", ",", "$", "serviceLocator", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "item", "[", "'key'", "]", ")", "&&", "!", "isset", "(", "$", "item", "[", "'index'", "]", ")", ")", "{", "$", "value", "[", "]", "=", "$", "current", ";", "continue", ";", "}", "$", "key", "=", "(", "isset", "(", "$", "item", "[", "'key'", "]", ")", ")", "?", "(", "string", ")", "$", "item", "[", "'key'", "]", ":", "intval", "(", "(", "string", ")", "$", "item", "[", "'index'", "]", ")", ";", "$", "value", "[", "$", "key", "]", "=", "$", "current", ";", "}", "break", ";", "case", "'null'", ":", "$", "value", "=", "null", ";", "break", ";", "case", "'instance'", ":", "$", "class", "=", "(", "string", ")", "$", "this", "[", "'class'", "]", ";", "$", "value", "=", "null", ";", "if", "(", "(", "$", "serviceLocator", "instanceof", "ServiceLocatorInterface", ")", "&&", "(", "$", "serviceLocator", "->", "has", "(", "$", "class", ")", ")", ")", "{", "$", "value", "=", "$", "serviceLocator", "->", "get", "(", "$", "class", ")", ";", "break", ";", "}", "if", "(", "$", "serviceLocator", "instanceof", "DependencyInjectionInterface", ")", "{", "$", "options", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "options", ")", ")", "{", "$", "options", "=", "$", "this", "->", "options", "->", "toPhpValue", "(", "'array'", ",", "$", "serviceLocator", ")", ";", "}", "$", "value", "=", "$", "serviceLocator", "->", "newInstance", "(", "$", "class", ",", "$", "options", ")", ";", "break", ";", "}", "break", ";", "default", ":", "$", "value", "=", "$", "this", "->", "toValue", "(", "$", "type", ")", ";", "break", ";", "}", "return", "$", "value", ";", "}" ]
Convert to php value @param string $type @return mixed
[ "Convert", "to", "php", "value" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L330-L397
240,850
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement._getMergeRule
protected function _getMergeRule($element, &$affected = null, $rule = null) { if ($rule instanceof MergeRuleInterface) { $result = $rule($this, $element, $affected); if ($result !== false) { return $result; } } $name = $element->getName(); if (isset($this->{$name})) { $affected = $this->{$name}; return self::MERGE_REPLACE; } return self::MERGE_APPEND; }
php
protected function _getMergeRule($element, &$affected = null, $rule = null) { if ($rule instanceof MergeRuleInterface) { $result = $rule($this, $element, $affected); if ($result !== false) { return $result; } } $name = $element->getName(); if (isset($this->{$name})) { $affected = $this->{$name}; return self::MERGE_REPLACE; } return self::MERGE_APPEND; }
[ "protected", "function", "_getMergeRule", "(", "$", "element", ",", "&", "$", "affected", "=", "null", ",", "$", "rule", "=", "null", ")", "{", "if", "(", "$", "rule", "instanceof", "MergeRuleInterface", ")", "{", "$", "result", "=", "$", "rule", "(", "$", "this", ",", "$", "element", ",", "$", "affected", ")", ";", "if", "(", "$", "result", "!==", "false", ")", "{", "return", "$", "result", ";", "}", "}", "$", "name", "=", "$", "element", "->", "getName", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "{", "$", "name", "}", ")", ")", "{", "$", "affected", "=", "$", "this", "->", "{", "$", "name", "}", ";", "return", "self", "::", "MERGE_REPLACE", ";", "}", "return", "self", "::", "MERGE_APPEND", ";", "}" ]
find merge rule @param \rampage\core\xml\SimpleXmlElement $element @param \rampage\core\xml\SimpleXmlElement $affected @return int
[ "find", "merge", "rule" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L406-L423
240,851
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.mergeAttributes
public function mergeAttributes(SimpleXmlElement $node, $replace = true) { foreach ($node->attributes() as $name => $value) { if (isset($this[$name])) { if ($replace) { $this[$name] = (string)$value; } continue; } $this->addAttribute($name, (string)$value); } return $this; }
php
public function mergeAttributes(SimpleXmlElement $node, $replace = true) { foreach ($node->attributes() as $name => $value) { if (isset($this[$name])) { if ($replace) { $this[$name] = (string)$value; } continue; } $this->addAttribute($name, (string)$value); } return $this; }
[ "public", "function", "mergeAttributes", "(", "SimpleXmlElement", "$", "node", ",", "$", "replace", "=", "true", ")", "{", "foreach", "(", "$", "node", "->", "attributes", "(", ")", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "[", "$", "name", "]", ")", ")", "{", "if", "(", "$", "replace", ")", "{", "$", "this", "[", "$", "name", "]", "=", "(", "string", ")", "$", "value", ";", "}", "continue", ";", "}", "$", "this", "->", "addAttribute", "(", "$", "name", ",", "(", "string", ")", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Merge attributes from the given node to this one @param \rampage\core\xml\SimpleXmlElement $node @param bool $replace
[ "Merge", "attributes", "from", "the", "given", "node", "to", "this", "one" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L431-L446
240,852
tux-rampage/rampage-php
library/rampage/core/xml/SimpleXmlElement.php
SimpleXmlElement.merge
public function merge(SimpleXmlElement $element, $replace = true, $rule = null) { foreach ($element->children() as $name => $child) { $affected = null; $currentpath = $child->getPath(); $action = $this->_getMergeRule($child, $affected, $rule); if ($action == self::MERGE_APPEND) { $affected = $this->addChild($name, (string)$child); } if (!$affected instanceof SimpleXmlElement) { continue; } $affected->mergeAttributes($child, $replace); if ($child->hasChildren()) { $affected->merge($child, $replace, $rule); continue; } else if ($replace) { $affected[0] = (string)$child; } } return $this; }
php
public function merge(SimpleXmlElement $element, $replace = true, $rule = null) { foreach ($element->children() as $name => $child) { $affected = null; $currentpath = $child->getPath(); $action = $this->_getMergeRule($child, $affected, $rule); if ($action == self::MERGE_APPEND) { $affected = $this->addChild($name, (string)$child); } if (!$affected instanceof SimpleXmlElement) { continue; } $affected->mergeAttributes($child, $replace); if ($child->hasChildren()) { $affected->merge($child, $replace, $rule); continue; } else if ($replace) { $affected[0] = (string)$child; } } return $this; }
[ "public", "function", "merge", "(", "SimpleXmlElement", "$", "element", ",", "$", "replace", "=", "true", ",", "$", "rule", "=", "null", ")", "{", "foreach", "(", "$", "element", "->", "children", "(", ")", "as", "$", "name", "=>", "$", "child", ")", "{", "$", "affected", "=", "null", ";", "$", "currentpath", "=", "$", "child", "->", "getPath", "(", ")", ";", "$", "action", "=", "$", "this", "->", "_getMergeRule", "(", "$", "child", ",", "$", "affected", ",", "$", "rule", ")", ";", "if", "(", "$", "action", "==", "self", "::", "MERGE_APPEND", ")", "{", "$", "affected", "=", "$", "this", "->", "addChild", "(", "$", "name", ",", "(", "string", ")", "$", "child", ")", ";", "}", "if", "(", "!", "$", "affected", "instanceof", "SimpleXmlElement", ")", "{", "continue", ";", "}", "$", "affected", "->", "mergeAttributes", "(", "$", "child", ",", "$", "replace", ")", ";", "if", "(", "$", "child", "->", "hasChildren", "(", ")", ")", "{", "$", "affected", "->", "merge", "(", "$", "child", ",", "$", "replace", ",", "$", "rule", ")", ";", "continue", ";", "}", "else", "if", "(", "$", "replace", ")", "{", "$", "affected", "[", "0", "]", "=", "(", "string", ")", "$", "child", ";", "}", "}", "return", "$", "this", ";", "}" ]
merge another xml element into this one @param SimpleXmlElement $element @return string
[ "merge", "another", "xml", "element", "into", "this", "one" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/xml/SimpleXmlElement.php#L454-L480
240,853
gios-asu/nectary
src/routers/router.php
Router.route_exists
private function route_exists() : bool { if ( property_exists( $this, 'routes' ) ) { return array_key_exists( $this->__method_name, $this->routes ); } return false; }
php
private function route_exists() : bool { if ( property_exists( $this, 'routes' ) ) { return array_key_exists( $this->__method_name, $this->routes ); } return false; }
[ "private", "function", "route_exists", "(", ")", ":", "bool", "{", "if", "(", "property_exists", "(", "$", "this", ",", "'routes'", ")", ")", "{", "return", "array_key_exists", "(", "$", "this", "->", "__method_name", ",", "$", "this", "->", "routes", ")", ";", "}", "return", "false", ";", "}" ]
Check if the route has been defined @return bool
[ "Check", "if", "the", "route", "has", "been", "defined" ]
f972c737a9036a3090652950a1309a62c07d86c0
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/routers/router.php#L82-L87
240,854
gios-asu/nectary
src/routers/router.php
Router.route_request
private function route_request() { $named_arguments = $this->get_named_arguments(); list( $to_class, $to_method, $on_error ) = $this->get_route_parts(); return $this->do_route( $to_class, $to_method, $named_arguments, $on_error ); }
php
private function route_request() { $named_arguments = $this->get_named_arguments(); list( $to_class, $to_method, $on_error ) = $this->get_route_parts(); return $this->do_route( $to_class, $to_method, $named_arguments, $on_error ); }
[ "private", "function", "route_request", "(", ")", "{", "$", "named_arguments", "=", "$", "this", "->", "get_named_arguments", "(", ")", ";", "list", "(", "$", "to_class", ",", "$", "to_method", ",", "$", "on_error", ")", "=", "$", "this", "->", "get_route_parts", "(", ")", ";", "return", "$", "this", "->", "do_route", "(", "$", "to_class", ",", "$", "to_method", ",", "$", "named_arguments", ",", "$", "on_error", ")", ";", "}" ]
Build and do the route @throws \ReflectionException
[ "Build", "and", "do", "the", "route" ]
f972c737a9036a3090652950a1309a62c07d86c0
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/routers/router.php#L94-L100
240,855
gios-asu/nectary
src/routers/router.php
Router.get_named_arguments
private function get_named_arguments() : array { // name the parameters $named_arguments = []; if ( array_key_exists( 'expects', $this->routes[ $this->__method_name ] ) ) { $expects = $this->routes[ $this->__method_name ]['expects']; foreach ( $expects as $index => $parameter_name ) { if ( array_key_exists( $index, $this->__arguments ) ) { $named_arguments[ $parameter_name ] = $this->__arguments[ $index ]; } } } return $named_arguments; }
php
private function get_named_arguments() : array { // name the parameters $named_arguments = []; if ( array_key_exists( 'expects', $this->routes[ $this->__method_name ] ) ) { $expects = $this->routes[ $this->__method_name ]['expects']; foreach ( $expects as $index => $parameter_name ) { if ( array_key_exists( $index, $this->__arguments ) ) { $named_arguments[ $parameter_name ] = $this->__arguments[ $index ]; } } } return $named_arguments; }
[ "private", "function", "get_named_arguments", "(", ")", ":", "array", "{", "// name the parameters", "$", "named_arguments", "=", "[", "]", ";", "if", "(", "array_key_exists", "(", "'expects'", ",", "$", "this", "->", "routes", "[", "$", "this", "->", "__method_name", "]", ")", ")", "{", "$", "expects", "=", "$", "this", "->", "routes", "[", "$", "this", "->", "__method_name", "]", "[", "'expects'", "]", ";", "foreach", "(", "$", "expects", "as", "$", "index", "=>", "$", "parameter_name", ")", "{", "if", "(", "array_key_exists", "(", "$", "index", ",", "$", "this", "->", "__arguments", ")", ")", "{", "$", "named_arguments", "[", "$", "parameter_name", "]", "=", "$", "this", "->", "__arguments", "[", "$", "index", "]", ";", "}", "}", "}", "return", "$", "named_arguments", ";", "}" ]
Map the arguments passed into the method to the expected arguments defined by the route @return array
[ "Map", "the", "arguments", "passed", "into", "the", "method", "to", "the", "expected", "arguments", "defined", "by", "the", "route" ]
f972c737a9036a3090652950a1309a62c07d86c0
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/routers/router.php#L108-L123
240,856
gios-asu/nectary
src/routers/router.php
Router.get_route_parts
private function get_route_parts() : array { $to = $this->routes[ $this->__method_name ]['to']; if ( \is_array( $to ) ) { $to_parts = $to; } else { $to_parts = explode( '@', $to ); } $to_class = $to_parts[0]; $to_method = $to_parts[1]; $on_error = null; if ( array_key_exists( 'on_error', $this->routes[ $this->__method_name ] ) ) { $on_error = $this->routes[ $this->__method_name ]['on_error']; } return [ $to_class, $to_method, $on_error ]; }
php
private function get_route_parts() : array { $to = $this->routes[ $this->__method_name ]['to']; if ( \is_array( $to ) ) { $to_parts = $to; } else { $to_parts = explode( '@', $to ); } $to_class = $to_parts[0]; $to_method = $to_parts[1]; $on_error = null; if ( array_key_exists( 'on_error', $this->routes[ $this->__method_name ] ) ) { $on_error = $this->routes[ $this->__method_name ]['on_error']; } return [ $to_class, $to_method, $on_error ]; }
[ "private", "function", "get_route_parts", "(", ")", ":", "array", "{", "$", "to", "=", "$", "this", "->", "routes", "[", "$", "this", "->", "__method_name", "]", "[", "'to'", "]", ";", "if", "(", "\\", "is_array", "(", "$", "to", ")", ")", "{", "$", "to_parts", "=", "$", "to", ";", "}", "else", "{", "$", "to_parts", "=", "explode", "(", "'@'", ",", "$", "to", ")", ";", "}", "$", "to_class", "=", "$", "to_parts", "[", "0", "]", ";", "$", "to_method", "=", "$", "to_parts", "[", "1", "]", ";", "$", "on_error", "=", "null", ";", "if", "(", "array_key_exists", "(", "'on_error'", ",", "$", "this", "->", "routes", "[", "$", "this", "->", "__method_name", "]", ")", ")", "{", "$", "on_error", "=", "$", "this", "->", "routes", "[", "$", "this", "->", "__method_name", "]", "[", "'on_error'", "]", ";", "}", "return", "[", "$", "to_class", ",", "$", "to_method", ",", "$", "on_error", "]", ";", "}" ]
Get the individual parts of the route, including the class and method to route to @return array
[ "Get", "the", "individual", "parts", "of", "the", "route", "including", "the", "class", "and", "method", "to", "route", "to" ]
f972c737a9036a3090652950a1309a62c07d86c0
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/routers/router.php#L131-L148
240,857
gios-asu/nectary
src/routers/router.php
Router.do_route
private function do_route( $class_name, $method_name, $named_arguments, $on_error ) { if ( \is_object( $class_name ) ) { return $this->call( array( $class_name, $method_name, ), $named_arguments ); } $injector_factory = new Dependency_Injection_Factory( $class_name, $method_name, $named_arguments ); list( $obj, $dependencies, $validators ) = $injector_factory->build(); // Check all validators foreach ( $validators as $validator ) { $message = $validator->validate( $on_error ); if ( $message ) { return $message; } } return $this->call( array( $obj, $method_name, ), $dependencies ); }
php
private function do_route( $class_name, $method_name, $named_arguments, $on_error ) { if ( \is_object( $class_name ) ) { return $this->call( array( $class_name, $method_name, ), $named_arguments ); } $injector_factory = new Dependency_Injection_Factory( $class_name, $method_name, $named_arguments ); list( $obj, $dependencies, $validators ) = $injector_factory->build(); // Check all validators foreach ( $validators as $validator ) { $message = $validator->validate( $on_error ); if ( $message ) { return $message; } } return $this->call( array( $obj, $method_name, ), $dependencies ); }
[ "private", "function", "do_route", "(", "$", "class_name", ",", "$", "method_name", ",", "$", "named_arguments", ",", "$", "on_error", ")", "{", "if", "(", "\\", "is_object", "(", "$", "class_name", ")", ")", "{", "return", "$", "this", "->", "call", "(", "array", "(", "$", "class_name", ",", "$", "method_name", ",", ")", ",", "$", "named_arguments", ")", ";", "}", "$", "injector_factory", "=", "new", "Dependency_Injection_Factory", "(", "$", "class_name", ",", "$", "method_name", ",", "$", "named_arguments", ")", ";", "list", "(", "$", "obj", ",", "$", "dependencies", ",", "$", "validators", ")", "=", "$", "injector_factory", "->", "build", "(", ")", ";", "// Check all validators", "foreach", "(", "$", "validators", "as", "$", "validator", ")", "{", "$", "message", "=", "$", "validator", "->", "validate", "(", "$", "on_error", ")", ";", "if", "(", "$", "message", ")", "{", "return", "$", "message", ";", "}", "}", "return", "$", "this", "->", "call", "(", "array", "(", "$", "obj", ",", "$", "method_name", ",", ")", ",", "$", "dependencies", ")", ";", "}" ]
Resolve dependencies for dependency injection and call the given route @param string $class_name The class to route to @param string $method_name The method name to call in the give class @param array $named_arguments Associative array of suggested arguments @param callback $on_error Callback if a validator fails @return mixed @throws \ReflectionException
[ "Resolve", "dependencies", "for", "dependency", "injection", "and", "call", "the", "given", "route" ]
f972c737a9036a3090652950a1309a62c07d86c0
https://github.com/gios-asu/nectary/blob/f972c737a9036a3090652950a1309a62c07d86c0/src/routers/router.php#L161-L200
240,858
tonjoo/tiga-framework
src/Response/ResponseFactory.php
ResponseFactory.template
public static function template($template, $parameter = array(), $status = 200, $headers = array()) { View::setTemplate($template, $parameter); return new Response('', $status, $headers); }
php
public static function template($template, $parameter = array(), $status = 200, $headers = array()) { View::setTemplate($template, $parameter); return new Response('', $status, $headers); }
[ "public", "static", "function", "template", "(", "$", "template", ",", "$", "parameter", "=", "array", "(", ")", ",", "$", "status", "=", "200", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "View", "::", "setTemplate", "(", "$", "template", ",", "$", "parameter", ")", ";", "return", "new", "Response", "(", "''", ",", "$", "status", ",", "$", "headers", ")", ";", "}" ]
Generate response from template. @param string $template @param array $parameter @param int $status @param array $headers @return Response
[ "Generate", "response", "from", "template", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Response/ResponseFactory.php#L37-L42
240,859
tonjoo/tiga-framework
src/Response/ResponseFactory.php
ResponseFactory.json
public static function json($data, $status = 200, $headers = array()) { $jsonHeader = array('Content-Type' => 'application/json'); $content = json_encode($data); return new Response($content, $status, $jsonHeader); }
php
public static function json($data, $status = 200, $headers = array()) { $jsonHeader = array('Content-Type' => 'application/json'); $content = json_encode($data); return new Response($content, $status, $jsonHeader); }
[ "public", "static", "function", "json", "(", "$", "data", ",", "$", "status", "=", "200", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "$", "jsonHeader", "=", "array", "(", "'Content-Type'", "=>", "'application/json'", ")", ";", "$", "content", "=", "json_encode", "(", "$", "data", ")", ";", "return", "new", "Response", "(", "$", "content", ",", "$", "status", ",", "$", "jsonHeader", ")", ";", "}" ]
Return JSON response. @param array $data @param int $status @param array $headers @return Response
[ "Return", "JSON", "response", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Response/ResponseFactory.php#L53-L60
240,860
tonjoo/tiga-framework
src/Response/ResponseFactory.php
ResponseFactory.redirect
public static function redirect($url, $status = 302, $headers = array()) { $redirect = new RedirectResponse($url, $status, $headers); $redirect->sendHeaders(); die(); }
php
public static function redirect($url, $status = 302, $headers = array()) { $redirect = new RedirectResponse($url, $status, $headers); $redirect->sendHeaders(); die(); }
[ "public", "static", "function", "redirect", "(", "$", "url", ",", "$", "status", "=", "302", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "$", "redirect", "=", "new", "RedirectResponse", "(", "$", "url", ",", "$", "status", ",", "$", "headers", ")", ";", "$", "redirect", "->", "sendHeaders", "(", ")", ";", "die", "(", ")", ";", "}" ]
Redirect Response. @param string $url @param int $status @param array $headers
[ "Redirect", "Response", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Response/ResponseFactory.php#L69-L74
240,861
tonjoo/tiga-framework
src/Response/ResponseFactory.php
ResponseFactory.download
public static function download($file, $status = 200, $headers = array()) { require_once ABSPATH.'wp-admin/includes/file.php'; WP_Filesystem(); global $wp_filesystem; $fileData = $wp_filesystem->get_contents($file); $downloadHeader['Content-Description'] = 'File Transfer'; $downloadHeader['Content-Type'] = 'application/octet-stream'; $downloadHeader['Content-Disposition'] = 'attachment; filename='.basename($file); $downloadHeader['Content-Transfer-Encoding'] = 'binary'; $downloadHeader['Expires'] = '0'; $downloadHeader['Cache-Control'] = 'must-revalidate'; $downloadHeader['Pragma'] = 'public'; $downloadHeader['Content-Length'] = filesize($file); $response = new Response($fileData, 200, $downloadHeader); $response->send(); }
php
public static function download($file, $status = 200, $headers = array()) { require_once ABSPATH.'wp-admin/includes/file.php'; WP_Filesystem(); global $wp_filesystem; $fileData = $wp_filesystem->get_contents($file); $downloadHeader['Content-Description'] = 'File Transfer'; $downloadHeader['Content-Type'] = 'application/octet-stream'; $downloadHeader['Content-Disposition'] = 'attachment; filename='.basename($file); $downloadHeader['Content-Transfer-Encoding'] = 'binary'; $downloadHeader['Expires'] = '0'; $downloadHeader['Cache-Control'] = 'must-revalidate'; $downloadHeader['Pragma'] = 'public'; $downloadHeader['Content-Length'] = filesize($file); $response = new Response($fileData, 200, $downloadHeader); $response->send(); }
[ "public", "static", "function", "download", "(", "$", "file", ",", "$", "status", "=", "200", ",", "$", "headers", "=", "array", "(", ")", ")", "{", "require_once", "ABSPATH", ".", "'wp-admin/includes/file.php'", ";", "WP_Filesystem", "(", ")", ";", "global", "$", "wp_filesystem", ";", "$", "fileData", "=", "$", "wp_filesystem", "->", "get_contents", "(", "$", "file", ")", ";", "$", "downloadHeader", "[", "'Content-Description'", "]", "=", "'File Transfer'", ";", "$", "downloadHeader", "[", "'Content-Type'", "]", "=", "'application/octet-stream'", ";", "$", "downloadHeader", "[", "'Content-Disposition'", "]", "=", "'attachment; filename='", ".", "basename", "(", "$", "file", ")", ";", "$", "downloadHeader", "[", "'Content-Transfer-Encoding'", "]", "=", "'binary'", ";", "$", "downloadHeader", "[", "'Expires'", "]", "=", "'0'", ";", "$", "downloadHeader", "[", "'Cache-Control'", "]", "=", "'must-revalidate'", ";", "$", "downloadHeader", "[", "'Pragma'", "]", "=", "'public'", ";", "$", "downloadHeader", "[", "'Content-Length'", "]", "=", "filesize", "(", "$", "file", ")", ";", "$", "response", "=", "new", "Response", "(", "$", "fileData", ",", "200", ",", "$", "downloadHeader", ")", ";", "$", "response", "->", "send", "(", ")", ";", "}" ]
Generate download file. @param string $file @param int $status @param array $headers
[ "Generate", "download", "file", "." ]
3c2eebd3bc616106fa1bba3e43f1791aff75eec5
https://github.com/tonjoo/tiga-framework/blob/3c2eebd3bc616106fa1bba3e43f1791aff75eec5/src/Response/ResponseFactory.php#L83-L104
240,862
HouseOfAgile/dacorp-extra-bundle
Listener/LanguageListener.php
LanguageListener.setLocaleForUnauthenticatedUser
public function setLocaleForUnauthenticatedUser(GetResponseEvent $event) { if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { return; } $request = $event->getRequest(); if ('unset' == $request->getLocale()) { if ($locale = $request->getSession()->get('_locale')) { $request->setLocale($locale); } else { $request->setLocale($request->getPreferredLanguage()); } } }
php
public function setLocaleForUnauthenticatedUser(GetResponseEvent $event) { if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { return; } $request = $event->getRequest(); if ('unset' == $request->getLocale()) { if ($locale = $request->getSession()->get('_locale')) { $request->setLocale($locale); } else { $request->setLocale($request->getPreferredLanguage()); } } }
[ "public", "function", "setLocaleForUnauthenticatedUser", "(", "GetResponseEvent", "$", "event", ")", "{", "if", "(", "HttpKernelInterface", "::", "MASTER_REQUEST", "!==", "$", "event", "->", "getRequestType", "(", ")", ")", "{", "return", ";", "}", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "if", "(", "'unset'", "==", "$", "request", "->", "getLocale", "(", ")", ")", "{", "if", "(", "$", "locale", "=", "$", "request", "->", "getSession", "(", ")", "->", "get", "(", "'_locale'", ")", ")", "{", "$", "request", "->", "setLocale", "(", "$", "locale", ")", ";", "}", "else", "{", "$", "request", "->", "setLocale", "(", "$", "request", "->", "getPreferredLanguage", "(", ")", ")", ";", "}", "}", "}" ]
kernel.request event. If a guest user doesn't have an opened session, locale is equal to "undefined" as configured by default in parameters.ini. If so, set as a locale the user's preferred language. @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
[ "kernel", ".", "request", "event", ".", "If", "a", "guest", "user", "doesn", "t", "have", "an", "opened", "session", "locale", "is", "equal", "to", "undefined", "as", "configured", "by", "default", "in", "parameters", ".", "ini", ".", "If", "so", "set", "as", "a", "locale", "the", "user", "s", "preferred", "language", "." ]
99fe024791e7833058908a2e5544bde948031524
https://github.com/HouseOfAgile/dacorp-extra-bundle/blob/99fe024791e7833058908a2e5544bde948031524/Listener/LanguageListener.php#L36-L49
240,863
HouseOfAgile/dacorp-extra-bundle
Listener/LanguageListener.php
LanguageListener.setLocaleForAuthenticatedUser
public function setLocaleForAuthenticatedUser(InteractiveLoginEvent $event) { $user = $event->getAuthenticationToken()->getUser(); if ($lang = $user->getLocale()) { $this->session->set('_locale', $lang); } else { $request = $event->getRequest(); if ('unset' == $request->getLocale()) { $this->session->set('_locale', 'en'); } } }
php
public function setLocaleForAuthenticatedUser(InteractiveLoginEvent $event) { $user = $event->getAuthenticationToken()->getUser(); if ($lang = $user->getLocale()) { $this->session->set('_locale', $lang); } else { $request = $event->getRequest(); if ('unset' == $request->getLocale()) { $this->session->set('_locale', 'en'); } } }
[ "public", "function", "setLocaleForAuthenticatedUser", "(", "InteractiveLoginEvent", "$", "event", ")", "{", "$", "user", "=", "$", "event", "->", "getAuthenticationToken", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "$", "lang", "=", "$", "user", "->", "getLocale", "(", ")", ")", "{", "$", "this", "->", "session", "->", "set", "(", "'_locale'", ",", "$", "lang", ")", ";", "}", "else", "{", "$", "request", "=", "$", "event", "->", "getRequest", "(", ")", ";", "if", "(", "'unset'", "==", "$", "request", "->", "getLocale", "(", ")", ")", "{", "$", "this", "->", "session", "->", "set", "(", "'_locale'", ",", "'en'", ")", ";", "}", "}", "}" ]
security.interactive_login event. If a user chose a language in preferences, it would be set, if not, a locale that was set by setLocaleForUnauthenticatedUser remains. @param \Symfony\Component\Security\Http\Event\InteractiveLoginEvent $event
[ "security", ".", "interactive_login", "event", ".", "If", "a", "user", "chose", "a", "language", "in", "preferences", "it", "would", "be", "set", "if", "not", "a", "locale", "that", "was", "set", "by", "setLocaleForUnauthenticatedUser", "remains", "." ]
99fe024791e7833058908a2e5544bde948031524
https://github.com/HouseOfAgile/dacorp-extra-bundle/blob/99fe024791e7833058908a2e5544bde948031524/Listener/LanguageListener.php#L57-L68
240,864
judus/minimal-minimal
src/Facades/App.php
App.makeInstance
protected static function makeInstance( $class, array $options = null ): Implementation { $options || $options = ['provider' => self::app()]; return IOC::make($class, [$options, true]); }
php
protected static function makeInstance( $class, array $options = null ): Implementation { $options || $options = ['provider' => self::app()]; return IOC::make($class, [$options, true]); }
[ "protected", "static", "function", "makeInstance", "(", "$", "class", ",", "array", "$", "options", "=", "null", ")", ":", "Implementation", "{", "$", "options", "||", "$", "options", "=", "[", "'provider'", "=>", "self", "::", "app", "(", ")", "]", ";", "return", "IOC", "::", "make", "(", "$", "class", ",", "[", "$", "options", ",", "true", "]", ")", ";", "}" ]
Make the instance this facade refers to @param $class @param array|null $options @return Implementation
[ "Make", "the", "instance", "this", "facade", "refers", "to" ]
36db55c537175cead2ab412f166bf2574d0f9597
https://github.com/judus/minimal-minimal/blob/36db55c537175cead2ab412f166bf2574d0f9597/src/Facades/App.php#L38-L45
240,865
judus/minimal-minimal
src/Facades/App.php
App.getInstance
public static function getInstance( $class = null, array $options = [] ) { /** @var Implementation $instance */ if (is_null(self::$instance)) { if (is_null($class)) { self::$instance = self::makeInstance( Implementation::class, $options )->getApp($options); self::$instance->load(); } else { ! is_object($class) || self::$instance = $class; } } return self::$instance; }
php
public static function getInstance( $class = null, array $options = [] ) { /** @var Implementation $instance */ if (is_null(self::$instance)) { if (is_null($class)) { self::$instance = self::makeInstance( Implementation::class, $options )->getApp($options); self::$instance->load(); } else { ! is_object($class) || self::$instance = $class; } } return self::$instance; }
[ "public", "static", "function", "getInstance", "(", "$", "class", "=", "null", ",", "array", "$", "options", "=", "[", "]", ")", "{", "/** @var Implementation $instance */", "if", "(", "is_null", "(", "self", "::", "$", "instance", ")", ")", "{", "if", "(", "is_null", "(", "$", "class", ")", ")", "{", "self", "::", "$", "instance", "=", "self", "::", "makeInstance", "(", "Implementation", "::", "class", ",", "$", "options", ")", "->", "getApp", "(", "$", "options", ")", ";", "self", "::", "$", "instance", "->", "load", "(", ")", ";", "}", "else", "{", "!", "is_object", "(", "$", "class", ")", "||", "self", "::", "$", "instance", "=", "$", "class", ";", "}", "}", "return", "self", "::", "$", "instance", ";", "}" ]
Get the instance this facade refers to @param null $class @param array $options @return Implementation
[ "Get", "the", "instance", "this", "facade", "refers", "to" ]
36db55c537175cead2ab412f166bf2574d0f9597
https://github.com/judus/minimal-minimal/blob/36db55c537175cead2ab412f166bf2574d0f9597/src/Facades/App.php#L88-L105
240,866
mfrost503/Snaggle
src/Client/Signatures/Signature.php
Signature.setHttpMethod
public function setHttpMethod($method) { $allowedMethods = array( 'POST', 'PUT', 'GET', 'DELETE', 'PATCH' ); if (!in_array(strtoupper($method), $allowedMethods)) { throw new \InvalidArgumentException('Provided method not allowed'); } $this->httpMethod = strtoupper($method); return $this; }
php
public function setHttpMethod($method) { $allowedMethods = array( 'POST', 'PUT', 'GET', 'DELETE', 'PATCH' ); if (!in_array(strtoupper($method), $allowedMethods)) { throw new \InvalidArgumentException('Provided method not allowed'); } $this->httpMethod = strtoupper($method); return $this; }
[ "public", "function", "setHttpMethod", "(", "$", "method", ")", "{", "$", "allowedMethods", "=", "array", "(", "'POST'", ",", "'PUT'", ",", "'GET'", ",", "'DELETE'", ",", "'PATCH'", ")", ";", "if", "(", "!", "in_array", "(", "strtoupper", "(", "$", "method", ")", ",", "$", "allowedMethods", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Provided method not allowed'", ")", ";", "}", "$", "this", "->", "httpMethod", "=", "strtoupper", "(", "$", "method", ")", ";", "return", "$", "this", ";", "}" ]
Method to set the HTTP verb for the request @param string $method
[ "Method", "to", "set", "the", "HTTP", "verb", "for", "the", "request" ]
20990fe94b12b2013bca22689cde3b231eac4380
https://github.com/mfrost503/Snaggle/blob/20990fe94b12b2013bca22689cde3b231eac4380/src/Client/Signatures/Signature.php#L122-L136
240,867
mfrost503/Snaggle
src/Client/Signatures/Signature.php
Signature.getNonce
public function getNonce() { if ($this->nonce !== '') { return $this->nonce; } $this->nonce = md5(uniqid(rand(), true)); return $this->nonce; }
php
public function getNonce() { if ($this->nonce !== '') { return $this->nonce; } $this->nonce = md5(uniqid(rand(), true)); return $this->nonce; }
[ "public", "function", "getNonce", "(", ")", "{", "if", "(", "$", "this", "->", "nonce", "!==", "''", ")", "{", "return", "$", "this", "->", "nonce", ";", "}", "$", "this", "->", "nonce", "=", "md5", "(", "uniqid", "(", "rand", "(", ")", ",", "true", ")", ")", ";", "return", "$", "this", "->", "nonce", ";", "}" ]
Method to retrieve the nonce @return string
[ "Method", "to", "retrieve", "the", "nonce" ]
20990fe94b12b2013bca22689cde3b231eac4380
https://github.com/mfrost503/Snaggle/blob/20990fe94b12b2013bca22689cde3b231eac4380/src/Client/Signatures/Signature.php#L176-L183
240,868
mfrost503/Snaggle
src/Client/Signatures/Signature.php
Signature.setTimestamp
public function setTimestamp($timestamp = 0) { $this->timestamp = $timestamp; if ($timestamp === 0) { $this->timestamp = $this->generateTimestamp(); } return $this; }
php
public function setTimestamp($timestamp = 0) { $this->timestamp = $timestamp; if ($timestamp === 0) { $this->timestamp = $this->generateTimestamp(); } return $this; }
[ "public", "function", "setTimestamp", "(", "$", "timestamp", "=", "0", ")", "{", "$", "this", "->", "timestamp", "=", "$", "timestamp", ";", "if", "(", "$", "timestamp", "===", "0", ")", "{", "$", "this", "->", "timestamp", "=", "$", "this", "->", "generateTimestamp", "(", ")", ";", "}", "return", "$", "this", ";", "}" ]
Method to set the timestamp parameter for the signature @param int $timestamp
[ "Method", "to", "set", "the", "timestamp", "parameter", "for", "the", "signature" ]
20990fe94b12b2013bca22689cde3b231eac4380
https://github.com/mfrost503/Snaggle/blob/20990fe94b12b2013bca22689cde3b231eac4380/src/Client/Signatures/Signature.php#L242-L249
240,869
tomphp/TjoAnnotationRouter
src/TjoAnnotationRouter/Service/AnnotationManagerFactory.php
AnnotationManagerFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $annotationManager = new AnnotationManager(); $parser = new DoctrineAnnotationParser(); foreach ($this->defaultAnnotations as $annotationName) { $class = 'TjoAnnotationRouter\\Annotation\\' . $annotationName; $parser->registerAnnotation($class); } $annotationManager->attach($parser); return $annotationManager; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $annotationManager = new AnnotationManager(); $parser = new DoctrineAnnotationParser(); foreach ($this->defaultAnnotations as $annotationName) { $class = 'TjoAnnotationRouter\\Annotation\\' . $annotationName; $parser->registerAnnotation($class); } $annotationManager->attach($parser); return $annotationManager; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "annotationManager", "=", "new", "AnnotationManager", "(", ")", ";", "$", "parser", "=", "new", "DoctrineAnnotationParser", "(", ")", ";", "foreach", "(", "$", "this", "->", "defaultAnnotations", "as", "$", "annotationName", ")", "{", "$", "class", "=", "'TjoAnnotationRouter\\\\Annotation\\\\'", ".", "$", "annotationName", ";", "$", "parser", "->", "registerAnnotation", "(", "$", "class", ")", ";", "}", "$", "annotationManager", "->", "attach", "(", "$", "parser", ")", ";", "return", "$", "annotationManager", ";", "}" ]
Returns a configured instance of Zend\Code\Annotation\AnnotationManager @return AnnotationManager
[ "Returns", "a", "configured", "instance", "of", "Zend", "\\", "Code", "\\", "Annotation", "\\", "AnnotationManager" ]
ee323691e948d82449287eae5c1ecce80cc90971
https://github.com/tomphp/TjoAnnotationRouter/blob/ee323691e948d82449287eae5c1ecce80cc90971/src/TjoAnnotationRouter/Service/AnnotationManagerFactory.php#L38-L52
240,870
lazyguru/toggl
src/TimeEntry.php
TimeEntry.setTask
public function setTask($task) { $taskCode = filter_var($task, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); if (strpos($taskCode, '-') !== false) { $taskCode = str_replace('-', '', $taskCode); } $taskCode = $this->project . $taskCode; $this->task = $taskCode; }
php
public function setTask($task) { $taskCode = filter_var($task, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION); if (strpos($taskCode, '-') !== false) { $taskCode = str_replace('-', '', $taskCode); } $taskCode = $this->project . $taskCode; $this->task = $taskCode; }
[ "public", "function", "setTask", "(", "$", "task", ")", "{", "$", "taskCode", "=", "filter_var", "(", "$", "task", ",", "FILTER_SANITIZE_NUMBER_FLOAT", ",", "FILTER_FLAG_ALLOW_FRACTION", ")", ";", "if", "(", "strpos", "(", "$", "taskCode", ",", "'-'", ")", "!==", "false", ")", "{", "$", "taskCode", "=", "str_replace", "(", "'-'", ",", "''", ",", "$", "taskCode", ")", ";", "}", "$", "taskCode", "=", "$", "this", "->", "project", ".", "$", "taskCode", ";", "$", "this", "->", "task", "=", "$", "taskCode", ";", "}" ]
Sets the internal task ID for this task. Task is determineed by concatenating project and task code @param string $task
[ "Sets", "the", "internal", "task", "ID", "for", "this", "task", ".", "Task", "is", "determineed", "by", "concatenating", "project", "and", "task", "code" ]
5ce8b5f937b38dc5afd40b362db26e93239d7135
https://github.com/lazyguru/toggl/blob/5ce8b5f937b38dc5afd40b362db26e93239d7135/src/TimeEntry.php#L52-L60
240,871
lazyguru/toggl
src/TimeEntry.php
TimeEntry.processTags
public function processTags($tags = null) { if (empty($tags)) { $tags = $this->tags; } foreach ($tags as $tag) { $this->tags[] = $tag; if (preg_match('/[A-Z]+\-[\d]+/', $tag)) { $this->setTicket($tag); continue; } if ($tag == 'Jira') { $this->setLogged(true); } } $this->tags = array_unique($this->tags); }
php
public function processTags($tags = null) { if (empty($tags)) { $tags = $this->tags; } foreach ($tags as $tag) { $this->tags[] = $tag; if (preg_match('/[A-Z]+\-[\d]+/', $tag)) { $this->setTicket($tag); continue; } if ($tag == 'Jira') { $this->setLogged(true); } } $this->tags = array_unique($this->tags); }
[ "public", "function", "processTags", "(", "$", "tags", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "tags", ")", ")", "{", "$", "tags", "=", "$", "this", "->", "tags", ";", "}", "foreach", "(", "$", "tags", "as", "$", "tag", ")", "{", "$", "this", "->", "tags", "[", "]", "=", "$", "tag", ";", "if", "(", "preg_match", "(", "'/[A-Z]+\\-[\\d]+/'", ",", "$", "tag", ")", ")", "{", "$", "this", "->", "setTicket", "(", "$", "tag", ")", ";", "continue", ";", "}", "if", "(", "$", "tag", "==", "'Jira'", ")", "{", "$", "this", "->", "setLogged", "(", "true", ")", ";", "}", "}", "$", "this", "->", "tags", "=", "array_unique", "(", "$", "this", "->", "tags", ")", ";", "}" ]
Processes an array of tags to find the ticket number as well as other internally used tags @param array $tags An array of tags to process
[ "Processes", "an", "array", "of", "tags", "to", "find", "the", "ticket", "number", "as", "well", "as", "other", "internally", "used", "tags" ]
5ce8b5f937b38dc5afd40b362db26e93239d7135
https://github.com/lazyguru/toggl/blob/5ce8b5f937b38dc5afd40b362db26e93239d7135/src/TimeEntry.php#L269-L285
240,872
ipunkt/rancherize-backup-storagebox
plugin/Backup/Methods/Storagebox/StorageboxMethod.php
StorageboxMethod.startRestoreService
private function startRestoreService( StorageboxData $data, $backupKey, Database $database, OutputInterface $output) { $stackName = $data->getBackup()->getStackName(); $restoreService = new Service(); $restoreService->setImage('ipunktbs/xtrabackup:1.1.1'); $restoreService->setName('restore-'.$backupKey); $restoreService->setCommand('restore '.$backupKey); $restoreService->setRestart(Service::RESTART_START_ONCE); $mysqlVolume = $this->makeVolume($data); $backupVolume = $this->makeBackupVolume($database); $restoreService->addVolume( $mysqlVolume ); $restoreService->addVolume( $backupVolume ); /** * @var SchedulerParser $schedulerParser */ //$schedulerParser = container(SchedulerParser::class); $schedulerParser = container('scheduler-parser'); $config = new ArrayConfiguration([ 'scheduler' => [ 'should-have-tags' => [ 'primary-restore' ] ] ]); $schedulerParser->parse($restoreService, $config); $restoreInfrastructure = new Infrastructure(); $restoreInfrastructure->addService($restoreService); $this->infrastructureWriter->setPath( $this->getWorkDirectory() ) ->setSkipClear(false) ->write($restoreInfrastructure, new FileWriter()); $output->writeln("Starting ".$restoreService->getName()."."); $this->rancherService->start( $this->getWorkDirectory(), $stackName); $output->writeln("Waiting for ".$restoreService->getName()." to finish."); $this->rancherService->wait($stackName, $restoreService->getName(), new HealthStateMatcher('started-once') ); $output->writeln($restoreService->getName()." finished."); return $restoreService; }
php
private function startRestoreService( StorageboxData $data, $backupKey, Database $database, OutputInterface $output) { $stackName = $data->getBackup()->getStackName(); $restoreService = new Service(); $restoreService->setImage('ipunktbs/xtrabackup:1.1.1'); $restoreService->setName('restore-'.$backupKey); $restoreService->setCommand('restore '.$backupKey); $restoreService->setRestart(Service::RESTART_START_ONCE); $mysqlVolume = $this->makeVolume($data); $backupVolume = $this->makeBackupVolume($database); $restoreService->addVolume( $mysqlVolume ); $restoreService->addVolume( $backupVolume ); /** * @var SchedulerParser $schedulerParser */ //$schedulerParser = container(SchedulerParser::class); $schedulerParser = container('scheduler-parser'); $config = new ArrayConfiguration([ 'scheduler' => [ 'should-have-tags' => [ 'primary-restore' ] ] ]); $schedulerParser->parse($restoreService, $config); $restoreInfrastructure = new Infrastructure(); $restoreInfrastructure->addService($restoreService); $this->infrastructureWriter->setPath( $this->getWorkDirectory() ) ->setSkipClear(false) ->write($restoreInfrastructure, new FileWriter()); $output->writeln("Starting ".$restoreService->getName()."."); $this->rancherService->start( $this->getWorkDirectory(), $stackName); $output->writeln("Waiting for ".$restoreService->getName()." to finish."); $this->rancherService->wait($stackName, $restoreService->getName(), new HealthStateMatcher('started-once') ); $output->writeln($restoreService->getName()." finished."); return $restoreService; }
[ "private", "function", "startRestoreService", "(", "StorageboxData", "$", "data", ",", "$", "backupKey", ",", "Database", "$", "database", ",", "OutputInterface", "$", "output", ")", "{", "$", "stackName", "=", "$", "data", "->", "getBackup", "(", ")", "->", "getStackName", "(", ")", ";", "$", "restoreService", "=", "new", "Service", "(", ")", ";", "$", "restoreService", "->", "setImage", "(", "'ipunktbs/xtrabackup:1.1.1'", ")", ";", "$", "restoreService", "->", "setName", "(", "'restore-'", ".", "$", "backupKey", ")", ";", "$", "restoreService", "->", "setCommand", "(", "'restore '", ".", "$", "backupKey", ")", ";", "$", "restoreService", "->", "setRestart", "(", "Service", "::", "RESTART_START_ONCE", ")", ";", "$", "mysqlVolume", "=", "$", "this", "->", "makeVolume", "(", "$", "data", ")", ";", "$", "backupVolume", "=", "$", "this", "->", "makeBackupVolume", "(", "$", "database", ")", ";", "$", "restoreService", "->", "addVolume", "(", "$", "mysqlVolume", ")", ";", "$", "restoreService", "->", "addVolume", "(", "$", "backupVolume", ")", ";", "/**\n\t\t * @var SchedulerParser $schedulerParser\n\t\t */", "//$schedulerParser = container(SchedulerParser::class);", "$", "schedulerParser", "=", "container", "(", "'scheduler-parser'", ")", ";", "$", "config", "=", "new", "ArrayConfiguration", "(", "[", "'scheduler'", "=>", "[", "'should-have-tags'", "=>", "[", "'primary-restore'", "]", "]", "]", ")", ";", "$", "schedulerParser", "->", "parse", "(", "$", "restoreService", ",", "$", "config", ")", ";", "$", "restoreInfrastructure", "=", "new", "Infrastructure", "(", ")", ";", "$", "restoreInfrastructure", "->", "addService", "(", "$", "restoreService", ")", ";", "$", "this", "->", "infrastructureWriter", "->", "setPath", "(", "$", "this", "->", "getWorkDirectory", "(", ")", ")", "->", "setSkipClear", "(", "false", ")", "->", "write", "(", "$", "restoreInfrastructure", ",", "new", "FileWriter", "(", ")", ")", ";", "$", "output", "->", "writeln", "(", "\"Starting \"", ".", "$", "restoreService", "->", "getName", "(", ")", ".", "\".\"", ")", ";", "$", "this", "->", "rancherService", "->", "start", "(", "$", "this", "->", "getWorkDirectory", "(", ")", ",", "$", "stackName", ")", ";", "$", "output", "->", "writeln", "(", "\"Waiting for \"", ".", "$", "restoreService", "->", "getName", "(", ")", ".", "\" to finish.\"", ")", ";", "$", "this", "->", "rancherService", "->", "wait", "(", "$", "stackName", ",", "$", "restoreService", "->", "getName", "(", ")", ",", "new", "HealthStateMatcher", "(", "'started-once'", ")", ")", ";", "$", "output", "->", "writeln", "(", "$", "restoreService", "->", "getName", "(", ")", ".", "\" finished.\"", ")", ";", "return", "$", "restoreService", ";", "}" ]
Start the restore service @param StorageboxData $data @param string $backupKey @param Database $database @param OutputInterface $output @return Service
[ "Start", "the", "restore", "service" ]
2c018a2a811aea864c33bddb3ed5f53cd7b696f8
https://github.com/ipunkt/rancherize-backup-storagebox/blob/2c018a2a811aea864c33bddb3ed5f53cd7b696f8/plugin/Backup/Methods/Storagebox/StorageboxMethod.php#L286-L326
240,873
ipunkt/rancherize-backup-storagebox
plugin/Backup/Methods/Storagebox/StorageboxMethod.php
StorageboxMethod.startNewService
private function startNewService(Service $restoreService,StorageboxData $data, $backupKey, OutputInterface $output) { $stackName = $data->getBackup()->getStackName(); $restoreServiceName = $restoreService->getName(); $dockerCompose = [ 'version' => '2', 'services' => array_merge( [$data->getBackup()->getServiceName() => $data->getService()], $data->getSidekicks() ) ]; $rancherCompose = $data->getRancherData(); // TODO: Allow to set as option. If not set: ask user $regex = '~$~'; $replacement = '-'.$backupKey; foreach($this->modifiers as $modifier) { if($modifier instanceof RequiresReplacementRegex) $modifier->setReplacementRegex($regex, $replacement); $modifier->modify($dockerCompose, $rancherCompose, $data); } // Start on the same server as the restore service $compose = &$dockerCompose; foreach([ 'services', $data->getNewServiceName(), 'labels', ] as $key) { if( !array_key_exists($key, $compose) ) $compose[$key] = []; $compose = &$compose[$key]; } $dockerCompose['services'][$data->getNewServiceName()]['labels']['io.rancher.scheduler.affinity:container_label_soft'] = "io.rancher.stack_service.name=${stackName}/${restoreServiceName}"; $dockerFileContent = Yaml::dump($dockerCompose, 100, 2); $this->buildService->createDockerCompose($dockerFileContent); $rancherFileContent = Yaml::dump($rancherCompose, 100, 2); $this->buildService->createRancherCompose($rancherFileContent); $stackName = $data->getBackup()->getStackName(); $newServiceName = $data->getNewServiceName(); $output->writeln("Starting $newServiceName."); $this->rancherService->start( $this->getWorkDirectory(), $stackName); $output->writeln("Waiting for $newServiceName to start."); $this->rancherService->wait($stackName, $newServiceName, new SingleStateMatcher('active') ); $output->writeln("$newServiceName Started."); }
php
private function startNewService(Service $restoreService,StorageboxData $data, $backupKey, OutputInterface $output) { $stackName = $data->getBackup()->getStackName(); $restoreServiceName = $restoreService->getName(); $dockerCompose = [ 'version' => '2', 'services' => array_merge( [$data->getBackup()->getServiceName() => $data->getService()], $data->getSidekicks() ) ]; $rancherCompose = $data->getRancherData(); // TODO: Allow to set as option. If not set: ask user $regex = '~$~'; $replacement = '-'.$backupKey; foreach($this->modifiers as $modifier) { if($modifier instanceof RequiresReplacementRegex) $modifier->setReplacementRegex($regex, $replacement); $modifier->modify($dockerCompose, $rancherCompose, $data); } // Start on the same server as the restore service $compose = &$dockerCompose; foreach([ 'services', $data->getNewServiceName(), 'labels', ] as $key) { if( !array_key_exists($key, $compose) ) $compose[$key] = []; $compose = &$compose[$key]; } $dockerCompose['services'][$data->getNewServiceName()]['labels']['io.rancher.scheduler.affinity:container_label_soft'] = "io.rancher.stack_service.name=${stackName}/${restoreServiceName}"; $dockerFileContent = Yaml::dump($dockerCompose, 100, 2); $this->buildService->createDockerCompose($dockerFileContent); $rancherFileContent = Yaml::dump($rancherCompose, 100, 2); $this->buildService->createRancherCompose($rancherFileContent); $stackName = $data->getBackup()->getStackName(); $newServiceName = $data->getNewServiceName(); $output->writeln("Starting $newServiceName."); $this->rancherService->start( $this->getWorkDirectory(), $stackName); $output->writeln("Waiting for $newServiceName to start."); $this->rancherService->wait($stackName, $newServiceName, new SingleStateMatcher('active') ); $output->writeln("$newServiceName Started."); }
[ "private", "function", "startNewService", "(", "Service", "$", "restoreService", ",", "StorageboxData", "$", "data", ",", "$", "backupKey", ",", "OutputInterface", "$", "output", ")", "{", "$", "stackName", "=", "$", "data", "->", "getBackup", "(", ")", "->", "getStackName", "(", ")", ";", "$", "restoreServiceName", "=", "$", "restoreService", "->", "getName", "(", ")", ";", "$", "dockerCompose", "=", "[", "'version'", "=>", "'2'", ",", "'services'", "=>", "array_merge", "(", "[", "$", "data", "->", "getBackup", "(", ")", "->", "getServiceName", "(", ")", "=>", "$", "data", "->", "getService", "(", ")", "]", ",", "$", "data", "->", "getSidekicks", "(", ")", ")", "]", ";", "$", "rancherCompose", "=", "$", "data", "->", "getRancherData", "(", ")", ";", "// TODO: Allow to set as option. If not set: ask user", "$", "regex", "=", "'~$~'", ";", "$", "replacement", "=", "'-'", ".", "$", "backupKey", ";", "foreach", "(", "$", "this", "->", "modifiers", "as", "$", "modifier", ")", "{", "if", "(", "$", "modifier", "instanceof", "RequiresReplacementRegex", ")", "$", "modifier", "->", "setReplacementRegex", "(", "$", "regex", ",", "$", "replacement", ")", ";", "$", "modifier", "->", "modify", "(", "$", "dockerCompose", ",", "$", "rancherCompose", ",", "$", "data", ")", ";", "}", "// Start on the same server as the restore service", "$", "compose", "=", "&", "$", "dockerCompose", ";", "foreach", "(", "[", "'services'", ",", "$", "data", "->", "getNewServiceName", "(", ")", ",", "'labels'", ",", "]", "as", "$", "key", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "compose", ")", ")", "$", "compose", "[", "$", "key", "]", "=", "[", "]", ";", "$", "compose", "=", "&", "$", "compose", "[", "$", "key", "]", ";", "}", "$", "dockerCompose", "[", "'services'", "]", "[", "$", "data", "->", "getNewServiceName", "(", ")", "]", "[", "'labels'", "]", "[", "'io.rancher.scheduler.affinity:container_label_soft'", "]", "=", "\"io.rancher.stack_service.name=${stackName}/${restoreServiceName}\"", ";", "$", "dockerFileContent", "=", "Yaml", "::", "dump", "(", "$", "dockerCompose", ",", "100", ",", "2", ")", ";", "$", "this", "->", "buildService", "->", "createDockerCompose", "(", "$", "dockerFileContent", ")", ";", "$", "rancherFileContent", "=", "Yaml", "::", "dump", "(", "$", "rancherCompose", ",", "100", ",", "2", ")", ";", "$", "this", "->", "buildService", "->", "createRancherCompose", "(", "$", "rancherFileContent", ")", ";", "$", "stackName", "=", "$", "data", "->", "getBackup", "(", ")", "->", "getStackName", "(", ")", ";", "$", "newServiceName", "=", "$", "data", "->", "getNewServiceName", "(", ")", ";", "$", "output", "->", "writeln", "(", "\"Starting $newServiceName.\"", ")", ";", "$", "this", "->", "rancherService", "->", "start", "(", "$", "this", "->", "getWorkDirectory", "(", ")", ",", "$", "stackName", ")", ";", "$", "output", "->", "writeln", "(", "\"Waiting for $newServiceName to start.\"", ")", ";", "$", "this", "->", "rancherService", "->", "wait", "(", "$", "stackName", ",", "$", "newServiceName", ",", "new", "SingleStateMatcher", "(", "'active'", ")", ")", ";", "$", "output", "->", "writeln", "(", "\"$newServiceName Started.\"", ")", ";", "}" ]
Start the new service @param Service $restoreService @param StorageboxData $data @param $backupKey @param OutputInterface $output
[ "Start", "the", "new", "service" ]
2c018a2a811aea864c33bddb3ed5f53cd7b696f8
https://github.com/ipunkt/rancherize-backup-storagebox/blob/2c018a2a811aea864c33bddb3ed5f53cd7b696f8/plugin/Backup/Methods/Storagebox/StorageboxMethod.php#L335-L385
240,874
asbsoft/yii2module-content_2_170309
models/ContentBase.php
ContentBase.prepareI18nModels
public function prepareI18nModels() { $mI18n = $this->getJoined()->all(); $modelsI18n = []; foreach ($mI18n as $modelI18n) { $modelI18n->correctSelectedText(); $modelsI18n[$modelI18n->lang_code] = $modelI18n; } foreach ($this->languages as $langCode => $lang) { if (empty($modelsI18n[$langCode])) { $newI18n = $this->module->model(static::I18N_JOIN_MODEL); $modelsI18n[$langCode] = $newI18n->loadDefaultValues(); $modelsI18n[$langCode]->lang_code = $langCode; } } return $modelsI18n; }
php
public function prepareI18nModels() { $mI18n = $this->getJoined()->all(); $modelsI18n = []; foreach ($mI18n as $modelI18n) { $modelI18n->correctSelectedText(); $modelsI18n[$modelI18n->lang_code] = $modelI18n; } foreach ($this->languages as $langCode => $lang) { if (empty($modelsI18n[$langCode])) { $newI18n = $this->module->model(static::I18N_JOIN_MODEL); $modelsI18n[$langCode] = $newI18n->loadDefaultValues(); $modelsI18n[$langCode]->lang_code = $langCode; } } return $modelsI18n; }
[ "public", "function", "prepareI18nModels", "(", ")", "{", "$", "mI18n", "=", "$", "this", "->", "getJoined", "(", ")", "->", "all", "(", ")", ";", "$", "modelsI18n", "=", "[", "]", ";", "foreach", "(", "$", "mI18n", "as", "$", "modelI18n", ")", "{", "$", "modelI18n", "->", "correctSelectedText", "(", ")", ";", "$", "modelsI18n", "[", "$", "modelI18n", "->", "lang_code", "]", "=", "$", "modelI18n", ";", "}", "foreach", "(", "$", "this", "->", "languages", "as", "$", "langCode", "=>", "$", "lang", ")", "{", "if", "(", "empty", "(", "$", "modelsI18n", "[", "$", "langCode", "]", ")", ")", "{", "$", "newI18n", "=", "$", "this", "->", "module", "->", "model", "(", "static", "::", "I18N_JOIN_MODEL", ")", ";", "$", "modelsI18n", "[", "$", "langCode", "]", "=", "$", "newI18n", "->", "loadDefaultValues", "(", ")", ";", "$", "modelsI18n", "[", "$", "langCode", "]", "->", "lang_code", "=", "$", "langCode", ";", "}", "}", "return", "$", "modelsI18n", ";", "}" ]
Prepare i18n-models array, create new if need. No error if new language add or not found joined record - will create new i18n-model with default values. @return array in format langCode => i18n-model's object
[ "Prepare", "i18n", "-", "models", "array", "create", "new", "if", "need", ".", "No", "error", "if", "new", "language", "add", "or", "not", "found", "joined", "record", "-", "will", "create", "new", "i18n", "-", "model", "with", "default", "values", "." ]
9e7ee40fd48ef9656a9f95379f20bf6a4004187b
https://github.com/asbsoft/yii2module-content_2_170309/blob/9e7ee40fd48ef9656a9f95379f20bf6a4004187b/models/ContentBase.php#L217-L233
240,875
wasabi-cms/core
src/Model/Entity/Setting.php
Setting.errors
public function errors($field = null, $errors = null, $overwrite = false) { if (isset($this->_properties['scope'])) { $this->_errors = []; } return parent::errors($field, $errors, $overwrite); }
php
public function errors($field = null, $errors = null, $overwrite = false) { if (isset($this->_properties['scope'])) { $this->_errors = []; } return parent::errors($field, $errors, $overwrite); }
[ "public", "function", "errors", "(", "$", "field", "=", "null", ",", "$", "errors", "=", "null", ",", "$", "overwrite", "=", "false", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_properties", "[", "'scope'", "]", ")", ")", "{", "$", "this", "->", "_errors", "=", "[", "]", ";", "}", "return", "parent", "::", "errors", "(", "$", "field", ",", "$", "errors", ",", "$", "overwrite", ")", ";", "}" ]
Skip error checking for the actual save operation since the entity is checked for errors manually within the KeyValueBehavior. @param string|array|null $field The field to get errors for, or the array of errors to set. @param string|array|null $errors The errors to be set for $field @param bool $overwrite Whether or not to overwrite pre-existing errors for $field @return array|\Cake\Datasource\EntityInterface
[ "Skip", "error", "checking", "for", "the", "actual", "save", "operation", "since", "the", "entity", "is", "checked", "for", "errors", "manually", "within", "the", "KeyValueBehavior", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Model/Entity/Setting.php#L35-L42
240,876
theluckyteam/php-jira
src/jira/Repository/RepositoryDispatcher.php
RepositoryDispatcher.addRepository
public function addRepository(RepositoryInterface $repository) { if ($repository instanceof IssueRepository) { $type = 'issue'; } else { throw new \Exception('Unknown repository type.'); } $this->repositories[$type] = $repository; }
php
public function addRepository(RepositoryInterface $repository) { if ($repository instanceof IssueRepository) { $type = 'issue'; } else { throw new \Exception('Unknown repository type.'); } $this->repositories[$type] = $repository; }
[ "public", "function", "addRepository", "(", "RepositoryInterface", "$", "repository", ")", "{", "if", "(", "$", "repository", "instanceof", "IssueRepository", ")", "{", "$", "type", "=", "'issue'", ";", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Unknown repository type.'", ")", ";", "}", "$", "this", "->", "repositories", "[", "$", "type", "]", "=", "$", "repository", ";", "}" ]
Register the repository in the manager @param RepositoryInterface $repository @throws \Exception
[ "Register", "the", "repository", "in", "the", "manager" ]
5a50ab4fc57dd77239f1b7e9c87738318c258c38
https://github.com/theluckyteam/php-jira/blob/5a50ab4fc57dd77239f1b7e9c87738318c258c38/src/jira/Repository/RepositoryDispatcher.php#L130-L139
240,877
eureka-framework/Eurekon
Help.php
Help.addArgument
public function addArgument($shortName = '', $fullName = '', $description = '', $hasValue = false, $isMandatory = false) { $argument = new \stdClass(); $argument->shortName = $shortName; $argument->fullName = $fullName; $argument->description = $description; $argument->hasValue = (bool) $hasValue; $argument->isMandatory = (bool) $isMandatory; $this->arguments[] = $argument; }
php
public function addArgument($shortName = '', $fullName = '', $description = '', $hasValue = false, $isMandatory = false) { $argument = new \stdClass(); $argument->shortName = $shortName; $argument->fullName = $fullName; $argument->description = $description; $argument->hasValue = (bool) $hasValue; $argument->isMandatory = (bool) $isMandatory; $this->arguments[] = $argument; }
[ "public", "function", "addArgument", "(", "$", "shortName", "=", "''", ",", "$", "fullName", "=", "''", ",", "$", "description", "=", "''", ",", "$", "hasValue", "=", "false", ",", "$", "isMandatory", "=", "false", ")", "{", "$", "argument", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "argument", "->", "shortName", "=", "$", "shortName", ";", "$", "argument", "->", "fullName", "=", "$", "fullName", ";", "$", "argument", "->", "description", "=", "$", "description", ";", "$", "argument", "->", "hasValue", "=", "(", "bool", ")", "$", "hasValue", ";", "$", "argument", "->", "isMandatory", "=", "(", "bool", ")", "$", "isMandatory", ";", "$", "this", "->", "arguments", "[", "]", "=", "$", "argument", ";", "}" ]
Add argument in list for script help @param string $shortName Short name for argument @param string $fullName Full name for argument @param string $description Argument's description @param boolean $hasValue If argument must have value @param boolean $isMandatory Set true to force mandatory mention. @return void
[ "Add", "argument", "in", "list", "for", "script", "help" ]
86f958f9458ea369894286d8cdc4fe4ded33489a
https://github.com/eureka-framework/Eurekon/blob/86f958f9458ea369894286d8cdc4fe4ded33489a/Help.php#L142-L152
240,878
EarthlingInteractive/PHPCMIPREST
lib/EarthIT/CMIPREST/ResultAssembler/NOJResultAssembler.php
EarthIT_CMIPREST_ResultAssembler_NOJResultAssembler._q45
protected function _q45( EarthIT_Schema_ResourceClass $rc, array $items ) { $restObjects = array(); $keyByIds = $this->shouldKeyRestItemsById($rc); foreach( $items as $item ) { $restItem = $this->internalObjectToRest($rc, $item); if( $keyByIds ) { $restObjects[EarthIT_Storage_Util::itemId($item,$rc)] = $restItem; } else { $restObjects[] = $restItem; } } return $this->jsonTyped($restObjects, $keyByIds ? EarthIT_JSON::JT_OBJECT : EarthIT_JSON::JT_LIST); }
php
protected function _q45( EarthIT_Schema_ResourceClass $rc, array $items ) { $restObjects = array(); $keyByIds = $this->shouldKeyRestItemsById($rc); foreach( $items as $item ) { $restItem = $this->internalObjectToRest($rc, $item); if( $keyByIds ) { $restObjects[EarthIT_Storage_Util::itemId($item,$rc)] = $restItem; } else { $restObjects[] = $restItem; } } return $this->jsonTyped($restObjects, $keyByIds ? EarthIT_JSON::JT_OBJECT : EarthIT_JSON::JT_LIST); }
[ "protected", "function", "_q45", "(", "EarthIT_Schema_ResourceClass", "$", "rc", ",", "array", "$", "items", ")", "{", "$", "restObjects", "=", "array", "(", ")", ";", "$", "keyByIds", "=", "$", "this", "->", "shouldKeyRestItemsById", "(", "$", "rc", ")", ";", "foreach", "(", "$", "items", "as", "$", "item", ")", "{", "$", "restItem", "=", "$", "this", "->", "internalObjectToRest", "(", "$", "rc", ",", "$", "item", ")", ";", "if", "(", "$", "keyByIds", ")", "{", "$", "restObjects", "[", "EarthIT_Storage_Util", "::", "itemId", "(", "$", "item", ",", "$", "rc", ")", "]", "=", "$", "restItem", ";", "}", "else", "{", "$", "restObjects", "[", "]", "=", "$", "restItem", ";", "}", "}", "return", "$", "this", "->", "jsonTyped", "(", "$", "restObjects", ",", "$", "keyByIds", "?", "EarthIT_JSON", "::", "JT_OBJECT", ":", "EarthIT_JSON", "::", "JT_LIST", ")", ";", "}" ]
Convert the given rows from DB to REST format according to the specified resource class.
[ "Convert", "the", "given", "rows", "from", "DB", "to", "REST", "format", "according", "to", "the", "specified", "resource", "class", "." ]
db0398ea4fc07fa62f2de9ba43f2f3137170d9f0
https://github.com/EarthlingInteractive/PHPCMIPREST/blob/db0398ea4fc07fa62f2de9ba43f2f3137170d9f0/lib/EarthIT/CMIPREST/ResultAssembler/NOJResultAssembler.php#L67-L79
240,879
teamelf/core
src/Http/ViewController.php
ViewController.addAssets
protected function addAssets() { $this->assets = ViewService::getAssetManager(); $this->assets ->addCss(__DIR__ . '/../../assets/common/dist/common.css') ->addJs(__DIR__ . '/../../assets/common/dist/common.js') ->entry('teamelf/common/main'); }
php
protected function addAssets() { $this->assets = ViewService::getAssetManager(); $this->assets ->addCss(__DIR__ . '/../../assets/common/dist/common.css') ->addJs(__DIR__ . '/../../assets/common/dist/common.js') ->entry('teamelf/common/main'); }
[ "protected", "function", "addAssets", "(", ")", "{", "$", "this", "->", "assets", "=", "ViewService", "::", "getAssetManager", "(", ")", ";", "$", "this", "->", "assets", "->", "addCss", "(", "__DIR__", ".", "'/../../assets/common/dist/common.css'", ")", "->", "addJs", "(", "__DIR__", ".", "'/../../assets/common/dist/common.js'", ")", "->", "entry", "(", "'teamelf/common/main'", ")", ";", "}" ]
add common assets
[ "add", "common", "assets" ]
653fc6e27f42239c2a8998a5fea325480e9dd39e
https://github.com/teamelf/core/blob/653fc6e27f42239c2a8998a5fea325480e9dd39e/src/Http/ViewController.php#L54-L61
240,880
zepi/turbo-base
Zepi/DataSource/Doctrine/src/Manager/EntityManager.php
EntityManager.buildDataRequestQuery
public function buildDataRequestQuery(DataRequest $dataRequest, QueryBuilder $queryBuilder, $entity, $tableCode) { $queryBuilder->select($tableCode) ->from($entity, $tableCode); $hasWhere = false; $i = 1; foreach ($dataRequest->getFilters() as $filter) { $whereQuery = $tableCode . '.' . $filter->getFieldName() . ' ' . $filter->getMode() . ' :p' . $i; if ($hasWhere) { $queryBuilder->andWhere($whereQuery); } else { $queryBuilder->where($whereQuery); $hasWhere = true; } $queryBuilder->setParameter('p' . $i, $this->prepareValue($filter->getNeededValue(), $filter->getMode())); $i++; } // Sorting if ($dataRequest->hasSorting()) { $mode = 'ASC'; if (in_array($dataRequest->getSortByDirection(), array('ASC', 'DESC'))) { $mode = $dataRequest->getSortByDirection(); } $queryBuilder->orderBy($tableCode . '.' . $dataRequest->getSortBy(), $mode); } // Offset if ($dataRequest->hasRange()) { $queryBuilder->setFirstResult($dataRequest->getOffset()); $queryBuilder->setMaxResults($dataRequest->getNumberOfEntries()); } }
php
public function buildDataRequestQuery(DataRequest $dataRequest, QueryBuilder $queryBuilder, $entity, $tableCode) { $queryBuilder->select($tableCode) ->from($entity, $tableCode); $hasWhere = false; $i = 1; foreach ($dataRequest->getFilters() as $filter) { $whereQuery = $tableCode . '.' . $filter->getFieldName() . ' ' . $filter->getMode() . ' :p' . $i; if ($hasWhere) { $queryBuilder->andWhere($whereQuery); } else { $queryBuilder->where($whereQuery); $hasWhere = true; } $queryBuilder->setParameter('p' . $i, $this->prepareValue($filter->getNeededValue(), $filter->getMode())); $i++; } // Sorting if ($dataRequest->hasSorting()) { $mode = 'ASC'; if (in_array($dataRequest->getSortByDirection(), array('ASC', 'DESC'))) { $mode = $dataRequest->getSortByDirection(); } $queryBuilder->orderBy($tableCode . '.' . $dataRequest->getSortBy(), $mode); } // Offset if ($dataRequest->hasRange()) { $queryBuilder->setFirstResult($dataRequest->getOffset()); $queryBuilder->setMaxResults($dataRequest->getNumberOfEntries()); } }
[ "public", "function", "buildDataRequestQuery", "(", "DataRequest", "$", "dataRequest", ",", "QueryBuilder", "$", "queryBuilder", ",", "$", "entity", ",", "$", "tableCode", ")", "{", "$", "queryBuilder", "->", "select", "(", "$", "tableCode", ")", "->", "from", "(", "$", "entity", ",", "$", "tableCode", ")", ";", "$", "hasWhere", "=", "false", ";", "$", "i", "=", "1", ";", "foreach", "(", "$", "dataRequest", "->", "getFilters", "(", ")", "as", "$", "filter", ")", "{", "$", "whereQuery", "=", "$", "tableCode", ".", "'.'", ".", "$", "filter", "->", "getFieldName", "(", ")", ".", "' '", ".", "$", "filter", "->", "getMode", "(", ")", ".", "' :p'", ".", "$", "i", ";", "if", "(", "$", "hasWhere", ")", "{", "$", "queryBuilder", "->", "andWhere", "(", "$", "whereQuery", ")", ";", "}", "else", "{", "$", "queryBuilder", "->", "where", "(", "$", "whereQuery", ")", ";", "$", "hasWhere", "=", "true", ";", "}", "$", "queryBuilder", "->", "setParameter", "(", "'p'", ".", "$", "i", ",", "$", "this", "->", "prepareValue", "(", "$", "filter", "->", "getNeededValue", "(", ")", ",", "$", "filter", "->", "getMode", "(", ")", ")", ")", ";", "$", "i", "++", ";", "}", "// Sorting", "if", "(", "$", "dataRequest", "->", "hasSorting", "(", ")", ")", "{", "$", "mode", "=", "'ASC'", ";", "if", "(", "in_array", "(", "$", "dataRequest", "->", "getSortByDirection", "(", ")", ",", "array", "(", "'ASC'", ",", "'DESC'", ")", ")", ")", "{", "$", "mode", "=", "$", "dataRequest", "->", "getSortByDirection", "(", ")", ";", "}", "$", "queryBuilder", "->", "orderBy", "(", "$", "tableCode", ".", "'.'", ".", "$", "dataRequest", "->", "getSortBy", "(", ")", ",", "$", "mode", ")", ";", "}", "// Offset", "if", "(", "$", "dataRequest", "->", "hasRange", "(", ")", ")", "{", "$", "queryBuilder", "->", "setFirstResult", "(", "$", "dataRequest", "->", "getOffset", "(", ")", ")", ";", "$", "queryBuilder", "->", "setMaxResults", "(", "$", "dataRequest", "->", "getNumberOfEntries", "(", ")", ")", ";", "}", "}" ]
Builds the query for the given data request object @access public @param \Zepi\DataSource\Core\Entity\DataRequest $dataRequest @param \Doctrine\ORM\QueryBuilder $queryBuilder @param string $entity @param string $tableCode
[ "Builds", "the", "query", "for", "the", "given", "data", "request", "object" ]
9a36d8c7649317f55f91b2adf386bd1f04ec02a3
https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/DataSource/Doctrine/src/Manager/EntityManager.php#L74-L109
240,881
oscarotero/server
src/Server.php
Server.run
public static function run($cwd = null, array $index = ['html', 'php'], $front = '/index.php') { if ($cwd === null) { $cwd = getcwd(); } $file = self::getFilePath($cwd, $index); //The file does not exists if ($file === false) { return false; } //The file is the front controller if (!empty($front) && ($file === $cwd.$front)) { return false; } //The file can be served by the php server if ($cwd === getcwd()) { return true; } $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); //The file is a php script that must be included if ($ext === 'php') { return $file; } //Output the file content if (isset(self::$mimes[$ext])) { $mime = self::$mimes[$ext]; } else { $info = new finfo(FILEINFO_MIME); $mime = $info->file($file); } header('Content-Type: '.$mime); readfile($file); exit; }
php
public static function run($cwd = null, array $index = ['html', 'php'], $front = '/index.php') { if ($cwd === null) { $cwd = getcwd(); } $file = self::getFilePath($cwd, $index); //The file does not exists if ($file === false) { return false; } //The file is the front controller if (!empty($front) && ($file === $cwd.$front)) { return false; } //The file can be served by the php server if ($cwd === getcwd()) { return true; } $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); //The file is a php script that must be included if ($ext === 'php') { return $file; } //Output the file content if (isset(self::$mimes[$ext])) { $mime = self::$mimes[$ext]; } else { $info = new finfo(FILEINFO_MIME); $mime = $info->file($file); } header('Content-Type: '.$mime); readfile($file); exit; }
[ "public", "static", "function", "run", "(", "$", "cwd", "=", "null", ",", "array", "$", "index", "=", "[", "'html'", ",", "'php'", "]", ",", "$", "front", "=", "'/index.php'", ")", "{", "if", "(", "$", "cwd", "===", "null", ")", "{", "$", "cwd", "=", "getcwd", "(", ")", ";", "}", "$", "file", "=", "self", "::", "getFilePath", "(", "$", "cwd", ",", "$", "index", ")", ";", "//The file does not exists", "if", "(", "$", "file", "===", "false", ")", "{", "return", "false", ";", "}", "//The file is the front controller", "if", "(", "!", "empty", "(", "$", "front", ")", "&&", "(", "$", "file", "===", "$", "cwd", ".", "$", "front", ")", ")", "{", "return", "false", ";", "}", "//The file can be served by the php server", "if", "(", "$", "cwd", "===", "getcwd", "(", ")", ")", "{", "return", "true", ";", "}", "$", "ext", "=", "strtolower", "(", "pathinfo", "(", "$", "file", ",", "PATHINFO_EXTENSION", ")", ")", ";", "//The file is a php script that must be included", "if", "(", "$", "ext", "===", "'php'", ")", "{", "return", "$", "file", ";", "}", "//Output the file content", "if", "(", "isset", "(", "self", "::", "$", "mimes", "[", "$", "ext", "]", ")", ")", "{", "$", "mime", "=", "self", "::", "$", "mimes", "[", "$", "ext", "]", ";", "}", "else", "{", "$", "info", "=", "new", "finfo", "(", "FILEINFO_MIME", ")", ";", "$", "mime", "=", "$", "info", "->", "file", "(", "$", "file", ")", ";", "}", "header", "(", "'Content-Type: '", ".", "$", "mime", ")", ";", "readfile", "(", "$", "file", ")", ";", "exit", ";", "}" ]
Runs the server @param string|null $cwd @param array $index @param string $front @return bool|string
[ "Runs", "the", "server" ]
cee9636e0d6fda094dae819f8151fd6b6563f0dc
https://github.com/oscarotero/server/blob/cee9636e0d6fda094dae819f8151fd6b6563f0dc/src/Server.php#L24-L65
240,882
oscarotero/server
src/Server.php
Server.getRequestPath
public static function getRequestPath() { if (empty($_SERVER['REQUEST_URI'])) { return false; } $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); return empty($path) ? $path : urldecode($path); }
php
public static function getRequestPath() { if (empty($_SERVER['REQUEST_URI'])) { return false; } $path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH); return empty($path) ? $path : urldecode($path); }
[ "public", "static", "function", "getRequestPath", "(", ")", "{", "if", "(", "empty", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ")", ")", "{", "return", "false", ";", "}", "$", "path", "=", "parse_url", "(", "$", "_SERVER", "[", "'REQUEST_URI'", "]", ",", "PHP_URL_PATH", ")", ";", "return", "empty", "(", "$", "path", ")", "?", "$", "path", ":", "urldecode", "(", "$", "path", ")", ";", "}" ]
Returns the path of the request uri @return string|false
[ "Returns", "the", "path", "of", "the", "request", "uri" ]
cee9636e0d6fda094dae819f8151fd6b6563f0dc
https://github.com/oscarotero/server/blob/cee9636e0d6fda094dae819f8151fd6b6563f0dc/src/Server.php#L72-L81
240,883
oscarotero/server
src/Server.php
Server.getFilePath
public static function getFilePath($cwd, array $index) { $path = self::getRequestPath(); if ($path === false) { return false; } $file = $cwd.$path; if (is_file($file)) { return $file; } if (empty($index)) { return false; } foreach ($index as $ext) { $f = rtrim($file, '/').'/index.'.$ext; if (is_file($f)) { return $f; } } return false; }
php
public static function getFilePath($cwd, array $index) { $path = self::getRequestPath(); if ($path === false) { return false; } $file = $cwd.$path; if (is_file($file)) { return $file; } if (empty($index)) { return false; } foreach ($index as $ext) { $f = rtrim($file, '/').'/index.'.$ext; if (is_file($f)) { return $f; } } return false; }
[ "public", "static", "function", "getFilePath", "(", "$", "cwd", ",", "array", "$", "index", ")", "{", "$", "path", "=", "self", "::", "getRequestPath", "(", ")", ";", "if", "(", "$", "path", "===", "false", ")", "{", "return", "false", ";", "}", "$", "file", "=", "$", "cwd", ".", "$", "path", ";", "if", "(", "is_file", "(", "$", "file", ")", ")", "{", "return", "$", "file", ";", "}", "if", "(", "empty", "(", "$", "index", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "index", "as", "$", "ext", ")", "{", "$", "f", "=", "rtrim", "(", "$", "file", ",", "'/'", ")", ".", "'/index.'", ".", "$", "ext", ";", "if", "(", "is_file", "(", "$", "f", ")", ")", "{", "return", "$", "f", ";", "}", "}", "return", "false", ";", "}" ]
Check whether the requested path exists @param string $cwd @param array $index @return string|false
[ "Check", "whether", "the", "requested", "path", "exists" ]
cee9636e0d6fda094dae819f8151fd6b6563f0dc
https://github.com/oscarotero/server/blob/cee9636e0d6fda094dae819f8151fd6b6563f0dc/src/Server.php#L91-L118
240,884
PowerOnSystem/WebFramework
src/Routing/Dispatcher.php
Dispatcher.handle
public function handle( \AltoRouter $router, \PowerOn\Network\Request $request ) { $match = $router->match($request->path); if ( $match ) { $target = explode('#', $match['target']); $this->controller = $target[0]; $this->action = key_exists(1, $target) ? $target[1] : 'index'; } else { $url = $request->urlToArray(); $controller = array_shift($url); $action = array_shift($url); $this->controller = $controller ? $controller : 'index'; $this->action = $action ? $action : 'index'; } $handler = $this->loadController(); if ( !$handler || !method_exists($handler, $this->action) ) { throw new NotFoundException('El sitio al que intenta ingresar no existe.'); } return $handler; }
php
public function handle( \AltoRouter $router, \PowerOn\Network\Request $request ) { $match = $router->match($request->path); if ( $match ) { $target = explode('#', $match['target']); $this->controller = $target[0]; $this->action = key_exists(1, $target) ? $target[1] : 'index'; } else { $url = $request->urlToArray(); $controller = array_shift($url); $action = array_shift($url); $this->controller = $controller ? $controller : 'index'; $this->action = $action ? $action : 'index'; } $handler = $this->loadController(); if ( !$handler || !method_exists($handler, $this->action) ) { throw new NotFoundException('El sitio al que intenta ingresar no existe.'); } return $handler; }
[ "public", "function", "handle", "(", "\\", "AltoRouter", "$", "router", ",", "\\", "PowerOn", "\\", "Network", "\\", "Request", "$", "request", ")", "{", "$", "match", "=", "$", "router", "->", "match", "(", "$", "request", "->", "path", ")", ";", "if", "(", "$", "match", ")", "{", "$", "target", "=", "explode", "(", "'#'", ",", "$", "match", "[", "'target'", "]", ")", ";", "$", "this", "->", "controller", "=", "$", "target", "[", "0", "]", ";", "$", "this", "->", "action", "=", "key_exists", "(", "1", ",", "$", "target", ")", "?", "$", "target", "[", "1", "]", ":", "'index'", ";", "}", "else", "{", "$", "url", "=", "$", "request", "->", "urlToArray", "(", ")", ";", "$", "controller", "=", "array_shift", "(", "$", "url", ")", ";", "$", "action", "=", "array_shift", "(", "$", "url", ")", ";", "$", "this", "->", "controller", "=", "$", "controller", "?", "$", "controller", ":", "'index'", ";", "$", "this", "->", "action", "=", "$", "action", "?", "$", "action", ":", "'index'", ";", "}", "$", "handler", "=", "$", "this", "->", "loadController", "(", ")", ";", "if", "(", "!", "$", "handler", "||", "!", "method_exists", "(", "$", "handler", ",", "$", "this", "->", "action", ")", ")", "{", "throw", "new", "NotFoundException", "(", "'El sitio al que intenta ingresar no existe.'", ")", ";", "}", "return", "$", "handler", ";", "}" ]
Obtiene el controlador a utilizar @return \PowerOn\Controller\Controller Devuelve el controlador
[ "Obtiene", "el", "controlador", "a", "utilizar" ]
3b885a390adc42d6ad93d7900d33d97c66a6c2a9
https://github.com/PowerOnSystem/WebFramework/blob/3b885a390adc42d6ad93d7900d33d97c66a6c2a9/src/Routing/Dispatcher.php#L48-L69
240,885
PowerOnSystem/WebFramework
src/Routing/Dispatcher.php
Dispatcher.force
public function force($request_controller, $request_action = 'index') { $this->controller = $request_controller; $this->action = $request_action; $handler = $this->loadController(); if ( !$handler ) { throw new LogicException(sprintf('No se existe la clase del controlador (%s)', $this->controller)); } if ( !method_exists($handler, $this->action) ) { $reflection = new \ReflectionClass($handler); throw new LogicException(sprintf('No existe el m&eacute;todo (%s) del controlador (%s)', $this->action, $reflection->getName()), ['controller' => $handler]); } return $handler; }
php
public function force($request_controller, $request_action = 'index') { $this->controller = $request_controller; $this->action = $request_action; $handler = $this->loadController(); if ( !$handler ) { throw new LogicException(sprintf('No se existe la clase del controlador (%s)', $this->controller)); } if ( !method_exists($handler, $this->action) ) { $reflection = new \ReflectionClass($handler); throw new LogicException(sprintf('No existe el m&eacute;todo (%s) del controlador (%s)', $this->action, $reflection->getName()), ['controller' => $handler]); } return $handler; }
[ "public", "function", "force", "(", "$", "request_controller", ",", "$", "request_action", "=", "'index'", ")", "{", "$", "this", "->", "controller", "=", "$", "request_controller", ";", "$", "this", "->", "action", "=", "$", "request_action", ";", "$", "handler", "=", "$", "this", "->", "loadController", "(", ")", ";", "if", "(", "!", "$", "handler", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "'No se existe la clase del controlador (%s)'", ",", "$", "this", "->", "controller", ")", ")", ";", "}", "if", "(", "!", "method_exists", "(", "$", "handler", ",", "$", "this", "->", "action", ")", ")", "{", "$", "reflection", "=", "new", "\\", "ReflectionClass", "(", "$", "handler", ")", ";", "throw", "new", "LogicException", "(", "sprintf", "(", "'No existe el m&eacute;todo (%s) del controlador (%s)'", ",", "$", "this", "->", "action", ",", "$", "reflection", "->", "getName", "(", ")", ")", ",", "[", "'controller'", "=>", "$", "handler", "]", ")", ";", "}", "return", "$", "handler", ";", "}" ]
Forza la carga de un controlador @param string $request_controller @param string $request_action @return \PowerOn\Controller\Controller @throws LogicException
[ "Forza", "la", "carga", "de", "un", "controlador" ]
3b885a390adc42d6ad93d7900d33d97c66a6c2a9
https://github.com/PowerOnSystem/WebFramework/blob/3b885a390adc42d6ad93d7900d33d97c66a6c2a9/src/Routing/Dispatcher.php#L78-L96
240,886
PowerOnSystem/WebFramework
src/Routing/Dispatcher.php
Dispatcher.loadController
private function loadController() { $controller_name = Inflector::classify($this->controller) . 'Controller'; $controller_class = $this->controller === 'system' ? 'PowerOn\\Controller\\CoreController' : 'App\\Controller\\' . $controller_name; if ( !class_exists($controller_class) ) { return FALSE; } return new $controller_class(); }
php
private function loadController() { $controller_name = Inflector::classify($this->controller) . 'Controller'; $controller_class = $this->controller === 'system' ? 'PowerOn\\Controller\\CoreController' : 'App\\Controller\\' . $controller_name; if ( !class_exists($controller_class) ) { return FALSE; } return new $controller_class(); }
[ "private", "function", "loadController", "(", ")", "{", "$", "controller_name", "=", "Inflector", "::", "classify", "(", "$", "this", "->", "controller", ")", ".", "'Controller'", ";", "$", "controller_class", "=", "$", "this", "->", "controller", "===", "'system'", "?", "'PowerOn\\\\Controller\\\\CoreController'", ":", "'App\\\\Controller\\\\'", ".", "$", "controller_name", ";", "if", "(", "!", "class_exists", "(", "$", "controller_class", ")", ")", "{", "return", "FALSE", ";", "}", "return", "new", "$", "controller_class", "(", ")", ";", "}" ]
Verifica la existencia del controlador solicitado y lo devuelve @return \PowerOn\Controller\Controller Devuelve una instancia del controlador solicitado, devuelve FALSE si no existe
[ "Verifica", "la", "existencia", "del", "controlador", "solicitado", "y", "lo", "devuelve" ]
3b885a390adc42d6ad93d7900d33d97c66a6c2a9
https://github.com/PowerOnSystem/WebFramework/blob/3b885a390adc42d6ad93d7900d33d97c66a6c2a9/src/Routing/Dispatcher.php#L102-L111
240,887
emaphp/zenith-soap
src/Zenith/SOAP/Request.php
Request.getParameter
public function getParameter($as = self::AS_STRING) { if ($as == self::AS_SIMPLEXML) { //convert to SimpleXMLElement $success = simplexml_load_string($this->parameter); if ($success === false) { $error = libxml_get_last_error(); throw new \RuntimeException("XML Syntax error: " . $error->message); } return $success; } elseif ($as == self::AS_DOM) { //convert to DOMDocument $dom = new \DOMDocument(); if (!$dom->loadXML($this->parameter)) { $error = libxml_get_last_error(); throw new \RuntimeException("XML Syntax error: " . $error->message); } return $dom; } return $this->parameter; }
php
public function getParameter($as = self::AS_STRING) { if ($as == self::AS_SIMPLEXML) { //convert to SimpleXMLElement $success = simplexml_load_string($this->parameter); if ($success === false) { $error = libxml_get_last_error(); throw new \RuntimeException("XML Syntax error: " . $error->message); } return $success; } elseif ($as == self::AS_DOM) { //convert to DOMDocument $dom = new \DOMDocument(); if (!$dom->loadXML($this->parameter)) { $error = libxml_get_last_error(); throw new \RuntimeException("XML Syntax error: " . $error->message); } return $dom; } return $this->parameter; }
[ "public", "function", "getParameter", "(", "$", "as", "=", "self", "::", "AS_STRING", ")", "{", "if", "(", "$", "as", "==", "self", "::", "AS_SIMPLEXML", ")", "{", "//convert to SimpleXMLElement", "$", "success", "=", "simplexml_load_string", "(", "$", "this", "->", "parameter", ")", ";", "if", "(", "$", "success", "===", "false", ")", "{", "$", "error", "=", "libxml_get_last_error", "(", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "\"XML Syntax error: \"", ".", "$", "error", "->", "message", ")", ";", "}", "return", "$", "success", ";", "}", "elseif", "(", "$", "as", "==", "self", "::", "AS_DOM", ")", "{", "//convert to DOMDocument", "$", "dom", "=", "new", "\\", "DOMDocument", "(", ")", ";", "if", "(", "!", "$", "dom", "->", "loadXML", "(", "$", "this", "->", "parameter", ")", ")", "{", "$", "error", "=", "libxml_get_last_error", "(", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "\"XML Syntax error: \"", ".", "$", "error", "->", "message", ")", ";", "}", "return", "$", "dom", ";", "}", "return", "$", "this", "->", "parameter", ";", "}" ]
Obtains parameter in the specified format @param int $as @return SimpleXMLElement|\DOMDocument|string
[ "Obtains", "parameter", "in", "the", "specified", "format" ]
06622c2fcf0566e3f5c75cb5bc086e06823a5db5
https://github.com/emaphp/zenith-soap/blob/06622c2fcf0566e3f5c75cb5bc086e06823a5db5/src/Zenith/SOAP/Request.php#L154-L179
240,888
OWeb/OWeb-Framework
OWeb/utils/js/jquery/HeaderOnReadyManager.php
HeaderOnReadyManager.makeAdd
public function makeAdd(){ if(OWEB_DEBUG > 0) $code .= $this->makeAddNormal (); else $code .= $this->makeAddNormal (); Headers::getInstance()->addHeader($code, Headers::jsCode); }
php
public function makeAdd(){ if(OWEB_DEBUG > 0) $code .= $this->makeAddNormal (); else $code .= $this->makeAddNormal (); Headers::getInstance()->addHeader($code, Headers::jsCode); }
[ "public", "function", "makeAdd", "(", ")", "{", "if", "(", "OWEB_DEBUG", ">", "0", ")", "$", "code", ".=", "$", "this", "->", "makeAddNormal", "(", ")", ";", "else", "$", "code", ".=", "$", "this", "->", "makeAddNormal", "(", ")", ";", "Headers", "::", "getInstance", "(", ")", "->", "addHeader", "(", "$", "code", ",", "Headers", "::", "jsCode", ")", ";", "}" ]
Will add the headers registered to the main Headers Manager
[ "Will", "add", "the", "headers", "registered", "to", "the", "main", "Headers", "Manager" ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/utils/js/jquery/HeaderOnReadyManager.php#L66-L73
240,889
OWeb/OWeb-Framework
OWeb/utils/js/jquery/HeaderOnReadyManager.php
HeaderOnReadyManager.makeAddDebug
public function makeAddDebug(){ $s = ""; foreach ($this->headers as $code){ $s .= '$( document ).ready(function() {'."\n"; $s .= $code; $s .= "\n});\n\n"; } return $s; }
php
public function makeAddDebug(){ $s = ""; foreach ($this->headers as $code){ $s .= '$( document ).ready(function() {'."\n"; $s .= $code; $s .= "\n});\n\n"; } return $s; }
[ "public", "function", "makeAddDebug", "(", ")", "{", "$", "s", "=", "\"\"", ";", "foreach", "(", "$", "this", "->", "headers", "as", "$", "code", ")", "{", "$", "s", ".=", "'$( document ).ready(function() {'", ".", "\"\\n\"", ";", "$", "s", ".=", "$", "code", ";", "$", "s", ".=", "\"\\n});\\n\\n\"", ";", "}", "return", "$", "s", ";", "}" ]
If debug is active we should separate each JS function to prevent one wrong code to brake all others @return string
[ "If", "debug", "is", "active", "we", "should", "separate", "each", "JS", "function", "to", "prevent", "one", "wrong", "code", "to", "brake", "all", "others" ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/utils/js/jquery/HeaderOnReadyManager.php#L81-L89
240,890
OWeb/OWeb-Framework
OWeb/utils/js/jquery/HeaderOnReadyManager.php
HeaderOnReadyManager.makeAddNormal
public function makeAddNormal(){ $s = "var oweb_ready = function (){"; foreach ($this->headers as $code) $s .= $code."\n\n"; $s .= "}\n\n"; $s .= '$( document ).ready(function() {'."\n"; $s .= "oweb_ready(); \n"; $s .= "\n});\n\n"; return $s; }
php
public function makeAddNormal(){ $s = "var oweb_ready = function (){"; foreach ($this->headers as $code) $s .= $code."\n\n"; $s .= "}\n\n"; $s .= '$( document ).ready(function() {'."\n"; $s .= "oweb_ready(); \n"; $s .= "\n});\n\n"; return $s; }
[ "public", "function", "makeAddNormal", "(", ")", "{", "$", "s", "=", "\"var oweb_ready = function (){\"", ";", "foreach", "(", "$", "this", "->", "headers", "as", "$", "code", ")", "$", "s", ".=", "$", "code", ".", "\"\\n\\n\"", ";", "$", "s", ".=", "\"}\\n\\n\"", ";", "$", "s", ".=", "'$( document ).ready(function() {'", ".", "\"\\n\"", ";", "$", "s", ".=", "\"oweb_ready(); \\n\"", ";", "$", "s", ".=", "\"\\n});\\n\\n\"", ";", "return", "$", "s", ";", "}" ]
If Debug isn't active we will put them all in 1 ready function to increase performances and hope that all JS codes are okay. @return string
[ "If", "Debug", "isn", "t", "active", "we", "will", "put", "them", "all", "in", "1", "ready", "function", "to", "increase", "performances", "and", "hope", "that", "all", "JS", "codes", "are", "okay", "." ]
fb441f51afb16860b0c946a55c36c789fbb125fa
https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/utils/js/jquery/HeaderOnReadyManager.php#L97-L108
240,891
ClassPreloader/Console
src/PreCompileCommand.php
PreCompileCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $this->validateCommand($input); $output->writeln('> Loading configuration file'); $config = $input->getOption('config'); $files = (new ConfigResolver())->getFileList($config); $output->writeLn('- Found '.count($files).' files'); $preloader = (new Factory())->create($this->getOptions($input)); $outputFile = $input->getOption('output'); $handle = $preloader->prepareOutput($outputFile, $input->getOption('strict_types')); $output->writeln('> Compiling classes'); $count = 0; $countSkipped = 0; $comments = !$input->getOption('strip_comments'); foreach ($files as $file) { $count++; try { $code = $preloader->getCode($file, $comments); $output->writeln('- Writing '.$file); fwrite($handle, $code."\n"); } catch (VisitorExceptionInterface $e) { $countSkipped++; $output->writeln('- Skipping '.$file); } } fclose($handle); $output->writeln("> Compiled loader written to $outputFile"); $output->writeln('- Files: '.($count - $countSkipped).'/'.$count.' (skipped: '.$countSkipped.')'); $output->writeln('- Filesize: '.(round(filesize($outputFile) / 1024)).' kb'); }
php
protected function execute(InputInterface $input, OutputInterface $output) { $this->validateCommand($input); $output->writeln('> Loading configuration file'); $config = $input->getOption('config'); $files = (new ConfigResolver())->getFileList($config); $output->writeLn('- Found '.count($files).' files'); $preloader = (new Factory())->create($this->getOptions($input)); $outputFile = $input->getOption('output'); $handle = $preloader->prepareOutput($outputFile, $input->getOption('strict_types')); $output->writeln('> Compiling classes'); $count = 0; $countSkipped = 0; $comments = !$input->getOption('strip_comments'); foreach ($files as $file) { $count++; try { $code = $preloader->getCode($file, $comments); $output->writeln('- Writing '.$file); fwrite($handle, $code."\n"); } catch (VisitorExceptionInterface $e) { $countSkipped++; $output->writeln('- Skipping '.$file); } } fclose($handle); $output->writeln("> Compiled loader written to $outputFile"); $output->writeln('- Files: '.($count - $countSkipped).'/'.$count.' (skipped: '.$countSkipped.')'); $output->writeln('- Filesize: '.(round(filesize($outputFile) / 1024)).' kb'); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "this", "->", "validateCommand", "(", "$", "input", ")", ";", "$", "output", "->", "writeln", "(", "'> Loading configuration file'", ")", ";", "$", "config", "=", "$", "input", "->", "getOption", "(", "'config'", ")", ";", "$", "files", "=", "(", "new", "ConfigResolver", "(", ")", ")", "->", "getFileList", "(", "$", "config", ")", ";", "$", "output", "->", "writeLn", "(", "'- Found '", ".", "count", "(", "$", "files", ")", ".", "' files'", ")", ";", "$", "preloader", "=", "(", "new", "Factory", "(", ")", ")", "->", "create", "(", "$", "this", "->", "getOptions", "(", "$", "input", ")", ")", ";", "$", "outputFile", "=", "$", "input", "->", "getOption", "(", "'output'", ")", ";", "$", "handle", "=", "$", "preloader", "->", "prepareOutput", "(", "$", "outputFile", ",", "$", "input", "->", "getOption", "(", "'strict_types'", ")", ")", ";", "$", "output", "->", "writeln", "(", "'> Compiling classes'", ")", ";", "$", "count", "=", "0", ";", "$", "countSkipped", "=", "0", ";", "$", "comments", "=", "!", "$", "input", "->", "getOption", "(", "'strip_comments'", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "count", "++", ";", "try", "{", "$", "code", "=", "$", "preloader", "->", "getCode", "(", "$", "file", ",", "$", "comments", ")", ";", "$", "output", "->", "writeln", "(", "'- Writing '", ".", "$", "file", ")", ";", "fwrite", "(", "$", "handle", ",", "$", "code", ".", "\"\\n\"", ")", ";", "}", "catch", "(", "VisitorExceptionInterface", "$", "e", ")", "{", "$", "countSkipped", "++", ";", "$", "output", "->", "writeln", "(", "'- Skipping '", ".", "$", "file", ")", ";", "}", "}", "fclose", "(", "$", "handle", ")", ";", "$", "output", "->", "writeln", "(", "\"> Compiled loader written to $outputFile\"", ")", ";", "$", "output", "->", "writeln", "(", "'- Files: '", ".", "(", "$", "count", "-", "$", "countSkipped", ")", ".", "'/'", ".", "$", "count", ".", "' (skipped: '", ".", "$", "countSkipped", ".", "')'", ")", ";", "$", "output", "->", "writeln", "(", "'- Filesize: '", ".", "(", "round", "(", "filesize", "(", "$", "outputFile", ")", "/", "1024", ")", ")", ".", "' kb'", ")", ";", "}" ]
Executes the pre-compile command. @param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output @return int|null
[ "Executes", "the", "pre", "-", "compile", "command", "." ]
95935923e704ad4d0fb375e24849538405840ea5
https://github.com/ClassPreloader/Console/blob/95935923e704ad4d0fb375e24849538405840ea5/src/PreCompileCommand.php#L64-L102
240,892
ClassPreloader/Console
src/PreCompileCommand.php
PreCompileCommand.getOptions
protected function getOptions(InputInterface $input) { return [ 'dir' => (bool) $input->getOption('fix_dir'), 'file' => (bool) $input->getOption('fix_file'), 'skip' => (bool) $input->getOption('skip_dir_file'), 'strict' => (bool) $input->getOption('strict_types'), ]; }
php
protected function getOptions(InputInterface $input) { return [ 'dir' => (bool) $input->getOption('fix_dir'), 'file' => (bool) $input->getOption('fix_file'), 'skip' => (bool) $input->getOption('skip_dir_file'), 'strict' => (bool) $input->getOption('strict_types'), ]; }
[ "protected", "function", "getOptions", "(", "InputInterface", "$", "input", ")", "{", "return", "[", "'dir'", "=>", "(", "bool", ")", "$", "input", "->", "getOption", "(", "'fix_dir'", ")", ",", "'file'", "=>", "(", "bool", ")", "$", "input", "->", "getOption", "(", "'fix_file'", ")", ",", "'skip'", "=>", "(", "bool", ")", "$", "input", "->", "getOption", "(", "'skip_dir_file'", ")", ",", "'strict'", "=>", "(", "bool", ")", "$", "input", "->", "getOption", "(", "'strict_types'", ")", ",", "]", ";", "}" ]
Get the options to pass to the factory. @param \Symfony\Component\Console\Input\InputInterface $input @return bool[]
[ "Get", "the", "options", "to", "pass", "to", "the", "factory", "." ]
95935923e704ad4d0fb375e24849538405840ea5
https://github.com/ClassPreloader/Console/blob/95935923e704ad4d0fb375e24849538405840ea5/src/PreCompileCommand.php#L131-L139
240,893
mvccore/ext-debug-tracy-auth
src/MvcCore/Ext/Debugs/Tracys/AuthPanel.php
AuthPanel.&
public function & getViewData () { if ($this->view !== NULL) return $this->view; $user = & \MvcCore\Ext\Auths\Basic::GetInstance()->GetUser(); $authenticated = $user instanceof \MvcCore\Ext\Auths\Basics\IUser; $this->view = (object) [ 'user' => $user, 'authenticated' => $authenticated, ]; return $this->view; }
php
public function & getViewData () { if ($this->view !== NULL) return $this->view; $user = & \MvcCore\Ext\Auths\Basic::GetInstance()->GetUser(); $authenticated = $user instanceof \MvcCore\Ext\Auths\Basics\IUser; $this->view = (object) [ 'user' => $user, 'authenticated' => $authenticated, ]; return $this->view; }
[ "public", "function", "&", "getViewData", "(", ")", "{", "if", "(", "$", "this", "->", "view", "!==", "NULL", ")", "return", "$", "this", "->", "view", ";", "$", "user", "=", "&", "\\", "MvcCore", "\\", "Ext", "\\", "Auths", "\\", "Basic", "::", "GetInstance", "(", ")", "->", "GetUser", "(", ")", ";", "$", "authenticated", "=", "$", "user", "instanceof", "\\", "MvcCore", "\\", "Ext", "\\", "Auths", "\\", "Basics", "\\", "IUser", ";", "$", "this", "->", "view", "=", "(", "object", ")", "[", "'user'", "=>", "$", "user", ",", "'authenticated'", "=>", "$", "authenticated", ",", "]", ";", "return", "$", "this", "->", "view", ";", "}" ]
Set up view data, if data are completed, return them directly. - complete basic \MvcCore core objects to complere other view data - complete user and authorized boolean - set result data into static field @return object
[ "Set", "up", "view", "data", "if", "data", "are", "completed", "return", "them", "directly", ".", "-", "complete", "basic", "\\", "MvcCore", "core", "objects", "to", "complere", "other", "view", "data", "-", "complete", "user", "and", "authorized", "boolean", "-", "set", "result", "data", "into", "static", "field" ]
3fc1abd6979914c062665841bb032ea57a07af30
https://github.com/mvccore/ext-debug-tracy-auth/blob/3fc1abd6979914c062665841bb032ea57a07af30/src/MvcCore/Ext/Debugs/Tracys/AuthPanel.php#L82-L91
240,894
crip-laravel/core
src/Data/Repository.php
Repository.find
public function find($find, $column = 'id', array $relations = [], array $columns = ['*']) { $this->model = $this->where($column, $find); $this->model = $this->relation->apply($this->model, $this, $relations); return $this->model->firstOrFail($columns); }
php
public function find($find, $column = 'id', array $relations = [], array $columns = ['*']) { $this->model = $this->where($column, $find); $this->model = $this->relation->apply($this->model, $this, $relations); return $this->model->firstOrFail($columns); }
[ "public", "function", "find", "(", "$", "find", ",", "$", "column", "=", "'id'", ",", "array", "$", "relations", "=", "[", "]", ",", "array", "$", "columns", "=", "[", "'*'", "]", ")", "{", "$", "this", "->", "model", "=", "$", "this", "->", "where", "(", "$", "column", ",", "$", "find", ")", ";", "$", "this", "->", "model", "=", "$", "this", "->", "relation", "->", "apply", "(", "$", "this", "->", "model", ",", "$", "this", ",", "$", "relations", ")", ";", "return", "$", "this", "->", "model", "->", "firstOrFail", "(", "$", "columns", ")", ";", "}" ]
Find single record with secure relation keys only Eager relations can be taken from request input @param $find @param string $column @param array $relations @param array $columns @return Model
[ "Find", "single", "record", "with", "secure", "relation", "keys", "only", "Eager", "relations", "can", "be", "taken", "from", "request", "input" ]
d58cef97d97fba8b01bec33801452ecbd7c992de
https://github.com/crip-laravel/core/blob/d58cef97d97fba8b01bec33801452ecbd7c992de/src/Data/Repository.php#L158-L164
240,895
crip-laravel/core
src/Data/Repository.php
Repository.findWith
public function findWith($find, array $with = [], $column = 'id', array $columns = ['*']) { return $this->whereWith($find, $column, $with)->firstOrFail($columns); }
php
public function findWith($find, array $with = [], $column = 'id', array $columns = ['*']) { return $this->whereWith($find, $column, $with)->firstOrFail($columns); }
[ "public", "function", "findWith", "(", "$", "find", ",", "array", "$", "with", "=", "[", "]", ",", "$", "column", "=", "'id'", ",", "array", "$", "columns", "=", "[", "'*'", "]", ")", "{", "return", "$", "this", "->", "whereWith", "(", "$", "find", ",", "$", "column", ",", "$", "with", ")", "->", "firstOrFail", "(", "$", "columns", ")", ";", "}" ]
Find single record with custom relation query @param $find @param array $with @param string $column @param array $columns @return Model
[ "Find", "single", "record", "with", "custom", "relation", "query" ]
d58cef97d97fba8b01bec33801452ecbd7c992de
https://github.com/crip-laravel/core/blob/d58cef97d97fba8b01bec33801452ecbd7c992de/src/Data/Repository.php#L175-L178
240,896
crip-laravel/core
src/Data/Repository.php
Repository.onlyFillable
public function onlyFillable(array $input) { $result = array_intersect_key($input, array_flip($this->modelInstance->getFillable())); foreach ($this->avoidEmptyUpdate as $avoid) { if (array_key_exists($avoid, $result) && empty($result[$avoid])) { unset($result[$avoid]); } } return $result; }
php
public function onlyFillable(array $input) { $result = array_intersect_key($input, array_flip($this->modelInstance->getFillable())); foreach ($this->avoidEmptyUpdate as $avoid) { if (array_key_exists($avoid, $result) && empty($result[$avoid])) { unset($result[$avoid]); } } return $result; }
[ "public", "function", "onlyFillable", "(", "array", "$", "input", ")", "{", "$", "result", "=", "array_intersect_key", "(", "$", "input", ",", "array_flip", "(", "$", "this", "->", "modelInstance", "->", "getFillable", "(", ")", ")", ")", ";", "foreach", "(", "$", "this", "->", "avoidEmptyUpdate", "as", "$", "avoid", ")", "{", "if", "(", "array_key_exists", "(", "$", "avoid", ",", "$", "result", ")", "&&", "empty", "(", "$", "result", "[", "$", "avoid", "]", ")", ")", "{", "unset", "(", "$", "result", "[", "$", "avoid", "]", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Filter input from un allowed fields for model @param array $input @return array
[ "Filter", "input", "from", "un", "allowed", "fields", "for", "model" ]
d58cef97d97fba8b01bec33801452ecbd7c992de
https://github.com/crip-laravel/core/blob/d58cef97d97fba8b01bec33801452ecbd7c992de/src/Data/Repository.php#L353-L364
240,897
crip-laravel/core
src/Data/Repository.php
Repository.whereWith
protected function whereWith($find, $column, $with, $where_role = '=') { $this->where($column, $where_role, $find); $this->with($with); return $this->model; }
php
protected function whereWith($find, $column, $with, $where_role = '=') { $this->where($column, $where_role, $find); $this->with($with); return $this->model; }
[ "protected", "function", "whereWith", "(", "$", "find", ",", "$", "column", ",", "$", "with", ",", "$", "where_role", "=", "'='", ")", "{", "$", "this", "->", "where", "(", "$", "column", ",", "$", "where_role", ",", "$", "find", ")", ";", "$", "this", "->", "with", "(", "$", "with", ")", ";", "return", "$", "this", "->", "model", ";", "}" ]
Unfiltered querable with this model @param $find @param $column @param $with @param string $where_role @return Builder
[ "Unfiltered", "querable", "with", "this", "model" ]
d58cef97d97fba8b01bec33801452ecbd7c992de
https://github.com/crip-laravel/core/blob/d58cef97d97fba8b01bec33801452ecbd7c992de/src/Data/Repository.php#L403-L409
240,898
tux-rampage/rampage-php
library/rampage/core/PathManager.php
PathManager.get
public function get($type, $file = null) { if (!isset($this->paths[$type])) { $method = 'get'.Utils::camelize($type).'Dir'; if (!method_exists($this, $method)) { return null; } $this->set($type, $this->$method()); } $path = $this->paths[$type]; if ($file) { if ($path instanceof pathmanager\FallbackInterface) { $path = $path->resolve($file); } else { $path .= '/' . ltrim($file, '/'); } } return $path; }
php
public function get($type, $file = null) { if (!isset($this->paths[$type])) { $method = 'get'.Utils::camelize($type).'Dir'; if (!method_exists($this, $method)) { return null; } $this->set($type, $this->$method()); } $path = $this->paths[$type]; if ($file) { if ($path instanceof pathmanager\FallbackInterface) { $path = $path->resolve($file); } else { $path .= '/' . ltrim($file, '/'); } } return $path; }
[ "public", "function", "get", "(", "$", "type", ",", "$", "file", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "paths", "[", "$", "type", "]", ")", ")", "{", "$", "method", "=", "'get'", ".", "Utils", "::", "camelize", "(", "$", "type", ")", ".", "'Dir'", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "method", ")", ")", "{", "return", "null", ";", "}", "$", "this", "->", "set", "(", "$", "type", ",", "$", "this", "->", "$", "method", "(", ")", ")", ";", "}", "$", "path", "=", "$", "this", "->", "paths", "[", "$", "type", "]", ";", "if", "(", "$", "file", ")", "{", "if", "(", "$", "path", "instanceof", "pathmanager", "\\", "FallbackInterface", ")", "{", "$", "path", "=", "$", "path", "->", "resolve", "(", "$", "file", ")", ";", "}", "else", "{", "$", "path", ".=", "'/'", ".", "ltrim", "(", "$", "file", ",", "'/'", ")", ";", "}", "}", "return", "$", "path", ";", "}" ]
Returns a path @param string $type @param string $file
[ "Returns", "a", "path" ]
1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf
https://github.com/tux-rampage/rampage-php/blob/1c679b04a6d477e2f8fdb86135e1d9f0c128b1cf/library/rampage/core/PathManager.php#L135-L157
240,899
o3co/query.extension.cql
Lexer.php
Lexer.isNextToken
public function isNextToken($token, $ignoreSpaces = true) { if($this->pos >= $this->len) { return Tokens::T_END == $token; } switch($token) { case Tokens::T_END: return false; case Tokens::T_OPERATOR: return $this->isNextToken(Tokens::T_LOGICAL_OP, $ignoreSpaces) || $this->isNextToken(Tokens::T_COMPARISON_OP, $ignoreSpaces) ; case Tokens::T_QUOTE: return $this->isNextToken(Tokens::T_SINGLE_QUOTE, $ignoreSpaces) || $this->isNextToken(Tokens::T_DOUBLE_QUOTE, $ignoreSpaces) ; case Tokens::T_LOGICAL_OP: return $this->isNextToken(Tokens::T_AND, $ignoreSpaces) || $this->isNextToken(Tokens::T_OR, $ignoreSpaces) || $this->isNextToken(Tokens::T_NOT, $ignoreSpaces) ; break; case Tokens::T_COMPARISON_OP: return $this->isNextToken(Tokens::T_EQ, $ignoreSpaces) || $this->isNextToken(Tokens::T_NE, $ignoreSpaces) || $this->isNextToken(Tokens::T_GT, $ignoreSpaces) || $this->isNextToken(Tokens::T_GE, $ignoreSpaces) || $this->isNextToken(Tokens::T_LT, $ignoreSpaces) || $this->isNextToken(Tokens::T_LE, $ignoreSpaces) || $this->isNextToken(Tokens::T_IS_NULL, $ignoreSpaces) || $this->isNextToken(Tokens::T_IS_ANY, $ignoreSpaces) || $this->isNextToken(Tokens::T_IN, $ignoreSpaces) || $this->isNextToken(Tokens::T_RANGE, $ignoreSpaces) || $this->isNextToken(Tokens::T_MATCH, $ignoreSpaces) ; break; case Tokens::T_IDENTIFIER: $pos = $this->pos; if($ignoreSpaces) { $pos = $this->getPosAfterSpaces($pos); } // if alphabet or '_' is following, then identifier. return ctype_alpha($this->value[$pos]) || ('_' == $this->value[$pos]); default: $literal = $this->literals->getLiteralForToken($token); if($this->literals->isSpace($literal)) { $ignoreSpaces = false; } return $this->isNextLiteral($literal, $ignoreSpaces); break; } }
php
public function isNextToken($token, $ignoreSpaces = true) { if($this->pos >= $this->len) { return Tokens::T_END == $token; } switch($token) { case Tokens::T_END: return false; case Tokens::T_OPERATOR: return $this->isNextToken(Tokens::T_LOGICAL_OP, $ignoreSpaces) || $this->isNextToken(Tokens::T_COMPARISON_OP, $ignoreSpaces) ; case Tokens::T_QUOTE: return $this->isNextToken(Tokens::T_SINGLE_QUOTE, $ignoreSpaces) || $this->isNextToken(Tokens::T_DOUBLE_QUOTE, $ignoreSpaces) ; case Tokens::T_LOGICAL_OP: return $this->isNextToken(Tokens::T_AND, $ignoreSpaces) || $this->isNextToken(Tokens::T_OR, $ignoreSpaces) || $this->isNextToken(Tokens::T_NOT, $ignoreSpaces) ; break; case Tokens::T_COMPARISON_OP: return $this->isNextToken(Tokens::T_EQ, $ignoreSpaces) || $this->isNextToken(Tokens::T_NE, $ignoreSpaces) || $this->isNextToken(Tokens::T_GT, $ignoreSpaces) || $this->isNextToken(Tokens::T_GE, $ignoreSpaces) || $this->isNextToken(Tokens::T_LT, $ignoreSpaces) || $this->isNextToken(Tokens::T_LE, $ignoreSpaces) || $this->isNextToken(Tokens::T_IS_NULL, $ignoreSpaces) || $this->isNextToken(Tokens::T_IS_ANY, $ignoreSpaces) || $this->isNextToken(Tokens::T_IN, $ignoreSpaces) || $this->isNextToken(Tokens::T_RANGE, $ignoreSpaces) || $this->isNextToken(Tokens::T_MATCH, $ignoreSpaces) ; break; case Tokens::T_IDENTIFIER: $pos = $this->pos; if($ignoreSpaces) { $pos = $this->getPosAfterSpaces($pos); } // if alphabet or '_' is following, then identifier. return ctype_alpha($this->value[$pos]) || ('_' == $this->value[$pos]); default: $literal = $this->literals->getLiteralForToken($token); if($this->literals->isSpace($literal)) { $ignoreSpaces = false; } return $this->isNextLiteral($literal, $ignoreSpaces); break; } }
[ "public", "function", "isNextToken", "(", "$", "token", ",", "$", "ignoreSpaces", "=", "true", ")", "{", "if", "(", "$", "this", "->", "pos", ">=", "$", "this", "->", "len", ")", "{", "return", "Tokens", "::", "T_END", "==", "$", "token", ";", "}", "switch", "(", "$", "token", ")", "{", "case", "Tokens", "::", "T_END", ":", "return", "false", ";", "case", "Tokens", "::", "T_OPERATOR", ":", "return", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_LOGICAL_OP", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_COMPARISON_OP", ",", "$", "ignoreSpaces", ")", ";", "case", "Tokens", "::", "T_QUOTE", ":", "return", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_SINGLE_QUOTE", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_DOUBLE_QUOTE", ",", "$", "ignoreSpaces", ")", ";", "case", "Tokens", "::", "T_LOGICAL_OP", ":", "return", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_AND", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_OR", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_NOT", ",", "$", "ignoreSpaces", ")", ";", "break", ";", "case", "Tokens", "::", "T_COMPARISON_OP", ":", "return", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_EQ", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_NE", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_GT", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_GE", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_LT", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_LE", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_IS_NULL", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_IS_ANY", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_IN", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_RANGE", ",", "$", "ignoreSpaces", ")", "||", "$", "this", "->", "isNextToken", "(", "Tokens", "::", "T_MATCH", ",", "$", "ignoreSpaces", ")", ";", "break", ";", "case", "Tokens", "::", "T_IDENTIFIER", ":", "$", "pos", "=", "$", "this", "->", "pos", ";", "if", "(", "$", "ignoreSpaces", ")", "{", "$", "pos", "=", "$", "this", "->", "getPosAfterSpaces", "(", "$", "pos", ")", ";", "}", "// if alphabet or '_' is following, then identifier.", "return", "ctype_alpha", "(", "$", "this", "->", "value", "[", "$", "pos", "]", ")", "||", "(", "'_'", "==", "$", "this", "->", "value", "[", "$", "pos", "]", ")", ";", "default", ":", "$", "literal", "=", "$", "this", "->", "literals", "->", "getLiteralForToken", "(", "$", "token", ")", ";", "if", "(", "$", "this", "->", "literals", "->", "isSpace", "(", "$", "literal", ")", ")", "{", "$", "ignoreSpaces", "=", "false", ";", "}", "return", "$", "this", "->", "isNextLiteral", "(", "$", "literal", ",", "$", "ignoreSpaces", ")", ";", "break", ";", "}", "}" ]
isNextToken Check the next token or literal @param integer $token @access public @return void
[ "isNextToken", "Check", "the", "next", "token", "or", "literal" ]
7fee694279db31364975d9e7f184a90f9e52f1e1
https://github.com/o3co/query.extension.cql/blob/7fee694279db31364975d9e7f184a90f9e52f1e1/Lexer.php#L145-L201