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
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
tttptd/laravel-responder
src/Traits/MakesApiRequests.php
MakesApiRequests.getSuccessData
protected function getSuccessData($attributes = null) { $rawData = $this->decodeResponseJson()['data']; if (is_null($attributes)) { return $rawData; } elseif (is_string($attributes)) { return array_get($rawData, $attributes); } $data = []; foreach ($attributes as $attribute) { $data[] = array_get($rawData, $attribute); } return $data; }
php
protected function getSuccessData($attributes = null) { $rawData = $this->decodeResponseJson()['data']; if (is_null($attributes)) { return $rawData; } elseif (is_string($attributes)) { return array_get($rawData, $attributes); } $data = []; foreach ($attributes as $attribute) { $data[] = array_get($rawData, $attribute); } return $data; }
[ "protected", "function", "getSuccessData", "(", "$", "attributes", "=", "null", ")", "{", "$", "rawData", "=", "$", "this", "->", "decodeResponseJson", "(", ")", "[", "'data'", "]", ";", "if", "(", "is_null", "(", "$", "attributes", ")", ")", "{", "ret...
Decodes JSON response and returns the data. @param string|array|null $attributes @return array
[ "Decodes", "JSON", "response", "and", "returns", "the", "data", "." ]
train
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Traits/MakesApiRequests.php#L107-L124
tttptd/laravel-responder
src/Traits/MakesApiRequests.php
MakesApiRequests.seeError
protected function seeError(string $error, int $status = null) { if (! is_null($status)) { $this->seeStatusCode($status); } if ($this->app->config->get('responder.status_code')) { $this->seeJson([ 'status' => $status ]); } return $this->seeJson([ 'success' => false ])->seeJsonSubset([ 'error' => [ 'code' => $error ] ]); }
php
protected function seeError(string $error, int $status = null) { if (! is_null($status)) { $this->seeStatusCode($status); } if ($this->app->config->get('responder.status_code')) { $this->seeJson([ 'status' => $status ]); } return $this->seeJson([ 'success' => false ])->seeJsonSubset([ 'error' => [ 'code' => $error ] ]); }
[ "protected", "function", "seeError", "(", "string", "$", "error", ",", "int", "$", "status", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "status", ")", ")", "{", "$", "this", "->", "seeStatusCode", "(", "$", "status", ")", ";", "}",...
Assert that the response is a valid error response. @param string $error @param int|null $status @return $this
[ "Assert", "that", "the", "response", "is", "a", "valid", "error", "response", "." ]
train
https://github.com/tttptd/laravel-responder/blob/0e4a32701f0de755c1f1af458045829e1bd6caf6/src/Traits/MakesApiRequests.php#L133-L152
flowcode/AmulenUserBundle
src/Flowcode/UserBundle/Service/UserService.php
UserService.create
public function create(User $user) { /* handle encode */ $user = $this->encode($user); $this->getEm()->persist($user); $this->getEm()->flush(); return $user; }
php
public function create(User $user) { /* handle encode */ $user = $this->encode($user); $this->getEm()->persist($user); $this->getEm()->flush(); return $user; }
[ "public", "function", "create", "(", "User", "$", "user", ")", "{", "/* handle encode */", "$", "user", "=", "$", "this", "->", "encode", "(", "$", "user", ")", ";", "$", "this", "->", "getEm", "(", ")", "->", "persist", "(", "$", "user", ")", ";",...
Create a new user. @param User $user the user instance. @return User the user instance.
[ "Create", "a", "new", "user", "." ]
train
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Service/UserService.php#L69-L78
flowcode/AmulenUserBundle
src/Flowcode/UserBundle/Service/UserService.php
UserService.generateRandomPassword
public function generateRandomPassword() { $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789"; $pass = array(); $alphaLength = strlen($alphabet) - 1; for ($i = 0; $i < 8; $i++) { $n = rand(0, $alphaLength); $pass[] = $alphabet[$n]; } return implode($pass); }
php
public function generateRandomPassword() { $alphabet = "abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789"; $pass = array(); $alphaLength = strlen($alphabet) - 1; for ($i = 0; $i < 8; $i++) { $n = rand(0, $alphaLength); $pass[] = $alphabet[$n]; } return implode($pass); }
[ "public", "function", "generateRandomPassword", "(", ")", "{", "$", "alphabet", "=", "\"abcdefghijklmnopqrstuwxyzABCDEFGHIJKLMNOPQRSTUWXYZ0123456789\"", ";", "$", "pass", "=", "array", "(", ")", ";", "$", "alphaLength", "=", "strlen", "(", "$", "alphabet", ")", "-...
Geneate Radmon password.
[ "Geneate", "Radmon", "password", "." ]
train
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Service/UserService.php#L118-L128
flowcode/AmulenUserBundle
src/Flowcode/UserBundle/Service/UserService.php
UserService.isUnique
public function isUnique($username, $email, $dni = null, $code = null) { $entities = $this->getEm()->getRepository("AmulenUserBundle:User")->findByUniques($username, $email, $dni, $code); return count($entities) <= 0; }
php
public function isUnique($username, $email, $dni = null, $code = null) { $entities = $this->getEm()->getRepository("AmulenUserBundle:User")->findByUniques($username, $email, $dni, $code); return count($entities) <= 0; }
[ "public", "function", "isUnique", "(", "$", "username", ",", "$", "email", ",", "$", "dni", "=", "null", ",", "$", "code", "=", "null", ")", "{", "$", "entities", "=", "$", "this", "->", "getEm", "(", ")", "->", "getRepository", "(", "\"AmulenUserBun...
Check if is unique. @param [type] $username [description] @param [type] $email [description] @param [type] $phone [description] @param [type] $dni [description] @param [type] $code [description] @return boolean [description]
[ "Check", "if", "is", "unique", "." ]
train
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Service/UserService.php#L152-L156
flowcode/AmulenUserBundle
src/Flowcode/UserBundle/Service/UserService.php
UserService.getAuthToken
public function getAuthToken($user, $plainPassword, $firewall, $roles = array()) { // Here, "public" is the name of the firewall in your security.yml $token = new UsernamePasswordToken($user, $user->getPlainPassword(), $firewall, $roles); // For older versions of Symfony, use security.context here $this->tokenStorage->setToken($token); return $token; }
php
public function getAuthToken($user, $plainPassword, $firewall, $roles = array()) { // Here, "public" is the name of the firewall in your security.yml $token = new UsernamePasswordToken($user, $user->getPlainPassword(), $firewall, $roles); // For older versions of Symfony, use security.context here $this->tokenStorage->setToken($token); return $token; }
[ "public", "function", "getAuthToken", "(", "$", "user", ",", "$", "plainPassword", ",", "$", "firewall", ",", "$", "roles", "=", "array", "(", ")", ")", "{", "// Here, \"public\" is the name of the firewall in your security.yml", "$", "token", "=", "new", "Usernam...
Get by Code. @param [type] $user [user to auth] @param [type] $user [user's plain password] @param [type] $firewall [name in security.yml] @param [type] $roles [user's roles] @return [bool] token [description]
[ "Get", "by", "Code", "." ]
train
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Service/UserService.php#L177-L186
flowcode/AmulenUserBundle
src/Flowcode/UserBundle/Service/UserService.php
UserService.uploadImage
public function uploadImage(User $entity) { /* the file property can be empty if the field is not required */ if (null === $entity->getFile()) { return $entity; } $uploadBaseDir = $this->container->getParameter("user_avatar_basedir"); $uploadDir = $this->container->getParameter("user_avatar_dir"); /* set the path property to the filename where you've saved the file */ $filename = $entity->getFile()->getClientOriginalName(); $extension = $entity->getFile()->getClientOriginalExtension(); $imageName = md5($filename . time()) . '.' . $extension; $entity->setAvatar($uploadDir . $imageName); $entity->getFile()->move($uploadBaseDir . $uploadDir, $imageName); $entity->setFile(null); return $entity; }
php
public function uploadImage(User $entity) { /* the file property can be empty if the field is not required */ if (null === $entity->getFile()) { return $entity; } $uploadBaseDir = $this->container->getParameter("user_avatar_basedir"); $uploadDir = $this->container->getParameter("user_avatar_dir"); /* set the path property to the filename where you've saved the file */ $filename = $entity->getFile()->getClientOriginalName(); $extension = $entity->getFile()->getClientOriginalExtension(); $imageName = md5($filename . time()) . '.' . $extension; $entity->setAvatar($uploadDir . $imageName); $entity->getFile()->move($uploadBaseDir . $uploadDir, $imageName); $entity->setFile(null); return $entity; }
[ "public", "function", "uploadImage", "(", "User", "$", "entity", ")", "{", "/* the file property can be empty if the field is not required */", "if", "(", "null", "===", "$", "entity", "->", "getFile", "(", ")", ")", "{", "return", "$", "entity", ";", "}", "$", ...
Upload user image. @param User $entity @return User
[ "Upload", "user", "image", "." ]
train
https://github.com/flowcode/AmulenUserBundle/blob/00055834d9f094e63dcd8d66e2fedb822fcddee0/src/Flowcode/UserBundle/Service/UserService.php#L206-L229
WellCommerce/AppBundle
Service/Currency/Importer/AbstractExchangeRatesImporter.php
AbstractExchangeRatesImporter.addUpdateExchangeRate
protected function addUpdateExchangeRate($currencyFrom, $currencyTo, $rate) { if (!in_array($currencyTo, $this->managedCurrencies)) { return false; } $exchangeRate = $this->currencyRateRepository->findOneBy([ 'currencyFrom' => $currencyFrom, 'currencyTo' => $currencyTo, ]); if (null === $exchangeRate) { $exchangeRate = new CurrencyRate(); $exchangeRate->setCurrencyFrom($currencyFrom); $exchangeRate->setCurrencyTo($currencyTo); $exchangeRate->setExchangeRate($rate); $this->helper->getEntityManager()->persist($exchangeRate); } else { $exchangeRate->setExchangeRate($rate); } return true; }
php
protected function addUpdateExchangeRate($currencyFrom, $currencyTo, $rate) { if (!in_array($currencyTo, $this->managedCurrencies)) { return false; } $exchangeRate = $this->currencyRateRepository->findOneBy([ 'currencyFrom' => $currencyFrom, 'currencyTo' => $currencyTo, ]); if (null === $exchangeRate) { $exchangeRate = new CurrencyRate(); $exchangeRate->setCurrencyFrom($currencyFrom); $exchangeRate->setCurrencyTo($currencyTo); $exchangeRate->setExchangeRate($rate); $this->helper->getEntityManager()->persist($exchangeRate); } else { $exchangeRate->setExchangeRate($rate); } return true; }
[ "protected", "function", "addUpdateExchangeRate", "(", "$", "currencyFrom", ",", "$", "currencyTo", ",", "$", "rate", ")", "{", "if", "(", "!", "in_array", "(", "$", "currencyTo", ",", "$", "this", "->", "managedCurrencies", ")", ")", "{", "return", "false...
Adds new rate or updates existing one @param string $currencyFrom @param string $currencyTo @param float $rate
[ "Adds", "new", "rate", "or", "updates", "existing", "one" ]
train
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Service/Currency/Importer/AbstractExchangeRatesImporter.php#L72-L94
tystuyfzand/flysystem-seaweedfs
src/Mapping/CacheMapper.php
CacheMapper.store
public function store($path, $fileId, $mimeType, $size) { $this->cache->put('seaweedfs.' . md5($path), [ 'fid' => $fileId, 'mimeType' => $mimeType, 'size' => $size ]); }
php
public function store($path, $fileId, $mimeType, $size) { $this->cache->put('seaweedfs.' . md5($path), [ 'fid' => $fileId, 'mimeType' => $mimeType, 'size' => $size ]); }
[ "public", "function", "store", "(", "$", "path", ",", "$", "fileId", ",", "$", "mimeType", ",", "$", "size", ")", "{", "$", "this", "->", "cache", "->", "put", "(", "'seaweedfs.'", ".", "md5", "(", "$", "path", ")", ",", "[", "'fid'", "=>", "$", ...
Store a path to a seaweedfs file id @param $path @param $fileId @param $mimeType @param $size @return mixed
[ "Store", "a", "path", "to", "a", "seaweedfs", "file", "id" ]
train
https://github.com/tystuyfzand/flysystem-seaweedfs/blob/992334ba1d8e26fe6bbb9e33feedbf66b4872613/src/Mapping/CacheMapper.php#L32-L38
zhouyl/mellivora
Mellivora/View/Factory.php
Factory.render
public function render($view, $data = [], $mergeData = []) { return $this->make($view, $this->parseData($data), $mergeData)->render(); }
php
public function render($view, $data = [], $mergeData = []) { return $this->make($view, $this->parseData($data), $mergeData)->render(); }
[ "public", "function", "render", "(", "$", "view", ",", "$", "data", "=", "[", "]", ",", "$", "mergeData", "=", "[", "]", ")", "{", "return", "$", "this", "->", "make", "(", "$", "view", ",", "$", "this", "->", "parseData", "(", "$", "data", ")"...
Get the rendered content of the view based @param string $view @param array $data @param array $mergeData @return string
[ "Get", "the", "rendered", "content", "of", "the", "view", "based" ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/View/Factory.php#L149-L152
gpupo/common-schema
src/ORM/Entity/Banking/Report/Report.php
Report.addRecord
public function addRecord(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record) { $this->records[] = $record; return $this; }
php
public function addRecord(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record) { $this->records[] = $record; return $this; }
[ "public", "function", "addRecord", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Banking", "\\", "Report", "\\", "Record", "$", "record", ")", "{", "$", "this", "->", "records", "[", "]", "=", "$", "record", ";", "return...
Add record. @param \Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record @return Report
[ "Add", "record", "." ]
train
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Banking/Report/Report.php#L403-L408
gpupo/common-schema
src/ORM/Entity/Banking/Report/Report.php
Report.removeRecord
public function removeRecord(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record) { return $this->records->removeElement($record); }
php
public function removeRecord(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record) { return $this->records->removeElement($record); }
[ "public", "function", "removeRecord", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Banking", "\\", "Report", "\\", "Record", "$", "record", ")", "{", "return", "$", "this", "->", "records", "->", "removeElement", "(", "$", ...
Remove record. @param \Gpupo\CommonSchema\ORM\Entity\Banking\Report\Record $record @return bool TRUE if this collection contained the specified element, FALSE otherwise
[ "Remove", "record", "." ]
train
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Banking/Report/Report.php#L417-L420
actimeo/pgproc
src/PgProcedures.class.php
PgProcedures.connect
private function connect () { $connectionString = "host=".$this->server." port=".$this->port." dbname=".$this->db." user=".$this->user." password=".$this->password; $this->handler = pg_connect ($connectionString); }
php
private function connect () { $connectionString = "host=".$this->server." port=".$this->port." dbname=".$this->db." user=".$this->user." password=".$this->password; $this->handler = pg_connect ($connectionString); }
[ "private", "function", "connect", "(", ")", "{", "$", "connectionString", "=", "\"host=\"", ".", "$", "this", "->", "server", ".", "\" port=\"", ".", "$", "this", "->", "port", ".", "\" dbname=\"", ".", "$", "this", "->", "db", ".", "\" user=\"", ".", ...
********* PRIVATE * *********
[ "*********", "PRIVATE", "*", "*********" ]
train
https://github.com/actimeo/pgproc/blob/e251da8f27a560ccf82196ee946f73e0ed030108/src/PgProcedures.class.php#L126-L129
ezsystems/ezcomments-ls-extension
classes/ezcomeditcommenttool.php
ezcomEditCommentTool.fillObject
public function fillObject( $comment, $fieldNames = null ) { if ( is_null( $fieldNames ) ) { $fieldNames = array(); foreach ( $this->fields as $field => $fieldSetup ) { if( $field != 'email' ) { $fieldNames[] = $field; } } } parent::fillObject( $comment, $fieldNames ); }
php
public function fillObject( $comment, $fieldNames = null ) { if ( is_null( $fieldNames ) ) { $fieldNames = array(); foreach ( $this->fields as $field => $fieldSetup ) { if( $field != 'email' ) { $fieldNames[] = $field; } } } parent::fillObject( $comment, $fieldNames ); }
[ "public", "function", "fillObject", "(", "$", "comment", ",", "$", "fieldNames", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "fieldNames", ")", ")", "{", "$", "fieldNames", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", ...
(non-PHPdoc) @see extension/ezcomments/classes/ezcomFormTool#fillObject($comment, $fieldNames)
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/ezsystems/ezcomments-ls-extension/blob/2b4cd8c34d4a77813e4d6a9c5a0d317a274c63c5/classes/ezcomeditcommenttool.php#L79-L93
ajgarlag/AjglCsv
src/Reader/RfcReader.php
RfcReader.doRead
protected function doRead() { $row = CsvRfcUtils::fGetCsv($this->getHandler(), 0, $this->getDelimiter()); return ($row !== false) ? $row : null; }
php
protected function doRead() { $row = CsvRfcUtils::fGetCsv($this->getHandler(), 0, $this->getDelimiter()); return ($row !== false) ? $row : null; }
[ "protected", "function", "doRead", "(", ")", "{", "$", "row", "=", "CsvRfcUtils", "::", "fGetCsv", "(", "$", "this", "->", "getHandler", "(", ")", ",", "0", ",", "$", "this", "->", "getDelimiter", "(", ")", ")", ";", "return", "(", "$", "row", "!==...
{@inheritdoc}
[ "{" ]
train
https://github.com/ajgarlag/AjglCsv/blob/28872f58b9ef864893cac6faddfcb1229c2c2047/src/Reader/RfcReader.php#L24-L29
nabab/bbn
src/bbn/file/system2.php
system2._connect_nextcloud
private function _connect_nextcloud(array $cfg): bool { if ( isset($cfg['host'], $cfg['user'], $cfg['pass']) && class_exists('\\Sabre\\DAV\\Client') ){ $this->prefix = '/remote.php/webdav/'; $this->obj = new \Sabre\DAV\Client([ 'baseUri' => 'http'.(isset($cfg['port']) && ($cfg['port'] === 21) ? '' : 's').'://'.$cfg['host'].$this->prefix.$cfg['path'], 'userName' => $cfg['user'], 'password' => $cfg['pass'] ]); $this->host = 'http'.(isset($cfg['port']) && ($cfg['port'] === 21) ? '' : 's').'://'.$cfg['host']; if ( $this->obj->options() ){ $this->current = ''; return true; } $this->error = _('Impossible to connect to the WebDAV host'); } return false; }
php
private function _connect_nextcloud(array $cfg): bool { if ( isset($cfg['host'], $cfg['user'], $cfg['pass']) && class_exists('\\Sabre\\DAV\\Client') ){ $this->prefix = '/remote.php/webdav/'; $this->obj = new \Sabre\DAV\Client([ 'baseUri' => 'http'.(isset($cfg['port']) && ($cfg['port'] === 21) ? '' : 's').'://'.$cfg['host'].$this->prefix.$cfg['path'], 'userName' => $cfg['user'], 'password' => $cfg['pass'] ]); $this->host = 'http'.(isset($cfg['port']) && ($cfg['port'] === 21) ? '' : 's').'://'.$cfg['host']; if ( $this->obj->options() ){ $this->current = ''; return true; } $this->error = _('Impossible to connect to the WebDAV host'); } return false; }
[ "private", "function", "_connect_nextcloud", "(", "array", "$", "cfg", ")", ":", "bool", "{", "if", "(", "isset", "(", "$", "cfg", "[", "'host'", "]", ",", "$", "cfg", "[", "'user'", "]", ",", "$", "cfg", "[", "'pass'", "]", ")", "&&", "class_exist...
Connect to FTP @param array $cfg @return bool
[ "Connect", "to", "FTP" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/system2.php#L60-L79
nabab/bbn
src/bbn/file/system2.php
system2._connect_ftp
private function _connect_ftp(array $cfg): bool { if ( isset($cfg['host'], $cfg['user'], $cfg['pass']) ){ $args = [$cfg['host'], $cfg['port'] ?? 21, $cfg['timeout'] ?? $this->timeout]; if ( ( ($this->obj = @ftp_ssl_connect(...$args)) && @ftp_login($this->obj, $cfg['user'], $cfg['pass']) ) || ( ($this->obj = @ftp_connect(...$args)) && @ftp_login($this->obj, $cfg['user'], $cfg['pass']) ) ){ $this->current = ftp_pwd($this->obj); $this->prefix = 'ftp://'.$cfg['user'].':'.$cfg['pass'].'@'.$cfg['host']; return true; } $this->error = _('Impossible to connect to the FTP host'); } return false; }
php
private function _connect_ftp(array $cfg): bool { if ( isset($cfg['host'], $cfg['user'], $cfg['pass']) ){ $args = [$cfg['host'], $cfg['port'] ?? 21, $cfg['timeout'] ?? $this->timeout]; if ( ( ($this->obj = @ftp_ssl_connect(...$args)) && @ftp_login($this->obj, $cfg['user'], $cfg['pass']) ) || ( ($this->obj = @ftp_connect(...$args)) && @ftp_login($this->obj, $cfg['user'], $cfg['pass']) ) ){ $this->current = ftp_pwd($this->obj); $this->prefix = 'ftp://'.$cfg['user'].':'.$cfg['pass'].'@'.$cfg['host']; return true; } $this->error = _('Impossible to connect to the FTP host'); } return false; }
[ "private", "function", "_connect_ftp", "(", "array", "$", "cfg", ")", ":", "bool", "{", "if", "(", "isset", "(", "$", "cfg", "[", "'host'", "]", ",", "$", "cfg", "[", "'user'", "]", ",", "$", "cfg", "[", "'pass'", "]", ")", ")", "{", "$", "args...
Connect to FTP @param array $cfg @return bool
[ "Connect", "to", "FTP" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/system2.php#L86-L105
nabab/bbn
src/bbn/file/system2.php
system2._connect_ssh
private function _connect_ssh(array $cfg): bool { if ( isset($cfg['host'], $cfg['user'], $cfg['pass']) ){ $this->cn = @ssh2_connect($cfg['host'], $cfg['port'] ?? 22); if ( !$this->cn ){ $this->error = _("Could not connect through SSH."); } else if ( @ssh2_auth_password($this->cn, $cfg['user'], $cfg['pass']) ){ //die(_("Could not authenticate with username and password.")); $this->obj = @ssh2_sftp($this->cn); if ( $this->obj ){ $this->current = ssh2_sftp_realpath($this->obj, '.'); $this->prefix = 'ssh2.sftp://'.$this->obj; return true; } $this->error = _("Could not initialize SFTP subsystem."); } else{ $this->error = _("Could not authenticate with username and password."); } } return false; }
php
private function _connect_ssh(array $cfg): bool { if ( isset($cfg['host'], $cfg['user'], $cfg['pass']) ){ $this->cn = @ssh2_connect($cfg['host'], $cfg['port'] ?? 22); if ( !$this->cn ){ $this->error = _("Could not connect through SSH."); } else if ( @ssh2_auth_password($this->cn, $cfg['user'], $cfg['pass']) ){ //die(_("Could not authenticate with username and password.")); $this->obj = @ssh2_sftp($this->cn); if ( $this->obj ){ $this->current = ssh2_sftp_realpath($this->obj, '.'); $this->prefix = 'ssh2.sftp://'.$this->obj; return true; } $this->error = _("Could not initialize SFTP subsystem."); } else{ $this->error = _("Could not authenticate with username and password."); } } return false; }
[ "private", "function", "_connect_ssh", "(", "array", "$", "cfg", ")", ":", "bool", "{", "if", "(", "isset", "(", "$", "cfg", "[", "'host'", "]", ",", "$", "cfg", "[", "'user'", "]", ",", "$", "cfg", "[", "'pass'", "]", ")", ")", "{", "$", "this...
Connects to SSH @param array $cfg @return bool
[ "Connects", "to", "SSH" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/system2.php#L112-L134
nabab/bbn
src/bbn/file/system2.php
system2._check_filter
private function _check_filter($item, $filter): bool { if ( $filter ){ if ( is_string($filter) ){ return strtolower(substr(\is_array($item) ? $item['path'] : $item, - strlen($filter))) === strtolower($filter); } if ( is_callable($filter) ){ return $filter($item); } } return true; }
php
private function _check_filter($item, $filter): bool { if ( $filter ){ if ( is_string($filter) ){ return strtolower(substr(\is_array($item) ? $item['path'] : $item, - strlen($filter))) === strtolower($filter); } if ( is_callable($filter) ){ return $filter($item); } } return true; }
[ "private", "function", "_check_filter", "(", "$", "item", ",", "$", "filter", ")", ":", "bool", "{", "if", "(", "$", "filter", ")", "{", "if", "(", "is_string", "(", "$", "filter", ")", ")", "{", "return", "strtolower", "(", "substr", "(", "\\", "i...
Checks if the given files name ends with the given suffix string @param array|string $item @param callable|string $filter @return bool
[ "Checks", "if", "the", "given", "files", "name", "ends", "with", "the", "given", "suffix", "string" ]
train
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/file/system2.php#L142-L153
caffeinated/beverage
src/StubGenerator.php
StubGenerator.render
public function render($string, array $vars = array()) { $fileName = uniqid(time(), false); $this->generateDirectoryStructure(storage_path(), [ 'caffeinated/stubs' ]); $path = storage_path("caffeinated/stubs/{$fileName}"); $this->files->put($path, $this->compiler->compileString($string)); if (is_array($vars) && ! empty($vars)) { extract($vars); } ob_start(); include($path); $var = ob_get_contents(); ob_end_clean(); $this->files->delete($path); return $var; }
php
public function render($string, array $vars = array()) { $fileName = uniqid(time(), false); $this->generateDirectoryStructure(storage_path(), [ 'caffeinated/stubs' ]); $path = storage_path("caffeinated/stubs/{$fileName}"); $this->files->put($path, $this->compiler->compileString($string)); if (is_array($vars) && ! empty($vars)) { extract($vars); } ob_start(); include($path); $var = ob_get_contents(); ob_end_clean(); $this->files->delete($path); return $var; }
[ "public", "function", "render", "(", "$", "string", ",", "array", "$", "vars", "=", "array", "(", ")", ")", "{", "$", "fileName", "=", "uniqid", "(", "time", "(", ")", ",", "false", ")", ";", "$", "this", "->", "generateDirectoryStructure", "(", "sto...
render @param $string @param array $vars @return string
[ "render" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/StubGenerator.php#L49-L68
caffeinated/beverage
src/StubGenerator.php
StubGenerator.generate
public function generate($stubDir, $destDir, array $files = [ ], array $vars = [ ]) { foreach ($files as $stubFile => $destFile) { foreach (array_dot($vars) as $key => $val) { $destFile = Str::replace($destFile, '{{' . $key . '}}', $val); } $stubPath = Path::join($stubDir, $stubFile); $destPath = Path::join($destDir, $destFile); $destDirPath = Path::getDirectory($destPath); if (! $this->files->exists($destDirPath)) { $this->files->makeDirectory($destDirPath, 0755, true); } $rendered = $this->render($this->files->get($stubPath), $vars); $this->files->put($destPath, $rendered); } return $this; }
php
public function generate($stubDir, $destDir, array $files = [ ], array $vars = [ ]) { foreach ($files as $stubFile => $destFile) { foreach (array_dot($vars) as $key => $val) { $destFile = Str::replace($destFile, '{{' . $key . '}}', $val); } $stubPath = Path::join($stubDir, $stubFile); $destPath = Path::join($destDir, $destFile); $destDirPath = Path::getDirectory($destPath); if (! $this->files->exists($destDirPath)) { $this->files->makeDirectory($destDirPath, 0755, true); } $rendered = $this->render($this->files->get($stubPath), $vars); $this->files->put($destPath, $rendered); } return $this; }
[ "public", "function", "generate", "(", "$", "stubDir", ",", "$", "destDir", ",", "array", "$", "files", "=", "[", "]", ",", "array", "$", "vars", "=", "[", "]", ")", "{", "foreach", "(", "$", "files", "as", "$", "stubFile", "=>", "$", "destFile", ...
generate @param string $stubDir @param string $destDir @param array $files @param array $vars @return $this @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
[ "generate" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/StubGenerator.php#L80-L99
caffeinated/beverage
src/StubGenerator.php
StubGenerator.generateDirectoryStructure
public function generateDirectoryStructure($destDir, array $dirs = [ ]) { foreach ($dirs as $dirPath) { $dirPath = Path::join($destDir, $dirPath); if (! $this->files->exists($dirPath)) { $this->files->makeDirectory($dirPath, 0755, true); } } return $this; }
php
public function generateDirectoryStructure($destDir, array $dirs = [ ]) { foreach ($dirs as $dirPath) { $dirPath = Path::join($destDir, $dirPath); if (! $this->files->exists($dirPath)) { $this->files->makeDirectory($dirPath, 0755, true); } } return $this; }
[ "public", "function", "generateDirectoryStructure", "(", "$", "destDir", ",", "array", "$", "dirs", "=", "[", "]", ")", "{", "foreach", "(", "$", "dirs", "as", "$", "dirPath", ")", "{", "$", "dirPath", "=", "Path", "::", "join", "(", "$", "destDir", ...
generateDirectoryStructure @param $destDir @param array $dirs @return $this
[ "generateDirectoryStructure" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/StubGenerator.php#L108-L117
WScore/Validation
src/Utils/Helper.php
Helper.convertFilter
public static function convertFilter($filter) { if (!$filter) { return array(); } if (is_array($filter)) { return $filter; } $filter_array = array(); $rules = explode('|', $filter); foreach ($rules as $rule) { list($name, $arg) = self::get_name_and_arg($rule); $filter_array[$name] = $arg; } return $filter_array; }
php
public static function convertFilter($filter) { if (!$filter) { return array(); } if (is_array($filter)) { return $filter; } $filter_array = array(); $rules = explode('|', $filter); foreach ($rules as $rule) { list($name, $arg) = self::get_name_and_arg($rule); $filter_array[$name] = $arg; } return $filter_array; }
[ "public", "static", "function", "convertFilter", "(", "$", "filter", ")", "{", "if", "(", "!", "$", "filter", ")", "{", "return", "array", "(", ")", ";", "}", "if", "(", "is_array", "(", "$", "filter", ")", ")", "{", "return", "$", "filter", ";", ...
converts string filter to array. string in: 'rule1:parameter1|rule2:parameter2' @param string|array $filter @return array
[ "converts", "string", "filter", "to", "array", ".", "string", "in", ":", "rule1", ":", "parameter1|rule2", ":", "parameter2" ]
train
https://github.com/WScore/Validation/blob/25c0dca37d624bb0bb22f8e79ba54db2f69e0950/src/Utils/Helper.php#L29-L46
surebert/surebert-framework
src/sb/Email.php
Email.addIcalendarEvent
public function addIcalendarEvent(\sb\ICalendar\Event $event) { $a = new \sb\Email\Attachment(); $a->mime_type = 'text/calendar;'; $a->setEncoding('8bit'); $a->name = 'event.ics'; $a->contents = $event->__toString(); $this->addAttachment($a); }
php
public function addIcalendarEvent(\sb\ICalendar\Event $event) { $a = new \sb\Email\Attachment(); $a->mime_type = 'text/calendar;'; $a->setEncoding('8bit'); $a->name = 'event.ics'; $a->contents = $event->__toString(); $this->addAttachment($a); }
[ "public", "function", "addIcalendarEvent", "(", "\\", "sb", "\\", "ICalendar", "\\", "Event", "$", "event", ")", "{", "$", "a", "=", "new", "\\", "sb", "\\", "Email", "\\", "Attachment", "(", ")", ";", "$", "a", "->", "mime_type", "=", "'text/calendar;...
Add an \sb\ICalendar\Event request @param \sb\ICalendar\Event $event
[ "Add", "an", "\\", "sb", "\\", "ICalendar", "\\", "Event", "request" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email.php#L234-L244
surebert/surebert-framework
src/sb/Email.php
Email.onBeforeSend
public function onBeforeSend() { if(!isset($this->__added_sent_by_stamp)){ $this->body .= "\n\nSent Using Surebert Mail" ." recorded: \nSending IP: " . \sb\Gateway::$remote_addr . " \nSending Host: " . \sb\Gateway::$http_host; if (!empty($this->body_HTML)) { $this->body_HTML .= '<br /><br />' .'<span style="font-size:10px;color:#BCBCBC;margin-top:20px;">' .'Sent Using Surebert Mail:' .'<br />Sending IP:' . \sb\Gateway::$remote_addr .' <br />Sending Host: ' . \sb\Gateway::$http_host. '</span>'; } $this->__added_sent_by_stamp = true; } return true; }
php
public function onBeforeSend() { if(!isset($this->__added_sent_by_stamp)){ $this->body .= "\n\nSent Using Surebert Mail" ." recorded: \nSending IP: " . \sb\Gateway::$remote_addr . " \nSending Host: " . \sb\Gateway::$http_host; if (!empty($this->body_HTML)) { $this->body_HTML .= '<br /><br />' .'<span style="font-size:10px;color:#BCBCBC;margin-top:20px;">' .'Sent Using Surebert Mail:' .'<br />Sending IP:' . \sb\Gateway::$remote_addr .' <br />Sending Host: ' . \sb\Gateway::$http_host. '</span>'; } $this->__added_sent_by_stamp = true; } return true; }
[ "public", "function", "onBeforeSend", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "__added_sent_by_stamp", ")", ")", "{", "$", "this", "->", "body", ".=", "\"\\n\\nSent Using Surebert Mail\"", ".", "\" recorded: \\nSending IP: \"", ".", "\\",...
Fires before sending, if returns false, then sending does not occur @return boolean
[ "Fires", "before", "sending", "if", "returns", "false", "then", "sending", "does", "not", "occur" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email.php#L256-L275
surebert/surebert-framework
src/sb/Email.php
Email.send
public function send($outbox=null) { if($outbox instanceof Writer){ self::$outbox = $outbox; } elseif(!self::$outbox){ self::$outbox = new Writer(); } if($this->onBeforeSend($this) !== false){ self::$outbox->addEmailToOutbox($this); //return if sent return self::$outbox->send(); } }
php
public function send($outbox=null) { if($outbox instanceof Writer){ self::$outbox = $outbox; } elseif(!self::$outbox){ self::$outbox = new Writer(); } if($this->onBeforeSend($this) !== false){ self::$outbox->addEmailToOutbox($this); //return if sent return self::$outbox->send(); } }
[ "public", "function", "send", "(", "$", "outbox", "=", "null", ")", "{", "if", "(", "$", "outbox", "instanceof", "Writer", ")", "{", "self", "::", "$", "outbox", "=", "$", "outbox", ";", "}", "elseif", "(", "!", "self", "::", "$", "outbox", ")", ...
Uses sb_Email_Writer to send the email
[ "Uses", "sb_Email_Writer", "to", "send", "the", "email" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email.php#L279-L296
surebert/surebert-framework
src/sb/Email.php
Email.constructMultipartMessage
public function constructMultipartMessage() { $mixed_boundary = '__mixed_1S2U3R4E5B6E7R8T9'; $alterative_boundary = '__alter_1S2U3R4E5B6E7R8T9'; $this->attachments_in_HTML =0; if(strstr($this->body_HTML, "cid:")) { $this->attachments_in_HTML =1; $related_boundary = '__relate_1S2U3R4E5B6E7R8T9'; } $this->_header_text = "From: ".$this->from.PHP_EOL; $this->_header_text .= "Reply-To: ".$this->from.PHP_EOL; $this->_header_text .= "Return-Path: ".$this->from.PHP_EOL; foreach($this->cc as $cc) { $this->_header_text .="Cc:".$cc.PHP_EOL; } foreach($this->bcc as $bcc) { $this->_header_text .="Bcc:".$bcc.PHP_EOL; } $this->_header_text .= "MIME-Version: 1.0".PHP_EOL; foreach($this->headers as $key=>$val) { $this->_header_text .= $key.":".$val.PHP_EOL; } $this->_header_text .= "Content-Type: multipart/mixed;".PHP_EOL; $this->_header_text .= ' boundary="'.$mixed_boundary.'"'.PHP_EOL.PHP_EOL; // Add a message for peoplewithout mime $message = "This message has an attachment in MIME format created with surebert mail.".PHP_EOL.PHP_EOL; //if there is body_HTML use it otherwise use just plain text if(!empty($this->body_HTML)) { $message .= "--".$mixed_boundary.PHP_EOL; if($this->attachments_in_HTML == 1) { $message .= "Content-Type: multipart/related;".PHP_EOL; $message .= ' boundary="'.$related_boundary.'"'.PHP_EOL.PHP_EOL; $message .= "--".$related_boundary.PHP_EOL; } $message .= "Content-Type: multipart/alternative;".PHP_EOL; $message .= ' boundary="'.$alterative_boundary.'"'.PHP_EOL.PHP_EOL; $message .= "--".$alterative_boundary.PHP_EOL; $message .= "Content-Type: text/plain; charset=".$this->charset."; format=flowed".PHP_EOL; $message .= "Content-Transfer-Encoding: ".$this->transfer_encoding.PHP_EOL; $message .= "Content-Disposition: inline".PHP_EOL.PHP_EOL; $message .= $this->body . PHP_EOL; $message .= "--".$alterative_boundary.PHP_EOL; $message .= "Content-Type: text/html; charset=".$this->charset.PHP_EOL; $message .= "Content-Transfer-Encoding: ".$this->transfer_encoding.PHP_EOL.PHP_EOL; $message .= $this->body_HTML . PHP_EOL; $message .="--".$alterative_boundary."--".PHP_EOL; } else { $message .= "--".$mixed_boundary.PHP_EOL; $message .= "Content-Type: text/plain; charset=".$this->charset."; format=flowed".PHP_EOL; $message .= "Content-Transfer-Encoding: ".$this->transfer_encoding.PHP_EOL; $message .= "Content-Disposition: inline".PHP_EOL.PHP_EOL; $message .= $this->body . PHP_EOL; } //add all attachments for this email foreach($this->attachments as &$attachment) { //if only filepath is set, grab name and contents from there if(isset($attachment->filepath)) { if(empty($attachment->name)) { $attachment->name = basename($attachment->filepath); } if(empty($attachment->contents)) { $attachment->contents = file_get_contents($attachment->filepath); } if(empty($attachment->mime_type)) { $attachment->mime_type = \sb\Files::fileToMime($attachment->filepath); } } $ex = explode(".", $attachment->name); $attachment->extension = strtolower(array_pop($ex)); //try and guess the mime type unless it is set if(empty($attachment->mime_type)) { $attachment->mime_type = \sb\Files::extensionToMime($attachment->extension); } if($attachment->encoding == 'base64' && !isset($attachment->_base64_encoded)){ $attachment->_base64_encoded = true; $attachment->contents = chunk_split(base64_encode($attachment->contents)); } // Add file attachment to the message if($this->attachments_in_HTML == 1) { $message .= "--".$related_boundary.PHP_EOL; } else { $message .= "--".$mixed_boundary.PHP_EOL; } if($attachment->mime_type == 'text/calendar'){ $message .= "Content-class: urn:content-classes:calendarmessage;".PHP_EOL; } $message .= "Content-Type: ".$attachment->mime_type.";".PHP_EOL; $message .= " name=".$attachment->name.PHP_EOL; $message .= "Content-Transfer-Encoding: ".$attachment->encoding.PHP_EOL; $message .= "Content-ID: <".$attachment->name.">".PHP_EOL.PHP_EOL; $message .= $attachment->contents.PHP_EOL; } //end related if using body_HTML if($this->attachments_in_HTML == 1) { $message .= "--".$related_boundary."--".PHP_EOL; } //end message $message .="--".$mixed_boundary."--".PHP_EOL; $this->body = $message; $raw = ""; if($this->to){ $raw .= "To: ".$this->to.PHP_EOL; } $raw .= "Subject: ".$this->subject.PHP_EOL; $raw .= $this->_header_text .$this->body; return $raw; }
php
public function constructMultipartMessage() { $mixed_boundary = '__mixed_1S2U3R4E5B6E7R8T9'; $alterative_boundary = '__alter_1S2U3R4E5B6E7R8T9'; $this->attachments_in_HTML =0; if(strstr($this->body_HTML, "cid:")) { $this->attachments_in_HTML =1; $related_boundary = '__relate_1S2U3R4E5B6E7R8T9'; } $this->_header_text = "From: ".$this->from.PHP_EOL; $this->_header_text .= "Reply-To: ".$this->from.PHP_EOL; $this->_header_text .= "Return-Path: ".$this->from.PHP_EOL; foreach($this->cc as $cc) { $this->_header_text .="Cc:".$cc.PHP_EOL; } foreach($this->bcc as $bcc) { $this->_header_text .="Bcc:".$bcc.PHP_EOL; } $this->_header_text .= "MIME-Version: 1.0".PHP_EOL; foreach($this->headers as $key=>$val) { $this->_header_text .= $key.":".$val.PHP_EOL; } $this->_header_text .= "Content-Type: multipart/mixed;".PHP_EOL; $this->_header_text .= ' boundary="'.$mixed_boundary.'"'.PHP_EOL.PHP_EOL; // Add a message for peoplewithout mime $message = "This message has an attachment in MIME format created with surebert mail.".PHP_EOL.PHP_EOL; //if there is body_HTML use it otherwise use just plain text if(!empty($this->body_HTML)) { $message .= "--".$mixed_boundary.PHP_EOL; if($this->attachments_in_HTML == 1) { $message .= "Content-Type: multipart/related;".PHP_EOL; $message .= ' boundary="'.$related_boundary.'"'.PHP_EOL.PHP_EOL; $message .= "--".$related_boundary.PHP_EOL; } $message .= "Content-Type: multipart/alternative;".PHP_EOL; $message .= ' boundary="'.$alterative_boundary.'"'.PHP_EOL.PHP_EOL; $message .= "--".$alterative_boundary.PHP_EOL; $message .= "Content-Type: text/plain; charset=".$this->charset."; format=flowed".PHP_EOL; $message .= "Content-Transfer-Encoding: ".$this->transfer_encoding.PHP_EOL; $message .= "Content-Disposition: inline".PHP_EOL.PHP_EOL; $message .= $this->body . PHP_EOL; $message .= "--".$alterative_boundary.PHP_EOL; $message .= "Content-Type: text/html; charset=".$this->charset.PHP_EOL; $message .= "Content-Transfer-Encoding: ".$this->transfer_encoding.PHP_EOL.PHP_EOL; $message .= $this->body_HTML . PHP_EOL; $message .="--".$alterative_boundary."--".PHP_EOL; } else { $message .= "--".$mixed_boundary.PHP_EOL; $message .= "Content-Type: text/plain; charset=".$this->charset."; format=flowed".PHP_EOL; $message .= "Content-Transfer-Encoding: ".$this->transfer_encoding.PHP_EOL; $message .= "Content-Disposition: inline".PHP_EOL.PHP_EOL; $message .= $this->body . PHP_EOL; } //add all attachments for this email foreach($this->attachments as &$attachment) { //if only filepath is set, grab name and contents from there if(isset($attachment->filepath)) { if(empty($attachment->name)) { $attachment->name = basename($attachment->filepath); } if(empty($attachment->contents)) { $attachment->contents = file_get_contents($attachment->filepath); } if(empty($attachment->mime_type)) { $attachment->mime_type = \sb\Files::fileToMime($attachment->filepath); } } $ex = explode(".", $attachment->name); $attachment->extension = strtolower(array_pop($ex)); //try and guess the mime type unless it is set if(empty($attachment->mime_type)) { $attachment->mime_type = \sb\Files::extensionToMime($attachment->extension); } if($attachment->encoding == 'base64' && !isset($attachment->_base64_encoded)){ $attachment->_base64_encoded = true; $attachment->contents = chunk_split(base64_encode($attachment->contents)); } // Add file attachment to the message if($this->attachments_in_HTML == 1) { $message .= "--".$related_boundary.PHP_EOL; } else { $message .= "--".$mixed_boundary.PHP_EOL; } if($attachment->mime_type == 'text/calendar'){ $message .= "Content-class: urn:content-classes:calendarmessage;".PHP_EOL; } $message .= "Content-Type: ".$attachment->mime_type.";".PHP_EOL; $message .= " name=".$attachment->name.PHP_EOL; $message .= "Content-Transfer-Encoding: ".$attachment->encoding.PHP_EOL; $message .= "Content-ID: <".$attachment->name.">".PHP_EOL.PHP_EOL; $message .= $attachment->contents.PHP_EOL; } //end related if using body_HTML if($this->attachments_in_HTML == 1) { $message .= "--".$related_boundary."--".PHP_EOL; } //end message $message .="--".$mixed_boundary."--".PHP_EOL; $this->body = $message; $raw = ""; if($this->to){ $raw .= "To: ".$this->to.PHP_EOL; } $raw .= "Subject: ".$this->subject.PHP_EOL; $raw .= $this->_header_text .$this->body; return $raw; }
[ "public", "function", "constructMultipartMessage", "(", ")", "{", "$", "mixed_boundary", "=", "'__mixed_1S2U3R4E5B6E7R8T9'", ";", "$", "alterative_boundary", "=", "'__alter_1S2U3R4E5B6E7R8T9'", ";", "$", "this", "->", "attachments_in_HTML", "=", "0", ";", "if", "(", ...
Convert the email to a multipart_message @return string the raw email source
[ "Convert", "the", "email", "to", "a", "multipart_message" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Email.php#L322-L466
xiewulong/yii2-fileupload
oss/libs/guzzle/common/Guzzle/Common/Exception/ExceptionCollection.php
ExceptionCollection.add
public function add($e) { if ($this->message) { $this->message .= "\n"; } if ($e instanceof self) { $this->message .= '(' . get_class($e) . ")"; foreach (explode("\n", $e->getMessage()) as $message) { $this->message .= "\n {$message}"; } } elseif ($e instanceof \Exception) { $this->exceptions[] = $e; $this->message .= '(' . get_class($e) . ') ' . $e->getMessage(); } return $this; }
php
public function add($e) { if ($this->message) { $this->message .= "\n"; } if ($e instanceof self) { $this->message .= '(' . get_class($e) . ")"; foreach (explode("\n", $e->getMessage()) as $message) { $this->message .= "\n {$message}"; } } elseif ($e instanceof \Exception) { $this->exceptions[] = $e; $this->message .= '(' . get_class($e) . ') ' . $e->getMessage(); } return $this; }
[ "public", "function", "add", "(", "$", "e", ")", "{", "if", "(", "$", "this", "->", "message", ")", "{", "$", "this", "->", "message", ".=", "\"\\n\"", ";", "}", "if", "(", "$", "e", "instanceof", "self", ")", "{", "$", "this", "->", "message", ...
Add exceptions to the collection @param ExceptionCollection|\Exception $e Exception to add @return ExceptionCollection;
[ "Add", "exceptions", "to", "the", "collection" ]
train
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/guzzle/common/Guzzle/Common/Exception/ExceptionCollection.php#L37-L54
pwm/treegami
src/Tree.php
Tree.unfold
public static function unfold(callable $f, $seed): Tree { $unfold = function (callable $f) use (&$unfold): Closure { return function ($seed) use (&$unfold, $f): Tree { [$node, $remaining] = $f($seed); return new Tree($node, \array_map($unfold($f), $remaining)); }; }; [$node, $remaining] = $f($seed); return new Tree($node, \array_map($unfold($f), $remaining)); }
php
public static function unfold(callable $f, $seed): Tree { $unfold = function (callable $f) use (&$unfold): Closure { return function ($seed) use (&$unfold, $f): Tree { [$node, $remaining] = $f($seed); return new Tree($node, \array_map($unfold($f), $remaining)); }; }; [$node, $remaining] = $f($seed); return new Tree($node, \array_map($unfold($f), $remaining)); }
[ "public", "static", "function", "unfold", "(", "callable", "$", "f", ",", "$", "seed", ")", ":", "Tree", "{", "$", "unfold", "=", "function", "(", "callable", "$", "f", ")", "use", "(", "&", "$", "unfold", ")", ":", "Closure", "{", "return", "funct...
(b -> (a, [b])) -> b -> Tree a
[ "(", "b", "-", ">", "(", "a", "[", "b", "]", "))", "-", ">", "b", "-", ">", "Tree", "a" ]
train
https://github.com/pwm/treegami/blob/4a808ad1c138a3de96f78ef386f54bac2f5cf0c0/src/Tree.php#L22-L32
pwm/treegami
src/Tree.php
Tree.fold
public function fold(callable $f) { $fold = function (Tree $tree) use (&$fold, $f) { return $f($tree->node, \array_map($fold, $tree->children)); }; return $fold($this); }
php
public function fold(callable $f) { $fold = function (Tree $tree) use (&$fold, $f) { return $f($tree->node, \array_map($fold, $tree->children)); }; return $fold($this); }
[ "public", "function", "fold", "(", "callable", "$", "f", ")", "{", "$", "fold", "=", "function", "(", "Tree", "$", "tree", ")", "use", "(", "&", "$", "fold", ",", "$", "f", ")", "{", "return", "$", "f", "(", "$", "tree", "->", "node", ",", "\...
(a -> [b] -> b) -> Tree a -> b
[ "(", "a", "-", ">", "[", "b", "]", "-", ">", "b", ")", "-", ">", "Tree", "a", "-", ">", "b" ]
train
https://github.com/pwm/treegami/blob/4a808ad1c138a3de96f78ef386f54bac2f5cf0c0/src/Tree.php#L35-L41
pwm/treegami
src/Tree.php
Tree.map
public function map(callable $f): Tree { return $this->fold(function ($node, array $children) use ($f): Tree { return new Tree($f($node), $children); }); }
php
public function map(callable $f): Tree { return $this->fold(function ($node, array $children) use ($f): Tree { return new Tree($f($node), $children); }); }
[ "public", "function", "map", "(", "callable", "$", "f", ")", ":", "Tree", "{", "return", "$", "this", "->", "fold", "(", "function", "(", "$", "node", ",", "array", "$", "children", ")", "use", "(", "$", "f", ")", ":", "Tree", "{", "return", "new...
(a -> b) -> Tree a -> Tree b
[ "(", "a", "-", ">", "b", ")", "-", ">", "Tree", "a", "-", ">", "Tree", "b" ]
train
https://github.com/pwm/treegami/blob/4a808ad1c138a3de96f78ef386f54bac2f5cf0c0/src/Tree.php#L44-L49
php-lug/lug
src/Bundle/ResourceBundle/DependencyInjection/Compiler/RegisterManagerTagPass.php
RegisterManagerTagPass.process
public function process(ContainerBuilder $container) { foreach (array_keys($container->findTaggedServiceIds('lug.resource')) as $service) { $resource = $container->getDefinition($service)->getArgument(0); $alias = 'lug.manager.'.$resource; if (!$container->hasAlias($alias)) { continue; } $container ->getDefinition((string) $container->getAlias($alias)) ->addTag('lug.manager', ['resource' => $resource]); } }
php
public function process(ContainerBuilder $container) { foreach (array_keys($container->findTaggedServiceIds('lug.resource')) as $service) { $resource = $container->getDefinition($service)->getArgument(0); $alias = 'lug.manager.'.$resource; if (!$container->hasAlias($alias)) { continue; } $container ->getDefinition((string) $container->getAlias($alias)) ->addTag('lug.manager', ['resource' => $resource]); } }
[ "public", "function", "process", "(", "ContainerBuilder", "$", "container", ")", "{", "foreach", "(", "array_keys", "(", "$", "container", "->", "findTaggedServiceIds", "(", "'lug.resource'", ")", ")", "as", "$", "service", ")", "{", "$", "resource", "=", "$...
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/ResourceBundle/DependencyInjection/Compiler/RegisterManagerTagPass.php#L25-L39
gedex/php-janrain-api
lib/Janrain/Api/Engage/Mapping.php
Mapping.map
public function map(array $params) { if (!isset($params['ientifier'])) { throw new MissingArgumentException('identifier'); } if (!isset($params['primaryKey'])) { throw new MissingArgumentException('primaryKey'); } if (!isset($params['format'])) { $params['format'] = 'json'; } return $this->post('map', $params); }
php
public function map(array $params) { if (!isset($params['ientifier'])) { throw new MissingArgumentException('identifier'); } if (!isset($params['primaryKey'])) { throw new MissingArgumentException('primaryKey'); } if (!isset($params['format'])) { $params['format'] = 'json'; } return $this->post('map', $params); }
[ "public", "function", "map", "(", "array", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'ientifier'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'identifier'", ")", ";", "}", "if", "(", "!", "...
Associates a primary key with a user's social identity. @param array $params
[ "Associates", "a", "primary", "key", "with", "a", "user", "s", "social", "identity", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/Mapping.php#L27-L42
gedex/php-janrain-api
lib/Janrain/Api/Engage/Mapping.php
Mapping.unmap
public function unmap(array $params) { if (!isset($params['ientifier'])) { throw new MissingArgumentException('identifier'); } if (!isset($params['all_identifiers'])) { throw new MissingArgumentException('all_identifiers'); } if (!isset($params['primaryKey'])) { throw new MissingArgumentException('primaryKey'); } if (!isset($params['unlink'])) { throw new MissingArgumentException('unlink'); } if (!isset($params['format'])) { $params['format'] = 'json'; } return $this->post('unmap', $params); }
php
public function unmap(array $params) { if (!isset($params['ientifier'])) { throw new MissingArgumentException('identifier'); } if (!isset($params['all_identifiers'])) { throw new MissingArgumentException('all_identifiers'); } if (!isset($params['primaryKey'])) { throw new MissingArgumentException('primaryKey'); } if (!isset($params['unlink'])) { throw new MissingArgumentException('unlink'); } if (!isset($params['format'])) { $params['format'] = 'json'; } return $this->post('unmap', $params); }
[ "public", "function", "unmap", "(", "array", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "params", "[", "'ientifier'", "]", ")", ")", "{", "throw", "new", "MissingArgumentException", "(", "'identifier'", ")", ";", "}", "if", "(", "!", ...
Removes an identity provider from a primary key as well as allowing you to optionally unlink your application from the user's account with the provider. @param array $params
[ "Removes", "an", "identity", "provider", "from", "a", "primary", "key", "as", "well", "as", "allowing", "you", "to", "optionally", "unlink", "your", "application", "from", "the", "user", "s", "account", "with", "the", "provider", "." ]
train
https://github.com/gedex/php-janrain-api/blob/6283f68454e0ad5211ac620f1d337df38cd49597/lib/Janrain/Api/Engage/Mapping.php#L62-L85
odiaseo/pagebuilder
src/PageBuilder/Controller/PageController.php
PageController.get
public function get($id) { return $this->_sendPayload( $this->_getService($this->_pageServiceKey)->getPageLayout($id) ); }
php
public function get($id) { return $this->_sendPayload( $this->_getService($this->_pageServiceKey)->getPageLayout($id) ); }
[ "public", "function", "get", "(", "$", "id", ")", "{", "return", "$", "this", "->", "_sendPayload", "(", "$", "this", "->", "_getService", "(", "$", "this", "->", "_pageServiceKey", ")", "->", "getPageLayout", "(", "$", "id", ")", ")", ";", "}" ]
Get page layout details @param mixed $id @return mixed|\Zend\View\Model\ModelInterface
[ "Get", "page", "layout", "details" ]
train
https://github.com/odiaseo/pagebuilder/blob/88ef7cccf305368561307efe4ca07fac8e5774f3/src/PageBuilder/Controller/PageController.php#L19-L24
philiplb/Valdi
src/Valdi/Validator/Collection.php
Collection.isValidArray
protected function isValidArray($values, Validator $validator, array $rules) { if (!is_array($values)) { $this->invalidDetails = $values; return false; } $this->invalidDetails = []; foreach ($values as $key => $value) { $elementValidation = $validator->isValid(['value' => $rules], ['value' => $value]); if (!$elementValidation['valid']) { $this->invalidDetails[$key] = $elementValidation['errors']['value']; } } return count($this->invalidDetails) === 0; }
php
protected function isValidArray($values, Validator $validator, array $rules) { if (!is_array($values)) { $this->invalidDetails = $values; return false; } $this->invalidDetails = []; foreach ($values as $key => $value) { $elementValidation = $validator->isValid(['value' => $rules], ['value' => $value]); if (!$elementValidation['valid']) { $this->invalidDetails[$key] = $elementValidation['errors']['value']; } } return count($this->invalidDetails) === 0; }
[ "protected", "function", "isValidArray", "(", "$", "values", ",", "Validator", "$", "validator", ",", "array", "$", "rules", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "$", "this", "->", "invalidDetails", "=", "$", "values...
{@inheritdoc}
[ "{" ]
train
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator/Collection.php#L24-L38
caffeinated/beverage
src/ServiceProvider.php
ServiceProvider.boot
public function boot() { $this->bootConfigFiles(); $this->bootViews(); $this->bootAssets(); $this->bootMigrations(); $this->bootSeeds(); $this->requireHelpersFor('boot'); return $this->app; }
php
public function boot() { $this->bootConfigFiles(); $this->bootViews(); $this->bootAssets(); $this->bootMigrations(); $this->bootSeeds(); $this->requireHelpersFor('boot'); return $this->app; }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "bootConfigFiles", "(", ")", ";", "$", "this", "->", "bootViews", "(", ")", ";", "$", "this", "->", "bootAssets", "(", ")", ";", "$", "this", "->", "bootMigrations", "(", ")", ";", "$"...
Perform the booting of the service. @return \Illuminate\Foundation\Application
[ "Perform", "the", "booting", "of", "the", "service", "." ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/ServiceProvider.php#L280-L290
caffeinated/beverage
src/ServiceProvider.php
ServiceProvider.bootConfigFiles
protected function bootConfigFiles() { if (isset($this->dir) and isset($this->configFiles) and is_array($this->configFiles)) { foreach ($this->configFiles as $filename) { $this->publishes([ $this->getConfigFilePath($filename) => config_path($filename . '.php') ], 'config'); } } }
php
protected function bootConfigFiles() { if (isset($this->dir) and isset($this->configFiles) and is_array($this->configFiles)) { foreach ($this->configFiles as $filename) { $this->publishes([ $this->getConfigFilePath($filename) => config_path($filename . '.php') ], 'config'); } } }
[ "protected", "function", "bootConfigFiles", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "dir", ")", "and", "isset", "(", "$", "this", "->", "configFiles", ")", "and", "is_array", "(", "$", "this", "->", "configFiles", ")", ")", "{", "f...
Adds the config files defined in $configFiles to the publish procedure. Can be overriden to adjust default functionality
[ "Adds", "the", "config", "files", "defined", "in", "$configFiles", "to", "the", "publish", "procedure", ".", "Can", "be", "overriden", "to", "adjust", "default", "functionality" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/ServiceProvider.php#L296-L303
caffeinated/beverage
src/ServiceProvider.php
ServiceProvider.bootViews
protected function bootViews() { if (isset($this->dir) and isset($this->viewDirs) and is_array($this->viewDirs)) { foreach ($this->viewDirs as $dirName => $namespace) { $viewPath = $this->getViewsPath($dirName); $viewsDestinationPath = Str::replace($this->viewsDestinationPath, '{namespace}', $namespace); $this->loadViewsFrom($viewPath, $namespace); $this->publishes([ $viewPath => base_path($viewsDestinationPath) ], 'views'); } } }
php
protected function bootViews() { if (isset($this->dir) and isset($this->viewDirs) and is_array($this->viewDirs)) { foreach ($this->viewDirs as $dirName => $namespace) { $viewPath = $this->getViewsPath($dirName); $viewsDestinationPath = Str::replace($this->viewsDestinationPath, '{namespace}', $namespace); $this->loadViewsFrom($viewPath, $namespace); $this->publishes([ $viewPath => base_path($viewsDestinationPath) ], 'views'); } } }
[ "protected", "function", "bootViews", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "dir", ")", "and", "isset", "(", "$", "this", "->", "viewDirs", ")", "and", "is_array", "(", "$", "this", "->", "viewDirs", ")", ")", "{", "foreach", "...
Adds the view directories defined in $viewDirs to the publish procedure. Can be overriden to adjust default functionality
[ "Adds", "the", "view", "directories", "defined", "in", "$viewDirs", "to", "the", "publish", "procedure", ".", "Can", "be", "overriden", "to", "adjust", "default", "functionality" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/ServiceProvider.php#L309-L319
caffeinated/beverage
src/ServiceProvider.php
ServiceProvider.bootAssets
protected function bootAssets() { if (isset($this->dir) and isset($this->assetDirs) and is_array($this->assetDirs)) { foreach ($this->assetDirs as $dirName => $namespace) { $assetDestinationPath = Str::replace($this->assetsDestinationPath, '{namespace}', $namespace); $this->publishes([ $this->getAssetsPath($dirName) => public_path($assetDestinationPath) ], 'public'); } } }
php
protected function bootAssets() { if (isset($this->dir) and isset($this->assetDirs) and is_array($this->assetDirs)) { foreach ($this->assetDirs as $dirName => $namespace) { $assetDestinationPath = Str::replace($this->assetsDestinationPath, '{namespace}', $namespace); $this->publishes([ $this->getAssetsPath($dirName) => public_path($assetDestinationPath) ], 'public'); } } }
[ "protected", "function", "bootAssets", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "dir", ")", "and", "isset", "(", "$", "this", "->", "assetDirs", ")", "and", "is_array", "(", "$", "this", "->", "assetDirs", ")", ")", "{", "foreach", ...
Adds the asset directories defined in $assetDirs to the publish procedure. Can be overriden to adjust default functionality
[ "Adds", "the", "asset", "directories", "defined", "in", "$assetDirs", "to", "the", "publish", "procedure", ".", "Can", "be", "overriden", "to", "adjust", "default", "functionality" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/ServiceProvider.php#L325-L333
caffeinated/beverage
src/ServiceProvider.php
ServiceProvider.bootMigrations
protected function bootMigrations() { if (isset($this->dir) and isset($this->migrationDirs) and is_array($this->migrationDirs)) { foreach ($this->migrationDirs as $dirPath) { $this->publishes([ $this->getDatabasePath($dirPath) => database_path($this->migrationDestinationPath) ], 'migrations'); } } }
php
protected function bootMigrations() { if (isset($this->dir) and isset($this->migrationDirs) and is_array($this->migrationDirs)) { foreach ($this->migrationDirs as $dirPath) { $this->publishes([ $this->getDatabasePath($dirPath) => database_path($this->migrationDestinationPath) ], 'migrations'); } } }
[ "protected", "function", "bootMigrations", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "dir", ")", "and", "isset", "(", "$", "this", "->", "migrationDirs", ")", "and", "is_array", "(", "$", "this", "->", "migrationDirs", ")", ")", "{", ...
Adds the migration directories defined in $migrationDirs to the publish procedure. Can be overriden to adjust default functionality
[ "Adds", "the", "migration", "directories", "defined", "in", "$migrationDirs", "to", "the", "publish", "procedure", ".", "Can", "be", "overriden", "to", "adjust", "default", "functionality" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/ServiceProvider.php#L339-L346
caffeinated/beverage
src/ServiceProvider.php
ServiceProvider.bootSeeds
protected function bootSeeds() { if (isset($this->dir) and isset($this->seedDirs) and is_array($this->seedDirs)) { foreach ($this->seedDirs as $dirPath) { $this->publishes([ $this->getDatabasePath($dirPath) => database_path($this->seedsDestinationPath) ], 'seeds'); } } }
php
protected function bootSeeds() { if (isset($this->dir) and isset($this->seedDirs) and is_array($this->seedDirs)) { foreach ($this->seedDirs as $dirPath) { $this->publishes([ $this->getDatabasePath($dirPath) => database_path($this->seedsDestinationPath) ], 'seeds'); } } }
[ "protected", "function", "bootSeeds", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "dir", ")", "and", "isset", "(", "$", "this", "->", "seedDirs", ")", "and", "is_array", "(", "$", "this", "->", "seedDirs", ")", ")", "{", "foreach", "...
Adds the seed directories defined in $seedDirs to the publish procedure. Can be overriden to adjust default functionality
[ "Adds", "the", "seed", "directories", "defined", "in", "$seedDirs", "to", "the", "publish", "procedure", ".", "Can", "be", "overriden", "to", "adjust", "default", "functionality" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/ServiceProvider.php#L352-L359
caffeinated/beverage
src/ServiceProvider.php
ServiceProvider.registerConfigFiles
protected function registerConfigFiles() { if (isset($this->dir) and isset($this->configFiles) and is_array($this->configFiles)) { foreach ($this->configFiles as $key) { $path = $this->getConfigFilePath($key); //$this->mergeConfigFrom($this->getConfigFilePath($filename), $filename); $config = $this->app->make('config')->get($key, [ ]); $this->app->make('config')->set($key, array_replace_recursive(require $path, $config)); } } }
php
protected function registerConfigFiles() { if (isset($this->dir) and isset($this->configFiles) and is_array($this->configFiles)) { foreach ($this->configFiles as $key) { $path = $this->getConfigFilePath($key); //$this->mergeConfigFrom($this->getConfigFilePath($filename), $filename); $config = $this->app->make('config')->get($key, [ ]); $this->app->make('config')->set($key, array_replace_recursive(require $path, $config)); } } }
[ "protected", "function", "registerConfigFiles", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "dir", ")", "and", "isset", "(", "$", "this", "->", "configFiles", ")", "and", "is_array", "(", "$", "this", "->", "configFiles", ")", ")", "{", ...
Merges all defined config files defined in $configFiles. Can be overriden to adjust default functionality
[ "Merges", "all", "defined", "config", "files", "defined", "in", "$configFiles", ".", "Can", "be", "overriden", "to", "adjust", "default", "functionality" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/ServiceProvider.php#L446-L456
caffeinated/beverage
src/ServiceProvider.php
ServiceProvider.getPath
public function getPath($relativePath, $fileName = null, $ext = '.php') { $path = Path::join($this->dir, $relativePath); return is_null($fileName) ? $path : Path::join($path, $fileName . $ext); }
php
public function getPath($relativePath, $fileName = null, $ext = '.php') { $path = Path::join($this->dir, $relativePath); return is_null($fileName) ? $path : Path::join($path, $fileName . $ext); }
[ "public", "function", "getPath", "(", "$", "relativePath", ",", "$", "fileName", "=", "null", ",", "$", "ext", "=", "'.php'", ")", "{", "$", "path", "=", "Path", "::", "join", "(", "$", "this", "->", "dir", ",", "$", "relativePath", ")", ";", "retu...
getFilePath @param $relativePath @param null $fileName @param string $ext @return string
[ "getFilePath" ]
train
https://github.com/caffeinated/beverage/blob/c7d612a1d3bc1baddc97fec60ab17224550efaf3/src/ServiceProvider.php#L474-L479
Eresus/EresusCMS
src/core/lib/admin/lists.php
AdminList.control
function control($type, $href, $custom = array()) { $s = ''; if (isset($this->__controls[$type])) $control = $this->__controls[$type]; switch($type) { case 'position': $s = array_pop($href); $href = $href[0]; break; } foreach ($custom as $key => $value) { $control[$key] = $value; } $result = '<a href="' . $href . '"' . (isset($control['onclick']) ? ' onclick="' . $control['onclick'] . '"' : '') . '><img src="' . Eresus_CMS::getLegacyKernel()->root . $control['image'] . '" alt="' . $control['alt'].'" title="'.$control['title'].'" /></a>'; if ($type == 'position') $result .= ' '.$this->control('position_down', $s, $custom); return $result; }
php
function control($type, $href, $custom = array()) { $s = ''; if (isset($this->__controls[$type])) $control = $this->__controls[$type]; switch($type) { case 'position': $s = array_pop($href); $href = $href[0]; break; } foreach ($custom as $key => $value) { $control[$key] = $value; } $result = '<a href="' . $href . '"' . (isset($control['onclick']) ? ' onclick="' . $control['onclick'] . '"' : '') . '><img src="' . Eresus_CMS::getLegacyKernel()->root . $control['image'] . '" alt="' . $control['alt'].'" title="'.$control['title'].'" /></a>'; if ($type == 'position') $result .= ' '.$this->control('position_down', $s, $custom); return $result; }
[ "function", "control", "(", "$", "type", ",", "$", "href", ",", "$", "custom", "=", "array", "(", ")", ")", "{", "$", "s", "=", "''", ";", "if", "(", "isset", "(", "$", "this", "->", "__controls", "[", "$", "type", "]", ")", ")", "$", "contro...
Отрисовывает элемент управления @param string $type Тип ЭУ (delete,toggle,move,custom...) @param string $href Ссылка @param array $custom Индивидуальные настройки @return string HTML
[ "Отрисовывает", "элемент", "управления" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/admin/lists.php#L61-L81
Eresus/EresusCMS
src/core/lib/admin/lists.php
AdminList.setHead
function setHead() { $this->head = array(); $items = func_get_args(); if (count($items)) foreach($items as $item) { if (is_string($item)) $this->head[] = array('text' => $item); elseif (is_array($item)) $this->head[] = $item; } }
php
function setHead() { $this->head = array(); $items = func_get_args(); if (count($items)) foreach($items as $item) { if (is_string($item)) $this->head[] = array('text' => $item); elseif (is_array($item)) $this->head[] = $item; } }
[ "function", "setHead", "(", ")", "{", "$", "this", "->", "head", "=", "array", "(", ")", ";", "$", "items", "=", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "items", ")", ")", "foreach", "(", "$", "items", "as", "$", "item", "...
Устанавливает названия и параметры столбцов @access public @param string $text Заголовок столбца или @param array $cell Описание столбца
[ "Устанавливает", "названия", "и", "параметры", "столбцов" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/admin/lists.php#L92-L100
Eresus/EresusCMS
src/core/lib/admin/lists.php
AdminList.setColumn
function setColumn($index, $params) { if (isset($this->columns[$index])) $this->columns[$index] = array_merge($this->columns[$index], $params); else $this->columns[$index] = $params; }
php
function setColumn($index, $params) { if (isset($this->columns[$index])) $this->columns[$index] = array_merge($this->columns[$index], $params); else $this->columns[$index] = $params; }
[ "function", "setColumn", "(", "$", "index", ",", "$", "params", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "columns", "[", "$", "index", "]", ")", ")", "$", "this", "->", "columns", "[", "$", "index", "]", "=", "array_merge", "(", "$",...
Устанавливает параметры столбца Перезаписываются только параметры указанные в $params @access public @param int $index Номер столбца @param array $params Описание столбца
[ "Устанавливает", "параметры", "столбца" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/admin/lists.php#L112-L116
Eresus/EresusCMS
src/core/lib/admin/lists.php
AdminList.addRow
function addRow($cells) { for($i=0; $i < count($cells); $i++) { if (!is_array($cells[$i])) $cells[$i] = array('text' => $cells[$i]); if (!isset($cells[$i]['text']) && isset($cells[$i][0])) { $cells[$i]['text'] = $cells[$i][0]; unset($cells[$i][0]); } } $this->body[] = $cells; }
php
function addRow($cells) { for($i=0; $i < count($cells); $i++) { if (!is_array($cells[$i])) $cells[$i] = array('text' => $cells[$i]); if (!isset($cells[$i]['text']) && isset($cells[$i][0])) { $cells[$i]['text'] = $cells[$i][0]; unset($cells[$i][0]); } } $this->body[] = $cells; }
[ "function", "addRow", "(", "$", "cells", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "cells", ")", ";", "$", "i", "++", ")", "{", "if", "(", "!", "is_array", "(", "$", "cells", "[", "$", "i", "]", ")",...
Добавляет строку в таблицу @access public @param array $cells Ячейки строки
[ "Добавляет", "строку", "в", "таблицу" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/admin/lists.php#L125-L135
Eresus/EresusCMS
src/core/lib/admin/lists.php
AdminList.addRows
function addRows($rows) { for($i=0; $i < count($rows); $i++) $this->addRow($rows[$i]); }
php
function addRows($rows) { for($i=0; $i < count($rows); $i++) $this->addRow($rows[$i]); }
[ "function", "addRows", "(", "$", "rows", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "rows", ")", ";", "$", "i", "++", ")", "$", "this", "->", "addRow", "(", "$", "rows", "[", "$", "i", "]", ")", ";", ...
Добавляет строки в таблицу @access public @param array $rows Строки
[ "Добавляет", "строки", "в", "таблицу" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/admin/lists.php#L144-L147
Eresus/EresusCMS
src/core/lib/admin/lists.php
AdminList.renderCell
function renderCell($tag, $cell) { $style = ''; $text= isset($cell['text']) ? $cell['text'] : ''; if (isset($cell['href'])) $text = '<a href="'.$cell['href'].'">'.$text.'</a>'; if (isset($cell['align'])) $style .= 'text-align: '.$cell['align'].';'; if (isset($cell['style'])) $style .= $cell['style']; $result = '<'.$tag.(empty($style)?'':" style=\"$style\"").'>'.$text.'</'.$tag.'>'; return $result; }
php
function renderCell($tag, $cell) { $style = ''; $text= isset($cell['text']) ? $cell['text'] : ''; if (isset($cell['href'])) $text = '<a href="'.$cell['href'].'">'.$text.'</a>'; if (isset($cell['align'])) $style .= 'text-align: '.$cell['align'].';'; if (isset($cell['style'])) $style .= $cell['style']; $result = '<'.$tag.(empty($style)?'':" style=\"$style\"").'>'.$text.'</'.$tag.'>'; return $result; }
[ "function", "renderCell", "(", "$", "tag", ",", "$", "cell", ")", "{", "$", "style", "=", "''", ";", "$", "text", "=", "isset", "(", "$", "cell", "[", "'text'", "]", ")", "?", "$", "cell", "[", "'text'", "]", ":", "''", ";", "if", "(", "isset...
Отрисовывает ячейку таблицы @access private
[ "Отрисовывает", "ячейку", "таблицы" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/admin/lists.php#L154-L163
Eresus/EresusCMS
src/core/lib/admin/lists.php
AdminList.render
function render() { $thead = ''; foreach($this->head as $cell) $thead .= $this->renderCell('th', $cell); $tbody = array(); foreach($this->body as $row) { $cells = '<tr>'; foreach($row as $cell) $cells .= $this->renderCell('td', $cell); $cells .= '</tr>'; $tbody[] = $cells; } $table = '<table class="admList">'; $table .= '<tr>'.$thead.'</tr>'; $table .= implode("\n", $tbody); $table .= '</table>'; return $table; }
php
function render() { $thead = ''; foreach($this->head as $cell) $thead .= $this->renderCell('th', $cell); $tbody = array(); foreach($this->body as $row) { $cells = '<tr>'; foreach($row as $cell) $cells .= $this->renderCell('td', $cell); $cells .= '</tr>'; $tbody[] = $cells; } $table = '<table class="admList">'; $table .= '<tr>'.$thead.'</tr>'; $table .= implode("\n", $tbody); $table .= '</table>'; return $table; }
[ "function", "render", "(", ")", "{", "$", "thead", "=", "''", ";", "foreach", "(", "$", "this", "->", "head", "as", "$", "cell", ")", "$", "thead", ".=", "$", "this", "->", "renderCell", "(", "'th'", ",", "$", "cell", ")", ";", "$", "tbody", "=...
Отрисовывает таблицу @return string HTML-код таблицы
[ "Отрисовывает", "таблицу" ]
train
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/lib/admin/lists.php#L170-L186
video-games-records/TeamBundle
Controller/TeamController.php
TeamController.indexAction
public function indexAction($id, $slug) { /** @var \VideoGamesRecords\CoreBundle\Entity\Team $team */ $team = $this->getDoctrine()->getRepository('VideoGamesRecordsTeamBundle:Team')->getTeamWithGames($id); if ($slug !== $team->getSlug()) { return $this->redirectToRoute('vgr_team_index', ['id' => $team->getIdTeam(), 'slug' => $team->getSlug()], 301); } $breadcrumbs = $this->get('white_october_breadcrumbs'); $breadcrumbs->addRouteItem('Home', 'homepage'); $breadcrumbs->addItem($team->getLibTeam()); return $this->render('VideoGamesRecordsTeamBundle:Team:index.html.twig', ['team' => $team]); }
php
public function indexAction($id, $slug) { /** @var \VideoGamesRecords\CoreBundle\Entity\Team $team */ $team = $this->getDoctrine()->getRepository('VideoGamesRecordsTeamBundle:Team')->getTeamWithGames($id); if ($slug !== $team->getSlug()) { return $this->redirectToRoute('vgr_team_index', ['id' => $team->getIdTeam(), 'slug' => $team->getSlug()], 301); } $breadcrumbs = $this->get('white_october_breadcrumbs'); $breadcrumbs->addRouteItem('Home', 'homepage'); $breadcrumbs->addItem($team->getLibTeam()); return $this->render('VideoGamesRecordsTeamBundle:Team:index.html.twig', ['team' => $team]); }
[ "public", "function", "indexAction", "(", "$", "id", ",", "$", "slug", ")", "{", "/** @var \\VideoGamesRecords\\CoreBundle\\Entity\\Team $team */", "$", "team", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'VideoGamesRecordsTeamBundle:...
@Route("/{id}/{slug}", requirements={"id": "[1-9]\d*"}, name="vgr_team_index") @Method("GET") @Cache(smaxage="10") @param int $id @param string $slug @return \Symfony\Component\HttpFoundation\Response @throws \Exception
[ "@Route", "(", "/", "{", "id", "}", "/", "{", "slug", "}", "requirements", "=", "{", "id", ":", "[", "1", "-", "9", "]", "\\", "d", "*", "}", "name", "=", "vgr_team_index", ")", "@Method", "(", "GET", ")", "@Cache", "(", "smaxage", "=", "10", ...
train
https://github.com/video-games-records/TeamBundle/blob/4e5b73874bacb96f70ab16e74d54a1b6efc8e62f/Controller/TeamController.php#L32-L45
video-games-records/TeamBundle
Controller/TeamController.php
TeamController.listAction
public function listAction($page) { $query = $this->getDoctrine()->getRepository('VideoGamesRecordsTeamBundle:Team')->getPaginatedQuery(); $paginator = $this->get('knp_paginator'); /** @var \Knp\Bundle\PaginatorBundle\Pagination\SlidingPagination $teams */ $teams = $paginator->paginate($query, $page, Team::NUM_ITEMS); $teams->setUsedRoute('vgr_team_list_paginated'); $breadcrumbs = $this->get('white_october_breadcrumbs'); $breadcrumbs->addRouteItem('Home', 'homepage'); $breadcrumbs->addItem('team.list'); return $this->render('VideoGamesRecordsTeamBundle:Team:list.html.twig', ['teams' => $teams]); }
php
public function listAction($page) { $query = $this->getDoctrine()->getRepository('VideoGamesRecordsTeamBundle:Team')->getPaginatedQuery(); $paginator = $this->get('knp_paginator'); /** @var \Knp\Bundle\PaginatorBundle\Pagination\SlidingPagination $teams */ $teams = $paginator->paginate($query, $page, Team::NUM_ITEMS); $teams->setUsedRoute('vgr_team_list_paginated'); $breadcrumbs = $this->get('white_october_breadcrumbs'); $breadcrumbs->addRouteItem('Home', 'homepage'); $breadcrumbs->addItem('team.list'); return $this->render('VideoGamesRecordsTeamBundle:Team:list.html.twig', ['teams' => $teams]); }
[ "public", "function", "listAction", "(", "$", "page", ")", "{", "$", "query", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'VideoGamesRecordsTeamBundle:Team'", ")", "->", "getPaginatedQuery", "(", ")", ";", "$", "paginator", ...
@Route("/list", defaults={"page": 1}, name="vgr_team_list") @Route("/list/page/{page}", requirements={"page": "[1-9]\d*"}, name="vgr_team_list_paginated") @Method("GET") @Cache(smaxage="10") @param int $page @return \Symfony\Component\HttpFoundation\Response
[ "@Route", "(", "/", "list", "defaults", "=", "{", "page", ":", "1", "}", "name", "=", "vgr_team_list", ")", "@Route", "(", "/", "list", "/", "page", "/", "{", "page", "}", "requirements", "=", "{", "page", ":", "[", "1", "-", "9", "]", "\\", "d...
train
https://github.com/video-games-records/TeamBundle/blob/4e5b73874bacb96f70ab16e74d54a1b6efc8e62f/Controller/TeamController.php#L57-L71
video-games-records/TeamBundle
Controller/TeamController.php
TeamController.accountAction
public function accountAction() { /** @var \VideoGamesRecords\CoreBundle\Entity\Player $player */ $player = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Player')->find($this->getPlayer()->getIdPlayer()); return $this->render( 'VideoGamesRecordsTeamBundle:Team:account.html.twig', [ 'player' => $player, ] ); }
php
public function accountAction() { /** @var \VideoGamesRecords\CoreBundle\Entity\Player $player */ $player = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Player')->find($this->getPlayer()->getIdPlayer()); return $this->render( 'VideoGamesRecordsTeamBundle:Team:account.html.twig', [ 'player' => $player, ] ); }
[ "public", "function", "accountAction", "(", ")", "{", "/** @var \\VideoGamesRecords\\CoreBundle\\Entity\\Player $player */", "$", "player", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'VideoGamesRecordsCoreBundle:Player'", ")", "->", "fin...
@Route("/account", name="vgr_team_account") @Method("GET") @Cache(smaxage="10") @Security("is_granted('IS_AUTHENTICATED_REMEMBERED')") @return \Symfony\Component\HttpFoundation\Response @throws \Exception
[ "@Route", "(", "/", "account", "name", "=", "vgr_team_account", ")", "@Method", "(", "GET", ")", "@Cache", "(", "smaxage", "=", "10", ")", "@Security", "(", "is_granted", "(", "IS_AUTHENTICATED_REMEMBERED", ")", ")" ]
train
https://github.com/video-games-records/TeamBundle/blob/4e5b73874bacb96f70ab16e74d54a1b6efc8e62f/Controller/TeamController.php#L82-L93
video-games-records/TeamBundle
Controller/TeamController.php
TeamController.quitAction
public function quitAction(Request $request) { $form = $this->createFormBuilder() ->setAction($this->generateUrl('vgr_team_quit')) ->setMethod('POST') ->add('save', SubmitType::class, array('label' => 'QUIT')) ->getForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { /** @var \VideoGamesRecords\CoreBundle\Entity\Player $player */ $player = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Player')->find($this->getPlayer()->getIdPlayer()); $player->setTeam(null); $em = $this->getDoctrine()->getManager(); $em->flush(); //----- Message $this->addFlash( 'notice', sprintf('Your changes were saved!!!') ); return $this->redirectToRoute('vgr_account_index'); } return $this->render( 'VideoGamesRecordsTeamBundle:Form:form.html.twig', [ 'form' => $form->createView(), ] ); }
php
public function quitAction(Request $request) { $form = $this->createFormBuilder() ->setAction($this->generateUrl('vgr_team_quit')) ->setMethod('POST') ->add('save', SubmitType::class, array('label' => 'QUIT')) ->getForm(); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { /** @var \VideoGamesRecords\CoreBundle\Entity\Player $player */ $player = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Player')->find($this->getPlayer()->getIdPlayer()); $player->setTeam(null); $em = $this->getDoctrine()->getManager(); $em->flush(); //----- Message $this->addFlash( 'notice', sprintf('Your changes were saved!!!') ); return $this->redirectToRoute('vgr_account_index'); } return $this->render( 'VideoGamesRecordsTeamBundle:Form:form.html.twig', [ 'form' => $form->createView(), ] ); }
[ "public", "function", "quitAction", "(", "Request", "$", "request", ")", "{", "$", "form", "=", "$", "this", "->", "createFormBuilder", "(", ")", "->", "setAction", "(", "$", "this", "->", "generateUrl", "(", "'vgr_team_quit'", ")", ")", "->", "setMethod",...
@Route("/quit", name="vgr_team_quit") @Method({"GET","POST"}) @Cache(smaxage="10") @Security("is_granted('IS_AUTHENTICATED_REMEMBERED')") @param Request $request @return \Symfony\Component\HttpFoundation\Response @throws \Exception
[ "@Route", "(", "/", "quit", "name", "=", "vgr_team_quit", ")", "@Method", "(", "{", "GET", "POST", "}", ")", "@Cache", "(", "smaxage", "=", "10", ")", "@Security", "(", "is_granted", "(", "IS_AUTHENTICATED_REMEMBERED", ")", ")" ]
train
https://github.com/video-games-records/TeamBundle/blob/4e5b73874bacb96f70ab16e74d54a1b6efc8e62f/Controller/TeamController.php#L105-L139
video-games-records/TeamBundle
Controller/TeamController.php
TeamController.createAction
public function createAction(Request $request) { //----- breadcrumbs $breadcrumbs = $this->get('white_october_breadcrumbs'); $breadcrumbs->addRouteItem('Home', 'homepage'); $breadcrumbs->addRouteItem('Account', 'vgr_account_index'); $breadcrumbs->addItem('Create team'); /** @var \VideoGamesRecords\CoreBundle\Entity\Player $player */ $player = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Player')->find($this->getPlayer()->getIdPlayer()); $team = new Team(); $form = $this->createForm(TeamForm::class, $team); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $team->setIdLeader($player->getIdPlayer()); $em = $this->getDoctrine()->getManager(); $em->persist($team); $em->flush(); $player->setTeam($team); $em->flush(); //----- Message $this->addFlash( 'notice', sprintf('Your changes were saved!!!') ); return $this->redirectToRoute('vgr_account_index'); } return $this->render( 'VideoGamesRecordsTeamBundle:Team:create.html.twig', [ 'form' => $form->createView(), ] ); }
php
public function createAction(Request $request) { //----- breadcrumbs $breadcrumbs = $this->get('white_october_breadcrumbs'); $breadcrumbs->addRouteItem('Home', 'homepage'); $breadcrumbs->addRouteItem('Account', 'vgr_account_index'); $breadcrumbs->addItem('Create team'); /** @var \VideoGamesRecords\CoreBundle\Entity\Player $player */ $player = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Player')->find($this->getPlayer()->getIdPlayer()); $team = new Team(); $form = $this->createForm(TeamForm::class, $team); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $team->setIdLeader($player->getIdPlayer()); $em = $this->getDoctrine()->getManager(); $em->persist($team); $em->flush(); $player->setTeam($team); $em->flush(); //----- Message $this->addFlash( 'notice', sprintf('Your changes were saved!!!') ); return $this->redirectToRoute('vgr_account_index'); } return $this->render( 'VideoGamesRecordsTeamBundle:Team:create.html.twig', [ 'form' => $form->createView(), ] ); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "//----- breadcrumbs", "$", "breadcrumbs", "=", "$", "this", "->", "get", "(", "'white_october_breadcrumbs'", ")", ";", "$", "breadcrumbs", "->", "addRouteItem", "(", "'Home'", ",", ...
@Route("/create", name="vgr_team_create") @Method({"GET","POST"}) @Cache(smaxage="10") @Security("is_granted('IS_AUTHENTICATED_REMEMBERED')") @param Request $request @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response @throws \Exception
[ "@Route", "(", "/", "create", "name", "=", "vgr_team_create", ")", "@Method", "(", "{", "GET", "POST", "}", ")", "@Cache", "(", "smaxage", "=", "10", ")", "@Security", "(", "is_granted", "(", "IS_AUTHENTICATED_REMEMBERED", ")", ")" ]
train
https://github.com/video-games-records/TeamBundle/blob/4e5b73874bacb96f70ab16e74d54a1b6efc8e62f/Controller/TeamController.php#L153-L194
video-games-records/TeamBundle
Controller/TeamController.php
TeamController.changeLeaderAction
public function changeLeaderAction(Request $request) { $breadcrumbs = $this->get('white_october_breadcrumbs'); $breadcrumbs->addRouteItem('Home', 'homepage'); $breadcrumbs->addRouteItem('Account', 'vgr_account_index'); $breadcrumbs->addItem('Change leader'); /** @var \VideoGamesRecords\CoreBundle\Entity\Player $player */ $player = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Player')->find($this->getPlayer()->getIdPlayer()); $players = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Player')->getPlayersFromTeam($player->getTeam()->getIdTeam()); $choices = array(); /** @var \VideoGamesRecords\CoreBundle\Entity\Player $row */ foreach ($players as $row) { if ($this->getPlayer()->getIdPlayer() != $row->getIdPlayer()) { $choices[$row->getPseudo()] = $row->getIdPlayer(); } } $form = $this->createForm(ChangeLeaderForm::class, null, array('players' => $choices)); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $data = $form->getData(); $team = $player->getTeam(); $team->setIdLeader($data['idPlayer']); $em = $this->getDoctrine()->getManager(); $em->flush(); //----- Message $this->addFlash( 'notice', sprintf('Your changes were saved!!!') ); return $this->redirectToRoute('vgr_account_index'); } return $this->render( 'VideoGamesRecordsTeamBundle:Team:change-leader.html.twig', [ 'form' => $form->createView(), 'nbChoices' => count($choices) ] ); }
php
public function changeLeaderAction(Request $request) { $breadcrumbs = $this->get('white_october_breadcrumbs'); $breadcrumbs->addRouteItem('Home', 'homepage'); $breadcrumbs->addRouteItem('Account', 'vgr_account_index'); $breadcrumbs->addItem('Change leader'); /** @var \VideoGamesRecords\CoreBundle\Entity\Player $player */ $player = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Player')->find($this->getPlayer()->getIdPlayer()); $players = $this->getDoctrine()->getRepository('VideoGamesRecordsCoreBundle:Player')->getPlayersFromTeam($player->getTeam()->getIdTeam()); $choices = array(); /** @var \VideoGamesRecords\CoreBundle\Entity\Player $row */ foreach ($players as $row) { if ($this->getPlayer()->getIdPlayer() != $row->getIdPlayer()) { $choices[$row->getPseudo()] = $row->getIdPlayer(); } } $form = $this->createForm(ChangeLeaderForm::class, null, array('players' => $choices)); $form->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { $data = $form->getData(); $team = $player->getTeam(); $team->setIdLeader($data['idPlayer']); $em = $this->getDoctrine()->getManager(); $em->flush(); //----- Message $this->addFlash( 'notice', sprintf('Your changes were saved!!!') ); return $this->redirectToRoute('vgr_account_index'); } return $this->render( 'VideoGamesRecordsTeamBundle:Team:change-leader.html.twig', [ 'form' => $form->createView(), 'nbChoices' => count($choices) ] ); }
[ "public", "function", "changeLeaderAction", "(", "Request", "$", "request", ")", "{", "$", "breadcrumbs", "=", "$", "this", "->", "get", "(", "'white_october_breadcrumbs'", ")", ";", "$", "breadcrumbs", "->", "addRouteItem", "(", "'Home'", ",", "'homepage'", "...
@Route("/change-leader", name="vgr_team_change_leader") @Method({"GET","POST"}) @Cache(smaxage="10") @Security("is_granted('IS_AUTHENTICATED_REMEMBERED')") @param Request $request @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response @throws \Exception
[ "@Route", "(", "/", "change", "-", "leader", "name", "=", "vgr_team_change_leader", ")", "@Method", "(", "{", "GET", "POST", "}", ")", "@Cache", "(", "smaxage", "=", "10", ")", "@Security", "(", "is_granted", "(", "IS_AUTHENTICATED_REMEMBERED", ")", ")" ]
train
https://github.com/video-games-records/TeamBundle/blob/4e5b73874bacb96f70ab16e74d54a1b6efc8e62f/Controller/TeamController.php#L256-L303
technote-space/wordpress-plugin-base
src/classes/models/lib/config.php
Config.load
public function load( $name ) { if ( ! isset( $this->_configs[ $name ] ) ) { $plugin_config = $this->load_config_file( $this->app->define->plugin_configs_dir, $name ); $lib_config = $this->load_config_file( $this->app->define->lib_configs_dir, $name ); $this->_configs[ $name ] = array_replace_recursive( $lib_config, $plugin_config ); } return $this->_configs[ $name ]; }
php
public function load( $name ) { if ( ! isset( $this->_configs[ $name ] ) ) { $plugin_config = $this->load_config_file( $this->app->define->plugin_configs_dir, $name ); $lib_config = $this->load_config_file( $this->app->define->lib_configs_dir, $name ); $this->_configs[ $name ] = array_replace_recursive( $lib_config, $plugin_config ); } return $this->_configs[ $name ]; }
[ "public", "function", "load", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_configs", "[", "$", "name", "]", ")", ")", "{", "$", "plugin_config", "=", "$", "this", "->", "load_config_file", "(", "$", "this", "->", ...
@param string $name @return array
[ "@param", "string", "$name" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/config.php#L40-L48
technote-space/wordpress-plugin-base
src/classes/models/lib/config.php
Config.get
public function get( $name, $key, $default = null ) { return $this->app->utility->array_get( $this->load( $name ), $key, $default ); }
php
public function get( $name, $key, $default = null ) { return $this->app->utility->array_get( $this->load( $name ), $key, $default ); }
[ "public", "function", "get", "(", "$", "name", ",", "$", "key", ",", "$", "default", "=", "null", ")", "{", "return", "$", "this", "->", "app", "->", "utility", "->", "array_get", "(", "$", "this", "->", "load", "(", "$", "name", ")", ",", "$", ...
@param string $name @param string $key @param mixed $default @return mixed
[ "@param", "string", "$name", "@param", "string", "$key", "@param", "mixed", "$default" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/config.php#L57-L59
technote-space/wordpress-plugin-base
src/classes/models/lib/config.php
Config.load_config_file
private function load_config_file( $dir, $name ) { $path = rtrim( $dir, DS ) . DS . $name . '.php'; if ( ! file_exists( $path ) ) { return []; } /** @noinspection PhpIncludeInspection */ $config = include $path; if ( ! is_array( $config ) ) { $config = []; } return $config; }
php
private function load_config_file( $dir, $name ) { $path = rtrim( $dir, DS ) . DS . $name . '.php'; if ( ! file_exists( $path ) ) { return []; } /** @noinspection PhpIncludeInspection */ $config = include $path; if ( ! is_array( $config ) ) { $config = []; } return $config; }
[ "private", "function", "load_config_file", "(", "$", "dir", ",", "$", "name", ")", "{", "$", "path", "=", "rtrim", "(", "$", "dir", ",", "DS", ")", ".", "DS", ".", "$", "name", ".", "'.php'", ";", "if", "(", "!", "file_exists", "(", "$", "path", ...
@param string $dir @param string $name @return array|mixed
[ "@param", "string", "$dir", "@param", "string", "$name" ]
train
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/config.php#L77-L89
gpupo/common-schema
src/ORM/Entity/Banking/Report/Record.php
Record.setReport
public function setReport(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Report $report = null) { $this->report = $report; return $this; }
php
public function setReport(\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Report $report = null) { $this->report = $report; return $this; }
[ "public", "function", "setReport", "(", "\\", "Gpupo", "\\", "CommonSchema", "\\", "ORM", "\\", "Entity", "\\", "Banking", "\\", "Report", "\\", "Report", "$", "report", "=", "null", ")", "{", "$", "this", "->", "report", "=", "$", "report", ";", "retu...
Set report. @param null|\Gpupo\CommonSchema\ORM\Entity\Banking\Report\Report $report @return Record
[ "Set", "report", "." ]
train
https://github.com/gpupo/common-schema/blob/a762d2eb3063b7317c72c69cbb463b1f95b86b0a/src/ORM/Entity/Banking/Report/Record.php#L615-L620
oroinc/OroLayoutComponent
ContextDataCollection.php
ContextDataCollection.get
public function get($name) { if (!isset($this->items[$name]) && !array_key_exists($name, $this->items) && !$this->applyDefaultValue($name) ) { throw new \OutOfBoundsException(sprintf('Undefined data item index: %s.', $name)); }; return $this->items[$name]; }
php
public function get($name) { if (!isset($this->items[$name]) && !array_key_exists($name, $this->items) && !$this->applyDefaultValue($name) ) { throw new \OutOfBoundsException(sprintf('Undefined data item index: %s.', $name)); }; return $this->items[$name]; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "items", "[", "$", "name", "]", ")", "&&", "!", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "items", ")", "&&", "!", "$"...
Gets a value stored in the context data variable. @param string $name The data item name @return mixed @throws \OutOfBoundsException if the data item does not exist
[ "Gets", "a", "value", "stored", "in", "the", "context", "data", "variable", "." ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ContextDataCollection.php#L48-L58
oroinc/OroLayoutComponent
ContextDataCollection.php
ContextDataCollection.applyDefaultValue
protected function applyDefaultValue($name) { if (!isset($this->defaults[$name])) { return false; } $value = $this->defaults[$name]; if (is_callable($value)) { try { $this->items[$name] = call_user_func($value, $this->context); } catch (\BadMethodCallException $e) { return false; } } else { $this->items[$name] = $value; } return true; }
php
protected function applyDefaultValue($name) { if (!isset($this->defaults[$name])) { return false; } $value = $this->defaults[$name]; if (is_callable($value)) { try { $this->items[$name] = call_user_func($value, $this->context); } catch (\BadMethodCallException $e) { return false; } } else { $this->items[$name] = $value; } return true; }
[ "protected", "function", "applyDefaultValue", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "defaults", "[", "$", "name", "]", ")", ")", "{", "return", "false", ";", "}", "$", "value", "=", "$", "this", "->", "default...
@param string $name The data item name @return bool true if the default value has been applied; otherwise, false
[ "@param", "string", "$name", "The", "data", "item", "name" ]
train
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/ContextDataCollection.php#L111-L129
webdevvie/pheanstalk-task-queue-bundle
Command/AbstractWorker.php
AbstractWorker.logException
protected function logException(\Exception $exception) { $this->logger->error( $exception->getMessage(), array( 'class'=>get_class($exception), 'message'=>$exception->getMessage(), 'file'=>$exception->getMessage(), 'line'=>$exception->getMessage(), 'command'=>$this->getName() ) ); }
php
protected function logException(\Exception $exception) { $this->logger->error( $exception->getMessage(), array( 'class'=>get_class($exception), 'message'=>$exception->getMessage(), 'file'=>$exception->getMessage(), 'line'=>$exception->getMessage(), 'command'=>$this->getName() ) ); }
[ "protected", "function", "logException", "(", "\\", "Exception", "$", "exception", ")", "{", "$", "this", "->", "logger", "->", "error", "(", "$", "exception", "->", "getMessage", "(", ")", ",", "array", "(", "'class'", "=>", "get_class", "(", "$", "exce...
Logs an exception to the logger @param \Exception $exception @return void
[ "Logs", "an", "exception", "to", "the", "logger" ]
train
https://github.com/webdevvie/pheanstalk-task-queue-bundle/blob/db5e63a8f844e345dc2e69ce8e94b32d851020eb/Command/AbstractWorker.php#L133-L145
surebert/surebert-framework
src/sb/Validate/ContactInfo.php
ContactInfo.email
public static function email($email, $check_mx_records = true) { $result = new \sb\Validate\Results(); $result->value = $email; if (filter_var($email, \FILTER_VALIDATE_EMAIL)) { list($name, $domain) = explode('@', $email); if (!checkdnsrr($domain, 'MX')) { $result->is_valid = false; $result->message = 'Invalid domain name or mail server down for this address'; } else { $result->message = 'Valid format and domain checked'; $result->is_valid = true; } } else { $result->is_valid = false; $result->message = 'Invalid format'; } return $result; }
php
public static function email($email, $check_mx_records = true) { $result = new \sb\Validate\Results(); $result->value = $email; if (filter_var($email, \FILTER_VALIDATE_EMAIL)) { list($name, $domain) = explode('@', $email); if (!checkdnsrr($domain, 'MX')) { $result->is_valid = false; $result->message = 'Invalid domain name or mail server down for this address'; } else { $result->message = 'Valid format and domain checked'; $result->is_valid = true; } } else { $result->is_valid = false; $result->message = 'Invalid format'; } return $result; }
[ "public", "static", "function", "email", "(", "$", "email", ",", "$", "check_mx_records", "=", "true", ")", "{", "$", "result", "=", "new", "\\", "sb", "\\", "Validate", "\\", "Results", "(", ")", ";", "$", "result", "->", "value", "=", "$", "email",...
Validates an email address format and checks DNS record. Does not include the whole spec for vlid emails, only accepts one @ symbol, letters, numbers, and . _ - + ! as special characters @author paul.visco@roswellpark.org @version 1.2 13/18/2008 @param string $email @param string $check_mx_records Check the MX record at the dns to make sure the mail host exists @return \sb\Validate_Results
[ "Validates", "an", "email", "address", "format", "and", "checks", "DNS", "record", ".", "Does", "not", "include", "the", "whole", "spec", "for", "vlid", "emails", "only", "accepts", "one", "@", "symbol", "letters", "numbers", "and", ".", "_", "-", "+", "...
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Validate/ContactInfo.php#L100-L121
surebert/surebert-framework
src/sb/Validate/ContactInfo.php
ContactInfo.zip
public static function zip($zip, $check_usps = true) { $result = new \sb\Validate\Results(); $result->value = $zip; $result->is_valid = false; if (preg_match("/^(\d{5})(-\d{4})*$/", $zip)) { $result->message = "Valid zip code format"; $result->is_valid = true; if ($check_usps) { $page = @file_get_contents("https://tools.usps.com/go/ZipLookupResultsAction!input.action?resultMode=2&postalCode=" . substr($zip, 0, 5)); if (!$page) { $result->message .= ' cannot reach USPS site to validate zip code existence'; } else { preg_match("~<p class=\"std-address\">(.*?)</p>~", $page, $city); if (isset($city[1])) { $data = trim($city[1]); $result->state = substr($data, -2, 2); $result->city = ucwords(strtolower(preg_replace("~" . $result->state . "$~", "", $data))); $result->message .= " for " . $result->city . ',' . $result->state; } else { $result->message .= " but city not found!"; $result->is_valid = false; } } } } else { $result->message = "Invalid zip code format "; } return $result; }
php
public static function zip($zip, $check_usps = true) { $result = new \sb\Validate\Results(); $result->value = $zip; $result->is_valid = false; if (preg_match("/^(\d{5})(-\d{4})*$/", $zip)) { $result->message = "Valid zip code format"; $result->is_valid = true; if ($check_usps) { $page = @file_get_contents("https://tools.usps.com/go/ZipLookupResultsAction!input.action?resultMode=2&postalCode=" . substr($zip, 0, 5)); if (!$page) { $result->message .= ' cannot reach USPS site to validate zip code existence'; } else { preg_match("~<p class=\"std-address\">(.*?)</p>~", $page, $city); if (isset($city[1])) { $data = trim($city[1]); $result->state = substr($data, -2, 2); $result->city = ucwords(strtolower(preg_replace("~" . $result->state . "$~", "", $data))); $result->message .= " for " . $result->city . ',' . $result->state; } else { $result->message .= " but city not found!"; $result->is_valid = false; } } } } else { $result->message = "Invalid zip code format "; } return $result; }
[ "public", "static", "function", "zip", "(", "$", "zip", ",", "$", "check_usps", "=", "true", ")", "{", "$", "result", "=", "new", "\\", "sb", "\\", "Validate", "\\", "Results", "(", ")", ";", "$", "result", "->", "value", "=", "$", "zip", ";", "$...
Validates a zip code @author paul.visco@roswellpark.org @version 1.2 13/18/2008 @param string $zip The zip code to validate in xxxxx or xxxxx-xxxx format @param boolean check_usps Check the usps sie look for validation @return \sb\Validate_Results The message property includes the city if it exists
[ "Validates", "a", "zip", "code" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Validate/ContactInfo.php#L133-L169
surebert/surebert-framework
src/sb/Validate/ContactInfo.php
ContactInfo.phone
public static function phone($phone) { $result = new \sb\Validate\Results(); $result->value = $phone; $result->is_valid = false; if (preg_match("/^\d{3}-\d{3}-\d{4}$/", $phone)) { $result->message = "Valid phone number"; $result->is_valid = true; } else { $result->message = "Invalid phone number"; } return $result; }
php
public static function phone($phone) { $result = new \sb\Validate\Results(); $result->value = $phone; $result->is_valid = false; if (preg_match("/^\d{3}-\d{3}-\d{4}$/", $phone)) { $result->message = "Valid phone number"; $result->is_valid = true; } else { $result->message = "Invalid phone number"; } return $result; }
[ "public", "static", "function", "phone", "(", "$", "phone", ")", "{", "$", "result", "=", "new", "\\", "sb", "\\", "Validate", "\\", "Results", "(", ")", ";", "$", "result", "->", "value", "=", "$", "phone", ";", "$", "result", "->", "is_valid", "=...
Validates a phone number. Without a modem we can only validate format ;( @author paul.visco@roswellpark.org @version 1.2 13/18/2008 @param string $phone The phone number to validate shoudl be in xxx-xxx-xxxx format @return \sb\Validate_Results
[ "Validates", "a", "phone", "number", ".", "Without", "a", "modem", "we", "can", "only", "validate", "format", ";", "(", "@author", "paul", ".", "visco@roswellpark", ".", "org", "@version", "1", ".", "2", "13", "/", "18", "/", "2008", "@param", "string", ...
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Validate/ContactInfo.php#L179-L193
surebert/surebert-framework
src/sb/Validate/ContactInfo.php
ContactInfo.url
public static function url($url, $check_url = true) { $result = new \sb\Validate\Results(); $result->value = $url; $result->is_valid = false; $result->data = new stdClass(); // /(\s|\n)([a-z]+?):\/\/([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)/i if (preg_match("/^http:\/\/([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)$/i", $url)) { $result->message = "Valid url format"; $result->is_valid = true; if ($check_url) { $page = @file_get_contents($url); if (!$page) { $result->is_valid = false; $result->message .= ' but page not loaded'; $result->data->header = $http_response_header[0]; } else { if (!preg_match("/<html/", $page)) { $result->is_valid = false; $result->message .= " page reachable but no html tag found"; } else { $result->message .= " and page loaded"; } } } } else { $result->message = "Invalid url format"; } return $result; }
php
public static function url($url, $check_url = true) { $result = new \sb\Validate\Results(); $result->value = $url; $result->is_valid = false; $result->data = new stdClass(); // /(\s|\n)([a-z]+?):\/\/([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)/i if (preg_match("/^http:\/\/([a-z0-9\-\.,\?!%\*_\#:;~\\&$@\/=\+]+)$/i", $url)) { $result->message = "Valid url format"; $result->is_valid = true; if ($check_url) { $page = @file_get_contents($url); if (!$page) { $result->is_valid = false; $result->message .= ' but page not loaded'; $result->data->header = $http_response_header[0]; } else { if (!preg_match("/<html/", $page)) { $result->is_valid = false; $result->message .= " page reachable but no html tag found"; } else { $result->message .= " and page loaded"; } } } } else { $result->message = "Invalid url format"; } return $result; }
[ "public", "static", "function", "url", "(", "$", "url", ",", "$", "check_url", "=", "true", ")", "{", "$", "result", "=", "new", "\\", "sb", "\\", "Validate", "\\", "Results", "(", ")", ";", "$", "result", "->", "value", "=", "$", "url", ";", "$"...
Validates a url. Also checks to make sure the page is reachable and has HTML Tag @author paul.visco@roswellpark.org @version 1.2 13/18/2008 @param string $url The url to validate should @return \sb\Validate_Results
[ "Validates", "a", "url", ".", "Also", "checks", "to", "make", "sure", "the", "page", "is", "reachable", "and", "has", "HTML", "Tag", "@author", "paul", ".", "visco@roswellpark", ".", "org", "@version", "1", ".", "2", "13", "/", "18", "/", "2008" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Validate/ContactInfo.php#L204-L240
surebert/surebert-framework
src/sb/Validate/ContactInfo.php
ContactInfo.state
public static function state($state) { $result = new \sb\Validate\Results(); $result->value = $state; if (in_array($state, self::states)) { $result->is_valid = true; $result->message = 'Valid state code'; } else { $result->is_valid = false; $result->message = 'Invalid state code, are you sure you are using a two letter abbreviation'; } return $result; }
php
public static function state($state) { $result = new \sb\Validate\Results(); $result->value = $state; if (in_array($state, self::states)) { $result->is_valid = true; $result->message = 'Valid state code'; } else { $result->is_valid = false; $result->message = 'Invalid state code, are you sure you are using a two letter abbreviation'; } return $result; }
[ "public", "static", "function", "state", "(", "$", "state", ")", "{", "$", "result", "=", "new", "\\", "sb", "\\", "Validate", "\\", "Results", "(", ")", ";", "$", "result", "->", "value", "=", "$", "state", ";", "if", "(", "in_array", "(", "$", ...
Validates state two character abbr @author paul.visco@roswellpark.org @version 1.2 13/18/2008 @param string $state @return \sb\Validate_Results
[ "Validates", "state", "two", "character", "abbr", "@author", "paul", ".", "visco@roswellpark", ".", "org", "@version", "1", ".", "2", "13", "/", "18", "/", "2008" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Validate/ContactInfo.php#L250-L266
surebert/surebert-framework
src/sb/Validate/ContactInfo.php
ContactInfo.province
public static function province($province) { $result = new \sb\Validate\Results(); $result->value = $province; if (in_array($province, self::provinces)) { $result->is_valid = true; $result->message = 'Valid province code'; } else { $result->is_valid = false; $result->message = 'Invalid province code, are you sure you are using a two letter abbreviation'; } return $result; }
php
public static function province($province) { $result = new \sb\Validate\Results(); $result->value = $province; if (in_array($province, self::provinces)) { $result->is_valid = true; $result->message = 'Valid province code'; } else { $result->is_valid = false; $result->message = 'Invalid province code, are you sure you are using a two letter abbreviation'; } return $result; }
[ "public", "static", "function", "province", "(", "$", "province", ")", "{", "$", "result", "=", "new", "\\", "sb", "\\", "Validate", "\\", "Results", "(", ")", ";", "$", "result", "->", "value", "=", "$", "province", ";", "if", "(", "in_array", "(", ...
Validates canadian province two character abbr @author paul.visco@roswellpark.org @version 1.2 13/18/2008 @param string $province @return \sb\Validate_Results
[ "Validates", "canadian", "province", "two", "character", "abbr", "@author", "paul", ".", "visco@roswellpark", ".", "org", "@version", "1", ".", "2", "13", "/", "18", "/", "2008" ]
train
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Validate/ContactInfo.php#L276-L292
thecodingmachine/mvc.splash-common
src/Mouf/Mvc/Splash/HtmlResponse.php
HtmlResponse.getBody
public function getBody() { if ($this->stream === null) { ob_start(); $this->htmlElement->toHtml(); $content = ob_get_clean(); $this->stream = new Stream('php://memory', 'wb+'); $this->stream->write($content); } return $this->stream; }
php
public function getBody() { if ($this->stream === null) { ob_start(); $this->htmlElement->toHtml(); $content = ob_get_clean(); $this->stream = new Stream('php://memory', 'wb+'); $this->stream->write($content); } return $this->stream; }
[ "public", "function", "getBody", "(", ")", "{", "if", "(", "$", "this", "->", "stream", "===", "null", ")", "{", "ob_start", "(", ")", ";", "$", "this", "->", "htmlElement", "->", "toHtml", "(", ")", ";", "$", "content", "=", "ob_get_clean", "(", "...
Gets the body of the message. @return StreamInterface Returns the body as a stream.
[ "Gets", "the", "body", "of", "the", "message", "." ]
train
https://github.com/thecodingmachine/mvc.splash-common/blob/eed0269ceda4d7d090a330a220490906a7aa60bd/src/Mouf/Mvc/Splash/HtmlResponse.php#L74-L85
GrupaZero/api
src/Gzero/Api/Controller/Admin/FileTranslationController.php
FileTranslationController.index
public function index($id) { $this->authorize('readList', File::class); $input = $this->validator->validate('list'); $params = $this->processor->process($input)->getProcessedFields(); $file = $this->repository->getById($id); if (!empty($file)) { $results = $this->repository->getTranslations( $file, $params['filter'], $params['orderBy'], $params['page'], $params['perPage'] ); return $this->respondWithSuccess($results, new FileTranslationTransformer); } else { return $this->respondNotFound(); } }
php
public function index($id) { $this->authorize('readList', File::class); $input = $this->validator->validate('list'); $params = $this->processor->process($input)->getProcessedFields(); $file = $this->repository->getById($id); if (!empty($file)) { $results = $this->repository->getTranslations( $file, $params['filter'], $params['orderBy'], $params['page'], $params['perPage'] ); return $this->respondWithSuccess($results, new FileTranslationTransformer); } else { return $this->respondNotFound(); } }
[ "public", "function", "index", "(", "$", "id", ")", "{", "$", "this", "->", "authorize", "(", "'readList'", ",", "File", "::", "class", ")", ";", "$", "input", "=", "$", "this", "->", "validator", "->", "validate", "(", "'list'", ")", ";", "$", "pa...
Display a listing of the resource. @param int|null $id Id used for nested resources @return \Illuminate\Http\JsonResponse
[ "Display", "a", "listing", "of", "the", "resource", "." ]
train
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/FileTranslationController.php#L61-L79
GrupaZero/api
src/Gzero/Api/Controller/Admin/FileTranslationController.php
FileTranslationController.show
public function show($id, $translationId) { $file = $this->getFile($id); if (!empty($file)) { $this->authorize('read', $file); $translation = $this->repository->getFileTranslationById($file, $translationId); if (!empty($translation)) { return $this->respondWithSuccess($translation, new FileTranslationTransformer); } } return $this->respondNotFound(); }
php
public function show($id, $translationId) { $file = $this->getFile($id); if (!empty($file)) { $this->authorize('read', $file); $translation = $this->repository->getFileTranslationById($file, $translationId); if (!empty($translation)) { return $this->respondWithSuccess($translation, new FileTranslationTransformer); } } return $this->respondNotFound(); }
[ "public", "function", "show", "(", "$", "id", ",", "$", "translationId", ")", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", "$", "id", ")", ";", "if", "(", "!", "empty", "(", "$", "file", ")", ")", "{", "$", "this", "->", "authorize...
Display a specified resource. @param int $id Id of the file @param int $translationId Id of the file translation @return \Illuminate\Http\JsonResponse
[ "Display", "a", "specified", "resource", "." ]
train
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/FileTranslationController.php#L89-L100
GrupaZero/api
src/Gzero/Api/Controller/Admin/FileTranslationController.php
FileTranslationController.store
public function store($id) { $file = $this->getFile($id); if (!empty($file)) { $this->authorize('create', $file); $this->authorize('update', $file); $input = $this->validator->validate('create'); $translation = $this->repository->createTranslation($file, $input); return $this->respondWithSuccess($translation, new FileTranslationTransformer); } return $this->respondNotFound(); }
php
public function store($id) { $file = $this->getFile($id); if (!empty($file)) { $this->authorize('create', $file); $this->authorize('update', $file); $input = $this->validator->validate('create'); $translation = $this->repository->createTranslation($file, $input); return $this->respondWithSuccess($translation, new FileTranslationTransformer); } return $this->respondNotFound(); }
[ "public", "function", "store", "(", "$", "id", ")", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", "$", "id", ")", ";", "if", "(", "!", "empty", "(", "$", "file", ")", ")", "{", "$", "this", "->", "authorize", "(", "'create'", ",", ...
Stores newly created translation for specified file entity in database. @param int $id Id of the file @return \Illuminate\Http\JsonResponse
[ "Stores", "newly", "created", "translation", "for", "specified", "file", "entity", "in", "database", "." ]
train
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/FileTranslationController.php#L109-L120
GrupaZero/api
src/Gzero/Api/Controller/Admin/FileTranslationController.php
FileTranslationController.destroy
public function destroy($id, $translationId) { $file = $this->getFile($id); if (!empty($file)) { $this->authorize('delete', $file); $translation = $this->repository->getTranslationById($file, $translationId); if (!empty($translation)) { $this->repository->deleteTranslation($translation); return $this->respondWithSimpleSuccess(['success' => true]); } } return $this->respondNotFound(); }
php
public function destroy($id, $translationId) { $file = $this->getFile($id); if (!empty($file)) { $this->authorize('delete', $file); $translation = $this->repository->getTranslationById($file, $translationId); if (!empty($translation)) { $this->repository->deleteTranslation($translation); return $this->respondWithSimpleSuccess(['success' => true]); } } return $this->respondNotFound(); }
[ "public", "function", "destroy", "(", "$", "id", ",", "$", "translationId", ")", "{", "$", "file", "=", "$", "this", "->", "getFile", "(", "$", "id", ")", ";", "if", "(", "!", "empty", "(", "$", "file", ")", ")", "{", "$", "this", "->", "author...
Remove the specified resource from database. @param int $id Id of the file @param int $translationId Id of the file translation @return \Illuminate\Http\JsonResponse
[ "Remove", "the", "specified", "resource", "from", "database", "." ]
train
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/FileTranslationController.php#L142-L154
mikebarlow/html-helper
src/Services/Basic/Data.php
Data.getValue
public function getValue($name) { if (! is_string($name)) { return null; } $bits = explode('.', $name); $postData = $_POST; foreach ($bits as $key) { if (is_array($postData) && isset($postData[$key])) { $postData = $postData[$key]; } else { return null; } } return $postData; }
php
public function getValue($name) { if (! is_string($name)) { return null; } $bits = explode('.', $name); $postData = $_POST; foreach ($bits as $key) { if (is_array($postData) && isset($postData[$key])) { $postData = $postData[$key]; } else { return null; } } return $postData; }
[ "public", "function", "getValue", "(", "$", "name", ")", "{", "if", "(", "!", "is_string", "(", "$", "name", ")", ")", "{", "return", "null", ";", "}", "$", "bits", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "postData", "=", "...
get the post data to prefill the inputs @param string dot notation format of the input name we're looking for @return mixed|null Return value from post data or null if not found
[ "get", "the", "post", "data", "to", "prefill", "the", "inputs" ]
train
https://github.com/mikebarlow/html-helper/blob/d9d9dc3e92ba3ecd75f3a2e5a5bc2d23f38b5f65/src/Services/Basic/Data.php#L13-L31
PayBreak/foundation
src/Decision/Risk.php
Risk.setRisk
public function setRisk($risk) { if (!is_numeric($risk)) { throw new \InvalidArgumentException('Risk must be numeric.'); } $this->__call('setRisk', [self::normalize($risk)]); return $this; }
php
public function setRisk($risk) { if (!is_numeric($risk)) { throw new \InvalidArgumentException('Risk must be numeric.'); } $this->__call('setRisk', [self::normalize($risk)]); return $this; }
[ "public", "function", "setRisk", "(", "$", "risk", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "risk", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Risk must be numeric.'", ")", ";", "}", "$", "this", "->", "__call", "(",...
Set Risk @author WN @param float $risk <0,1> @return $this
[ "Set", "Risk" ]
train
https://github.com/PayBreak/foundation/blob/3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4/src/Decision/Risk.php#L48-L56
PayBreak/foundation
src/Decision/Risk.php
Risk.normalize
public static function normalize($risk) { return (float) max(min($risk, self::MAXIMUM_RISK), self::MINIMUM_RISK); }
php
public static function normalize($risk) { return (float) max(min($risk, self::MAXIMUM_RISK), self::MINIMUM_RISK); }
[ "public", "static", "function", "normalize", "(", "$", "risk", ")", "{", "return", "(", "float", ")", "max", "(", "min", "(", "$", "risk", ",", "self", "::", "MAXIMUM_RISK", ")", ",", "self", "::", "MINIMUM_RISK", ")", ";", "}" ]
Normalize Risk - make sure that risk will be in bound @author WN @param $risk @return float <0,1>
[ "Normalize", "Risk", "-", "make", "sure", "that", "risk", "will", "be", "in", "bound" ]
train
https://github.com/PayBreak/foundation/blob/3dc5a5791e0c95abefa2a415a7f9fdb5abb62ca4/src/Decision/Risk.php#L65-L68
GreenCape/joomla-cli
src/GreenCape/JoomlaCLI/Driver/Abstract.php
JoomlaDriver.setupEnvironment
public function setupEnvironment($basePath, $application = 'site') { if ($application != 'site') { $basePath .= '/' . $application; } $server = array( 'HTTP_HOST' => 'undefined', 'HTTP_USER_AGENT' => 'undefined', 'REQUEST_METHOD' => 'GET', ); $_SERVER = array_merge($_SERVER, $server); if (file_exists($basePath . '/defines.php')) { include_once $basePath . '/defines.php'; } if (!defined('_JDEFINES')) { define('JPATH_BASE', $basePath); require_once JPATH_BASE . '/includes/defines.php'; } require_once JPATH_BASE . '/includes/framework.php'; if ($application == 'administrator') { require_once JPATH_BASE.'/includes/helper.php'; require_once JPATH_BASE.'/includes/toolbar.php'; // JUri uses $_SERVER['HTTP_HOST'] without check $_SERVER['HTTP_HOST'] = 'CLI'; } $app = \JFactory::getApplication($application); $app->initialise(); }
php
public function setupEnvironment($basePath, $application = 'site') { if ($application != 'site') { $basePath .= '/' . $application; } $server = array( 'HTTP_HOST' => 'undefined', 'HTTP_USER_AGENT' => 'undefined', 'REQUEST_METHOD' => 'GET', ); $_SERVER = array_merge($_SERVER, $server); if (file_exists($basePath . '/defines.php')) { include_once $basePath . '/defines.php'; } if (!defined('_JDEFINES')) { define('JPATH_BASE', $basePath); require_once JPATH_BASE . '/includes/defines.php'; } require_once JPATH_BASE . '/includes/framework.php'; if ($application == 'administrator') { require_once JPATH_BASE.'/includes/helper.php'; require_once JPATH_BASE.'/includes/toolbar.php'; // JUri uses $_SERVER['HTTP_HOST'] without check $_SERVER['HTTP_HOST'] = 'CLI'; } $app = \JFactory::getApplication($application); $app->initialise(); }
[ "public", "function", "setupEnvironment", "(", "$", "basePath", ",", "$", "application", "=", "'site'", ")", "{", "if", "(", "$", "application", "!=", "'site'", ")", "{", "$", "basePath", ".=", "'/'", ".", "$", "application", ";", "}", "$", "server", "...
Setup the environment @param string $basePath The root of the Joomla! application @param string $application The application, eg., 'site' or 'administration' @return void
[ "Setup", "the", "environment" ]
train
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Driver/Abstract.php#L51-L89
GreenCape/joomla-cli
src/GreenCape/JoomlaCLI/Driver/Abstract.php
JoomlaDriver.getExtensionInfo
public function getExtensionInfo($manifest) { $data = array(); $data['type'] = (string)$manifest['type']; $data['extension'] = (string)$manifest->name; $data['name'] = \JText::_($manifest->name); $data['version'] = (string)$manifest->version; $data['description'] = \JText::_($manifest->description); return $data; }
php
public function getExtensionInfo($manifest) { $data = array(); $data['type'] = (string)$manifest['type']; $data['extension'] = (string)$manifest->name; $data['name'] = \JText::_($manifest->name); $data['version'] = (string)$manifest->version; $data['description'] = \JText::_($manifest->description); return $data; }
[ "public", "function", "getExtensionInfo", "(", "$", "manifest", ")", "{", "$", "data", "=", "array", "(", ")", ";", "$", "data", "[", "'type'", "]", "=", "(", "string", ")", "$", "manifest", "[", "'type'", "]", ";", "$", "data", "[", "'extension'", ...
@param $manifest @return array
[ "@param", "$manifest" ]
train
https://github.com/GreenCape/joomla-cli/blob/74a6940f27b1f66c99330d4f9e2c5ac314cdd369/src/GreenCape/JoomlaCLI/Driver/Abstract.php#L115-L125
mothership-ec/composer
src/Composer/Downloader/GitDownloader.php
GitDownloader.doDownload
public function doDownload(PackageInterface $package, $path, $url) { GitUtil::cleanEnv(); $path = $this->normalizePath($path); $ref = $package->getSourceReference(); $flag = defined('PHP_WINDOWS_VERSION_MAJOR') ? '/D ' : ''; $command = 'git clone --no-checkout %s %s && cd '.$flag.'%2$s && git remote add composer %1$s && git fetch composer'; $this->io->writeError(" Cloning ".$ref); $commandCallable = function ($url) use ($ref, $path, $command) { return sprintf($command, ProcessExecutor::escape($url), ProcessExecutor::escape($path), ProcessExecutor::escape($ref)); }; $this->gitUtil->runCommand($commandCallable, $url, $path, true); if ($url !== $package->getSourceUrl()) { $url = $package->getSourceUrl(); $this->process->execute(sprintf('git remote set-url origin %s', ProcessExecutor::escape($url)), $output, $path); } $this->setPushUrl($path, $url); if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) { if ($package->getDistReference() === $package->getSourceReference()) { $package->setDistReference($newRef); } $package->setSourceReference($newRef); } }
php
public function doDownload(PackageInterface $package, $path, $url) { GitUtil::cleanEnv(); $path = $this->normalizePath($path); $ref = $package->getSourceReference(); $flag = defined('PHP_WINDOWS_VERSION_MAJOR') ? '/D ' : ''; $command = 'git clone --no-checkout %s %s && cd '.$flag.'%2$s && git remote add composer %1$s && git fetch composer'; $this->io->writeError(" Cloning ".$ref); $commandCallable = function ($url) use ($ref, $path, $command) { return sprintf($command, ProcessExecutor::escape($url), ProcessExecutor::escape($path), ProcessExecutor::escape($ref)); }; $this->gitUtil->runCommand($commandCallable, $url, $path, true); if ($url !== $package->getSourceUrl()) { $url = $package->getSourceUrl(); $this->process->execute(sprintf('git remote set-url origin %s', ProcessExecutor::escape($url)), $output, $path); } $this->setPushUrl($path, $url); if ($newRef = $this->updateToCommit($path, $ref, $package->getPrettyVersion(), $package->getReleaseDate())) { if ($package->getDistReference() === $package->getSourceReference()) { $package->setDistReference($newRef); } $package->setSourceReference($newRef); } }
[ "public", "function", "doDownload", "(", "PackageInterface", "$", "package", ",", "$", "path", ",", "$", "url", ")", "{", "GitUtil", "::", "cleanEnv", "(", ")", ";", "$", "path", "=", "$", "this", "->", "normalizePath", "(", "$", "path", ")", ";", "$...
{@inheritDoc}
[ "{" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/GitDownloader.php#L40-L67
mothership-ec/composer
src/Composer/Downloader/GitDownloader.php
GitDownloader.doUpdate
public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url) { GitUtil::cleanEnv(); $path = $this->normalizePath($path); if (!is_dir($path.'/.git')) { throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information'); } $ref = $target->getSourceReference(); $this->io->writeError(" Checking out ".$ref); $command = 'git remote set-url composer %s && git fetch composer && git fetch --tags composer'; $commandCallable = function ($url) use ($command) { return sprintf($command, ProcessExecutor::escape ($url)); }; $this->gitUtil->runCommand($commandCallable, $url, $path); if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) { if ($target->getDistReference() === $target->getSourceReference()) { $target->setDistReference($newRef); } $target->setSourceReference($newRef); } }
php
public function doUpdate(PackageInterface $initial, PackageInterface $target, $path, $url) { GitUtil::cleanEnv(); $path = $this->normalizePath($path); if (!is_dir($path.'/.git')) { throw new \RuntimeException('The .git directory is missing from '.$path.', see https://getcomposer.org/commit-deps for more information'); } $ref = $target->getSourceReference(); $this->io->writeError(" Checking out ".$ref); $command = 'git remote set-url composer %s && git fetch composer && git fetch --tags composer'; $commandCallable = function ($url) use ($command) { return sprintf($command, ProcessExecutor::escape ($url)); }; $this->gitUtil->runCommand($commandCallable, $url, $path); if ($newRef = $this->updateToCommit($path, $ref, $target->getPrettyVersion(), $target->getReleaseDate())) { if ($target->getDistReference() === $target->getSourceReference()) { $target->setDistReference($newRef); } $target->setSourceReference($newRef); } }
[ "public", "function", "doUpdate", "(", "PackageInterface", "$", "initial", ",", "PackageInterface", "$", "target", ",", "$", "path", ",", "$", "url", ")", "{", "GitUtil", "::", "cleanEnv", "(", ")", ";", "$", "path", "=", "$", "this", "->", "normalizePat...
{@inheritDoc}
[ "{" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/GitDownloader.php#L72-L95
mothership-ec/composer
src/Composer/Downloader/GitDownloader.php
GitDownloader.getLocalChanges
public function getLocalChanges(PackageInterface $package, $path) { GitUtil::cleanEnv(); $path = $this->normalizePath($path); if (!is_dir($path.'/.git')) { return; } $command = 'git status --porcelain --untracked-files=no'; if (0 !== $this->process->execute($command, $output, $path)) { throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); } return trim($output) ?: null; }
php
public function getLocalChanges(PackageInterface $package, $path) { GitUtil::cleanEnv(); $path = $this->normalizePath($path); if (!is_dir($path.'/.git')) { return; } $command = 'git status --porcelain --untracked-files=no'; if (0 !== $this->process->execute($command, $output, $path)) { throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput()); } return trim($output) ?: null; }
[ "public", "function", "getLocalChanges", "(", "PackageInterface", "$", "package", ",", "$", "path", ")", "{", "GitUtil", "::", "cleanEnv", "(", ")", ";", "$", "path", "=", "$", "this", "->", "normalizePath", "(", "$", "path", ")", ";", "if", "(", "!", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/GitDownloader.php#L100-L114
mothership-ec/composer
src/Composer/Downloader/GitDownloader.php
GitDownloader.cleanChanges
protected function cleanChanges(PackageInterface $package, $path, $update) { GitUtil::cleanEnv(); $path = $this->normalizePath($path); if (!$changes = $this->getLocalChanges($package, $path)) { return; } if (!$this->io->isInteractive()) { $discardChanges = $this->config->get('discard-changes'); if (true === $discardChanges) { return $this->discardChanges($path); } if ('stash' === $discardChanges) { if (!$update) { return parent::cleanChanges($package, $path, $update); } return $this->stashChanges($path); } return parent::cleanChanges($package, $path, $update); } $changes = array_map(function ($elem) { return ' '.$elem; }, preg_split('{\s*\r?\n\s*}', $changes)); $this->io->writeError(' <error>The package has modified files:</error>'); $this->io->writeError(array_slice($changes, 0, 10)); if (count($changes) > 10) { $this->io->writeError(' <info>'.count($changes) - 10 . ' more files modified, choose "v" to view the full list</info>'); } while (true) { switch ($this->io->ask(' <info>Discard changes [y,n,v,'.($update ? 's,' : '').'?]?</info> ', '?')) { case 'y': $this->discardChanges($path); break 2; case 's': if (!$update) { goto help; } $this->stashChanges($path); break 2; case 'n': throw new \RuntimeException('Update aborted'); case 'v': $this->io->writeError($changes); break; case '?': default: help: $this->io->writeError(array( ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'), ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up', ' v - view modified files', )); if ($update) { $this->io->writeError(' s - stash changes and try to reapply them after the update'); } $this->io->writeError(' ? - print help'); break; } } }
php
protected function cleanChanges(PackageInterface $package, $path, $update) { GitUtil::cleanEnv(); $path = $this->normalizePath($path); if (!$changes = $this->getLocalChanges($package, $path)) { return; } if (!$this->io->isInteractive()) { $discardChanges = $this->config->get('discard-changes'); if (true === $discardChanges) { return $this->discardChanges($path); } if ('stash' === $discardChanges) { if (!$update) { return parent::cleanChanges($package, $path, $update); } return $this->stashChanges($path); } return parent::cleanChanges($package, $path, $update); } $changes = array_map(function ($elem) { return ' '.$elem; }, preg_split('{\s*\r?\n\s*}', $changes)); $this->io->writeError(' <error>The package has modified files:</error>'); $this->io->writeError(array_slice($changes, 0, 10)); if (count($changes) > 10) { $this->io->writeError(' <info>'.count($changes) - 10 . ' more files modified, choose "v" to view the full list</info>'); } while (true) { switch ($this->io->ask(' <info>Discard changes [y,n,v,'.($update ? 's,' : '').'?]?</info> ', '?')) { case 'y': $this->discardChanges($path); break 2; case 's': if (!$update) { goto help; } $this->stashChanges($path); break 2; case 'n': throw new \RuntimeException('Update aborted'); case 'v': $this->io->writeError($changes); break; case '?': default: help: $this->io->writeError(array( ' y - discard changes and apply the '.($update ? 'update' : 'uninstall'), ' n - abort the '.($update ? 'update' : 'uninstall').' and let you manually clean things up', ' v - view modified files', )); if ($update) { $this->io->writeError(' s - stash changes and try to reapply them after the update'); } $this->io->writeError(' ? - print help'); break; } } }
[ "protected", "function", "cleanChanges", "(", "PackageInterface", "$", "package", ",", "$", "path", ",", "$", "update", ")", "{", "GitUtil", "::", "cleanEnv", "(", ")", ";", "$", "path", "=", "$", "this", "->", "normalizePath", "(", "$", "path", ")", "...
{@inheritDoc}
[ "{" ]
train
https://github.com/mothership-ec/composer/blob/fa6ad031a939d8d33b211e428fdbdd28cfce238c/src/Composer/Downloader/GitDownloader.php#L119-L188
Smile-SA/EzUICronBundle
Controller/StatusController.php
StatusController.listAction
public function listAction() { $this->performAccessChecks(); $crons = $this->cronService->listCronsStatus(); $cronRows = array(); foreach ($crons as $cron) { $cronRows[] = array( 'alias' => $cron->getAlias(), 'queued' => $cron instanceof SmileCron ? ($cron->getQueued() ? $cron->getQueued()->format('d-m-Y H:i') : false) : false, 'started' => $cron instanceof SmileCron ? ($cron->getStarted() ? $cron->getStarted()->format('d-m-Y H:i') : false) : false, 'ended' => $cron instanceof SmileCron ? ($cron->getEnded() ? $cron->getEnded()->format('d-m-Y H:i') : false) : false, 'status' => $cron instanceof SmileCron ? $cron->getStatus() : false ); } return $this->render('SmileEzUICronBundle:cron:tab/status/list.html.twig', [ 'datas' => $cronRows ]); }
php
public function listAction() { $this->performAccessChecks(); $crons = $this->cronService->listCronsStatus(); $cronRows = array(); foreach ($crons as $cron) { $cronRows[] = array( 'alias' => $cron->getAlias(), 'queued' => $cron instanceof SmileCron ? ($cron->getQueued() ? $cron->getQueued()->format('d-m-Y H:i') : false) : false, 'started' => $cron instanceof SmileCron ? ($cron->getStarted() ? $cron->getStarted()->format('d-m-Y H:i') : false) : false, 'ended' => $cron instanceof SmileCron ? ($cron->getEnded() ? $cron->getEnded()->format('d-m-Y H:i') : false) : false, 'status' => $cron instanceof SmileCron ? $cron->getStatus() : false ); } return $this->render('SmileEzUICronBundle:cron:tab/status/list.html.twig', [ 'datas' => $cronRows ]); }
[ "public", "function", "listAction", "(", ")", "{", "$", "this", "->", "performAccessChecks", "(", ")", ";", "$", "crons", "=", "$", "this", "->", "cronService", "->", "listCronsStatus", "(", ")", ";", "$", "cronRows", "=", "array", "(", ")", ";", "fore...
List crons status @return \Symfony\Component\HttpFoundation\Response
[ "List", "crons", "status" ]
train
https://github.com/Smile-SA/EzUICronBundle/blob/c62fc6a3ab0b39e3f911742d9affe4aade90cf66/Controller/StatusController.php#L33-L59
kvantstudio/site_gallery
src/Plugin/Field/FieldFormatter/SiteGalleryDefaultImageFormatter.php
SiteGalleryDefaultImageFormatter.viewElements
public function viewElements(FieldItemListInterface $items, $langcode) { $elements = parent::viewElements($items, $langcode); foreach ($elements as &$element) { $element['#theme'] = 'site_gallery_default_image_formatter'; } return $elements; }
php
public function viewElements(FieldItemListInterface $items, $langcode) { $elements = parent::viewElements($items, $langcode); foreach ($elements as &$element) { $element['#theme'] = 'site_gallery_default_image_formatter'; } return $elements; }
[ "public", "function", "viewElements", "(", "FieldItemListInterface", "$", "items", ",", "$", "langcode", ")", "{", "$", "elements", "=", "parent", "::", "viewElements", "(", "$", "items", ",", "$", "langcode", ")", ";", "foreach", "(", "$", "elements", "as...
{@inheritdoc}
[ "{" ]
train
https://github.com/kvantstudio/site_gallery/blob/b618180f3005a690c2fc1885b5e9d34ae461cec7/src/Plugin/Field/FieldFormatter/SiteGalleryDefaultImageFormatter.php#L24-L30
philiplb/Valdi
src/Valdi/Validator.php
Validator.createValidators
protected function createValidators(array $validators) { $this->availableValidators = []; foreach ($validators as $name => $type) { $class = '\\Valdi\\Validator\\'.$type; $this->availableValidators[$name] = new $class(); } }
php
protected function createValidators(array $validators) { $this->availableValidators = []; foreach ($validators as $name => $type) { $class = '\\Valdi\\Validator\\'.$type; $this->availableValidators[$name] = new $class(); } }
[ "protected", "function", "createValidators", "(", "array", "$", "validators", ")", "{", "$", "this", "->", "availableValidators", "=", "[", "]", ";", "foreach", "(", "$", "validators", "as", "$", "name", "=>", "$", "type", ")", "{", "$", "class", "=", ...
Creates instances of the available validators. @param array $validators the validators to load, key = name, value = classname within the namespace "\Valdi\Validator"
[ "Creates", "instances", "of", "the", "available", "validators", "." ]
train
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator.php#L34-L40
philiplb/Valdi
src/Valdi/Validator.php
Validator.isValidRule
protected function isValidRule($validator, $parameters, $value) { if (!array_key_exists($validator, $this->availableValidators)) { throw new ValidatorException('"'.$validator.'" not found as available validator.'); } return $this->availableValidators[$validator]->isValid($value, $parameters) ? null : $this->availableValidators[$validator]->getInvalidDetails(); }
php
protected function isValidRule($validator, $parameters, $value) { if (!array_key_exists($validator, $this->availableValidators)) { throw new ValidatorException('"'.$validator.'" not found as available validator.'); } return $this->availableValidators[$validator]->isValid($value, $parameters) ? null : $this->availableValidators[$validator]->getInvalidDetails(); }
[ "protected", "function", "isValidRule", "(", "$", "validator", ",", "$", "parameters", ",", "$", "value", ")", "{", "if", "(", "!", "array_key_exists", "(", "$", "validator", ",", "$", "this", "->", "availableValidators", ")", ")", "{", "throw", "new", "...
Validates a single rule. @param string $validator the validator to use @param string[] $parameters the validation parameters, depending on the validator @param string $value the value to validate @return boolean true if the value is valid @throws ValidationException thrown if the validator is not available
[ "Validates", "a", "single", "rule", "." ]
train
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator.php#L58-L64
philiplb/Valdi
src/Valdi/Validator.php
Validator.isValidValue
public function isValidValue($rules, $value) { $result = []; foreach ($rules as $rule) { $parameters = $rule; $name = array_shift($parameters); $valid = $this->isValidRule($name, $parameters, $value); if ($valid !== null) { $result[] = $valid; } } return $result; }
php
public function isValidValue($rules, $value) { $result = []; foreach ($rules as $rule) { $parameters = $rule; $name = array_shift($parameters); $valid = $this->isValidRule($name, $parameters, $value); if ($valid !== null) { $result[] = $valid; } } return $result; }
[ "public", "function", "isValidValue", "(", "$", "rules", ",", "$", "value", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "rules", "as", "$", "rule", ")", "{", "$", "parameters", "=", "$", "rule", ";", "$", "name", "=", "array...
Validates a value via the given rules. @param array $rules the validation rules @param string $value the value to validate @return string[] the fields where the validation failed
[ "Validates", "a", "value", "via", "the", "given", "rules", "." ]
train
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator.php#L114-L125
philiplb/Valdi
src/Valdi/Validator.php
Validator.isValid
public function isValid(array $rules, array $data) { $errors = []; foreach ($rules as $field => $fieldRules) { $value = isset($data[$field]) ? $data[$field] : null; $fieldErrors = $this->isValidValue($fieldRules, $value); if (!empty($fieldErrors)) { $errors[$field] = $fieldErrors; } } return [ 'valid' => count($errors) === 0, 'errors' => $errors ]; }
php
public function isValid(array $rules, array $data) { $errors = []; foreach ($rules as $field => $fieldRules) { $value = isset($data[$field]) ? $data[$field] : null; $fieldErrors = $this->isValidValue($fieldRules, $value); if (!empty($fieldErrors)) { $errors[$field] = $fieldErrors; } } return [ 'valid' => count($errors) === 0, 'errors' => $errors ]; }
[ "public", "function", "isValid", "(", "array", "$", "rules", ",", "array", "$", "data", ")", "{", "$", "errors", "=", "[", "]", ";", "foreach", "(", "$", "rules", "as", "$", "field", "=>", "$", "fieldRules", ")", "{", "$", "value", "=", "isset", ...
Performs the actual validation. @param array $rules the validation rules: an array with a field name as key and an array of rules to use for this field; each rule is an array with the validator name as first element and parameters as following elements; example: array('a' => array(array('required')), 'b' => array(array('min', 1))) @param array $data the data to validate as a map @return array<string,boolean|array> the validation result having the keys "valid" (true or false) and the key "errors" containing all failed fields as keys with arrays of the failed validator names; example where the field "b" from the above sample failed due to the min validator: array('valid' => false, errors => array('b' => array('min'))) the "or" validator doesn't return a single string on validation error; instead, it returns an array listing all failed validators of it: array('or' => array('url', 'email')
[ "Performs", "the", "actual", "validation", "." ]
train
https://github.com/philiplb/Valdi/blob/9927ec34a2cb00cec705e952d3c2374e2dc3c972/src/Valdi/Validator.php#L148-L161
mrgarry/yii2-omj-fidavista
FidavistaStatement.php
FidavistaStatement.getStatement
public function getStatement() { $response = []; //iegūst visus datus un sakārto tos smukā masīvā foreach ($this->accountList as $account) { $currencyList = $account->getCurrencies(); $accountName = $account->name(); foreach ($currencyList as $currency) { $trxList = $currency->getTransactions(); $currencyName = $currency->name(); foreach ($trxList as $trx) { //sākam paša masīva formēšanu $response[] = $this->getStatementRow($trx, $currencyName, $accountName); } } } return $response; }
php
public function getStatement() { $response = []; //iegūst visus datus un sakārto tos smukā masīvā foreach ($this->accountList as $account) { $currencyList = $account->getCurrencies(); $accountName = $account->name(); foreach ($currencyList as $currency) { $trxList = $currency->getTransactions(); $currencyName = $currency->name(); foreach ($trxList as $trx) { //sākam paša masīva formēšanu $response[] = $this->getStatementRow($trx, $currencyName, $accountName); } } } return $response; }
[ "public", "function", "getStatement", "(", ")", "{", "$", "response", "=", "[", "]", ";", "//iegūst visus datus un sakārto tos smukā masīvā\r", "foreach", "(", "$", "this", "->", "accountList", "as", "$", "account", ")", "{", "$", "currencyList", "=", "$", "ac...
Returns 2-dim array with bank statement data ready to be imported into any DB atgriež smuku 2-dimensiju masīvu ar statement data, kas ir gatavs importam uz DB @return array
[ "Returns", "2", "-", "dim", "array", "with", "bank", "statement", "data", "ready", "to", "be", "imported", "into", "any", "DB", "atgriež", "smuku", "2", "-", "dimensiju", "masīvu", "ar", "statement", "data", "kas", "ir", "gatavs", "importam", "uz", "DB" ]
train
https://github.com/mrgarry/yii2-omj-fidavista/blob/ee4ecadd6648b68e891352c214ff33a72622941b/FidavistaStatement.php#L202-L222
mrgarry/yii2-omj-fidavista
FidavistaStatement.php
FidavistaStatement.isFidaVista
public static function isFidaVista($statement) { $result = false; $domDocument = new \DOMDocument(); libxml_use_internal_errors(true); try { //$domDocument->loadXML($statement); if ($domDocument->loadXML($statement) == true) { $node = $domDocument->childNodes->item(0); if ($node->nodeName === 'FIDAVISTA') { $result = true; } } } catch (Exception $exc) { $result = false; } finally { unset($domDocument); } return $result; }
php
public static function isFidaVista($statement) { $result = false; $domDocument = new \DOMDocument(); libxml_use_internal_errors(true); try { //$domDocument->loadXML($statement); if ($domDocument->loadXML($statement) == true) { $node = $domDocument->childNodes->item(0); if ($node->nodeName === 'FIDAVISTA') { $result = true; } } } catch (Exception $exc) { $result = false; } finally { unset($domDocument); } return $result; }
[ "public", "static", "function", "isFidaVista", "(", "$", "statement", ")", "{", "$", "result", "=", "false", ";", "$", "domDocument", "=", "new", "\\", "DOMDocument", "(", ")", ";", "libxml_use_internal_errors", "(", "true", ")", ";", "try", "{", "//$domDo...
Checks if given file data is valid FidaVista/XML bank statement @param string $statement file contents that need to be checked @return boolean
[ "Checks", "if", "given", "file", "data", "is", "valid", "FidaVista", "/", "XML", "bank", "statement" ]
train
https://github.com/mrgarry/yii2-omj-fidavista/blob/ee4ecadd6648b68e891352c214ff33a72622941b/FidavistaStatement.php#L230-L252
mrgarry/yii2-omj-fidavista
FidavistaStatement.php
FidavistaStatement.saveToDb
public function saveToDb($incomingOnly = false) { $count = ($incomingOnly) ? $this->dbInterface->executeDataImportIncoming() : $this->dbInterface->executeDataImport(); return $count; }
php
public function saveToDb($incomingOnly = false) { $count = ($incomingOnly) ? $this->dbInterface->executeDataImportIncoming() : $this->dbInterface->executeDataImport(); return $count; }
[ "public", "function", "saveToDb", "(", "$", "incomingOnly", "=", "false", ")", "{", "$", "count", "=", "(", "$", "incomingOnly", ")", "?", "$", "this", "->", "dbInterface", "->", "executeDataImportIncoming", "(", ")", ":", "$", "this", "->", "dbInterface",...
Saves the data to DB using iAccountStatementDbController @param bool $incomingOnly @return int Optinally can be implemented in iAccountStatementDbController - num of rows imported
[ "Saves", "the", "data", "to", "DB", "using", "iAccountStatementDbController" ]
train
https://github.com/mrgarry/yii2-omj-fidavista/blob/ee4ecadd6648b68e891352c214ff33a72622941b/FidavistaStatement.php#L259-L262
zhouyl/mellivora
Mellivora/View/Concerns/ManagesLoops.php
ManagesLoops.addLoop
public function addLoop($data) { $length = is_array($data) || $data instanceof Countable ? count($data) : null; $parent = Arr::last($this->loopsStack); $this->loopsStack[] = [ 'iteration' => 0, 'index' => 0, 'remaining' => isset($length) ? $length : null, 'count' => $length, 'first' => true, 'last' => isset($length) ? $length === 1 : null, 'depth' => count($this->loopsStack) + 1, 'parent' => $parent ? (object) $parent : null, ]; }
php
public function addLoop($data) { $length = is_array($data) || $data instanceof Countable ? count($data) : null; $parent = Arr::last($this->loopsStack); $this->loopsStack[] = [ 'iteration' => 0, 'index' => 0, 'remaining' => isset($length) ? $length : null, 'count' => $length, 'first' => true, 'last' => isset($length) ? $length === 1 : null, 'depth' => count($this->loopsStack) + 1, 'parent' => $parent ? (object) $parent : null, ]; }
[ "public", "function", "addLoop", "(", "$", "data", ")", "{", "$", "length", "=", "is_array", "(", "$", "data", ")", "||", "$", "data", "instanceof", "Countable", "?", "count", "(", "$", "data", ")", ":", "null", ";", "$", "parent", "=", "Arr", "::"...
Add new loop to the stack. @param array|\Countable $data @return void
[ "Add", "new", "loop", "to", "the", "stack", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/View/Concerns/ManagesLoops.php#L24-L40
zhouyl/mellivora
Mellivora/View/Concerns/ManagesLoops.php
ManagesLoops.incrementLoopIndices
public function incrementLoopIndices() { $loop = $this->loopsStack[$index = count($this->loopsStack) - 1]; $this->loopsStack[$index] = array_merge($this->loopsStack[$index], [ 'iteration' => $loop['iteration'] + 1, 'index' => $loop['iteration'], 'first' => $loop['iteration'] === 0, 'remaining' => isset($loop['count']) ? $loop['remaining'] - 1 : null, 'last' => isset($loop['count']) ? $loop['iteration'] === $loop['count'] - 1 : null, ]); }
php
public function incrementLoopIndices() { $loop = $this->loopsStack[$index = count($this->loopsStack) - 1]; $this->loopsStack[$index] = array_merge($this->loopsStack[$index], [ 'iteration' => $loop['iteration'] + 1, 'index' => $loop['iteration'], 'first' => $loop['iteration'] === 0, 'remaining' => isset($loop['count']) ? $loop['remaining'] - 1 : null, 'last' => isset($loop['count']) ? $loop['iteration'] === $loop['count'] - 1 : null, ]); }
[ "public", "function", "incrementLoopIndices", "(", ")", "{", "$", "loop", "=", "$", "this", "->", "loopsStack", "[", "$", "index", "=", "count", "(", "$", "this", "->", "loopsStack", ")", "-", "1", "]", ";", "$", "this", "->", "loopsStack", "[", "$",...
Increment the top loop's indices. @return void
[ "Increment", "the", "top", "loop", "s", "indices", "." ]
train
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/View/Concerns/ManagesLoops.php#L47-L58
php-lug/lug
src/Bundle/GridBundle/LugGridBundle.php
LugGridBundle.build
public function build(ContainerBuilder $container) { $container ->addCompilerPass(new RegisterActionPass()) ->addCompilerPass(new RegisterBatchPass()) ->addCompilerPass(new RegisterColumnPass()) ->addCompilerPass(new RegisterFilterManagerStoragePass()) ->addCompilerPass(new RegisterFilterPass()) ->addCompilerPass(new RegisterSortPass()) ->addCompilerPass(new RegisterBatchFormSubscriberPass()) ->addCompilerPass(new RegisterFilterFormPass()) ->addCompilerPass(new ReplaceLocaleContextPass()); }
php
public function build(ContainerBuilder $container) { $container ->addCompilerPass(new RegisterActionPass()) ->addCompilerPass(new RegisterBatchPass()) ->addCompilerPass(new RegisterColumnPass()) ->addCompilerPass(new RegisterFilterManagerStoragePass()) ->addCompilerPass(new RegisterFilterPass()) ->addCompilerPass(new RegisterSortPass()) ->addCompilerPass(new RegisterBatchFormSubscriberPass()) ->addCompilerPass(new RegisterFilterFormPass()) ->addCompilerPass(new ReplaceLocaleContextPass()); }
[ "public", "function", "build", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "container", "->", "addCompilerPass", "(", "new", "RegisterActionPass", "(", ")", ")", "->", "addCompilerPass", "(", "new", "RegisterBatchPass", "(", ")", ")", "->", "addC...
{@inheritdoc}
[ "{" ]
train
https://github.com/php-lug/lug/blob/81c109f187eba0a60f17e8cc59984ebb31841db7/src/Bundle/GridBundle/LugGridBundle.php#L34-L46
graze/data-structure
src/Container/ImmutableFlatContainer.php
ImmutableFlatContainer.set
public function set($key, $value) { $cont = clone $this; $cont->doSet($key, $this->recursiveClone($value)); return $cont; }
php
public function set($key, $value) { $cont = clone $this; $cont->doSet($key, $this->recursiveClone($value)); return $cont; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "$", "cont", "=", "clone", "$", "this", ";", "$", "cont", "->", "doSet", "(", "$", "key", ",", "$", "this", "->", "recursiveClone", "(", "$", "value", ")", ")", ";", "re...
@param string $key @param mixed $value @return ContainerInterface
[ "@param", "string", "$key", "@param", "mixed", "$value" ]
train
https://github.com/graze/data-structure/blob/24e0544b7828f65b1b93ce69ad702c9efb4a64d0/src/Container/ImmutableFlatContainer.php#L52-L58
graze/data-structure
src/Container/ImmutableFlatContainer.php
ImmutableFlatContainer.remove
public function remove($key) { if ($this->has($key)) { $cont = clone $this; $cont->doRemove($key); return $cont; } return $this; }
php
public function remove($key) { if ($this->has($key)) { $cont = clone $this; $cont->doRemove($key); return $cont; } return $this; }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "$", "cont", "=", "clone", "$", "this", ";", "$", "cont", "->", "doRemove", "(", "$", "key", ")", ";", "return", "...
@param string $key @return ContainerInterface
[ "@param", "string", "$key" ]
train
https://github.com/graze/data-structure/blob/24e0544b7828f65b1b93ce69ad702c9efb4a64d0/src/Container/ImmutableFlatContainer.php#L77-L87
accompli/chrono
src/Process/ProcessExecutor.php
ProcessExecutor.execute
public function execute($command, $workingDirectory = null, array $environmentVariables = null) { if ($workingDirectory === null) { $workingDirectory = $this->getWorkingDirectory(); } $process = new Process($command, $workingDirectory, $environmentVariables); $process->setTimeout(300); $process->run(); $this->lastProcessExecutionResult = new ProcessExecutionResult($process->getExitCode(), $process->getOutput(), $process->getErrorOutput()); return $this->lastProcessExecutionResult; }
php
public function execute($command, $workingDirectory = null, array $environmentVariables = null) { if ($workingDirectory === null) { $workingDirectory = $this->getWorkingDirectory(); } $process = new Process($command, $workingDirectory, $environmentVariables); $process->setTimeout(300); $process->run(); $this->lastProcessExecutionResult = new ProcessExecutionResult($process->getExitCode(), $process->getOutput(), $process->getErrorOutput()); return $this->lastProcessExecutionResult; }
[ "public", "function", "execute", "(", "$", "command", ",", "$", "workingDirectory", "=", "null", ",", "array", "$", "environmentVariables", "=", "null", ")", "{", "if", "(", "$", "workingDirectory", "===", "null", ")", "{", "$", "workingDirectory", "=", "$...
{@inheritdoc}
[ "{" ]
train
https://github.com/accompli/chrono/blob/5f3201ee1e3fdc519fabac92bc9bfb7d9bebdebc/src/Process/ProcessExecutor.php#L42-L55
expectation-php/expect
src/MatcherEvaluator.php
MatcherEvaluator.evaluate
public function evaluate($actual) { $matcherResult = $this->matcher->match($actual); $expected = $this->negated ? false : true; $result = $matcherResult === $expected; return new Result($actual, $this->negated, $this->matcher, $result); }
php
public function evaluate($actual) { $matcherResult = $this->matcher->match($actual); $expected = $this->negated ? false : true; $result = $matcherResult === $expected; return new Result($actual, $this->negated, $this->matcher, $result); }
[ "public", "function", "evaluate", "(", "$", "actual", ")", "{", "$", "matcherResult", "=", "$", "this", "->", "matcher", "->", "match", "(", "$", "actual", ")", ";", "$", "expected", "=", "$", "this", "->", "negated", "?", "false", ":", "true", ";", ...
Evaluate the value of actual. @param mixed $actual value of actual @return \expect\Result
[ "Evaluate", "the", "value", "of", "actual", "." ]
train
https://github.com/expectation-php/expect/blob/1a32c5af37f3dc8dabe4e8eedeeb21aea16ce139/src/MatcherEvaluator.php#L92-L100