repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.getUserCustomerRelationsJoinCustomer
public function getUserCustomerRelationsJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = UserCustomerRelationQuery::create(null, $criteria); $query->joinWith('Customer', $join_behavior); return $this->getUserCustomerRelations($query, $con); }
php
public function getUserCustomerRelationsJoinCustomer($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN) { $query = UserCustomerRelationQuery::create(null, $criteria); $query->joinWith('Customer', $join_behavior); return $this->getUserCustomerRelations($query, $con); }
[ "public", "function", "getUserCustomerRelationsJoinCustomer", "(", "$", "criteria", "=", "null", ",", "$", "con", "=", "null", ",", "$", "join_behavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "UserCustomerRelationQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", ";", "$", "query", "->", "joinWith", "(", "'Customer'", ",", "$", "join_behavior", ")", ";", "return", "$", "this", "->", "getUserCustomerRelations", "(", "$", "query", ",", "$", "con", ")", ";", "}" ]
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this User is new, it will return an empty collection; or if this User has previously been saved, it will retrieve related UserCustomerRelations 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 User. @param Criteria $criteria optional Criteria object to narrow the query @param PropelPDO $con optional connection object @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return PropelObjectCollection|UserCustomerRelation[] List of UserCustomerRelation objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "User", "is", "new", "it", "will", "return", "an", "empty", "collection", ";", "or", "if", "this", "User", "has", "previously", "been", "saved", "it", "will", "retrieve", "related", "UserCustomerRelations", "from", "storage", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L1849-L1855
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.getUserRoles
public function getUserRoles($criteria = null, PropelPDO $con = null) { $partial = $this->collUserRolesPartial && !$this->isNew(); if (null === $this->collUserRoles || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collUserRoles) { // return empty collection $this->initUserRoles(); } else { $collUserRoles = UserRoleQuery::create(null, $criteria) ->filterByUser($this) ->find($con); if (null !== $criteria) { if (false !== $this->collUserRolesPartial && count($collUserRoles)) { $this->initUserRoles(false); foreach ($collUserRoles as $obj) { if (false == $this->collUserRoles->contains($obj)) { $this->collUserRoles->append($obj); } } $this->collUserRolesPartial = true; } $collUserRoles->getInternalIterator()->rewind(); return $collUserRoles; } if ($partial && $this->collUserRoles) { foreach ($this->collUserRoles as $obj) { if ($obj->isNew()) { $collUserRoles[] = $obj; } } } $this->collUserRoles = $collUserRoles; $this->collUserRolesPartial = false; } } return $this->collUserRoles; }
php
public function getUserRoles($criteria = null, PropelPDO $con = null) { $partial = $this->collUserRolesPartial && !$this->isNew(); if (null === $this->collUserRoles || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collUserRoles) { // return empty collection $this->initUserRoles(); } else { $collUserRoles = UserRoleQuery::create(null, $criteria) ->filterByUser($this) ->find($con); if (null !== $criteria) { if (false !== $this->collUserRolesPartial && count($collUserRoles)) { $this->initUserRoles(false); foreach ($collUserRoles as $obj) { if (false == $this->collUserRoles->contains($obj)) { $this->collUserRoles->append($obj); } } $this->collUserRolesPartial = true; } $collUserRoles->getInternalIterator()->rewind(); return $collUserRoles; } if ($partial && $this->collUserRoles) { foreach ($this->collUserRoles as $obj) { if ($obj->isNew()) { $collUserRoles[] = $obj; } } } $this->collUserRoles = $collUserRoles; $this->collUserRolesPartial = false; } } return $this->collUserRoles; }
[ "public", "function", "getUserRoles", "(", "$", "criteria", "=", "null", ",", "PropelPDO", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collUserRolesPartial", "&&", "!", "$", "this", "->", "isNew", "(", ")", ";", "if", "(", "null", "===", "$", "this", "->", "collUserRoles", "||", "null", "!==", "$", "criteria", "||", "$", "partial", ")", "{", "if", "(", "$", "this", "->", "isNew", "(", ")", "&&", "null", "===", "$", "this", "->", "collUserRoles", ")", "{", "// return empty collection", "$", "this", "->", "initUserRoles", "(", ")", ";", "}", "else", "{", "$", "collUserRoles", "=", "UserRoleQuery", "::", "create", "(", "null", ",", "$", "criteria", ")", "->", "filterByUser", "(", "$", "this", ")", "->", "find", "(", "$", "con", ")", ";", "if", "(", "null", "!==", "$", "criteria", ")", "{", "if", "(", "false", "!==", "$", "this", "->", "collUserRolesPartial", "&&", "count", "(", "$", "collUserRoles", ")", ")", "{", "$", "this", "->", "initUserRoles", "(", "false", ")", ";", "foreach", "(", "$", "collUserRoles", "as", "$", "obj", ")", "{", "if", "(", "false", "==", "$", "this", "->", "collUserRoles", "->", "contains", "(", "$", "obj", ")", ")", "{", "$", "this", "->", "collUserRoles", "->", "append", "(", "$", "obj", ")", ";", "}", "}", "$", "this", "->", "collUserRolesPartial", "=", "true", ";", "}", "$", "collUserRoles", "->", "getInternalIterator", "(", ")", "->", "rewind", "(", ")", ";", "return", "$", "collUserRoles", ";", "}", "if", "(", "$", "partial", "&&", "$", "this", "->", "collUserRoles", ")", "{", "foreach", "(", "$", "this", "->", "collUserRoles", "as", "$", "obj", ")", "{", "if", "(", "$", "obj", "->", "isNew", "(", ")", ")", "{", "$", "collUserRoles", "[", "]", "=", "$", "obj", ";", "}", "}", "}", "$", "this", "->", "collUserRoles", "=", "$", "collUserRoles", ";", "$", "this", "->", "collUserRolesPartial", "=", "false", ";", "}", "}", "return", "$", "this", "->", "collUserRoles", ";", "}" ]
Gets an array of UserRole 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 User 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 PropelPDO $con optional connection object @return PropelObjectCollection|UserRole[] List of UserRole objects @throws PropelException
[ "Gets", "an", "array", "of", "UserRole", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L1919-L1962
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.clear
public function clear() { $this->id = null; $this->username = null; $this->password = null; $this->salt = null; $this->firstname = null; $this->lastname = null; $this->email = null; $this->phone = null; $this->memo = null; $this->activated = null; $this->last_login = null; $this->notification_change = null; $this->notification_error = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
php
public function clear() { $this->id = null; $this->username = null; $this->password = null; $this->salt = null; $this->firstname = null; $this->lastname = null; $this->email = null; $this->phone = null; $this->memo = null; $this->activated = null; $this->last_login = null; $this->notification_change = null; $this->notification_error = null; $this->alreadyInSave = false; $this->alreadyInValidation = false; $this->alreadyInClearAllReferencesDeep = false; $this->clearAllReferences(); $this->applyDefaultValues(); $this->resetModified(); $this->setNew(true); $this->setDeleted(false); }
[ "public", "function", "clear", "(", ")", "{", "$", "this", "->", "id", "=", "null", ";", "$", "this", "->", "username", "=", "null", ";", "$", "this", "->", "password", "=", "null", ";", "$", "this", "->", "salt", "=", "null", ";", "$", "this", "->", "firstname", "=", "null", ";", "$", "this", "->", "lastname", "=", "null", ";", "$", "this", "->", "email", "=", "null", ";", "$", "this", "->", "phone", "=", "null", ";", "$", "this", "->", "memo", "=", "null", ";", "$", "this", "->", "activated", "=", "null", ";", "$", "this", "->", "last_login", "=", "null", ";", "$", "this", "->", "notification_change", "=", "null", ";", "$", "this", "->", "notification_error", "=", "null", ";", "$", "this", "->", "alreadyInSave", "=", "false", ";", "$", "this", "->", "alreadyInValidation", "=", "false", ";", "$", "this", "->", "alreadyInClearAllReferencesDeep", "=", "false", ";", "$", "this", "->", "clearAllReferences", "(", ")", ";", "$", "this", "->", "applyDefaultValues", "(", ")", ";", "$", "this", "->", "resetModified", "(", ")", ";", "$", "this", "->", "setNew", "(", "true", ")", ";", "$", "this", "->", "setDeleted", "(", "false", ")", ";", "}" ]
Clears the current object and sets all attributes to their default values
[ "Clears", "the", "current", "object", "and", "sets", "all", "attributes", "to", "their", "default", "values" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L2113-L2136
slashworks/control-bundle
src/Slashworks/BackendBundle/Model/om/BaseUser.php
BaseUser.clearAllReferences
public function clearAllReferences($deep = false) { if ($deep && !$this->alreadyInClearAllReferencesDeep) { $this->alreadyInClearAllReferencesDeep = true; if ($this->collUserCustomerRelations) { foreach ($this->collUserCustomerRelations as $o) { $o->clearAllReferences($deep); } } if ($this->collUserRoles) { foreach ($this->collUserRoles as $o) { $o->clearAllReferences($deep); } } $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) if ($this->collUserCustomerRelations instanceof PropelCollection) { $this->collUserCustomerRelations->clearIterator(); } $this->collUserCustomerRelations = null; if ($this->collUserRoles instanceof PropelCollection) { $this->collUserRoles->clearIterator(); } $this->collUserRoles = null; }
php
public function clearAllReferences($deep = false) { if ($deep && !$this->alreadyInClearAllReferencesDeep) { $this->alreadyInClearAllReferencesDeep = true; if ($this->collUserCustomerRelations) { foreach ($this->collUserCustomerRelations as $o) { $o->clearAllReferences($deep); } } if ($this->collUserRoles) { foreach ($this->collUserRoles as $o) { $o->clearAllReferences($deep); } } $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) if ($this->collUserCustomerRelations instanceof PropelCollection) { $this->collUserCustomerRelations->clearIterator(); } $this->collUserCustomerRelations = null; if ($this->collUserRoles instanceof PropelCollection) { $this->collUserRoles->clearIterator(); } $this->collUserRoles = null; }
[ "public", "function", "clearAllReferences", "(", "$", "deep", "=", "false", ")", "{", "if", "(", "$", "deep", "&&", "!", "$", "this", "->", "alreadyInClearAllReferencesDeep", ")", "{", "$", "this", "->", "alreadyInClearAllReferencesDeep", "=", "true", ";", "if", "(", "$", "this", "->", "collUserCustomerRelations", ")", "{", "foreach", "(", "$", "this", "->", "collUserCustomerRelations", "as", "$", "o", ")", "{", "$", "o", "->", "clearAllReferences", "(", "$", "deep", ")", ";", "}", "}", "if", "(", "$", "this", "->", "collUserRoles", ")", "{", "foreach", "(", "$", "this", "->", "collUserRoles", "as", "$", "o", ")", "{", "$", "o", "->", "clearAllReferences", "(", "$", "deep", ")", ";", "}", "}", "$", "this", "->", "alreadyInClearAllReferencesDeep", "=", "false", ";", "}", "// if ($deep)", "if", "(", "$", "this", "->", "collUserCustomerRelations", "instanceof", "PropelCollection", ")", "{", "$", "this", "->", "collUserCustomerRelations", "->", "clearIterator", "(", ")", ";", "}", "$", "this", "->", "collUserCustomerRelations", "=", "null", ";", "if", "(", "$", "this", "->", "collUserRoles", "instanceof", "PropelCollection", ")", "{", "$", "this", "->", "collUserRoles", "->", "clearIterator", "(", ")", ";", "}", "$", "this", "->", "collUserRoles", "=", "null", ";", "}" ]
Resets all references to other model objects or collections of model objects. This method is a user-space workaround for PHP's inability to garbage collect objects with circular references (even in PHP 5.3). This is currently necessary when using Propel in certain daemon or large-volume/high-memory operations. @param boolean $deep Whether to also clear the references on all referrer objects.
[ "Resets", "all", "references", "to", "other", "model", "objects", "or", "collections", "of", "model", "objects", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/BackendBundle/Model/om/BaseUser.php#L2147-L2173
ClanCats/Core
src/classes/CCProfiler.php
CCProfiler._init
public static function _init() { // is the profiler enabled? if ( !static::$_enabled = ClanCats::$config->get( 'profiler.enabled' ) ) { return; } // enable profiling only in development mode if ( ClanCats::in_development() ) { // add a hook to the resposne so that we can // append a table with the profiler data to the body CCEvent::mind( 'response.output', function( $output ) { if ( strpos( $output, '</body>' ) === false ) { return $output; } $table = \UI\Table::create( array( 'style' => array( 'width' => '100%', ), 'cellpadding' => '5', 'class' => 'table debug-table debug-table-profiler', )); $table->header( array( '#', 'message', 'memory', 'time' ) ); foreach( \CCProfiler::data() as $key => $item ) { $table->row( array( $key+1, $item[0], $item[1], $item[2] ) ); } // add the table before the body end return str_replace( '</body>', $table."\n</body>", $output ); }); // also add an error inspector hook so that we can access the // profiler data in the error handler CCError_Inspector::info_callback( 'Profiler', function() { $table = array(); foreach( \CCProfiler::data() as $key => $check ) { $table[('#'.($key+1).': '.$check[2] )] = $check[0]; } return $table; }); } }
php
public static function _init() { // is the profiler enabled? if ( !static::$_enabled = ClanCats::$config->get( 'profiler.enabled' ) ) { return; } // enable profiling only in development mode if ( ClanCats::in_development() ) { // add a hook to the resposne so that we can // append a table with the profiler data to the body CCEvent::mind( 'response.output', function( $output ) { if ( strpos( $output, '</body>' ) === false ) { return $output; } $table = \UI\Table::create( array( 'style' => array( 'width' => '100%', ), 'cellpadding' => '5', 'class' => 'table debug-table debug-table-profiler', )); $table->header( array( '#', 'message', 'memory', 'time' ) ); foreach( \CCProfiler::data() as $key => $item ) { $table->row( array( $key+1, $item[0], $item[1], $item[2] ) ); } // add the table before the body end return str_replace( '</body>', $table."\n</body>", $output ); }); // also add an error inspector hook so that we can access the // profiler data in the error handler CCError_Inspector::info_callback( 'Profiler', function() { $table = array(); foreach( \CCProfiler::data() as $key => $check ) { $table[('#'.($key+1).': '.$check[2] )] = $check[0]; } return $table; }); } }
[ "public", "static", "function", "_init", "(", ")", "{", "// is the profiler enabled?", "if", "(", "!", "static", "::", "$", "_enabled", "=", "ClanCats", "::", "$", "config", "->", "get", "(", "'profiler.enabled'", ")", ")", "{", "return", ";", "}", "// enable profiling only in development mode", "if", "(", "ClanCats", "::", "in_development", "(", ")", ")", "{", "// add a hook to the resposne so that we can ", "// append a table with the profiler data to the body", "CCEvent", "::", "mind", "(", "'response.output'", ",", "function", "(", "$", "output", ")", "{", "if", "(", "strpos", "(", "$", "output", ",", "'</body>'", ")", "===", "false", ")", "{", "return", "$", "output", ";", "}", "$", "table", "=", "\\", "UI", "\\", "Table", "::", "create", "(", "array", "(", "'style'", "=>", "array", "(", "'width'", "=>", "'100%'", ",", ")", ",", "'cellpadding'", "=>", "'5'", ",", "'class'", "=>", "'table debug-table debug-table-profiler'", ",", ")", ")", ";", "$", "table", "->", "header", "(", "array", "(", "'#'", ",", "'message'", ",", "'memory'", ",", "'time'", ")", ")", ";", "foreach", "(", "\\", "CCProfiler", "::", "data", "(", ")", "as", "$", "key", "=>", "$", "item", ")", "{", "$", "table", "->", "row", "(", "array", "(", "$", "key", "+", "1", ",", "$", "item", "[", "0", "]", ",", "$", "item", "[", "1", "]", ",", "$", "item", "[", "2", "]", ")", ")", ";", "}", "// add the table before the body end", "return", "str_replace", "(", "'</body>'", ",", "$", "table", ".", "\"\\n</body>\"", ",", "$", "output", ")", ";", "}", ")", ";", "// also add an error inspector hook so that we can access the ", "// profiler data in the error handler", "CCError_Inspector", "::", "info_callback", "(", "'Profiler'", ",", "function", "(", ")", "{", "$", "table", "=", "array", "(", ")", ";", "foreach", "(", "\\", "CCProfiler", "::", "data", "(", ")", "as", "$", "key", "=>", "$", "check", ")", "{", "$", "table", "[", "(", "'#'", ".", "(", "$", "key", "+", "1", ")", ".", "': '", ".", "$", "check", "[", "2", "]", ")", "]", "=", "$", "check", "[", "0", "]", ";", "}", "return", "$", "table", ";", "}", ")", ";", "}", "}" ]
The Autoloader initialisation @return void
[ "The", "Autoloader", "initialisation" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCProfiler.php#L34-L87
ClanCats/Core
src/classes/CCProfiler.php
CCProfiler.memory
public static function memory( $format = false ) { $memory = memory_get_usage() - CCF_PROFILER_MEM; if ( $format ) { return CCStr::bytes( $memory ); } return $memory; }
php
public static function memory( $format = false ) { $memory = memory_get_usage() - CCF_PROFILER_MEM; if ( $format ) { return CCStr::bytes( $memory ); } return $memory; }
[ "public", "static", "function", "memory", "(", "$", "format", "=", "false", ")", "{", "$", "memory", "=", "memory_get_usage", "(", ")", "-", "CCF_PROFILER_MEM", ";", "if", "(", "$", "format", ")", "{", "return", "CCStr", "::", "bytes", "(", "$", "memory", ")", ";", "}", "return", "$", "memory", ";", "}" ]
returns current memory usage @param bool $format @return string
[ "returns", "current", "memory", "usage" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCProfiler.php#L135-L145
ClanCats/Core
src/classes/CCProfiler.php
CCProfiler.time
public static function time( $format = false ) { $time = microtime( true ) - CCF_PROFILER_TME; if ( $format ) { return CCStr::microtime( $time ); } return $time; }
php
public static function time( $format = false ) { $time = microtime( true ) - CCF_PROFILER_TME; if ( $format ) { return CCStr::microtime( $time ); } return $time; }
[ "public", "static", "function", "time", "(", "$", "format", "=", "false", ")", "{", "$", "time", "=", "microtime", "(", "true", ")", "-", "CCF_PROFILER_TME", ";", "if", "(", "$", "format", ")", "{", "return", "CCStr", "::", "microtime", "(", "$", "time", ")", ";", "}", "return", "$", "time", ";", "}" ]
returns current execution time @param bool $format @return string
[ "returns", "current", "execution", "time" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCProfiler.php#L153-L163
PortaText/php-sdk
src/PortaText/Command/Api/Jobs.php
Jobs.getEndpoint
protected function getEndpoint($method) { $endpoint = "jobs"; $jobId = $this->getArgument("id"); if (!is_null($jobId)) { $endpoint .= "/$jobId"; $this->delArgument("id"); } $page = $this->getArgument("page"); $this->delArgument("page"); if (!is_null($page)) { $endpoint .= "?page=$page"; } if (!is_null($this->getArgument("accept_any_file"))) { $endpoint .= "/result"; } return $endpoint; }
php
protected function getEndpoint($method) { $endpoint = "jobs"; $jobId = $this->getArgument("id"); if (!is_null($jobId)) { $endpoint .= "/$jobId"; $this->delArgument("id"); } $page = $this->getArgument("page"); $this->delArgument("page"); if (!is_null($page)) { $endpoint .= "?page=$page"; } if (!is_null($this->getArgument("accept_any_file"))) { $endpoint .= "/result"; } return $endpoint; }
[ "protected", "function", "getEndpoint", "(", "$", "method", ")", "{", "$", "endpoint", "=", "\"jobs\"", ";", "$", "jobId", "=", "$", "this", "->", "getArgument", "(", "\"id\"", ")", ";", "if", "(", "!", "is_null", "(", "$", "jobId", ")", ")", "{", "$", "endpoint", ".=", "\"/$jobId\"", ";", "$", "this", "->", "delArgument", "(", "\"id\"", ")", ";", "}", "$", "page", "=", "$", "this", "->", "getArgument", "(", "\"page\"", ")", ";", "$", "this", "->", "delArgument", "(", "\"page\"", ")", ";", "if", "(", "!", "is_null", "(", "$", "page", ")", ")", "{", "$", "endpoint", ".=", "\"?page=$page\"", ";", "}", "if", "(", "!", "is_null", "(", "$", "this", "->", "getArgument", "(", "\"accept_any_file\"", ")", ")", ")", "{", "$", "endpoint", ".=", "\"/result\"", ";", "}", "return", "$", "endpoint", ";", "}" ]
Returns a string with the endpoint for the given command. @param string $method Method for this command. @return string
[ "Returns", "a", "string", "with", "the", "endpoint", "for", "the", "given", "command", "." ]
train
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/Jobs.php#L63-L80
miisieq/InfaktClient
src/Infakt/Mapper/VatRateMapper.php
VatRateMapper.map
public function map($data) { return (new VatRate()) ->setId((int) $data['id']) ->setRate((float) $data['rate']) ->setName($data['name']) ->setSymbol($data['symbol']); }
php
public function map($data) { return (new VatRate()) ->setId((int) $data['id']) ->setRate((float) $data['rate']) ->setName($data['name']) ->setSymbol($data['symbol']); }
[ "public", "function", "map", "(", "$", "data", ")", "{", "return", "(", "new", "VatRate", "(", ")", ")", "->", "setId", "(", "(", "int", ")", "$", "data", "[", "'id'", "]", ")", "->", "setRate", "(", "(", "float", ")", "$", "data", "[", "'rate'", "]", ")", "->", "setName", "(", "$", "data", "[", "'name'", "]", ")", "->", "setSymbol", "(", "$", "data", "[", "'symbol'", "]", ")", ";", "}" ]
{@inheritdoc} @param $data @return VatRate
[ "{", "@inheritdoc", "}" ]
train
https://github.com/miisieq/InfaktClient/blob/5f0ae58c7be32580f3c92c2a7e7a7808d83d4e81/src/Infakt/Mapper/VatRateMapper.php#L18-L25
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Loader/AbstractFileLoader.php
AbstractFileLoader.doReplace
public function doReplace($input, $data, $global) { preg_match_all( '/%(?P<reference>[^%]+)%/', $input, $matches ); if (false === empty($matches['reference'])) { foreach ($matches['reference'] as $reference) { try { $ref = $this->resolveReference($reference, $data); } catch (InvalidReferenceException $exception) { if (empty($global)) { throw $exception; } $ref = $this->resolveReference($reference, $global); } if ((false === is_null($ref)) && (false === is_scalar($ref)) && (false == preg_match('/^%(?:[^%]+)%$/', $input))) { throw InvalidReferenceException::format( 'The non-scalar reference "%s" cannot be used inline.', "%$reference%" ); } if ("%$reference%" === $input) { $input = $ref; } else { $input = str_replace("%$reference%", $ref, $input); } } } return $input; }
php
public function doReplace($input, $data, $global) { preg_match_all( '/%(?P<reference>[^%]+)%/', $input, $matches ); if (false === empty($matches['reference'])) { foreach ($matches['reference'] as $reference) { try { $ref = $this->resolveReference($reference, $data); } catch (InvalidReferenceException $exception) { if (empty($global)) { throw $exception; } $ref = $this->resolveReference($reference, $global); } if ((false === is_null($ref)) && (false === is_scalar($ref)) && (false == preg_match('/^%(?:[^%]+)%$/', $input))) { throw InvalidReferenceException::format( 'The non-scalar reference "%s" cannot be used inline.', "%$reference%" ); } if ("%$reference%" === $input) { $input = $ref; } else { $input = str_replace("%$reference%", $ref, $input); } } } return $input; }
[ "public", "function", "doReplace", "(", "$", "input", ",", "$", "data", ",", "$", "global", ")", "{", "preg_match_all", "(", "'/%(?P<reference>[^%]+)%/'", ",", "$", "input", ",", "$", "matches", ")", ";", "if", "(", "false", "===", "empty", "(", "$", "matches", "[", "'reference'", "]", ")", ")", "{", "foreach", "(", "$", "matches", "[", "'reference'", "]", "as", "$", "reference", ")", "{", "try", "{", "$", "ref", "=", "$", "this", "->", "resolveReference", "(", "$", "reference", ",", "$", "data", ")", ";", "}", "catch", "(", "InvalidReferenceException", "$", "exception", ")", "{", "if", "(", "empty", "(", "$", "global", ")", ")", "{", "throw", "$", "exception", ";", "}", "$", "ref", "=", "$", "this", "->", "resolveReference", "(", "$", "reference", ",", "$", "global", ")", ";", "}", "if", "(", "(", "false", "===", "is_null", "(", "$", "ref", ")", ")", "&&", "(", "false", "===", "is_scalar", "(", "$", "ref", ")", ")", "&&", "(", "false", "==", "preg_match", "(", "'/^%(?:[^%]+)%$/'", ",", "$", "input", ")", ")", ")", "{", "throw", "InvalidReferenceException", "::", "format", "(", "'The non-scalar reference \"%s\" cannot be used inline.'", ",", "\"%$reference%\"", ")", ";", "}", "if", "(", "\"%$reference%\"", "===", "$", "input", ")", "{", "$", "input", "=", "$", "ref", ";", "}", "else", "{", "$", "input", "=", "str_replace", "(", "\"%$reference%\"", ",", "$", "ref", ",", "$", "input", ")", ";", "}", "}", "}", "return", "$", "input", ";", "}" ]
Replace the placeholder value(s). @param mixed $input The input. @param array $data The data the input is from. @param array $global The global values. @return mixed The result. @throws InvalidReferenceException If an invalid reference is used.
[ "Replace", "the", "placeholder", "value", "(", "s", ")", "." ]
train
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Loader/AbstractFileLoader.php#L48-L86
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Loader/AbstractFileLoader.php
AbstractFileLoader.load
public function load($resource, $type = null) { $file = $this->locator->locate($resource, $type); if ($this->collector) { $this->collector->addResource(new FileResource($file)); } $data = $this->doLoad($file); return $this->process($data, $resource); }
php
public function load($resource, $type = null) { $file = $this->locator->locate($resource, $type); if ($this->collector) { $this->collector->addResource(new FileResource($file)); } $data = $this->doLoad($file); return $this->process($data, $resource); }
[ "public", "function", "load", "(", "$", "resource", ",", "$", "type", "=", "null", ")", "{", "$", "file", "=", "$", "this", "->", "locator", "->", "locate", "(", "$", "resource", ",", "$", "type", ")", ";", "if", "(", "$", "this", "->", "collector", ")", "{", "$", "this", "->", "collector", "->", "addResource", "(", "new", "FileResource", "(", "$", "file", ")", ")", ";", "}", "$", "data", "=", "$", "this", "->", "doLoad", "(", "$", "file", ")", ";", "return", "$", "this", "->", "process", "(", "$", "data", ",", "$", "resource", ")", ";", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Loader/AbstractFileLoader.php#L107-L118
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Loader/AbstractFileLoader.php
AbstractFileLoader.process
public function process($data, $file) { if (empty($data)) { return array(); } if (isset($data['imports'])) { if (false === is_array($data['imports'])) { throw ImportException::format( 'The "imports" value is not valid in "%s".', $file ); } $dir = dirname($file); foreach ($data['imports'] as $i => $import) { if (false === is_array($import)) { throw ImportException::format( 'One of the "imports" values (#%d) is not valid in "%s".', $i, $file ); } if (false === isset($import['resource'])) { throw ImportException::format( 'A resource was not defined for an import in "%s".', $file ); } $this->setCurrentDir($dir); $data = array_replace_recursive( $this->import( $import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false ), $data ); } } $global = $this->wise ? $this->wise->getGlobalParameters() : array(); $_this = $this; ArrayUtil::walkRecursive( $data, function (&$value, $key, &$array) use (&$data, $global, $_this) { $value = $_this->doReplace($value, $data, $global); if (false !== strpos($key, '%')) { unset($array[$key]); $key = $_this->doReplace($key, $data, $global); $array[$key] = $value; } } ); return $data; }
php
public function process($data, $file) { if (empty($data)) { return array(); } if (isset($data['imports'])) { if (false === is_array($data['imports'])) { throw ImportException::format( 'The "imports" value is not valid in "%s".', $file ); } $dir = dirname($file); foreach ($data['imports'] as $i => $import) { if (false === is_array($import)) { throw ImportException::format( 'One of the "imports" values (#%d) is not valid in "%s".', $i, $file ); } if (false === isset($import['resource'])) { throw ImportException::format( 'A resource was not defined for an import in "%s".', $file ); } $this->setCurrentDir($dir); $data = array_replace_recursive( $this->import( $import['resource'], null, isset($import['ignore_errors']) ? (bool) $import['ignore_errors'] : false ), $data ); } } $global = $this->wise ? $this->wise->getGlobalParameters() : array(); $_this = $this; ArrayUtil::walkRecursive( $data, function (&$value, $key, &$array) use (&$data, $global, $_this) { $value = $_this->doReplace($value, $data, $global); if (false !== strpos($key, '%')) { unset($array[$key]); $key = $_this->doReplace($key, $data, $global); $array[$key] = $value; } } ); return $data; }
[ "public", "function", "process", "(", "$", "data", ",", "$", "file", ")", "{", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'imports'", "]", ")", ")", "{", "if", "(", "false", "===", "is_array", "(", "$", "data", "[", "'imports'", "]", ")", ")", "{", "throw", "ImportException", "::", "format", "(", "'The \"imports\" value is not valid in \"%s\".'", ",", "$", "file", ")", ";", "}", "$", "dir", "=", "dirname", "(", "$", "file", ")", ";", "foreach", "(", "$", "data", "[", "'imports'", "]", "as", "$", "i", "=>", "$", "import", ")", "{", "if", "(", "false", "===", "is_array", "(", "$", "import", ")", ")", "{", "throw", "ImportException", "::", "format", "(", "'One of the \"imports\" values (#%d) is not valid in \"%s\".'", ",", "$", "i", ",", "$", "file", ")", ";", "}", "if", "(", "false", "===", "isset", "(", "$", "import", "[", "'resource'", "]", ")", ")", "{", "throw", "ImportException", "::", "format", "(", "'A resource was not defined for an import in \"%s\".'", ",", "$", "file", ")", ";", "}", "$", "this", "->", "setCurrentDir", "(", "$", "dir", ")", ";", "$", "data", "=", "array_replace_recursive", "(", "$", "this", "->", "import", "(", "$", "import", "[", "'resource'", "]", ",", "null", ",", "isset", "(", "$", "import", "[", "'ignore_errors'", "]", ")", "?", "(", "bool", ")", "$", "import", "[", "'ignore_errors'", "]", ":", "false", ")", ",", "$", "data", ")", ";", "}", "}", "$", "global", "=", "$", "this", "->", "wise", "?", "$", "this", "->", "wise", "->", "getGlobalParameters", "(", ")", ":", "array", "(", ")", ";", "$", "_this", "=", "$", "this", ";", "ArrayUtil", "::", "walkRecursive", "(", "$", "data", ",", "function", "(", "&", "$", "value", ",", "$", "key", ",", "&", "$", "array", ")", "use", "(", "&", "$", "data", ",", "$", "global", ",", "$", "_this", ")", "{", "$", "value", "=", "$", "_this", "->", "doReplace", "(", "$", "value", ",", "$", "data", ",", "$", "global", ")", ";", "if", "(", "false", "!==", "strpos", "(", "$", "key", ",", "'%'", ")", ")", "{", "unset", "(", "$", "array", "[", "$", "key", "]", ")", ";", "$", "key", "=", "$", "_this", "->", "doReplace", "(", "$", "key", ",", "$", "data", ",", "$", "global", ")", ";", "$", "array", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", ")", ";", "return", "$", "data", ";", "}" ]
Imports other configuration files and resolves references. @param array $data The data. @param string $file The file source. @return array The processed data. @throws ImportException If "imports" is invalid. @throws InvalidReferenceException If an invalid reference is used.
[ "Imports", "other", "configuration", "files", "and", "resolves", "references", "." ]
train
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Loader/AbstractFileLoader.php#L131-L195
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Loader/AbstractFileLoader.php
AbstractFileLoader.resolveReference
public function resolveReference($reference, $values) { foreach (explode('.', $reference) as $leaf) { if ((!is_array($values) && !($values instanceof ArrayAccess)) || (is_array($values) && !array_key_exists($leaf, $values)) || (($values instanceof ArrayAccess) && !$values->offsetExists($leaf))) { throw InvalidReferenceException::format( 'The reference "%s" could not be resolved (failed at "%s").', "%$reference%", $leaf ); } $values = $values[$leaf]; } return $values; }
php
public function resolveReference($reference, $values) { foreach (explode('.', $reference) as $leaf) { if ((!is_array($values) && !($values instanceof ArrayAccess)) || (is_array($values) && !array_key_exists($leaf, $values)) || (($values instanceof ArrayAccess) && !$values->offsetExists($leaf))) { throw InvalidReferenceException::format( 'The reference "%s" could not be resolved (failed at "%s").', "%$reference%", $leaf ); } $values = $values[$leaf]; } return $values; }
[ "public", "function", "resolveReference", "(", "$", "reference", ",", "$", "values", ")", "{", "foreach", "(", "explode", "(", "'.'", ",", "$", "reference", ")", "as", "$", "leaf", ")", "{", "if", "(", "(", "!", "is_array", "(", "$", "values", ")", "&&", "!", "(", "$", "values", "instanceof", "ArrayAccess", ")", ")", "||", "(", "is_array", "(", "$", "values", ")", "&&", "!", "array_key_exists", "(", "$", "leaf", ",", "$", "values", ")", ")", "||", "(", "(", "$", "values", "instanceof", "ArrayAccess", ")", "&&", "!", "$", "values", "->", "offsetExists", "(", "$", "leaf", ")", ")", ")", "{", "throw", "InvalidReferenceException", "::", "format", "(", "'The reference \"%s\" could not be resolved (failed at \"%s\").'", ",", "\"%$reference%\"", ",", "$", "leaf", ")", ";", "}", "$", "values", "=", "$", "values", "[", "$", "leaf", "]", ";", "}", "return", "$", "values", ";", "}" ]
Resolves the reference and returns its value. @param string $reference A reference. @param array|ArrayAccess $values A list of values. @return mixed The referenced value. @throws InvalidReferenceException If the reference is not valid.
[ "Resolves", "the", "reference", "and", "returns", "its", "value", "." ]
train
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Loader/AbstractFileLoader.php#L207-L224
nyeholt/silverstripe-external-content
code/model/ExternalContent.php
ExternalContent.getDataObjectFor
public static function getDataObjectFor($id) { if ($id == 'root') { return null; } $obj = null; if (preg_match(self::ID_FORMAT, $id, $matches)) { $id = $matches[1]; $composed = isset($matches[2]) ? trim($matches[2], self::ID_SEPARATOR) : null; $obj = DataObject::get_by_id(self::DEFAULT_CLASS, $id); if ($composed && $obj) { $obj = $obj->getObject($composed); } } else { } return $obj; }
php
public static function getDataObjectFor($id) { if ($id == 'root') { return null; } $obj = null; if (preg_match(self::ID_FORMAT, $id, $matches)) { $id = $matches[1]; $composed = isset($matches[2]) ? trim($matches[2], self::ID_SEPARATOR) : null; $obj = DataObject::get_by_id(self::DEFAULT_CLASS, $id); if ($composed && $obj) { $obj = $obj->getObject($composed); } } else { } return $obj; }
[ "public", "static", "function", "getDataObjectFor", "(", "$", "id", ")", "{", "if", "(", "$", "id", "==", "'root'", ")", "{", "return", "null", ";", "}", "$", "obj", "=", "null", ";", "if", "(", "preg_match", "(", "self", "::", "ID_FORMAT", ",", "$", "id", ",", "$", "matches", ")", ")", "{", "$", "id", "=", "$", "matches", "[", "1", "]", ";", "$", "composed", "=", "isset", "(", "$", "matches", "[", "2", "]", ")", "?", "trim", "(", "$", "matches", "[", "2", "]", ",", "self", "::", "ID_SEPARATOR", ")", ":", "null", ";", "$", "obj", "=", "DataObject", "::", "get_by_id", "(", "self", "::", "DEFAULT_CLASS", ",", "$", "id", ")", ";", "if", "(", "$", "composed", "&&", "$", "obj", ")", "{", "$", "obj", "=", "$", "obj", "->", "getObject", "(", "$", "composed", ")", ";", "}", "}", "else", "{", "}", "return", "$", "obj", ";", "}" ]
Get the actual object based on a composite ID Don't really want to use a static, but SS's data object retrieval system doesn't really provide a nice override mechanism other than useCustomObject @param String $id The compound ID to get a data object for @return DataObject
[ "Get", "the", "actual", "object", "based", "on", "a", "composite", "ID" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/code/model/ExternalContent.php#L47-L66
alphayax/phpdoc_md
src/MdGen.php
MdGen.loadClasses
protected function loadClasses(){ if( ! is_dir( $this->srcDirectory)){ throw new \Exception( 'Source directory not found : '. $this->srcDirectory); } $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator( $this->srcDirectory), \RecursiveIteratorIterator::SELF_FIRST); $Regex = new \RegexIterator( $objects, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH); foreach( $Regex as $name => $object){ if ( ! empty( $name)) { require_once $name; } } $classes = get_declared_classes(); $traits = get_declared_traits(); $interfaces = get_declared_interfaces(); $this->loadedClasses = array_merge( $classes, $traits, $interfaces); }
php
protected function loadClasses(){ if( ! is_dir( $this->srcDirectory)){ throw new \Exception( 'Source directory not found : '. $this->srcDirectory); } $objects = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator( $this->srcDirectory), \RecursiveIteratorIterator::SELF_FIRST); $Regex = new \RegexIterator( $objects, '/^.+\.php$/i', \RecursiveRegexIterator::GET_MATCH); foreach( $Regex as $name => $object){ if ( ! empty( $name)) { require_once $name; } } $classes = get_declared_classes(); $traits = get_declared_traits(); $interfaces = get_declared_interfaces(); $this->loadedClasses = array_merge( $classes, $traits, $interfaces); }
[ "protected", "function", "loadClasses", "(", ")", "{", "if", "(", "!", "is_dir", "(", "$", "this", "->", "srcDirectory", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Source directory not found : '", ".", "$", "this", "->", "srcDirectory", ")", ";", "}", "$", "objects", "=", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", "this", "->", "srcDirectory", ")", ",", "\\", "RecursiveIteratorIterator", "::", "SELF_FIRST", ")", ";", "$", "Regex", "=", "new", "\\", "RegexIterator", "(", "$", "objects", ",", "'/^.+\\.php$/i'", ",", "\\", "RecursiveRegexIterator", "::", "GET_MATCH", ")", ";", "foreach", "(", "$", "Regex", "as", "$", "name", "=>", "$", "object", ")", "{", "if", "(", "!", "empty", "(", "$", "name", ")", ")", "{", "require_once", "$", "name", ";", "}", "}", "$", "classes", "=", "get_declared_classes", "(", ")", ";", "$", "traits", "=", "get_declared_traits", "(", ")", ";", "$", "interfaces", "=", "get_declared_interfaces", "(", ")", ";", "$", "this", "->", "loadedClasses", "=", "array_merge", "(", "$", "classes", ",", "$", "traits", ",", "$", "interfaces", ")", ";", "}" ]
Load class in the source directory
[ "Load", "class", "in", "the", "source", "directory" ]
train
https://github.com/alphayax/phpdoc_md/blob/326da10b837161591a32ab4f36f9b2f4feabbe65/src/MdGen.php#L39-L56
alphayax/phpdoc_md
src/MdGen.php
MdGen.filterNamespace
public function filterNamespace( $namespaceName) { $FilteredClasses = []; foreach( $this->loadedClasses as $loadedClass){ if( 0 == substr_compare( $loadedClass, $namespaceName, 0, strlen( $namespaceName))){ $FilteredClasses[] = $loadedClass; } } $this->loadedClasses = $FilteredClasses; }
php
public function filterNamespace( $namespaceName) { $FilteredClasses = []; foreach( $this->loadedClasses as $loadedClass){ if( 0 == substr_compare( $loadedClass, $namespaceName, 0, strlen( $namespaceName))){ $FilteredClasses[] = $loadedClass; } } $this->loadedClasses = $FilteredClasses; }
[ "public", "function", "filterNamespace", "(", "$", "namespaceName", ")", "{", "$", "FilteredClasses", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "loadedClasses", "as", "$", "loadedClass", ")", "{", "if", "(", "0", "==", "substr_compare", "(", "$", "loadedClass", ",", "$", "namespaceName", ",", "0", ",", "strlen", "(", "$", "namespaceName", ")", ")", ")", "{", "$", "FilteredClasses", "[", "]", "=", "$", "loadedClass", ";", "}", "}", "$", "this", "->", "loadedClasses", "=", "$", "FilteredClasses", ";", "}" ]
Filter class who are in a specific namespace @param $namespaceName
[ "Filter", "class", "who", "are", "in", "a", "specific", "namespace" ]
train
https://github.com/alphayax/phpdoc_md/blob/326da10b837161591a32ab4f36f9b2f4feabbe65/src/MdGen.php#L62-L70
alphayax/phpdoc_md
src/MdGen.php
MdGen.filterSubClasses
public function filterSubClasses( $className) { $FilteredClasses = []; foreach( $this->loadedClasses as $loadedClass){ if( is_subclass_of( $loadedClass, $className)){ $FilteredClasses[] = $loadedClass; } } $this->loadedClasses = $FilteredClasses; }
php
public function filterSubClasses( $className) { $FilteredClasses = []; foreach( $this->loadedClasses as $loadedClass){ if( is_subclass_of( $loadedClass, $className)){ $FilteredClasses[] = $loadedClass; } } $this->loadedClasses = $FilteredClasses; }
[ "public", "function", "filterSubClasses", "(", "$", "className", ")", "{", "$", "FilteredClasses", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "loadedClasses", "as", "$", "loadedClass", ")", "{", "if", "(", "is_subclass_of", "(", "$", "loadedClass", ",", "$", "className", ")", ")", "{", "$", "FilteredClasses", "[", "]", "=", "$", "loadedClass", ";", "}", "}", "$", "this", "->", "loadedClasses", "=", "$", "FilteredClasses", ";", "}" ]
Filter class who are sub-classes of a specific class @param $className
[ "Filter", "class", "who", "are", "sub", "-", "classes", "of", "a", "specific", "class" ]
train
https://github.com/alphayax/phpdoc_md/blob/326da10b837161591a32ab4f36f9b2f4feabbe65/src/MdGen.php#L76-L84
alphayax/phpdoc_md
src/MdGen.php
MdGen.generate
public function generate( $directory = '.'){ $chapters = $this->generateClassMdFromLoadedClasses(); $this->rootPage = new models\NamespaceMd( $this->rootNamespace, $chapters); $this->rootPage->setDirectory( $directory); $this->rootPage->write(); }
php
public function generate( $directory = '.'){ $chapters = $this->generateClassMdFromLoadedClasses(); $this->rootPage = new models\NamespaceMd( $this->rootNamespace, $chapters); $this->rootPage->setDirectory( $directory); $this->rootPage->write(); }
[ "public", "function", "generate", "(", "$", "directory", "=", "'.'", ")", "{", "$", "chapters", "=", "$", "this", "->", "generateClassMdFromLoadedClasses", "(", ")", ";", "$", "this", "->", "rootPage", "=", "new", "models", "\\", "NamespaceMd", "(", "$", "this", "->", "rootNamespace", ",", "$", "chapters", ")", ";", "$", "this", "->", "rootPage", "->", "setDirectory", "(", "$", "directory", ")", ";", "$", "this", "->", "rootPage", "->", "write", "(", ")", ";", "}" ]
Generate markdown files @param string $directory
[ "Generate", "markdown", "files" ]
train
https://github.com/alphayax/phpdoc_md/blob/326da10b837161591a32ab4f36f9b2f4feabbe65/src/MdGen.php#L102-L107
Chill-project/Main
Controller/CenterController.php
CenterController.createCreateForm
private function createCreateForm(Center $center) { $form = $this->createForm(new CenterType(), $center, array( 'action' => $this->generateUrl('admin_center_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
php
private function createCreateForm(Center $center) { $form = $this->createForm(new CenterType(), $center, array( 'action' => $this->generateUrl('admin_center_create'), 'method' => 'POST', )); $form->add('submit', 'submit', array('label' => 'Create')); return $form; }
[ "private", "function", "createCreateForm", "(", "Center", "$", "center", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "CenterType", "(", ")", ",", "$", "center", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_center_create'", ")", ",", "'method'", "=>", "'POST'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Create'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to create a Center entity. @param Center $center The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "create", "a", "Center", "entity", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/CenterController.php#L63-L73
Chill-project/Main
Controller/CenterController.php
CenterController.newAction
public function newAction() { $center = new Center(); $form = $this->createCreateForm($center); return $this->render('ChillMainBundle:Center:new.html.twig', array( 'entity' => $center, 'form' => $form->createView(), )); }
php
public function newAction() { $center = new Center(); $form = $this->createCreateForm($center); return $this->render('ChillMainBundle:Center:new.html.twig', array( 'entity' => $center, 'form' => $form->createView(), )); }
[ "public", "function", "newAction", "(", ")", "{", "$", "center", "=", "new", "Center", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "center", ")", ";", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:Center:new.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "center", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
Displays a form to create a new Center entity.
[ "Displays", "a", "form", "to", "create", "a", "new", "Center", "entity", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/CenterController.php#L79-L88
Chill-project/Main
Controller/CenterController.php
CenterController.createEditForm
private function createEditForm(Center $center) { $form = $this->createForm(new CenterType(), $center, array( 'action' => $this->generateUrl('admin_center_update', array('id' => $center->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
php
private function createEditForm(Center $center) { $form = $this->createForm(new CenterType(), $center, array( 'action' => $this->generateUrl('admin_center_update', array('id' => $center->getId())), 'method' => 'PUT', )); $form->add('submit', 'submit', array('label' => 'Update')); return $form; }
[ "private", "function", "createEditForm", "(", "Center", "$", "center", ")", "{", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "CenterType", "(", ")", ",", "$", "center", ",", "array", "(", "'action'", "=>", "$", "this", "->", "generateUrl", "(", "'admin_center_update'", ",", "array", "(", "'id'", "=>", "$", "center", "->", "getId", "(", ")", ")", ")", ",", "'method'", "=>", "'PUT'", ",", ")", ")", ";", "$", "form", "->", "add", "(", "'submit'", ",", "'submit'", ",", "array", "(", "'label'", "=>", "'Update'", ")", ")", ";", "return", "$", "form", ";", "}" ]
Creates a form to edit a Center entity. @param Center $center The entity @return \Symfony\Component\Form\Form The form
[ "Creates", "a", "form", "to", "edit", "a", "Center", "entity", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/CenterController.php#L137-L147
Chill-project/Main
Controller/CenterController.php
CenterController.updateAction
public function updateAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $center = $em->getRepository('ChillMainBundle:Center')->find($id); if (!$center) { throw $this->createNotFoundException('Unable to find Center entity.'); } $editForm = $this->createEditForm($center); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); return $this->redirect($this->generateUrl('admin_center_edit', array('id' => $id))); } return $this->render('ChillMainBundle:Center:edit.html.twig', array( 'entity' => $center, 'edit_form' => $editForm->createView() )); }
php
public function updateAction(Request $request, $id) { $em = $this->getDoctrine()->getManager(); $center = $em->getRepository('ChillMainBundle:Center')->find($id); if (!$center) { throw $this->createNotFoundException('Unable to find Center entity.'); } $editForm = $this->createEditForm($center); $editForm->handleRequest($request); if ($editForm->isValid()) { $em->flush(); return $this->redirect($this->generateUrl('admin_center_edit', array('id' => $id))); } return $this->render('ChillMainBundle:Center:edit.html.twig', array( 'entity' => $center, 'edit_form' => $editForm->createView() )); }
[ "public", "function", "updateAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "center", "=", "$", "em", "->", "getRepository", "(", "'ChillMainBundle:Center'", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "center", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'Unable to find Center entity.'", ")", ";", "}", "$", "editForm", "=", "$", "this", "->", "createEditForm", "(", "$", "center", ")", ";", "$", "editForm", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "editForm", "->", "isValid", "(", ")", ")", "{", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_center_edit'", ",", "array", "(", "'id'", "=>", "$", "id", ")", ")", ")", ";", "}", "return", "$", "this", "->", "render", "(", "'ChillMainBundle:Center:edit.html.twig'", ",", "array", "(", "'entity'", "=>", "$", "center", ",", "'edit_form'", "=>", "$", "editForm", "->", "createView", "(", ")", ")", ")", ";", "}" ]
Edits an existing Center entity.
[ "Edits", "an", "existing", "Center", "entity", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Controller/CenterController.php#L152-L175
shinjin/freezer
src/Freezer.php
Freezer.freeze
public function freeze($object, array &$objects = array()) { if (!is_object($object)) { throw new InvalidArgumentException(1, 'object'); } if ($object instanceof LazyProxy) { if ($object->isThawed()) { $object = $object->getObject(); } else { return array('root' => $object->getId()); } } // If the object has not been frozen before, generate a new UUID and // store it in the "special" __freezer_uuid property. if (!isset($object->{$this->idProperty})) { $object->{$this->idProperty} = $this->generateId(); } if (!isset($object->__freezer)) { $object->__freezer = array(); } $isDirty = $this->isDirty($object, true); $id = (string)$object->{$this->idProperty}; if (!isset($objects[$id])) { $objects[$id] = array( 'class' => get_class($object), 'isDirty' => $isDirty, 'state' => array() ); // Iterate over the properties of the object. $properties = call_user_func($this->propertyReader, $object); foreach ($properties as $name => $value) { if ($name !== $this->idProperty) { if (is_array($value)) { $this->freezeArray($value, $objects); } elseif (is_object($value)) { // Freeze the aggregated object. $this->freeze($value, $objects); // Replace $v with the aggregated object's id. $value = '__freezer_' . $value->{$this->idProperty}; } elseif (is_resource($value)) { $value = null; } // Store the attribute in the object's state array. $objects[$id]['state'][$name] = $value; } } } return array('root' => $id, 'objects' => $objects); }
php
public function freeze($object, array &$objects = array()) { if (!is_object($object)) { throw new InvalidArgumentException(1, 'object'); } if ($object instanceof LazyProxy) { if ($object->isThawed()) { $object = $object->getObject(); } else { return array('root' => $object->getId()); } } // If the object has not been frozen before, generate a new UUID and // store it in the "special" __freezer_uuid property. if (!isset($object->{$this->idProperty})) { $object->{$this->idProperty} = $this->generateId(); } if (!isset($object->__freezer)) { $object->__freezer = array(); } $isDirty = $this->isDirty($object, true); $id = (string)$object->{$this->idProperty}; if (!isset($objects[$id])) { $objects[$id] = array( 'class' => get_class($object), 'isDirty' => $isDirty, 'state' => array() ); // Iterate over the properties of the object. $properties = call_user_func($this->propertyReader, $object); foreach ($properties as $name => $value) { if ($name !== $this->idProperty) { if (is_array($value)) { $this->freezeArray($value, $objects); } elseif (is_object($value)) { // Freeze the aggregated object. $this->freeze($value, $objects); // Replace $v with the aggregated object's id. $value = '__freezer_' . $value->{$this->idProperty}; } elseif (is_resource($value)) { $value = null; } // Store the attribute in the object's state array. $objects[$id]['state'][$name] = $value; } } } return array('root' => $id, 'objects' => $objects); }
[ "public", "function", "freeze", "(", "$", "object", ",", "array", "&", "$", "objects", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "1", ",", "'object'", ")", ";", "}", "if", "(", "$", "object", "instanceof", "LazyProxy", ")", "{", "if", "(", "$", "object", "->", "isThawed", "(", ")", ")", "{", "$", "object", "=", "$", "object", "->", "getObject", "(", ")", ";", "}", "else", "{", "return", "array", "(", "'root'", "=>", "$", "object", "->", "getId", "(", ")", ")", ";", "}", "}", "// If the object has not been frozen before, generate a new UUID and", "// store it in the \"special\" __freezer_uuid property.", "if", "(", "!", "isset", "(", "$", "object", "->", "{", "$", "this", "->", "idProperty", "}", ")", ")", "{", "$", "object", "->", "{", "$", "this", "->", "idProperty", "}", "=", "$", "this", "->", "generateId", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "object", "->", "__freezer", ")", ")", "{", "$", "object", "->", "__freezer", "=", "array", "(", ")", ";", "}", "$", "isDirty", "=", "$", "this", "->", "isDirty", "(", "$", "object", ",", "true", ")", ";", "$", "id", "=", "(", "string", ")", "$", "object", "->", "{", "$", "this", "->", "idProperty", "}", ";", "if", "(", "!", "isset", "(", "$", "objects", "[", "$", "id", "]", ")", ")", "{", "$", "objects", "[", "$", "id", "]", "=", "array", "(", "'class'", "=>", "get_class", "(", "$", "object", ")", ",", "'isDirty'", "=>", "$", "isDirty", ",", "'state'", "=>", "array", "(", ")", ")", ";", "// Iterate over the properties of the object.", "$", "properties", "=", "call_user_func", "(", "$", "this", "->", "propertyReader", ",", "$", "object", ")", ";", "foreach", "(", "$", "properties", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "$", "name", "!==", "$", "this", "->", "idProperty", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "freezeArray", "(", "$", "value", ",", "$", "objects", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", ")", "{", "// Freeze the aggregated object.", "$", "this", "->", "freeze", "(", "$", "value", ",", "$", "objects", ")", ";", "// Replace $v with the aggregated object's id.", "$", "value", "=", "'__freezer_'", ".", "$", "value", "->", "{", "$", "this", "->", "idProperty", "}", ";", "}", "elseif", "(", "is_resource", "(", "$", "value", ")", ")", "{", "$", "value", "=", "null", ";", "}", "// Store the attribute in the object's state array.", "$", "objects", "[", "$", "id", "]", "[", "'state'", "]", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "}", "return", "array", "(", "'root'", "=>", "$", "id", ",", "'objects'", "=>", "$", "objects", ")", ";", "}" ]
Freezes an object. @param object $object The object that is to be frozen. @param array $objects Only used internally. @return array The frozen object(s). @throws InvalidArgumentException
[ "Freezes", "an", "object", "." ]
train
https://github.com/shinjin/freezer/blob/f5955fb5476fa8ac456e27c0edafaae331d02cd3/src/Freezer.php#L54-L112
shinjin/freezer
src/Freezer.php
Freezer.freezeArray
protected function freezeArray(array &$array, array &$objects) { foreach ($array as &$value) { if (is_array($value)) { $this->freezeArray($value, $objects); } elseif (is_object($value)) { list($id,) = array_values($this->freeze($value, $objects)); $value = '__freezer_' . $id; } } }
php
protected function freezeArray(array &$array, array &$objects) { foreach ($array as &$value) { if (is_array($value)) { $this->freezeArray($value, $objects); } elseif (is_object($value)) { list($id,) = array_values($this->freeze($value, $objects)); $value = '__freezer_' . $id; } } }
[ "protected", "function", "freezeArray", "(", "array", "&", "$", "array", ",", "array", "&", "$", "objects", ")", "{", "foreach", "(", "$", "array", "as", "&", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "this", "->", "freezeArray", "(", "$", "value", ",", "$", "objects", ")", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", ")", "{", "list", "(", "$", "id", ",", ")", "=", "array_values", "(", "$", "this", "->", "freeze", "(", "$", "value", ",", "$", "objects", ")", ")", ";", "$", "value", "=", "'__freezer_'", ".", "$", "id", ";", "}", "}", "}" ]
Freezes an array. @param array $array The array that is to be frozen. @param array $objects Only used internally.
[ "Freezes", "an", "array", "." ]
train
https://github.com/shinjin/freezer/blob/f5955fb5476fa8ac456e27c0edafaae331d02cd3/src/Freezer.php#L120-L130
shinjin/freezer
src/Freezer.php
Freezer.thaw
public function thaw(array $frozenObject, $root = null, array &$objects = array()) { foreach ($frozenObject['objects'] as $object) { if (!class_exists($object['class'], $this->useAutoload)) { throw new \RuntimeException( sprintf('Class "%s" could not be found.', $object['class']) ); } } // By default, we thaw the root object and (recursively) // its aggregated objects. if ($root === null) { $root = $frozenObject['root']; } // Thaw object (if it has not been thawed before). if (!isset($objects[$root])) { $class = $frozenObject['objects'][$root]['class']; $state = $frozenObject['objects'][$root]['state']; // Use a trick to create a new object of a class // without invoking its constructor. $objects[$root] = unserialize( sprintf('O:%d:"%s":0:{}', strlen($class), $class) ); // Handle aggregated objects. $this->thawArray($state, $frozenObject, $objects); $reflector = new \ReflectionObject($objects[$root]); foreach ($state as $name => $value) { if (strpos($name, '__freezer') !== 0) { $property = $reflector->getProperty($name); $property->setAccessible(true); $property->setValue($objects[$root], $value); } } // Store id. $objects[$root]->{$this->idProperty} = $root; // Store __freezer. if (isset($state['__freezer'])) { $objects[$root]->__freezer = $state['__freezer']; } } return $objects[$root]; }
php
public function thaw(array $frozenObject, $root = null, array &$objects = array()) { foreach ($frozenObject['objects'] as $object) { if (!class_exists($object['class'], $this->useAutoload)) { throw new \RuntimeException( sprintf('Class "%s" could not be found.', $object['class']) ); } } // By default, we thaw the root object and (recursively) // its aggregated objects. if ($root === null) { $root = $frozenObject['root']; } // Thaw object (if it has not been thawed before). if (!isset($objects[$root])) { $class = $frozenObject['objects'][$root]['class']; $state = $frozenObject['objects'][$root]['state']; // Use a trick to create a new object of a class // without invoking its constructor. $objects[$root] = unserialize( sprintf('O:%d:"%s":0:{}', strlen($class), $class) ); // Handle aggregated objects. $this->thawArray($state, $frozenObject, $objects); $reflector = new \ReflectionObject($objects[$root]); foreach ($state as $name => $value) { if (strpos($name, '__freezer') !== 0) { $property = $reflector->getProperty($name); $property->setAccessible(true); $property->setValue($objects[$root], $value); } } // Store id. $objects[$root]->{$this->idProperty} = $root; // Store __freezer. if (isset($state['__freezer'])) { $objects[$root]->__freezer = $state['__freezer']; } } return $objects[$root]; }
[ "public", "function", "thaw", "(", "array", "$", "frozenObject", ",", "$", "root", "=", "null", ",", "array", "&", "$", "objects", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "frozenObject", "[", "'objects'", "]", "as", "$", "object", ")", "{", "if", "(", "!", "class_exists", "(", "$", "object", "[", "'class'", "]", ",", "$", "this", "->", "useAutoload", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Class \"%s\" could not be found.'", ",", "$", "object", "[", "'class'", "]", ")", ")", ";", "}", "}", "// By default, we thaw the root object and (recursively)", "// its aggregated objects.", "if", "(", "$", "root", "===", "null", ")", "{", "$", "root", "=", "$", "frozenObject", "[", "'root'", "]", ";", "}", "// Thaw object (if it has not been thawed before).", "if", "(", "!", "isset", "(", "$", "objects", "[", "$", "root", "]", ")", ")", "{", "$", "class", "=", "$", "frozenObject", "[", "'objects'", "]", "[", "$", "root", "]", "[", "'class'", "]", ";", "$", "state", "=", "$", "frozenObject", "[", "'objects'", "]", "[", "$", "root", "]", "[", "'state'", "]", ";", "// Use a trick to create a new object of a class", "// without invoking its constructor.", "$", "objects", "[", "$", "root", "]", "=", "unserialize", "(", "sprintf", "(", "'O:%d:\"%s\":0:{}'", ",", "strlen", "(", "$", "class", ")", ",", "$", "class", ")", ")", ";", "// Handle aggregated objects.", "$", "this", "->", "thawArray", "(", "$", "state", ",", "$", "frozenObject", ",", "$", "objects", ")", ";", "$", "reflector", "=", "new", "\\", "ReflectionObject", "(", "$", "objects", "[", "$", "root", "]", ")", ";", "foreach", "(", "$", "state", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "strpos", "(", "$", "name", ",", "'__freezer'", ")", "!==", "0", ")", "{", "$", "property", "=", "$", "reflector", "->", "getProperty", "(", "$", "name", ")", ";", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "$", "property", "->", "setValue", "(", "$", "objects", "[", "$", "root", "]", ",", "$", "value", ")", ";", "}", "}", "// Store id.", "$", "objects", "[", "$", "root", "]", "->", "{", "$", "this", "->", "idProperty", "}", "=", "$", "root", ";", "// Store __freezer.", "if", "(", "isset", "(", "$", "state", "[", "'__freezer'", "]", ")", ")", "{", "$", "objects", "[", "$", "root", "]", "->", "__freezer", "=", "$", "state", "[", "'__freezer'", "]", ";", "}", "}", "return", "$", "objects", "[", "$", "root", "]", ";", "}" ]
Thaws an object. @param array $frozenObject The frozen object that should be thawed. @param string $root The UUID of the object that should be treated as the root object when multiple objects are present in $frozenObject. @param array $objects Only used internally. @return object The thawed object. @throws RuntimeException
[ "Thaws", "an", "object", "." ]
train
https://github.com/shinjin/freezer/blob/f5955fb5476fa8ac456e27c0edafaae331d02cd3/src/Freezer.php#L143-L193
shinjin/freezer
src/Freezer.php
Freezer.generateHash
public function generateHash($object) { if (!is_object($object)) { throw new InvalidArgumentException(1, 'object'); } $properties = call_user_func($this->propertyReader, $object); ksort($properties); if (isset($properties['__freezer'])) { unset($properties['__freezer']); } foreach ($properties as $name => $value) { if (is_array($value)) { $properties[$name] = '<array>'; } elseif (is_object($value)) { if (!isset($value->{$this->idProperty})) { $value->{$this->idProperty} = $this->generateId(); } $properties[$name] = (string)$value->{$this->idProperty}; } elseif (is_resource($value)) { $properties[$name] = null; } } return sha1(get_class($object) . join(':', $properties)); }
php
public function generateHash($object) { if (!is_object($object)) { throw new InvalidArgumentException(1, 'object'); } $properties = call_user_func($this->propertyReader, $object); ksort($properties); if (isset($properties['__freezer'])) { unset($properties['__freezer']); } foreach ($properties as $name => $value) { if (is_array($value)) { $properties[$name] = '<array>'; } elseif (is_object($value)) { if (!isset($value->{$this->idProperty})) { $value->{$this->idProperty} = $this->generateId(); } $properties[$name] = (string)$value->{$this->idProperty}; } elseif (is_resource($value)) { $properties[$name] = null; } } return sha1(get_class($object) . join(':', $properties)); }
[ "public", "function", "generateHash", "(", "$", "object", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "1", ",", "'object'", ")", ";", "}", "$", "properties", "=", "call_user_func", "(", "$", "this", "->", "propertyReader", ",", "$", "object", ")", ";", "ksort", "(", "$", "properties", ")", ";", "if", "(", "isset", "(", "$", "properties", "[", "'__freezer'", "]", ")", ")", "{", "unset", "(", "$", "properties", "[", "'__freezer'", "]", ")", ";", "}", "foreach", "(", "$", "properties", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "properties", "[", "$", "name", "]", "=", "'<array>'", ";", "}", "elseif", "(", "is_object", "(", "$", "value", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "value", "->", "{", "$", "this", "->", "idProperty", "}", ")", ")", "{", "$", "value", "->", "{", "$", "this", "->", "idProperty", "}", "=", "$", "this", "->", "generateId", "(", ")", ";", "}", "$", "properties", "[", "$", "name", "]", "=", "(", "string", ")", "$", "value", "->", "{", "$", "this", "->", "idProperty", "}", ";", "}", "elseif", "(", "is_resource", "(", "$", "value", ")", ")", "{", "$", "properties", "[", "$", "name", "]", "=", "null", ";", "}", "}", "return", "sha1", "(", "get_class", "(", "$", "object", ")", ".", "join", "(", "':'", ",", "$", "properties", ")", ")", ";", "}" ]
Hashes an object using the SHA1 hashing function on the property values of an object without recursing into aggregated arrays or objects. @param object $object The object that is to be hashed. @return string @throws InvalidArgumentException
[ "Hashes", "an", "object", "using", "the", "SHA1", "hashing", "function", "on", "the", "property", "values", "of", "an", "object", "without", "recursing", "into", "aggregated", "arrays", "or", "objects", "." ]
train
https://github.com/shinjin/freezer/blob/f5955fb5476fa8ac456e27c0edafaae331d02cd3/src/Freezer.php#L301-L329
shinjin/freezer
src/Freezer.php
Freezer.generateId
public function generateId() { $data = openssl_random_pseudo_bytes(16); $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100 $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); }
php
public function generateId() { $data = openssl_random_pseudo_bytes(16); $data[6] = chr(ord($data[6]) & 0x0f | 0x40); // set version to 0100 $data[8] = chr(ord($data[8]) & 0x3f | 0x80); // set bits 6-7 to 10 return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); }
[ "public", "function", "generateId", "(", ")", "{", "$", "data", "=", "openssl_random_pseudo_bytes", "(", "16", ")", ";", "$", "data", "[", "6", "]", "=", "chr", "(", "ord", "(", "$", "data", "[", "6", "]", ")", "&", "0x0f", "|", "0x40", ")", ";", "// set version to 0100", "$", "data", "[", "8", "]", "=", "chr", "(", "ord", "(", "$", "data", "[", "8", "]", ")", "&", "0x3f", "|", "0x80", ")", ";", "// set bits 6-7 to 10", "return", "vsprintf", "(", "'%s%s-%s-%s-%s-%s%s%s'", ",", "str_split", "(", "bin2hex", "(", "$", "data", ")", ",", "4", ")", ")", ";", "}" ]
This implementation of UUID generation is based on code from an answer on stackoverflow. @return string @link https://stackoverflow.com/a/15875555
[ "This", "implementation", "of", "UUID", "generation", "is", "based", "on", "code", "from", "an", "answer", "on", "stackoverflow", "." ]
train
https://github.com/shinjin/freezer/blob/f5955fb5476fa8ac456e27c0edafaae331d02cd3/src/Freezer.php#L338-L345
shinjin/freezer
src/Freezer.php
Freezer.isDirty
public function isDirty($object, $rehash = false) { if (!is_object($object)) { throw new InvalidArgumentException(1, 'object'); } if (!is_bool($rehash)) { throw new InvalidArgumentException(2, 'boolean'); } $isDirty = true; if (isset($object->__freezer)) { $hash = $this->generateHash($object); if (isset($object->__freezer['hash']) && $object->__freezer['hash'] === $hash) { $isDirty = false; } if ($isDirty && $rehash) { $object->__freezer['hash'] = $hash; } } return $isDirty; }
php
public function isDirty($object, $rehash = false) { if (!is_object($object)) { throw new InvalidArgumentException(1, 'object'); } if (!is_bool($rehash)) { throw new InvalidArgumentException(2, 'boolean'); } $isDirty = true; if (isset($object->__freezer)) { $hash = $this->generateHash($object); if (isset($object->__freezer['hash']) && $object->__freezer['hash'] === $hash) { $isDirty = false; } if ($isDirty && $rehash) { $object->__freezer['hash'] = $hash; } } return $isDirty; }
[ "public", "function", "isDirty", "(", "$", "object", ",", "$", "rehash", "=", "false", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "1", ",", "'object'", ")", ";", "}", "if", "(", "!", "is_bool", "(", "$", "rehash", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "2", ",", "'boolean'", ")", ";", "}", "$", "isDirty", "=", "true", ";", "if", "(", "isset", "(", "$", "object", "->", "__freezer", ")", ")", "{", "$", "hash", "=", "$", "this", "->", "generateHash", "(", "$", "object", ")", ";", "if", "(", "isset", "(", "$", "object", "->", "__freezer", "[", "'hash'", "]", ")", "&&", "$", "object", "->", "__freezer", "[", "'hash'", "]", "===", "$", "hash", ")", "{", "$", "isDirty", "=", "false", ";", "}", "if", "(", "$", "isDirty", "&&", "$", "rehash", ")", "{", "$", "object", "->", "__freezer", "[", "'hash'", "]", "=", "$", "hash", ";", "}", "}", "return", "$", "isDirty", ";", "}" ]
Checks whether an object is dirty, ie. if its SHA1 hash is still valid. Returns true when the object's __freezer['hash'] value is no longer valid or does not exist. Returns false when the object's __freezer['hash'] value is still valid. @param object $object The object that is to be checked. @param boolean $rehash Whether or not to rehash dirty objects. @return boolean @throws InvalidArgumentException
[ "Checks", "whether", "an", "object", "is", "dirty", "ie", ".", "if", "its", "SHA1", "hash", "is", "still", "valid", "." ]
train
https://github.com/shinjin/freezer/blob/f5955fb5476fa8ac456e27c0edafaae331d02cd3/src/Freezer.php#L359-L385
shinjin/freezer
src/Freezer.php
Freezer.readProperties
public function readProperties($object) { if (!is_object($object)) { throw new InvalidArgumentException(1, 'object'); } $reflector = new \ReflectionObject($object); $result = array(); // Iterate over the properties of the object. foreach ($reflector->getProperties() as $property) { $property->setAccessible(true); $result[$property->getName()] = $property->getValue($object); } return $result; }
php
public function readProperties($object) { if (!is_object($object)) { throw new InvalidArgumentException(1, 'object'); } $reflector = new \ReflectionObject($object); $result = array(); // Iterate over the properties of the object. foreach ($reflector->getProperties() as $property) { $property->setAccessible(true); $result[$property->getName()] = $property->getValue($object); } return $result; }
[ "public", "function", "readProperties", "(", "$", "object", ")", "{", "if", "(", "!", "is_object", "(", "$", "object", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "1", ",", "'object'", ")", ";", "}", "$", "reflector", "=", "new", "\\", "ReflectionObject", "(", "$", "object", ")", ";", "$", "result", "=", "array", "(", ")", ";", "// Iterate over the properties of the object.", "foreach", "(", "$", "reflector", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "$", "result", "[", "$", "property", "->", "getName", "(", ")", "]", "=", "$", "property", "->", "getValue", "(", "$", "object", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns an associative array of all properties of an object, including those declared as protected or private. @param object $object The object for which all properties are returned. @return array @throws InvalidArgumentException
[ "Returns", "an", "associative", "array", "of", "all", "properties", "of", "an", "object", "including", "those", "declared", "as", "protected", "or", "private", "." ]
train
https://github.com/shinjin/freezer/blob/f5955fb5476fa8ac456e27c0edafaae331d02cd3/src/Freezer.php#L395-L411
SignpostMarv/daft-object
src/DefinitionAssistant.php
DefinitionAssistant.RegisterAbstractDaftObjectType
public static function RegisterAbstractDaftObjectType(string $maybe) : string { /** * @var array<int, string> */ $props = $maybe::DaftObjectProperties(); /** * @psalm-var class-string<A> */ $maybe = static::RegisterDaftObjectTypeFromTypeAndProps($maybe, ...$props); return $maybe; }
php
public static function RegisterAbstractDaftObjectType(string $maybe) : string { /** * @var array<int, string> */ $props = $maybe::DaftObjectProperties(); /** * @psalm-var class-string<A> */ $maybe = static::RegisterDaftObjectTypeFromTypeAndProps($maybe, ...$props); return $maybe; }
[ "public", "static", "function", "RegisterAbstractDaftObjectType", "(", "string", "$", "maybe", ")", ":", "string", "{", "/**\n * @var array<int, string>\n */", "$", "props", "=", "$", "maybe", "::", "DaftObjectProperties", "(", ")", ";", "/**\n * @psalm-var class-string<A>\n */", "$", "maybe", "=", "static", "::", "RegisterDaftObjectTypeFromTypeAndProps", "(", "$", "maybe", ",", "...", "$", "props", ")", ";", "return", "$", "maybe", ";", "}" ]
@template A as AbstractDaftObject @psalm-param class-string<A> $maybe @psalm-return class-string<A>
[ "@template", "A", "as", "AbstractDaftObject" ]
train
https://github.com/SignpostMarv/daft-object/blob/514886592b64986cc637040045f098335e27c037/src/DefinitionAssistant.php#L41-L54
SignpostMarv/daft-object
src/DefinitionAssistant.php
DefinitionAssistant.ObtainExpectedProperties
public static function ObtainExpectedProperties($maybe) : array { /** * @psalm-var class-string<T> */ $maybe = is_string($maybe) ? $maybe : get_class($maybe); $maybe = self::MaybeRegisterAdditionalTypes($maybe); return parent::ObtainExpectedProperties($maybe); }
php
public static function ObtainExpectedProperties($maybe) : array { /** * @psalm-var class-string<T> */ $maybe = is_string($maybe) ? $maybe : get_class($maybe); $maybe = self::MaybeRegisterAdditionalTypes($maybe); return parent::ObtainExpectedProperties($maybe); }
[ "public", "static", "function", "ObtainExpectedProperties", "(", "$", "maybe", ")", ":", "array", "{", "/**\n * @psalm-var class-string<T>\n */", "$", "maybe", "=", "is_string", "(", "$", "maybe", ")", "?", "$", "maybe", ":", "get_class", "(", "$", "maybe", ")", ";", "$", "maybe", "=", "self", "::", "MaybeRegisterAdditionalTypes", "(", "$", "maybe", ")", ";", "return", "parent", "::", "ObtainExpectedProperties", "(", "$", "maybe", ")", ";", "}" ]
{@inheritdoc} @psalm-param class-string<T>|T $maybe
[ "{", "@inheritdoc", "}" ]
train
https://github.com/SignpostMarv/daft-object/blob/514886592b64986cc637040045f098335e27c037/src/DefinitionAssistant.php#L61-L71
SignpostMarv/daft-object
src/DefinitionAssistant.php
DefinitionAssistant.MaybeThrowIfValueDoesNotMatchMultiTypedArray
public static function MaybeThrowIfValueDoesNotMatchMultiTypedArray( bool $autoTrimStrings, bool $throwIfNotUnique, $value, string ...$types ) : array { if ( ! is_array($value)) { throw new InvalidArgumentException( 'Argument 3 passed to ' . __METHOD__ . ' must be an array, ' . (is_object($value) ? get_class($value) : gettype($value)) . ' given!' ); } /** * @var (scalar|array|object|null)[] */ $value = $value; return static::MaybeThrowIfValueDoesNotMatchMultiTypedArrayValueArray( $autoTrimStrings, $throwIfNotUnique, $value, ...$types ); }
php
public static function MaybeThrowIfValueDoesNotMatchMultiTypedArray( bool $autoTrimStrings, bool $throwIfNotUnique, $value, string ...$types ) : array { if ( ! is_array($value)) { throw new InvalidArgumentException( 'Argument 3 passed to ' . __METHOD__ . ' must be an array, ' . (is_object($value) ? get_class($value) : gettype($value)) . ' given!' ); } /** * @var (scalar|array|object|null)[] */ $value = $value; return static::MaybeThrowIfValueDoesNotMatchMultiTypedArrayValueArray( $autoTrimStrings, $throwIfNotUnique, $value, ...$types ); }
[ "public", "static", "function", "MaybeThrowIfValueDoesNotMatchMultiTypedArray", "(", "bool", "$", "autoTrimStrings", ",", "bool", "$", "throwIfNotUnique", ",", "$", "value", ",", "string", "...", "$", "types", ")", ":", "array", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Argument 3 passed to '", ".", "__METHOD__", ".", "' must be an array, '", ".", "(", "is_object", "(", "$", "value", ")", "?", "get_class", "(", "$", "value", ")", ":", "gettype", "(", "$", "value", ")", ")", ".", "' given!'", ")", ";", "}", "/**\n * @var (scalar|array|object|null)[]\n */", "$", "value", "=", "$", "value", ";", "return", "static", "::", "MaybeThrowIfValueDoesNotMatchMultiTypedArrayValueArray", "(", "$", "autoTrimStrings", ",", "$", "throwIfNotUnique", ",", "$", "value", ",", "...", "$", "types", ")", ";", "}" ]
@param scalar|array|object|null $value @return array<int, scalar|array|object|null> filtered $value
[ "@param", "scalar|array|object|null", "$value" ]
train
https://github.com/SignpostMarv/daft-object/blob/514886592b64986cc637040045f098335e27c037/src/DefinitionAssistant.php#L102-L129
SignpostMarv/daft-object
src/DefinitionAssistant.php
DefinitionAssistant.RegisterDaftObjectTypeFromTypeAndProps
protected static function RegisterDaftObjectTypeFromTypeAndProps( string $maybe, string $prop, string ...$props ) : string { array_unshift($props, $prop); $args = static::TypeAndGetterAndSetterClosureWithProps($maybe, ...$props); /** * @var array<int, string> */ $props = array_slice($args, 3); static::RegisterType($args[self::INT_ARRAY_INDEX_TYPE], $args[self::INT_ARRAY_INDEX_GETTER], $args[self::INT_ARRAY_INDEX_SETTER], ...$props); self::MaybeRegisterAdditionalTypes($args[self::INT_ARRAY_INDEX_TYPE]); return $maybe; }
php
protected static function RegisterDaftObjectTypeFromTypeAndProps( string $maybe, string $prop, string ...$props ) : string { array_unshift($props, $prop); $args = static::TypeAndGetterAndSetterClosureWithProps($maybe, ...$props); /** * @var array<int, string> */ $props = array_slice($args, 3); static::RegisterType($args[self::INT_ARRAY_INDEX_TYPE], $args[self::INT_ARRAY_INDEX_GETTER], $args[self::INT_ARRAY_INDEX_SETTER], ...$props); self::MaybeRegisterAdditionalTypes($args[self::INT_ARRAY_INDEX_TYPE]); return $maybe; }
[ "protected", "static", "function", "RegisterDaftObjectTypeFromTypeAndProps", "(", "string", "$", "maybe", ",", "string", "$", "prop", ",", "string", "...", "$", "props", ")", ":", "string", "{", "array_unshift", "(", "$", "props", ",", "$", "prop", ")", ";", "$", "args", "=", "static", "::", "TypeAndGetterAndSetterClosureWithProps", "(", "$", "maybe", ",", "...", "$", "props", ")", ";", "/**\n * @var array<int, string>\n */", "$", "props", "=", "array_slice", "(", "$", "args", ",", "3", ")", ";", "static", "::", "RegisterType", "(", "$", "args", "[", "self", "::", "INT_ARRAY_INDEX_TYPE", "]", ",", "$", "args", "[", "self", "::", "INT_ARRAY_INDEX_GETTER", "]", ",", "$", "args", "[", "self", "::", "INT_ARRAY_INDEX_SETTER", "]", ",", "...", "$", "props", ")", ";", "self", "::", "MaybeRegisterAdditionalTypes", "(", "$", "args", "[", "self", "::", "INT_ARRAY_INDEX_TYPE", "]", ")", ";", "return", "$", "maybe", ";", "}" ]
@psalm-param class-string<T> $maybe @psalm-return class-string<T>
[ "@psalm", "-", "param", "class", "-", "string<T", ">", "$maybe" ]
train
https://github.com/SignpostMarv/daft-object/blob/514886592b64986cc637040045f098335e27c037/src/DefinitionAssistant.php#L136-L155
SignpostMarv/daft-object
src/DefinitionAssistant.php
DefinitionAssistant.TypeAndGetterAndSetterClosureWithProps
private static function TypeAndGetterAndSetterClosureWithProps( string $type, string ...$props ) : array { /** * @psalm-var array{0:class-string<T>, 1:null|Closure(string):?string, 2:null|Closure(string):?string, 4:string} */ $out = array_merge( [ $type, static::SetterOrGetterClosure($type, self::BOOL_EXPECTING_GETTER, ...$props), static::SetterOrGetterClosure($type, self::BOOL_EXPECTING_SETTER, ...$props), ], $props ); return $out; }
php
private static function TypeAndGetterAndSetterClosureWithProps( string $type, string ...$props ) : array { /** * @psalm-var array{0:class-string<T>, 1:null|Closure(string):?string, 2:null|Closure(string):?string, 4:string} */ $out = array_merge( [ $type, static::SetterOrGetterClosure($type, self::BOOL_EXPECTING_GETTER, ...$props), static::SetterOrGetterClosure($type, self::BOOL_EXPECTING_SETTER, ...$props), ], $props ); return $out; }
[ "private", "static", "function", "TypeAndGetterAndSetterClosureWithProps", "(", "string", "$", "type", ",", "string", "...", "$", "props", ")", ":", "array", "{", "/**\n * @psalm-var array{0:class-string<T>, 1:null|Closure(string):?string, 2:null|Closure(string):?string, 4:string}\n */", "$", "out", "=", "array_merge", "(", "[", "$", "type", ",", "static", "::", "SetterOrGetterClosure", "(", "$", "type", ",", "self", "::", "BOOL_EXPECTING_GETTER", ",", "...", "$", "props", ")", ",", "static", "::", "SetterOrGetterClosure", "(", "$", "type", ",", "self", "::", "BOOL_EXPECTING_SETTER", ",", "...", "$", "props", ")", ",", "]", ",", "$", "props", ")", ";", "return", "$", "out", ";", "}" ]
@psalm-param class-string<T> $type @psalm-return array{0:class-string<T>, 1:null|Closure(string):?string, 2:null|Closure(string):?string, 4:string}
[ "@psalm", "-", "param", "class", "-", "string<T", ">", "$type" ]
train
https://github.com/SignpostMarv/daft-object/blob/514886592b64986cc637040045f098335e27c037/src/DefinitionAssistant.php#L172-L189
SignpostMarv/daft-object
src/DefinitionAssistant.php
DefinitionAssistant.MaybeThrowIfValueDoesNotMatchMultiTypedArrayValueArray
private static function MaybeThrowIfValueDoesNotMatchMultiTypedArrayValueArray( bool $autoTrimStrings, bool $throwIfNotUnique, array $value, string ...$types ) : array { $value = static::MaybeThrowIfNotArrayIntKeys($value); $value = static::MaybeThrowIfValueArrayDoesNotMatchTypes($value, ...$types); /** * @var (scalar|array|object|null)[] */ $value = static::MaybeRemapStringsToTrimmedStrings($value, $autoTrimStrings, ...$types); $initialCount = count($value); /** * @var array<int, scalar|array|object|null> */ $out = []; foreach ($value as $maybe) { if ( ! in_array($maybe, $out, true)) { $out[] = $maybe; } } if ($throwIfNotUnique && count($out) !== $initialCount) { throw new InvalidArgumentException( 'Argument 3 passed to ' . __METHOD__ . ' contained non-unique values!' ); } return $out; }
php
private static function MaybeThrowIfValueDoesNotMatchMultiTypedArrayValueArray( bool $autoTrimStrings, bool $throwIfNotUnique, array $value, string ...$types ) : array { $value = static::MaybeThrowIfNotArrayIntKeys($value); $value = static::MaybeThrowIfValueArrayDoesNotMatchTypes($value, ...$types); /** * @var (scalar|array|object|null)[] */ $value = static::MaybeRemapStringsToTrimmedStrings($value, $autoTrimStrings, ...$types); $initialCount = count($value); /** * @var array<int, scalar|array|object|null> */ $out = []; foreach ($value as $maybe) { if ( ! in_array($maybe, $out, true)) { $out[] = $maybe; } } if ($throwIfNotUnique && count($out) !== $initialCount) { throw new InvalidArgumentException( 'Argument 3 passed to ' . __METHOD__ . ' contained non-unique values!' ); } return $out; }
[ "private", "static", "function", "MaybeThrowIfValueDoesNotMatchMultiTypedArrayValueArray", "(", "bool", "$", "autoTrimStrings", ",", "bool", "$", "throwIfNotUnique", ",", "array", "$", "value", ",", "string", "...", "$", "types", ")", ":", "array", "{", "$", "value", "=", "static", "::", "MaybeThrowIfNotArrayIntKeys", "(", "$", "value", ")", ";", "$", "value", "=", "static", "::", "MaybeThrowIfValueArrayDoesNotMatchTypes", "(", "$", "value", ",", "...", "$", "types", ")", ";", "/**\n * @var (scalar|array|object|null)[]\n */", "$", "value", "=", "static", "::", "MaybeRemapStringsToTrimmedStrings", "(", "$", "value", ",", "$", "autoTrimStrings", ",", "...", "$", "types", ")", ";", "$", "initialCount", "=", "count", "(", "$", "value", ")", ";", "/**\n * @var array<int, scalar|array|object|null>\n */", "$", "out", "=", "[", "]", ";", "foreach", "(", "$", "value", "as", "$", "maybe", ")", "{", "if", "(", "!", "in_array", "(", "$", "maybe", ",", "$", "out", ",", "true", ")", ")", "{", "$", "out", "[", "]", "=", "$", "maybe", ";", "}", "}", "if", "(", "$", "throwIfNotUnique", "&&", "count", "(", "$", "out", ")", "!==", "$", "initialCount", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Argument 3 passed to '", ".", "__METHOD__", ".", "' contained non-unique values!'", ")", ";", "}", "return", "$", "out", ";", "}" ]
@param (scalar|array|object|null)[] $value @return array<int, scalar|array|object|null> filtered $value
[ "@param", "(", "scalar|array|object|null", ")", "[]", "$value" ]
train
https://github.com/SignpostMarv/daft-object/blob/514886592b64986cc637040045f098335e27c037/src/DefinitionAssistant.php#L196-L232
SignpostMarv/daft-object
src/DefinitionAssistant.php
DefinitionAssistant.MaybeThrowIfValueArrayDoesNotMatchTypes
private static function MaybeThrowIfValueArrayDoesNotMatchTypes( array $value, string ...$types ) : array { $initialCount = count($value); $value = array_filter( $value, /** * @param scalar|array|object|null $maybe */ function ($maybe) use ($types) : bool { if (is_object($maybe)) { foreach ($types as $maybeType) { if (is_a($maybe, $maybeType)) { return true; } } return false; } return in_array( gettype($maybe), $types, DefinitionAssistant::IN_ARRAY_STRICT_MODE ); } ); if (count($value) !== $initialCount) { throw new InvalidArgumentException( 'Argument 3 passed to ' . __METHOD__ . ' contained values that did not match the provided types!' ); } return $value; }
php
private static function MaybeThrowIfValueArrayDoesNotMatchTypes( array $value, string ...$types ) : array { $initialCount = count($value); $value = array_filter( $value, /** * @param scalar|array|object|null $maybe */ function ($maybe) use ($types) : bool { if (is_object($maybe)) { foreach ($types as $maybeType) { if (is_a($maybe, $maybeType)) { return true; } } return false; } return in_array( gettype($maybe), $types, DefinitionAssistant::IN_ARRAY_STRICT_MODE ); } ); if (count($value) !== $initialCount) { throw new InvalidArgumentException( 'Argument 3 passed to ' . __METHOD__ . ' contained values that did not match the provided types!' ); } return $value; }
[ "private", "static", "function", "MaybeThrowIfValueArrayDoesNotMatchTypes", "(", "array", "$", "value", ",", "string", "...", "$", "types", ")", ":", "array", "{", "$", "initialCount", "=", "count", "(", "$", "value", ")", ";", "$", "value", "=", "array_filter", "(", "$", "value", ",", "/**\n * @param scalar|array|object|null $maybe\n */", "function", "(", "$", "maybe", ")", "use", "(", "$", "types", ")", ":", "bool", "{", "if", "(", "is_object", "(", "$", "maybe", ")", ")", "{", "foreach", "(", "$", "types", "as", "$", "maybeType", ")", "{", "if", "(", "is_a", "(", "$", "maybe", ",", "$", "maybeType", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}", "return", "in_array", "(", "gettype", "(", "$", "maybe", ")", ",", "$", "types", ",", "DefinitionAssistant", "::", "IN_ARRAY_STRICT_MODE", ")", ";", "}", ")", ";", "if", "(", "count", "(", "$", "value", ")", "!==", "$", "initialCount", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Argument 3 passed to '", ".", "__METHOD__", ".", "' contained values that did not match the provided types!'", ")", ";", "}", "return", "$", "value", ";", "}" ]
@param array<int, scalar|array|object|null> $value @return array<int, scalar|array|object|null> filtered $value
[ "@param", "array<int", "scalar|array|object|null", ">", "$value" ]
train
https://github.com/SignpostMarv/daft-object/blob/514886592b64986cc637040045f098335e27c037/src/DefinitionAssistant.php#L262-L301
SignpostMarv/daft-object
src/DefinitionAssistant.php
DefinitionAssistant.MaybeRemapStringsToTrimmedStrings
private static function MaybeRemapStringsToTrimmedStrings( array $value, bool $autoTrimStrings, string ...$types ) : array { if ( $autoTrimStrings && in_array('string', $types, DefinitionAssistant::IN_ARRAY_STRICT_MODE) ) { $value = array_map( /** * @param scalar|array|object|null $maybe * * @return scalar|array|object|null */ function ($maybe) { return is_string($maybe) ? trim($maybe) : $maybe; }, $value ); } return $value; }
php
private static function MaybeRemapStringsToTrimmedStrings( array $value, bool $autoTrimStrings, string ...$types ) : array { if ( $autoTrimStrings && in_array('string', $types, DefinitionAssistant::IN_ARRAY_STRICT_MODE) ) { $value = array_map( /** * @param scalar|array|object|null $maybe * * @return scalar|array|object|null */ function ($maybe) { return is_string($maybe) ? trim($maybe) : $maybe; }, $value ); } return $value; }
[ "private", "static", "function", "MaybeRemapStringsToTrimmedStrings", "(", "array", "$", "value", ",", "bool", "$", "autoTrimStrings", ",", "string", "...", "$", "types", ")", ":", "array", "{", "if", "(", "$", "autoTrimStrings", "&&", "in_array", "(", "'string'", ",", "$", "types", ",", "DefinitionAssistant", "::", "IN_ARRAY_STRICT_MODE", ")", ")", "{", "$", "value", "=", "array_map", "(", "/**\n * @param scalar|array|object|null $maybe\n *\n * @return scalar|array|object|null\n */", "function", "(", "$", "maybe", ")", "{", "return", "is_string", "(", "$", "maybe", ")", "?", "trim", "(", "$", "maybe", ")", ":", "$", "maybe", ";", "}", ",", "$", "value", ")", ";", "}", "return", "$", "value", ";", "}" ]
@param array<int, scalar|array|object|null> $value @return array<int, scalar|array|object|null>
[ "@param", "array<int", "scalar|array|object|null", ">", "$value" ]
train
https://github.com/SignpostMarv/daft-object/blob/514886592b64986cc637040045f098335e27c037/src/DefinitionAssistant.php#L308-L331
krzysztofmazur/php-object-mapper
src/KrzysztofMazur/ObjectMapper/Mapping/Field/Field.php
Field.map
public function map($source, $target) { $this->writer->write($target, $this->reader->read($source)); }
php
public function map($source, $target) { $this->writer->write($target, $this->reader->read($source)); }
[ "public", "function", "map", "(", "$", "source", ",", "$", "target", ")", "{", "$", "this", "->", "writer", "->", "write", "(", "$", "target", ",", "$", "this", "->", "reader", "->", "read", "(", "$", "source", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/krzysztofmazur/php-object-mapper/blob/2c22acad9634cfe8e9a75d72e665d450ada8d4e3/src/KrzysztofMazur/ObjectMapper/Mapping/Field/Field.php#L58-L61
danrevah/shortify-punit
src/Verify/Verify.php
Verify.getChainedMockCounter
private function getChainedMockCounter($methods) { $mockReturnValues = ShortifyPunit::getReturnValues(); $mockResponse = $mockReturnValues[$this->mockedClass][$this->instanceId]; foreach ($methods as $method) { $methodName = key($method); $args = $method[$methodName]; $serializedArgs = serialize($args); if ( ! isset($mockResponse[$methodName][$serializedArgs])) { if ( ! isset($mockResponse[$methodName])) { break; } // try to finding matching Hamcrest-API Function (anything(), equalTo()) $serializedArgs = static::checkMatchingArguments($mockResponse[$methodName], $args); if (is_null($serializedArgs)) { break; } } $mockResponse = $mockResponse[$methodName][$serializedArgs]; } return isset($mockResponse['response']['counter']) ? $mockResponse['response']['counter'] : 0; }
php
private function getChainedMockCounter($methods) { $mockReturnValues = ShortifyPunit::getReturnValues(); $mockResponse = $mockReturnValues[$this->mockedClass][$this->instanceId]; foreach ($methods as $method) { $methodName = key($method); $args = $method[$methodName]; $serializedArgs = serialize($args); if ( ! isset($mockResponse[$methodName][$serializedArgs])) { if ( ! isset($mockResponse[$methodName])) { break; } // try to finding matching Hamcrest-API Function (anything(), equalTo()) $serializedArgs = static::checkMatchingArguments($mockResponse[$methodName], $args); if (is_null($serializedArgs)) { break; } } $mockResponse = $mockResponse[$methodName][$serializedArgs]; } return isset($mockResponse['response']['counter']) ? $mockResponse['response']['counter'] : 0; }
[ "private", "function", "getChainedMockCounter", "(", "$", "methods", ")", "{", "$", "mockReturnValues", "=", "ShortifyPunit", "::", "getReturnValues", "(", ")", ";", "$", "mockResponse", "=", "$", "mockReturnValues", "[", "$", "this", "->", "mockedClass", "]", "[", "$", "this", "->", "instanceId", "]", ";", "foreach", "(", "$", "methods", "as", "$", "method", ")", "{", "$", "methodName", "=", "key", "(", "$", "method", ")", ";", "$", "args", "=", "$", "method", "[", "$", "methodName", "]", ";", "$", "serializedArgs", "=", "serialize", "(", "$", "args", ")", ";", "if", "(", "!", "isset", "(", "$", "mockResponse", "[", "$", "methodName", "]", "[", "$", "serializedArgs", "]", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "mockResponse", "[", "$", "methodName", "]", ")", ")", "{", "break", ";", "}", "// try to finding matching Hamcrest-API Function (anything(), equalTo())", "$", "serializedArgs", "=", "static", "::", "checkMatchingArguments", "(", "$", "mockResponse", "[", "$", "methodName", "]", ",", "$", "args", ")", ";", "if", "(", "is_null", "(", "$", "serializedArgs", ")", ")", "{", "break", ";", "}", "}", "$", "mockResponse", "=", "$", "mockResponse", "[", "$", "methodName", "]", "[", "$", "serializedArgs", "]", ";", "}", "return", "isset", "(", "$", "mockResponse", "[", "'response'", "]", "[", "'counter'", "]", ")", "?", "$", "mockResponse", "[", "'response'", "]", "[", "'counter'", "]", ":", "0", ";", "}" ]
Getting the call counter for the specific chained stubbing methods @param $methods @return int
[ "Getting", "the", "call", "counter", "for", "the", "specific", "chained", "stubbing", "methods" ]
train
https://github.com/danrevah/shortify-punit/blob/cedd08f31de8e7409a07d2630701ef4e924cc5f0/src/Verify/Verify.php#L121-L151
tylerjuniorcollege/slim-layout
src/Layout.php
Layout.setLayout
public function setLayout($template) { $layout = $this->getTemplatePathname($template); if(!is_file($layout)) { throw new \RuntimeException("Layout file `$template` does not exist."); } else { $this->layout = $template; } }
php
public function setLayout($template) { $layout = $this->getTemplatePathname($template); if(!is_file($layout)) { throw new \RuntimeException("Layout file `$template` does not exist."); } else { $this->layout = $template; } }
[ "public", "function", "setLayout", "(", "$", "template", ")", "{", "$", "layout", "=", "$", "this", "->", "getTemplatePathname", "(", "$", "template", ")", ";", "if", "(", "!", "is_file", "(", "$", "layout", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "\"Layout file `$template` does not exist.\"", ")", ";", "}", "else", "{", "$", "this", "->", "layout", "=", "$", "template", ";", "}", "}" ]
Layout Configuration Getters and Setters
[ "Layout", "Configuration", "Getters", "and", "Setters" ]
train
https://github.com/tylerjuniorcollege/slim-layout/blob/60939b9f7502b90bf319fe741a747dd40ef61bfe/src/Layout.php#L40-L47
tylerjuniorcollege/slim-layout
src/Layout.php
Layout.render
public function render($template, $data = array()) { if(!is_null($this->layout) && $this->enabled === TRUE) { // Render the layout!! $this->setLayoutData('content', parent::render($template, array_merge($this->layoutData, (array)$data))); $this->setLayoutData('js', $this->jsAssets->render()); $this->setLayoutData('css', $this->cssAssets->render()); $this->setLayoutData('title', $this->titleParts->render()); return parent::render($this->layout, $this->layoutData); } else { return parent::render($template, $data); } }
php
public function render($template, $data = array()) { if(!is_null($this->layout) && $this->enabled === TRUE) { // Render the layout!! $this->setLayoutData('content', parent::render($template, array_merge($this->layoutData, (array)$data))); $this->setLayoutData('js', $this->jsAssets->render()); $this->setLayoutData('css', $this->cssAssets->render()); $this->setLayoutData('title', $this->titleParts->render()); return parent::render($this->layout, $this->layoutData); } else { return parent::render($template, $data); } }
[ "public", "function", "render", "(", "$", "template", ",", "$", "data", "=", "array", "(", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "layout", ")", "&&", "$", "this", "->", "enabled", "===", "TRUE", ")", "{", "// Render the layout!!", "$", "this", "->", "setLayoutData", "(", "'content'", ",", "parent", "::", "render", "(", "$", "template", ",", "array_merge", "(", "$", "this", "->", "layoutData", ",", "(", "array", ")", "$", "data", ")", ")", ")", ";", "$", "this", "->", "setLayoutData", "(", "'js'", ",", "$", "this", "->", "jsAssets", "->", "render", "(", ")", ")", ";", "$", "this", "->", "setLayoutData", "(", "'css'", ",", "$", "this", "->", "cssAssets", "->", "render", "(", ")", ")", ";", "$", "this", "->", "setLayoutData", "(", "'title'", ",", "$", "this", "->", "titleParts", "->", "render", "(", ")", ")", ";", "return", "parent", "::", "render", "(", "$", "this", "->", "layout", ",", "$", "this", "->", "layoutData", ")", ";", "}", "else", "{", "return", "parent", "::", "render", "(", "$", "template", ",", "$", "data", ")", ";", "}", "}" ]
Overloading render() function to inject the layout.
[ "Overloading", "render", "()", "function", "to", "inject", "the", "layout", "." ]
train
https://github.com/tylerjuniorcollege/slim-layout/blob/60939b9f7502b90bf319fe741a747dd40ef61bfe/src/Layout.php#L169-L180
tylerjuniorcollege/slim-layout
src/Layout.php
Layout.renderJson
public function renderJson($data, $status = 200) { $app = \Slim\Slim::getInstance(); $app->response()->status($status); $app->response()->header('Content-Type', 'application/json'); $body = json_encode($data); $app->response()->body($body); $app->stop(); }
php
public function renderJson($data, $status = 200) { $app = \Slim\Slim::getInstance(); $app->response()->status($status); $app->response()->header('Content-Type', 'application/json'); $body = json_encode($data); $app->response()->body($body); $app->stop(); }
[ "public", "function", "renderJson", "(", "$", "data", ",", "$", "status", "=", "200", ")", "{", "$", "app", "=", "\\", "Slim", "\\", "Slim", "::", "getInstance", "(", ")", ";", "$", "app", "->", "response", "(", ")", "->", "status", "(", "$", "status", ")", ";", "$", "app", "->", "response", "(", ")", "->", "header", "(", "'Content-Type'", ",", "'application/json'", ")", ";", "$", "body", "=", "json_encode", "(", "$", "data", ")", ";", "$", "app", "->", "response", "(", ")", "->", "body", "(", "$", "body", ")", ";", "$", "app", "->", "stop", "(", ")", ";", "}" ]
New function for pre-rendering JSON without having to call disableLayout AND other rendering code.
[ "New", "function", "for", "pre", "-", "rendering", "JSON", "without", "having", "to", "call", "disableLayout", "AND", "other", "rendering", "code", "." ]
train
https://github.com/tylerjuniorcollege/slim-layout/blob/60939b9f7502b90bf319fe741a747dd40ef61bfe/src/Layout.php#L183-L192
tylerjuniorcollege/slim-layout
src/Layout.php
Layout.partial
public function partial($template, $data = array()) { return parent::render($template, array_merge($this->layoutData, (array)$data)); }
php
public function partial($template, $data = array()) { return parent::render($template, array_merge($this->layoutData, (array)$data)); }
[ "public", "function", "partial", "(", "$", "template", ",", "$", "data", "=", "array", "(", ")", ")", "{", "return", "parent", "::", "render", "(", "$", "template", ",", "array_merge", "(", "$", "this", "->", "layoutData", ",", "(", "array", ")", "$", "data", ")", ")", ";", "}" ]
Function for rendering partial content. This WILL inject the layout parameters.
[ "Function", "for", "rendering", "partial", "content", ".", "This", "WILL", "inject", "the", "layout", "parameters", "." ]
train
https://github.com/tylerjuniorcollege/slim-layout/blob/60939b9f7502b90bf319fe741a747dd40ef61bfe/src/Layout.php#L195-L197
fsi-open/doctrine-extensions-bundle
Form/Type/FSi/FileType.php
FileType.buildView
public function buildView(FormView $view, FormInterface $form, array $options) { if (!$form->getData() instanceof FSiFile) { return; } if (isset($options['file_url'])) { $fileUrlCallable = $options['file_url']; $view->vars['file_url'] = $fileUrlCallable($this->urlGenerator, $form); } else { $view->vars['file_url'] = $this->filePathResolver->fileUrl($form->getData()); } }
php
public function buildView(FormView $view, FormInterface $form, array $options) { if (!$form->getData() instanceof FSiFile) { return; } if (isset($options['file_url'])) { $fileUrlCallable = $options['file_url']; $view->vars['file_url'] = $fileUrlCallable($this->urlGenerator, $form); } else { $view->vars['file_url'] = $this->filePathResolver->fileUrl($form->getData()); } }
[ "public", "function", "buildView", "(", "FormView", "$", "view", ",", "FormInterface", "$", "form", ",", "array", "$", "options", ")", "{", "if", "(", "!", "$", "form", "->", "getData", "(", ")", "instanceof", "FSiFile", ")", "{", "return", ";", "}", "if", "(", "isset", "(", "$", "options", "[", "'file_url'", "]", ")", ")", "{", "$", "fileUrlCallable", "=", "$", "options", "[", "'file_url'", "]", ";", "$", "view", "->", "vars", "[", "'file_url'", "]", "=", "$", "fileUrlCallable", "(", "$", "this", "->", "urlGenerator", ",", "$", "form", ")", ";", "}", "else", "{", "$", "view", "->", "vars", "[", "'file_url'", "]", "=", "$", "this", "->", "filePathResolver", "->", "fileUrl", "(", "$", "form", "->", "getData", "(", ")", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/fsi-open/doctrine-extensions-bundle/blob/1b9c01e0b216b2c1b2af087de233abbf3c84b9fe/Form/Type/FSi/FileType.php#L80-L92
fsi-open/doctrine-extensions-bundle
Form/Type/FSi/FileType.php
FileType.configureOptions
public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'data_class' => FSiFile::class, 'constraints' => [new File()] ]); $resolver->setDefined('file_url'); $resolver->setAllowedTypes('file_url', ['null', 'callable']); }
php
public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ 'data_class' => FSiFile::class, 'constraints' => [new File()] ]); $resolver->setDefined('file_url'); $resolver->setAllowedTypes('file_url', ['null', 'callable']); }
[ "public", "function", "configureOptions", "(", "OptionsResolver", "$", "resolver", ")", "{", "$", "resolver", "->", "setDefaults", "(", "[", "'data_class'", "=>", "FSiFile", "::", "class", ",", "'constraints'", "=>", "[", "new", "File", "(", ")", "]", "]", ")", ";", "$", "resolver", "->", "setDefined", "(", "'file_url'", ")", ";", "$", "resolver", "->", "setAllowedTypes", "(", "'file_url'", ",", "[", "'null'", ",", "'callable'", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/fsi-open/doctrine-extensions-bundle/blob/1b9c01e0b216b2c1b2af087de233abbf3c84b9fe/Form/Type/FSi/FileType.php#L105-L113
ClanCats/Core
src/classes/CCRoute.php
CCRoute.factory
public static function factory( $callback, $params = array() ) { $route = new static(); $route->callback = $callback; $route->params = $params; return $route; }
php
public static function factory( $callback, $params = array() ) { $route = new static(); $route->callback = $callback; $route->params = $params; return $route; }
[ "public", "static", "function", "factory", "(", "$", "callback", ",", "$", "params", "=", "array", "(", ")", ")", "{", "$", "route", "=", "new", "static", "(", ")", ";", "$", "route", "->", "callback", "=", "$", "callback", ";", "$", "route", "->", "params", "=", "$", "params", ";", "return", "$", "route", ";", "}" ]
static route factory @param callback $callback @param array $params @return CCRoute
[ "static", "route", "factory" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCRoute.php#L22-L27
redaigbaria/oauth2
src/Util/RedirectUri.php
RedirectUri.make
public static function make($uri, $params = [], $queryDelimeter = '?') { $uri .= (strstr($uri, $queryDelimeter) === false) ? $queryDelimeter : '&'; return $uri.http_build_query($params); }
php
public static function make($uri, $params = [], $queryDelimeter = '?') { $uri .= (strstr($uri, $queryDelimeter) === false) ? $queryDelimeter : '&'; return $uri.http_build_query($params); }
[ "public", "static", "function", "make", "(", "$", "uri", ",", "$", "params", "=", "[", "]", ",", "$", "queryDelimeter", "=", "'?'", ")", "{", "$", "uri", ".=", "(", "strstr", "(", "$", "uri", ",", "$", "queryDelimeter", ")", "===", "false", ")", "?", "$", "queryDelimeter", ":", "'&'", ";", "return", "$", "uri", ".", "http_build_query", "(", "$", "params", ")", ";", "}" ]
Generate a new redirect uri @param string $uri The base URI @param array $params The query string parameters @param string $queryDelimeter The query string delimeter (default: "?") @return string The updated URI
[ "Generate", "a", "new", "redirect", "uri" ]
train
https://github.com/redaigbaria/oauth2/blob/54cca4aaaff6a095cbf1c8010f2fe2cc7de4e45a/src/Util/RedirectUri.php#L28-L33
VincentChalnot/SidusEAVFilterBundle
Filter/Type/AbstractSimpleFilterType.php
AbstractSimpleFilterType.handleData
public function handleData(QueryHandlerInterface $queryHandler, FilterInterface $filter, $data): void { if (!$queryHandler instanceof EAVQueryHandlerInterface) { throw new BadQueryHandlerException($queryHandler, EAVQueryHandlerInterface::class); } if (!$queryHandler->isEAVFilter($filter)) { $this->fallbackFilterType->handleData($queryHandler, $filter, $data); return; } if ($this->isEmpty($data)) { return; } $eavQb = new EAVQueryBuilder($queryHandler->getQueryBuilder(), $queryHandler->getAlias()); $eavQb->setContext($queryHandler->getQueryContext()); $dqlHandlers = []; foreach ($filter->getAttributes() as $attributePath) { $attributeQb = $queryHandler->getEAVAttributeQueryBuilder($eavQb, $attributePath); $dqlHandlers[] = $this->applyAttributeQueryBuilder($attributeQb, $data); } if (0 < \count($dqlHandlers)) { $eavQb->apply($eavQb->getOr($dqlHandlers)); } }
php
public function handleData(QueryHandlerInterface $queryHandler, FilterInterface $filter, $data): void { if (!$queryHandler instanceof EAVQueryHandlerInterface) { throw new BadQueryHandlerException($queryHandler, EAVQueryHandlerInterface::class); } if (!$queryHandler->isEAVFilter($filter)) { $this->fallbackFilterType->handleData($queryHandler, $filter, $data); return; } if ($this->isEmpty($data)) { return; } $eavQb = new EAVQueryBuilder($queryHandler->getQueryBuilder(), $queryHandler->getAlias()); $eavQb->setContext($queryHandler->getQueryContext()); $dqlHandlers = []; foreach ($filter->getAttributes() as $attributePath) { $attributeQb = $queryHandler->getEAVAttributeQueryBuilder($eavQb, $attributePath); $dqlHandlers[] = $this->applyAttributeQueryBuilder($attributeQb, $data); } if (0 < \count($dqlHandlers)) { $eavQb->apply($eavQb->getOr($dqlHandlers)); } }
[ "public", "function", "handleData", "(", "QueryHandlerInterface", "$", "queryHandler", ",", "FilterInterface", "$", "filter", ",", "$", "data", ")", ":", "void", "{", "if", "(", "!", "$", "queryHandler", "instanceof", "EAVQueryHandlerInterface", ")", "{", "throw", "new", "BadQueryHandlerException", "(", "$", "queryHandler", ",", "EAVQueryHandlerInterface", "::", "class", ")", ";", "}", "if", "(", "!", "$", "queryHandler", "->", "isEAVFilter", "(", "$", "filter", ")", ")", "{", "$", "this", "->", "fallbackFilterType", "->", "handleData", "(", "$", "queryHandler", ",", "$", "filter", ",", "$", "data", ")", ";", "return", ";", "}", "if", "(", "$", "this", "->", "isEmpty", "(", "$", "data", ")", ")", "{", "return", ";", "}", "$", "eavQb", "=", "new", "EAVQueryBuilder", "(", "$", "queryHandler", "->", "getQueryBuilder", "(", ")", ",", "$", "queryHandler", "->", "getAlias", "(", ")", ")", ";", "$", "eavQb", "->", "setContext", "(", "$", "queryHandler", "->", "getQueryContext", "(", ")", ")", ";", "$", "dqlHandlers", "=", "[", "]", ";", "foreach", "(", "$", "filter", "->", "getAttributes", "(", ")", "as", "$", "attributePath", ")", "{", "$", "attributeQb", "=", "$", "queryHandler", "->", "getEAVAttributeQueryBuilder", "(", "$", "eavQb", ",", "$", "attributePath", ")", ";", "$", "dqlHandlers", "[", "]", "=", "$", "this", "->", "applyAttributeQueryBuilder", "(", "$", "attributeQb", ",", "$", "data", ")", ";", "}", "if", "(", "0", "<", "\\", "count", "(", "$", "dqlHandlers", ")", ")", "{", "$", "eavQb", "->", "apply", "(", "$", "eavQb", "->", "getOr", "(", "$", "dqlHandlers", ")", ")", ";", "}", "}" ]
{@inheritdoc} @throws \LogicException @throws \UnexpectedValueException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/VincentChalnot/SidusEAVFilterBundle/blob/25a9e0495fae30cb96ecded56c50cf7fe70c9032/Filter/Type/AbstractSimpleFilterType.php#L25-L50
webforge-labs/psc-cms
lib/Psc/Inflector.php
Inflector.propertyName
public function propertyName($className) { if (!is_string($className) || mb_strpos($className, '\\') !== FALSE) { throw new \InvalidArgumentException(sprintf("ClassName %s kann nicht zu propertyName umgewandelt werden. Er muss ein String sein und darf nur der ClassName sein", \Psc\Code\Code::varInfo($className))); } // 1. Fall: Klasse ist CamelCase. wichtig ist hierbei dass das erste a klein ist if (Preg::match($className, '/^[A-Z]{1}[a-z]{1}/') > 0) { return lcfirst($className); } // 2. Fall: Klassename ist eine Abkürzung. Z. B. OID (aka: der ganze String sind Großbuchstaben) if (Preg::match($className, '/^[A-Z]+$/')) { return mb_strtolower($className); } // 3. Fall: KlassenName ist mixed sowas wie OIDMeta // teile auf in m[1] = 'OID' m[2] = 'Meta' $m = array(); if (Preg::match($className, '/^([A-Z]+)([A-Z]{1}[a-z]{1}.*)$/', $m) > 0) { return mb_strtolower($m[1]).$m[2]; } throw new \RuntimeException(sprintf("Kein matching Case für ClassName '%s'", $className)); }
php
public function propertyName($className) { if (!is_string($className) || mb_strpos($className, '\\') !== FALSE) { throw new \InvalidArgumentException(sprintf("ClassName %s kann nicht zu propertyName umgewandelt werden. Er muss ein String sein und darf nur der ClassName sein", \Psc\Code\Code::varInfo($className))); } // 1. Fall: Klasse ist CamelCase. wichtig ist hierbei dass das erste a klein ist if (Preg::match($className, '/^[A-Z]{1}[a-z]{1}/') > 0) { return lcfirst($className); } // 2. Fall: Klassename ist eine Abkürzung. Z. B. OID (aka: der ganze String sind Großbuchstaben) if (Preg::match($className, '/^[A-Z]+$/')) { return mb_strtolower($className); } // 3. Fall: KlassenName ist mixed sowas wie OIDMeta // teile auf in m[1] = 'OID' m[2] = 'Meta' $m = array(); if (Preg::match($className, '/^([A-Z]+)([A-Z]{1}[a-z]{1}.*)$/', $m) > 0) { return mb_strtolower($m[1]).$m[2]; } throw new \RuntimeException(sprintf("Kein matching Case für ClassName '%s'", $className)); }
[ "public", "function", "propertyName", "(", "$", "className", ")", "{", "if", "(", "!", "is_string", "(", "$", "className", ")", "||", "mb_strpos", "(", "$", "className", ",", "'\\\\'", ")", "!==", "FALSE", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "\"ClassName %s kann nicht zu propertyName umgewandelt werden. Er muss ein String sein und darf nur der ClassName sein\"", ",", "\\", "Psc", "\\", "Code", "\\", "Code", "::", "varInfo", "(", "$", "className", ")", ")", ")", ";", "}", "// 1. Fall: Klasse ist CamelCase. wichtig ist hierbei dass das erste a klein ist", "if", "(", "Preg", "::", "match", "(", "$", "className", ",", "'/^[A-Z]{1}[a-z]{1}/'", ")", ">", "0", ")", "{", "return", "lcfirst", "(", "$", "className", ")", ";", "}", "// 2. Fall: Klassename ist eine Abkürzung. Z. B. OID (aka: der ganze String sind Großbuchstaben)", "if", "(", "Preg", "::", "match", "(", "$", "className", ",", "'/^[A-Z]+$/'", ")", ")", "{", "return", "mb_strtolower", "(", "$", "className", ")", ";", "}", "// 3. Fall: KlassenName ist mixed sowas wie OIDMeta", "// teile auf in m[1] = 'OID' m[2] = 'Meta'", "$", "m", "=", "array", "(", ")", ";", "if", "(", "Preg", "::", "match", "(", "$", "className", ",", "'/^([A-Z]+)([A-Z]{1}[a-z]{1}.*)$/'", ",", "$", "m", ")", ">", "0", ")", "{", "return", "mb_strtolower", "(", "$", "m", "[", "1", "]", ")", ".", "$", "m", "[", "2", "]", ";", "}", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "\"Kein matching Case für ClassName '%s'\",", " ", "c", "lassName)", ")", ";", "", "}" ]
Gibt den (lcfirst) LowerCase Name für einen Klassennamen zurück OID => oid OIDMeta => oidMeta SomeClassName => someClassName @param $className ohne Namespace
[ "Gibt", "den", "(", "lcfirst", ")", "LowerCase", "Name", "für", "einen", "Klassennamen", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/Inflector.php#L98-L121
ARCANEDEV/Agent
src/Agent.php
Agent.getDetectionRulesExtended
public function getDetectionRulesExtended() { static $rules; if ( ! $rules) { $rules = $this->mergeRules( static::$additionalDevices, // NEW static::getPhoneDevices(), static::getTabletDevices(), static::getOperatingSystems(), static::$additionalOperatingSystems, // NEW static::getBrowsers(), static::$additionalBrowsers, // NEW static::getUtilities() ); } return $rules; }
php
public function getDetectionRulesExtended() { static $rules; if ( ! $rules) { $rules = $this->mergeRules( static::$additionalDevices, // NEW static::getPhoneDevices(), static::getTabletDevices(), static::getOperatingSystems(), static::$additionalOperatingSystems, // NEW static::getBrowsers(), static::$additionalBrowsers, // NEW static::getUtilities() ); } return $rules; }
[ "public", "function", "getDetectionRulesExtended", "(", ")", "{", "static", "$", "rules", ";", "if", "(", "!", "$", "rules", ")", "{", "$", "rules", "=", "$", "this", "->", "mergeRules", "(", "static", "::", "$", "additionalDevices", ",", "// NEW", "static", "::", "getPhoneDevices", "(", ")", ",", "static", "::", "getTabletDevices", "(", ")", ",", "static", "::", "getOperatingSystems", "(", ")", ",", "static", "::", "$", "additionalOperatingSystems", ",", "// NEW", "static", "::", "getBrowsers", "(", ")", ",", "static", "::", "$", "additionalBrowsers", ",", "// NEW", "static", "::", "getUtilities", "(", ")", ")", ";", "}", "return", "$", "rules", ";", "}" ]
Get all detection rules. These rules include the additional platforms and browsers. @return array
[ "Get", "all", "detection", "rules", ".", "These", "rules", "include", "the", "additional", "platforms", "and", "browsers", "." ]
train
https://github.com/ARCANEDEV/Agent/blob/74a3aff7830463d3cc31afdaf6ec89f2e5bf3468/src/Agent.php#L121-L139
ARCANEDEV/Agent
src/Agent.php
Agent.device
public function device($userAgent = null) { // Get device rules $rules = $this->mergeRules( static::$additionalDevices, // NEW static::$phoneDevices, static::$tabletDevices, static::$utilities ); return $this->findDetectionRulesAgainstUA($rules, $userAgent); }
php
public function device($userAgent = null) { // Get device rules $rules = $this->mergeRules( static::$additionalDevices, // NEW static::$phoneDevices, static::$tabletDevices, static::$utilities ); return $this->findDetectionRulesAgainstUA($rules, $userAgent); }
[ "public", "function", "device", "(", "$", "userAgent", "=", "null", ")", "{", "// Get device rules", "$", "rules", "=", "$", "this", "->", "mergeRules", "(", "static", "::", "$", "additionalDevices", ",", "// NEW", "static", "::", "$", "phoneDevices", ",", "static", "::", "$", "tabletDevices", ",", "static", "::", "$", "utilities", ")", ";", "return", "$", "this", "->", "findDetectionRulesAgainstUA", "(", "$", "rules", ",", "$", "userAgent", ")", ";", "}" ]
Get the device name. @param string|null $userAgent @return string
[ "Get", "the", "device", "name", "." ]
train
https://github.com/ARCANEDEV/Agent/blob/74a3aff7830463d3cc31afdaf6ec89f2e5bf3468/src/Agent.php#L160-L171
ARCANEDEV/Agent
src/Agent.php
Agent.browser
public function browser($userAgent = null) { // Get browser rules $rules = $this->mergeRules( static::$additionalBrowsers, // NEW static::$browsers ); return $this->findDetectionRulesAgainstUA($rules, $userAgent); }
php
public function browser($userAgent = null) { // Get browser rules $rules = $this->mergeRules( static::$additionalBrowsers, // NEW static::$browsers ); return $this->findDetectionRulesAgainstUA($rules, $userAgent); }
[ "public", "function", "browser", "(", "$", "userAgent", "=", "null", ")", "{", "// Get browser rules", "$", "rules", "=", "$", "this", "->", "mergeRules", "(", "static", "::", "$", "additionalBrowsers", ",", "// NEW", "static", "::", "$", "browsers", ")", ";", "return", "$", "this", "->", "findDetectionRulesAgainstUA", "(", "$", "rules", ",", "$", "userAgent", ")", ";", "}" ]
Get the browser name. @param string|null $userAgent @return string
[ "Get", "the", "browser", "name", "." ]
train
https://github.com/ARCANEDEV/Agent/blob/74a3aff7830463d3cc31afdaf6ec89f2e5bf3468/src/Agent.php#L180-L189
ARCANEDEV/Agent
src/Agent.php
Agent.robot
public function robot($userAgent = null) { return $this->isRobot($userAgent) ? ucfirst($this->getCrawlerDetector()->getMatches()) : false; }
php
public function robot($userAgent = null) { return $this->isRobot($userAgent) ? ucfirst($this->getCrawlerDetector()->getMatches()) : false; }
[ "public", "function", "robot", "(", "$", "userAgent", "=", "null", ")", "{", "return", "$", "this", "->", "isRobot", "(", "$", "userAgent", ")", "?", "ucfirst", "(", "$", "this", "->", "getCrawlerDetector", "(", ")", "->", "getMatches", "(", ")", ")", ":", "false", ";", "}" ]
Get the robot name. @param string|null $userAgent @return string
[ "Get", "the", "robot", "name", "." ]
train
https://github.com/ARCANEDEV/Agent/blob/74a3aff7830463d3cc31afdaf6ec89f2e5bf3468/src/Agent.php#L198-L203
ARCANEDEV/Agent
src/Agent.php
Agent.platform
public function platform($userAgent = null) { // Get platform rules $rules = $this->mergeRules( static::$operatingSystems, static::$additionalOperatingSystems // NEW ); return $this->findDetectionRulesAgainstUA($rules, $userAgent); }
php
public function platform($userAgent = null) { // Get platform rules $rules = $this->mergeRules( static::$operatingSystems, static::$additionalOperatingSystems // NEW ); return $this->findDetectionRulesAgainstUA($rules, $userAgent); }
[ "public", "function", "platform", "(", "$", "userAgent", "=", "null", ")", "{", "// Get platform rules", "$", "rules", "=", "$", "this", "->", "mergeRules", "(", "static", "::", "$", "operatingSystems", ",", "static", "::", "$", "additionalOperatingSystems", "// NEW", ")", ";", "return", "$", "this", "->", "findDetectionRulesAgainstUA", "(", "$", "rules", ",", "$", "userAgent", ")", ";", "}" ]
Get the platform name. @param string|null $userAgent @return string
[ "Get", "the", "platform", "name", "." ]
train
https://github.com/ARCANEDEV/Agent/blob/74a3aff7830463d3cc31afdaf6ec89f2e5bf3468/src/Agent.php#L212-L221
ARCANEDEV/Agent
src/Agent.php
Agent.version
public function version($propertyName, $type = self::VERSION_TYPE_STRING) { $check = key(static::$additionalProperties); // Check if the additional properties have been added already if ( ! array_key_exists($check, static::$properties)) { // TODO: why is mergeRules not working here? static::$properties = array_merge( static::$properties, static::$additionalProperties ); } return parent::version($propertyName, $type); }
php
public function version($propertyName, $type = self::VERSION_TYPE_STRING) { $check = key(static::$additionalProperties); // Check if the additional properties have been added already if ( ! array_key_exists($check, static::$properties)) { // TODO: why is mergeRules not working here? static::$properties = array_merge( static::$properties, static::$additionalProperties ); } return parent::version($propertyName, $type); }
[ "public", "function", "version", "(", "$", "propertyName", ",", "$", "type", "=", "self", "::", "VERSION_TYPE_STRING", ")", "{", "$", "check", "=", "key", "(", "static", "::", "$", "additionalProperties", ")", ";", "// Check if the additional properties have been added already", "if", "(", "!", "array_key_exists", "(", "$", "check", ",", "static", "::", "$", "properties", ")", ")", "{", "// TODO: why is mergeRules not working here?", "static", "::", "$", "properties", "=", "array_merge", "(", "static", "::", "$", "properties", ",", "static", "::", "$", "additionalProperties", ")", ";", "}", "return", "parent", "::", "version", "(", "$", "propertyName", ",", "$", "type", ")", ";", "}" ]
Check the version of the given property in the User-Agent. Will return a float number. (eg. 2_0 will return 2.0, 4.3.1 will return 4.31) @param string $propertyName The name of the property. See self::getProperties() array keys for all possible properties. @param string $type Either self::VERSION_TYPE_STRING to get a string value or self::VERSION_TYPE_FLOAT indicating a float value. This parameter is optional and defaults to self::VERSION_TYPE_STRING. Passing an invalid parameter will default to the this type as well. @return string|float The version of the property we are trying to extract.
[ "Check", "the", "version", "of", "the", "given", "property", "in", "the", "User", "-", "Agent", ".", "Will", "return", "a", "float", "number", ".", "(", "eg", ".", "2_0", "will", "return", "2", ".", "0", "4", ".", "3", ".", "1", "will", "return", "4", ".", "31", ")" ]
train
https://github.com/ARCANEDEV/Agent/blob/74a3aff7830463d3cc31afdaf6ec89f2e5bf3468/src/Agent.php#L294-L308
ARCANEDEV/Agent
src/Agent.php
Agent.mergeRules
protected function mergeRules(...$rulesGroups) { $merged = []; foreach ($rulesGroups as $rules) { foreach ($rules as $key => $value) { if (empty($merged[$key])) $merged[$key] = $value; elseif (is_array($merged[$key])) $merged[$key][] = $value; else $merged[$key] .= '|' . $value; } } return $merged; }
php
protected function mergeRules(...$rulesGroups) { $merged = []; foreach ($rulesGroups as $rules) { foreach ($rules as $key => $value) { if (empty($merged[$key])) $merged[$key] = $value; elseif (is_array($merged[$key])) $merged[$key][] = $value; else $merged[$key] .= '|' . $value; } } return $merged; }
[ "protected", "function", "mergeRules", "(", "...", "$", "rulesGroups", ")", "{", "$", "merged", "=", "[", "]", ";", "foreach", "(", "$", "rulesGroups", "as", "$", "rules", ")", "{", "foreach", "(", "$", "rules", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "merged", "[", "$", "key", "]", ")", ")", "$", "merged", "[", "$", "key", "]", "=", "$", "value", ";", "elseif", "(", "is_array", "(", "$", "merged", "[", "$", "key", "]", ")", ")", "$", "merged", "[", "$", "key", "]", "[", "]", "=", "$", "value", ";", "else", "$", "merged", "[", "$", "key", "]", ".=", "'|'", ".", "$", "value", ";", "}", "}", "return", "$", "merged", ";", "}" ]
Merge multiple rules into one array. @param array $rulesGroups @return array
[ "Merge", "multiple", "rules", "into", "one", "array", "." ]
train
https://github.com/ARCANEDEV/Agent/blob/74a3aff7830463d3cc31afdaf6ec89f2e5bf3468/src/Agent.php#L359-L375
picamator/CacheManager
src/Data/EventBuilder.php
EventBuilder.setOperationResult
public function setOperationResult($operationResult) : EventBuilderInterface { if (!is_null($operationResult) && !is_bool($operationResult) && !is_a($operationResult, '\Picamator\CacheManager\Api\Data\SearchResultInterface') ) { throw new InvalidArgumentException('Invalid $operationResult type. It should be null, boolean or SearchResultInterface.'); } // convert boolean to scalar object to prevent null-true-false problem if (is_bool($operationResult)) { $operationResult = (object) $operationResult; } $this->data['operationResult'] = $operationResult; return $this; }
php
public function setOperationResult($operationResult) : EventBuilderInterface { if (!is_null($operationResult) && !is_bool($operationResult) && !is_a($operationResult, '\Picamator\CacheManager\Api\Data\SearchResultInterface') ) { throw new InvalidArgumentException('Invalid $operationResult type. It should be null, boolean or SearchResultInterface.'); } // convert boolean to scalar object to prevent null-true-false problem if (is_bool($operationResult)) { $operationResult = (object) $operationResult; } $this->data['operationResult'] = $operationResult; return $this; }
[ "public", "function", "setOperationResult", "(", "$", "operationResult", ")", ":", "EventBuilderInterface", "{", "if", "(", "!", "is_null", "(", "$", "operationResult", ")", "&&", "!", "is_bool", "(", "$", "operationResult", ")", "&&", "!", "is_a", "(", "$", "operationResult", ",", "'\\Picamator\\CacheManager\\Api\\Data\\SearchResultInterface'", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid $operationResult type. It should be null, boolean or SearchResultInterface.'", ")", ";", "}", "// convert boolean to scalar object to prevent null-true-false problem", "if", "(", "is_bool", "(", "$", "operationResult", ")", ")", "{", "$", "operationResult", "=", "(", "object", ")", "$", "operationResult", ";", "}", "$", "this", "->", "data", "[", "'operationResult'", "]", "=", "$", "operationResult", ";", "return", "$", "this", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/picamator/CacheManager/blob/5e5493910610b65ae31a362786d7963ba3e33806/src/Data/EventBuilder.php#L85-L102
OpenClassrooms/CacheBundle
DependencyInjection/OpenClassroomsCacheExtension.php
OpenClassroomsCacheExtension.load
public function load(array $config, ContainerBuilder $container) { $config = $this->processConfiguration(new Configuration(), $config); $provider = $config['provider']; $container->setParameter( 'openclassrooms.cache.default_lifetime', $config['default_lifetime'] ); $container->setParameter( 'openclassrooms.cache.cache_provider_type', key($provider) ); switch (key($provider)) { case CacheProviderType::REDIS: $providerConfig = $provider[CacheProviderType::REDIS]; $container->setParameter('openclassrooms.cache.provider_host', $providerConfig['host']); $container->setParameter('openclassrooms.cache.provider_port', $providerConfig['port']); $container->setParameter('openclassrooms.cache.provider_timeout', $providerConfig['timeout']); break; default; break; } $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config/')); $loader->load('services.xml'); }
php
public function load(array $config, ContainerBuilder $container) { $config = $this->processConfiguration(new Configuration(), $config); $provider = $config['provider']; $container->setParameter( 'openclassrooms.cache.default_lifetime', $config['default_lifetime'] ); $container->setParameter( 'openclassrooms.cache.cache_provider_type', key($provider) ); switch (key($provider)) { case CacheProviderType::REDIS: $providerConfig = $provider[CacheProviderType::REDIS]; $container->setParameter('openclassrooms.cache.provider_host', $providerConfig['host']); $container->setParameter('openclassrooms.cache.provider_port', $providerConfig['port']); $container->setParameter('openclassrooms.cache.provider_timeout', $providerConfig['timeout']); break; default; break; } $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config/')); $loader->load('services.xml'); }
[ "public", "function", "load", "(", "array", "$", "config", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "config", "=", "$", "this", "->", "processConfiguration", "(", "new", "Configuration", "(", ")", ",", "$", "config", ")", ";", "$", "provider", "=", "$", "config", "[", "'provider'", "]", ";", "$", "container", "->", "setParameter", "(", "'openclassrooms.cache.default_lifetime'", ",", "$", "config", "[", "'default_lifetime'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'openclassrooms.cache.cache_provider_type'", ",", "key", "(", "$", "provider", ")", ")", ";", "switch", "(", "key", "(", "$", "provider", ")", ")", "{", "case", "CacheProviderType", "::", "REDIS", ":", "$", "providerConfig", "=", "$", "provider", "[", "CacheProviderType", "::", "REDIS", "]", ";", "$", "container", "->", "setParameter", "(", "'openclassrooms.cache.provider_host'", ",", "$", "providerConfig", "[", "'host'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'openclassrooms.cache.provider_port'", ",", "$", "providerConfig", "[", "'port'", "]", ")", ";", "$", "container", "->", "setParameter", "(", "'openclassrooms.cache.provider_timeout'", ",", "$", "providerConfig", "[", "'timeout'", "]", ")", ";", "break", ";", "default", ";", "break", ";", "}", "$", "loader", "=", "new", "XmlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resources/config/'", ")", ")", ";", "$", "loader", "->", "load", "(", "'services.xml'", ")", ";", "}" ]
Loads a specific configuration. @param array $config An array of configuration values @param ContainerBuilder $container A ContainerBuilder instance @throws \InvalidArgumentException When provided tag is not defined in this extension @api
[ "Loads", "a", "specific", "configuration", "." ]
train
https://github.com/OpenClassrooms/CacheBundle/blob/a8b9226b4370bba12190b821b45d46eb848ca34b/DependencyInjection/OpenClassroomsCacheExtension.php#L26-L54
maniaplanet/maniaplanet-ws-sdk
libraries/Maniaplanet/WebServices/ManiaHome/ManialinkPublisher.php
ManialinkPublisher.postPublicEvent
function postPublicEvent($message, $eventDate, $link = null, $titleIdString = null, $mediaURL = null) { $e = new Event(); $e->senderName = $this->manialink; $e->message = $message; $e->link = $link; $e->eventDate = $eventDate; $e->titleId = $titleIdString; $e->mediaURL = $mediaURL; return $this->execute('POST', '/maniahome/event/public/', array($e)); }
php
function postPublicEvent($message, $eventDate, $link = null, $titleIdString = null, $mediaURL = null) { $e = new Event(); $e->senderName = $this->manialink; $e->message = $message; $e->link = $link; $e->eventDate = $eventDate; $e->titleId = $titleIdString; $e->mediaURL = $mediaURL; return $this->execute('POST', '/maniahome/event/public/', array($e)); }
[ "function", "postPublicEvent", "(", "$", "message", ",", "$", "eventDate", ",", "$", "link", "=", "null", ",", "$", "titleIdString", "=", "null", ",", "$", "mediaURL", "=", "null", ")", "{", "$", "e", "=", "new", "Event", "(", ")", ";", "$", "e", "->", "senderName", "=", "$", "this", "->", "manialink", ";", "$", "e", "->", "message", "=", "$", "message", ";", "$", "e", "->", "link", "=", "$", "link", ";", "$", "e", "->", "eventDate", "=", "$", "eventDate", ";", "$", "e", "->", "titleId", "=", "$", "titleIdString", ";", "$", "e", "->", "mediaURL", "=", "$", "mediaURL", ";", "return", "$", "this", "->", "execute", "(", "'POST'", ",", "'/maniahome/event/public/'", ",", "array", "(", "$", "e", ")", ")", ";", "}" ]
Create an event visible by all players who bookmarked your Manialink @param string $message The message itself. If you send a public notification to a player, the message will be prepended with its nickname. Max length is 255 chars, you can use Maniaplanet special chars. @param int $eventDate The UNIX Timestamp of the date of the event @param string $link Link when the player clicks on the notification @return int
[ "Create", "an", "event", "visible", "by", "all", "players", "who", "bookmarked", "your", "Manialink" ]
train
https://github.com/maniaplanet/maniaplanet-ws-sdk/blob/027a458388035fe66f2f56ff3ea1f85eff2a5a4e/libraries/Maniaplanet/WebServices/ManiaHome/ManialinkPublisher.php#L161-L171
webforge-labs/psc-cms
lib/Psc/CMS/Service/StandardControllerService.php
StandardControllerService.routeController
public function routeController(ServiceRequest $request) { $parts = $request->getParts(); $r = new RequestMatcher($request); /* Class */ $class = $this->getControllerClass($r->matchNES(), $check = TRUE); /* Method */ $method = $r->shift(); // method ist optional (kann index sein) if ($method === NULL) { $method = 'index'; } $class->elevateClass(); if (!$class->hasMethod($method)) { throw ControllerRouteException::create("in Methode: %s::%s nicht gefunden", $class->getFQN(), $method); } /* Params */ $gMethod = $class->getMethod($method); $dynamicParts = $r->getLeftParts(); // absaven $params = array(); foreach ($gMethod->getParameters() as $param) { if ($param->getName() === 'requestBody') { $params[] = $request->getBody(); } elseif ($param->getName() === 'requestType') { $params[] = $request->getType(); } elseif ($param->getName() === 'request') { $params[] = $request; } elseif ($param->getName() === 'requestParts') { $params[] = $dynamicParts; } elseif (!$r->isEmpty()) { $params[] = $r->shift(); } } return array($this->getControllerInstance($class), $method, $params); }
php
public function routeController(ServiceRequest $request) { $parts = $request->getParts(); $r = new RequestMatcher($request); /* Class */ $class = $this->getControllerClass($r->matchNES(), $check = TRUE); /* Method */ $method = $r->shift(); // method ist optional (kann index sein) if ($method === NULL) { $method = 'index'; } $class->elevateClass(); if (!$class->hasMethod($method)) { throw ControllerRouteException::create("in Methode: %s::%s nicht gefunden", $class->getFQN(), $method); } /* Params */ $gMethod = $class->getMethod($method); $dynamicParts = $r->getLeftParts(); // absaven $params = array(); foreach ($gMethod->getParameters() as $param) { if ($param->getName() === 'requestBody') { $params[] = $request->getBody(); } elseif ($param->getName() === 'requestType') { $params[] = $request->getType(); } elseif ($param->getName() === 'request') { $params[] = $request; } elseif ($param->getName() === 'requestParts') { $params[] = $dynamicParts; } elseif (!$r->isEmpty()) { $params[] = $r->shift(); } } return array($this->getControllerInstance($class), $method, $params); }
[ "public", "function", "routeController", "(", "ServiceRequest", "$", "request", ")", "{", "$", "parts", "=", "$", "request", "->", "getParts", "(", ")", ";", "$", "r", "=", "new", "RequestMatcher", "(", "$", "request", ")", ";", "/* Class */", "$", "class", "=", "$", "this", "->", "getControllerClass", "(", "$", "r", "->", "matchNES", "(", ")", ",", "$", "check", "=", "TRUE", ")", ";", "/* Method */", "$", "method", "=", "$", "r", "->", "shift", "(", ")", ";", "// method ist optional (kann index sein)", "if", "(", "$", "method", "===", "NULL", ")", "{", "$", "method", "=", "'index'", ";", "}", "$", "class", "->", "elevateClass", "(", ")", ";", "if", "(", "!", "$", "class", "->", "hasMethod", "(", "$", "method", ")", ")", "{", "throw", "ControllerRouteException", "::", "create", "(", "\"in Methode: %s::%s nicht gefunden\"", ",", "$", "class", "->", "getFQN", "(", ")", ",", "$", "method", ")", ";", "}", "/* Params */", "$", "gMethod", "=", "$", "class", "->", "getMethod", "(", "$", "method", ")", ";", "$", "dynamicParts", "=", "$", "r", "->", "getLeftParts", "(", ")", ";", "// absaven", "$", "params", "=", "array", "(", ")", ";", "foreach", "(", "$", "gMethod", "->", "getParameters", "(", ")", "as", "$", "param", ")", "{", "if", "(", "$", "param", "->", "getName", "(", ")", "===", "'requestBody'", ")", "{", "$", "params", "[", "]", "=", "$", "request", "->", "getBody", "(", ")", ";", "}", "elseif", "(", "$", "param", "->", "getName", "(", ")", "===", "'requestType'", ")", "{", "$", "params", "[", "]", "=", "$", "request", "->", "getType", "(", ")", ";", "}", "elseif", "(", "$", "param", "->", "getName", "(", ")", "===", "'request'", ")", "{", "$", "params", "[", "]", "=", "$", "request", ";", "}", "elseif", "(", "$", "param", "->", "getName", "(", ")", "===", "'requestParts'", ")", "{", "$", "params", "[", "]", "=", "$", "dynamicParts", ";", "}", "elseif", "(", "!", "$", "r", "->", "isEmpty", "(", ")", ")", "{", "$", "params", "[", "]", "=", "$", "r", "->", "shift", "(", ")", ";", "}", "}", "return", "array", "(", "$", "this", "->", "getControllerInstance", "(", "$", "class", ")", ",", "$", "method", ",", "$", "params", ")", ";", "}" ]
Findet den Controller anhand des Requests unsere StandardStrategie ist hier: 1.Part => Klassenname: $className in <$this->getControllersNamespace()>\\<ucfirst($className)>Controller oder (nicht implementiert) 1.Part => Schlüssel in $this->controllersMap oder (whatever) 2.Part => Name der Methode des Controllers 3-x.Part => Parameter zur Methode des Controllers (Reihenfolge wichtig) die "freien" Parameter des Requests werden auf die freien Parameter der Methode gemappt. Zusätzlich können die Parameter der Methode noch $requestType|$requestParts|$requestBody|$request sein. Diese werden dann mit den Parametern des Requests gesetzt GET /person/form/7 PersonController::form = function($id) => Project\Controllers\PersonController::form(7) GET /person/form/7 PersonController::form = function($requestType, $id) => Project\Controllers\PersonController::form(Service::GET, 7) POST /person/form/7 PersonController::form = function($requestType, $requestBody, $id) => Project\Controllers\PersonController::form(Service::POST, array(...), 7) GET /person/complex/example/for/request/uri PersonController::complex = function($requestType, $requestParts) => Project\Controllers\PersonController::complex(Service::GET, array('example','for','request','uri')) @return list(\Psc\CMS\Controller\ServiceController, string, Array)
[ "Findet", "den", "Controller", "anhand", "des", "Requests" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Service/StandardControllerService.php#L47-L83
PeekAndPoke/psi
src/Operation/Intermediate/Functional/SkipOperation.php
SkipOperation.apply
public function apply($input, $index, IntermediateContext $context) { if (! $context->memory->contains($this)) { $context->memory->offsetSet($this, 0); } $count = $context->memory->offsetGet($this); $context->memory->offsetSet($this, $count+1); $takeIt = $count >= $this->skip; $context->outUseItem = $takeIt; $context->outCanContinue = true; return $input; }
php
public function apply($input, $index, IntermediateContext $context) { if (! $context->memory->contains($this)) { $context->memory->offsetSet($this, 0); } $count = $context->memory->offsetGet($this); $context->memory->offsetSet($this, $count+1); $takeIt = $count >= $this->skip; $context->outUseItem = $takeIt; $context->outCanContinue = true; return $input; }
[ "public", "function", "apply", "(", "$", "input", ",", "$", "index", ",", "IntermediateContext", "$", "context", ")", "{", "if", "(", "!", "$", "context", "->", "memory", "->", "contains", "(", "$", "this", ")", ")", "{", "$", "context", "->", "memory", "->", "offsetSet", "(", "$", "this", ",", "0", ")", ";", "}", "$", "count", "=", "$", "context", "->", "memory", "->", "offsetGet", "(", "$", "this", ")", ";", "$", "context", "->", "memory", "->", "offsetSet", "(", "$", "this", ",", "$", "count", "+", "1", ")", ";", "$", "takeIt", "=", "$", "count", ">=", "$", "this", "->", "skip", ";", "$", "context", "->", "outUseItem", "=", "$", "takeIt", ";", "$", "context", "->", "outCanContinue", "=", "true", ";", "return", "$", "input", ";", "}" ]
@param mixed $input The element in the stream @param mixed $index The index in the input iterator @param IntermediateContext $context The solving context @return mixed
[ "@param", "mixed", "$input", "The", "element", "in", "the", "stream", "@param", "mixed", "$index", "The", "index", "in", "the", "input", "iterator", "@param", "IntermediateContext", "$context", "The", "solving", "context" ]
train
https://github.com/PeekAndPoke/psi/blob/cfd45d995d3a2c2ea6ba5b1ce7b5fcc71179456f/src/Operation/Intermediate/Functional/SkipOperation.php#L36-L51
JBZoo/Less
src/Driver/Leafo.php
Leafo._initCompiler
protected function _initCompiler() { if ($this->_compiler) { return $this->_compiler; } $this->_compiler = new \lessc(); if (class_exists('\lessc_formatter_lessjs')) { $formatter = new \lessc_formatter_lessjs(); // configurate css view $formatter->openSingle = ' { '; $formatter->closeSingle = "}\n"; $formatter->close = "}\n"; $formatter->indentChar = ' '; $formatter->disableSingle = true; $formatter->breakSelectors = true; $formatter->assignSeparator = ': '; $formatter->selectorSeparator = ', '; $this->_compiler->setFormatter($formatter); } $this->_compiler->setPreserveComments(false); // Set paths $importPaths = (array)$this->_options->get('import_paths', []); foreach ($importPaths as $fullPath => $relPath) { $this->setImportPath($fullPath, $relPath); } // Set paths $this->_compiler->setVariables((array)$this->_options->get('global_vars', [])); return $this->_compiler; }
php
protected function _initCompiler() { if ($this->_compiler) { return $this->_compiler; } $this->_compiler = new \lessc(); if (class_exists('\lessc_formatter_lessjs')) { $formatter = new \lessc_formatter_lessjs(); // configurate css view $formatter->openSingle = ' { '; $formatter->closeSingle = "}\n"; $formatter->close = "}\n"; $formatter->indentChar = ' '; $formatter->disableSingle = true; $formatter->breakSelectors = true; $formatter->assignSeparator = ': '; $formatter->selectorSeparator = ', '; $this->_compiler->setFormatter($formatter); } $this->_compiler->setPreserveComments(false); // Set paths $importPaths = (array)$this->_options->get('import_paths', []); foreach ($importPaths as $fullPath => $relPath) { $this->setImportPath($fullPath, $relPath); } // Set paths $this->_compiler->setVariables((array)$this->_options->get('global_vars', [])); return $this->_compiler; }
[ "protected", "function", "_initCompiler", "(", ")", "{", "if", "(", "$", "this", "->", "_compiler", ")", "{", "return", "$", "this", "->", "_compiler", ";", "}", "$", "this", "->", "_compiler", "=", "new", "\\", "lessc", "(", ")", ";", "if", "(", "class_exists", "(", "'\\lessc_formatter_lessjs'", ")", ")", "{", "$", "formatter", "=", "new", "\\", "lessc_formatter_lessjs", "(", ")", ";", "// configurate css view", "$", "formatter", "->", "openSingle", "=", "' { '", ";", "$", "formatter", "->", "closeSingle", "=", "\"}\\n\"", ";", "$", "formatter", "->", "close", "=", "\"}\\n\"", ";", "$", "formatter", "->", "indentChar", "=", "' '", ";", "$", "formatter", "->", "disableSingle", "=", "true", ";", "$", "formatter", "->", "breakSelectors", "=", "true", ";", "$", "formatter", "->", "assignSeparator", "=", "': '", ";", "$", "formatter", "->", "selectorSeparator", "=", "', '", ";", "$", "this", "->", "_compiler", "->", "setFormatter", "(", "$", "formatter", ")", ";", "}", "$", "this", "->", "_compiler", "->", "setPreserveComments", "(", "false", ")", ";", "// Set paths", "$", "importPaths", "=", "(", "array", ")", "$", "this", "->", "_options", "->", "get", "(", "'import_paths'", ",", "[", "]", ")", ";", "foreach", "(", "$", "importPaths", "as", "$", "fullPath", "=>", "$", "relPath", ")", "{", "$", "this", "->", "setImportPath", "(", "$", "fullPath", ",", "$", "relPath", ")", ";", "}", "// Set paths", "$", "this", "->", "_compiler", "->", "setVariables", "(", "(", "array", ")", "$", "this", "->", "_options", "->", "get", "(", "'global_vars'", ",", "[", "]", ")", ")", ";", "return", "$", "this", "->", "_compiler", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/JBZoo/Less/blob/9e9c41e3c7b76222c0d81379dead222413f2f042/src/Driver/Leafo.php#L44-L78
JBZoo/Less
src/Driver/Leafo.php
Leafo.setImportPath
public function setImportPath($fullPath, $relPath = null) { $this->_initCompiler(); if (!FS::isDir($fullPath)) { throw new Exception('Undefined import path: ' . $fullPath); } $fullPath = FS::getRelative($fullPath, $this->_options->get('root_path')); $this->_compiler->addImportDir($fullPath); }
php
public function setImportPath($fullPath, $relPath = null) { $this->_initCompiler(); if (!FS::isDir($fullPath)) { throw new Exception('Undefined import path: ' . $fullPath); } $fullPath = FS::getRelative($fullPath, $this->_options->get('root_path')); $this->_compiler->addImportDir($fullPath); }
[ "public", "function", "setImportPath", "(", "$", "fullPath", ",", "$", "relPath", "=", "null", ")", "{", "$", "this", "->", "_initCompiler", "(", ")", ";", "if", "(", "!", "FS", "::", "isDir", "(", "$", "fullPath", ")", ")", "{", "throw", "new", "Exception", "(", "'Undefined import path: '", ".", "$", "fullPath", ")", ";", "}", "$", "fullPath", "=", "FS", "::", "getRelative", "(", "$", "fullPath", ",", "$", "this", "->", "_options", "->", "get", "(", "'root_path'", ")", ")", ";", "$", "this", "->", "_compiler", "->", "addImportDir", "(", "$", "fullPath", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/JBZoo/Less/blob/9e9c41e3c7b76222c0d81379dead222413f2f042/src/Driver/Leafo.php#L83-L94
inc2734/wp-share-buttons
src/App/Model/Requester/Twitter.php
Twitter._get_count
protected function _get_count( $permalink ) { $request = "https://opensharecount.com/count.json?url=$permalink"; $response = wp_remote_get( $request ); $body = wp_remote_retrieve_body( $response ); $body = json_decode( $body, true ); if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { error_log( '[WP Share Buttons] Twitter request / ' . $request . ' / ' . json_encode( $body ) ); } if ( ! is_array( $body ) ) { return '-'; } if ( ! isset( $body['count'] ) ) { return '-'; } if ( isset( $body['error'] ) ) { if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { error_log( get_stylesheet() . ': ' . $body['error'] ); } return '-'; } return $body['count']; }
php
protected function _get_count( $permalink ) { $request = "https://opensharecount.com/count.json?url=$permalink"; $response = wp_remote_get( $request ); $body = wp_remote_retrieve_body( $response ); $body = json_decode( $body, true ); if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { error_log( '[WP Share Buttons] Twitter request / ' . $request . ' / ' . json_encode( $body ) ); } if ( ! is_array( $body ) ) { return '-'; } if ( ! isset( $body['count'] ) ) { return '-'; } if ( isset( $body['error'] ) ) { if ( defined( 'WP_DEBUG' ) && true === WP_DEBUG ) { error_log( get_stylesheet() . ': ' . $body['error'] ); } return '-'; } return $body['count']; }
[ "protected", "function", "_get_count", "(", "$", "permalink", ")", "{", "$", "request", "=", "\"https://opensharecount.com/count.json?url=$permalink\"", ";", "$", "response", "=", "wp_remote_get", "(", "$", "request", ")", ";", "$", "body", "=", "wp_remote_retrieve_body", "(", "$", "response", ")", ";", "$", "body", "=", "json_decode", "(", "$", "body", ",", "true", ")", ";", "if", "(", "defined", "(", "'WP_DEBUG'", ")", "&&", "true", "===", "WP_DEBUG", ")", "{", "error_log", "(", "'[WP Share Buttons] Twitter request / '", ".", "$", "request", ".", "' / '", ".", "json_encode", "(", "$", "body", ")", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "body", ")", ")", "{", "return", "'-'", ";", "}", "if", "(", "!", "isset", "(", "$", "body", "[", "'count'", "]", ")", ")", "{", "return", "'-'", ";", "}", "if", "(", "isset", "(", "$", "body", "[", "'error'", "]", ")", ")", "{", "if", "(", "defined", "(", "'WP_DEBUG'", ")", "&&", "true", "===", "WP_DEBUG", ")", "{", "error_log", "(", "get_stylesheet", "(", ")", ".", "': '", ".", "$", "body", "[", "'error'", "]", ")", ";", "}", "return", "'-'", ";", "}", "return", "$", "body", "[", "'count'", "]", ";", "}" ]
Get count from API @param string $permalink @return int Count
[ "Get", "count", "from", "API" ]
train
https://github.com/inc2734/wp-share-buttons/blob/cd032893ca083a343f5871e855cce68f4ede3a17/src/App/Model/Requester/Twitter.php#L30-L56
yuncms/framework
src/grid/ActionColumn.php
ActionColumn.init
public function init() { parent::init(); $this->initDefaultButtons(); if (empty($this->header)) { $this->header = Yii::t('yuncms', 'Operation'); } }
php
public function init() { parent::init(); $this->initDefaultButtons(); if (empty($this->header)) { $this->header = Yii::t('yuncms', 'Operation'); } }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "$", "this", "->", "initDefaultButtons", "(", ")", ";", "if", "(", "empty", "(", "$", "this", "->", "header", ")", ")", "{", "$", "this", "->", "header", "=", "Yii", "::", "t", "(", "'yuncms'", ",", "'Operation'", ")", ";", "}", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/grid/ActionColumn.php#L25-L32
TheBigBrainsCompany/TbbcRestUtilBundle
DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('tbbc_rest_util'); $this->addErrorSection($rootNode); return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('tbbc_rest_util'); $this->addErrorSection($rootNode); return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'tbbc_rest_util'", ")", ";", "$", "this", "->", "addErrorSection", "(", "$", "rootNode", ")", ";", "return", "$", "treeBuilder", ";", "}" ]
Generates the configuration tree builder @return TreeBuilder
[ "Generates", "the", "configuration", "tree", "builder" ]
train
https://github.com/TheBigBrainsCompany/TbbcRestUtilBundle/blob/48c0598a94a4f6b3883d349d8f134138e8bc6d7c/DependencyInjection/Configuration.php#L28-L36
TheBigBrainsCompany/TbbcRestUtilBundle
DependencyInjection/Configuration.php
Configuration.addErrorSection
private function addErrorSection(ArrayNodeDefinition $node) { $node ->children() ->arrayNode('error') ->children() ->booleanNode('use_bundled_factories')->defaultTrue()->end() ->scalarNode('error_resolver') ->defaultValue('tbbc_rest_util.error.error_resolver') ->end() ->arrayNode('exception_mapping') ->useAttributeAsKey('name') ->prototype('array') ->children() ->scalarNode('class')->isRequired()->cannotBeEmpty()->end() ->scalarNode('factory') ->isRequired() ->cannotBeEmpty() ->defaultValue('default') ->end() ->scalarNode('http_status_code')->isRequired()->cannotBeEmpty()->end() ->scalarNode('error_code')->isRequired()->cannotBeEmpty()->end() ->scalarNode('error_message')->defaultNull()->end() ->scalarNode('error_extended_message')->defaultNull()->end() ->scalarNode('error_more_info_url')->defaultNull()->end() ->end() ->end() ->end() ->end() ->end() ->end(); }
php
private function addErrorSection(ArrayNodeDefinition $node) { $node ->children() ->arrayNode('error') ->children() ->booleanNode('use_bundled_factories')->defaultTrue()->end() ->scalarNode('error_resolver') ->defaultValue('tbbc_rest_util.error.error_resolver') ->end() ->arrayNode('exception_mapping') ->useAttributeAsKey('name') ->prototype('array') ->children() ->scalarNode('class')->isRequired()->cannotBeEmpty()->end() ->scalarNode('factory') ->isRequired() ->cannotBeEmpty() ->defaultValue('default') ->end() ->scalarNode('http_status_code')->isRequired()->cannotBeEmpty()->end() ->scalarNode('error_code')->isRequired()->cannotBeEmpty()->end() ->scalarNode('error_message')->defaultNull()->end() ->scalarNode('error_extended_message')->defaultNull()->end() ->scalarNode('error_more_info_url')->defaultNull()->end() ->end() ->end() ->end() ->end() ->end() ->end(); }
[ "private", "function", "addErrorSection", "(", "ArrayNodeDefinition", "$", "node", ")", "{", "$", "node", "->", "children", "(", ")", "->", "arrayNode", "(", "'error'", ")", "->", "children", "(", ")", "->", "booleanNode", "(", "'use_bundled_factories'", ")", "->", "defaultTrue", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'error_resolver'", ")", "->", "defaultValue", "(", "'tbbc_rest_util.error.error_resolver'", ")", "->", "end", "(", ")", "->", "arrayNode", "(", "'exception_mapping'", ")", "->", "useAttributeAsKey", "(", "'name'", ")", "->", "prototype", "(", "'array'", ")", "->", "children", "(", ")", "->", "scalarNode", "(", "'class'", ")", "->", "isRequired", "(", ")", "->", "cannotBeEmpty", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'factory'", ")", "->", "isRequired", "(", ")", "->", "cannotBeEmpty", "(", ")", "->", "defaultValue", "(", "'default'", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'http_status_code'", ")", "->", "isRequired", "(", ")", "->", "cannotBeEmpty", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'error_code'", ")", "->", "isRequired", "(", ")", "->", "cannotBeEmpty", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'error_message'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'error_extended_message'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'error_more_info_url'", ")", "->", "defaultNull", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "}" ]
Parses the tbbc_rest_util.error config section Example for yaml driver: tbbc_rest_util: error: use_bundled_factories: true exception_mapping: InvalidArgumentException: class: "\InvalidArgumentException" factory: default http_status_code: 400 error_code: 400101 error_message: "Invalid argument exception" error_extended_message: "More extended message" error_more_info_url: "http://api.my.tld/doc/error/400101" @param ArrayNodeDefinition $node @return void
[ "Parses", "the", "tbbc_rest_util", ".", "error", "config", "section", "Example", "for", "yaml", "driver", ":", "tbbc_rest_util", ":", "error", ":", "use_bundled_factories", ":", "true", "exception_mapping", ":", "InvalidArgumentException", ":", "class", ":", "\\", "InvalidArgumentException", "factory", ":", "default", "http_status_code", ":", "400", "error_code", ":", "400101", "error_message", ":", "Invalid", "argument", "exception", "error_extended_message", ":", "More", "extended", "message", "error_more_info_url", ":", "http", ":", "//", "api", ".", "my", ".", "tld", "/", "doc", "/", "error", "/", "400101" ]
train
https://github.com/TheBigBrainsCompany/TbbcRestUtilBundle/blob/48c0598a94a4f6b3883d349d8f134138e8bc6d7c/DependencyInjection/Configuration.php#L57-L88
spiral-modules/scaffolder
source/Scaffolder/Commands/MigrationCommand.php
MigrationCommand.perform
public function perform(Migrator $migrator) { /** @var MigrationDeclaration $declaration */ $declaration = $this->createDeclaration(); if (!empty($this->option('table'))) { $columns = []; foreach ($this->option('column') as $field) { if (strpos($field, ':') === false) { throw new ScaffolderException("Column definition must in 'name:type' form"); } list($name, $type) = explode(':', $field); $columns[$name] = $type; } $declaration->declareCreation($this->option('table'), $columns); } $file = new FileDeclaration($this->getNamespace()); $file->setComment($this->config->headerLines()); $file->addElement($declaration); $filename = $migrator->getRepository()->registerMigration( $this->argument('name'), $declaration->getName(), $file->render() ); $this->writeln( "Declaration of '<info>{$declaration->getName()}</info>' " . "has been successfully written into '<comment>{$filename}</comment>'." ); }
php
public function perform(Migrator $migrator) { /** @var MigrationDeclaration $declaration */ $declaration = $this->createDeclaration(); if (!empty($this->option('table'))) { $columns = []; foreach ($this->option('column') as $field) { if (strpos($field, ':') === false) { throw new ScaffolderException("Column definition must in 'name:type' form"); } list($name, $type) = explode(':', $field); $columns[$name] = $type; } $declaration->declareCreation($this->option('table'), $columns); } $file = new FileDeclaration($this->getNamespace()); $file->setComment($this->config->headerLines()); $file->addElement($declaration); $filename = $migrator->getRepository()->registerMigration( $this->argument('name'), $declaration->getName(), $file->render() ); $this->writeln( "Declaration of '<info>{$declaration->getName()}</info>' " . "has been successfully written into '<comment>{$filename}</comment>'." ); }
[ "public", "function", "perform", "(", "Migrator", "$", "migrator", ")", "{", "/** @var MigrationDeclaration $declaration */", "$", "declaration", "=", "$", "this", "->", "createDeclaration", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "option", "(", "'table'", ")", ")", ")", "{", "$", "columns", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "option", "(", "'column'", ")", "as", "$", "field", ")", "{", "if", "(", "strpos", "(", "$", "field", ",", "':'", ")", "===", "false", ")", "{", "throw", "new", "ScaffolderException", "(", "\"Column definition must in 'name:type' form\"", ")", ";", "}", "list", "(", "$", "name", ",", "$", "type", ")", "=", "explode", "(", "':'", ",", "$", "field", ")", ";", "$", "columns", "[", "$", "name", "]", "=", "$", "type", ";", "}", "$", "declaration", "->", "declareCreation", "(", "$", "this", "->", "option", "(", "'table'", ")", ",", "$", "columns", ")", ";", "}", "$", "file", "=", "new", "FileDeclaration", "(", "$", "this", "->", "getNamespace", "(", ")", ")", ";", "$", "file", "->", "setComment", "(", "$", "this", "->", "config", "->", "headerLines", "(", ")", ")", ";", "$", "file", "->", "addElement", "(", "$", "declaration", ")", ";", "$", "filename", "=", "$", "migrator", "->", "getRepository", "(", ")", "->", "registerMigration", "(", "$", "this", "->", "argument", "(", "'name'", ")", ",", "$", "declaration", "->", "getName", "(", ")", ",", "$", "file", "->", "render", "(", ")", ")", ";", "$", "this", "->", "writeln", "(", "\"Declaration of '<info>{$declaration->getName()}</info>' \"", ".", "\"has been successfully written into '<comment>{$filename}</comment>'.\"", ")", ";", "}" ]
@param Migrator $migrator @throws ScaffolderException
[ "@param", "Migrator", "$migrator" ]
train
https://github.com/spiral-modules/scaffolder/blob/9be9dd0da6e4b02232db24e797fe5c288afbbddf/source/Scaffolder/Commands/MigrationCommand.php#L40-L74
iocaste/microservice-foundation
src/Http/Requests/Request.php
Request.response
public function response(array $errors): JsonResponse { return $this->respondValidationError( ApiResponse::CODE_VALIDATION_ERROR, $this->transformErrors($errors) ); }
php
public function response(array $errors): JsonResponse { return $this->respondValidationError( ApiResponse::CODE_VALIDATION_ERROR, $this->transformErrors($errors) ); }
[ "public", "function", "response", "(", "array", "$", "errors", ")", ":", "JsonResponse", "{", "return", "$", "this", "->", "respondValidationError", "(", "ApiResponse", "::", "CODE_VALIDATION_ERROR", ",", "$", "this", "->", "transformErrors", "(", "$", "errors", ")", ")", ";", "}" ]
Method throws validation error response. @param array $errors @return \Illuminate\Http\JsonResponse
[ "Method", "throws", "validation", "error", "response", "." ]
train
https://github.com/iocaste/microservice-foundation/blob/274a154de4299e8a57314bab972e09f6d8cdae9e/src/Http/Requests/Request.php#L23-L29
austinkregel/Warden
src/Warden/Http/Controllers/Controller.php
Controller.checkParams
public function checkParams(array $params) { foreach ($params as $p) { $config = config('kregel.warden.models'); $configKeys = array_keys($config); // dd($p, $config, $configKeys, !in_array($p, $config), !in_array($p, $configKeys), !in_array($p, $configKeys) && !in_array($p, $config)); if (in_array($p, $configKeys) && in_array($p, $config)) { throw new \Exception('You\'re attempting to use a value that isn\'t in the config! '.print_r($configKeys, true)); } } }
php
public function checkParams(array $params) { foreach ($params as $p) { $config = config('kregel.warden.models'); $configKeys = array_keys($config); // dd($p, $config, $configKeys, !in_array($p, $config), !in_array($p, $configKeys), !in_array($p, $configKeys) && !in_array($p, $config)); if (in_array($p, $configKeys) && in_array($p, $config)) { throw new \Exception('You\'re attempting to use a value that isn\'t in the config! '.print_r($configKeys, true)); } } }
[ "public", "function", "checkParams", "(", "array", "$", "params", ")", "{", "foreach", "(", "$", "params", "as", "$", "p", ")", "{", "$", "config", "=", "config", "(", "'kregel.warden.models'", ")", ";", "$", "configKeys", "=", "array_keys", "(", "$", "config", ")", ";", "// dd($p, $config, $configKeys, !in_array($p, $config), !in_array($p, $configKeys), !in_array($p, $configKeys) && !in_array($p, $config));", "if", "(", "in_array", "(", "$", "p", ",", "$", "configKeys", ")", "&&", "in_array", "(", "$", "p", ",", "$", "config", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'You\\'re attempting to use a value that isn\\'t in the config! '", ".", "print_r", "(", "$", "configKeys", ",", "true", ")", ")", ";", "}", "}", "}" ]
@param array $params @throws \Exception
[ "@param", "array", "$params" ]
train
https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Http/Controllers/Controller.php#L38-L48
austinkregel/Warden
src/Warden/Http/Controllers/Controller.php
Controller.get
public function get($route, $params = []) { $route = $this->parseRoute($route, $params); $request = Request::create($route, 'GET'); $response = Route::dispatch($request); return $response; }
php
public function get($route, $params = []) { $route = $this->parseRoute($route, $params); $request = Request::create($route, 'GET'); $response = Route::dispatch($request); return $response; }
[ "public", "function", "get", "(", "$", "route", ",", "$", "params", "=", "[", "]", ")", "{", "$", "route", "=", "$", "this", "->", "parseRoute", "(", "$", "route", ",", "$", "params", ")", ";", "$", "request", "=", "Request", "::", "create", "(", "$", "route", ",", "'GET'", ")", ";", "$", "response", "=", "Route", "::", "dispatch", "(", "$", "request", ")", ";", "return", "$", "response", ";", "}" ]
@param $route @param array $params @return mixed
[ "@param", "$route", "@param", "array", "$params" ]
train
https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Http/Controllers/Controller.php#L56-L63
austinkregel/Warden
src/Warden/Http/Controllers/Controller.php
Controller.delete
public function delete($route, $params = []) { $route = $this->parseRoute($route, $params); $request = Request::create($route, 'DELETE', Input::all()); $response = Route::dispatch($request); return $response; }
php
public function delete($route, $params = []) { $route = $this->parseRoute($route, $params); $request = Request::create($route, 'DELETE', Input::all()); $response = Route::dispatch($request); return $response; }
[ "public", "function", "delete", "(", "$", "route", ",", "$", "params", "=", "[", "]", ")", "{", "$", "route", "=", "$", "this", "->", "parseRoute", "(", "$", "route", ",", "$", "params", ")", ";", "$", "request", "=", "Request", "::", "create", "(", "$", "route", ",", "'DELETE'", ",", "Input", "::", "all", "(", ")", ")", ";", "$", "response", "=", "Route", "::", "dispatch", "(", "$", "request", ")", ";", "return", "$", "response", ";", "}" ]
@param $route @return mixed
[ "@param", "$route" ]
train
https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Http/Controllers/Controller.php#L83-L90
austinkregel/Warden
src/Warden/Http/Controllers/Controller.php
Controller.parseRoute
public function parseRoute($route, $params = []) { if (Route::has($route)) { $url = route($route, $params); } else { $url = url($route, $params); } $tld = ['.ved/', '.dev/', '.com/', '.org/', '.net/', '.int/', '.edu/', '.gov/', '.mil/', '.ac/', '.ad/', '.ae/', '.af/', '.ag/', '.ai/', '.al/', '.am/', '.an/', '.ao/', '.aq/', '.ar/', '.as/', '.at/', '.au/', '.aw/', '.ax/', '.az/', '.ba/', '.bb/', '.bd/', '.be/', '.bf/', '.bg/', '.bh/', '.bi/', '.bj/', '.bm/', '.bn/', '.bo/', '.bq/', '.br/', '.bs/', '.bt/', '.bv/', '.bw/', '.by/', '.bz/', '.ca/', '.cc/', '.cd/', '.cf/', '.cg/', '.ch/', '.ci/', '.ck/', '.cl/', '.cm/', '.cn/', '.co/', '.cr/', '.cs/', '.cu/', '.cv/', '.cw/', '.cx/', '.cy/', '.cz/', '.dd/', '.de/', '.dj/', '.dk/', '.dm/', '.do/', '.dz/', '.ec/', '.ee/', '.eg/', '.eh/', '.er/', '.es/', '.et/', '.eu/', '.fi/', '.fj/', '.fk/', '.fm/', '.fo/', '.fr/', '.ga/', '.gb/', '.gd/', '.ge/', '.gf/', '.gg/', '.gh/', '.gi/', '.gl/', '.gm/', '.gn/', '.gp/', '.gq/', '.gr/', '.gs/', '.gt/', '.gu/', '.gw/', '.gy/', '.hk/', '.hm/', '.hn/', '.hr/', '.ht/', '.hu/', '.id/', '.ie/', '.il/', '.im/', '.in/', '.io/', '.iq/', '.ir/', '.is/', '.it/', '.je/', '.jm/', '.jo/', '.jp/', '.ke/', '.kg/', '.kh/', '.ki/', '.km/', '.kn/', '.kp/', '.kr/', '.krd/', '.kw/', '.ky/', '.kz/', '.la/', '.lb/', '.lc/', '.li/', '.lk/', '.lr/', '.ls/', '.lt/', '.lu/', '.lv/', '.ly/', '.ma/', '.mc/', '.md/', '.me/', '.mg/', '.mh/', '.mk/', '.ml/', '.mm/', '.mn/', '.mo/', '.mp/', '.mq/', '.mr/', '.ms/', '.mt/', '.mu/', '.mv/', '.mw/', '.mx/', '.my/', '.mz/', '.na/', '.nc/', '.ne/', '.nf/', '.ng/', '.ni/', '.nl/', '.no/', '.np/', '.nr/', '.nu/', '.nz/', '.om/', '.pa/', '.pe/', '.pf/', '.pg/', '.ph/', '.pk/', '.pl/', '.pm/', '.pn/', '.pr/', '.ps/', '.pt/', '.pw/', '.py/', '.qa/', '.re/', '.ro/', '.rs/', '.ru/', '.rw/', '.sa/', '.sb/', '.sc/', '.sd/', '.se/', '.sg/', '.sh/', '.si/', '.sj/', '.sk/', '.sl/', '.sm/', '.sn/', '.so/', '.sr/', '.ss/', '.st/', '.su/', '.sv/', '.sx/', '.sy/', '.sz/', '.tc/', '.td/', '.tf/', '.tg/', '.th/', '.tj/', '.tk/', '.tl/', '.tm/', '.tn/', '.to/', '.tp/', '.tr/', '.tt/', '.tv/', '.tw/', '.tz/', '.ua/', '.ug/', '.uk/', '.us/', '.uy/', '.uz/', '.va/', '.vc/', '.ve/', '.vg/', '.vi/', '.vn/', '.vu/', '.wf/', '.ws/', '.ye/', '.yt/', '.yu/', '.za/', '.zm/', '.zr/', '.zw/', '.academy/', '.accountant/', '.accountants/', '.active/', '.actor/', '.adult/', '.aero/', '.agency/', '.airforce/', '.apartments/', '.app/', '.archi/', '.army/', '.associates/', '.attorney/', '.auction/', '.audio/', '.autos/', '.band/', '.bar/', '.bargains/', '.beer/', '.best/', '.bid/', '.bike/', '.bingo/', '.bio/', '.biz/', '.black/', '.blackfriday/', '.blog/', '.blue/', '.boo/', '.boutique/', '.build/', '.builders/', '.business/', '.buzz/', '.cab/', '.camera/', '.camp/', '.cancerresearch/', '.capital/', '.cards/', '.care/', '.career/', '.careers/', '.cash/', '.casino/', '.catering/', '.center/', '.ceo/', '.channel/', '.chat/', '.cheap/', '.christmas/', '.church/', '.city/', '.claims/', '.cleaning/', '.click/', '.clinic/', '.clothing/', '.club/', '.coach/', '.codes/', '.coffee/', '.college/', '.community/', '.company/', '.computer/', '.condos/', '.construction/', '.consulting/', '.contractors/', '.cooking/', '.cool/', '.country/', '.coupons/', '.credit/', '.creditcard/', '.cricket/', '.cruises/', '.dad/', '.dance/', '.date/', '.dating/', '.day/', '.deals/', '.degree/', '.delivery/', '.democrat/', '.dental/', '.dentist/', '.design/', '.diamonds/', '.diet/', '.digital/', '.direct/', '.directory/', '.discount/', '.dog/', '.domains/', '.download/', '.eat/', '.education/', '.email/', '.energy/', '.engineer/', '.engineering/', '.equipment/', '.esq/', '.estate/', '.events/', '.exchange/', '.expert/', '.exposed/', '.express/', '.fail/', '.faith/', '.fans/', '.farm/', '.fashion/', '.feedback/', '.finance/', '.financial/', '.fish/', '.fishing/', '.fit/', '.fitness/', '.flights/', '.florist/', '.flowers/', '.fly/', '.foo/', '.football/', '.forsale/', '.foundation/', '.fund/', '.furniture/', '.fyi/', '.gallery/', '.garden/', '.gift/', '.gifts/', '.gives/', '.glass/', '.global/', '.gold/', '.golf/', '.gop/', '.graphics/', '.green/', '.gripe/', '.guide/', '.guitars/', '.guru/', '.healthcare/', '.help/', '.here/', '.hiphop/', '.hiv/', '.hockey/', '.holdings/', '.holiday/', '.homes/', '.horse/', '.host/', '.hosting/', '.house/', '.how/', '.info/', '.ing/', '.ink/', '.institute[58]/', '.insure/', '.international/', '.investments/', '.jewelry/', '.jobs/', '.kim/', '.kitchen/', '.land/', '.lawyer/', '.lease/', '.legal/', '.lgbt/', '.life/', '.lighting/', '.limited/', '.limo/', '.link/', '.loan/', '.loans/', '.lol/', '.lotto/', '.love/', '.luxe/', '.luxury/', '.management/', '.market/', '.marketing/', '.markets/', '.mba/', '.media/', '.meet/', '.meme/', '.memorial/', '.men/', '.menu/', '.mobi/', '.moe/', '.money/', '.mortgage/', '.motorcycles/', '.mov/', '.movie/', '.museum/', '.name/', '.navy/', '.network/', '.new/', '.news/', '.ngo/', '.ninja/', '.one/', '.ong/', '.onl/', '.online/', '.ooo/', '.organic/', '.partners/', '.parts/', '.party/', '.pharmacy/', '.photo/', '.photography/', '.photos/', '.physio/', '.pics/', '.pictures/', '.pink/', '.pizza/', '.place/', '.plumbing/', '.plus/', '.poker/', '.porn/', '.post/', '.press/', '.pro/', '.productions/', '.prof/', '.properties/', '.property/', '.qpon/', '.racing/', '.recipes/', '.red/', '.rehab/', '.ren/', '.rent/', '.rentals/', '.repair/', '.report/', '.republican/', '.rest/', '.review/', '.reviews/', '.rich/', '.rip/', '.rocks/', '.rodeo/', '.rsvp/', '.run/', '.sale/', '.school/', '.science/', '.services/', '.sex/', '.sexy/', '.shoes/', '.show/', '.singles/', '.site/', '.soccer/', '.social/', '.software/', '.solar/', '.solutions/', '.space/', '.studio/', '.style/', '.sucks/', '.supplies/', '.supply/', '.support/', '.surf/', '.surgery/', '.systems/', '.tattoo/', '.tax/', '.taxi/', '.team/', '.technology/', '.tel/', '.tennis/', '.theater/', '.tips/', '.tires/', '.today/', '.tools/', '.top/', '.tours/', '.town/', '.toys/', '.trade/', '.training/', '.travel/', '.university/', '.vacations/', '.vet/', '.video/', '.villas/', '.vision/', '.vodka/', '.vote/', '.voting/', '.voyage/', '.wang/', '.watch/', '.webcam/', '.website/', '.wed/', '.wedding/', '.whoswho/', '.wiki/', '.win/', '.work/', '.works/', '.world/', '.wtf/', '.xxx/', '.xyz/', '.yoga/', '.zone/', '.maison/', '.abogado/', '.gratis/', '.futbol/', '.juegos/', '.soy/', '.tienda/', '.uno/', '.viajes/', '.haus/', '.immobilien/', '.jetzt/', '.kaufen/', '.reise/', '.reisen/', '.schule/', '.versicherung/', '.desi/', '.shiksha/', '.casa/', '.cafe/', '.immo/', '.moda/', '.voto/', '.bar/', '.bank/', '.coop/', '.enterprises/', '.industries/', '.institute/', '.ltda/', '.pub/', '.realtor/', '.reit/', '.rest/', '.restaurant/', '.sarl/', '.ventures/', '.capetown/', '.durban/', '.joburg/', '.asia/', '.krd/', '.nagoya/', '.okinawa/', '.ryukyu/', '.taipei/', '.tatar/', '.tokyo/', '.yokohama/', '.alsace/', '.amsterdam/', '.barcelona/', '.bayern/', '.berlin/', '.brussels/', '.budapest/', '.bzh/', '.cat/', '.cologne/', '.cymru/', '.eus/', '.frl/', '.gal/', '.gent/', '.hamburg/', '.irish/', '.koeln/', '.london/', '.madrid/', '.moscow/', '.nrw/', '.paris/', '.ruhr/', '.saarland/', '.scot/', '.tirol/', '.vlaanderen/', '.wales/', '.wien/', '.zuerich/', '.miami/', '.nyc/', '.quebec/', '.vegas/', '.kiwi/', '.melbourne/', '.sydney/', '.lat/', '.rio/', '.allfinanz/', '.android/', '.aquarelle/', '.axa/', '.barclays/', '.barclaycard/', '.bloomberg/', '.bmw/', '.bnl/', '.bnpparibas/', '.cal/', '.caravan/', '.cern/', '.chrome/', '.citic/', '.crs/', '.cuisinella/', '.dnp/', '.dvag/', '.emerck/', '.everbank/', '.firmdale/', '.flsmidth/', '.frogans/', '.gbiz/', '.gle/', '.globo/', '.gmail/', '.gmo/', '.gmx/', '.google/', '.hsbc/', '.ibm/', '.kred/', '.lacaixa/', '.latrobe/', '.lds/', '.mango/', '.mini/', '.monash/', '.mormon/', '.neustar/', '.nexus/', '.nhk/', '.nico/', '.nra/', '.otsuka/', '.ovh/', '.piaget/', '.pohl/', '.praxi/', '.prod/', '.sca/', '.scb/', '.schmidt/', '.sohu/', '.spiegel/', '.suzuki/', '.tui/', '.uol/', '.williamhill/', '.wme/', '.wtc/', '.yandex/', '.youtube/']; $explode = $this->explodeWhere($url, $tld); return end($explode).'/'; }
php
public function parseRoute($route, $params = []) { if (Route::has($route)) { $url = route($route, $params); } else { $url = url($route, $params); } $tld = ['.ved/', '.dev/', '.com/', '.org/', '.net/', '.int/', '.edu/', '.gov/', '.mil/', '.ac/', '.ad/', '.ae/', '.af/', '.ag/', '.ai/', '.al/', '.am/', '.an/', '.ao/', '.aq/', '.ar/', '.as/', '.at/', '.au/', '.aw/', '.ax/', '.az/', '.ba/', '.bb/', '.bd/', '.be/', '.bf/', '.bg/', '.bh/', '.bi/', '.bj/', '.bm/', '.bn/', '.bo/', '.bq/', '.br/', '.bs/', '.bt/', '.bv/', '.bw/', '.by/', '.bz/', '.ca/', '.cc/', '.cd/', '.cf/', '.cg/', '.ch/', '.ci/', '.ck/', '.cl/', '.cm/', '.cn/', '.co/', '.cr/', '.cs/', '.cu/', '.cv/', '.cw/', '.cx/', '.cy/', '.cz/', '.dd/', '.de/', '.dj/', '.dk/', '.dm/', '.do/', '.dz/', '.ec/', '.ee/', '.eg/', '.eh/', '.er/', '.es/', '.et/', '.eu/', '.fi/', '.fj/', '.fk/', '.fm/', '.fo/', '.fr/', '.ga/', '.gb/', '.gd/', '.ge/', '.gf/', '.gg/', '.gh/', '.gi/', '.gl/', '.gm/', '.gn/', '.gp/', '.gq/', '.gr/', '.gs/', '.gt/', '.gu/', '.gw/', '.gy/', '.hk/', '.hm/', '.hn/', '.hr/', '.ht/', '.hu/', '.id/', '.ie/', '.il/', '.im/', '.in/', '.io/', '.iq/', '.ir/', '.is/', '.it/', '.je/', '.jm/', '.jo/', '.jp/', '.ke/', '.kg/', '.kh/', '.ki/', '.km/', '.kn/', '.kp/', '.kr/', '.krd/', '.kw/', '.ky/', '.kz/', '.la/', '.lb/', '.lc/', '.li/', '.lk/', '.lr/', '.ls/', '.lt/', '.lu/', '.lv/', '.ly/', '.ma/', '.mc/', '.md/', '.me/', '.mg/', '.mh/', '.mk/', '.ml/', '.mm/', '.mn/', '.mo/', '.mp/', '.mq/', '.mr/', '.ms/', '.mt/', '.mu/', '.mv/', '.mw/', '.mx/', '.my/', '.mz/', '.na/', '.nc/', '.ne/', '.nf/', '.ng/', '.ni/', '.nl/', '.no/', '.np/', '.nr/', '.nu/', '.nz/', '.om/', '.pa/', '.pe/', '.pf/', '.pg/', '.ph/', '.pk/', '.pl/', '.pm/', '.pn/', '.pr/', '.ps/', '.pt/', '.pw/', '.py/', '.qa/', '.re/', '.ro/', '.rs/', '.ru/', '.rw/', '.sa/', '.sb/', '.sc/', '.sd/', '.se/', '.sg/', '.sh/', '.si/', '.sj/', '.sk/', '.sl/', '.sm/', '.sn/', '.so/', '.sr/', '.ss/', '.st/', '.su/', '.sv/', '.sx/', '.sy/', '.sz/', '.tc/', '.td/', '.tf/', '.tg/', '.th/', '.tj/', '.tk/', '.tl/', '.tm/', '.tn/', '.to/', '.tp/', '.tr/', '.tt/', '.tv/', '.tw/', '.tz/', '.ua/', '.ug/', '.uk/', '.us/', '.uy/', '.uz/', '.va/', '.vc/', '.ve/', '.vg/', '.vi/', '.vn/', '.vu/', '.wf/', '.ws/', '.ye/', '.yt/', '.yu/', '.za/', '.zm/', '.zr/', '.zw/', '.academy/', '.accountant/', '.accountants/', '.active/', '.actor/', '.adult/', '.aero/', '.agency/', '.airforce/', '.apartments/', '.app/', '.archi/', '.army/', '.associates/', '.attorney/', '.auction/', '.audio/', '.autos/', '.band/', '.bar/', '.bargains/', '.beer/', '.best/', '.bid/', '.bike/', '.bingo/', '.bio/', '.biz/', '.black/', '.blackfriday/', '.blog/', '.blue/', '.boo/', '.boutique/', '.build/', '.builders/', '.business/', '.buzz/', '.cab/', '.camera/', '.camp/', '.cancerresearch/', '.capital/', '.cards/', '.care/', '.career/', '.careers/', '.cash/', '.casino/', '.catering/', '.center/', '.ceo/', '.channel/', '.chat/', '.cheap/', '.christmas/', '.church/', '.city/', '.claims/', '.cleaning/', '.click/', '.clinic/', '.clothing/', '.club/', '.coach/', '.codes/', '.coffee/', '.college/', '.community/', '.company/', '.computer/', '.condos/', '.construction/', '.consulting/', '.contractors/', '.cooking/', '.cool/', '.country/', '.coupons/', '.credit/', '.creditcard/', '.cricket/', '.cruises/', '.dad/', '.dance/', '.date/', '.dating/', '.day/', '.deals/', '.degree/', '.delivery/', '.democrat/', '.dental/', '.dentist/', '.design/', '.diamonds/', '.diet/', '.digital/', '.direct/', '.directory/', '.discount/', '.dog/', '.domains/', '.download/', '.eat/', '.education/', '.email/', '.energy/', '.engineer/', '.engineering/', '.equipment/', '.esq/', '.estate/', '.events/', '.exchange/', '.expert/', '.exposed/', '.express/', '.fail/', '.faith/', '.fans/', '.farm/', '.fashion/', '.feedback/', '.finance/', '.financial/', '.fish/', '.fishing/', '.fit/', '.fitness/', '.flights/', '.florist/', '.flowers/', '.fly/', '.foo/', '.football/', '.forsale/', '.foundation/', '.fund/', '.furniture/', '.fyi/', '.gallery/', '.garden/', '.gift/', '.gifts/', '.gives/', '.glass/', '.global/', '.gold/', '.golf/', '.gop/', '.graphics/', '.green/', '.gripe/', '.guide/', '.guitars/', '.guru/', '.healthcare/', '.help/', '.here/', '.hiphop/', '.hiv/', '.hockey/', '.holdings/', '.holiday/', '.homes/', '.horse/', '.host/', '.hosting/', '.house/', '.how/', '.info/', '.ing/', '.ink/', '.institute[58]/', '.insure/', '.international/', '.investments/', '.jewelry/', '.jobs/', '.kim/', '.kitchen/', '.land/', '.lawyer/', '.lease/', '.legal/', '.lgbt/', '.life/', '.lighting/', '.limited/', '.limo/', '.link/', '.loan/', '.loans/', '.lol/', '.lotto/', '.love/', '.luxe/', '.luxury/', '.management/', '.market/', '.marketing/', '.markets/', '.mba/', '.media/', '.meet/', '.meme/', '.memorial/', '.men/', '.menu/', '.mobi/', '.moe/', '.money/', '.mortgage/', '.motorcycles/', '.mov/', '.movie/', '.museum/', '.name/', '.navy/', '.network/', '.new/', '.news/', '.ngo/', '.ninja/', '.one/', '.ong/', '.onl/', '.online/', '.ooo/', '.organic/', '.partners/', '.parts/', '.party/', '.pharmacy/', '.photo/', '.photography/', '.photos/', '.physio/', '.pics/', '.pictures/', '.pink/', '.pizza/', '.place/', '.plumbing/', '.plus/', '.poker/', '.porn/', '.post/', '.press/', '.pro/', '.productions/', '.prof/', '.properties/', '.property/', '.qpon/', '.racing/', '.recipes/', '.red/', '.rehab/', '.ren/', '.rent/', '.rentals/', '.repair/', '.report/', '.republican/', '.rest/', '.review/', '.reviews/', '.rich/', '.rip/', '.rocks/', '.rodeo/', '.rsvp/', '.run/', '.sale/', '.school/', '.science/', '.services/', '.sex/', '.sexy/', '.shoes/', '.show/', '.singles/', '.site/', '.soccer/', '.social/', '.software/', '.solar/', '.solutions/', '.space/', '.studio/', '.style/', '.sucks/', '.supplies/', '.supply/', '.support/', '.surf/', '.surgery/', '.systems/', '.tattoo/', '.tax/', '.taxi/', '.team/', '.technology/', '.tel/', '.tennis/', '.theater/', '.tips/', '.tires/', '.today/', '.tools/', '.top/', '.tours/', '.town/', '.toys/', '.trade/', '.training/', '.travel/', '.university/', '.vacations/', '.vet/', '.video/', '.villas/', '.vision/', '.vodka/', '.vote/', '.voting/', '.voyage/', '.wang/', '.watch/', '.webcam/', '.website/', '.wed/', '.wedding/', '.whoswho/', '.wiki/', '.win/', '.work/', '.works/', '.world/', '.wtf/', '.xxx/', '.xyz/', '.yoga/', '.zone/', '.maison/', '.abogado/', '.gratis/', '.futbol/', '.juegos/', '.soy/', '.tienda/', '.uno/', '.viajes/', '.haus/', '.immobilien/', '.jetzt/', '.kaufen/', '.reise/', '.reisen/', '.schule/', '.versicherung/', '.desi/', '.shiksha/', '.casa/', '.cafe/', '.immo/', '.moda/', '.voto/', '.bar/', '.bank/', '.coop/', '.enterprises/', '.industries/', '.institute/', '.ltda/', '.pub/', '.realtor/', '.reit/', '.rest/', '.restaurant/', '.sarl/', '.ventures/', '.capetown/', '.durban/', '.joburg/', '.asia/', '.krd/', '.nagoya/', '.okinawa/', '.ryukyu/', '.taipei/', '.tatar/', '.tokyo/', '.yokohama/', '.alsace/', '.amsterdam/', '.barcelona/', '.bayern/', '.berlin/', '.brussels/', '.budapest/', '.bzh/', '.cat/', '.cologne/', '.cymru/', '.eus/', '.frl/', '.gal/', '.gent/', '.hamburg/', '.irish/', '.koeln/', '.london/', '.madrid/', '.moscow/', '.nrw/', '.paris/', '.ruhr/', '.saarland/', '.scot/', '.tirol/', '.vlaanderen/', '.wales/', '.wien/', '.zuerich/', '.miami/', '.nyc/', '.quebec/', '.vegas/', '.kiwi/', '.melbourne/', '.sydney/', '.lat/', '.rio/', '.allfinanz/', '.android/', '.aquarelle/', '.axa/', '.barclays/', '.barclaycard/', '.bloomberg/', '.bmw/', '.bnl/', '.bnpparibas/', '.cal/', '.caravan/', '.cern/', '.chrome/', '.citic/', '.crs/', '.cuisinella/', '.dnp/', '.dvag/', '.emerck/', '.everbank/', '.firmdale/', '.flsmidth/', '.frogans/', '.gbiz/', '.gle/', '.globo/', '.gmail/', '.gmo/', '.gmx/', '.google/', '.hsbc/', '.ibm/', '.kred/', '.lacaixa/', '.latrobe/', '.lds/', '.mango/', '.mini/', '.monash/', '.mormon/', '.neustar/', '.nexus/', '.nhk/', '.nico/', '.nra/', '.otsuka/', '.ovh/', '.piaget/', '.pohl/', '.praxi/', '.prod/', '.sca/', '.scb/', '.schmidt/', '.sohu/', '.spiegel/', '.suzuki/', '.tui/', '.uol/', '.williamhill/', '.wme/', '.wtc/', '.yandex/', '.youtube/']; $explode = $this->explodeWhere($url, $tld); return end($explode).'/'; }
[ "public", "function", "parseRoute", "(", "$", "route", ",", "$", "params", "=", "[", "]", ")", "{", "if", "(", "Route", "::", "has", "(", "$", "route", ")", ")", "{", "$", "url", "=", "route", "(", "$", "route", ",", "$", "params", ")", ";", "}", "else", "{", "$", "url", "=", "url", "(", "$", "route", ",", "$", "params", ")", ";", "}", "$", "tld", "=", "[", "'.ved/'", ",", "'.dev/'", ",", "'.com/'", ",", "'.org/'", ",", "'.net/'", ",", "'.int/'", ",", "'.edu/'", ",", "'.gov/'", ",", "'.mil/'", ",", "'.ac/'", ",", "'.ad/'", ",", "'.ae/'", ",", "'.af/'", ",", "'.ag/'", ",", "'.ai/'", ",", "'.al/'", ",", "'.am/'", ",", "'.an/'", ",", "'.ao/'", ",", "'.aq/'", ",", "'.ar/'", ",", "'.as/'", ",", "'.at/'", ",", "'.au/'", ",", "'.aw/'", ",", "'.ax/'", ",", "'.az/'", ",", "'.ba/'", ",", "'.bb/'", ",", "'.bd/'", ",", "'.be/'", ",", "'.bf/'", ",", "'.bg/'", ",", "'.bh/'", ",", "'.bi/'", ",", "'.bj/'", ",", "'.bm/'", ",", "'.bn/'", ",", "'.bo/'", ",", "'.bq/'", ",", "'.br/'", ",", "'.bs/'", ",", "'.bt/'", ",", "'.bv/'", ",", "'.bw/'", ",", "'.by/'", ",", "'.bz/'", ",", "'.ca/'", ",", "'.cc/'", ",", "'.cd/'", ",", "'.cf/'", ",", "'.cg/'", ",", "'.ch/'", ",", "'.ci/'", ",", "'.ck/'", ",", "'.cl/'", ",", "'.cm/'", ",", "'.cn/'", ",", "'.co/'", ",", "'.cr/'", ",", "'.cs/'", ",", "'.cu/'", ",", "'.cv/'", ",", "'.cw/'", ",", "'.cx/'", ",", "'.cy/'", ",", "'.cz/'", ",", "'.dd/'", ",", "'.de/'", ",", "'.dj/'", ",", "'.dk/'", ",", "'.dm/'", ",", "'.do/'", ",", "'.dz/'", ",", "'.ec/'", ",", "'.ee/'", ",", "'.eg/'", ",", "'.eh/'", ",", "'.er/'", ",", "'.es/'", ",", "'.et/'", ",", "'.eu/'", ",", "'.fi/'", ",", "'.fj/'", ",", "'.fk/'", ",", "'.fm/'", ",", "'.fo/'", ",", "'.fr/'", ",", "'.ga/'", ",", "'.gb/'", ",", "'.gd/'", ",", "'.ge/'", ",", "'.gf/'", ",", "'.gg/'", ",", "'.gh/'", ",", "'.gi/'", ",", "'.gl/'", ",", "'.gm/'", ",", "'.gn/'", ",", "'.gp/'", ",", "'.gq/'", ",", "'.gr/'", ",", "'.gs/'", ",", "'.gt/'", ",", "'.gu/'", ",", "'.gw/'", ",", "'.gy/'", ",", "'.hk/'", ",", "'.hm/'", ",", "'.hn/'", ",", "'.hr/'", ",", "'.ht/'", ",", "'.hu/'", ",", "'.id/'", ",", "'.ie/'", ",", "'.il/'", ",", "'.im/'", ",", "'.in/'", ",", "'.io/'", ",", "'.iq/'", ",", "'.ir/'", ",", "'.is/'", ",", "'.it/'", ",", "'.je/'", ",", "'.jm/'", ",", "'.jo/'", ",", "'.jp/'", ",", "'.ke/'", ",", "'.kg/'", ",", "'.kh/'", ",", "'.ki/'", ",", "'.km/'", ",", "'.kn/'", ",", "'.kp/'", ",", "'.kr/'", ",", "'.krd/'", ",", "'.kw/'", ",", "'.ky/'", ",", "'.kz/'", ",", "'.la/'", ",", "'.lb/'", ",", "'.lc/'", ",", "'.li/'", ",", "'.lk/'", ",", "'.lr/'", ",", "'.ls/'", ",", "'.lt/'", ",", "'.lu/'", ",", "'.lv/'", ",", "'.ly/'", ",", "'.ma/'", ",", "'.mc/'", ",", "'.md/'", ",", "'.me/'", ",", "'.mg/'", ",", "'.mh/'", ",", "'.mk/'", ",", "'.ml/'", ",", "'.mm/'", ",", "'.mn/'", ",", "'.mo/'", ",", "'.mp/'", ",", "'.mq/'", ",", "'.mr/'", ",", "'.ms/'", ",", "'.mt/'", ",", "'.mu/'", ",", "'.mv/'", ",", "'.mw/'", ",", "'.mx/'", ",", "'.my/'", ",", "'.mz/'", ",", "'.na/'", ",", "'.nc/'", ",", "'.ne/'", ",", "'.nf/'", ",", "'.ng/'", ",", "'.ni/'", ",", "'.nl/'", ",", "'.no/'", ",", "'.np/'", ",", "'.nr/'", ",", "'.nu/'", ",", "'.nz/'", ",", "'.om/'", ",", "'.pa/'", ",", "'.pe/'", ",", "'.pf/'", ",", "'.pg/'", ",", "'.ph/'", ",", "'.pk/'", ",", "'.pl/'", ",", "'.pm/'", ",", "'.pn/'", ",", "'.pr/'", ",", "'.ps/'", ",", "'.pt/'", ",", "'.pw/'", ",", "'.py/'", ",", "'.qa/'", ",", "'.re/'", ",", "'.ro/'", ",", "'.rs/'", ",", "'.ru/'", ",", "'.rw/'", ",", "'.sa/'", ",", "'.sb/'", ",", "'.sc/'", ",", "'.sd/'", ",", "'.se/'", ",", "'.sg/'", ",", "'.sh/'", ",", "'.si/'", ",", "'.sj/'", ",", "'.sk/'", ",", "'.sl/'", ",", "'.sm/'", ",", "'.sn/'", ",", "'.so/'", ",", "'.sr/'", ",", "'.ss/'", ",", "'.st/'", ",", "'.su/'", ",", "'.sv/'", ",", "'.sx/'", ",", "'.sy/'", ",", "'.sz/'", ",", "'.tc/'", ",", "'.td/'", ",", "'.tf/'", ",", "'.tg/'", ",", "'.th/'", ",", "'.tj/'", ",", "'.tk/'", ",", "'.tl/'", ",", "'.tm/'", ",", "'.tn/'", ",", "'.to/'", ",", "'.tp/'", ",", "'.tr/'", ",", "'.tt/'", ",", "'.tv/'", ",", "'.tw/'", ",", "'.tz/'", ",", "'.ua/'", ",", "'.ug/'", ",", "'.uk/'", ",", "'.us/'", ",", "'.uy/'", ",", "'.uz/'", ",", "'.va/'", ",", "'.vc/'", ",", "'.ve/'", ",", "'.vg/'", ",", "'.vi/'", ",", "'.vn/'", ",", "'.vu/'", ",", "'.wf/'", ",", "'.ws/'", ",", "'.ye/'", ",", "'.yt/'", ",", "'.yu/'", ",", "'.za/'", ",", "'.zm/'", ",", "'.zr/'", ",", "'.zw/'", ",", "'.academy/'", ",", "'.accountant/'", ",", "'.accountants/'", ",", "'.active/'", ",", "'.actor/'", ",", "'.adult/'", ",", "'.aero/'", ",", "'.agency/'", ",", "'.airforce/'", ",", "'.apartments/'", ",", "'.app/'", ",", "'.archi/'", ",", "'.army/'", ",", "'.associates/'", ",", "'.attorney/'", ",", "'.auction/'", ",", "'.audio/'", ",", "'.autos/'", ",", "'.band/'", ",", "'.bar/'", ",", "'.bargains/'", ",", "'.beer/'", ",", "'.best/'", ",", "'.bid/'", ",", "'.bike/'", ",", "'.bingo/'", ",", "'.bio/'", ",", "'.biz/'", ",", "'.black/'", ",", "'.blackfriday/'", ",", "'.blog/'", ",", "'.blue/'", ",", "'.boo/'", ",", "'.boutique/'", ",", "'.build/'", ",", "'.builders/'", ",", "'.business/'", ",", "'.buzz/'", ",", "'.cab/'", ",", "'.camera/'", ",", "'.camp/'", ",", "'.cancerresearch/'", ",", "'.capital/'", ",", "'.cards/'", ",", "'.care/'", ",", "'.career/'", ",", "'.careers/'", ",", "'.cash/'", ",", "'.casino/'", ",", "'.catering/'", ",", "'.center/'", ",", "'.ceo/'", ",", "'.channel/'", ",", "'.chat/'", ",", "'.cheap/'", ",", "'.christmas/'", ",", "'.church/'", ",", "'.city/'", ",", "'.claims/'", ",", "'.cleaning/'", ",", "'.click/'", ",", "'.clinic/'", ",", "'.clothing/'", ",", "'.club/'", ",", "'.coach/'", ",", "'.codes/'", ",", "'.coffee/'", ",", "'.college/'", ",", "'.community/'", ",", "'.company/'", ",", "'.computer/'", ",", "'.condos/'", ",", "'.construction/'", ",", "'.consulting/'", ",", "'.contractors/'", ",", "'.cooking/'", ",", "'.cool/'", ",", "'.country/'", ",", "'.coupons/'", ",", "'.credit/'", ",", "'.creditcard/'", ",", "'.cricket/'", ",", "'.cruises/'", ",", "'.dad/'", ",", "'.dance/'", ",", "'.date/'", ",", "'.dating/'", ",", "'.day/'", ",", "'.deals/'", ",", "'.degree/'", ",", "'.delivery/'", ",", "'.democrat/'", ",", "'.dental/'", ",", "'.dentist/'", ",", "'.design/'", ",", "'.diamonds/'", ",", "'.diet/'", ",", "'.digital/'", ",", "'.direct/'", ",", "'.directory/'", ",", "'.discount/'", ",", "'.dog/'", ",", "'.domains/'", ",", "'.download/'", ",", "'.eat/'", ",", "'.education/'", ",", "'.email/'", ",", "'.energy/'", ",", "'.engineer/'", ",", "'.engineering/'", ",", "'.equipment/'", ",", "'.esq/'", ",", "'.estate/'", ",", "'.events/'", ",", "'.exchange/'", ",", "'.expert/'", ",", "'.exposed/'", ",", "'.express/'", ",", "'.fail/'", ",", "'.faith/'", ",", "'.fans/'", ",", "'.farm/'", ",", "'.fashion/'", ",", "'.feedback/'", ",", "'.finance/'", ",", "'.financial/'", ",", "'.fish/'", ",", "'.fishing/'", ",", "'.fit/'", ",", "'.fitness/'", ",", "'.flights/'", ",", "'.florist/'", ",", "'.flowers/'", ",", "'.fly/'", ",", "'.foo/'", ",", "'.football/'", ",", "'.forsale/'", ",", "'.foundation/'", ",", "'.fund/'", ",", "'.furniture/'", ",", "'.fyi/'", ",", "'.gallery/'", ",", "'.garden/'", ",", "'.gift/'", ",", "'.gifts/'", ",", "'.gives/'", ",", "'.glass/'", ",", "'.global/'", ",", "'.gold/'", ",", "'.golf/'", ",", "'.gop/'", ",", "'.graphics/'", ",", "'.green/'", ",", "'.gripe/'", ",", "'.guide/'", ",", "'.guitars/'", ",", "'.guru/'", ",", "'.healthcare/'", ",", "'.help/'", ",", "'.here/'", ",", "'.hiphop/'", ",", "'.hiv/'", ",", "'.hockey/'", ",", "'.holdings/'", ",", "'.holiday/'", ",", "'.homes/'", ",", "'.horse/'", ",", "'.host/'", ",", "'.hosting/'", ",", "'.house/'", ",", "'.how/'", ",", "'.info/'", ",", "'.ing/'", ",", "'.ink/'", ",", "'.institute[58]/'", ",", "'.insure/'", ",", "'.international/'", ",", "'.investments/'", ",", "'.jewelry/'", ",", "'.jobs/'", ",", "'.kim/'", ",", "'.kitchen/'", ",", "'.land/'", ",", "'.lawyer/'", ",", "'.lease/'", ",", "'.legal/'", ",", "'.lgbt/'", ",", "'.life/'", ",", "'.lighting/'", ",", "'.limited/'", ",", "'.limo/'", ",", "'.link/'", ",", "'.loan/'", ",", "'.loans/'", ",", "'.lol/'", ",", "'.lotto/'", ",", "'.love/'", ",", "'.luxe/'", ",", "'.luxury/'", ",", "'.management/'", ",", "'.market/'", ",", "'.marketing/'", ",", "'.markets/'", ",", "'.mba/'", ",", "'.media/'", ",", "'.meet/'", ",", "'.meme/'", ",", "'.memorial/'", ",", "'.men/'", ",", "'.menu/'", ",", "'.mobi/'", ",", "'.moe/'", ",", "'.money/'", ",", "'.mortgage/'", ",", "'.motorcycles/'", ",", "'.mov/'", ",", "'.movie/'", ",", "'.museum/'", ",", "'.name/'", ",", "'.navy/'", ",", "'.network/'", ",", "'.new/'", ",", "'.news/'", ",", "'.ngo/'", ",", "'.ninja/'", ",", "'.one/'", ",", "'.ong/'", ",", "'.onl/'", ",", "'.online/'", ",", "'.ooo/'", ",", "'.organic/'", ",", "'.partners/'", ",", "'.parts/'", ",", "'.party/'", ",", "'.pharmacy/'", ",", "'.photo/'", ",", "'.photography/'", ",", "'.photos/'", ",", "'.physio/'", ",", "'.pics/'", ",", "'.pictures/'", ",", "'.pink/'", ",", "'.pizza/'", ",", "'.place/'", ",", "'.plumbing/'", ",", "'.plus/'", ",", "'.poker/'", ",", "'.porn/'", ",", "'.post/'", ",", "'.press/'", ",", "'.pro/'", ",", "'.productions/'", ",", "'.prof/'", ",", "'.properties/'", ",", "'.property/'", ",", "'.qpon/'", ",", "'.racing/'", ",", "'.recipes/'", ",", "'.red/'", ",", "'.rehab/'", ",", "'.ren/'", ",", "'.rent/'", ",", "'.rentals/'", ",", "'.repair/'", ",", "'.report/'", ",", "'.republican/'", ",", "'.rest/'", ",", "'.review/'", ",", "'.reviews/'", ",", "'.rich/'", ",", "'.rip/'", ",", "'.rocks/'", ",", "'.rodeo/'", ",", "'.rsvp/'", ",", "'.run/'", ",", "'.sale/'", ",", "'.school/'", ",", "'.science/'", ",", "'.services/'", ",", "'.sex/'", ",", "'.sexy/'", ",", "'.shoes/'", ",", "'.show/'", ",", "'.singles/'", ",", "'.site/'", ",", "'.soccer/'", ",", "'.social/'", ",", "'.software/'", ",", "'.solar/'", ",", "'.solutions/'", ",", "'.space/'", ",", "'.studio/'", ",", "'.style/'", ",", "'.sucks/'", ",", "'.supplies/'", ",", "'.supply/'", ",", "'.support/'", ",", "'.surf/'", ",", "'.surgery/'", ",", "'.systems/'", ",", "'.tattoo/'", ",", "'.tax/'", ",", "'.taxi/'", ",", "'.team/'", ",", "'.technology/'", ",", "'.tel/'", ",", "'.tennis/'", ",", "'.theater/'", ",", "'.tips/'", ",", "'.tires/'", ",", "'.today/'", ",", "'.tools/'", ",", "'.top/'", ",", "'.tours/'", ",", "'.town/'", ",", "'.toys/'", ",", "'.trade/'", ",", "'.training/'", ",", "'.travel/'", ",", "'.university/'", ",", "'.vacations/'", ",", "'.vet/'", ",", "'.video/'", ",", "'.villas/'", ",", "'.vision/'", ",", "'.vodka/'", ",", "'.vote/'", ",", "'.voting/'", ",", "'.voyage/'", ",", "'.wang/'", ",", "'.watch/'", ",", "'.webcam/'", ",", "'.website/'", ",", "'.wed/'", ",", "'.wedding/'", ",", "'.whoswho/'", ",", "'.wiki/'", ",", "'.win/'", ",", "'.work/'", ",", "'.works/'", ",", "'.world/'", ",", "'.wtf/'", ",", "'.xxx/'", ",", "'.xyz/'", ",", "'.yoga/'", ",", "'.zone/'", ",", "'.maison/'", ",", "'.abogado/'", ",", "'.gratis/'", ",", "'.futbol/'", ",", "'.juegos/'", ",", "'.soy/'", ",", "'.tienda/'", ",", "'.uno/'", ",", "'.viajes/'", ",", "'.haus/'", ",", "'.immobilien/'", ",", "'.jetzt/'", ",", "'.kaufen/'", ",", "'.reise/'", ",", "'.reisen/'", ",", "'.schule/'", ",", "'.versicherung/'", ",", "'.desi/'", ",", "'.shiksha/'", ",", "'.casa/'", ",", "'.cafe/'", ",", "'.immo/'", ",", "'.moda/'", ",", "'.voto/'", ",", "'.bar/'", ",", "'.bank/'", ",", "'.coop/'", ",", "'.enterprises/'", ",", "'.industries/'", ",", "'.institute/'", ",", "'.ltda/'", ",", "'.pub/'", ",", "'.realtor/'", ",", "'.reit/'", ",", "'.rest/'", ",", "'.restaurant/'", ",", "'.sarl/'", ",", "'.ventures/'", ",", "'.capetown/'", ",", "'.durban/'", ",", "'.joburg/'", ",", "'.asia/'", ",", "'.krd/'", ",", "'.nagoya/'", ",", "'.okinawa/'", ",", "'.ryukyu/'", ",", "'.taipei/'", ",", "'.tatar/'", ",", "'.tokyo/'", ",", "'.yokohama/'", ",", "'.alsace/'", ",", "'.amsterdam/'", ",", "'.barcelona/'", ",", "'.bayern/'", ",", "'.berlin/'", ",", "'.brussels/'", ",", "'.budapest/'", ",", "'.bzh/'", ",", "'.cat/'", ",", "'.cologne/'", ",", "'.cymru/'", ",", "'.eus/'", ",", "'.frl/'", ",", "'.gal/'", ",", "'.gent/'", ",", "'.hamburg/'", ",", "'.irish/'", ",", "'.koeln/'", ",", "'.london/'", ",", "'.madrid/'", ",", "'.moscow/'", ",", "'.nrw/'", ",", "'.paris/'", ",", "'.ruhr/'", ",", "'.saarland/'", ",", "'.scot/'", ",", "'.tirol/'", ",", "'.vlaanderen/'", ",", "'.wales/'", ",", "'.wien/'", ",", "'.zuerich/'", ",", "'.miami/'", ",", "'.nyc/'", ",", "'.quebec/'", ",", "'.vegas/'", ",", "'.kiwi/'", ",", "'.melbourne/'", ",", "'.sydney/'", ",", "'.lat/'", ",", "'.rio/'", ",", "'.allfinanz/'", ",", "'.android/'", ",", "'.aquarelle/'", ",", "'.axa/'", ",", "'.barclays/'", ",", "'.barclaycard/'", ",", "'.bloomberg/'", ",", "'.bmw/'", ",", "'.bnl/'", ",", "'.bnpparibas/'", ",", "'.cal/'", ",", "'.caravan/'", ",", "'.cern/'", ",", "'.chrome/'", ",", "'.citic/'", ",", "'.crs/'", ",", "'.cuisinella/'", ",", "'.dnp/'", ",", "'.dvag/'", ",", "'.emerck/'", ",", "'.everbank/'", ",", "'.firmdale/'", ",", "'.flsmidth/'", ",", "'.frogans/'", ",", "'.gbiz/'", ",", "'.gle/'", ",", "'.globo/'", ",", "'.gmail/'", ",", "'.gmo/'", ",", "'.gmx/'", ",", "'.google/'", ",", "'.hsbc/'", ",", "'.ibm/'", ",", "'.kred/'", ",", "'.lacaixa/'", ",", "'.latrobe/'", ",", "'.lds/'", ",", "'.mango/'", ",", "'.mini/'", ",", "'.monash/'", ",", "'.mormon/'", ",", "'.neustar/'", ",", "'.nexus/'", ",", "'.nhk/'", ",", "'.nico/'", ",", "'.nra/'", ",", "'.otsuka/'", ",", "'.ovh/'", ",", "'.piaget/'", ",", "'.pohl/'", ",", "'.praxi/'", ",", "'.prod/'", ",", "'.sca/'", ",", "'.scb/'", ",", "'.schmidt/'", ",", "'.sohu/'", ",", "'.spiegel/'", ",", "'.suzuki/'", ",", "'.tui/'", ",", "'.uol/'", ",", "'.williamhill/'", ",", "'.wme/'", ",", "'.wtc/'", ",", "'.yandex/'", ",", "'.youtube/'", "]", ";", "$", "explode", "=", "$", "this", "->", "explodeWhere", "(", "$", "url", ",", "$", "tld", ")", ";", "return", "end", "(", "$", "explode", ")", ".", "'/'", ";", "}" ]
@param $route @param array $params @return mixed
[ "@param", "$route", "@param", "array", "$params" ]
train
https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Http/Controllers/Controller.php#L112-L123
austinkregel/Warden
src/Warden/Http/Controllers/Controller.php
Controller.explodeWhere
private function explodeWhere($string, $array) { $returnable = []; foreach ($array as $a) { if (stripos($string, $a) !== false) { $returnable = array_merge($returnable, explode($a, $string)); } } return $returnable; }
php
private function explodeWhere($string, $array) { $returnable = []; foreach ($array as $a) { if (stripos($string, $a) !== false) { $returnable = array_merge($returnable, explode($a, $string)); } } return $returnable; }
[ "private", "function", "explodeWhere", "(", "$", "string", ",", "$", "array", ")", "{", "$", "returnable", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "a", ")", "{", "if", "(", "stripos", "(", "$", "string", ",", "$", "a", ")", "!==", "false", ")", "{", "$", "returnable", "=", "array_merge", "(", "$", "returnable", ",", "explode", "(", "$", "a", ",", "$", "string", ")", ")", ";", "}", "}", "return", "$", "returnable", ";", "}" ]
@param $string @param $array @return array
[ "@param", "$string", "@param", "$array" ]
train
https://github.com/austinkregel/Warden/blob/6f5a98bd79a488f0f300f4851061ac6f7d19f8a3/src/Warden/Http/Controllers/Controller.php#L131-L141
geekwright/Po
src/PoInitPHP.php
PoInitPHP.msginitString
public function msginitString(string $source, string $refname): PoFile { if (!($this->poFile instanceof PoFile)) { $this->poFile = new PoFile; } $tokens = token_get_all($source); $translateTags = array_merge($this->gettextTags, $this->pgettextTags, $this->ngettextTags); $commentText=null; $commentLine=(-10); $tokenCount = count($tokens); $i = 0; while ($i<$tokenCount) { $token = $tokens[$i]; if (is_array($token) && $token[0] == T_STRING && in_array($token[1], $translateTags)) { $entry = new PoEntry; $gtt = array(); list(, $text, $line) = $token; $entry->add(PoTokens::REFERENCE, $refname . ':' . $line); $gtt['line']=$line; $gtt['function']=$text; $gtt['args'] = array(); $la = 1; while (is_array($tokens[$i + $la]) && $tokens[$i + $la][0] == T_WHITESPACE) { $la++; } if ($tokens[$i + $la] == '(') { while ((')' != $token=$tokens[$i + $la]) && ($la < 10)) { if (is_array($token) && ( $token[0] == T_CONSTANT_ENCAPSED_STRING || $token[0] == T_ENCAPSED_AND_WHITESPACE )) { list(, $text, $line) = $token; $gtt['args'][]=$text; } $la++; } if (count($gtt['args'])) { if (in_array($gtt['function'], $this->gettextTags)) { $entry->set(PoTokens::MESSAGE, $this->escapeForPo($gtt['args'][0])); } elseif (count($gtt['args'])>1 && in_array($gtt['function'], $this->pgettextTags)) { $entry->set(PoTokens::CONTEXT, $this->escapeForPo($gtt['args'][0])); $entry->set(PoTokens::MESSAGE, $this->escapeForPo($gtt['args'][1])); } elseif (count($gtt['args'])>1 && in_array($gtt['function'], $this->ngettextTags)) { $entry->set(PoTokens::MESSAGE, $this->escapeForPo($gtt['args'][0])); $entry->set(PoTokens::PLURAL, $this->escapeForPo($gtt['args'][1])); } $this->checkPhpFormatFlag($entry); if ($gtt['line']==($commentLine+1)) { $entry->set(PoTokens::EXTRACTED_COMMENTS, $this->stripComment($commentText)); } $this->poFile->mergeEntry($entry); } } } elseif (is_array($token) && $token[0] == T_COMMENT) { list(, $commentText, $commentLine) = $token; } $i++; } return $this->poFile; }
php
public function msginitString(string $source, string $refname): PoFile { if (!($this->poFile instanceof PoFile)) { $this->poFile = new PoFile; } $tokens = token_get_all($source); $translateTags = array_merge($this->gettextTags, $this->pgettextTags, $this->ngettextTags); $commentText=null; $commentLine=(-10); $tokenCount = count($tokens); $i = 0; while ($i<$tokenCount) { $token = $tokens[$i]; if (is_array($token) && $token[0] == T_STRING && in_array($token[1], $translateTags)) { $entry = new PoEntry; $gtt = array(); list(, $text, $line) = $token; $entry->add(PoTokens::REFERENCE, $refname . ':' . $line); $gtt['line']=$line; $gtt['function']=$text; $gtt['args'] = array(); $la = 1; while (is_array($tokens[$i + $la]) && $tokens[$i + $la][0] == T_WHITESPACE) { $la++; } if ($tokens[$i + $la] == '(') { while ((')' != $token=$tokens[$i + $la]) && ($la < 10)) { if (is_array($token) && ( $token[0] == T_CONSTANT_ENCAPSED_STRING || $token[0] == T_ENCAPSED_AND_WHITESPACE )) { list(, $text, $line) = $token; $gtt['args'][]=$text; } $la++; } if (count($gtt['args'])) { if (in_array($gtt['function'], $this->gettextTags)) { $entry->set(PoTokens::MESSAGE, $this->escapeForPo($gtt['args'][0])); } elseif (count($gtt['args'])>1 && in_array($gtt['function'], $this->pgettextTags)) { $entry->set(PoTokens::CONTEXT, $this->escapeForPo($gtt['args'][0])); $entry->set(PoTokens::MESSAGE, $this->escapeForPo($gtt['args'][1])); } elseif (count($gtt['args'])>1 && in_array($gtt['function'], $this->ngettextTags)) { $entry->set(PoTokens::MESSAGE, $this->escapeForPo($gtt['args'][0])); $entry->set(PoTokens::PLURAL, $this->escapeForPo($gtt['args'][1])); } $this->checkPhpFormatFlag($entry); if ($gtt['line']==($commentLine+1)) { $entry->set(PoTokens::EXTRACTED_COMMENTS, $this->stripComment($commentText)); } $this->poFile->mergeEntry($entry); } } } elseif (is_array($token) && $token[0] == T_COMMENT) { list(, $commentText, $commentLine) = $token; } $i++; } return $this->poFile; }
[ "public", "function", "msginitString", "(", "string", "$", "source", ",", "string", "$", "refname", ")", ":", "PoFile", "{", "if", "(", "!", "(", "$", "this", "->", "poFile", "instanceof", "PoFile", ")", ")", "{", "$", "this", "->", "poFile", "=", "new", "PoFile", ";", "}", "$", "tokens", "=", "token_get_all", "(", "$", "source", ")", ";", "$", "translateTags", "=", "array_merge", "(", "$", "this", "->", "gettextTags", ",", "$", "this", "->", "pgettextTags", ",", "$", "this", "->", "ngettextTags", ")", ";", "$", "commentText", "=", "null", ";", "$", "commentLine", "=", "(", "-", "10", ")", ";", "$", "tokenCount", "=", "count", "(", "$", "tokens", ")", ";", "$", "i", "=", "0", ";", "while", "(", "$", "i", "<", "$", "tokenCount", ")", "{", "$", "token", "=", "$", "tokens", "[", "$", "i", "]", ";", "if", "(", "is_array", "(", "$", "token", ")", "&&", "$", "token", "[", "0", "]", "==", "T_STRING", "&&", "in_array", "(", "$", "token", "[", "1", "]", ",", "$", "translateTags", ")", ")", "{", "$", "entry", "=", "new", "PoEntry", ";", "$", "gtt", "=", "array", "(", ")", ";", "list", "(", ",", "$", "text", ",", "$", "line", ")", "=", "$", "token", ";", "$", "entry", "->", "add", "(", "PoTokens", "::", "REFERENCE", ",", "$", "refname", ".", "':'", ".", "$", "line", ")", ";", "$", "gtt", "[", "'line'", "]", "=", "$", "line", ";", "$", "gtt", "[", "'function'", "]", "=", "$", "text", ";", "$", "gtt", "[", "'args'", "]", "=", "array", "(", ")", ";", "$", "la", "=", "1", ";", "while", "(", "is_array", "(", "$", "tokens", "[", "$", "i", "+", "$", "la", "]", ")", "&&", "$", "tokens", "[", "$", "i", "+", "$", "la", "]", "[", "0", "]", "==", "T_WHITESPACE", ")", "{", "$", "la", "++", ";", "}", "if", "(", "$", "tokens", "[", "$", "i", "+", "$", "la", "]", "==", "'('", ")", "{", "while", "(", "(", "')'", "!=", "$", "token", "=", "$", "tokens", "[", "$", "i", "+", "$", "la", "]", ")", "&&", "(", "$", "la", "<", "10", ")", ")", "{", "if", "(", "is_array", "(", "$", "token", ")", "&&", "(", "$", "token", "[", "0", "]", "==", "T_CONSTANT_ENCAPSED_STRING", "||", "$", "token", "[", "0", "]", "==", "T_ENCAPSED_AND_WHITESPACE", ")", ")", "{", "list", "(", ",", "$", "text", ",", "$", "line", ")", "=", "$", "token", ";", "$", "gtt", "[", "'args'", "]", "[", "]", "=", "$", "text", ";", "}", "$", "la", "++", ";", "}", "if", "(", "count", "(", "$", "gtt", "[", "'args'", "]", ")", ")", "{", "if", "(", "in_array", "(", "$", "gtt", "[", "'function'", "]", ",", "$", "this", "->", "gettextTags", ")", ")", "{", "$", "entry", "->", "set", "(", "PoTokens", "::", "MESSAGE", ",", "$", "this", "->", "escapeForPo", "(", "$", "gtt", "[", "'args'", "]", "[", "0", "]", ")", ")", ";", "}", "elseif", "(", "count", "(", "$", "gtt", "[", "'args'", "]", ")", ">", "1", "&&", "in_array", "(", "$", "gtt", "[", "'function'", "]", ",", "$", "this", "->", "pgettextTags", ")", ")", "{", "$", "entry", "->", "set", "(", "PoTokens", "::", "CONTEXT", ",", "$", "this", "->", "escapeForPo", "(", "$", "gtt", "[", "'args'", "]", "[", "0", "]", ")", ")", ";", "$", "entry", "->", "set", "(", "PoTokens", "::", "MESSAGE", ",", "$", "this", "->", "escapeForPo", "(", "$", "gtt", "[", "'args'", "]", "[", "1", "]", ")", ")", ";", "}", "elseif", "(", "count", "(", "$", "gtt", "[", "'args'", "]", ")", ">", "1", "&&", "in_array", "(", "$", "gtt", "[", "'function'", "]", ",", "$", "this", "->", "ngettextTags", ")", ")", "{", "$", "entry", "->", "set", "(", "PoTokens", "::", "MESSAGE", ",", "$", "this", "->", "escapeForPo", "(", "$", "gtt", "[", "'args'", "]", "[", "0", "]", ")", ")", ";", "$", "entry", "->", "set", "(", "PoTokens", "::", "PLURAL", ",", "$", "this", "->", "escapeForPo", "(", "$", "gtt", "[", "'args'", "]", "[", "1", "]", ")", ")", ";", "}", "$", "this", "->", "checkPhpFormatFlag", "(", "$", "entry", ")", ";", "if", "(", "$", "gtt", "[", "'line'", "]", "==", "(", "$", "commentLine", "+", "1", ")", ")", "{", "$", "entry", "->", "set", "(", "PoTokens", "::", "EXTRACTED_COMMENTS", ",", "$", "this", "->", "stripComment", "(", "$", "commentText", ")", ")", ";", "}", "$", "this", "->", "poFile", "->", "mergeEntry", "(", "$", "entry", ")", ";", "}", "}", "}", "elseif", "(", "is_array", "(", "$", "token", ")", "&&", "$", "token", "[", "0", "]", "==", "T_COMMENT", ")", "{", "list", "(", ",", "$", "commentText", ",", "$", "commentLine", ")", "=", "$", "token", ";", "}", "$", "i", "++", ";", "}", "return", "$", "this", "->", "poFile", ";", "}" ]
Inspect the supplied source, capture gettext references as a PoFile object. @param string $source php source code @param string $refname source identification used for PO reference comments @return PoFile
[ "Inspect", "the", "supplied", "source", "capture", "gettext", "references", "as", "a", "PoFile", "object", "." ]
train
https://github.com/geekwright/Po/blob/9474d059a83b64e6242cc41e5c5b7a08bc57e4e2/src/PoInitPHP.php#L52-L114
ClanCats/Core
src/classes/CCForge/Php.php
CCForge_Php.make
public static function make( $cmd, $params ) { if ( !is_array( $params ) ) { $params = array( $params ); } $forge = new static; if ( !method_exists( $forge, $cmd ) ) { throw new CCException( "CCForge_Php - Command could not be found." ); } return call_user_func_array( array( $forge, $cmd ), $params ); }
php
public static function make( $cmd, $params ) { if ( !is_array( $params ) ) { $params = array( $params ); } $forge = new static; if ( !method_exists( $forge, $cmd ) ) { throw new CCException( "CCForge_Php - Command could not be found." ); } return call_user_func_array( array( $forge, $cmd ), $params ); }
[ "public", "static", "function", "make", "(", "$", "cmd", ",", "$", "params", ")", "{", "if", "(", "!", "is_array", "(", "$", "params", ")", ")", "{", "$", "params", "=", "array", "(", "$", "params", ")", ";", "}", "$", "forge", "=", "new", "static", ";", "if", "(", "!", "method_exists", "(", "$", "forge", ",", "$", "cmd", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCForge_Php - Command could not be found.\"", ")", ";", "}", "return", "call_user_func_array", "(", "array", "(", "$", "forge", ",", "$", "cmd", ")", ",", "$", "params", ")", ";", "}" ]
runs a forge command on a dummy forge @param string $cmd @param array $params @return string
[ "runs", "a", "forge", "command", "on", "a", "dummy", "forge" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCForge/Php.php#L33-L48
ClanCats/Core
src/classes/CCForge/Php.php
CCForge_Php.comment
public function comment( $str, $wordwrap = 80 ) { $str = trim( wordwrap( $str, $wordwrap ) ); $str = str_replace( "\n", "\n".' * ', $str ); $str = str_replace( "\n".' * *', "\n".' **', $str ); return $this->add( "/**\n * ".$str."\n */" ); }
php
public function comment( $str, $wordwrap = 80 ) { $str = trim( wordwrap( $str, $wordwrap ) ); $str = str_replace( "\n", "\n".' * ', $str ); $str = str_replace( "\n".' * *', "\n".' **', $str ); return $this->add( "/**\n * ".$str."\n */" ); }
[ "public", "function", "comment", "(", "$", "str", ",", "$", "wordwrap", "=", "80", ")", "{", "$", "str", "=", "trim", "(", "wordwrap", "(", "$", "str", ",", "$", "wordwrap", ")", ")", ";", "$", "str", "=", "str_replace", "(", "\"\\n\"", ",", "\"\\n\"", ".", "' * '", ",", "$", "str", ")", ";", "$", "str", "=", "str_replace", "(", "\"\\n\"", ".", "' * *'", ",", "\"\\n\"", ".", "' **'", ",", "$", "str", ")", ";", "return", "$", "this", "->", "add", "(", "\"/**\\n * \"", ".", "$", "str", ".", "\"\\n */\"", ")", ";", "}" ]
generates an PHP comment @param string $str @param int $wordwrap @return string
[ "generates", "an", "PHP", "comment" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCForge/Php.php#L124-L130
ClanCats/Core
src/classes/CCForge/Php.php
CCForge_Php.closure
public function closure( $name, $content = null, $comment ) { return $this->add( ( $comment ? static::make( 'comment', array( $comment ) )."\n" : '' ). $name."\n{\n".str_replace( "\n", "\n\t", "\t".CCStr::capture( $content ) )."\n}" ); }
php
public function closure( $name, $content = null, $comment ) { return $this->add( ( $comment ? static::make( 'comment', array( $comment ) )."\n" : '' ). $name."\n{\n".str_replace( "\n", "\n\t", "\t".CCStr::capture( $content ) )."\n}" ); }
[ "public", "function", "closure", "(", "$", "name", ",", "$", "content", "=", "null", ",", "$", "comment", ")", "{", "return", "$", "this", "->", "add", "(", "(", "$", "comment", "?", "static", "::", "make", "(", "'comment'", ",", "array", "(", "$", "comment", ")", ")", ".", "\"\\n\"", ":", "''", ")", ".", "$", "name", ".", "\"\\n{\\n\"", ".", "str_replace", "(", "\"\\n\"", ",", "\"\\n\\t\"", ",", "\"\\t\"", ".", "CCStr", "::", "capture", "(", "$", "content", ")", ")", ".", "\"\\n}\"", ")", ";", "}" ]
generates an closure @param string $str @param int $wordwrap @return string
[ "generates", "an", "closure" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCForge/Php.php#L139-L143
ClanCats/Core
src/classes/CCForge/Php.php
CCForge_Php.a_class
public function a_class( $name, $content, $extends = null, $implements = null ) { return $this->add( $this->closure( "class ".$name. ( $extends ? ' extends '.$extends : '' ). ( $implements ? ' implements '.$implements : '' ), $content ) ); }
php
public function a_class( $name, $content, $extends = null, $implements = null ) { return $this->add( $this->closure( "class ".$name. ( $extends ? ' extends '.$extends : '' ). ( $implements ? ' implements '.$implements : '' ), $content ) ); }
[ "public", "function", "a_class", "(", "$", "name", ",", "$", "content", ",", "$", "extends", "=", "null", ",", "$", "implements", "=", "null", ")", "{", "return", "$", "this", "->", "add", "(", "$", "this", "->", "closure", "(", "\"class \"", ".", "$", "name", ".", "(", "$", "extends", "?", "' extends '", ".", "$", "extends", ":", "''", ")", ".", "(", "$", "implements", "?", "' implements '", ".", "$", "implements", ":", "''", ")", ",", "$", "content", ")", ")", ";", "}" ]
generates an PHP class @param string $str @param int $wordwrap @return string
[ "generates", "an", "PHP", "class" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCForge/Php.php#L152-L157
ClanCats/Core
src/classes/CCForge/Php.php
CCForge_Php.property
public function property( $name, $default = null, $comment = null, $export = true ) { if ( $default !== null ) { if ( $export ) { $default = var_export( $default, true ); } } return $this->add( ( $comment ? static::make( 'comment', array( $comment ) )."\n" : '' ). $name.( $default !== null ? ' = '. $default : '' ).';' ); }
php
public function property( $name, $default = null, $comment = null, $export = true ) { if ( $default !== null ) { if ( $export ) { $default = var_export( $default, true ); } } return $this->add( ( $comment ? static::make( 'comment', array( $comment ) )."\n" : '' ). $name.( $default !== null ? ' = '. $default : '' ).';' ); }
[ "public", "function", "property", "(", "$", "name", ",", "$", "default", "=", "null", ",", "$", "comment", "=", "null", ",", "$", "export", "=", "true", ")", "{", "if", "(", "$", "default", "!==", "null", ")", "{", "if", "(", "$", "export", ")", "{", "$", "default", "=", "var_export", "(", "$", "default", ",", "true", ")", ";", "}", "}", "return", "$", "this", "->", "add", "(", "(", "$", "comment", "?", "static", "::", "make", "(", "'comment'", ",", "array", "(", "$", "comment", ")", ")", ".", "\"\\n\"", ":", "''", ")", ".", "$", "name", ".", "(", "$", "default", "!==", "null", "?", "' = '", ".", "$", "default", ":", "''", ")", ".", "';'", ")", ";", "}" ]
generates a class property @param string $str @param int $wordwrap @return string
[ "generates", "a", "class", "property" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCForge/Php.php#L166-L178
PortaText/php-sdk
src/PortaText/Command/Api/Settings.php
Settings.enableAutoRecharges
public function enableAutoRecharges($whenCredit, $total) { $this->setArgument("autorecharge_enabled", true); $this->setArgument("autorecharge_total", $total); return $this->setArgument("autorecharge_when_credit", $whenCredit); }
php
public function enableAutoRecharges($whenCredit, $total) { $this->setArgument("autorecharge_enabled", true); $this->setArgument("autorecharge_total", $total); return $this->setArgument("autorecharge_when_credit", $whenCredit); }
[ "public", "function", "enableAutoRecharges", "(", "$", "whenCredit", ",", "$", "total", ")", "{", "$", "this", "->", "setArgument", "(", "\"autorecharge_enabled\"", ",", "true", ")", ";", "$", "this", "->", "setArgument", "(", "\"autorecharge_total\"", ",", "$", "total", ")", ";", "return", "$", "this", "->", "setArgument", "(", "\"autorecharge_when_credit\"", ",", "$", "whenCredit", ")", ";", "}" ]
Enables auto recharges. @param integer $whenCredit Autorecharge when credit reaches this amount. @param float $total Total credits to autorecharge. @return PortaText\Command\ICommand
[ "Enables", "auto", "recharges", "." ]
train
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/Settings.php#L72-L77
PortaText/php-sdk
src/PortaText/Command/Api/Settings.php
Settings.publishEventsToSns
public function publishEventsToSns($key, $secret, $topicArn) { $this->setArgument("sns_publish_enabled", true); $this->setArgument("sns_access_key", $key); $this->setArgument("sns_access_secret", $secret); return $this->setArgument("sns_topic", $topicArn); }
php
public function publishEventsToSns($key, $secret, $topicArn) { $this->setArgument("sns_publish_enabled", true); $this->setArgument("sns_access_key", $key); $this->setArgument("sns_access_secret", $secret); return $this->setArgument("sns_topic", $topicArn); }
[ "public", "function", "publishEventsToSns", "(", "$", "key", ",", "$", "secret", ",", "$", "topicArn", ")", "{", "$", "this", "->", "setArgument", "(", "\"sns_publish_enabled\"", ",", "true", ")", ";", "$", "this", "->", "setArgument", "(", "\"sns_access_key\"", ",", "$", "key", ")", ";", "$", "this", "->", "setArgument", "(", "\"sns_access_secret\"", ",", "$", "secret", ")", ";", "return", "$", "this", "->", "setArgument", "(", "\"sns_topic\"", ",", "$", "topicArn", ")", ";", "}" ]
Enables publishing of events to an SNS topic. @param string $key Amazon AWS access key. @param string $secret Amazon AWS access secret. @param string $topicArn SNS Topic ARN. @return PortaText\Command\ICommand
[ "Enables", "publishing", "of", "events", "to", "an", "SNS", "topic", "." ]
train
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/Settings.php#L225-L231
slashworks/control-bundle
src/Slashworks/AppBundle/Form/Type/RemoteAppType.php
RemoteAppType.buildForm
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('type'); $builder->add('name'); $builder->add('domain'); $builder->add('apiUrl'); $builder->add('apiAuthType','choice',array( "choices" => array( 'none' => "remote_app.apiAuthType.none", 'http-basic' => "remote_app.apiAuthType.http-basic", 'url-user-password' => "remote_app.apiAuthType.url-user-password", 'url-token' => "remote_app.apiAuthType.url-token" ) )); $builder->add('apiAuthUser'); $builder->add('apiAuthPassword'); $builder->add('apiAuthHttpUser'); $builder->add('apiAuthHttpPassword'); $builder->add('apiAuthToken'); $builder->add('notificationRecipient'); $builder->add('notificationSender'); $builder->add('notification_change',null, array("required" => false)); $builder->add('notification_error',null, array("required" => false)); $builder->add('notificationSender'); $builder->add('apiAuthUrlUserKey'); $builder->add('apiAuthUrlPwKey'); $builder->add('cron'); $builder->add('customer','model',array( 'class' => 'Slashworks\AppBundle\Model\Customer', 'property' => 'name' )); $builder->add('activated',null, array("required" => false)); $builder->add('notes'); $builder->add('includeLog',null, array("required" => false)); }
php
public function buildForm(FormBuilderInterface $builder, array $options) { $builder->add('type'); $builder->add('name'); $builder->add('domain'); $builder->add('apiUrl'); $builder->add('apiAuthType','choice',array( "choices" => array( 'none' => "remote_app.apiAuthType.none", 'http-basic' => "remote_app.apiAuthType.http-basic", 'url-user-password' => "remote_app.apiAuthType.url-user-password", 'url-token' => "remote_app.apiAuthType.url-token" ) )); $builder->add('apiAuthUser'); $builder->add('apiAuthPassword'); $builder->add('apiAuthHttpUser'); $builder->add('apiAuthHttpPassword'); $builder->add('apiAuthToken'); $builder->add('notificationRecipient'); $builder->add('notificationSender'); $builder->add('notification_change',null, array("required" => false)); $builder->add('notification_error',null, array("required" => false)); $builder->add('notificationSender'); $builder->add('apiAuthUrlUserKey'); $builder->add('apiAuthUrlPwKey'); $builder->add('cron'); $builder->add('customer','model',array( 'class' => 'Slashworks\AppBundle\Model\Customer', 'property' => 'name' )); $builder->add('activated',null, array("required" => false)); $builder->add('notes'); $builder->add('includeLog',null, array("required" => false)); }
[ "public", "function", "buildForm", "(", "FormBuilderInterface", "$", "builder", ",", "array", "$", "options", ")", "{", "$", "builder", "->", "add", "(", "'type'", ")", ";", "$", "builder", "->", "add", "(", "'name'", ")", ";", "$", "builder", "->", "add", "(", "'domain'", ")", ";", "$", "builder", "->", "add", "(", "'apiUrl'", ")", ";", "$", "builder", "->", "add", "(", "'apiAuthType'", ",", "'choice'", ",", "array", "(", "\"choices\"", "=>", "array", "(", "'none'", "=>", "\"remote_app.apiAuthType.none\"", ",", "'http-basic'", "=>", "\"remote_app.apiAuthType.http-basic\"", ",", "'url-user-password'", "=>", "\"remote_app.apiAuthType.url-user-password\"", ",", "'url-token'", "=>", "\"remote_app.apiAuthType.url-token\"", ")", ")", ")", ";", "$", "builder", "->", "add", "(", "'apiAuthUser'", ")", ";", "$", "builder", "->", "add", "(", "'apiAuthPassword'", ")", ";", "$", "builder", "->", "add", "(", "'apiAuthHttpUser'", ")", ";", "$", "builder", "->", "add", "(", "'apiAuthHttpPassword'", ")", ";", "$", "builder", "->", "add", "(", "'apiAuthToken'", ")", ";", "$", "builder", "->", "add", "(", "'notificationRecipient'", ")", ";", "$", "builder", "->", "add", "(", "'notificationSender'", ")", ";", "$", "builder", "->", "add", "(", "'notification_change'", ",", "null", ",", "array", "(", "\"required\"", "=>", "false", ")", ")", ";", "$", "builder", "->", "add", "(", "'notification_error'", ",", "null", ",", "array", "(", "\"required\"", "=>", "false", ")", ")", ";", "$", "builder", "->", "add", "(", "'notificationSender'", ")", ";", "$", "builder", "->", "add", "(", "'apiAuthUrlUserKey'", ")", ";", "$", "builder", "->", "add", "(", "'apiAuthUrlPwKey'", ")", ";", "$", "builder", "->", "add", "(", "'cron'", ")", ";", "$", "builder", "->", "add", "(", "'customer'", ",", "'model'", ",", "array", "(", "'class'", "=>", "'Slashworks\\AppBundle\\Model\\Customer'", ",", "'property'", "=>", "'name'", ")", ")", ";", "$", "builder", "->", "add", "(", "'activated'", ",", "null", ",", "array", "(", "\"required\"", "=>", "false", ")", ")", ";", "$", "builder", "->", "add", "(", "'notes'", ")", ";", "$", "builder", "->", "add", "(", "'includeLog'", ",", "null", ",", "array", "(", "\"required\"", "=>", "false", ")", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Form/Type/RemoteAppType.php#L45-L79
jenwachter/html-form
src/Utility/Sanitizer.php
Sanitizer.apply
protected function apply($function, $args = array()) { foreach ($this->data as $key => &$value) { if (!is_array($value)) { $value = $this->applyToValue($function, $args, $value); } else { $value = array_map(function ($v) use ($function, $args) { return $this->applyToValue($function, $args, $v); }, $value); } } }
php
protected function apply($function, $args = array()) { foreach ($this->data as $key => &$value) { if (!is_array($value)) { $value = $this->applyToValue($function, $args, $value); } else { $value = array_map(function ($v) use ($function, $args) { return $this->applyToValue($function, $args, $v); }, $value); } } }
[ "protected", "function", "apply", "(", "$", "function", ",", "$", "args", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "this", "->", "data", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "applyToValue", "(", "$", "function", ",", "$", "args", ",", "$", "value", ")", ";", "}", "else", "{", "$", "value", "=", "array_map", "(", "function", "(", "$", "v", ")", "use", "(", "$", "function", ",", "$", "args", ")", "{", "return", "$", "this", "->", "applyToValue", "(", "$", "function", ",", "$", "args", ",", "$", "v", ")", ";", "}", ",", "$", "value", ")", ";", "}", "}", "}" ]
Apply a function to each value @param string $function Function name (ex: "stripslashes") @param array $args Function arguments @return null
[ "Apply", "a", "function", "to", "each", "value" ]
train
https://github.com/jenwachter/html-form/blob/eaece87d474f7da5c25679548fb8f1608a94303c/src/Utility/Sanitizer.php#L28-L41
CakeCMS/Core
src/Controller/AppController.php
AppController.initialize
public function initialize() { parent::initialize(); $this->cms = Cms::getInstance(); $this->_setTheme(); $pluginEvent = Plugin::getData('Core', 'Controller.initialize'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.initialize')) { call_user_func_array($pluginEvent->find(0), [$this]); } }
php
public function initialize() { parent::initialize(); $this->cms = Cms::getInstance(); $this->_setTheme(); $pluginEvent = Plugin::getData('Core', 'Controller.initialize'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.initialize')) { call_user_func_array($pluginEvent->find(0), [$this]); } }
[ "public", "function", "initialize", "(", ")", "{", "parent", "::", "initialize", "(", ")", ";", "$", "this", "->", "cms", "=", "Cms", "::", "getInstance", "(", ")", ";", "$", "this", "->", "_setTheme", "(", ")", ";", "$", "pluginEvent", "=", "Plugin", "::", "getData", "(", "'Core'", ",", "'Controller.initialize'", ")", ";", "if", "(", "is_callable", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ")", "&&", "Plugin", "::", "hasManifestEvent", "(", "'Controller.initialize'", ")", ")", "{", "call_user_func_array", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ",", "[", "$", "this", "]", ")", ";", "}", "}" ]
Initialization hook method. @return void @throws \JBZoo\Utils\Exception
[ "Initialization", "hook", "method", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/AppController.php#L58-L68
CakeCMS/Core
src/Controller/AppController.php
AppController.beforeRender
public function beforeRender(Event $event) { $pluginEvent = Plugin::getData('Core', 'Controller.beforeRender'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.beforeRender')) { call_user_func_array($pluginEvent->find(0), [$this, $event]); } if (!array_key_exists('_serialize', $this->viewVars) && in_array($this->response->getType(), ['application/json', 'application/xml']) ) { $this->set('_serialize', true); } }
php
public function beforeRender(Event $event) { $pluginEvent = Plugin::getData('Core', 'Controller.beforeRender'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.beforeRender')) { call_user_func_array($pluginEvent->find(0), [$this, $event]); } if (!array_key_exists('_serialize', $this->viewVars) && in_array($this->response->getType(), ['application/json', 'application/xml']) ) { $this->set('_serialize', true); } }
[ "public", "function", "beforeRender", "(", "Event", "$", "event", ")", "{", "$", "pluginEvent", "=", "Plugin", "::", "getData", "(", "'Core'", ",", "'Controller.beforeRender'", ")", ";", "if", "(", "is_callable", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ")", "&&", "Plugin", "::", "hasManifestEvent", "(", "'Controller.beforeRender'", ")", ")", "{", "call_user_func_array", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ",", "[", "$", "this", ",", "$", "event", "]", ")", ";", "}", "if", "(", "!", "array_key_exists", "(", "'_serialize'", ",", "$", "this", "->", "viewVars", ")", "&&", "in_array", "(", "$", "this", "->", "response", "->", "getType", "(", ")", ",", "[", "'application/json'", ",", "'application/xml'", "]", ")", ")", "{", "$", "this", "->", "set", "(", "'_serialize'", ",", "true", ")", ";", "}", "}" ]
Called after the controller action is run, but before the view is rendered. You can use this method to perform logic or set view variables that are required on every request. @param \Cake\Event\Event $event The beforeRender event. @return void @throws \JBZoo\Utils\Exception
[ "Called", "after", "the", "controller", "action", "is", "run", "but", "before", "the", "view", "is", "rendered", ".", "You", "can", "use", "this", "method", "to", "perform", "logic", "or", "set", "view", "variables", "that", "are", "required", "on", "every", "request", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/AppController.php#L79-L91
CakeCMS/Core
src/Controller/AppController.php
AppController.beforeFilter
public function beforeFilter(Event $event) { EventManager::trigger('Controller.setup', $this); $pluginEvent = Plugin::getData('Core', 'Controller.beforeFilter'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.beforeFilter')) { call_user_func_array($pluginEvent->find(0), [$this, $event]); } }
php
public function beforeFilter(Event $event) { EventManager::trigger('Controller.setup', $this); $pluginEvent = Plugin::getData('Core', 'Controller.beforeFilter'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.beforeFilter')) { call_user_func_array($pluginEvent->find(0), [$this, $event]); } }
[ "public", "function", "beforeFilter", "(", "Event", "$", "event", ")", "{", "EventManager", "::", "trigger", "(", "'Controller.setup'", ",", "$", "this", ")", ";", "$", "pluginEvent", "=", "Plugin", "::", "getData", "(", "'Core'", ",", "'Controller.beforeFilter'", ")", ";", "if", "(", "is_callable", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ")", "&&", "Plugin", "::", "hasManifestEvent", "(", "'Controller.beforeFilter'", ")", ")", "{", "call_user_func_array", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ",", "[", "$", "this", ",", "$", "event", "]", ")", ";", "}", "}" ]
Called before the controller action. You can use this method to configure and customize components or perform logic that needs to happen before each controller action. @param Event $event @return void @throws \JBZoo\Utils\Exception
[ "Called", "before", "the", "controller", "action", ".", "You", "can", "use", "this", "method", "to", "configure", "and", "customize", "components", "or", "perform", "logic", "that", "needs", "to", "happen", "before", "each", "controller", "action", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/AppController.php#L102-L110
CakeCMS/Core
src/Controller/AppController.php
AppController.beforeRedirect
public function beforeRedirect(Event $event, $url, Response $response) { $pluginEvent = Plugin::getData('Core', 'Controller.beforeRedirect'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.beforeRedirect')) { call_user_func_array($pluginEvent->find(0), [$this, $event, $url, $response]); } }
php
public function beforeRedirect(Event $event, $url, Response $response) { $pluginEvent = Plugin::getData('Core', 'Controller.beforeRedirect'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.beforeRedirect')) { call_user_func_array($pluginEvent->find(0), [$this, $event, $url, $response]); } }
[ "public", "function", "beforeRedirect", "(", "Event", "$", "event", ",", "$", "url", ",", "Response", "$", "response", ")", "{", "$", "pluginEvent", "=", "Plugin", "::", "getData", "(", "'Core'", ",", "'Controller.beforeRedirect'", ")", ";", "if", "(", "is_callable", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ")", "&&", "Plugin", "::", "hasManifestEvent", "(", "'Controller.beforeRedirect'", ")", ")", "{", "call_user_func_array", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ",", "[", "$", "this", ",", "$", "event", ",", "$", "url", ",", "$", "response", "]", ")", ";", "}", "}" ]
The beforeRedirect method is invoked when the controller's redirect method is called but before any further action. @param Event $event @param array|string $url @param Response $response @return void @throws \JBZoo\Utils\Exception
[ "The", "beforeRedirect", "method", "is", "invoked", "when", "the", "controller", "s", "redirect", "method", "is", "called", "but", "before", "any", "further", "action", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/AppController.php#L123-L129
CakeCMS/Core
src/Controller/AppController.php
AppController.afterFilter
public function afterFilter(Event $event) { $pluginEvent = Plugin::getData('Core', 'Controller.afterFilter'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.afterFilter')) { call_user_func_array($pluginEvent->find(0), [$this, $event]); } }
php
public function afterFilter(Event $event) { $pluginEvent = Plugin::getData('Core', 'Controller.afterFilter'); if (is_callable($pluginEvent->find(0)) && Plugin::hasManifestEvent('Controller.afterFilter')) { call_user_func_array($pluginEvent->find(0), [$this, $event]); } }
[ "public", "function", "afterFilter", "(", "Event", "$", "event", ")", "{", "$", "pluginEvent", "=", "Plugin", "::", "getData", "(", "'Core'", ",", "'Controller.afterFilter'", ")", ";", "if", "(", "is_callable", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ")", "&&", "Plugin", "::", "hasManifestEvent", "(", "'Controller.afterFilter'", ")", ")", "{", "call_user_func_array", "(", "$", "pluginEvent", "->", "find", "(", "0", ")", ",", "[", "$", "this", ",", "$", "event", "]", ")", ";", "}", "}" ]
Called after the controller action is run and rendered. @param Event $event @return void @throws \JBZoo\Utils\Exception
[ "Called", "after", "the", "controller", "action", "is", "run", "and", "rendered", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/AppController.php#L139-L145
CakeCMS/Core
src/Controller/AppController.php
AppController._setTheme
protected function _setTheme() { $theme = $this->request->getParam('theme'); if ($theme) { $this->viewBuilder()->setTheme($theme); } }
php
protected function _setTheme() { $theme = $this->request->getParam('theme'); if ($theme) { $this->viewBuilder()->setTheme($theme); } }
[ "protected", "function", "_setTheme", "(", ")", "{", "$", "theme", "=", "$", "this", "->", "request", "->", "getParam", "(", "'theme'", ")", ";", "if", "(", "$", "theme", ")", "{", "$", "this", "->", "viewBuilder", "(", ")", "->", "setTheme", "(", "$", "theme", ")", ";", "}", "}" ]
Setup application theme. @return void
[ "Setup", "application", "theme", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Controller/AppController.php#L152-L158
Chill-project/Main
Export/Formatter/CSVFormatter.php
CSVFormatter.appendAggregatorForm
private function appendAggregatorForm(FormBuilderInterface $builder, $nbAggregators) { $builder->add('order', 'choice', array( 'choices' => array_combine( range(1, $nbAggregators), range(1, $nbAggregators) ), 'multiple' => false, 'expanded' => false )); $builder->add('position', 'choice', array( 'choices' => array( 'row' => 'r', 'column' => 'c' ), 'choices_as_values' => true, 'multiple' => false, 'expanded' => false )); }
php
private function appendAggregatorForm(FormBuilderInterface $builder, $nbAggregators) { $builder->add('order', 'choice', array( 'choices' => array_combine( range(1, $nbAggregators), range(1, $nbAggregators) ), 'multiple' => false, 'expanded' => false )); $builder->add('position', 'choice', array( 'choices' => array( 'row' => 'r', 'column' => 'c' ), 'choices_as_values' => true, 'multiple' => false, 'expanded' => false )); }
[ "private", "function", "appendAggregatorForm", "(", "FormBuilderInterface", "$", "builder", ",", "$", "nbAggregators", ")", "{", "$", "builder", "->", "add", "(", "'order'", ",", "'choice'", ",", "array", "(", "'choices'", "=>", "array_combine", "(", "range", "(", "1", ",", "$", "nbAggregators", ")", ",", "range", "(", "1", ",", "$", "nbAggregators", ")", ")", ",", "'multiple'", "=>", "false", ",", "'expanded'", "=>", "false", ")", ")", ";", "$", "builder", "->", "add", "(", "'position'", ",", "'choice'", ",", "array", "(", "'choices'", "=>", "array", "(", "'row'", "=>", "'r'", ",", "'column'", "=>", "'c'", ")", ",", "'choices_as_values'", "=>", "true", ",", "'multiple'", "=>", "false", ",", "'expanded'", "=>", "false", ")", ")", ";", "}" ]
append a form line by aggregator on the formatter form. This form allow to choose the aggregator position (row or column) and the ordering @param FormBuilderInterface $builder @param string $nbAggregators
[ "append", "a", "form", "line", "by", "aggregator", "on", "the", "formatter", "form", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/Formatter/CSVFormatter.php#L114-L134
Chill-project/Main
Export/Formatter/CSVFormatter.php
CSVFormatter.orderingHeaders
protected function orderingHeaders($formatterData) { $this->formatterData = $formatterData; uasort($this->formatterData, function($a, $b) { return ($a['order'] <= $b['order'] ? -1 : 1); }); }
php
protected function orderingHeaders($formatterData) { $this->formatterData = $formatterData; uasort($this->formatterData, function($a, $b) { return ($a['order'] <= $b['order'] ? -1 : 1); }); }
[ "protected", "function", "orderingHeaders", "(", "$", "formatterData", ")", "{", "$", "this", "->", "formatterData", "=", "$", "formatterData", ";", "uasort", "(", "$", "this", "->", "formatterData", ",", "function", "(", "$", "a", ",", "$", "b", ")", "{", "return", "(", "$", "a", "[", "'order'", "]", "<=", "$", "b", "[", "'order'", "]", "?", "-", "1", ":", "1", ")", ";", "}", ")", ";", "}" ]
ordering aggregators, preserving key association. This function do not mind about position. If two aggregators have the same order, the second given will be placed after. This is not significant for the first ordering. @param type $formatterData @return type
[ "ordering", "aggregators", "preserving", "key", "association", "." ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Export/Formatter/CSVFormatter.php#L182-L189
anime-db/app-bundle
src/Entity/Notice.php
Notice.shown
public function shown() { if (is_null($this->date_closed)) { $this->date_closed = new \DateTime(); $this->date_closed->modify(sprintf('+%s seconds', $this->lifetime)); } $this->status = self::STATUS_SHOWN; }
php
public function shown() { if (is_null($this->date_closed)) { $this->date_closed = new \DateTime(); $this->date_closed->modify(sprintf('+%s seconds', $this->lifetime)); } $this->status = self::STATUS_SHOWN; }
[ "public", "function", "shown", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "date_closed", ")", ")", "{", "$", "this", "->", "date_closed", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "this", "->", "date_closed", "->", "modify", "(", "sprintf", "(", "'+%s seconds'", ",", "$", "this", "->", "lifetime", ")", ")", ";", "}", "$", "this", "->", "status", "=", "self", "::", "STATUS_SHOWN", ";", "}" ]
Notice shown.
[ "Notice", "shown", "." ]
train
https://github.com/anime-db/app-bundle/blob/ca3b342081719d41ba018792a75970cbb1f1fe22/src/Entity/Notice.php#L126-L133
PortaText/php-sdk
src/PortaText/Command/Api/Cnam.php
Cnam.getEndpoint
protected function getEndpoint($method) { $endpoint = "cnam"; $number = $this->getArgument("id"); $file = $this->getArgument("file"); if (is_null($number) && is_null($file)) { throw new \InvalidArgumentException("DID number cant be null"); } $this->delArgument("id"); if (!is_null($number)) { $endpoint .= "/$number"; } return $endpoint; }
php
protected function getEndpoint($method) { $endpoint = "cnam"; $number = $this->getArgument("id"); $file = $this->getArgument("file"); if (is_null($number) && is_null($file)) { throw new \InvalidArgumentException("DID number cant be null"); } $this->delArgument("id"); if (!is_null($number)) { $endpoint .= "/$number"; } return $endpoint; }
[ "protected", "function", "getEndpoint", "(", "$", "method", ")", "{", "$", "endpoint", "=", "\"cnam\"", ";", "$", "number", "=", "$", "this", "->", "getArgument", "(", "\"id\"", ")", ";", "$", "file", "=", "$", "this", "->", "getArgument", "(", "\"file\"", ")", ";", "if", "(", "is_null", "(", "$", "number", ")", "&&", "is_null", "(", "$", "file", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"DID number cant be null\"", ")", ";", "}", "$", "this", "->", "delArgument", "(", "\"id\"", ")", ";", "if", "(", "!", "is_null", "(", "$", "number", ")", ")", "{", "$", "endpoint", ".=", "\"/$number\"", ";", "}", "return", "$", "endpoint", ";", "}" ]
Returns a string with the endpoint for the given command. @param string $method Method for this command. @return string
[ "Returns", "a", "string", "with", "the", "endpoint", "for", "the", "given", "command", "." ]
train
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/Cnam.php#L50-L63
lelivrescolaire/SQSBundle
DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('llssqs'); $rootNode ->fixXmlConfig('queue') ->append($this->getQueuesConfig()); return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('llssqs'); $rootNode ->fixXmlConfig('queue') ->append($this->getQueuesConfig()); return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'llssqs'", ")", ";", "$", "rootNode", "->", "fixXmlConfig", "(", "'queue'", ")", "->", "append", "(", "$", "this", "->", "getQueuesConfig", "(", ")", ")", ";", "return", "$", "treeBuilder", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/lelivrescolaire/SQSBundle/blob/bba3fa6d63d0ae1bddbc7b2fe3c2e737f49d6559/DependencyInjection/Configuration.php#L18-L27
phpmob/changmin
src/PhpMob/WidgetBundle/Twig/WidgetAssetsExtension.php
WidgetAssetsExtension.getAssets
public function getAssets() { $content = ''; if ($style = trim($this->widgetAssets->getStyle())) { $content .= sprintf('<style>%s</style>', $style); } if ($script = trim($this->widgetAssets->getScript())) { $content .= sprintf('<script>$(function(){%s});</script>', $script); } return $content; }
php
public function getAssets() { $content = ''; if ($style = trim($this->widgetAssets->getStyle())) { $content .= sprintf('<style>%s</style>', $style); } if ($script = trim($this->widgetAssets->getScript())) { $content .= sprintf('<script>$(function(){%s});</script>', $script); } return $content; }
[ "public", "function", "getAssets", "(", ")", "{", "$", "content", "=", "''", ";", "if", "(", "$", "style", "=", "trim", "(", "$", "this", "->", "widgetAssets", "->", "getStyle", "(", ")", ")", ")", "{", "$", "content", ".=", "sprintf", "(", "'<style>%s</style>'", ",", "$", "style", ")", ";", "}", "if", "(", "$", "script", "=", "trim", "(", "$", "this", "->", "widgetAssets", "->", "getScript", "(", ")", ")", ")", "{", "$", "content", ".=", "sprintf", "(", "'<script>$(function(){%s});</script>'", ",", "$", "script", ")", ";", "}", "return", "$", "content", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/WidgetBundle/Twig/WidgetAssetsExtension.php#L52-L65
aedart/laravel-helpers
src/Traits/Notifications/NotificationFactoryTrait.php
NotificationFactoryTrait.getNotificationFactory
public function getNotificationFactory(): ?Factory { if (!$this->hasNotificationFactory()) { $this->setNotificationFactory($this->getDefaultNotificationFactory()); } return $this->notificationFactory; }
php
public function getNotificationFactory(): ?Factory { if (!$this->hasNotificationFactory()) { $this->setNotificationFactory($this->getDefaultNotificationFactory()); } return $this->notificationFactory; }
[ "public", "function", "getNotificationFactory", "(", ")", ":", "?", "Factory", "{", "if", "(", "!", "$", "this", "->", "hasNotificationFactory", "(", ")", ")", "{", "$", "this", "->", "setNotificationFactory", "(", "$", "this", "->", "getDefaultNotificationFactory", "(", ")", ")", ";", "}", "return", "$", "this", "->", "notificationFactory", ";", "}" ]
Get notification factory If no notification factory has been set, this method will set and return a default notification factory, if any such value is available @see getDefaultNotificationFactory() @return Factory|null notification factory or null if none notification factory has been set
[ "Get", "notification", "factory" ]
train
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Notifications/NotificationFactoryTrait.php#L53-L59
hisorange/traits
src/ObjectConfig.php
ObjectConfig.objectConfigGet
public function objectConfigGet($key, $default = null) { // Is this key exists? if (array_key_exists($key, $this->objectConfig)) { return $this->objectConfig[$key]; } return $default; }
php
public function objectConfigGet($key, $default = null) { // Is this key exists? if (array_key_exists($key, $this->objectConfig)) { return $this->objectConfig[$key]; } return $default; }
[ "public", "function", "objectConfigGet", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "// Is this key exists?", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "objectConfig", ")", ")", "{", "return", "$", "this", "->", "objectConfig", "[", "$", "key", "]", ";", "}", "return", "$", "default", ";", "}" ]
Get a value from the config. @param string $key @param mixed $default @return mixed
[ "Get", "a", "value", "from", "the", "config", "." ]
train
https://github.com/hisorange/traits/blob/465baf32faaf155b867dcc11218621e23ef4cac2/src/ObjectConfig.php#L43-L51
Chill-project/Main
Form/Type/DataTransformer/ObjectToIdTransformer.php
ObjectToIdTransformer.reverseTransform
public function reverseTransform($id) { if (!$id) { return null; } $object = $this->om ->getRepository($this->class) ->find($id) ; if (! $object) { throw new TransformationFailedException(); } return $object; }
php
public function reverseTransform($id) { if (!$id) { return null; } $object = $this->om ->getRepository($this->class) ->find($id) ; if (! $object) { throw new TransformationFailedException(); } return $object; }
[ "public", "function", "reverseTransform", "(", "$", "id", ")", "{", "if", "(", "!", "$", "id", ")", "{", "return", "null", ";", "}", "$", "object", "=", "$", "this", "->", "om", "->", "getRepository", "(", "$", "this", "->", "class", ")", "->", "find", "(", "$", "id", ")", ";", "if", "(", "!", "$", "object", ")", "{", "throw", "new", "TransformationFailedException", "(", ")", ";", "}", "return", "$", "object", ";", "}" ]
Transforms a string (id) to an object @param string $id @return Object|null @throws TransformationFailedException if object is not found.
[ "Transforms", "a", "string", "(", "id", ")", "to", "an", "object" ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Form/Type/DataTransformer/ObjectToIdTransformer.php#L70-L86
askupasoftware/amarkal
Extensions/WordPress/Options/Notifier.php
Notifier.notify
static function notify( $message, $type ) { $nots = State::get( 'notifications' ); array_push( $nots, array( 'message' => $message, 'type' => $type ) ); State::set( 'notifications', $nots ); }
php
static function notify( $message, $type ) { $nots = State::get( 'notifications' ); array_push( $nots, array( 'message' => $message, 'type' => $type ) ); State::set( 'notifications', $nots ); }
[ "static", "function", "notify", "(", "$", "message", ",", "$", "type", ")", "{", "$", "nots", "=", "State", "::", "get", "(", "'notifications'", ")", ";", "array_push", "(", "$", "nots", ",", "array", "(", "'message'", "=>", "$", "message", ",", "'type'", "=>", "$", "type", ")", ")", ";", "State", "::", "set", "(", "'notifications'", ",", "$", "nots", ")", ";", "}" ]
Register a notification. @param string $message The message to print. @param string $type The type of notification [self::ERROR|self::SUCCESS|self::INFO].
[ "Register", "a", "notification", "." ]
train
https://github.com/askupasoftware/amarkal/blob/fe8283e2d6847ef697abec832da7ee741a85058c/Extensions/WordPress/Options/Notifier.php#L23-L28