repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
sequencelengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
sequencelengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
yuncms/framework
src/notifications/channels/CloudPushChannel.php
CloudPushChannel.send
public function send(NotifiableInterface $notifiable, Notification $notification) { /** * @var $message CloudPushMessage */ $message = $notification->toCloudPush(); $appRecipient = $notifiable->routeNotificationFor('cloudPush'); if ($message->validate()) { $messageParams = [ 'AppKey' => $this->appKey, 'Target' => $appRecipient['target'], 'TargetValue' => $appRecipient['targetValue'], 'Title' => $message->title, 'Body' => $message->content, ]; if (!empty($message->extParameters)) { $messageParams['ExtParameters'] = Json::encode($message->extParameters); } $this->aliyun->getCloudPush()->pushNoticeToAndroid($messageParams); $messageParams['ApnsEnv'] = YII_ENV_DEV ? 'DEV' : 'PRODUCT'; $this->aliyun->getCloudPush()->pushNoticeToIOS($messageParams); } else { print_r($message->getErrors()); exit; } }
php
public function send(NotifiableInterface $notifiable, Notification $notification) { /** * @var $message CloudPushMessage */ $message = $notification->toCloudPush(); $appRecipient = $notifiable->routeNotificationFor('cloudPush'); if ($message->validate()) { $messageParams = [ 'AppKey' => $this->appKey, 'Target' => $appRecipient['target'], 'TargetValue' => $appRecipient['targetValue'], 'Title' => $message->title, 'Body' => $message->content, ]; if (!empty($message->extParameters)) { $messageParams['ExtParameters'] = Json::encode($message->extParameters); } $this->aliyun->getCloudPush()->pushNoticeToAndroid($messageParams); $messageParams['ApnsEnv'] = YII_ENV_DEV ? 'DEV' : 'PRODUCT'; $this->aliyun->getCloudPush()->pushNoticeToIOS($messageParams); } else { print_r($message->getErrors()); exit; } }
[ "public", "function", "send", "(", "NotifiableInterface", "$", "notifiable", ",", "Notification", "$", "notification", ")", "{", "/**\n * @var $message CloudPushMessage\n */", "$", "message", "=", "$", "notification", "->", "toCloudPush", "(", ")", ";", "$", "appRecipient", "=", "$", "notifiable", "->", "routeNotificationFor", "(", "'cloudPush'", ")", ";", "if", "(", "$", "message", "->", "validate", "(", ")", ")", "{", "$", "messageParams", "=", "[", "'AppKey'", "=>", "$", "this", "->", "appKey", ",", "'Target'", "=>", "$", "appRecipient", "[", "'target'", "]", ",", "'TargetValue'", "=>", "$", "appRecipient", "[", "'targetValue'", "]", ",", "'Title'", "=>", "$", "message", "->", "title", ",", "'Body'", "=>", "$", "message", "->", "content", ",", "]", ";", "if", "(", "!", "empty", "(", "$", "message", "->", "extParameters", ")", ")", "{", "$", "messageParams", "[", "'ExtParameters'", "]", "=", "Json", "::", "encode", "(", "$", "message", "->", "extParameters", ")", ";", "}", "$", "this", "->", "aliyun", "->", "getCloudPush", "(", ")", "->", "pushNoticeToAndroid", "(", "$", "messageParams", ")", ";", "$", "messageParams", "[", "'ApnsEnv'", "]", "=", "YII_ENV_DEV", "?", "'DEV'", ":", "'PRODUCT'", ";", "$", "this", "->", "aliyun", "->", "getCloudPush", "(", ")", "->", "pushNoticeToIOS", "(", "$", "messageParams", ")", ";", "}", "else", "{", "print_r", "(", "$", "message", "->", "getErrors", "(", ")", ")", ";", "exit", ";", "}", "}" ]
Send the given notification. @param NotifiableInterface $notifiable @param Notification $notification @return mixed @throws \yii\base\InvalidConfigException
[ "Send", "the", "given", "notification", "." ]
train
https://github.com/yuncms/framework/blob/af42e28ea4ae15ab8eead3f6d119f93863b94154/src/notifications/channels/CloudPushChannel.php#L55-L80
timiki/rpc-common
src/JsonRequest.php
JsonRequest.setResponse
public function setResponse(JsonResponse $response) { $this->response = $response; if (!$response->getRequest()) { $response->setRequest($this); } return $this; }
php
public function setResponse(JsonResponse $response) { $this->response = $response; if (!$response->getRequest()) { $response->setRequest($this); } return $this; }
[ "public", "function", "setResponse", "(", "JsonResponse", "$", "response", ")", "{", "$", "this", "->", "response", "=", "$", "response", ";", "if", "(", "!", "$", "response", "->", "getRequest", "(", ")", ")", "{", "$", "response", "->", "setRequest", "(", "$", "this", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set response. @param JsonResponse $response @return $this
[ "Set", "response", "." ]
train
https://github.com/timiki/rpc-common/blob/a20e8bc92b16aa3686c4405bf5182123a5cfc750/src/JsonRequest.php#L116-L125
timiki/rpc-common
src/JsonRequest.php
JsonRequest.isValid
public function isValid() { if (empty($this->jsonrpc)) { return false; } if (empty($this->method) || !is_string($this->method)) { return false; } if (!empty($this->params) && !is_array($this->params)) { return false; } return true; }
php
public function isValid() { if (empty($this->jsonrpc)) { return false; } if (empty($this->method) || !is_string($this->method)) { return false; } if (!empty($this->params) && !is_array($this->params)) { return false; } return true; }
[ "public", "function", "isValid", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "jsonrpc", ")", ")", "{", "return", "false", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "method", ")", "||", "!", "is_string", "(", "$", "this", "->", "method", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "params", ")", "&&", "!", "is_array", "(", "$", "this", "->", "params", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Is valid. @return boolean
[ "Is", "valid", "." ]
train
https://github.com/timiki/rpc-common/blob/a20e8bc92b16aa3686c4405bf5182123a5cfc750/src/JsonRequest.php#L132-L147
timiki/rpc-common
src/JsonRequest.php
JsonRequest.toArray
public function toArray() { $json = []; $json['jsonrpc'] = $this->jsonrpc; if ($this->method) { $json['method'] = $this->method; } $json['method'] = $this->method; if ($this->params) { $json['params'] = $this->params; } if ($this->id) { $json['id'] = $this->id; } return $json; }
php
public function toArray() { $json = []; $json['jsonrpc'] = $this->jsonrpc; if ($this->method) { $json['method'] = $this->method; } $json['method'] = $this->method; if ($this->params) { $json['params'] = $this->params; } if ($this->id) { $json['id'] = $this->id; } return $json; }
[ "public", "function", "toArray", "(", ")", "{", "$", "json", "=", "[", "]", ";", "$", "json", "[", "'jsonrpc'", "]", "=", "$", "this", "->", "jsonrpc", ";", "if", "(", "$", "this", "->", "method", ")", "{", "$", "json", "[", "'method'", "]", "=", "$", "this", "->", "method", ";", "}", "$", "json", "[", "'method'", "]", "=", "$", "this", "->", "method", ";", "if", "(", "$", "this", "->", "params", ")", "{", "$", "json", "[", "'params'", "]", "=", "$", "this", "->", "params", ";", "}", "if", "(", "$", "this", "->", "id", ")", "{", "$", "json", "[", "'id'", "]", "=", "$", "this", "->", "id", ";", "}", "return", "$", "json", ";", "}" ]
Convert JsonRequest to json string. @return array
[ "Convert", "JsonRequest", "to", "json", "string", "." ]
train
https://github.com/timiki/rpc-common/blob/a20e8bc92b16aa3686c4405bf5182123a5cfc750/src/JsonRequest.php#L166-L186
ARCANEDEV/Sanitizer
src/Filters/EmailFilter.php
EmailFilter.filter
public function filter($value, array $options = []) { return is_string($value) ? filter_var(Str::lower(trim($value)), FILTER_SANITIZE_EMAIL) : $value; }
php
public function filter($value, array $options = []) { return is_string($value) ? filter_var(Str::lower(trim($value)), FILTER_SANITIZE_EMAIL) : $value; }
[ "public", "function", "filter", "(", "$", "value", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "is_string", "(", "$", "value", ")", "?", "filter_var", "(", "Str", "::", "lower", "(", "trim", "(", "$", "value", ")", ")", ",", "FILTER_SANITIZE_EMAIL", ")", ":", "$", "value", ";", "}" ]
Sanitize email of the given string. @param mixed $value @param array $options @return string|mixed
[ "Sanitize", "email", "of", "the", "given", "string", "." ]
train
https://github.com/ARCANEDEV/Sanitizer/blob/e21990ce6d881366d52a7f4e5040b07cc3ecca96/src/Filters/EmailFilter.php#L26-L31
webforge-labs/psc-cms
lib/Psc/CMS/Project.php
Project.getInstallPharFile
public function getInstallPharFile() { if (($ipf = $this->config->get(array('build','installPharFile'), NULL)) !== NULL) { return new File($ipf); } else { return new File($this->getSrc(), 'psc-cms.phar.gz'); } }
php
public function getInstallPharFile() { if (($ipf = $this->config->get(array('build','installPharFile'), NULL)) !== NULL) { return new File($ipf); } else { return new File($this->getSrc(), 'psc-cms.phar.gz'); } }
[ "public", "function", "getInstallPharFile", "(", ")", "{", "if", "(", "(", "$", "ipf", "=", "$", "this", "->", "config", "->", "get", "(", "array", "(", "'build'", ",", "'installPharFile'", ")", ",", "NULL", ")", ")", "!==", "NULL", ")", "{", "return", "new", "File", "(", "$", "ipf", ")", ";", "}", "else", "{", "return", "new", "File", "(", "$", "this", "->", "getSrc", "(", ")", ",", "'psc-cms.phar.gz'", ")", ";", "}", "}" ]
Gibt den Ort zurück in dem im Projekt die psc-cms.phar.gz abgelegt werden soll @return File
[ "Gibt", "den", "Ort", "zurück", "in", "dem", "im", "Projekt", "die", "psc", "-", "cms", ".", "phar", ".", "gz", "abgelegt", "werden", "soll" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Project.php#L250-L256
webforge-labs/psc-cms
lib/Psc/CMS/Project.php
Project.namespaceToPath
public function namespaceToPath($namespace, Dir $classPath = NULL) { $cp = $classPath ?: $this->getClassPath()->up(); // end und anfangs backslashs weg $namespace = trim($namespace,'\\'); $dir = $cp->sub(str_replace('\\','/',$namespace).'/'); return $dir; }
php
public function namespaceToPath($namespace, Dir $classPath = NULL) { $cp = $classPath ?: $this->getClassPath()->up(); // end und anfangs backslashs weg $namespace = trim($namespace,'\\'); $dir = $cp->sub(str_replace('\\','/',$namespace).'/'); return $dir; }
[ "public", "function", "namespaceToPath", "(", "$", "namespace", ",", "Dir", "$", "classPath", "=", "NULL", ")", "{", "$", "cp", "=", "$", "classPath", "?", ":", "$", "this", "->", "getClassPath", "(", ")", "->", "up", "(", ")", ";", "// end und anfangs backslashs weg", "$", "namespace", "=", "trim", "(", "$", "namespace", ",", "'\\\\'", ")", ";", "$", "dir", "=", "$", "cp", "->", "sub", "(", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "namespace", ")", ".", "'/'", ")", ";", "return", "$", "dir", ";", "}" ]
Gibt das Verzeichnis eines Namespaces in einem Verzeichnis zurück dies nimmt einfach den Namespace @return Dir absolute im angegebenen $classPath oder in $this->getClassPath()
[ "Gibt", "das", "Verzeichnis", "eines", "Namespaces", "in", "einem", "Verzeichnis", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/CMS/Project.php#L304-L313
hackzilla/ticket-message
Manager/TicketManager.php
TicketManager.createMessage
public function createMessage(TicketInterface $ticket = null) { /* @var TicketMessageInterface $message */ $message = new $this->ticketMessageClass(); if ($ticket) { $message->setPriority($ticket->getPriority()); $message->setStatus($ticket->getStatus()); $message->setTicket($ticket); } else { $message->setStatus(TicketMessage::STATUS_OPEN); } return $message; }
php
public function createMessage(TicketInterface $ticket = null) { /* @var TicketMessageInterface $message */ $message = new $this->ticketMessageClass(); if ($ticket) { $message->setPriority($ticket->getPriority()); $message->setStatus($ticket->getStatus()); $message->setTicket($ticket); } else { $message->setStatus(TicketMessage::STATUS_OPEN); } return $message; }
[ "public", "function", "createMessage", "(", "TicketInterface", "$", "ticket", "=", "null", ")", "{", "/* @var TicketMessageInterface $message */", "$", "message", "=", "new", "$", "this", "->", "ticketMessageClass", "(", ")", ";", "if", "(", "$", "ticket", ")", "{", "$", "message", "->", "setPriority", "(", "$", "ticket", "->", "getPriority", "(", ")", ")", ";", "$", "message", "->", "setStatus", "(", "$", "ticket", "->", "getStatus", "(", ")", ")", ";", "$", "message", "->", "setTicket", "(", "$", "ticket", ")", ";", "}", "else", "{", "$", "message", "->", "setStatus", "(", "TicketMessage", "::", "STATUS_OPEN", ")", ";", "}", "return", "$", "message", ";", "}" ]
Create a new instance of TicketMessage Entity. @param TicketInterface $ticket @return TicketMessageInterface
[ "Create", "a", "new", "instance", "of", "TicketMessage", "Entity", "." ]
train
https://github.com/hackzilla/ticket-message/blob/043950aa95f322cfaae145ce3c7781a4b0618a18/Manager/TicketManager.php#L124-L138
hackzilla/ticket-message
Manager/TicketManager.php
TicketManager.updateTicket
public function updateTicket(TicketInterface $ticket, TicketMessageInterface $message = null) { $this->storageManager('persist', $ticket); if (is_null($ticket->getId())) { $this->fireEvent(TicketEvents::TICKET_CREATE, $ticket); $this->storageManager('persist', $ticket); } else { $this->fireEvent(TicketEvents::TICKET_UPDATE, $ticket); } if (!\is_null($message)) { $message->setTicket($ticket); $this->storageManager('persist', $message); } $this->storageManager('flush'); return $ticket; }
php
public function updateTicket(TicketInterface $ticket, TicketMessageInterface $message = null) { $this->storageManager('persist', $ticket); if (is_null($ticket->getId())) { $this->fireEvent(TicketEvents::TICKET_CREATE, $ticket); $this->storageManager('persist', $ticket); } else { $this->fireEvent(TicketEvents::TICKET_UPDATE, $ticket); } if (!\is_null($message)) { $message->setTicket($ticket); $this->storageManager('persist', $message); } $this->storageManager('flush'); return $ticket; }
[ "public", "function", "updateTicket", "(", "TicketInterface", "$", "ticket", ",", "TicketMessageInterface", "$", "message", "=", "null", ")", "{", "$", "this", "->", "storageManager", "(", "'persist'", ",", "$", "ticket", ")", ";", "if", "(", "is_null", "(", "$", "ticket", "->", "getId", "(", ")", ")", ")", "{", "$", "this", "->", "fireEvent", "(", "TicketEvents", "::", "TICKET_CREATE", ",", "$", "ticket", ")", ";", "$", "this", "->", "storageManager", "(", "'persist'", ",", "$", "ticket", ")", ";", "}", "else", "{", "$", "this", "->", "fireEvent", "(", "TicketEvents", "::", "TICKET_UPDATE", ",", "$", "ticket", ")", ";", "}", "if", "(", "!", "\\", "is_null", "(", "$", "message", ")", ")", "{", "$", "message", "->", "setTicket", "(", "$", "ticket", ")", ";", "$", "this", "->", "storageManager", "(", "'persist'", ",", "$", "message", ")", ";", "}", "$", "this", "->", "storageManager", "(", "'flush'", ")", ";", "return", "$", "ticket", ";", "}" ]
Update or Create a Ticket in the database Update or Create a TicketMessage in the database. @param TicketInterface $ticket @param TicketMessageInterface $message @return TicketInterface
[ "Update", "or", "Create", "a", "Ticket", "in", "the", "database", "Update", "or", "Create", "a", "TicketMessage", "in", "the", "database", "." ]
train
https://github.com/hackzilla/ticket-message/blob/043950aa95f322cfaae145ce3c7781a4b0618a18/Manager/TicketManager.php#L149-L168
hackzilla/ticket-message
Manager/TicketManager.php
TicketManager.deleteTicket
public function deleteTicket(TicketInterface $ticket) { $this->fireEvent(TicketEvents::TICKET_DELETE, $ticket); $this->storageManager('remove', $ticket); $this->storageManager('flush'); }
php
public function deleteTicket(TicketInterface $ticket) { $this->fireEvent(TicketEvents::TICKET_DELETE, $ticket); $this->storageManager('remove', $ticket); $this->storageManager('flush'); }
[ "public", "function", "deleteTicket", "(", "TicketInterface", "$", "ticket", ")", "{", "$", "this", "->", "fireEvent", "(", "TicketEvents", "::", "TICKET_DELETE", ",", "$", "ticket", ")", ";", "$", "this", "->", "storageManager", "(", "'remove'", ",", "$", "ticket", ")", ";", "$", "this", "->", "storageManager", "(", "'flush'", ")", ";", "}" ]
Delete a ticket from the database. @param TicketInterface $ticket*
[ "Delete", "a", "ticket", "from", "the", "database", "." ]
train
https://github.com/hackzilla/ticket-message/blob/043950aa95f322cfaae145ce3c7781a4b0618a18/Manager/TicketManager.php#L175-L181
hackzilla/ticket-message
Manager/TicketManager.php
TicketManager.getTicketList
public function getTicketList($ticketStatus, $ticketPriority = null, array $orderBy = null) { return $this->storageManager('getTicketList', $ticketStatus, $ticketPriority, $orderBy); }
php
public function getTicketList($ticketStatus, $ticketPriority = null, array $orderBy = null) { return $this->storageManager('getTicketList', $ticketStatus, $ticketPriority, $orderBy); }
[ "public", "function", "getTicketList", "(", "$", "ticketStatus", ",", "$", "ticketPriority", "=", "null", ",", "array", "$", "orderBy", "=", "null", ")", "{", "return", "$", "this", "->", "storageManager", "(", "'getTicketList'", ",", "$", "ticketStatus", ",", "$", "ticketPriority", ",", "$", "orderBy", ")", ";", "}" ]
@param int $ticketStatus @param int $ticketPriority @param array $orderBy field as the key and direction as the value @return Pagerfanta
[ "@param", "int", "$ticketStatus", "@param", "int", "$ticketPriority", "@param", "array", "$orderBy", "field", "as", "the", "key", "and", "direction", "as", "the", "value" ]
train
https://github.com/hackzilla/ticket-message/blob/043950aa95f322cfaae145ce3c7781a4b0618a18/Manager/TicketManager.php#L236-L239
hackzilla/ticket-message
Manager/TicketManager.php
TicketManager.getTicketStatus
public function getTicketStatus($statusStr) { static $statuses = false; if ($statuses === false) { $statuses = []; foreach (TicketMessageInterface::STATUSES as $id => $value) { $statuses[$id] = $this->translate($value); } } return \array_search($statusStr, $statuses); }
php
public function getTicketStatus($statusStr) { static $statuses = false; if ($statuses === false) { $statuses = []; foreach (TicketMessageInterface::STATUSES as $id => $value) { $statuses[$id] = $this->translate($value); } } return \array_search($statusStr, $statuses); }
[ "public", "function", "getTicketStatus", "(", "$", "statusStr", ")", "{", "static", "$", "statuses", "=", "false", ";", "if", "(", "$", "statuses", "===", "false", ")", "{", "$", "statuses", "=", "[", "]", ";", "foreach", "(", "TicketMessageInterface", "::", "STATUSES", "as", "$", "id", "=>", "$", "value", ")", "{", "$", "statuses", "[", "$", "id", "]", "=", "$", "this", "->", "translate", "(", "$", "value", ")", ";", "}", "}", "return", "\\", "array_search", "(", "$", "statusStr", ",", "$", "statuses", ")", ";", "}" ]
Lookup status code. @param string $statusStr @return int
[ "Lookup", "status", "code", "." ]
train
https://github.com/hackzilla/ticket-message/blob/043950aa95f322cfaae145ce3c7781a4b0618a18/Manager/TicketManager.php#L259-L272
hackzilla/ticket-message
Manager/TicketManager.php
TicketManager.getTicketPriority
public function getTicketPriority($priorityStr) { static $priorities = false; if ($priorities === false) { $priorities = []; foreach (TicketMessageInterface::PRIORITIES as $id => $value) { $priorities[$id] = $this->translate($value); } } return \array_search($priorityStr, $priorities); }
php
public function getTicketPriority($priorityStr) { static $priorities = false; if ($priorities === false) { $priorities = []; foreach (TicketMessageInterface::PRIORITIES as $id => $value) { $priorities[$id] = $this->translate($value); } } return \array_search($priorityStr, $priorities); }
[ "public", "function", "getTicketPriority", "(", "$", "priorityStr", ")", "{", "static", "$", "priorities", "=", "false", ";", "if", "(", "$", "priorities", "===", "false", ")", "{", "$", "priorities", "=", "[", "]", ";", "foreach", "(", "TicketMessageInterface", "::", "PRIORITIES", "as", "$", "id", "=>", "$", "value", ")", "{", "$", "priorities", "[", "$", "id", "]", "=", "$", "this", "->", "translate", "(", "$", "value", ")", ";", "}", "}", "return", "\\", "array_search", "(", "$", "priorityStr", ",", "$", "priorities", ")", ";", "}" ]
Lookup priority code. @param string $priorityStr @return int
[ "Lookup", "priority", "code", "." ]
train
https://github.com/hackzilla/ticket-message/blob/043950aa95f322cfaae145ce3c7781a4b0618a18/Manager/TicketManager.php#L281-L294
hackzilla/ticket-message
Manager/TicketManager.php
TicketManager.fireEvent
private function fireEvent($event, ...$params) { if (!$this->eventManager) { return; } $this->eventManager->handle($event, ...$params); }
php
private function fireEvent($event, ...$params) { if (!$this->eventManager) { return; } $this->eventManager->handle($event, ...$params); }
[ "private", "function", "fireEvent", "(", "$", "event", ",", "...", "$", "params", ")", "{", "if", "(", "!", "$", "this", "->", "eventManager", ")", "{", "return", ";", "}", "$", "this", "->", "eventManager", "->", "handle", "(", "$", "event", ",", "...", "$", "params", ")", ";", "}" ]
EventManager wrapper @param string $event @param array ...$params
[ "EventManager", "wrapper" ]
train
https://github.com/hackzilla/ticket-message/blob/043950aa95f322cfaae145ce3c7781a4b0618a18/Manager/TicketManager.php#L319-L326
PortaText/php-sdk
src/PortaText/Command/Api/CampaignLifecycle.php
CampaignLifecycle.getEndpoint
protected function getEndpoint($method) { $campaignId = $this->getArgument("id"); if (is_null($campaignId)) { throw new \InvalidArgumentException("Campaign id cant be null"); } $this->delArgument("id"); return "campaigns/$campaignId/lifecycle"; }
php
protected function getEndpoint($method) { $campaignId = $this->getArgument("id"); if (is_null($campaignId)) { throw new \InvalidArgumentException("Campaign id cant be null"); } $this->delArgument("id"); return "campaigns/$campaignId/lifecycle"; }
[ "protected", "function", "getEndpoint", "(", "$", "method", ")", "{", "$", "campaignId", "=", "$", "this", "->", "getArgument", "(", "\"id\"", ")", ";", "if", "(", "is_null", "(", "$", "campaignId", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Campaign id cant be null\"", ")", ";", "}", "$", "this", "->", "delArgument", "(", "\"id\"", ")", ";", "return", "\"campaigns/$campaignId/lifecycle\"", ";", "}" ]
Returns a string with the endpoint for the given command. @param string $method Method for this command. @return string
[ "Returns", "a", "string", "with", "the", "endpoint", "for", "the", "given", "command", "." ]
train
https://github.com/PortaText/php-sdk/blob/dbe04ef043db5b251953f9de57aa4d0f1785dfcc/src/PortaText/Command/Api/CampaignLifecycle.php#L80-L88
phpmob/changmin
src/PhpMob/ChangMinBundle/DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('changmin'); $rootNode ->children() ->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end() ->scalarNode('taxonomy')->defaultFalse()->end() ->end() ; $this->addTransitionConfig($rootNode); return $treeBuilder; }
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('changmin'); $rootNode ->children() ->scalarNode('driver')->defaultValue(SyliusResourceBundle::DRIVER_DOCTRINE_ORM)->end() ->scalarNode('taxonomy')->defaultFalse()->end() ->end() ; $this->addTransitionConfig($rootNode); return $treeBuilder; }
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'changmin'", ")", ";", "$", "rootNode", "->", "children", "(", ")", "->", "scalarNode", "(", "'driver'", ")", "->", "defaultValue", "(", "SyliusResourceBundle", "::", "DRIVER_DOCTRINE_ORM", ")", "->", "end", "(", ")", "->", "scalarNode", "(", "'taxonomy'", ")", "->", "defaultFalse", "(", ")", "->", "end", "(", ")", "->", "end", "(", ")", ";", "$", "this", "->", "addTransitionConfig", "(", "$", "rootNode", ")", ";", "return", "$", "treeBuilder", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/phpmob/changmin/blob/bfebb1561229094d1c138574abab75f2f1d17d66/src/PhpMob/ChangMinBundle/DependencyInjection/Configuration.php#L27-L42
xltxlm/logger
src/Log/DefineLog.php
DefineLog.resetUniqids
public static function resetUniqids() { $posix_getpid = posix_getpid(); unset(self::$uniqids[$posix_getpid]); unset(self::$i[$posix_getpid]); //重新设置数据库的值 PdoConfig::unsetAllinstance(); }
php
public static function resetUniqids() { $posix_getpid = posix_getpid(); unset(self::$uniqids[$posix_getpid]); unset(self::$i[$posix_getpid]); //重新设置数据库的值 PdoConfig::unsetAllinstance(); }
[ "public", "static", "function", "resetUniqids", "(", ")", "{", "$", "posix_getpid", "=", "posix_getpid", "(", ")", ";", "unset", "(", "self", "::", "$", "uniqids", "[", "$", "posix_getpid", "]", ")", ";", "unset", "(", "self", "::", "$", "i", "[", "$", "posix_getpid", "]", ")", ";", "//重新设置数据库的值", "PdoConfig", "::", "unsetAllinstance", "(", ")", ";", "}" ]
如果是处理队列类型的数据,每处理一次数据,重置一下日志的唯一标志
[ "如果是处理队列类型的数据,每处理一次数据,重置一下日志的唯一标志" ]
train
https://github.com/xltxlm/logger/blob/09592eeac38c6760bb4faabef939dd542f69b056/src/Log/DefineLog.php#L395-L402
xltxlm/logger
src/Log/DefineLog.php
DefineLog.setMessage
public function setMessage($message) { if (is_object($message)) { $message = (new ConvertObject($message)) ->toArray(); } $this->message = $message; return $this; }
php
public function setMessage($message) { if (is_object($message)) { $message = (new ConvertObject($message)) ->toArray(); } $this->message = $message; return $this; }
[ "public", "function", "setMessage", "(", "$", "message", ")", "{", "if", "(", "is_object", "(", "$", "message", ")", ")", "{", "$", "message", "=", "(", "new", "ConvertObject", "(", "$", "message", ")", ")", "->", "toArray", "(", ")", ";", "}", "$", "this", "->", "message", "=", "$", "message", ";", "return", "$", "this", ";", "}" ]
@param mixed $message @return $this
[ "@param", "mixed", "$message" ]
train
https://github.com/xltxlm/logger/blob/09592eeac38c6760bb4faabef939dd542f69b056/src/Log/DefineLog.php#L668-L676
kattsoftware/phassets
src/Phassets/Deployers/FilesystemDeployer.php
FilesystemDeployer.isPreviouslyDeployed
public function isPreviouslyDeployed(Asset $asset) { // Is there any previous deployed version? $outputBasename = $this->computeOutputBasename($asset); $file = $this->destinationPath . DIRECTORY_SEPARATOR . $outputBasename; if (is_file($file)) { $objectUrl = $this->baseUrl . '/' . $outputBasename; $asset->setOutputUrl($objectUrl); return true; } return false; }
php
public function isPreviouslyDeployed(Asset $asset) { // Is there any previous deployed version? $outputBasename = $this->computeOutputBasename($asset); $file = $this->destinationPath . DIRECTORY_SEPARATOR . $outputBasename; if (is_file($file)) { $objectUrl = $this->baseUrl . '/' . $outputBasename; $asset->setOutputUrl($objectUrl); return true; } return false; }
[ "public", "function", "isPreviouslyDeployed", "(", "Asset", "$", "asset", ")", "{", "// Is there any previous deployed version?", "$", "outputBasename", "=", "$", "this", "->", "computeOutputBasename", "(", "$", "asset", ")", ";", "$", "file", "=", "$", "this", "->", "destinationPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "outputBasename", ";", "if", "(", "is_file", "(", "$", "file", ")", ")", "{", "$", "objectUrl", "=", "$", "this", "->", "baseUrl", ".", "'/'", ".", "$", "outputBasename", ";", "$", "asset", "->", "setOutputUrl", "(", "$", "objectUrl", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Attempt to retrieve a previously deployed asset; if it does exist, then update the Asset instance's outputUrl property, without performing any further filters' actions. fullPath and outputExtension are set at this point in the Asset instance. @param Asset $asset @return bool Whether the Asset was previously deployed or not; If yes, then Asset's outputUrl property will be updated.
[ "Attempt", "to", "retrieve", "a", "previously", "deployed", "asset", ";", "if", "it", "does", "exist", "then", "update", "the", "Asset", "instance", "s", "outputUrl", "property", "without", "performing", "any", "further", "filters", "actions", ".", "fullPath", "and", "outputExtension", "are", "set", "at", "this", "point", "in", "the", "Asset", "instance", "." ]
train
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Deployers/FilesystemDeployer.php#L59-L73
kattsoftware/phassets
src/Phassets/Deployers/FilesystemDeployer.php
FilesystemDeployer.deploy
public function deploy(Asset $asset) { $outputBasename = $this->computeOutputBasename($asset); $fullPath = $this->destinationPath . DIRECTORY_SEPARATOR . $outputBasename; $saving = file_put_contents($fullPath, $asset->getContents()); if($saving === false) { throw new PhassetsInternalException( 'file_put_contents() could not write to ' . $fullPath . '. It is writable?' ); } $objectUrl = $this->baseUrl . '/' . $outputBasename; $asset->setOutputUrl($objectUrl); }
php
public function deploy(Asset $asset) { $outputBasename = $this->computeOutputBasename($asset); $fullPath = $this->destinationPath . DIRECTORY_SEPARATOR . $outputBasename; $saving = file_put_contents($fullPath, $asset->getContents()); if($saving === false) { throw new PhassetsInternalException( 'file_put_contents() could not write to ' . $fullPath . '. It is writable?' ); } $objectUrl = $this->baseUrl . '/' . $outputBasename; $asset->setOutputUrl($objectUrl); }
[ "public", "function", "deploy", "(", "Asset", "$", "asset", ")", "{", "$", "outputBasename", "=", "$", "this", "->", "computeOutputBasename", "(", "$", "asset", ")", ";", "$", "fullPath", "=", "$", "this", "->", "destinationPath", ".", "DIRECTORY_SEPARATOR", ".", "$", "outputBasename", ";", "$", "saving", "=", "file_put_contents", "(", "$", "fullPath", ",", "$", "asset", "->", "getContents", "(", ")", ")", ";", "if", "(", "$", "saving", "===", "false", ")", "{", "throw", "new", "PhassetsInternalException", "(", "'file_put_contents() could not write to '", ".", "$", "fullPath", ".", "'. It is writable?'", ")", ";", "}", "$", "objectUrl", "=", "$", "this", "->", "baseUrl", ".", "'/'", ".", "$", "outputBasename", ";", "$", "asset", "->", "setOutputUrl", "(", "$", "objectUrl", ")", ";", "}" ]
Given an Asset instance, try to deploy is using internal rules of this deployer and update Asset's property outputUrl. @param Asset $asset Asset instance whose outputUrl property will be modified @throws PhassetsInternalException If the deployment process fails
[ "Given", "an", "Asset", "instance", "try", "to", "deploy", "is", "using", "internal", "rules", "of", "this", "deployer", "and", "update", "Asset", "s", "property", "outputUrl", "." ]
train
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Deployers/FilesystemDeployer.php#L82-L99
kattsoftware/phassets
src/Phassets/Deployers/FilesystemDeployer.php
FilesystemDeployer.isSupported
public function isSupported() { $this->destinationPath = $this->configurator->getConfig('filesystem_deployer', 'destination_path'); $this->baseUrl = $this->configurator->getConfig('filesystem_deployer', 'base_url'); $this->trigger = $this->configurator->getConfig('filesystem_deployer', 'changes_trigger'); if ($this->destinationPath === null) { throw new PhassetsInternalException(__CLASS__ . ': no "destination_path" setting found'); } if (!is_dir($this->destinationPath) || !is_writable($this->destinationPath)) { throw new PhassetsInternalException(__CLASS__ . ": 'destination_path' ({$this->destinationPath}) is " . 'either not a valid dir, nor writable.' ); } }
php
public function isSupported() { $this->destinationPath = $this->configurator->getConfig('filesystem_deployer', 'destination_path'); $this->baseUrl = $this->configurator->getConfig('filesystem_deployer', 'base_url'); $this->trigger = $this->configurator->getConfig('filesystem_deployer', 'changes_trigger'); if ($this->destinationPath === null) { throw new PhassetsInternalException(__CLASS__ . ': no "destination_path" setting found'); } if (!is_dir($this->destinationPath) || !is_writable($this->destinationPath)) { throw new PhassetsInternalException(__CLASS__ . ": 'destination_path' ({$this->destinationPath}) is " . 'either not a valid dir, nor writable.' ); } }
[ "public", "function", "isSupported", "(", ")", "{", "$", "this", "->", "destinationPath", "=", "$", "this", "->", "configurator", "->", "getConfig", "(", "'filesystem_deployer'", ",", "'destination_path'", ")", ";", "$", "this", "->", "baseUrl", "=", "$", "this", "->", "configurator", "->", "getConfig", "(", "'filesystem_deployer'", ",", "'base_url'", ")", ";", "$", "this", "->", "trigger", "=", "$", "this", "->", "configurator", "->", "getConfig", "(", "'filesystem_deployer'", ",", "'changes_trigger'", ")", ";", "if", "(", "$", "this", "->", "destinationPath", "===", "null", ")", "{", "throw", "new", "PhassetsInternalException", "(", "__CLASS__", ".", "': no \"destination_path\" setting found'", ")", ";", "}", "if", "(", "!", "is_dir", "(", "$", "this", "->", "destinationPath", ")", "||", "!", "is_writable", "(", "$", "this", "->", "destinationPath", ")", ")", "{", "throw", "new", "PhassetsInternalException", "(", "__CLASS__", ".", "\": 'destination_path' ({$this->destinationPath}) is \"", ".", "'either not a valid dir, nor writable.'", ")", ";", "}", "}" ]
This must throw a PhassetsInternalException if the current configuration doesn't allow this deployer to deploy processed assets. @throws PhassetsInternalException If at this time Phassets can't use this deployer to deploy and serve deployed assets
[ "This", "must", "throw", "a", "PhassetsInternalException", "if", "the", "current", "configuration", "doesn", "t", "allow", "this", "deployer", "to", "deploy", "processed", "assets", "." ]
train
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Deployers/FilesystemDeployer.php#L108-L123
kattsoftware/phassets
src/Phassets/Deployers/FilesystemDeployer.php
FilesystemDeployer.computeOutputBasename
private function computeOutputBasename(Asset $asset) { $ext = $asset->getOutputExtension() ? '.' . $asset->getOutputExtension() : ''; switch ($this->trigger) { case 'md5': $suffix = $asset->getMd5(); break; case 'sha1': $suffix = $asset->getSha1(); break; case 'filemtime': default: $suffix = $asset->getModifiedTimestamp(); } return $asset->getFilename() . '_' . $suffix . $ext; }
php
private function computeOutputBasename(Asset $asset) { $ext = $asset->getOutputExtension() ? '.' . $asset->getOutputExtension() : ''; switch ($this->trigger) { case 'md5': $suffix = $asset->getMd5(); break; case 'sha1': $suffix = $asset->getSha1(); break; case 'filemtime': default: $suffix = $asset->getModifiedTimestamp(); } return $asset->getFilename() . '_' . $suffix . $ext; }
[ "private", "function", "computeOutputBasename", "(", "Asset", "$", "asset", ")", "{", "$", "ext", "=", "$", "asset", "->", "getOutputExtension", "(", ")", "?", "'.'", ".", "$", "asset", "->", "getOutputExtension", "(", ")", ":", "''", ";", "switch", "(", "$", "this", "->", "trigger", ")", "{", "case", "'md5'", ":", "$", "suffix", "=", "$", "asset", "->", "getMd5", "(", ")", ";", "break", ";", "case", "'sha1'", ":", "$", "suffix", "=", "$", "asset", "->", "getSha1", "(", ")", ";", "break", ";", "case", "'filemtime'", ":", "default", ":", "$", "suffix", "=", "$", "asset", "->", "getModifiedTimestamp", "(", ")", ";", "}", "return", "$", "asset", "->", "getFilename", "(", ")", ".", "'_'", ".", "$", "suffix", ".", "$", "ext", ";", "}" ]
Generates the output full file name of an Asset instance. Pattern: <filename>_<triggering_asset_value>[.<output_extension>] @param Asset $asset @return string Generated basename of asset
[ "Generates", "the", "output", "full", "file", "name", "of", "an", "Asset", "instance", ".", "Pattern", ":", "<filename", ">", "_<triggering_asset_value", ">", "[", ".", "<output_extension", ">", "]" ]
train
https://github.com/kattsoftware/phassets/blob/cc982cf1941eb5776287d64f027218bd4835ed2b/src/Phassets/Deployers/FilesystemDeployer.php#L132-L149
dunkelfrosch/phpcoverfish
src/PHPCoverFish/Common/CoverFishMessageWarning.php
CoverFishMessageWarning.getWarningStreamTemplate
public function getWarningStreamTemplate(CoverFishMapping $coverMapping, $noAnsiColors = false) { $coverLine = null; switch ($this->getMessageCode()) { case self::PHPUNIT_NO_COVERAGE_FOR_METHOD: $coverLine = sprintf('no @covers annotation for %s::%s', $coverMapping->getClassFQN(), $coverMapping->getMethod()); if (!$noAnsiColors) { $coverLine = Color::tplNormalColor('no @covers annotation for '); $coverLine .= Color::tplYellowColor($coverMapping->getClassFQN()); $coverLine .= Color::tplYellowColor('::' . $coverMapping->getMethod()); } if (null === $coverMapping->getMethod()) { $coverLine = str_replace('::', null, $coverLine); } break; case self::PHPUNIT_NO_DOCBLOCK_FOR_METHOD: $coverLine = sprintf('no phpdoc block for %s::%s', $coverMapping->getClassFQN(), $coverMapping->getMethod()); if (!$noAnsiColors) { $coverLine = Color::tplNormalColor('no phpdoc block for '); $coverLine .= Color::tplYellowColor($coverMapping->getClassFQN()); $coverLine .= Color::tplYellowColor('::' . $coverMapping->getMethod()); } if (null === $coverMapping->getMethod()) { $coverLine = str_replace('::', null, $coverLine); } break; default: break; } return $coverLine; }
php
public function getWarningStreamTemplate(CoverFishMapping $coverMapping, $noAnsiColors = false) { $coverLine = null; switch ($this->getMessageCode()) { case self::PHPUNIT_NO_COVERAGE_FOR_METHOD: $coverLine = sprintf('no @covers annotation for %s::%s', $coverMapping->getClassFQN(), $coverMapping->getMethod()); if (!$noAnsiColors) { $coverLine = Color::tplNormalColor('no @covers annotation for '); $coverLine .= Color::tplYellowColor($coverMapping->getClassFQN()); $coverLine .= Color::tplYellowColor('::' . $coverMapping->getMethod()); } if (null === $coverMapping->getMethod()) { $coverLine = str_replace('::', null, $coverLine); } break; case self::PHPUNIT_NO_DOCBLOCK_FOR_METHOD: $coverLine = sprintf('no phpdoc block for %s::%s', $coverMapping->getClassFQN(), $coverMapping->getMethod()); if (!$noAnsiColors) { $coverLine = Color::tplNormalColor('no phpdoc block for '); $coverLine .= Color::tplYellowColor($coverMapping->getClassFQN()); $coverLine .= Color::tplYellowColor('::' . $coverMapping->getMethod()); } if (null === $coverMapping->getMethod()) { $coverLine = str_replace('::', null, $coverLine); } break; default: break; } return $coverLine; }
[ "public", "function", "getWarningStreamTemplate", "(", "CoverFishMapping", "$", "coverMapping", ",", "$", "noAnsiColors", "=", "false", ")", "{", "$", "coverLine", "=", "null", ";", "switch", "(", "$", "this", "->", "getMessageCode", "(", ")", ")", "{", "case", "self", "::", "PHPUNIT_NO_COVERAGE_FOR_METHOD", ":", "$", "coverLine", "=", "sprintf", "(", "'no @covers annotation for %s::%s'", ",", "$", "coverMapping", "->", "getClassFQN", "(", ")", ",", "$", "coverMapping", "->", "getMethod", "(", ")", ")", ";", "if", "(", "!", "$", "noAnsiColors", ")", "{", "$", "coverLine", "=", "Color", "::", "tplNormalColor", "(", "'no @covers annotation for '", ")", ";", "$", "coverLine", ".=", "Color", "::", "tplYellowColor", "(", "$", "coverMapping", "->", "getClassFQN", "(", ")", ")", ";", "$", "coverLine", ".=", "Color", "::", "tplYellowColor", "(", "'::'", ".", "$", "coverMapping", "->", "getMethod", "(", ")", ")", ";", "}", "if", "(", "null", "===", "$", "coverMapping", "->", "getMethod", "(", ")", ")", "{", "$", "coverLine", "=", "str_replace", "(", "'::'", ",", "null", ",", "$", "coverLine", ")", ";", "}", "break", ";", "case", "self", "::", "PHPUNIT_NO_DOCBLOCK_FOR_METHOD", ":", "$", "coverLine", "=", "sprintf", "(", "'no phpdoc block for %s::%s'", ",", "$", "coverMapping", "->", "getClassFQN", "(", ")", ",", "$", "coverMapping", "->", "getMethod", "(", ")", ")", ";", "if", "(", "!", "$", "noAnsiColors", ")", "{", "$", "coverLine", "=", "Color", "::", "tplNormalColor", "(", "'no phpdoc block for '", ")", ";", "$", "coverLine", ".=", "Color", "::", "tplYellowColor", "(", "$", "coverMapping", "->", "getClassFQN", "(", ")", ")", ";", "$", "coverLine", ".=", "Color", "::", "tplYellowColor", "(", "'::'", ".", "$", "coverMapping", "->", "getMethod", "(", ")", ")", ";", "}", "if", "(", "null", "===", "$", "coverMapping", "->", "getMethod", "(", ")", ")", "{", "$", "coverLine", "=", "str_replace", "(", "'::'", ",", "null", ",", "$", "coverLine", ")", ";", "}", "break", ";", "default", ":", "break", ";", "}", "return", "$", "coverLine", ";", "}" ]
@param CoverFishMapping $coverMapping @param bool|false $noAnsiColors @return null|string
[ "@param", "CoverFishMapping", "$coverMapping", "@param", "bool|false", "$noAnsiColors" ]
train
https://github.com/dunkelfrosch/phpcoverfish/blob/779bd399ec8f4cadb3b7854200695c5eb3f5a8ad/src/PHPCoverFish/Common/CoverFishMessageWarning.php#L42-L79
CakeCMS/Core
src/Less/Less.php
Less.compile
public function compile($lessFile, $basePath = null) { try { $basePath = $this->_prepareBasepath($basePath, dirname($lessFile)); $cache = new Cache($this->_options); $cache->setFile($lessFile, $basePath); $isExpired = $cache->isExpired(); $isForce = $this->_options->get('force', false, 'bool'); if ($isForce || $cache->isExpired()) { $result = $this->_driver->compile($lessFile, $basePath); $cache->save($result); } $isExpired = ($isForce) ? true : $isExpired; $return = [FS::clean($cache->getFile(), '/'), $isExpired]; } catch (\Exception $e) { $message = 'Less error: ' . $e->getMessage(); throw new Exception($message); } return $return; }
php
public function compile($lessFile, $basePath = null) { try { $basePath = $this->_prepareBasepath($basePath, dirname($lessFile)); $cache = new Cache($this->_options); $cache->setFile($lessFile, $basePath); $isExpired = $cache->isExpired(); $isForce = $this->_options->get('force', false, 'bool'); if ($isForce || $cache->isExpired()) { $result = $this->_driver->compile($lessFile, $basePath); $cache->save($result); } $isExpired = ($isForce) ? true : $isExpired; $return = [FS::clean($cache->getFile(), '/'), $isExpired]; } catch (\Exception $e) { $message = 'Less error: ' . $e->getMessage(); throw new Exception($message); } return $return; }
[ "public", "function", "compile", "(", "$", "lessFile", ",", "$", "basePath", "=", "null", ")", "{", "try", "{", "$", "basePath", "=", "$", "this", "->", "_prepareBasepath", "(", "$", "basePath", ",", "dirname", "(", "$", "lessFile", ")", ")", ";", "$", "cache", "=", "new", "Cache", "(", "$", "this", "->", "_options", ")", ";", "$", "cache", "->", "setFile", "(", "$", "lessFile", ",", "$", "basePath", ")", ";", "$", "isExpired", "=", "$", "cache", "->", "isExpired", "(", ")", ";", "$", "isForce", "=", "$", "this", "->", "_options", "->", "get", "(", "'force'", ",", "false", ",", "'bool'", ")", ";", "if", "(", "$", "isForce", "||", "$", "cache", "->", "isExpired", "(", ")", ")", "{", "$", "result", "=", "$", "this", "->", "_driver", "->", "compile", "(", "$", "lessFile", ",", "$", "basePath", ")", ";", "$", "cache", "->", "save", "(", "$", "result", ")", ";", "}", "$", "isExpired", "=", "(", "$", "isForce", ")", "?", "true", ":", "$", "isExpired", ";", "$", "return", "=", "[", "FS", "::", "clean", "(", "$", "cache", "->", "getFile", "(", ")", ",", "'/'", ")", ",", "$", "isExpired", "]", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "message", "=", "'Less error: '", ".", "$", "e", "->", "getMessage", "(", ")", ";", "throw", "new", "Exception", "(", "$", "message", ")", ";", "}", "return", "$", "return", ";", "}" ]
Compile less file. @param string $lessFile @param null|string $basePath @return array @throws Exception
[ "Compile", "less", "file", "." ]
train
https://github.com/CakeCMS/Core/blob/f9cba7aa0043a10e5c35bd45fbad158688a09a96/src/Less/Less.php#L38-L63
fubhy/graphql-php
src/Executor/Values.php
Values.getVariableValues
public static function getVariableValues(Schema $schema, array $asts, array $inputs) { $values = []; foreach ($asts as $ast) { $variable = $ast->get('variable')->get('name')->get('value'); $values[$variable] = self::getvariableValue($schema, $ast, isset($inputs[$variable]) ? $inputs[$variable] : NULL); } return $values; }
php
public static function getVariableValues(Schema $schema, array $asts, array $inputs) { $values = []; foreach ($asts as $ast) { $variable = $ast->get('variable')->get('name')->get('value'); $values[$variable] = self::getvariableValue($schema, $ast, isset($inputs[$variable]) ? $inputs[$variable] : NULL); } return $values; }
[ "public", "static", "function", "getVariableValues", "(", "Schema", "$", "schema", ",", "array", "$", "asts", ",", "array", "$", "inputs", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "asts", "as", "$", "ast", ")", "{", "$", "variable", "=", "$", "ast", "->", "get", "(", "'variable'", ")", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", ";", "$", "values", "[", "$", "variable", "]", "=", "self", "::", "getvariableValue", "(", "$", "schema", ",", "$", "ast", ",", "isset", "(", "$", "inputs", "[", "$", "variable", "]", ")", "?", "$", "inputs", "[", "$", "variable", "]", ":", "NULL", ")", ";", "}", "return", "$", "values", ";", "}" ]
Prepares an object map of variables of the correct type based on the provided variable definitions and arbitrary input. If the input cannot be coerced to match the variable definitions, a Error will be thrown. @param Schema $schema @param array $asts @param array $inputs @return array @throws \Exception
[ "Prepares", "an", "object", "map", "of", "variables", "of", "the", "correct", "type", "based", "on", "the", "provided", "variable", "definitions", "and", "arbitrary", "input", ".", "If", "the", "input", "cannot", "be", "coerced", "to", "match", "the", "variable", "definitions", "a", "Error", "will", "be", "thrown", "." ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Values.php#L33-L41
fubhy/graphql-php
src/Executor/Values.php
Values.getArgumentValues
public static function getArgumentValues($arguments, $asts, $variables) { if (!$arguments || count($arguments) === 0) { return NULL; } $map = array_reduce($asts, function ($carry, $argument) { $carry[$argument->get('name')->get('value')] = $argument; return $carry; }, []); $result = []; foreach ($arguments as $argument) { $name = $argument->getName(); $value = isset($map[$name]) ? $map[$name]->get('value') : NULL; $result[$name] = self::coerceValueAST($argument->getType(), $value, $variables); } return $result; }
php
public static function getArgumentValues($arguments, $asts, $variables) { if (!$arguments || count($arguments) === 0) { return NULL; } $map = array_reduce($asts, function ($carry, $argument) { $carry[$argument->get('name')->get('value')] = $argument; return $carry; }, []); $result = []; foreach ($arguments as $argument) { $name = $argument->getName(); $value = isset($map[$name]) ? $map[$name]->get('value') : NULL; $result[$name] = self::coerceValueAST($argument->getType(), $value, $variables); } return $result; }
[ "public", "static", "function", "getArgumentValues", "(", "$", "arguments", ",", "$", "asts", ",", "$", "variables", ")", "{", "if", "(", "!", "$", "arguments", "||", "count", "(", "$", "arguments", ")", "===", "0", ")", "{", "return", "NULL", ";", "}", "$", "map", "=", "array_reduce", "(", "$", "asts", ",", "function", "(", "$", "carry", ",", "$", "argument", ")", "{", "$", "carry", "[", "$", "argument", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", "]", "=", "$", "argument", ";", "return", "$", "carry", ";", "}", ",", "[", "]", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "arguments", "as", "$", "argument", ")", "{", "$", "name", "=", "$", "argument", "->", "getName", "(", ")", ";", "$", "value", "=", "isset", "(", "$", "map", "[", "$", "name", "]", ")", "?", "$", "map", "[", "$", "name", "]", "->", "get", "(", "'value'", ")", ":", "NULL", ";", "$", "result", "[", "$", "name", "]", "=", "self", "::", "coerceValueAST", "(", "$", "argument", "->", "getType", "(", ")", ",", "$", "value", ",", "$", "variables", ")", ";", "}", "return", "$", "result", ";", "}" ]
Prepares an object map of argument values given a list of argument definitions and list of argument AST nodes. @param $arguments @param $asts @param $variables @return array|null
[ "Prepares", "an", "object", "map", "of", "argument", "values", "given", "a", "list", "of", "argument", "definitions", "and", "list", "of", "argument", "AST", "nodes", "." ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Values.php#L53-L71
fubhy/graphql-php
src/Executor/Values.php
Values.getDirectiveValue
public static function getDirectiveValue(DirectiveInterface $definition, $directives, $variables) { $ast = NULL; if ($directives) { foreach ($directives as $directive) { if ($directive->get('name')->get('value') === $definition->getName()) { $ast = $directive; break; } } } if ($ast) { if (!$definition->getType()) { return NULL; } return self::coerceValueAST($definition->getType(), $ast->get('value'), $variables); } }
php
public static function getDirectiveValue(DirectiveInterface $definition, $directives, $variables) { $ast = NULL; if ($directives) { foreach ($directives as $directive) { if ($directive->get('name')->get('value') === $definition->getName()) { $ast = $directive; break; } } } if ($ast) { if (!$definition->getType()) { return NULL; } return self::coerceValueAST($definition->getType(), $ast->get('value'), $variables); } }
[ "public", "static", "function", "getDirectiveValue", "(", "DirectiveInterface", "$", "definition", ",", "$", "directives", ",", "$", "variables", ")", "{", "$", "ast", "=", "NULL", ";", "if", "(", "$", "directives", ")", "{", "foreach", "(", "$", "directives", "as", "$", "directive", ")", "{", "if", "(", "$", "directive", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", "===", "$", "definition", "->", "getName", "(", ")", ")", "{", "$", "ast", "=", "$", "directive", ";", "break", ";", "}", "}", "}", "if", "(", "$", "ast", ")", "{", "if", "(", "!", "$", "definition", "->", "getType", "(", ")", ")", "{", "return", "NULL", ";", "}", "return", "self", "::", "coerceValueAST", "(", "$", "definition", "->", "getType", "(", ")", ",", "$", "ast", "->", "get", "(", "'value'", ")", ",", "$", "variables", ")", ";", "}", "}" ]
@param DirectiveInterface $definition @param $directives @param $variables @return array|mixed|null|string
[ "@param", "DirectiveInterface", "$definition", "@param", "$directives", "@param", "$variables" ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Values.php#L80-L98
fubhy/graphql-php
src/Executor/Values.php
Values.getVariableValue
protected static function getVariableValue(Schema $schema, VariableDefinition $definition, $input) { $type = TypeInfo::typeFromAST($schema, $definition->get('type')); if (!$type) { return NULL; } if (self::isValidValue($type, $input)) { if (!isset($input)) { $default = $definition->get('defaultValue'); if ($default) { return self::coerceValueAST($type, $default); } } return self::coerceValue($type, $input); } // @todo Fix exception message once printer is ported. throw new \Exception(sprintf('Variable $%s expected value of different type.', $definition->get('variable')->get('name')->get('value'))); }
php
protected static function getVariableValue(Schema $schema, VariableDefinition $definition, $input) { $type = TypeInfo::typeFromAST($schema, $definition->get('type')); if (!$type) { return NULL; } if (self::isValidValue($type, $input)) { if (!isset($input)) { $default = $definition->get('defaultValue'); if ($default) { return self::coerceValueAST($type, $default); } } return self::coerceValue($type, $input); } // @todo Fix exception message once printer is ported. throw new \Exception(sprintf('Variable $%s expected value of different type.', $definition->get('variable')->get('name')->get('value'))); }
[ "protected", "static", "function", "getVariableValue", "(", "Schema", "$", "schema", ",", "VariableDefinition", "$", "definition", ",", "$", "input", ")", "{", "$", "type", "=", "TypeInfo", "::", "typeFromAST", "(", "$", "schema", ",", "$", "definition", "->", "get", "(", "'type'", ")", ")", ";", "if", "(", "!", "$", "type", ")", "{", "return", "NULL", ";", "}", "if", "(", "self", "::", "isValidValue", "(", "$", "type", ",", "$", "input", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "input", ")", ")", "{", "$", "default", "=", "$", "definition", "->", "get", "(", "'defaultValue'", ")", ";", "if", "(", "$", "default", ")", "{", "return", "self", "::", "coerceValueAST", "(", "$", "type", ",", "$", "default", ")", ";", "}", "}", "return", "self", "::", "coerceValue", "(", "$", "type", ",", "$", "input", ")", ";", "}", "// @todo Fix exception message once printer is ported.", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Variable $%s expected value of different type.'", ",", "$", "definition", "->", "get", "(", "'variable'", ")", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", ")", ")", ";", "}" ]
Given a variable definition, and any value of input, return a value which adheres to the variable definition, or throw an error. @param Schema $schema @param VariableDefinition $definition @param $input @return array|mixed|null|string @throws \Exception
[ "Given", "a", "variable", "definition", "and", "any", "value", "of", "input", "return", "a", "value", "which", "adheres", "to", "the", "variable", "definition", "or", "throw", "an", "error", "." ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Values.php#L112-L133
fubhy/graphql-php
src/Executor/Values.php
Values.isValidValue
protected static function isValidValue(TypeInterface $type, $value) { if ($type instanceof NonNullModifier) { if (NULL === $value) { return FALSE; } return self::isValidValue($type->getWrappedType(), $value); } if ($value === NULL) { return TRUE; } if ($type instanceof ListModifier) { $itemType = $type->getWrappedType(); if (is_array($value)) { foreach ($value as $item) { if (!self::isValidValue($itemType, $item)) { return FALSE; } } return TRUE; } else { return self::isValidValue($itemType, $value); } } if ($type instanceof InputObjectType) { $fields = $type->getFields(); foreach ($fields as $fieldName => $field) { if (!self::isValidValue($field->getType(), isset($value[$fieldName]) ? $value[$fieldName] : NULL)) { return FALSE; } } return TRUE; } if ($type instanceof ScalarType || $type instanceof EnumType) { return NULL !== $type->coerce($value); } return FALSE; }
php
protected static function isValidValue(TypeInterface $type, $value) { if ($type instanceof NonNullModifier) { if (NULL === $value) { return FALSE; } return self::isValidValue($type->getWrappedType(), $value); } if ($value === NULL) { return TRUE; } if ($type instanceof ListModifier) { $itemType = $type->getWrappedType(); if (is_array($value)) { foreach ($value as $item) { if (!self::isValidValue($itemType, $item)) { return FALSE; } } return TRUE; } else { return self::isValidValue($itemType, $value); } } if ($type instanceof InputObjectType) { $fields = $type->getFields(); foreach ($fields as $fieldName => $field) { if (!self::isValidValue($field->getType(), isset($value[$fieldName]) ? $value[$fieldName] : NULL)) { return FALSE; } } return TRUE; } if ($type instanceof ScalarType || $type instanceof EnumType) { return NULL !== $type->coerce($value); } return FALSE; }
[ "protected", "static", "function", "isValidValue", "(", "TypeInterface", "$", "type", ",", "$", "value", ")", "{", "if", "(", "$", "type", "instanceof", "NonNullModifier", ")", "{", "if", "(", "NULL", "===", "$", "value", ")", "{", "return", "FALSE", ";", "}", "return", "self", "::", "isValidValue", "(", "$", "type", "->", "getWrappedType", "(", ")", ",", "$", "value", ")", ";", "}", "if", "(", "$", "value", "===", "NULL", ")", "{", "return", "TRUE", ";", "}", "if", "(", "$", "type", "instanceof", "ListModifier", ")", "{", "$", "itemType", "=", "$", "type", "->", "getWrappedType", "(", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "item", ")", "{", "if", "(", "!", "self", "::", "isValidValue", "(", "$", "itemType", ",", "$", "item", ")", ")", "{", "return", "FALSE", ";", "}", "}", "return", "TRUE", ";", "}", "else", "{", "return", "self", "::", "isValidValue", "(", "$", "itemType", ",", "$", "value", ")", ";", "}", "}", "if", "(", "$", "type", "instanceof", "InputObjectType", ")", "{", "$", "fields", "=", "$", "type", "->", "getFields", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "fieldName", "=>", "$", "field", ")", "{", "if", "(", "!", "self", "::", "isValidValue", "(", "$", "field", "->", "getType", "(", ")", ",", "isset", "(", "$", "value", "[", "$", "fieldName", "]", ")", "?", "$", "value", "[", "$", "fieldName", "]", ":", "NULL", ")", ")", "{", "return", "FALSE", ";", "}", "}", "return", "TRUE", ";", "}", "if", "(", "$", "type", "instanceof", "ScalarType", "||", "$", "type", "instanceof", "EnumType", ")", "{", "return", "NULL", "!==", "$", "type", "->", "coerce", "(", "$", "value", ")", ";", "}", "return", "FALSE", ";", "}" ]
Given a type and any value, return true if that value is valid. @param TypeInterface $type @param $value @return bool
[ "Given", "a", "type", "and", "any", "value", "return", "true", "if", "that", "value", "is", "valid", "." ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Values.php#L143-L188
fubhy/graphql-php
src/Executor/Values.php
Values.coerceValue
protected static function coerceValue(TypeInterface $type, $value) { if ($type instanceof NonNullModifier) { // Note: we're not checking that the result of coerceValue is non-null. // We only call this function after calling isValidValue. return self::coerceValue($type->getWrappedType(), $value); } if (!isset($value)) { return NULL; } if ($type instanceof ListModifier) { $itemType = $type->getWrappedType(); if (is_array($value)) { return array_map(function ($item) use ($itemType) { return Values::coerceValue($itemType, $item); }, $value); } else { return [self::coerceValue($itemType, $value)]; } } if ($type instanceof InputObjectType) { $fields = $type->getFields(); $object = []; foreach ($fields as $fieldName => $field) { $fieldValue = self::coerceValue($field->getType(), $value[$fieldName]); $object[$fieldName] = $fieldValue === NULL ? $field->getDefaultValue() : $fieldValue; } return $object; } if ($type instanceof ScalarType || $type instanceof EnumType) { $coerced = $type->coerce($value); if (NULL !== $coerced) { return $coerced; } } return NULL; }
php
protected static function coerceValue(TypeInterface $type, $value) { if ($type instanceof NonNullModifier) { // Note: we're not checking that the result of coerceValue is non-null. // We only call this function after calling isValidValue. return self::coerceValue($type->getWrappedType(), $value); } if (!isset($value)) { return NULL; } if ($type instanceof ListModifier) { $itemType = $type->getWrappedType(); if (is_array($value)) { return array_map(function ($item) use ($itemType) { return Values::coerceValue($itemType, $item); }, $value); } else { return [self::coerceValue($itemType, $value)]; } } if ($type instanceof InputObjectType) { $fields = $type->getFields(); $object = []; foreach ($fields as $fieldName => $field) { $fieldValue = self::coerceValue($field->getType(), $value[$fieldName]); $object[$fieldName] = $fieldValue === NULL ? $field->getDefaultValue() : $fieldValue; } return $object; } if ($type instanceof ScalarType || $type instanceof EnumType) { $coerced = $type->coerce($value); if (NULL !== $coerced) { return $coerced; } } return NULL; }
[ "protected", "static", "function", "coerceValue", "(", "TypeInterface", "$", "type", ",", "$", "value", ")", "{", "if", "(", "$", "type", "instanceof", "NonNullModifier", ")", "{", "// Note: we're not checking that the result of coerceValue is non-null.", "// We only call this function after calling isValidValue.", "return", "self", "::", "coerceValue", "(", "$", "type", "->", "getWrappedType", "(", ")", ",", "$", "value", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "value", ")", ")", "{", "return", "NULL", ";", "}", "if", "(", "$", "type", "instanceof", "ListModifier", ")", "{", "$", "itemType", "=", "$", "type", "->", "getWrappedType", "(", ")", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "return", "array_map", "(", "function", "(", "$", "item", ")", "use", "(", "$", "itemType", ")", "{", "return", "Values", "::", "coerceValue", "(", "$", "itemType", ",", "$", "item", ")", ";", "}", ",", "$", "value", ")", ";", "}", "else", "{", "return", "[", "self", "::", "coerceValue", "(", "$", "itemType", ",", "$", "value", ")", "]", ";", "}", "}", "if", "(", "$", "type", "instanceof", "InputObjectType", ")", "{", "$", "fields", "=", "$", "type", "->", "getFields", "(", ")", ";", "$", "object", "=", "[", "]", ";", "foreach", "(", "$", "fields", "as", "$", "fieldName", "=>", "$", "field", ")", "{", "$", "fieldValue", "=", "self", "::", "coerceValue", "(", "$", "field", "->", "getType", "(", ")", ",", "$", "value", "[", "$", "fieldName", "]", ")", ";", "$", "object", "[", "$", "fieldName", "]", "=", "$", "fieldValue", "===", "NULL", "?", "$", "field", "->", "getDefaultValue", "(", ")", ":", "$", "fieldValue", ";", "}", "return", "$", "object", ";", "}", "if", "(", "$", "type", "instanceof", "ScalarType", "||", "$", "type", "instanceof", "EnumType", ")", "{", "$", "coerced", "=", "$", "type", "->", "coerce", "(", "$", "value", ")", ";", "if", "(", "NULL", "!==", "$", "coerced", ")", "{", "return", "$", "coerced", ";", "}", "}", "return", "NULL", ";", "}" ]
Given a type and any value, return a runtime value coerced to match the type. @param TypeInterface $type @param $value @return array|mixed|null|string
[ "Given", "a", "type", "and", "any", "value", "return", "a", "runtime", "value", "coerced", "to", "match", "the", "type", "." ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Values.php#L199-L241
fubhy/graphql-php
src/Executor/Values.php
Values.coerceValueAST
protected static function coerceValueAST(TypeInterface $type, $ast, $variables = NULL) { if ($type instanceof NonNullModifier) { // Note: we're not checking that the result of coerceValueAST is non-null. // We're assuming that this query has been validated and the value used // here is of the correct type. return self::coerceValueAST($type->getWrappedType(), $ast, $variables); } if (!$ast) { return NULL; } if ($ast::KIND === Node::KIND_VARIABLE) { $variableName = $ast->get('name')->get('value'); if (!isset($variables, $variables[$variableName])) { return NULL; } // Note: we're not doing any checking that this variable is correct. We're // assuming that this query has been validated and the variable usage here // is of the correct type. return $variables[$variableName]; } if ($type instanceof ListModifier) { $itemType = $type->getWrappedType(); if ($ast::KIND === Node::KIND_ARRAY_VALUE) { $tmp = []; foreach ($ast->get('values') as $itemAST) { $tmp[] = self::coerceValueAST($itemType, $itemAST, $variables); } return $tmp; } else { return [self::coerceValueAST($itemType, $ast, $variables)]; } } if ($type instanceof InputObjectType) { $fields = $type->getFields(); if ($ast::KIND !== Node::KIND_OBJECT_VALUE) { return NULL; } $asts = array_reduce($ast->get('fields'), function ($carry, $field) { $carry[$field->get('name')->get('value')] = $field; return $carry; }, []); $object = []; foreach ($fields as $name => $item) { $field = $asts[$name]; $fieldValue = self::coerceValueAST($item->getType(), $field ? $field->get('value') : NULL, $variables); $object[$name] = $fieldValue === NULL ? $item->getDefaultValue() : $fieldValue; } return $object; } if ($type instanceof ScalarType || $type instanceof EnumType) { $coerced = $type->coerceLiteral($ast); if (isset($coerced)) { return $coerced; } } return NULL; }
php
protected static function coerceValueAST(TypeInterface $type, $ast, $variables = NULL) { if ($type instanceof NonNullModifier) { // Note: we're not checking that the result of coerceValueAST is non-null. // We're assuming that this query has been validated and the value used // here is of the correct type. return self::coerceValueAST($type->getWrappedType(), $ast, $variables); } if (!$ast) { return NULL; } if ($ast::KIND === Node::KIND_VARIABLE) { $variableName = $ast->get('name')->get('value'); if (!isset($variables, $variables[$variableName])) { return NULL; } // Note: we're not doing any checking that this variable is correct. We're // assuming that this query has been validated and the variable usage here // is of the correct type. return $variables[$variableName]; } if ($type instanceof ListModifier) { $itemType = $type->getWrappedType(); if ($ast::KIND === Node::KIND_ARRAY_VALUE) { $tmp = []; foreach ($ast->get('values') as $itemAST) { $tmp[] = self::coerceValueAST($itemType, $itemAST, $variables); } return $tmp; } else { return [self::coerceValueAST($itemType, $ast, $variables)]; } } if ($type instanceof InputObjectType) { $fields = $type->getFields(); if ($ast::KIND !== Node::KIND_OBJECT_VALUE) { return NULL; } $asts = array_reduce($ast->get('fields'), function ($carry, $field) { $carry[$field->get('name')->get('value')] = $field; return $carry; }, []); $object = []; foreach ($fields as $name => $item) { $field = $asts[$name]; $fieldValue = self::coerceValueAST($item->getType(), $field ? $field->get('value') : NULL, $variables); $object[$name] = $fieldValue === NULL ? $item->getDefaultValue() : $fieldValue; } return $object; } if ($type instanceof ScalarType || $type instanceof EnumType) { $coerced = $type->coerceLiteral($ast); if (isset($coerced)) { return $coerced; } } return NULL; }
[ "protected", "static", "function", "coerceValueAST", "(", "TypeInterface", "$", "type", ",", "$", "ast", ",", "$", "variables", "=", "NULL", ")", "{", "if", "(", "$", "type", "instanceof", "NonNullModifier", ")", "{", "// Note: we're not checking that the result of coerceValueAST is non-null.", "// We're assuming that this query has been validated and the value used", "// here is of the correct type.", "return", "self", "::", "coerceValueAST", "(", "$", "type", "->", "getWrappedType", "(", ")", ",", "$", "ast", ",", "$", "variables", ")", ";", "}", "if", "(", "!", "$", "ast", ")", "{", "return", "NULL", ";", "}", "if", "(", "$", "ast", "::", "KIND", "===", "Node", "::", "KIND_VARIABLE", ")", "{", "$", "variableName", "=", "$", "ast", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", ";", "if", "(", "!", "isset", "(", "$", "variables", ",", "$", "variables", "[", "$", "variableName", "]", ")", ")", "{", "return", "NULL", ";", "}", "// Note: we're not doing any checking that this variable is correct. We're", "// assuming that this query has been validated and the variable usage here", "// is of the correct type.", "return", "$", "variables", "[", "$", "variableName", "]", ";", "}", "if", "(", "$", "type", "instanceof", "ListModifier", ")", "{", "$", "itemType", "=", "$", "type", "->", "getWrappedType", "(", ")", ";", "if", "(", "$", "ast", "::", "KIND", "===", "Node", "::", "KIND_ARRAY_VALUE", ")", "{", "$", "tmp", "=", "[", "]", ";", "foreach", "(", "$", "ast", "->", "get", "(", "'values'", ")", "as", "$", "itemAST", ")", "{", "$", "tmp", "[", "]", "=", "self", "::", "coerceValueAST", "(", "$", "itemType", ",", "$", "itemAST", ",", "$", "variables", ")", ";", "}", "return", "$", "tmp", ";", "}", "else", "{", "return", "[", "self", "::", "coerceValueAST", "(", "$", "itemType", ",", "$", "ast", ",", "$", "variables", ")", "]", ";", "}", "}", "if", "(", "$", "type", "instanceof", "InputObjectType", ")", "{", "$", "fields", "=", "$", "type", "->", "getFields", "(", ")", ";", "if", "(", "$", "ast", "::", "KIND", "!==", "Node", "::", "KIND_OBJECT_VALUE", ")", "{", "return", "NULL", ";", "}", "$", "asts", "=", "array_reduce", "(", "$", "ast", "->", "get", "(", "'fields'", ")", ",", "function", "(", "$", "carry", ",", "$", "field", ")", "{", "$", "carry", "[", "$", "field", "->", "get", "(", "'name'", ")", "->", "get", "(", "'value'", ")", "]", "=", "$", "field", ";", "return", "$", "carry", ";", "}", ",", "[", "]", ")", ";", "$", "object", "=", "[", "]", ";", "foreach", "(", "$", "fields", "as", "$", "name", "=>", "$", "item", ")", "{", "$", "field", "=", "$", "asts", "[", "$", "name", "]", ";", "$", "fieldValue", "=", "self", "::", "coerceValueAST", "(", "$", "item", "->", "getType", "(", ")", ",", "$", "field", "?", "$", "field", "->", "get", "(", "'value'", ")", ":", "NULL", ",", "$", "variables", ")", ";", "$", "object", "[", "$", "name", "]", "=", "$", "fieldValue", "===", "NULL", "?", "$", "item", "->", "getDefaultValue", "(", ")", ":", "$", "fieldValue", ";", "}", "return", "$", "object", ";", "}", "if", "(", "$", "type", "instanceof", "ScalarType", "||", "$", "type", "instanceof", "EnumType", ")", "{", "$", "coerced", "=", "$", "type", "->", "coerceLiteral", "(", "$", "ast", ")", ";", "if", "(", "isset", "(", "$", "coerced", ")", ")", "{", "return", "$", "coerced", ";", "}", "}", "return", "NULL", ";", "}" ]
Given a type and a value AST node known to match this type, build a runtime value. @param TypeInterface $type @param $ast @param null $variables @return array|mixed|null|string
[ "Given", "a", "type", "and", "a", "value", "AST", "node", "known", "to", "match", "this", "type", "build", "a", "runtime", "value", "." ]
train
https://github.com/fubhy/graphql-php/blob/c1de2233c731ca29e5c5db4c43f3b9db36478c83/src/Executor/Values.php#L253-L325
lootils/archiver
src/Lootils/Archiver/ZipArchive.php
ZipArchive.add
public function add($file, $entry_name = null) { // Make sure to adapt the entry name as the original filename. if (!isset($entry_name)) { $entry_name = basename($file); } $result = $this->zip->addFile($file, $entry_name); if ($result === false) { throw new ArchiveException('Error adding ' . $file); } return $this; }
php
public function add($file, $entry_name = null) { // Make sure to adapt the entry name as the original filename. if (!isset($entry_name)) { $entry_name = basename($file); } $result = $this->zip->addFile($file, $entry_name); if ($result === false) { throw new ArchiveException('Error adding ' . $file); } return $this; }
[ "public", "function", "add", "(", "$", "file", ",", "$", "entry_name", "=", "null", ")", "{", "// Make sure to adapt the entry name as the original filename.", "if", "(", "!", "isset", "(", "$", "entry_name", ")", ")", "{", "$", "entry_name", "=", "basename", "(", "$", "file", ")", ";", "}", "$", "result", "=", "$", "this", "->", "zip", "->", "addFile", "(", "$", "file", ",", "$", "entry_name", ")", ";", "if", "(", "$", "result", "===", "false", ")", "{", "throw", "new", "ArchiveException", "(", "'Error adding '", ".", "$", "file", ")", ";", "}", "return", "$", "this", ";", "}" ]
Add the given file to the file archive.
[ "Add", "the", "given", "file", "to", "the", "file", "archive", "." ]
train
https://github.com/lootils/archiver/blob/5b801bddfe15f7378a118c4094f04b37abb5a53e/src/Lootils/Archiver/ZipArchive.php#L34-L46
lootils/archiver
src/Lootils/Archiver/ZipArchive.php
ZipArchive.remove
public function remove($entry) { $result = $this->zip->deleteName($entry); if ($result === false) { throw new ArchiveException('Error removing entry ' . $entry); } return $this; }
php
public function remove($entry) { $result = $this->zip->deleteName($entry); if ($result === false) { throw new ArchiveException('Error removing entry ' . $entry); } return $this; }
[ "public", "function", "remove", "(", "$", "entry", ")", "{", "$", "result", "=", "$", "this", "->", "zip", "->", "deleteName", "(", "$", "entry", ")", ";", "if", "(", "$", "result", "===", "false", ")", "{", "throw", "new", "ArchiveException", "(", "'Error removing entry '", ".", "$", "entry", ")", ";", "}", "return", "$", "this", ";", "}" ]
Remove the specified file from the archive.
[ "Remove", "the", "specified", "file", "from", "the", "archive", "." ]
train
https://github.com/lootils/archiver/blob/5b801bddfe15f7378a118c4094f04b37abb5a53e/src/Lootils/Archiver/ZipArchive.php#L51-L59
lootils/archiver
src/Lootils/Archiver/ZipArchive.php
ZipArchive.contents
public function contents() { $files = array(); for ($i=0; $i < $this->zip->numFiles; $i++) { $details = $this->zip->statIndex($i); $files[$details['name']] = $details; } return $files; }
php
public function contents() { $files = array(); for ($i=0; $i < $this->zip->numFiles; $i++) { $details = $this->zip->statIndex($i); $files[$details['name']] = $details; } return $files; }
[ "public", "function", "contents", "(", ")", "{", "$", "files", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "this", "->", "zip", "->", "numFiles", ";", "$", "i", "++", ")", "{", "$", "details", "=", "$", "this", "->", "zip", "->", "statIndex", "(", "$", "i", ")", ";", "$", "files", "[", "$", "details", "[", "'name'", "]", "]", "=", "$", "details", ";", "}", "return", "$", "files", ";", "}" ]
Retrieve an array of the archive contents.
[ "Retrieve", "an", "array", "of", "the", "archive", "contents", "." ]
train
https://github.com/lootils/archiver/blob/5b801bddfe15f7378a118c4094f04b37abb5a53e/src/Lootils/Archiver/ZipArchive.php#L82-L92
lootils/archiver
src/Lootils/Archiver/ZipArchive.php
ZipArchive.close
public function close() { if (isset($this->zip)) { $this->zip->close(); $this->zip = null; } }
php
public function close() { if (isset($this->zip)) { $this->zip->close(); $this->zip = null; } }
[ "public", "function", "close", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "zip", ")", ")", "{", "$", "this", "->", "zip", "->", "close", "(", ")", ";", "$", "this", "->", "zip", "=", "null", ";", "}", "}" ]
Release the zip resource.
[ "Release", "the", "zip", "resource", "." ]
train
https://github.com/lootils/archiver/blob/5b801bddfe15f7378a118c4094f04b37abb5a53e/src/Lootils/Archiver/ZipArchive.php#L105-L111
yohang/dependency-tools
src/Yohang/DependencyTools.php
DependencyTools.getOptions
protected static function getOptions($event) { $extra = $event->getComposer()->getPackage()->getExtra(); return array_merge( array( 'npm' => false, 'bower' => false ), isset($extra['dependency-tools']) ? $extra['dependency-tools'] : array() ); }
php
protected static function getOptions($event) { $extra = $event->getComposer()->getPackage()->getExtra(); return array_merge( array( 'npm' => false, 'bower' => false ), isset($extra['dependency-tools']) ? $extra['dependency-tools'] : array() ); }
[ "protected", "static", "function", "getOptions", "(", "$", "event", ")", "{", "$", "extra", "=", "$", "event", "->", "getComposer", "(", ")", "->", "getPackage", "(", ")", "->", "getExtra", "(", ")", ";", "return", "array_merge", "(", "array", "(", "'npm'", "=>", "false", ",", "'bower'", "=>", "false", ")", ",", "isset", "(", "$", "extra", "[", "'dependency-tools'", "]", ")", "?", "$", "extra", "[", "'dependency-tools'", "]", ":", "array", "(", ")", ")", ";", "}" ]
@param $event @return array
[ "@param", "$event" ]
train
https://github.com/yohang/dependency-tools/blob/9e0b85e8108900e397e25b8d1830b3d785ef11af/src/Yohang/DependencyTools.php#L47-L58
yohang/dependency-tools
src/Yohang/DependencyTools.php
DependencyTools.execCommand
protected static function execCommand($options, $cmd, array $args, $ifError) { if (is_array($options) && isset($options['path'])) { $cmd = $options['path']; } else { $executableFinder = new ExecutableFinder; $cmd = $executableFinder->find($cmd); } $out = ''; $process = ProcessBuilder::create(array_merge(array($cmd), $args))->getProcess(); if (isset($options['timeout'])) { $process->setTimeout($options['timeout']); } $process->run(function($type, $buffer) use (&$out) { $out .= $buffer; }); if (!$process->isSuccessful()) { throw new \RuntimeException($ifError."\n\n".$out); } }
php
protected static function execCommand($options, $cmd, array $args, $ifError) { if (is_array($options) && isset($options['path'])) { $cmd = $options['path']; } else { $executableFinder = new ExecutableFinder; $cmd = $executableFinder->find($cmd); } $out = ''; $process = ProcessBuilder::create(array_merge(array($cmd), $args))->getProcess(); if (isset($options['timeout'])) { $process->setTimeout($options['timeout']); } $process->run(function($type, $buffer) use (&$out) { $out .= $buffer; }); if (!$process->isSuccessful()) { throw new \RuntimeException($ifError."\n\n".$out); } }
[ "protected", "static", "function", "execCommand", "(", "$", "options", ",", "$", "cmd", ",", "array", "$", "args", ",", "$", "ifError", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", "&&", "isset", "(", "$", "options", "[", "'path'", "]", ")", ")", "{", "$", "cmd", "=", "$", "options", "[", "'path'", "]", ";", "}", "else", "{", "$", "executableFinder", "=", "new", "ExecutableFinder", ";", "$", "cmd", "=", "$", "executableFinder", "->", "find", "(", "$", "cmd", ")", ";", "}", "$", "out", "=", "''", ";", "$", "process", "=", "ProcessBuilder", "::", "create", "(", "array_merge", "(", "array", "(", "$", "cmd", ")", ",", "$", "args", ")", ")", "->", "getProcess", "(", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'timeout'", "]", ")", ")", "{", "$", "process", "->", "setTimeout", "(", "$", "options", "[", "'timeout'", "]", ")", ";", "}", "$", "process", "->", "run", "(", "function", "(", "$", "type", ",", "$", "buffer", ")", "use", "(", "&", "$", "out", ")", "{", "$", "out", ".=", "$", "buffer", ";", "}", ")", ";", "if", "(", "!", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "$", "ifError", ".", "\"\\n\\n\"", ".", "$", "out", ")", ";", "}", "}" ]
@param array $options @param string $cmd @param array $args @param string $ifError @throws \RuntimeException
[ "@param", "array", "$options", "@param", "string", "$cmd", "@param", "array", "$args", "@param", "string", "$ifError" ]
train
https://github.com/yohang/dependency-tools/blob/9e0b85e8108900e397e25b8d1830b3d785ef11af/src/Yohang/DependencyTools.php#L68-L87
webforge-labs/psc-cms
lib/Psc/GPC.php
GPC.clean
public static function clean($value) { if (!get_magic_quotes_gpc() && !self::$forceStripSlashes) return $value; return is_array($value) ? array_map(array('GPC','clean'), $value) : stripslashes($value); }
php
public static function clean($value) { if (!get_magic_quotes_gpc() && !self::$forceStripSlashes) return $value; return is_array($value) ? array_map(array('GPC','clean'), $value) : stripslashes($value); }
[ "public", "static", "function", "clean", "(", "$", "value", ")", "{", "if", "(", "!", "get_magic_quotes_gpc", "(", ")", "&&", "!", "self", "::", "$", "forceStripSlashes", ")", "return", "$", "value", ";", "return", "is_array", "(", "$", "value", ")", "?", "array_map", "(", "array", "(", "'GPC'", ",", "'clean'", ")", ",", "$", "value", ")", ":", "stripslashes", "(", "$", "value", ")", ";", "}" ]
Gibt den Wert (oder Array) ohne magic Slashes zurück @param array|string $value
[ "Gibt", "den", "Wert", "(", "oder", "Array", ")", "ohne", "magic", "Slashes", "zurück" ]
train
https://github.com/webforge-labs/psc-cms/blob/467bfa2547e6b4fa487d2d7f35fa6cc618dbc763/lib/Psc/GPC.php#L19-L25
teneleven/GeolocatorBundle
DependencyInjection/TenelevenGeolocatorExtension.php
TenelevenGeolocatorExtension.load
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $container->setAlias('teneleven.geolocator.geocoder', $config['geocoder_service']); $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.xml'); foreach ($config['locatables'] as $alias => $locatableConfig) { $this->configureLocatable($alias, $locatableConfig, $container); } }
php
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $container->setAlias('teneleven.geolocator.geocoder', $config['geocoder_service']); $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.xml'); foreach ($config['locatables'] as $alias => $locatableConfig) { $this->configureLocatable($alias, $locatableConfig, $container); } }
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "configuration", "=", "new", "Configuration", "(", ")", ";", "$", "config", "=", "$", "this", "->", "processConfiguration", "(", "$", "configuration", ",", "$", "configs", ")", ";", "$", "container", "->", "setAlias", "(", "'teneleven.geolocator.geocoder'", ",", "$", "config", "[", "'geocoder_service'", "]", ")", ";", "$", "loader", "=", "new", "Loader", "\\", "XmlFileLoader", "(", "$", "container", ",", "new", "FileLocator", "(", "__DIR__", ".", "'/../Resources/config'", ")", ")", ";", "$", "loader", "->", "load", "(", "'services.xml'", ")", ";", "foreach", "(", "$", "config", "[", "'locatables'", "]", "as", "$", "alias", "=>", "$", "locatableConfig", ")", "{", "$", "this", "->", "configureLocatable", "(", "$", "alias", ",", "$", "locatableConfig", ",", "$", "container", ")", ";", "}", "}" ]
{@inheritDoc}
[ "{" ]
train
https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/DependencyInjection/TenelevenGeolocatorExtension.php#L32-L45
teneleven/GeolocatorBundle
DependencyInjection/TenelevenGeolocatorExtension.php
TenelevenGeolocatorExtension.prepend
public function prepend(ContainerBuilder $container) { $configs = array( 'bazinga_geocoder' => array( 'providers' => array('google_maps' => null) ), // 'ivory_google_map' => array( // 'map' => array('width' => "100%", 'height' => "600px"), // 'info_window' => array('auto_close' => true) // ), 'doctrine' => array( 'orm' => array( 'dql' => array( 'numeric_functions' => array( 'GEO_DISTANCE' => 'Craue\GeoBundle\Doctrine\Query\Mysql\GeoDistance' ) ) ) ) ); foreach ($configs as $name => $config) { $container->prependExtensionConfig($name, $config); } }
php
public function prepend(ContainerBuilder $container) { $configs = array( 'bazinga_geocoder' => array( 'providers' => array('google_maps' => null) ), // 'ivory_google_map' => array( // 'map' => array('width' => "100%", 'height' => "600px"), // 'info_window' => array('auto_close' => true) // ), 'doctrine' => array( 'orm' => array( 'dql' => array( 'numeric_functions' => array( 'GEO_DISTANCE' => 'Craue\GeoBundle\Doctrine\Query\Mysql\GeoDistance' ) ) ) ) ); foreach ($configs as $name => $config) { $container->prependExtensionConfig($name, $config); } }
[ "public", "function", "prepend", "(", "ContainerBuilder", "$", "container", ")", "{", "$", "configs", "=", "array", "(", "'bazinga_geocoder'", "=>", "array", "(", "'providers'", "=>", "array", "(", "'google_maps'", "=>", "null", ")", ")", ",", "// 'ivory_google_map' => array(", "// 'map' => array('width' => \"100%\", 'height' => \"600px\"),", "// 'info_window' => array('auto_close' => true)", "// ),", "'doctrine'", "=>", "array", "(", "'orm'", "=>", "array", "(", "'dql'", "=>", "array", "(", "'numeric_functions'", "=>", "array", "(", "'GEO_DISTANCE'", "=>", "'Craue\\GeoBundle\\Doctrine\\Query\\Mysql\\GeoDistance'", ")", ")", ")", ")", ")", ";", "foreach", "(", "$", "configs", "as", "$", "name", "=>", "$", "config", ")", "{", "$", "container", "->", "prependExtensionConfig", "(", "$", "name", ",", "$", "config", ")", ";", "}", "}" ]
Configure sensitive defaults for other bundles @param ContainerBuilder $container
[ "Configure", "sensitive", "defaults", "for", "other", "bundles" ]
train
https://github.com/teneleven/GeolocatorBundle/blob/4ead8e783a91577f2a67aa302b79641d4b9e99ad/DependencyInjection/TenelevenGeolocatorExtension.php#L80-L104
andrelohmann/silverstripe-extended-image
code/models/SecureImage.php
SecureImage.getTag
public function getTag() { if($this->exists()) { $url = $this->getURL(); $title = ($this->Title) ? $this->Title : $this->Filename; if($this->Title) { $title = Convert::raw2att($this->Title); } else { if(preg_match("/([^\/]*)\.[a-zA-Z0-9]{1,6}$/", $title, $matches)) { $title = Convert::raw2att($matches[1]); } } return "<img src=\"$url\" alt=\"$title\" ".$this->getAttributesHTML()." />"; } }
php
public function getTag() { if($this->exists()) { $url = $this->getURL(); $title = ($this->Title) ? $this->Title : $this->Filename; if($this->Title) { $title = Convert::raw2att($this->Title); } else { if(preg_match("/([^\/]*)\.[a-zA-Z0-9]{1,6}$/", $title, $matches)) { $title = Convert::raw2att($matches[1]); } } return "<img src=\"$url\" alt=\"$title\" ".$this->getAttributesHTML()." />"; } }
[ "public", "function", "getTag", "(", ")", "{", "if", "(", "$", "this", "->", "exists", "(", ")", ")", "{", "$", "url", "=", "$", "this", "->", "getURL", "(", ")", ";", "$", "title", "=", "(", "$", "this", "->", "Title", ")", "?", "$", "this", "->", "Title", ":", "$", "this", "->", "Filename", ";", "if", "(", "$", "this", "->", "Title", ")", "{", "$", "title", "=", "Convert", "::", "raw2att", "(", "$", "this", "->", "Title", ")", ";", "}", "else", "{", "if", "(", "preg_match", "(", "\"/([^\\/]*)\\.[a-zA-Z0-9]{1,6}$/\"", ",", "$", "title", ",", "$", "matches", ")", ")", "{", "$", "title", "=", "Convert", "::", "raw2att", "(", "$", "matches", "[", "1", "]", ")", ";", "}", "}", "return", "\"<img src=\\\"$url\\\" alt=\\\"$title\\\" \"", ".", "$", "this", "->", "getAttributesHTML", "(", ")", ".", "\" />\"", ";", "}", "}" ]
Return an XHTML img tag for this Image, or NULL if the image file doesn't exist on the filesystem. @return string
[ "Return", "an", "XHTML", "img", "tag", "for", "this", "Image", "or", "NULL", "if", "the", "image", "file", "doesn", "t", "exist", "on", "the", "filesystem", "." ]
train
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/models/SecureImage.php#L105-L118
andrelohmann/silverstripe-extended-image
code/models/SecureImage.php
SecureImage.getFormattedImage
public function getFormattedImage($format) { $args = func_get_args(); if($this->exists()) { $cacheFile = call_user_func_array(array($this, "cacheFilename"), $args); if(!file_exists(Director::baseFolder()."/".$cacheFile) || self::$flush) { call_user_func_array(array($this, "generateFormattedImage"), $args); } $cached = new SecureImage_Cached($cacheFile); // Pass through the title so the templates can use it $cached->Title = $this->Title; $cached->ID = $this->ID; $cached->ParentID = $this->ParentID; return $cached; } }
php
public function getFormattedImage($format) { $args = func_get_args(); if($this->exists()) { $cacheFile = call_user_func_array(array($this, "cacheFilename"), $args); if(!file_exists(Director::baseFolder()."/".$cacheFile) || self::$flush) { call_user_func_array(array($this, "generateFormattedImage"), $args); } $cached = new SecureImage_Cached($cacheFile); // Pass through the title so the templates can use it $cached->Title = $this->Title; $cached->ID = $this->ID; $cached->ParentID = $this->ParentID; return $cached; } }
[ "public", "function", "getFormattedImage", "(", "$", "format", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "if", "(", "$", "this", "->", "exists", "(", ")", ")", "{", "$", "cacheFile", "=", "call_user_func_array", "(", "array", "(", "$", "this", ",", "\"cacheFilename\"", ")", ",", "$", "args", ")", ";", "if", "(", "!", "file_exists", "(", "Director", "::", "baseFolder", "(", ")", ".", "\"/\"", ".", "$", "cacheFile", ")", "||", "self", "::", "$", "flush", ")", "{", "call_user_func_array", "(", "array", "(", "$", "this", ",", "\"generateFormattedImage\"", ")", ",", "$", "args", ")", ";", "}", "$", "cached", "=", "new", "SecureImage_Cached", "(", "$", "cacheFile", ")", ";", "// Pass through the title so the templates can use it", "$", "cached", "->", "Title", "=", "$", "this", "->", "Title", ";", "$", "cached", "->", "ID", "=", "$", "this", "->", "ID", ";", "$", "cached", "->", "ParentID", "=", "$", "this", "->", "ParentID", ";", "return", "$", "cached", ";", "}", "}" ]
Return an image object representing the image in the given format. This image will be generated using generateFormattedImage(). The generated image is cached, to flush the cache append ?flush=1 to your URL. @param string $format The name of the format. @param string $arg1 An argument to pass to the generate function. @param string $arg2 A second argument to pass to the generate function. @return SecureImage_Cached
[ "Return", "an", "image", "object", "representing", "the", "image", "in", "the", "given", "format", ".", "This", "image", "will", "be", "generated", "using", "generateFormattedImage", "()", ".", "The", "generated", "image", "is", "cached", "to", "flush", "the", "cache", "append", "?flush", "=", "1", "to", "your", "URL", "." ]
train
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/models/SecureImage.php#L130-L147
andrelohmann/silverstripe-extended-image
code/models/SecureImage.php
SecureImage.cacheFilename
public function cacheFilename($format) { $args = func_get_args(); array_shift($args); $folder = $this->ParentID ? $this->Parent()->Filename : ASSETS_DIR . "/"; $format = $format.implode('',$args); $file = pathinfo($this->Name); return $folder . "_resampled/".md5($format."-".$file['filename']).".".$file['extension']; }
php
public function cacheFilename($format) { $args = func_get_args(); array_shift($args); $folder = $this->ParentID ? $this->Parent()->Filename : ASSETS_DIR . "/"; $format = $format.implode('',$args); $file = pathinfo($this->Name); return $folder . "_resampled/".md5($format."-".$file['filename']).".".$file['extension']; }
[ "public", "function", "cacheFilename", "(", "$", "format", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "args", ")", ";", "$", "folder", "=", "$", "this", "->", "ParentID", "?", "$", "this", "->", "Parent", "(", ")", "->", "Filename", ":", "ASSETS_DIR", ".", "\"/\"", ";", "$", "format", "=", "$", "format", ".", "implode", "(", "''", ",", "$", "args", ")", ";", "$", "file", "=", "pathinfo", "(", "$", "this", "->", "Name", ")", ";", "return", "$", "folder", ".", "\"_resampled/\"", ".", "md5", "(", "$", "format", ".", "\"-\"", ".", "$", "file", "[", "'filename'", "]", ")", ".", "\".\"", ".", "$", "file", "[", "'extension'", "]", ";", "}" ]
Return the filename for the cached image, given it's format name and arguments. @param string $format The format name. @param string $arg1 The first argument passed to the generate function. @param string $arg2 The second argument passed to the generate function. @return string
[ "Return", "the", "filename", "for", "the", "cached", "image", "given", "it", "s", "format", "name", "and", "arguments", "." ]
train
https://github.com/andrelohmann/silverstripe-extended-image/blob/178e9142ae8ff63f9bf36464093379f6e836b90b/code/models/SecureImage.php#L156-L164
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php
BaseApiLogQuery.create
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof ApiLogQuery) { return $criteria; } $query = new ApiLogQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
php
public static function create($modelAlias = null, $criteria = null) { if ($criteria instanceof ApiLogQuery) { return $criteria; } $query = new ApiLogQuery(null, null, $modelAlias); if ($criteria instanceof Criteria) { $query->mergeWith($criteria); } return $query; }
[ "public", "static", "function", "create", "(", "$", "modelAlias", "=", "null", ",", "$", "criteria", "=", "null", ")", "{", "if", "(", "$", "criteria", "instanceof", "ApiLogQuery", ")", "{", "return", "$", "criteria", ";", "}", "$", "query", "=", "new", "ApiLogQuery", "(", "null", ",", "null", ",", "$", "modelAlias", ")", ";", "if", "(", "$", "criteria", "instanceof", "Criteria", ")", "{", "$", "query", "->", "mergeWith", "(", "$", "criteria", ")", ";", "}", "return", "$", "query", ";", "}" ]
Returns a new ApiLogQuery object. @param string $modelAlias The alias of a model in the query @param ApiLogQuery|Criteria $criteria Optional Criteria to build the query from @return ApiLogQuery
[ "Returns", "a", "new", "ApiLogQuery", "object", "." ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php#L83-L95
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php
BaseApiLogQuery.filterByDtCall
public function filterByDtCall($dtCall = null, $comparison = null) { if (is_array($dtCall)) { $useMinMax = false; if (isset($dtCall['min'])) { $this->addUsingAlias(ApiLogPeer::DT_CALL, $dtCall['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($dtCall['max'])) { $this->addUsingAlias(ApiLogPeer::DT_CALL, $dtCall['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(ApiLogPeer::DT_CALL, $dtCall, $comparison); }
php
public function filterByDtCall($dtCall = null, $comparison = null) { if (is_array($dtCall)) { $useMinMax = false; if (isset($dtCall['min'])) { $this->addUsingAlias(ApiLogPeer::DT_CALL, $dtCall['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($dtCall['max'])) { $this->addUsingAlias(ApiLogPeer::DT_CALL, $dtCall['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(ApiLogPeer::DT_CALL, $dtCall, $comparison); }
[ "public", "function", "filterByDtCall", "(", "$", "dtCall", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "dtCall", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "dtCall", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "ApiLogPeer", "::", "DT_CALL", ",", "$", "dtCall", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "dtCall", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "ApiLogPeer", "::", "DT_CALL", ",", "$", "dtCall", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "ApiLogPeer", "::", "DT_CALL", ",", "$", "dtCall", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the dt_call column Example usage: <code> $query->filterByDtCall('2011-03-14'); // WHERE dt_call = '2011-03-14' $query->filterByDtCall('now'); // WHERE dt_call = '2011-03-14' $query->filterByDtCall(array('max' => 'yesterday')); // WHERE dt_call < '2011-03-13' </code> @param mixed $dtCall The value to use as filter. Values can be integers (unix timestamps), DateTime objects, or strings. Empty strings are treated as NULL. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ApiLogQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "dt_call", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php#L310-L331
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php
BaseApiLogQuery.filterByLastResponse
public function filterByLastResponse($lastResponse = null, $comparison = null) { return $this->addUsingAlias(ApiLogPeer::LAST_RESPONSE, $lastResponse, $comparison); }
php
public function filterByLastResponse($lastResponse = null, $comparison = null) { return $this->addUsingAlias(ApiLogPeer::LAST_RESPONSE, $lastResponse, $comparison); }
[ "public", "function", "filterByLastResponse", "(", "$", "lastResponse", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "ApiLogPeer", "::", "LAST_RESPONSE", ",", "$", "lastResponse", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the last_response column @param mixed $lastResponse The value to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ApiLogQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "last_response", "column" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php#L427-L431
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php
BaseApiLogQuery.filterByRemoteApp
public function filterByRemoteApp($remoteApp, $comparison = null) { if ($remoteApp instanceof RemoteApp) { return $this ->addUsingAlias(ApiLogPeer::REMOTE_APP_ID, $remoteApp->getId(), $comparison); } elseif ($remoteApp instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(ApiLogPeer::REMOTE_APP_ID, $remoteApp->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByRemoteApp() only accepts arguments of type RemoteApp or PropelCollection'); } }
php
public function filterByRemoteApp($remoteApp, $comparison = null) { if ($remoteApp instanceof RemoteApp) { return $this ->addUsingAlias(ApiLogPeer::REMOTE_APP_ID, $remoteApp->getId(), $comparison); } elseif ($remoteApp instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this ->addUsingAlias(ApiLogPeer::REMOTE_APP_ID, $remoteApp->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByRemoteApp() only accepts arguments of type RemoteApp or PropelCollection'); } }
[ "public", "function", "filterByRemoteApp", "(", "$", "remoteApp", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "$", "remoteApp", "instanceof", "RemoteApp", ")", "{", "return", "$", "this", "->", "addUsingAlias", "(", "ApiLogPeer", "::", "REMOTE_APP_ID", ",", "$", "remoteApp", "->", "getId", "(", ")", ",", "$", "comparison", ")", ";", "}", "elseif", "(", "$", "remoteApp", "instanceof", "PropelObjectCollection", ")", "{", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "return", "$", "this", "->", "addUsingAlias", "(", "ApiLogPeer", "::", "REMOTE_APP_ID", ",", "$", "remoteApp", "->", "toKeyValue", "(", "'PrimaryKey'", ",", "'Id'", ")", ",", "$", "comparison", ")", ";", "}", "else", "{", "throw", "new", "PropelException", "(", "'filterByRemoteApp() only accepts arguments of type RemoteApp or PropelCollection'", ")", ";", "}", "}" ]
Filter the query by a related RemoteApp object @param RemoteApp|PropelObjectCollection $remoteApp The related object(s) to use as filter @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return ApiLogQuery The current query, for fluid interface @throws PropelException - if the provided filter is invalid.
[ "Filter", "the", "query", "by", "a", "related", "RemoteApp", "object" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php#L442-L457
slashworks/control-bundle
src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php
BaseApiLogQuery.prune
public function prune($apiLog = null) { if ($apiLog) { $this->addUsingAlias(ApiLogPeer::ID, $apiLog->getId(), Criteria::NOT_EQUAL); } return $this; }
php
public function prune($apiLog = null) { if ($apiLog) { $this->addUsingAlias(ApiLogPeer::ID, $apiLog->getId(), Criteria::NOT_EQUAL); } return $this; }
[ "public", "function", "prune", "(", "$", "apiLog", "=", "null", ")", "{", "if", "(", "$", "apiLog", ")", "{", "$", "this", "->", "addUsingAlias", "(", "ApiLogPeer", "::", "ID", ",", "$", "apiLog", "->", "getId", "(", ")", ",", "Criteria", "::", "NOT_EQUAL", ")", ";", "}", "return", "$", "this", ";", "}" ]
Exclude object from result @param ApiLog $apiLog Object to remove from the list of results @return ApiLogQuery The current query, for fluid interface
[ "Exclude", "object", "from", "result" ]
train
https://github.com/slashworks/control-bundle/blob/2ba86d96f1f41f9424e2229c4e2b13017e973f89/src/Slashworks/AppBundle/Model/om/BaseApiLogQuery.php#L516-L523
Double-Opt-in/php-client-api
src/Security/Crypter.php
Crypter.encrypt
public function encrypt($plaintext, $key) { // Set up encryption parameters. $inputData = cryptoHelpers::convertStringToByteArray($plaintext); $keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($key)); $keyLength = count($keyAsNumbers); $iv = cryptoHelpers::generateSharedKey(16); $encrypted = AES::encrypt( $inputData, AES::modeOfOperation_CBC, $keyAsNumbers, $keyLength, $iv ); $retVal = $encrypted['originalsize'] . self::SEPARATOR_CRYPTO_PARTS . cryptoHelpers::toHex($iv) . self::SEPARATOR_CRYPTO_PARTS . cryptoHelpers::toHex($encrypted['cipher']); return self::IDENTIFIER . self::SEPARATOR_ALGORITHM . $retVal; }
php
public function encrypt($plaintext, $key) { // Set up encryption parameters. $inputData = cryptoHelpers::convertStringToByteArray($plaintext); $keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($key)); $keyLength = count($keyAsNumbers); $iv = cryptoHelpers::generateSharedKey(16); $encrypted = AES::encrypt( $inputData, AES::modeOfOperation_CBC, $keyAsNumbers, $keyLength, $iv ); $retVal = $encrypted['originalsize'] . self::SEPARATOR_CRYPTO_PARTS . cryptoHelpers::toHex($iv) . self::SEPARATOR_CRYPTO_PARTS . cryptoHelpers::toHex($encrypted['cipher']); return self::IDENTIFIER . self::SEPARATOR_ALGORITHM . $retVal; }
[ "public", "function", "encrypt", "(", "$", "plaintext", ",", "$", "key", ")", "{", "// Set up encryption parameters.", "$", "inputData", "=", "cryptoHelpers", "::", "convertStringToByteArray", "(", "$", "plaintext", ")", ";", "$", "keyAsNumbers", "=", "cryptoHelpers", "::", "toNumbers", "(", "bin2hex", "(", "$", "key", ")", ")", ";", "$", "keyLength", "=", "count", "(", "$", "keyAsNumbers", ")", ";", "$", "iv", "=", "cryptoHelpers", "::", "generateSharedKey", "(", "16", ")", ";", "$", "encrypted", "=", "AES", "::", "encrypt", "(", "$", "inputData", ",", "AES", "::", "modeOfOperation_CBC", ",", "$", "keyAsNumbers", ",", "$", "keyLength", ",", "$", "iv", ")", ";", "$", "retVal", "=", "$", "encrypted", "[", "'originalsize'", "]", ".", "self", "::", "SEPARATOR_CRYPTO_PARTS", ".", "cryptoHelpers", "::", "toHex", "(", "$", "iv", ")", ".", "self", "::", "SEPARATOR_CRYPTO_PARTS", ".", "cryptoHelpers", "::", "toHex", "(", "$", "encrypted", "[", "'cipher'", "]", ")", ";", "return", "self", "::", "IDENTIFIER", ".", "self", "::", "SEPARATOR_ALGORITHM", ".", "$", "retVal", ";", "}" ]
encrypts the given plain text with a key @param string $plaintext @param string $key @return string
[ "encrypts", "the", "given", "plain", "text", "with", "a", "key" ]
train
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/Crypter.php#L28-L49
Double-Opt-in/php-client-api
src/Security/Crypter.php
Crypter.decrypt
public function decrypt($encrypted, $key) { if (empty($encrypted)) return null; list($identifier, $input) = explode(self::SEPARATOR_ALGORITHM, $encrypted, 2); if ($identifier !== self::IDENTIFIER) throw new Exception('Encryption can not be decrypted. Unsupported identifier: ' . $identifier); // Split the input into its parts $cipherSplit = explode(self::SEPARATOR_CRYPTO_PARTS, $input); $originalSize = intval($cipherSplit[0]); $iv = cryptoHelpers::toNumbers($cipherSplit[1]); $cipherText = $cipherSplit[2]; // Set up encryption parameters $cipherIn = cryptoHelpers::toNumbers($cipherText); $keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($key)); $keyLength = count($keyAsNumbers); $decrypted = AES::decrypt( $cipherIn, $originalSize, AES::modeOfOperation_CBC, $keyAsNumbers, $keyLength, $iv ); // Byte-array to text. $hexDecrypted = cryptoHelpers::toHex($decrypted); $retVal = pack("H*", $hexDecrypted); return $retVal; }
php
public function decrypt($encrypted, $key) { if (empty($encrypted)) return null; list($identifier, $input) = explode(self::SEPARATOR_ALGORITHM, $encrypted, 2); if ($identifier !== self::IDENTIFIER) throw new Exception('Encryption can not be decrypted. Unsupported identifier: ' . $identifier); // Split the input into its parts $cipherSplit = explode(self::SEPARATOR_CRYPTO_PARTS, $input); $originalSize = intval($cipherSplit[0]); $iv = cryptoHelpers::toNumbers($cipherSplit[1]); $cipherText = $cipherSplit[2]; // Set up encryption parameters $cipherIn = cryptoHelpers::toNumbers($cipherText); $keyAsNumbers = cryptoHelpers::toNumbers(bin2hex($key)); $keyLength = count($keyAsNumbers); $decrypted = AES::decrypt( $cipherIn, $originalSize, AES::modeOfOperation_CBC, $keyAsNumbers, $keyLength, $iv ); // Byte-array to text. $hexDecrypted = cryptoHelpers::toHex($decrypted); $retVal = pack("H*", $hexDecrypted); return $retVal; }
[ "public", "function", "decrypt", "(", "$", "encrypted", ",", "$", "key", ")", "{", "if", "(", "empty", "(", "$", "encrypted", ")", ")", "return", "null", ";", "list", "(", "$", "identifier", ",", "$", "input", ")", "=", "explode", "(", "self", "::", "SEPARATOR_ALGORITHM", ",", "$", "encrypted", ",", "2", ")", ";", "if", "(", "$", "identifier", "!==", "self", "::", "IDENTIFIER", ")", "throw", "new", "Exception", "(", "'Encryption can not be decrypted. Unsupported identifier: '", ".", "$", "identifier", ")", ";", "// Split the input into its parts", "$", "cipherSplit", "=", "explode", "(", "self", "::", "SEPARATOR_CRYPTO_PARTS", ",", "$", "input", ")", ";", "$", "originalSize", "=", "intval", "(", "$", "cipherSplit", "[", "0", "]", ")", ";", "$", "iv", "=", "cryptoHelpers", "::", "toNumbers", "(", "$", "cipherSplit", "[", "1", "]", ")", ";", "$", "cipherText", "=", "$", "cipherSplit", "[", "2", "]", ";", "// Set up encryption parameters", "$", "cipherIn", "=", "cryptoHelpers", "::", "toNumbers", "(", "$", "cipherText", ")", ";", "$", "keyAsNumbers", "=", "cryptoHelpers", "::", "toNumbers", "(", "bin2hex", "(", "$", "key", ")", ")", ";", "$", "keyLength", "=", "count", "(", "$", "keyAsNumbers", ")", ";", "$", "decrypted", "=", "AES", "::", "decrypt", "(", "$", "cipherIn", ",", "$", "originalSize", ",", "AES", "::", "modeOfOperation_CBC", ",", "$", "keyAsNumbers", ",", "$", "keyLength", ",", "$", "iv", ")", ";", "// Byte-array to text.", "$", "hexDecrypted", "=", "cryptoHelpers", "::", "toHex", "(", "$", "decrypted", ")", ";", "$", "retVal", "=", "pack", "(", "\"H*\"", ",", "$", "hexDecrypted", ")", ";", "return", "$", "retVal", ";", "}" ]
decrypts a message @param string $encrypted @param string $key @return string @throws Exception
[ "decrypts", "a", "message" ]
train
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Security/Crypter.php#L60-L95
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.edebug
protected function edebug($str) { if (!$this->SMTPDebug) { return; } switch ($this->Debugoutput) { case 'error_log': error_log($str); break; case 'html': //Cleans up output a bit for a better looking display that's HTML-safe echo htmlentities(preg_replace('/[\r\n]+/', '', $str), ENT_QUOTES, $this->CharSet) . "<br>\n"; break; case 'echo': default: echo $str."\n"; } }
php
protected function edebug($str) { if (!$this->SMTPDebug) { return; } switch ($this->Debugoutput) { case 'error_log': error_log($str); break; case 'html': //Cleans up output a bit for a better looking display that's HTML-safe echo htmlentities(preg_replace('/[\r\n]+/', '', $str), ENT_QUOTES, $this->CharSet) . "<br>\n"; break; case 'echo': default: echo $str."\n"; } }
[ "protected", "function", "edebug", "(", "$", "str", ")", "{", "if", "(", "!", "$", "this", "->", "SMTPDebug", ")", "{", "return", ";", "}", "switch", "(", "$", "this", "->", "Debugoutput", ")", "{", "case", "'error_log'", ":", "error_log", "(", "$", "str", ")", ";", "break", ";", "case", "'html'", ":", "//Cleans up output a bit for a better looking display that's HTML-safe", "echo", "htmlentities", "(", "preg_replace", "(", "'/[\\r\\n]+/'", ",", "''", ",", "$", "str", ")", ",", "ENT_QUOTES", ",", "$", "this", "->", "CharSet", ")", ".", "\"<br>\\n\"", ";", "break", ";", "case", "'echo'", ":", "default", ":", "echo", "$", "str", ".", "\"\\n\"", ";", "}", "}" ]
Output debugging info via user-defined method. Only if debug output is enabled. @see PHPMailer::$Debugoutput @see PHPMailer::$SMTPDebug @param string $str
[ "Output", "debugging", "info", "via", "user", "-", "defined", "method", ".", "Only", "if", "debug", "output", "is", "enabled", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L629-L646
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.preSend
public function preSend() { try { $this->mailHeader = ''; if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL); } // Set whether the message is multipart/alternative if (!empty($this->AltBody)) { $this->ContentType = 'multipart/alternative'; } $this->error_count = 0; // reset errors $this->setMessageType(); // Refuse to send an empty message unless we are specifically allowing it if (!$this->AllowEmpty and empty($this->Body)) { throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL); } $this->MIMEHeader = $this->createHeader(); $this->MIMEBody = $this->createBody(); // To capture the complete message when using mail(), create // an extra header list which createHeader() doesn't fold in if ($this->Mailer == 'mail') { if (count($this->to) > 0) { $this->mailHeader .= $this->addrAppend('To', $this->to); } else { $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;'); } $this->mailHeader .= $this->headerLine( 'Subject', $this->encodeHeader($this->secureHeader(trim($this->Subject))) ); } // Sign with DKIM if enabled if (!empty($this->DKIM_domain) && !empty($this->DKIM_private) && !empty($this->DKIM_selector) && !empty($this->DKIM_domain) && file_exists($this->DKIM_private)) { $header_dkim = $this->DKIM_Add( $this->MIMEHeader . $this->mailHeader, $this->encodeHeader($this->secureHeader($this->Subject)), $this->MIMEBody ); $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF . str_replace("\r\n", "\n", $header_dkim) . self::CRLF; } return true; } catch (phpmailerException $exc) { $this->setError($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } }
php
public function preSend() { try { $this->mailHeader = ''; if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { throw new phpmailerException($this->lang('provide_address'), self::STOP_CRITICAL); } // Set whether the message is multipart/alternative if (!empty($this->AltBody)) { $this->ContentType = 'multipart/alternative'; } $this->error_count = 0; // reset errors $this->setMessageType(); // Refuse to send an empty message unless we are specifically allowing it if (!$this->AllowEmpty and empty($this->Body)) { throw new phpmailerException($this->lang('empty_message'), self::STOP_CRITICAL); } $this->MIMEHeader = $this->createHeader(); $this->MIMEBody = $this->createBody(); // To capture the complete message when using mail(), create // an extra header list which createHeader() doesn't fold in if ($this->Mailer == 'mail') { if (count($this->to) > 0) { $this->mailHeader .= $this->addrAppend('To', $this->to); } else { $this->mailHeader .= $this->headerLine('To', 'undisclosed-recipients:;'); } $this->mailHeader .= $this->headerLine( 'Subject', $this->encodeHeader($this->secureHeader(trim($this->Subject))) ); } // Sign with DKIM if enabled if (!empty($this->DKIM_domain) && !empty($this->DKIM_private) && !empty($this->DKIM_selector) && !empty($this->DKIM_domain) && file_exists($this->DKIM_private)) { $header_dkim = $this->DKIM_Add( $this->MIMEHeader . $this->mailHeader, $this->encodeHeader($this->secureHeader($this->Subject)), $this->MIMEBody ); $this->MIMEHeader = rtrim($this->MIMEHeader, "\r\n ") . self::CRLF . str_replace("\r\n", "\n", $header_dkim) . self::CRLF; } return true; } catch (phpmailerException $exc) { $this->setError($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } }
[ "public", "function", "preSend", "(", ")", "{", "try", "{", "$", "this", "->", "mailHeader", "=", "''", ";", "if", "(", "(", "count", "(", "$", "this", "->", "to", ")", "+", "count", "(", "$", "this", "->", "cc", ")", "+", "count", "(", "$", "this", "->", "bcc", ")", ")", "<", "1", ")", "{", "throw", "new", "phpmailerException", "(", "$", "this", "->", "lang", "(", "'provide_address'", ")", ",", "self", "::", "STOP_CRITICAL", ")", ";", "}", "// Set whether the message is multipart/alternative", "if", "(", "!", "empty", "(", "$", "this", "->", "AltBody", ")", ")", "{", "$", "this", "->", "ContentType", "=", "'multipart/alternative'", ";", "}", "$", "this", "->", "error_count", "=", "0", ";", "// reset errors", "$", "this", "->", "setMessageType", "(", ")", ";", "// Refuse to send an empty message unless we are specifically allowing it", "if", "(", "!", "$", "this", "->", "AllowEmpty", "and", "empty", "(", "$", "this", "->", "Body", ")", ")", "{", "throw", "new", "phpmailerException", "(", "$", "this", "->", "lang", "(", "'empty_message'", ")", ",", "self", "::", "STOP_CRITICAL", ")", ";", "}", "$", "this", "->", "MIMEHeader", "=", "$", "this", "->", "createHeader", "(", ")", ";", "$", "this", "->", "MIMEBody", "=", "$", "this", "->", "createBody", "(", ")", ";", "// To capture the complete message when using mail(), create", "// an extra header list which createHeader() doesn't fold in", "if", "(", "$", "this", "->", "Mailer", "==", "'mail'", ")", "{", "if", "(", "count", "(", "$", "this", "->", "to", ")", ">", "0", ")", "{", "$", "this", "->", "mailHeader", ".=", "$", "this", "->", "addrAppend", "(", "'To'", ",", "$", "this", "->", "to", ")", ";", "}", "else", "{", "$", "this", "->", "mailHeader", ".=", "$", "this", "->", "headerLine", "(", "'To'", ",", "'undisclosed-recipients:;'", ")", ";", "}", "$", "this", "->", "mailHeader", ".=", "$", "this", "->", "headerLine", "(", "'Subject'", ",", "$", "this", "->", "encodeHeader", "(", "$", "this", "->", "secureHeader", "(", "trim", "(", "$", "this", "->", "Subject", ")", ")", ")", ")", ";", "}", "// Sign with DKIM if enabled", "if", "(", "!", "empty", "(", "$", "this", "->", "DKIM_domain", ")", "&&", "!", "empty", "(", "$", "this", "->", "DKIM_private", ")", "&&", "!", "empty", "(", "$", "this", "->", "DKIM_selector", ")", "&&", "!", "empty", "(", "$", "this", "->", "DKIM_domain", ")", "&&", "file_exists", "(", "$", "this", "->", "DKIM_private", ")", ")", "{", "$", "header_dkim", "=", "$", "this", "->", "DKIM_Add", "(", "$", "this", "->", "MIMEHeader", ".", "$", "this", "->", "mailHeader", ",", "$", "this", "->", "encodeHeader", "(", "$", "this", "->", "secureHeader", "(", "$", "this", "->", "Subject", ")", ")", ",", "$", "this", "->", "MIMEBody", ")", ";", "$", "this", "->", "MIMEHeader", "=", "rtrim", "(", "$", "this", "->", "MIMEHeader", ",", "\"\\r\\n \"", ")", ".", "self", "::", "CRLF", ".", "str_replace", "(", "\"\\r\\n\"", ",", "\"\\n\"", ",", "$", "header_dkim", ")", ".", "self", "::", "CRLF", ";", "}", "return", "true", ";", "}", "catch", "(", "phpmailerException", "$", "exc", ")", "{", "$", "this", "->", "setError", "(", "$", "exc", "->", "getMessage", "(", ")", ")", ";", "if", "(", "$", "this", "->", "exceptions", ")", "{", "throw", "$", "exc", ";", "}", "return", "false", ";", "}", "}" ]
Prepare a message for sending. @throws phpmailerException @return boolean
[ "Prepare", "a", "message", "for", "sending", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L962-L1022
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.createHeader
public function createHeader() { $result = ''; // Set the boundaries $uniq_id = md5(uniqid(time())); $this->boundary[1] = 'b1_' . $uniq_id; $this->boundary[2] = 'b2_' . $uniq_id; $this->boundary[3] = 'b3_' . $uniq_id; if ($this->MessageDate == '') { $this->MessageDate = self::rfcDate(); } $result .= $this->headerLine('Date', $this->MessageDate); // To be created automatically by mail() if ($this->SingleTo === true) { if ($this->Mailer != 'mail') { foreach ($this->to as $toaddr) { $this->SingleToArray[] = $this->addrFormat($toaddr); } } } else { if (count($this->to) > 0) { if ($this->Mailer != 'mail') { $result .= $this->addrAppend('To', $this->to); } } elseif (count($this->cc) == 0) { $result .= $this->headerLine('To', 'undisclosed-recipients:;'); } } $result .= $this->addrAppend('From', array(array(trim($this->From), $this->FromName))); // sendmail and mail() extract Cc from the header before sending if (count($this->cc) > 0) { $result .= $this->addrAppend('Cc', $this->cc); } // sendmail and mail() extract Bcc from the header before sending if (( $this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail' ) and count($this->bcc) > 0 ) { $result .= $this->addrAppend('Bcc', $this->bcc); } if (count($this->ReplyTo) > 0) { $result .= $this->addrAppend('Reply-To', $this->ReplyTo); } // mail() sets the subject itself if ($this->Mailer != 'mail') { $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject))); } if ($this->MessageID != '') { $this->lastMessageID = $this->MessageID; } else { $this->lastMessageID = sprintf('<%s@%s>', $uniq_id, $this->ServerHostname()); } $result .= $this->HeaderLine('Message-ID', $this->lastMessageID); $result .= $this->headerLine('X-Priority', $this->Priority); if ($this->XMailer == '') { $result .= $this->headerLine( 'X-Mailer', 'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer/)' ); } else { $myXmailer = trim($this->XMailer); if ($myXmailer) { $result .= $this->headerLine('X-Mailer', $myXmailer); } } if ($this->ConfirmReadingTo != '') { $result .= $this->headerLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); } // Add custom headers for ($index = 0; $index < count($this->CustomHeader); $index++) { $result .= $this->headerLine( trim($this->CustomHeader[$index][0]), $this->encodeHeader(trim($this->CustomHeader[$index][1])) ); } if (!$this->sign_key_file) { $result .= $this->headerLine('MIME-Version', '1.0'); $result .= $this->getMailMIME(); } return $result; }
php
public function createHeader() { $result = ''; // Set the boundaries $uniq_id = md5(uniqid(time())); $this->boundary[1] = 'b1_' . $uniq_id; $this->boundary[2] = 'b2_' . $uniq_id; $this->boundary[3] = 'b3_' . $uniq_id; if ($this->MessageDate == '') { $this->MessageDate = self::rfcDate(); } $result .= $this->headerLine('Date', $this->MessageDate); // To be created automatically by mail() if ($this->SingleTo === true) { if ($this->Mailer != 'mail') { foreach ($this->to as $toaddr) { $this->SingleToArray[] = $this->addrFormat($toaddr); } } } else { if (count($this->to) > 0) { if ($this->Mailer != 'mail') { $result .= $this->addrAppend('To', $this->to); } } elseif (count($this->cc) == 0) { $result .= $this->headerLine('To', 'undisclosed-recipients:;'); } } $result .= $this->addrAppend('From', array(array(trim($this->From), $this->FromName))); // sendmail and mail() extract Cc from the header before sending if (count($this->cc) > 0) { $result .= $this->addrAppend('Cc', $this->cc); } // sendmail and mail() extract Bcc from the header before sending if (( $this->Mailer == 'sendmail' or $this->Mailer == 'qmail' or $this->Mailer == 'mail' ) and count($this->bcc) > 0 ) { $result .= $this->addrAppend('Bcc', $this->bcc); } if (count($this->ReplyTo) > 0) { $result .= $this->addrAppend('Reply-To', $this->ReplyTo); } // mail() sets the subject itself if ($this->Mailer != 'mail') { $result .= $this->headerLine('Subject', $this->encodeHeader($this->secureHeader($this->Subject))); } if ($this->MessageID != '') { $this->lastMessageID = $this->MessageID; } else { $this->lastMessageID = sprintf('<%s@%s>', $uniq_id, $this->ServerHostname()); } $result .= $this->HeaderLine('Message-ID', $this->lastMessageID); $result .= $this->headerLine('X-Priority', $this->Priority); if ($this->XMailer == '') { $result .= $this->headerLine( 'X-Mailer', 'PHPMailer ' . $this->Version . ' (https://github.com/PHPMailer/PHPMailer/)' ); } else { $myXmailer = trim($this->XMailer); if ($myXmailer) { $result .= $this->headerLine('X-Mailer', $myXmailer); } } if ($this->ConfirmReadingTo != '') { $result .= $this->headerLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); } // Add custom headers for ($index = 0; $index < count($this->CustomHeader); $index++) { $result .= $this->headerLine( trim($this->CustomHeader[$index][0]), $this->encodeHeader(trim($this->CustomHeader[$index][1])) ); } if (!$this->sign_key_file) { $result .= $this->headerLine('MIME-Version', '1.0'); $result .= $this->getMailMIME(); } return $result; }
[ "public", "function", "createHeader", "(", ")", "{", "$", "result", "=", "''", ";", "// Set the boundaries", "$", "uniq_id", "=", "md5", "(", "uniqid", "(", "time", "(", ")", ")", ")", ";", "$", "this", "->", "boundary", "[", "1", "]", "=", "'b1_'", ".", "$", "uniq_id", ";", "$", "this", "->", "boundary", "[", "2", "]", "=", "'b2_'", ".", "$", "uniq_id", ";", "$", "this", "->", "boundary", "[", "3", "]", "=", "'b3_'", ".", "$", "uniq_id", ";", "if", "(", "$", "this", "->", "MessageDate", "==", "''", ")", "{", "$", "this", "->", "MessageDate", "=", "self", "::", "rfcDate", "(", ")", ";", "}", "$", "result", ".=", "$", "this", "->", "headerLine", "(", "'Date'", ",", "$", "this", "->", "MessageDate", ")", ";", "// To be created automatically by mail()", "if", "(", "$", "this", "->", "SingleTo", "===", "true", ")", "{", "if", "(", "$", "this", "->", "Mailer", "!=", "'mail'", ")", "{", "foreach", "(", "$", "this", "->", "to", "as", "$", "toaddr", ")", "{", "$", "this", "->", "SingleToArray", "[", "]", "=", "$", "this", "->", "addrFormat", "(", "$", "toaddr", ")", ";", "}", "}", "}", "else", "{", "if", "(", "count", "(", "$", "this", "->", "to", ")", ">", "0", ")", "{", "if", "(", "$", "this", "->", "Mailer", "!=", "'mail'", ")", "{", "$", "result", ".=", "$", "this", "->", "addrAppend", "(", "'To'", ",", "$", "this", "->", "to", ")", ";", "}", "}", "elseif", "(", "count", "(", "$", "this", "->", "cc", ")", "==", "0", ")", "{", "$", "result", ".=", "$", "this", "->", "headerLine", "(", "'To'", ",", "'undisclosed-recipients:;'", ")", ";", "}", "}", "$", "result", ".=", "$", "this", "->", "addrAppend", "(", "'From'", ",", "array", "(", "array", "(", "trim", "(", "$", "this", "->", "From", ")", ",", "$", "this", "->", "FromName", ")", ")", ")", ";", "// sendmail and mail() extract Cc from the header before sending", "if", "(", "count", "(", "$", "this", "->", "cc", ")", ">", "0", ")", "{", "$", "result", ".=", "$", "this", "->", "addrAppend", "(", "'Cc'", ",", "$", "this", "->", "cc", ")", ";", "}", "// sendmail and mail() extract Bcc from the header before sending", "if", "(", "(", "$", "this", "->", "Mailer", "==", "'sendmail'", "or", "$", "this", "->", "Mailer", "==", "'qmail'", "or", "$", "this", "->", "Mailer", "==", "'mail'", ")", "and", "count", "(", "$", "this", "->", "bcc", ")", ">", "0", ")", "{", "$", "result", ".=", "$", "this", "->", "addrAppend", "(", "'Bcc'", ",", "$", "this", "->", "bcc", ")", ";", "}", "if", "(", "count", "(", "$", "this", "->", "ReplyTo", ")", ">", "0", ")", "{", "$", "result", ".=", "$", "this", "->", "addrAppend", "(", "'Reply-To'", ",", "$", "this", "->", "ReplyTo", ")", ";", "}", "// mail() sets the subject itself", "if", "(", "$", "this", "->", "Mailer", "!=", "'mail'", ")", "{", "$", "result", ".=", "$", "this", "->", "headerLine", "(", "'Subject'", ",", "$", "this", "->", "encodeHeader", "(", "$", "this", "->", "secureHeader", "(", "$", "this", "->", "Subject", ")", ")", ")", ";", "}", "if", "(", "$", "this", "->", "MessageID", "!=", "''", ")", "{", "$", "this", "->", "lastMessageID", "=", "$", "this", "->", "MessageID", ";", "}", "else", "{", "$", "this", "->", "lastMessageID", "=", "sprintf", "(", "'<%s@%s>'", ",", "$", "uniq_id", ",", "$", "this", "->", "ServerHostname", "(", ")", ")", ";", "}", "$", "result", ".=", "$", "this", "->", "HeaderLine", "(", "'Message-ID'", ",", "$", "this", "->", "lastMessageID", ")", ";", "$", "result", ".=", "$", "this", "->", "headerLine", "(", "'X-Priority'", ",", "$", "this", "->", "Priority", ")", ";", "if", "(", "$", "this", "->", "XMailer", "==", "''", ")", "{", "$", "result", ".=", "$", "this", "->", "headerLine", "(", "'X-Mailer'", ",", "'PHPMailer '", ".", "$", "this", "->", "Version", ".", "' (https://github.com/PHPMailer/PHPMailer/)'", ")", ";", "}", "else", "{", "$", "myXmailer", "=", "trim", "(", "$", "this", "->", "XMailer", ")", ";", "if", "(", "$", "myXmailer", ")", "{", "$", "result", ".=", "$", "this", "->", "headerLine", "(", "'X-Mailer'", ",", "$", "myXmailer", ")", ";", "}", "}", "if", "(", "$", "this", "->", "ConfirmReadingTo", "!=", "''", ")", "{", "$", "result", ".=", "$", "this", "->", "headerLine", "(", "'Disposition-Notification-To'", ",", "'<'", ".", "trim", "(", "$", "this", "->", "ConfirmReadingTo", ")", ".", "'>'", ")", ";", "}", "// Add custom headers", "for", "(", "$", "index", "=", "0", ";", "$", "index", "<", "count", "(", "$", "this", "->", "CustomHeader", ")", ";", "$", "index", "++", ")", "{", "$", "result", ".=", "$", "this", "->", "headerLine", "(", "trim", "(", "$", "this", "->", "CustomHeader", "[", "$", "index", "]", "[", "0", "]", ")", ",", "$", "this", "->", "encodeHeader", "(", "trim", "(", "$", "this", "->", "CustomHeader", "[", "$", "index", "]", "[", "1", "]", ")", ")", ")", ";", "}", "if", "(", "!", "$", "this", "->", "sign_key_file", ")", "{", "$", "result", ".=", "$", "this", "->", "headerLine", "(", "'MIME-Version'", ",", "'1.0'", ")", ";", "$", "result", ".=", "$", "this", "->", "getMailMIME", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
Assemble message headers. @access public @return string The assembled headers
[ "Assemble", "message", "headers", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L1623-L1717
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.setMessageType
protected function setMessageType() { $this->message_type = array(); if ($this->alternativeExists()) { $this->message_type[] = 'alt'; } if ($this->inlineImageExists()) { $this->message_type[] = 'inline'; } if ($this->attachmentExists()) { $this->message_type[] = 'attach'; } $this->message_type = implode('_', $this->message_type); if ($this->message_type == '') { $this->message_type = 'plain'; } }
php
protected function setMessageType() { $this->message_type = array(); if ($this->alternativeExists()) { $this->message_type[] = 'alt'; } if ($this->inlineImageExists()) { $this->message_type[] = 'inline'; } if ($this->attachmentExists()) { $this->message_type[] = 'attach'; } $this->message_type = implode('_', $this->message_type); if ($this->message_type == '') { $this->message_type = 'plain'; } }
[ "protected", "function", "setMessageType", "(", ")", "{", "$", "this", "->", "message_type", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "alternativeExists", "(", ")", ")", "{", "$", "this", "->", "message_type", "[", "]", "=", "'alt'", ";", "}", "if", "(", "$", "this", "->", "inlineImageExists", "(", ")", ")", "{", "$", "this", "->", "message_type", "[", "]", "=", "'inline'", ";", "}", "if", "(", "$", "this", "->", "attachmentExists", "(", ")", ")", "{", "$", "this", "->", "message_type", "[", "]", "=", "'attach'", ";", "}", "$", "this", "->", "message_type", "=", "implode", "(", "'_'", ",", "$", "this", "->", "message_type", ")", ";", "if", "(", "$", "this", "->", "message_type", "==", "''", ")", "{", "$", "this", "->", "message_type", "=", "'plain'", ";", "}", "}" ]
Set the message type. PHPMailer only supports some preset message types, not arbitrary MIME structures. @access protected @return void
[ "Set", "the", "message", "type", ".", "PHPMailer", "only", "supports", "some", "preset", "message", "types", "not", "arbitrary", "MIME", "structures", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L1998-L2014
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.addAttachment
public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment') { try { if (!@is_file($path)) { throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE); } // If a MIME type is not specified, try to work it out from the file name if ($type == '') { $type = self::filenameToType($path); } $filename = basename($path); if ($name == '') { $name = $filename; } $this->attachment[] = array( 0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, // isStringAttachment 6 => $disposition, 7 => 0 ); } catch (phpmailerException $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } return true; }
php
public function addAttachment($path, $name = '', $encoding = 'base64', $type = '', $disposition = 'attachment') { try { if (!@is_file($path)) { throw new phpmailerException($this->lang('file_access') . $path, self::STOP_CONTINUE); } // If a MIME type is not specified, try to work it out from the file name if ($type == '') { $type = self::filenameToType($path); } $filename = basename($path); if ($name == '') { $name = $filename; } $this->attachment[] = array( 0 => $path, 1 => $filename, 2 => $name, 3 => $encoding, 4 => $type, 5 => false, // isStringAttachment 6 => $disposition, 7 => 0 ); } catch (phpmailerException $exc) { $this->setError($exc->getMessage()); $this->edebug($exc->getMessage()); if ($this->exceptions) { throw $exc; } return false; } return true; }
[ "public", "function", "addAttachment", "(", "$", "path", ",", "$", "name", "=", "''", ",", "$", "encoding", "=", "'base64'", ",", "$", "type", "=", "''", ",", "$", "disposition", "=", "'attachment'", ")", "{", "try", "{", "if", "(", "!", "@", "is_file", "(", "$", "path", ")", ")", "{", "throw", "new", "phpmailerException", "(", "$", "this", "->", "lang", "(", "'file_access'", ")", ".", "$", "path", ",", "self", "::", "STOP_CONTINUE", ")", ";", "}", "// If a MIME type is not specified, try to work it out from the file name", "if", "(", "$", "type", "==", "''", ")", "{", "$", "type", "=", "self", "::", "filenameToType", "(", "$", "path", ")", ";", "}", "$", "filename", "=", "basename", "(", "$", "path", ")", ";", "if", "(", "$", "name", "==", "''", ")", "{", "$", "name", "=", "$", "filename", ";", "}", "$", "this", "->", "attachment", "[", "]", "=", "array", "(", "0", "=>", "$", "path", ",", "1", "=>", "$", "filename", ",", "2", "=>", "$", "name", ",", "3", "=>", "$", "encoding", ",", "4", "=>", "$", "type", ",", "5", "=>", "false", ",", "// isStringAttachment", "6", "=>", "$", "disposition", ",", "7", "=>", "0", ")", ";", "}", "catch", "(", "phpmailerException", "$", "exc", ")", "{", "$", "this", "->", "setError", "(", "$", "exc", "->", "getMessage", "(", ")", ")", ";", "$", "this", "->", "edebug", "(", "$", "exc", "->", "getMessage", "(", ")", ")", ";", "if", "(", "$", "this", "->", "exceptions", ")", "{", "throw", "$", "exc", ";", "}", "return", "false", ";", "}", "return", "true", ";", "}" ]
Add an attachment from a path on the filesystem. Returns false if the file could not be found or read. @param string $path Path to the attachment. @param string $name Overrides the attachment name. @param string $encoding File encoding (see $Encoding). @param string $type File extension (MIME) type. @param string $disposition Disposition to use @throws phpmailerException @return boolean
[ "Add", "an", "attachment", "from", "a", "path", "on", "the", "filesystem", ".", "Returns", "false", "if", "the", "file", "could", "not", "be", "found", "or", "read", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L2050-L2087
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.encodeQ
public function encodeQ($str, $position = 'text') { // There should not be any EOL in the string $pattern = ''; $encoded = str_replace(array("\r", "\n"), '', $str); switch (strtolower($position)) { case 'phrase': // RFC 2047 section 5.3 $pattern = '^A-Za-z0-9!*+\/ -'; break; /** @noinspection PhpMissingBreakStatementInspection */ case 'comment': // RFC 2047 section 5.2 $pattern = '\(\)"'; // intentional fall-through // for this reason we build the $pattern without including delimiters and [] case 'text': default: // RFC 2047 section 5.1 // Replace every high ascii, control, =, ? and _ characters $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; break; } $matches = array(); if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) { // If the string contains an '=', make sure it's the first thing we replace // so as to avoid double-encoding $eqkey = array_search('=', $matches[0]); if ($eqkey !== false) { unset($matches[0][$eqkey]); array_unshift($matches[0], '='); } foreach (array_unique($matches[0]) as $char) { $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); } } // Replace every spaces to _ (more readable than =20) return str_replace(' ', '_', $encoded); }
php
public function encodeQ($str, $position = 'text') { // There should not be any EOL in the string $pattern = ''; $encoded = str_replace(array("\r", "\n"), '', $str); switch (strtolower($position)) { case 'phrase': // RFC 2047 section 5.3 $pattern = '^A-Za-z0-9!*+\/ -'; break; /** @noinspection PhpMissingBreakStatementInspection */ case 'comment': // RFC 2047 section 5.2 $pattern = '\(\)"'; // intentional fall-through // for this reason we build the $pattern without including delimiters and [] case 'text': default: // RFC 2047 section 5.1 // Replace every high ascii, control, =, ? and _ characters $pattern = '\000-\011\013\014\016-\037\075\077\137\177-\377' . $pattern; break; } $matches = array(); if (preg_match_all("/[{$pattern}]/", $encoded, $matches)) { // If the string contains an '=', make sure it's the first thing we replace // so as to avoid double-encoding $eqkey = array_search('=', $matches[0]); if ($eqkey !== false) { unset($matches[0][$eqkey]); array_unshift($matches[0], '='); } foreach (array_unique($matches[0]) as $char) { $encoded = str_replace($char, '=' . sprintf('%02X', ord($char)), $encoded); } } // Replace every spaces to _ (more readable than =20) return str_replace(' ', '_', $encoded); }
[ "public", "function", "encodeQ", "(", "$", "str", ",", "$", "position", "=", "'text'", ")", "{", "// There should not be any EOL in the string", "$", "pattern", "=", "''", ";", "$", "encoded", "=", "str_replace", "(", "array", "(", "\"\\r\"", ",", "\"\\n\"", ")", ",", "''", ",", "$", "str", ")", ";", "switch", "(", "strtolower", "(", "$", "position", ")", ")", "{", "case", "'phrase'", ":", "// RFC 2047 section 5.3", "$", "pattern", "=", "'^A-Za-z0-9!*+\\/ -'", ";", "break", ";", "/** @noinspection PhpMissingBreakStatementInspection */", "case", "'comment'", ":", "// RFC 2047 section 5.2", "$", "pattern", "=", "'\\(\\)\"'", ";", "// intentional fall-through", "// for this reason we build the $pattern without including delimiters and []", "case", "'text'", ":", "default", ":", "// RFC 2047 section 5.1", "// Replace every high ascii, control, =, ? and _ characters", "$", "pattern", "=", "'\\000-\\011\\013\\014\\016-\\037\\075\\077\\137\\177-\\377'", ".", "$", "pattern", ";", "break", ";", "}", "$", "matches", "=", "array", "(", ")", ";", "if", "(", "preg_match_all", "(", "\"/[{$pattern}]/\"", ",", "$", "encoded", ",", "$", "matches", ")", ")", "{", "// If the string contains an '=', make sure it's the first thing we replace", "// so as to avoid double-encoding", "$", "eqkey", "=", "array_search", "(", "'='", ",", "$", "matches", "[", "0", "]", ")", ";", "if", "(", "$", "eqkey", "!==", "false", ")", "{", "unset", "(", "$", "matches", "[", "0", "]", "[", "$", "eqkey", "]", ")", ";", "array_unshift", "(", "$", "matches", "[", "0", "]", ",", "'='", ")", ";", "}", "foreach", "(", "array_unique", "(", "$", "matches", "[", "0", "]", ")", "as", "$", "char", ")", "{", "$", "encoded", "=", "str_replace", "(", "$", "char", ",", "'='", ".", "sprintf", "(", "'%02X'", ",", "ord", "(", "$", "char", ")", ")", ",", "$", "encoded", ")", ";", "}", "}", "// Replace every spaces to _ (more readable than =20)", "return", "str_replace", "(", "' '", ",", "'_'", ",", "$", "encoded", ")", ";", "}" ]
Encode a string using Q encoding. @link http://tools.ietf.org/html/rfc2047 @param string $str the text to encode @param string $position Where the text is going to be used, see the RFC for what that means @access public @return string
[ "Encode", "a", "string", "using", "Q", "encoding", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L2466-L2504
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.html2text
public function html2text($html, $advanced = false) { if ($advanced) { require_once 'extras/class.html2text.php'; $htmlconverter = new html2text($html); return $htmlconverter->get_text(); } return html_entity_decode( trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))), ENT_QUOTES, $this->CharSet ); }
php
public function html2text($html, $advanced = false) { if ($advanced) { require_once 'extras/class.html2text.php'; $htmlconverter = new html2text($html); return $htmlconverter->get_text(); } return html_entity_decode( trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))), ENT_QUOTES, $this->CharSet ); }
[ "public", "function", "html2text", "(", "$", "html", ",", "$", "advanced", "=", "false", ")", "{", "if", "(", "$", "advanced", ")", "{", "require_once", "'extras/class.html2text.php'", ";", "$", "htmlconverter", "=", "new", "html2text", "(", "$", "html", ")", ";", "return", "$", "htmlconverter", "->", "get_text", "(", ")", ";", "}", "return", "html_entity_decode", "(", "trim", "(", "strip_tags", "(", "preg_replace", "(", "'/<(head|title|style|script)[^>]*>.*?<\\/\\\\1>/si'", ",", "''", ",", "$", "html", ")", ")", ")", ",", "ENT_QUOTES", ",", "$", "this", "->", "CharSet", ")", ";", "}" ]
Convert an HTML string into plain text. @param string $html The HTML text to convert @param boolean $advanced Should this use the more complex html2text converter or just a simple one? @return string
[ "Convert", "an", "HTML", "string", "into", "plain", "text", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L2926-L2938
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer._mime_types
public static function _mime_types($ext = '') { $mimes = array( 'xl' => 'application/excel', 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'bin' => 'application/macbinary', 'doc' => 'application/msword', 'word' => 'application/msword', 'class' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'dms' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'psd' => 'application/octet-stream', 'sea' => 'application/octet-stream', 'so' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'gtar' => 'application/x-gtar', 'php3' => 'application/x-httpd-php', 'php4' => 'application/x-httpd-php', 'php' => 'application/x-httpd-php', 'phtml' => 'application/x-httpd-php', 'phps' => 'application/x-httpd-php-source', 'js' => 'application/x-javascript', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'tar' => 'application/x-tar', 'tgz' => 'application/x-tar', 'xht' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml', 'zip' => 'application/zip', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mpga' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'wav' => 'audio/x-wav', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'jpg' => 'image/jpeg', 'png' => 'image/png', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'eml' => 'message/rfc822', 'css' => 'text/css', 'html' => 'text/html', 'htm' => 'text/html', 'shtml' => 'text/html', 'log' => 'text/plain', 'text' => 'text/plain', 'txt' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'vcf' => 'text/vcard', 'vcard' => 'text/vcard', 'xml' => 'text/xml', 'xsl' => 'text/xml', 'mpeg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mov' => 'video/quicktime', 'qt' => 'video/quicktime', 'rv' => 'video/vnd.rn-realvideo', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie' ); return (array_key_exists(strtolower($ext), $mimes) ? $mimes[strtolower($ext)]: 'application/octet-stream'); }
php
public static function _mime_types($ext = '') { $mimes = array( 'xl' => 'application/excel', 'hqx' => 'application/mac-binhex40', 'cpt' => 'application/mac-compactpro', 'bin' => 'application/macbinary', 'doc' => 'application/msword', 'word' => 'application/msword', 'class' => 'application/octet-stream', 'dll' => 'application/octet-stream', 'dms' => 'application/octet-stream', 'exe' => 'application/octet-stream', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'psd' => 'application/octet-stream', 'sea' => 'application/octet-stream', 'so' => 'application/octet-stream', 'oda' => 'application/oda', 'pdf' => 'application/pdf', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', 'smi' => 'application/smil', 'smil' => 'application/smil', 'mif' => 'application/vnd.mif', 'xls' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'wbxml' => 'application/vnd.wap.wbxml', 'wmlc' => 'application/vnd.wap.wmlc', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'dxr' => 'application/x-director', 'dvi' => 'application/x-dvi', 'gtar' => 'application/x-gtar', 'php3' => 'application/x-httpd-php', 'php4' => 'application/x-httpd-php', 'php' => 'application/x-httpd-php', 'phtml' => 'application/x-httpd-php', 'phps' => 'application/x-httpd-php-source', 'js' => 'application/x-javascript', 'swf' => 'application/x-shockwave-flash', 'sit' => 'application/x-stuffit', 'tar' => 'application/x-tar', 'tgz' => 'application/x-tar', 'xht' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml', 'zip' => 'application/zip', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mpga' => 'audio/mpeg', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'ram' => 'audio/x-pn-realaudio', 'rm' => 'audio/x-pn-realaudio', 'rpm' => 'audio/x-pn-realaudio-plugin', 'ra' => 'audio/x-realaudio', 'wav' => 'audio/x-wav', 'bmp' => 'image/bmp', 'gif' => 'image/gif', 'jpeg' => 'image/jpeg', 'jpe' => 'image/jpeg', 'jpg' => 'image/jpeg', 'png' => 'image/png', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'eml' => 'message/rfc822', 'css' => 'text/css', 'html' => 'text/html', 'htm' => 'text/html', 'shtml' => 'text/html', 'log' => 'text/plain', 'text' => 'text/plain', 'txt' => 'text/plain', 'rtx' => 'text/richtext', 'rtf' => 'text/rtf', 'vcf' => 'text/vcard', 'vcard' => 'text/vcard', 'xml' => 'text/xml', 'xsl' => 'text/xml', 'mpeg' => 'video/mpeg', 'mpe' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mov' => 'video/quicktime', 'qt' => 'video/quicktime', 'rv' => 'video/vnd.rn-realvideo', 'avi' => 'video/x-msvideo', 'movie' => 'video/x-sgi-movie' ); return (array_key_exists(strtolower($ext), $mimes) ? $mimes[strtolower($ext)]: 'application/octet-stream'); }
[ "public", "static", "function", "_mime_types", "(", "$", "ext", "=", "''", ")", "{", "$", "mimes", "=", "array", "(", "'xl'", "=>", "'application/excel'", ",", "'hqx'", "=>", "'application/mac-binhex40'", ",", "'cpt'", "=>", "'application/mac-compactpro'", ",", "'bin'", "=>", "'application/macbinary'", ",", "'doc'", "=>", "'application/msword'", ",", "'word'", "=>", "'application/msword'", ",", "'class'", "=>", "'application/octet-stream'", ",", "'dll'", "=>", "'application/octet-stream'", ",", "'dms'", "=>", "'application/octet-stream'", ",", "'exe'", "=>", "'application/octet-stream'", ",", "'lha'", "=>", "'application/octet-stream'", ",", "'lzh'", "=>", "'application/octet-stream'", ",", "'psd'", "=>", "'application/octet-stream'", ",", "'sea'", "=>", "'application/octet-stream'", ",", "'so'", "=>", "'application/octet-stream'", ",", "'oda'", "=>", "'application/oda'", ",", "'pdf'", "=>", "'application/pdf'", ",", "'ai'", "=>", "'application/postscript'", ",", "'eps'", "=>", "'application/postscript'", ",", "'ps'", "=>", "'application/postscript'", ",", "'smi'", "=>", "'application/smil'", ",", "'smil'", "=>", "'application/smil'", ",", "'mif'", "=>", "'application/vnd.mif'", ",", "'xls'", "=>", "'application/vnd.ms-excel'", ",", "'ppt'", "=>", "'application/vnd.ms-powerpoint'", ",", "'wbxml'", "=>", "'application/vnd.wap.wbxml'", ",", "'wmlc'", "=>", "'application/vnd.wap.wmlc'", ",", "'dcr'", "=>", "'application/x-director'", ",", "'dir'", "=>", "'application/x-director'", ",", "'dxr'", "=>", "'application/x-director'", ",", "'dvi'", "=>", "'application/x-dvi'", ",", "'gtar'", "=>", "'application/x-gtar'", ",", "'php3'", "=>", "'application/x-httpd-php'", ",", "'php4'", "=>", "'application/x-httpd-php'", ",", "'php'", "=>", "'application/x-httpd-php'", ",", "'phtml'", "=>", "'application/x-httpd-php'", ",", "'phps'", "=>", "'application/x-httpd-php-source'", ",", "'js'", "=>", "'application/x-javascript'", ",", "'swf'", "=>", "'application/x-shockwave-flash'", ",", "'sit'", "=>", "'application/x-stuffit'", ",", "'tar'", "=>", "'application/x-tar'", ",", "'tgz'", "=>", "'application/x-tar'", ",", "'xht'", "=>", "'application/xhtml+xml'", ",", "'xhtml'", "=>", "'application/xhtml+xml'", ",", "'zip'", "=>", "'application/zip'", ",", "'mid'", "=>", "'audio/midi'", ",", "'midi'", "=>", "'audio/midi'", ",", "'mp2'", "=>", "'audio/mpeg'", ",", "'mp3'", "=>", "'audio/mpeg'", ",", "'mpga'", "=>", "'audio/mpeg'", ",", "'aif'", "=>", "'audio/x-aiff'", ",", "'aifc'", "=>", "'audio/x-aiff'", ",", "'aiff'", "=>", "'audio/x-aiff'", ",", "'ram'", "=>", "'audio/x-pn-realaudio'", ",", "'rm'", "=>", "'audio/x-pn-realaudio'", ",", "'rpm'", "=>", "'audio/x-pn-realaudio-plugin'", ",", "'ra'", "=>", "'audio/x-realaudio'", ",", "'wav'", "=>", "'audio/x-wav'", ",", "'bmp'", "=>", "'image/bmp'", ",", "'gif'", "=>", "'image/gif'", ",", "'jpeg'", "=>", "'image/jpeg'", ",", "'jpe'", "=>", "'image/jpeg'", ",", "'jpg'", "=>", "'image/jpeg'", ",", "'png'", "=>", "'image/png'", ",", "'tiff'", "=>", "'image/tiff'", ",", "'tif'", "=>", "'image/tiff'", ",", "'eml'", "=>", "'message/rfc822'", ",", "'css'", "=>", "'text/css'", ",", "'html'", "=>", "'text/html'", ",", "'htm'", "=>", "'text/html'", ",", "'shtml'", "=>", "'text/html'", ",", "'log'", "=>", "'text/plain'", ",", "'text'", "=>", "'text/plain'", ",", "'txt'", "=>", "'text/plain'", ",", "'rtx'", "=>", "'text/richtext'", ",", "'rtf'", "=>", "'text/rtf'", ",", "'vcf'", "=>", "'text/vcard'", ",", "'vcard'", "=>", "'text/vcard'", ",", "'xml'", "=>", "'text/xml'", ",", "'xsl'", "=>", "'text/xml'", ",", "'mpeg'", "=>", "'video/mpeg'", ",", "'mpe'", "=>", "'video/mpeg'", ",", "'mpg'", "=>", "'video/mpeg'", ",", "'mov'", "=>", "'video/quicktime'", ",", "'qt'", "=>", "'video/quicktime'", ",", "'rv'", "=>", "'video/vnd.rn-realvideo'", ",", "'avi'", "=>", "'video/x-msvideo'", ",", "'movie'", "=>", "'video/x-sgi-movie'", ")", ";", "return", "(", "array_key_exists", "(", "strtolower", "(", "$", "ext", ")", ",", "$", "mimes", ")", "?", "$", "mimes", "[", "strtolower", "(", "$", "ext", ")", "]", ":", "'application/octet-stream'", ")", ";", "}" ]
Get the MIME type for a file extension. @param string $ext File extension @access public @return string MIME type of file. @static
[ "Get", "the", "MIME", "type", "for", "a", "file", "extension", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L2947-L3040
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.filenameToType
public static function filenameToType($filename) { // In case the path is a URL, strip any query string before getting extension $qpos = strpos($filename, '?'); if ($qpos !== false) { $filename = substr($filename, 0, $qpos); } $pathinfo = self::mb_pathinfo($filename); return self::_mime_types($pathinfo['extension']); }
php
public static function filenameToType($filename) { // In case the path is a URL, strip any query string before getting extension $qpos = strpos($filename, '?'); if ($qpos !== false) { $filename = substr($filename, 0, $qpos); } $pathinfo = self::mb_pathinfo($filename); return self::_mime_types($pathinfo['extension']); }
[ "public", "static", "function", "filenameToType", "(", "$", "filename", ")", "{", "// In case the path is a URL, strip any query string before getting extension", "$", "qpos", "=", "strpos", "(", "$", "filename", ",", "'?'", ")", ";", "if", "(", "$", "qpos", "!==", "false", ")", "{", "$", "filename", "=", "substr", "(", "$", "filename", ",", "0", ",", "$", "qpos", ")", ";", "}", "$", "pathinfo", "=", "self", "::", "mb_pathinfo", "(", "$", "filename", ")", ";", "return", "self", "::", "_mime_types", "(", "$", "pathinfo", "[", "'extension'", "]", ")", ";", "}" ]
Map a file name to a MIME type. Defaults to 'application/octet-stream', i.e.. arbitrary binary data. @param string $filename A file name or full path, does not need to exist as a file @return string @static
[ "Map", "a", "file", "name", "to", "a", "MIME", "type", ".", "Defaults", "to", "application", "/", "octet", "-", "stream", "i", ".", "e", "..", "arbitrary", "binary", "data", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L3049-L3058
ClanCats/Core
src/bundles/Mail/PHPMailer/class.phpmailer.php
PHPMailer.set
public function set($name, $value = '') { try { if (isset($this->$name)) { $this->$name = $value; } else { throw new phpmailerException($this->lang('variable_set') . $name, self::STOP_CRITICAL); } } catch (Exception $exc) { $this->setError($exc->getMessage()); if ($exc->getCode() == self::STOP_CRITICAL) { return false; } } return true; }
php
public function set($name, $value = '') { try { if (isset($this->$name)) { $this->$name = $value; } else { throw new phpmailerException($this->lang('variable_set') . $name, self::STOP_CRITICAL); } } catch (Exception $exc) { $this->setError($exc->getMessage()); if ($exc->getCode() == self::STOP_CRITICAL) { return false; } } return true; }
[ "public", "function", "set", "(", "$", "name", ",", "$", "value", "=", "''", ")", "{", "try", "{", "if", "(", "isset", "(", "$", "this", "->", "$", "name", ")", ")", "{", "$", "this", "->", "$", "name", "=", "$", "value", ";", "}", "else", "{", "throw", "new", "phpmailerException", "(", "$", "this", "->", "lang", "(", "'variable_set'", ")", ".", "$", "name", ",", "self", "::", "STOP_CRITICAL", ")", ";", "}", "}", "catch", "(", "Exception", "$", "exc", ")", "{", "$", "this", "->", "setError", "(", "$", "exc", "->", "getMessage", "(", ")", ")", ";", "if", "(", "$", "exc", "->", "getCode", "(", ")", "==", "self", "::", "STOP_CRITICAL", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Set or reset instance properties. Usage Example: $page->set('X-Priority', '3'); @access public @param string $name @param mixed $value NOTE: will not work with arrays, there are no arrays to set/reset @throws phpmailerException @return boolean @TODO Should this not be using __set() magic function?
[ "Set", "or", "reset", "instance", "properties", "." ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/bundles/Mail/PHPMailer/class.phpmailer.php#L3121-L3136
webtown-php/KunstmaanExtensionBundle
src/Entity/PageParts/InsertPagePagePart.php
InsertPagePagePart.setNode
public function setNode(\Kunstmaan\NodeBundle\Entity\Node $node = null) { $this->node = $node; return $this; }
php
public function setNode(\Kunstmaan\NodeBundle\Entity\Node $node = null) { $this->node = $node; return $this; }
[ "public", "function", "setNode", "(", "\\", "Kunstmaan", "\\", "NodeBundle", "\\", "Entity", "\\", "Node", "$", "node", "=", "null", ")", "{", "$", "this", "->", "node", "=", "$", "node", ";", "return", "$", "this", ";", "}" ]
Set node @param \Kunstmaan\NodeBundle\Entity\Node $node @return InsertPagePagePart
[ "Set", "node" ]
train
https://github.com/webtown-php/KunstmaanExtensionBundle/blob/86c656c131295fe1f3f7694fd4da1e5e454076b9/src/Entity/PageParts/InsertPagePagePart.php#L32-L37
ClanCats/Core
src/classes/ClanCats.php
ClanCats.runtime
public static function runtime( $fnc = null, $params = array() ) { if ( is_null( $fnc ) ) { return static::$runtime_class; } return call_user_func_array( array( static::$runtime_class, $fnc ), $params ); }
php
public static function runtime( $fnc = null, $params = array() ) { if ( is_null( $fnc ) ) { return static::$runtime_class; } return call_user_func_array( array( static::$runtime_class, $fnc ), $params ); }
[ "public", "static", "function", "runtime", "(", "$", "fnc", "=", "null", ",", "$", "params", "=", "array", "(", ")", ")", "{", "if", "(", "is_null", "(", "$", "fnc", ")", ")", "{", "return", "static", "::", "$", "runtime_class", ";", "}", "return", "call_user_func_array", "(", "array", "(", "static", "::", "$", "runtime_class", ",", "$", "fnc", ")", ",", "$", "params", ")", ";", "}" ]
get the current runtime class name or execute an function on the runtime class @return string
[ "get", "the", "current", "runtime", "class", "name", "or", "execute", "an", "function", "on", "the", "runtime", "class" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/ClanCats.php#L111-L119
ClanCats/Core
src/classes/ClanCats.php
ClanCats.paths
public static function paths( $paths = null, $define = true ) { if ( is_null( $paths ) ) { return static::$paths; } foreach( $paths as $key => $path ) { static::$paths[$key] = $path; if ( $define === true ) { define( strtoupper( $key ).'PATH', $path ); } } }
php
public static function paths( $paths = null, $define = true ) { if ( is_null( $paths ) ) { return static::$paths; } foreach( $paths as $key => $path ) { static::$paths[$key] = $path; if ( $define === true ) { define( strtoupper( $key ).'PATH', $path ); } } }
[ "public", "static", "function", "paths", "(", "$", "paths", "=", "null", ",", "$", "define", "=", "true", ")", "{", "if", "(", "is_null", "(", "$", "paths", ")", ")", "{", "return", "static", "::", "$", "paths", ";", "}", "foreach", "(", "$", "paths", "as", "$", "key", "=>", "$", "path", ")", "{", "static", "::", "$", "paths", "[", "$", "key", "]", "=", "$", "path", ";", "if", "(", "$", "define", "===", "true", ")", "{", "define", "(", "strtoupper", "(", "$", "key", ")", ".", "'PATH'", ",", "$", "path", ")", ";", "}", "}", "}" ]
paths getter and setter when paths empty: return all registerd paths when paths an array: adds paths to the index and optional create a define. @param array $paths @param bool $define @return array|void
[ "paths", "getter", "and", "setter" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/ClanCats.php#L162-L178
ClanCats/Core
src/classes/ClanCats.php
ClanCats.directories
public static function directories( $dirs = null, $define = true ) { if ( is_null( $dirs ) ) { return static::$directories; } foreach( $dirs as $key => $dir ) { static::$directories[$key] = $dir; if ( $define === true ) { define( 'CCDIR_'.strtoupper( $key ), $dir ); } } }
php
public static function directories( $dirs = null, $define = true ) { if ( is_null( $dirs ) ) { return static::$directories; } foreach( $dirs as $key => $dir ) { static::$directories[$key] = $dir; if ( $define === true ) { define( 'CCDIR_'.strtoupper( $key ), $dir ); } } }
[ "public", "static", "function", "directories", "(", "$", "dirs", "=", "null", ",", "$", "define", "=", "true", ")", "{", "if", "(", "is_null", "(", "$", "dirs", ")", ")", "{", "return", "static", "::", "$", "directories", ";", "}", "foreach", "(", "$", "dirs", "as", "$", "key", "=>", "$", "dir", ")", "{", "static", "::", "$", "directories", "[", "$", "key", "]", "=", "$", "dir", ";", "if", "(", "$", "define", "===", "true", ")", "{", "define", "(", "'CCDIR_'", ".", "strtoupper", "(", "$", "key", ")", ",", "$", "dir", ")", ";", "}", "}", "}" ]
directories getter and setter when dirs empty: return all registerd directories when dirs an array: adds directories to the index and optional create a define. @param array $paths @param bool $define @return array|void
[ "directories", "getter", "and", "setter" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/ClanCats.php#L193-L209
ClanCats/Core
src/classes/ClanCats.php
ClanCats.environment_detector
public static function environment_detector( $env ) { $detected_environment = 'development'; if ( isset( $env ) && !empty( $env ) ) { if ( is_string( $env ) ) { $detected_environment = $env; } elseif ( is_array( $env ) ) { if ( isset( $env[':all'] ) ) { $detected_environment = $env[':all']; } foreach( $env as $host => $host_env ) { $rgx = "~^".str_replace( '*', '(.*)', $host )."$~"; if ( preg_match( $rgx, $_SERVER['HTTP_HOST'] ) ) { $detected_environment = $host_env; } } } elseif ( is_callable( $env ) ) { return call_user_func( $env ); } } return $detected_environment; }
php
public static function environment_detector( $env ) { $detected_environment = 'development'; if ( isset( $env ) && !empty( $env ) ) { if ( is_string( $env ) ) { $detected_environment = $env; } elseif ( is_array( $env ) ) { if ( isset( $env[':all'] ) ) { $detected_environment = $env[':all']; } foreach( $env as $host => $host_env ) { $rgx = "~^".str_replace( '*', '(.*)', $host )."$~"; if ( preg_match( $rgx, $_SERVER['HTTP_HOST'] ) ) { $detected_environment = $host_env; } } } elseif ( is_callable( $env ) ) { return call_user_func( $env ); } } return $detected_environment; }
[ "public", "static", "function", "environment_detector", "(", "$", "env", ")", "{", "$", "detected_environment", "=", "'development'", ";", "if", "(", "isset", "(", "$", "env", ")", "&&", "!", "empty", "(", "$", "env", ")", ")", "{", "if", "(", "is_string", "(", "$", "env", ")", ")", "{", "$", "detected_environment", "=", "$", "env", ";", "}", "elseif", "(", "is_array", "(", "$", "env", ")", ")", "{", "if", "(", "isset", "(", "$", "env", "[", "':all'", "]", ")", ")", "{", "$", "detected_environment", "=", "$", "env", "[", "':all'", "]", ";", "}", "foreach", "(", "$", "env", "as", "$", "host", "=>", "$", "host_env", ")", "{", "$", "rgx", "=", "\"~^\"", ".", "str_replace", "(", "'*'", ",", "'(.*)'", ",", "$", "host", ")", ".", "\"$~\"", ";", "if", "(", "preg_match", "(", "$", "rgx", ",", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ")", ")", "{", "$", "detected_environment", "=", "$", "host_env", ";", "}", "}", "}", "elseif", "(", "is_callable", "(", "$", "env", ")", ")", "{", "return", "call_user_func", "(", "$", "env", ")", ";", "}", "}", "return", "$", "detected_environment", ";", "}" ]
Detect the environment by the given parameter. You can pass arrays, strings and callbacks: array: // if you pass an array the detector is going // to try to match the HTTP_HOST as key. array( 'localhost' => 'development', ':all' => 'production' ) string: return 'staging' callback: function() { return $_SERVER['CCF_ENV']; } If the detector fails he wil return the default environment. @param mixed $env @return string
[ "Detect", "the", "environment", "by", "the", "given", "parameter", ".", "You", "can", "pass", "arrays", "strings", "and", "callbacks", ":" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/ClanCats.php#L247-L281
ClanCats/Core
src/classes/ClanCats.php
ClanCats.wake
public static function wake( $environment ) { if ( !is_null( static::$environment ) ) { throw new CCException( "ClanCats::wake - you cannot wake the application twice." ); } // set environment static::$environment = $environment; // load the main configuration static::$config = CCConfig::create( 'main' ); // setup the application error tables CCError_Inspector::info_callback( 'ClanCatsFramework', function() { return array( 'Runtime Class' => \ClanCats::runtime(), 'CCF Version' => \ClanCats::version(), 'CCF Environment' => \ClanCats::environment(), 'Development env' => var_export( \ClanCats::in_development(), true ), 'File extention' => EXT, 'Core namespace' => CCCORE_NAMESPACE, ); }); CCError_Inspector::info_callback( 'CCF Paths', array( 'ClanCats', 'paths' ) ); CCError_Inspector::info_callback( 'CCF Directories', array( 'ClanCats', 'directories' ) ); CCError_Inspector::info_callback( 'Namespaces', function() { return \CCFinder::$namespaces; }); }
php
public static function wake( $environment ) { if ( !is_null( static::$environment ) ) { throw new CCException( "ClanCats::wake - you cannot wake the application twice." ); } // set environment static::$environment = $environment; // load the main configuration static::$config = CCConfig::create( 'main' ); // setup the application error tables CCError_Inspector::info_callback( 'ClanCatsFramework', function() { return array( 'Runtime Class' => \ClanCats::runtime(), 'CCF Version' => \ClanCats::version(), 'CCF Environment' => \ClanCats::environment(), 'Development env' => var_export( \ClanCats::in_development(), true ), 'File extention' => EXT, 'Core namespace' => CCCORE_NAMESPACE, ); }); CCError_Inspector::info_callback( 'CCF Paths', array( 'ClanCats', 'paths' ) ); CCError_Inspector::info_callback( 'CCF Directories', array( 'ClanCats', 'directories' ) ); CCError_Inspector::info_callback( 'Namespaces', function() { return \CCFinder::$namespaces; }); }
[ "public", "static", "function", "wake", "(", "$", "environment", ")", "{", "if", "(", "!", "is_null", "(", "static", "::", "$", "environment", ")", ")", "{", "throw", "new", "CCException", "(", "\"ClanCats::wake - you cannot wake the application twice.\"", ")", ";", "}", "// set environment", "static", "::", "$", "environment", "=", "$", "environment", ";", "// load the main configuration", "static", "::", "$", "config", "=", "CCConfig", "::", "create", "(", "'main'", ")", ";", "// setup the application error tables", "CCError_Inspector", "::", "info_callback", "(", "'ClanCatsFramework'", ",", "function", "(", ")", "{", "return", "array", "(", "'Runtime Class'", "=>", "\\", "ClanCats", "::", "runtime", "(", ")", ",", "'CCF Version'", "=>", "\\", "ClanCats", "::", "version", "(", ")", ",", "'CCF Environment'", "=>", "\\", "ClanCats", "::", "environment", "(", ")", ",", "'Development env'", "=>", "var_export", "(", "\\", "ClanCats", "::", "in_development", "(", ")", ",", "true", ")", ",", "'File extention'", "=>", "EXT", ",", "'Core namespace'", "=>", "CCCORE_NAMESPACE", ",", ")", ";", "}", ")", ";", "CCError_Inspector", "::", "info_callback", "(", "'CCF Paths'", ",", "array", "(", "'ClanCats'", ",", "'paths'", ")", ")", ";", "CCError_Inspector", "::", "info_callback", "(", "'CCF Directories'", ",", "array", "(", "'ClanCats'", ",", "'directories'", ")", ")", ";", "CCError_Inspector", "::", "info_callback", "(", "'Namespaces'", ",", "function", "(", ")", "{", "return", "\\", "CCFinder", "::", "$", "namespaces", ";", "}", ")", ";", "}" ]
start the ccf lifecycle this method sets the current environment, loads the configuration and wakes the application @param string $environment @return void
[ "start", "the", "ccf", "lifecycle" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/ClanCats.php#L292-L322
ClanCats/Core
src/classes/ClanCats.php
ClanCats.wake_app
public static function wake_app( $app ) { static::$runtime_class = $app; \CCFinder::bind( $app, static::$paths['app'].$app.EXT ); // run the application wake $response = $app::wake(); // when the application wake returns an response we display it if ( $response instanceof CCResponse ) { if ( static::$config->send_app_wake_response ) { $response->send( true ); die; } } $response = null; // run the environment wake if ( method_exists( $app, 'wake_'.static::$environment ) ) { $response = call_user_func( $app.'::wake_'.static::$environment ); // when the application env wake returns an response we display it if ( $response instanceof CCResponse ) { if ( static::$config->send_app_wake_response ) { $response->send( true ); die; } } } // add routes from the app CCRouter::on( $app::routes() ); }
php
public static function wake_app( $app ) { static::$runtime_class = $app; \CCFinder::bind( $app, static::$paths['app'].$app.EXT ); // run the application wake $response = $app::wake(); // when the application wake returns an response we display it if ( $response instanceof CCResponse ) { if ( static::$config->send_app_wake_response ) { $response->send( true ); die; } } $response = null; // run the environment wake if ( method_exists( $app, 'wake_'.static::$environment ) ) { $response = call_user_func( $app.'::wake_'.static::$environment ); // when the application env wake returns an response we display it if ( $response instanceof CCResponse ) { if ( static::$config->send_app_wake_response ) { $response->send( true ); die; } } } // add routes from the app CCRouter::on( $app::routes() ); }
[ "public", "static", "function", "wake_app", "(", "$", "app", ")", "{", "static", "::", "$", "runtime_class", "=", "$", "app", ";", "\\", "CCFinder", "::", "bind", "(", "$", "app", ",", "static", "::", "$", "paths", "[", "'app'", "]", ".", "$", "app", ".", "EXT", ")", ";", "// run the application wake", "$", "response", "=", "$", "app", "::", "wake", "(", ")", ";", "// when the application wake returns an response we display it", "if", "(", "$", "response", "instanceof", "CCResponse", ")", "{", "if", "(", "static", "::", "$", "config", "->", "send_app_wake_response", ")", "{", "$", "response", "->", "send", "(", "true", ")", ";", "die", ";", "}", "}", "$", "response", "=", "null", ";", "// run the environment wake", "if", "(", "method_exists", "(", "$", "app", ",", "'wake_'", ".", "static", "::", "$", "environment", ")", ")", "{", "$", "response", "=", "call_user_func", "(", "$", "app", ".", "'::wake_'", ".", "static", "::", "$", "environment", ")", ";", "// when the application env wake returns an response we display it", "if", "(", "$", "response", "instanceof", "CCResponse", ")", "{", "if", "(", "static", "::", "$", "config", "->", "send_app_wake_response", ")", "{", "$", "response", "->", "send", "(", "true", ")", ";", "die", ";", "}", "}", "}", "// add routes from the app", "CCRouter", "::", "on", "(", "$", "app", "::", "routes", "(", ")", ")", ";", "}" ]
start the ccf app lifecycle This method registers the App class and runs the wake events. @param string $app The used app class = APPATH/<$app>.php @return void
[ "start", "the", "ccf", "app", "lifecycle" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/ClanCats.php#L332-L364
qcubed/orm
src/Query/Node/Column.php
Column.join
public function join( Builder $objBuilder, $blnExpandSelection = false, iCondition $objJoinCondition = null, Clause\Select $objSelect = null ) { $objParentNode = $this->objParentNode; if (!$objParentNode) { throw new Caller('A column node must have a parent node.'); } else { // Here we pass the join condition on to the parent object $objParentNode->join($objBuilder, $blnExpandSelection, $objJoinCondition, $objSelect); } }
php
public function join( Builder $objBuilder, $blnExpandSelection = false, iCondition $objJoinCondition = null, Clause\Select $objSelect = null ) { $objParentNode = $this->objParentNode; if (!$objParentNode) { throw new Caller('A column node must have a parent node.'); } else { // Here we pass the join condition on to the parent object $objParentNode->join($objBuilder, $blnExpandSelection, $objJoinCondition, $objSelect); } }
[ "public", "function", "join", "(", "Builder", "$", "objBuilder", ",", "$", "blnExpandSelection", "=", "false", ",", "iCondition", "$", "objJoinCondition", "=", "null", ",", "Clause", "\\", "Select", "$", "objSelect", "=", "null", ")", "{", "$", "objParentNode", "=", "$", "this", "->", "objParentNode", ";", "if", "(", "!", "$", "objParentNode", ")", "{", "throw", "new", "Caller", "(", "'A column node must have a parent node.'", ")", ";", "}", "else", "{", "// Here we pass the join condition on to the parent object", "$", "objParentNode", "->", "join", "(", "$", "objBuilder", ",", "$", "blnExpandSelection", ",", "$", "objJoinCondition", ",", "$", "objSelect", ")", ";", "}", "}" ]
Join the node to the given query. Since this is a leaf node, we pass on the join to the parent. @param Builder $objBuilder @param bool $blnExpandSelection @param iCondition|null $objJoinCondition @param Clause\Select|null $objSelect @throws Caller
[ "Join", "the", "node", "to", "the", "given", "query", ".", "Since", "this", "is", "a", "leaf", "node", "we", "pass", "on", "the", "join", "to", "the", "parent", "." ]
train
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/Node/Column.php#L96-L109
qcubed/orm
src/Query/Node/Column.php
Column.getAsManualSqlColumn
public function getAsManualSqlColumn() { if ($this->strTableName) { return $this->strTableName . '.' . $this->strName; } else { if (($this->objParentNode) && ($this->objParentNode->strTableName)) { return $this->objParentNode->strTableName . '.' . $this->strName; } else { return $this->strName; } } }
php
public function getAsManualSqlColumn() { if ($this->strTableName) { return $this->strTableName . '.' . $this->strName; } else { if (($this->objParentNode) && ($this->objParentNode->strTableName)) { return $this->objParentNode->strTableName . '.' . $this->strName; } else { return $this->strName; } } }
[ "public", "function", "getAsManualSqlColumn", "(", ")", "{", "if", "(", "$", "this", "->", "strTableName", ")", "{", "return", "$", "this", "->", "strTableName", ".", "'.'", ".", "$", "this", "->", "strName", ";", "}", "else", "{", "if", "(", "(", "$", "this", "->", "objParentNode", ")", "&&", "(", "$", "this", "->", "objParentNode", "->", "strTableName", ")", ")", "{", "return", "$", "this", "->", "objParentNode", "->", "strTableName", ".", "'.'", ".", "$", "this", "->", "strName", ";", "}", "else", "{", "return", "$", "this", "->", "strName", ";", "}", "}", "}" ]
Get the unaliased column name. For special situations, like order by, since you can't order by aliases. @return string
[ "Get", "the", "unaliased", "column", "name", ".", "For", "special", "situations", "like", "order", "by", "since", "you", "can", "t", "order", "by", "aliases", "." ]
train
https://github.com/qcubed/orm/blob/f320eba671f20874b1f3809c5293f8c02d5b1204/src/Query/Node/Column.php#L115-L126
aedart/laravel-helpers
src/Traits/Routing/RouteTrait.php
RouteTrait.getRoute
public function getRoute(): ?Registrar { if (!$this->hasRoute()) { $this->setRoute($this->getDefaultRoute()); } return $this->route; }
php
public function getRoute(): ?Registrar { if (!$this->hasRoute()) { $this->setRoute($this->getDefaultRoute()); } return $this->route; }
[ "public", "function", "getRoute", "(", ")", ":", "?", "Registrar", "{", "if", "(", "!", "$", "this", "->", "hasRoute", "(", ")", ")", "{", "$", "this", "->", "setRoute", "(", "$", "this", "->", "getDefaultRoute", "(", ")", ")", ";", "}", "return", "$", "this", "->", "route", ";", "}" ]
Get route If no route has been set, this method will set and return a default route, if any such value is available @see getDefaultRoute() @return Registrar|null route or null if none route has been set
[ "Get", "route" ]
train
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Routing/RouteTrait.php#L53-L59
meccado/acl-admin-control-panel
src/Http/Controllers/Admin/AdminController.php
AdminController.index
public function index() { $user = \App\User::with('profile')->findOrFail(\Auth::user()->id); return \View::make('acl::admin.dashboard', [ 'user' => $user, 'title' => 'list', ]); }
php
public function index() { $user = \App\User::with('profile')->findOrFail(\Auth::user()->id); return \View::make('acl::admin.dashboard', [ 'user' => $user, 'title' => 'list', ]); }
[ "public", "function", "index", "(", ")", "{", "$", "user", "=", "\\", "App", "\\", "User", "::", "with", "(", "'profile'", ")", "->", "findOrFail", "(", "\\", "Auth", "::", "user", "(", ")", "->", "id", ")", ";", "return", "\\", "View", "::", "make", "(", "'acl::admin.dashboard'", ",", "[", "'user'", "=>", "$", "user", ",", "'title'", "=>", "'list'", ",", "]", ")", ";", "}" ]
\Illuminate\Routing\Router $router
[ "\\", "Illuminate", "\\", "Routing", "\\", "Router", "$router" ]
train
https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/AdminController.php#L31-L38
meccado/acl-admin-control-panel
src/Http/Controllers/Admin/AdminController.php
AdminController.getUserRolePermissions
public function getUserRolePermissions() { $roles = Role::select('id', 'name', 'label')->get(); $permissions = Permission::select('id', 'name', 'label')->get(); return \View::make('admin.permissions.role-assign-permissions', [ 'roles' => $roles, 'permissions' => $permissions, 'title' => 'assign', ]); }
php
public function getUserRolePermissions() { $roles = Role::select('id', 'name', 'label')->get(); $permissions = Permission::select('id', 'name', 'label')->get(); return \View::make('admin.permissions.role-assign-permissions', [ 'roles' => $roles, 'permissions' => $permissions, 'title' => 'assign', ]); }
[ "public", "function", "getUserRolePermissions", "(", ")", "{", "$", "roles", "=", "Role", "::", "select", "(", "'id'", ",", "'name'", ",", "'label'", ")", "->", "get", "(", ")", ";", "$", "permissions", "=", "Permission", "::", "select", "(", "'id'", ",", "'name'", ",", "'label'", ")", "->", "get", "(", ")", ";", "return", "\\", "View", "::", "make", "(", "'admin.permissions.role-assign-permissions'", ",", "[", "'roles'", "=>", "$", "roles", ",", "'permissions'", "=>", "$", "permissions", ",", "'title'", "=>", "'assign'", ",", "]", ")", ";", "}" ]
Display given permissions to role. @return void
[ "Display", "given", "permissions", "to", "role", "." ]
train
https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/AdminController.php#L45-L54
meccado/acl-admin-control-panel
src/Http/Controllers/Admin/AdminController.php
AdminController.postUserRolePermissions
public function postUserRolePermissions(Request $request) { $this->validate($request, ['role' => 'required', 'permissions' => 'required']); $role = Role::with('permissions')->whereName($request->role)->first(); $role->permissions()->detach(); foreach ($request->permissions as $permission_name) { $permission = Permission::whereName($permission_name)->first(); $role->assign($permission); } \Session::flash('flash_message', 'Permission granted!'); return \Redirect::route('admin.assign-role-permissions',[ ]); }
php
public function postUserRolePermissions(Request $request) { $this->validate($request, ['role' => 'required', 'permissions' => 'required']); $role = Role::with('permissions')->whereName($request->role)->first(); $role->permissions()->detach(); foreach ($request->permissions as $permission_name) { $permission = Permission::whereName($permission_name)->first(); $role->assign($permission); } \Session::flash('flash_message', 'Permission granted!'); return \Redirect::route('admin.assign-role-permissions',[ ]); }
[ "public", "function", "postUserRolePermissions", "(", "Request", "$", "request", ")", "{", "$", "this", "->", "validate", "(", "$", "request", ",", "[", "'role'", "=>", "'required'", ",", "'permissions'", "=>", "'required'", "]", ")", ";", "$", "role", "=", "Role", "::", "with", "(", "'permissions'", ")", "->", "whereName", "(", "$", "request", "->", "role", ")", "->", "first", "(", ")", ";", "$", "role", "->", "permissions", "(", ")", "->", "detach", "(", ")", ";", "foreach", "(", "$", "request", "->", "permissions", "as", "$", "permission_name", ")", "{", "$", "permission", "=", "Permission", "::", "whereName", "(", "$", "permission_name", ")", "->", "first", "(", ")", ";", "$", "role", "->", "assign", "(", "$", "permission", ")", ";", "}", "\\", "Session", "::", "flash", "(", "'flash_message'", ",", "'Permission granted!'", ")", ";", "return", "\\", "Redirect", "::", "route", "(", "'admin.assign-role-permissions'", ",", "[", "]", ")", ";", "}" ]
Store given permissions to role. @param \Illuminate\Http\Request $request @return void
[ "Store", "given", "permissions", "to", "role", "." ]
train
https://github.com/meccado/acl-admin-control-panel/blob/50ac4c0dbf8bd49944ecad6a70708a70411b7378/src/Http/Controllers/Admin/AdminController.php#L64-L76
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.create
public static function create($paths, $cache = null, $debug = false) { $wise = new self($debug); if ($cache) { $wise->setCacheDir($cache); } $locator = new FileLocator($paths); $resolver = new LoaderResolver( array( new Loader\IniFileLoader($locator), new Loader\JsonFileLoader($locator), new Loader\PhpFileLoader($locator), new Loader\XmlFileLoader($locator), new Loader\YamlFileLoader($locator), ) ); $wise->setCollector(new Resource\ResourceCollector()); $wise->setLoader(new DelegatingLoader($resolver)); $resolver->setResourceCollector($wise->getCollector()); $resolver->setWise($wise); return $wise; }
php
public static function create($paths, $cache = null, $debug = false) { $wise = new self($debug); if ($cache) { $wise->setCacheDir($cache); } $locator = new FileLocator($paths); $resolver = new LoaderResolver( array( new Loader\IniFileLoader($locator), new Loader\JsonFileLoader($locator), new Loader\PhpFileLoader($locator), new Loader\XmlFileLoader($locator), new Loader\YamlFileLoader($locator), ) ); $wise->setCollector(new Resource\ResourceCollector()); $wise->setLoader(new DelegatingLoader($resolver)); $resolver->setResourceCollector($wise->getCollector()); $resolver->setWise($wise); return $wise; }
[ "public", "static", "function", "create", "(", "$", "paths", ",", "$", "cache", "=", "null", ",", "$", "debug", "=", "false", ")", "{", "$", "wise", "=", "new", "self", "(", "$", "debug", ")", ";", "if", "(", "$", "cache", ")", "{", "$", "wise", "->", "setCacheDir", "(", "$", "cache", ")", ";", "}", "$", "locator", "=", "new", "FileLocator", "(", "$", "paths", ")", ";", "$", "resolver", "=", "new", "LoaderResolver", "(", "array", "(", "new", "Loader", "\\", "IniFileLoader", "(", "$", "locator", ")", ",", "new", "Loader", "\\", "JsonFileLoader", "(", "$", "locator", ")", ",", "new", "Loader", "\\", "PhpFileLoader", "(", "$", "locator", ")", ",", "new", "Loader", "\\", "XmlFileLoader", "(", "$", "locator", ")", ",", "new", "Loader", "\\", "YamlFileLoader", "(", "$", "locator", ")", ",", ")", ")", ";", "$", "wise", "->", "setCollector", "(", "new", "Resource", "\\", "ResourceCollector", "(", ")", ")", ";", "$", "wise", "->", "setLoader", "(", "new", "DelegatingLoader", "(", "$", "resolver", ")", ")", ";", "$", "resolver", "->", "setResourceCollector", "(", "$", "wise", "->", "getCollector", "(", ")", ")", ";", "$", "resolver", "->", "setWise", "(", "$", "wise", ")", ";", "return", "$", "wise", ";", "}" ]
Creates a pre-configured instance of Wise. @param array|string $paths The configuration directory path(s). @param string $cache The cache directory path. @param boolean $debug Enable debugging? @return Wise The instance.
[ "Creates", "a", "pre", "-", "configured", "instance", "of", "Wise", "." ]
train
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L90-L116
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.load
public function load($resource, $type = null, $require = false) { if (null === $this->loader) { throw new LogicException('No loader has been configured.'); } if (false === $this->loader->supports($resource, $type)) { throw LoaderException::format( 'The resource "%s"%s is not supported by the loader.', is_scalar($resource) ? $resource : gettype($resource), $type ? " ($type)" : '' ); } if ($this->cacheDir && $this->collector && is_string($resource) && (false === strpos("\n", $resource)) && (false === strpos("\r", $resource))) { $cache = new ConfigCache( $this->cacheDir . DIRECTORY_SEPARATOR . basename($resource) . '.cache', $this->debug ); if ($cache->isFresh()) { /** @noinspection PhpIncludeInspection */ return require $cache; } } if ($this->collector) { $this->collector->clearResources(); } $data = $this->process( $this->loader->load($resource, $type), $resource, $type, $require ); if (isset($cache)) { $cache->write( '<?php return ' . var_export($data, true) . ';', $this->collector->getResources() ); } return $data; }
php
public function load($resource, $type = null, $require = false) { if (null === $this->loader) { throw new LogicException('No loader has been configured.'); } if (false === $this->loader->supports($resource, $type)) { throw LoaderException::format( 'The resource "%s"%s is not supported by the loader.', is_scalar($resource) ? $resource : gettype($resource), $type ? " ($type)" : '' ); } if ($this->cacheDir && $this->collector && is_string($resource) && (false === strpos("\n", $resource)) && (false === strpos("\r", $resource))) { $cache = new ConfigCache( $this->cacheDir . DIRECTORY_SEPARATOR . basename($resource) . '.cache', $this->debug ); if ($cache->isFresh()) { /** @noinspection PhpIncludeInspection */ return require $cache; } } if ($this->collector) { $this->collector->clearResources(); } $data = $this->process( $this->loader->load($resource, $type), $resource, $type, $require ); if (isset($cache)) { $cache->write( '<?php return ' . var_export($data, true) . ';', $this->collector->getResources() ); } return $data; }
[ "public", "function", "load", "(", "$", "resource", ",", "$", "type", "=", "null", ",", "$", "require", "=", "false", ")", "{", "if", "(", "null", "===", "$", "this", "->", "loader", ")", "{", "throw", "new", "LogicException", "(", "'No loader has been configured.'", ")", ";", "}", "if", "(", "false", "===", "$", "this", "->", "loader", "->", "supports", "(", "$", "resource", ",", "$", "type", ")", ")", "{", "throw", "LoaderException", "::", "format", "(", "'The resource \"%s\"%s is not supported by the loader.'", ",", "is_scalar", "(", "$", "resource", ")", "?", "$", "resource", ":", "gettype", "(", "$", "resource", ")", ",", "$", "type", "?", "\" ($type)\"", ":", "''", ")", ";", "}", "if", "(", "$", "this", "->", "cacheDir", "&&", "$", "this", "->", "collector", "&&", "is_string", "(", "$", "resource", ")", "&&", "(", "false", "===", "strpos", "(", "\"\\n\"", ",", "$", "resource", ")", ")", "&&", "(", "false", "===", "strpos", "(", "\"\\r\"", ",", "$", "resource", ")", ")", ")", "{", "$", "cache", "=", "new", "ConfigCache", "(", "$", "this", "->", "cacheDir", ".", "DIRECTORY_SEPARATOR", ".", "basename", "(", "$", "resource", ")", ".", "'.cache'", ",", "$", "this", "->", "debug", ")", ";", "if", "(", "$", "cache", "->", "isFresh", "(", ")", ")", "{", "/** @noinspection PhpIncludeInspection */", "return", "require", "$", "cache", ";", "}", "}", "if", "(", "$", "this", "->", "collector", ")", "{", "$", "this", "->", "collector", "->", "clearResources", "(", ")", ";", "}", "$", "data", "=", "$", "this", "->", "process", "(", "$", "this", "->", "loader", "->", "load", "(", "$", "resource", ",", "$", "type", ")", ",", "$", "resource", ",", "$", "type", ",", "$", "require", ")", ";", "if", "(", "isset", "(", "$", "cache", ")", ")", "{", "$", "cache", "->", "write", "(", "'<?php return '", ".", "var_export", "(", "$", "data", ",", "true", ")", ".", "';'", ",", "$", "this", "->", "collector", "->", "getResources", "(", ")", ")", ";", "}", "return", "$", "data", ";", "}" ]
Loads the configuration data from a resource. @param mixed $resource A resource. @param string $type The resource type. @param boolean $require Require processing? @return array The data. @throws LoaderException If the loader could not be used. @throws LogicException If no loader has been configured.
[ "Loads", "the", "configuration", "data", "from", "a", "resource", "." ]
train
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L190-L239
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.loadFlat
public function loadFlat($resource, $type = null, $require = false) { return ArrayUtil::flatten($this->load($resource, $type, $require)); }
php
public function loadFlat($resource, $type = null, $require = false) { return ArrayUtil::flatten($this->load($resource, $type, $require)); }
[ "public", "function", "loadFlat", "(", "$", "resource", ",", "$", "type", "=", "null", ",", "$", "require", "=", "false", ")", "{", "return", "ArrayUtil", "::", "flatten", "(", "$", "this", "->", "load", "(", "$", "resource", ",", "$", "type", ",", "$", "require", ")", ")", ";", "}" ]
Loads the configuration data from a resource and returns it flattened. @param mixed $resource A resource. @param string $type The resource type. @param boolean $require Require processing? @return array The data.
[ "Loads", "the", "configuration", "data", "from", "a", "resource", "and", "returns", "it", "flattened", "." ]
train
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L250-L253
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.setCollector
public function setCollector(ResourceCollectorInterface $collector) { $this->collector = $collector; if ($this->loader) { if ($this->loader instanceof ResourceAwareInterface) { $this->loader->setResourceCollector($collector); } if ($this->loader instanceof DelegatingLoader) { $resolver = $this->loader->getResolver(); if ($resolver instanceof ResourceAwareInterface) { $resolver->setResourceCollector($collector); } } } }
php
public function setCollector(ResourceCollectorInterface $collector) { $this->collector = $collector; if ($this->loader) { if ($this->loader instanceof ResourceAwareInterface) { $this->loader->setResourceCollector($collector); } if ($this->loader instanceof DelegatingLoader) { $resolver = $this->loader->getResolver(); if ($resolver instanceof ResourceAwareInterface) { $resolver->setResourceCollector($collector); } } } }
[ "public", "function", "setCollector", "(", "ResourceCollectorInterface", "$", "collector", ")", "{", "$", "this", "->", "collector", "=", "$", "collector", ";", "if", "(", "$", "this", "->", "loader", ")", "{", "if", "(", "$", "this", "->", "loader", "instanceof", "ResourceAwareInterface", ")", "{", "$", "this", "->", "loader", "->", "setResourceCollector", "(", "$", "collector", ")", ";", "}", "if", "(", "$", "this", "->", "loader", "instanceof", "DelegatingLoader", ")", "{", "$", "resolver", "=", "$", "this", "->", "loader", "->", "getResolver", "(", ")", ";", "if", "(", "$", "resolver", "instanceof", "ResourceAwareInterface", ")", "{", "$", "resolver", "->", "setResourceCollector", "(", "$", "collector", ")", ";", "}", "}", "}", "}" ]
Sets the resource collector. @param ResourceCollectorInterface $collector The collector.
[ "Sets", "the", "resource", "collector", "." ]
train
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L270-L287
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.setGlobalParameters
public function setGlobalParameters($parameters) { if (!is_array($parameters) && !($parameters instanceof ArrayAccess)) { throw new InvalidArgumentException( 'The $parameters argument must be an array or array accessible object.' ); } $this->parameters = $parameters; }
php
public function setGlobalParameters($parameters) { if (!is_array($parameters) && !($parameters instanceof ArrayAccess)) { throw new InvalidArgumentException( 'The $parameters argument must be an array or array accessible object.' ); } $this->parameters = $parameters; }
[ "public", "function", "setGlobalParameters", "(", "$", "parameters", ")", "{", "if", "(", "!", "is_array", "(", "$", "parameters", ")", "&&", "!", "(", "$", "parameters", "instanceof", "ArrayAccess", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'The $parameters argument must be an array or array accessible object.'", ")", ";", "}", "$", "this", "->", "parameters", "=", "$", "parameters", ";", "}" ]
Sets a list of global parameters. @param array|ArrayAccess $parameters The parameters. @throws InvalidArgumentException If $parameters is invalid.
[ "Sets", "a", "list", "of", "global", "parameters", "." ]
train
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L296-L305
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.setLoader
public function setLoader(LoaderInterface $loader) { $this->loader = $loader; if ($this->collector && ($loader instanceof ResourceAwareInterface)) { $loader->setResourceCollector($this->collector); } if ($loader instanceof WiseAwareInterface) { $loader->setWise($this); } if ($loader instanceof DelegatingLoader) { $resolver = $loader->getResolver(); if ($this->collector && ($resolver instanceof ResourceAwareInterface)) { $resolver->setResourceCollector($this->collector); } if ($resolver instanceof WiseAwareInterface) { $resolver->setWise($this); } } }
php
public function setLoader(LoaderInterface $loader) { $this->loader = $loader; if ($this->collector && ($loader instanceof ResourceAwareInterface)) { $loader->setResourceCollector($this->collector); } if ($loader instanceof WiseAwareInterface) { $loader->setWise($this); } if ($loader instanceof DelegatingLoader) { $resolver = $loader->getResolver(); if ($this->collector && ($resolver instanceof ResourceAwareInterface)) { $resolver->setResourceCollector($this->collector); } if ($resolver instanceof WiseAwareInterface) { $resolver->setWise($this); } } }
[ "public", "function", "setLoader", "(", "LoaderInterface", "$", "loader", ")", "{", "$", "this", "->", "loader", "=", "$", "loader", ";", "if", "(", "$", "this", "->", "collector", "&&", "(", "$", "loader", "instanceof", "ResourceAwareInterface", ")", ")", "{", "$", "loader", "->", "setResourceCollector", "(", "$", "this", "->", "collector", ")", ";", "}", "if", "(", "$", "loader", "instanceof", "WiseAwareInterface", ")", "{", "$", "loader", "->", "setWise", "(", "$", "this", ")", ";", "}", "if", "(", "$", "loader", "instanceof", "DelegatingLoader", ")", "{", "$", "resolver", "=", "$", "loader", "->", "getResolver", "(", ")", ";", "if", "(", "$", "this", "->", "collector", "&&", "(", "$", "resolver", "instanceof", "ResourceAwareInterface", ")", ")", "{", "$", "resolver", "->", "setResourceCollector", "(", "$", "this", "->", "collector", ")", ";", "}", "if", "(", "$", "resolver", "instanceof", "WiseAwareInterface", ")", "{", "$", "resolver", "->", "setWise", "(", "$", "this", ")", ";", "}", "}", "}" ]
Sets a configuration loader. @param LoaderInterface $loader A loader.
[ "Sets", "a", "configuration", "loader", "." ]
train
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L312-L336
kherge-abandoned/php-wise
src/lib/Herrera/Wise/Wise.php
Wise.process
private function process(array $data, $resource, $type, $require) { if ($this->processor) { if ($this->processor instanceof ProcessorInterface) { if ($this->processor->supports($resource, $type)) { $data = $this->processor->process($data); } elseif ($require) { throw ProcessorException::format( 'The resource "%s"%s is not supported by the processor.', is_string($resource) ? $resource : gettype($resource), $type ? " ($type)" : '' ); } } else { $processor = new Processor(); $data = $processor->processConfiguration( $this->processor, $data ); } } elseif ($require) { throw ProcessorException::format( 'No processor registered to handle any resource.' ); } return $data; }
php
private function process(array $data, $resource, $type, $require) { if ($this->processor) { if ($this->processor instanceof ProcessorInterface) { if ($this->processor->supports($resource, $type)) { $data = $this->processor->process($data); } elseif ($require) { throw ProcessorException::format( 'The resource "%s"%s is not supported by the processor.', is_string($resource) ? $resource : gettype($resource), $type ? " ($type)" : '' ); } } else { $processor = new Processor(); $data = $processor->processConfiguration( $this->processor, $data ); } } elseif ($require) { throw ProcessorException::format( 'No processor registered to handle any resource.' ); } return $data; }
[ "private", "function", "process", "(", "array", "$", "data", ",", "$", "resource", ",", "$", "type", ",", "$", "require", ")", "{", "if", "(", "$", "this", "->", "processor", ")", "{", "if", "(", "$", "this", "->", "processor", "instanceof", "ProcessorInterface", ")", "{", "if", "(", "$", "this", "->", "processor", "->", "supports", "(", "$", "resource", ",", "$", "type", ")", ")", "{", "$", "data", "=", "$", "this", "->", "processor", "->", "process", "(", "$", "data", ")", ";", "}", "elseif", "(", "$", "require", ")", "{", "throw", "ProcessorException", "::", "format", "(", "'The resource \"%s\"%s is not supported by the processor.'", ",", "is_string", "(", "$", "resource", ")", "?", "$", "resource", ":", "gettype", "(", "$", "resource", ")", ",", "$", "type", "?", "\" ($type)\"", ":", "''", ")", ";", "}", "}", "else", "{", "$", "processor", "=", "new", "Processor", "(", ")", ";", "$", "data", "=", "$", "processor", "->", "processConfiguration", "(", "$", "this", "->", "processor", ",", "$", "data", ")", ";", "}", "}", "elseif", "(", "$", "require", ")", "{", "throw", "ProcessorException", "::", "format", "(", "'No processor registered to handle any resource.'", ")", ";", "}", "return", "$", "data", ";", "}" ]
Processes the configuration definition. @param array $data The configuration data. @param mixed $resource A resource. @param string $type The resource type. @param boolean $require Require processing? @return array The processed configuration data. @throws ProcessorException If the processor could not be used and it is require that one be used.
[ "Processes", "the", "configuration", "definition", "." ]
train
https://github.com/kherge-abandoned/php-wise/blob/7621e0be7dbb2a015d68197d290fe8469f539a4d/src/lib/Herrera/Wise/Wise.php#L361-L388
aedart/laravel-helpers
src/Traits/Foundation/AppTrait.php
AppTrait.getApp
public function getApp(): ?Application { if (!$this->hasApp()) { $this->setApp($this->getDefaultApp()); } return $this->app; }
php
public function getApp(): ?Application { if (!$this->hasApp()) { $this->setApp($this->getDefaultApp()); } return $this->app; }
[ "public", "function", "getApp", "(", ")", ":", "?", "Application", "{", "if", "(", "!", "$", "this", "->", "hasApp", "(", ")", ")", "{", "$", "this", "->", "setApp", "(", "$", "this", "->", "getDefaultApp", "(", ")", ")", ";", "}", "return", "$", "this", "->", "app", ";", "}" ]
Get app If no app has been set, this method will set and return a default app, if any such value is available @see getDefaultApp() @return Application|null app or null if none app has been set
[ "Get", "app" ]
train
https://github.com/aedart/laravel-helpers/blob/8b81a2d6658f3f8cb62b6be2c34773aaa2df219a/src/Traits/Foundation/AppTrait.php#L53-L59
ClanCats/Core
src/classes/CCError/Handler/Cli.php
CCError_Handler_Cli.respond
public function respond() { $inspector = $this->inspector; CCCli::write( "\n".$inspector->exception_name().': ', 'red' ); CCCli::line( $inspector->message() ); CCCli::line( $inspector->exception()->getFile().':'.$inspector->exception()->getLine() ); }
php
public function respond() { $inspector = $this->inspector; CCCli::write( "\n".$inspector->exception_name().': ', 'red' ); CCCli::line( $inspector->message() ); CCCli::line( $inspector->exception()->getFile().':'.$inspector->exception()->getLine() ); }
[ "public", "function", "respond", "(", ")", "{", "$", "inspector", "=", "$", "this", "->", "inspector", ";", "CCCli", "::", "write", "(", "\"\\n\"", ".", "$", "inspector", "->", "exception_name", "(", ")", ".", "': '", ",", "'red'", ")", ";", "CCCli", "::", "line", "(", "$", "inspector", "->", "message", "(", ")", ")", ";", "CCCli", "::", "line", "(", "$", "inspector", "->", "exception", "(", ")", "->", "getFile", "(", ")", ".", "':'", ".", "$", "inspector", "->", "exception", "(", ")", "->", "getLine", "(", ")", ")", ";", "}" ]
respond information to the user @return void
[ "respond", "information", "to", "the", "user" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCError/Handler/Cli.php#L19-L26
egeloen/IvorySerializerBundle
DependencyInjection/Compiler/RegisterFOSServicePass.php
RegisterFOSServicePass.process
public function process(ContainerBuilder $container) { if (!$container->hasDefinition('fos_rest.exception.messages_map')) { $container->removeDefinition('ivory.serializer.fos'); return; } $exceptionType = $container->getDefinition('ivory.serializer.type.exception'); $exceptionType ->setClass(ExceptionType::class) ->setArguments([ new Reference('fos_rest.exception.messages_map'), $exceptionType->getArgument(0), ]); }
php
public function process(ContainerBuilder $container) { if (!$container->hasDefinition('fos_rest.exception.messages_map')) { $container->removeDefinition('ivory.serializer.fos'); return; } $exceptionType = $container->getDefinition('ivory.serializer.type.exception'); $exceptionType ->setClass(ExceptionType::class) ->setArguments([ new Reference('fos_rest.exception.messages_map'), $exceptionType->getArgument(0), ]); }
[ "public", "function", "process", "(", "ContainerBuilder", "$", "container", ")", "{", "if", "(", "!", "$", "container", "->", "hasDefinition", "(", "'fos_rest.exception.messages_map'", ")", ")", "{", "$", "container", "->", "removeDefinition", "(", "'ivory.serializer.fos'", ")", ";", "return", ";", "}", "$", "exceptionType", "=", "$", "container", "->", "getDefinition", "(", "'ivory.serializer.type.exception'", ")", ";", "$", "exceptionType", "->", "setClass", "(", "ExceptionType", "::", "class", ")", "->", "setArguments", "(", "[", "new", "Reference", "(", "'fos_rest.exception.messages_map'", ")", ",", "$", "exceptionType", "->", "getArgument", "(", "0", ")", ",", "]", ")", ";", "}" ]
{@inheritdoc}
[ "{" ]
train
https://github.com/egeloen/IvorySerializerBundle/blob/a2bdd912bf715c61b823cf7257ee232d5c823dd3/DependencyInjection/Compiler/RegisterFOSServicePass.php#L27-L42
christianvizarra/laravel-service-provider
src/Publisher/Publisher.php
Publisher.getSourceFiles
protected function getSourceFiles($path) { $files = []; foreach (glob($path.'/*.php') as $file) { $files[] = $file; } return $files; }
php
protected function getSourceFiles($path) { $files = []; foreach (glob($path.'/*.php') as $file) { $files[] = $file; } return $files; }
[ "protected", "function", "getSourceFiles", "(", "$", "path", ")", "{", "$", "files", "=", "[", "]", ";", "foreach", "(", "glob", "(", "$", "path", ".", "'/*.php'", ")", "as", "$", "file", ")", "{", "$", "files", "[", "]", "=", "$", "file", ";", "}", "return", "$", "files", ";", "}" ]
@param $type @param $files @return array
[ "@param", "$type", "@param", "$files" ]
train
https://github.com/christianvizarra/laravel-service-provider/blob/73e6b664c34ce228d4a3a48ed3b96cf2546ccfee/src/Publisher/Publisher.php#L146-L154
christianvizarra/laravel-service-provider
src/Publisher/Publisher.php
Publisher.getClassFromFile
protected function getClassFromFile($path) { $count = count($tokens = token_get_all(file_get_contents($path))); for ($i = 2; $i < $count; ++$i) { if ($tokens[$i - 2][0] == T_CLASS && $tokens[$i - 1][0] == T_WHITESPACE && $tokens[$i][0] == T_STRING) { return $tokens[$i][1]; } } }
php
protected function getClassFromFile($path) { $count = count($tokens = token_get_all(file_get_contents($path))); for ($i = 2; $i < $count; ++$i) { if ($tokens[$i - 2][0] == T_CLASS && $tokens[$i - 1][0] == T_WHITESPACE && $tokens[$i][0] == T_STRING) { return $tokens[$i][1]; } } }
[ "protected", "function", "getClassFromFile", "(", "$", "path", ")", "{", "$", "count", "=", "count", "(", "$", "tokens", "=", "token_get_all", "(", "file_get_contents", "(", "$", "path", ")", ")", ")", ";", "for", "(", "$", "i", "=", "2", ";", "$", "i", "<", "$", "count", ";", "++", "$", "i", ")", "{", "if", "(", "$", "tokens", "[", "$", "i", "-", "2", "]", "[", "0", "]", "==", "T_CLASS", "&&", "$", "tokens", "[", "$", "i", "-", "1", "]", "[", "0", "]", "==", "T_WHITESPACE", "&&", "$", "tokens", "[", "$", "i", "]", "[", "0", "]", "==", "T_STRING", ")", "{", "return", "$", "tokens", "[", "$", "i", "]", "[", "1", "]", ";", "}", "}", "}" ]
@param $path @return mixed
[ "@param", "$path" ]
train
https://github.com/christianvizarra/laravel-service-provider/blob/73e6b664c34ce228d4a3a48ed3b96cf2546ccfee/src/Publisher/Publisher.php#L161-L170
Chill-project/Main
Routing/Loader/ChillRoutesLoader.php
ChillRoutesLoader.load
public function load($resource, $type = null) { $collection = new RouteCollection(); foreach ($this->routes as $resource) { $collection->addCollection( $this->import($resource, NULL) ); } return $collection; }
php
public function load($resource, $type = null) { $collection = new RouteCollection(); foreach ($this->routes as $resource) { $collection->addCollection( $this->import($resource, NULL) ); } return $collection; }
[ "public", "function", "load", "(", "$", "resource", ",", "$", "type", "=", "null", ")", "{", "$", "collection", "=", "new", "RouteCollection", "(", ")", ";", "foreach", "(", "$", "this", "->", "routes", "as", "$", "resource", ")", "{", "$", "collection", "->", "addCollection", "(", "$", "this", "->", "import", "(", "$", "resource", ",", "NULL", ")", ")", ";", "}", "return", "$", "collection", ";", "}" ]
{@inheritDoc} @param type $resource @param type $type @return RouteCollection
[ "{", "@inheritDoc", "}" ]
train
https://github.com/Chill-project/Main/blob/384cb6c793072a4f1047dc5cafc2157ee2419f60/Routing/Loader/ChillRoutesLoader.php#L54-L65
ClanCats/Core
src/classes/CCOrbit/Ship.php
CCOrbit_Ship.create
public static function create( $path ) { if ( is_null( $path ) ) { return new static(); } // use the orbit path if we are relative if ( substr( $path, 0, 1 ) != '/' ) { $path = ORBITPATH.$path; } // check the path if ( substr( $path, -1 ) != '/' ) { $path .= '/'; } $blueprint = $path.'blueprint.json'; if ( !file_exists( $blueprint ) ) { throw new CCException( "CCOrbit_Ship::create - clould not find a blueprint at {$blueprint}." ); } if ( !$blueprint_data = CCJson::read( $blueprint ) ) { throw new CCException( "CCOrbit_Ship::create - invalid blueprint at {$blueprint}." ); } return static::blueprint( $blueprint_data, $path ); }
php
public static function create( $path ) { if ( is_null( $path ) ) { return new static(); } // use the orbit path if we are relative if ( substr( $path, 0, 1 ) != '/' ) { $path = ORBITPATH.$path; } // check the path if ( substr( $path, -1 ) != '/' ) { $path .= '/'; } $blueprint = $path.'blueprint.json'; if ( !file_exists( $blueprint ) ) { throw new CCException( "CCOrbit_Ship::create - clould not find a blueprint at {$blueprint}." ); } if ( !$blueprint_data = CCJson::read( $blueprint ) ) { throw new CCException( "CCOrbit_Ship::create - invalid blueprint at {$blueprint}." ); } return static::blueprint( $blueprint_data, $path ); }
[ "public", "static", "function", "create", "(", "$", "path", ")", "{", "if", "(", "is_null", "(", "$", "path", ")", ")", "{", "return", "new", "static", "(", ")", ";", "}", "// use the orbit path if we are relative", "if", "(", "substr", "(", "$", "path", ",", "0", ",", "1", ")", "!=", "'/'", ")", "{", "$", "path", "=", "ORBITPATH", ".", "$", "path", ";", "}", "// check the path", "if", "(", "substr", "(", "$", "path", ",", "-", "1", ")", "!=", "'/'", ")", "{", "$", "path", ".=", "'/'", ";", "}", "$", "blueprint", "=", "$", "path", ".", "'blueprint.json'", ";", "if", "(", "!", "file_exists", "(", "$", "blueprint", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCOrbit_Ship::create - clould not find a blueprint at {$blueprint}.\"", ")", ";", "}", "if", "(", "!", "$", "blueprint_data", "=", "CCJson", "::", "read", "(", "$", "blueprint", ")", ")", "{", "throw", "new", "CCException", "(", "\"CCOrbit_Ship::create - invalid blueprint at {$blueprint}.\"", ")", ";", "}", "return", "static", "::", "blueprint", "(", "$", "blueprint_data", ",", "$", "path", ")", ";", "}" ]
create an new ship object from path @param string $path @return CCOrbit_Ship
[ "create", "an", "new", "ship", "object", "from", "path" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCOrbit/Ship.php#L21-L53
ClanCats/Core
src/classes/CCOrbit/Ship.php
CCOrbit_Ship.blueprint
public static function blueprint( $data, $path ) { if ( !is_array( $data ) ) { throw new \InvalidArgumentException( "CCOrbit_Ship::blueprint - first argument has to be an array." ); } $ship = new static(); $name = $data['name']; $namespace = $data['namespace']; // check if we have a name if not use dir name if ( is_null( $name ) ) { $name = basename( $path ); } // get ship namespace if ( $namespace === true ) { $namespace = $name; } // try to load other ship class if ( is_string( $namespace ) ) { // register the namespace \CCFinder::bundle( $namespace, $path ); $class = $namespace.'\\Ship'; if ( class_exists( $class ) ) { $ship = new $class(); } } // set the path $ship->name = $name; $ship->path = $path; $ship->namespace = $namespace; // assign the data foreach( $data as $key => $item ) { if ( property_exists( $ship, $key ) ) { $ship->$key = $item; } } // check the namespace if ( $ship->namespace === false ) { if ( is_null( $ship->wake ) ) { $ship->wake = 'shipyard/wake'.EXT; } if ( is_null( $ship->install ) ) { $ship->install = 'shipyard/install'.EXT; } if ( is_null( $ship->uninstall ) ) { $ship->uninstall = 'shipyard/uninstall'.EXT; } } elseif ( is_string( $ship->namespace ) ) { if ( is_null( $ship->wake ) ) { $ship->wake = 'Ship::wake'; } if ( is_null( $ship->install ) ) { $ship->install = 'Ship::install'; } if ( is_null( $ship->uninstall ) ) { $ship->uninstall = 'Ship::uninstall'; } } return $ship; }
php
public static function blueprint( $data, $path ) { if ( !is_array( $data ) ) { throw new \InvalidArgumentException( "CCOrbit_Ship::blueprint - first argument has to be an array." ); } $ship = new static(); $name = $data['name']; $namespace = $data['namespace']; // check if we have a name if not use dir name if ( is_null( $name ) ) { $name = basename( $path ); } // get ship namespace if ( $namespace === true ) { $namespace = $name; } // try to load other ship class if ( is_string( $namespace ) ) { // register the namespace \CCFinder::bundle( $namespace, $path ); $class = $namespace.'\\Ship'; if ( class_exists( $class ) ) { $ship = new $class(); } } // set the path $ship->name = $name; $ship->path = $path; $ship->namespace = $namespace; // assign the data foreach( $data as $key => $item ) { if ( property_exists( $ship, $key ) ) { $ship->$key = $item; } } // check the namespace if ( $ship->namespace === false ) { if ( is_null( $ship->wake ) ) { $ship->wake = 'shipyard/wake'.EXT; } if ( is_null( $ship->install ) ) { $ship->install = 'shipyard/install'.EXT; } if ( is_null( $ship->uninstall ) ) { $ship->uninstall = 'shipyard/uninstall'.EXT; } } elseif ( is_string( $ship->namespace ) ) { if ( is_null( $ship->wake ) ) { $ship->wake = 'Ship::wake'; } if ( is_null( $ship->install ) ) { $ship->install = 'Ship::install'; } if ( is_null( $ship->uninstall ) ) { $ship->uninstall = 'Ship::uninstall'; } } return $ship; }
[ "public", "static", "function", "blueprint", "(", "$", "data", ",", "$", "path", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"CCOrbit_Ship::blueprint - first argument has to be an array.\"", ")", ";", "}", "$", "ship", "=", "new", "static", "(", ")", ";", "$", "name", "=", "$", "data", "[", "'name'", "]", ";", "$", "namespace", "=", "$", "data", "[", "'namespace'", "]", ";", "// check if we have a name if not use dir name", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "$", "name", "=", "basename", "(", "$", "path", ")", ";", "}", "// get ship namespace", "if", "(", "$", "namespace", "===", "true", ")", "{", "$", "namespace", "=", "$", "name", ";", "}", "// try to load other ship class", "if", "(", "is_string", "(", "$", "namespace", ")", ")", "{", "// register the namespace", "\\", "CCFinder", "::", "bundle", "(", "$", "namespace", ",", "$", "path", ")", ";", "$", "class", "=", "$", "namespace", ".", "'\\\\Ship'", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "$", "ship", "=", "new", "$", "class", "(", ")", ";", "}", "}", "// set the path", "$", "ship", "->", "name", "=", "$", "name", ";", "$", "ship", "->", "path", "=", "$", "path", ";", "$", "ship", "->", "namespace", "=", "$", "namespace", ";", "// assign the data", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "property_exists", "(", "$", "ship", ",", "$", "key", ")", ")", "{", "$", "ship", "->", "$", "key", "=", "$", "item", ";", "}", "}", "// check the namespace", "if", "(", "$", "ship", "->", "namespace", "===", "false", ")", "{", "if", "(", "is_null", "(", "$", "ship", "->", "wake", ")", ")", "{", "$", "ship", "->", "wake", "=", "'shipyard/wake'", ".", "EXT", ";", "}", "if", "(", "is_null", "(", "$", "ship", "->", "install", ")", ")", "{", "$", "ship", "->", "install", "=", "'shipyard/install'", ".", "EXT", ";", "}", "if", "(", "is_null", "(", "$", "ship", "->", "uninstall", ")", ")", "{", "$", "ship", "->", "uninstall", "=", "'shipyard/uninstall'", ".", "EXT", ";", "}", "}", "elseif", "(", "is_string", "(", "$", "ship", "->", "namespace", ")", ")", "{", "if", "(", "is_null", "(", "$", "ship", "->", "wake", ")", ")", "{", "$", "ship", "->", "wake", "=", "'Ship::wake'", ";", "}", "if", "(", "is_null", "(", "$", "ship", "->", "install", ")", ")", "{", "$", "ship", "->", "install", "=", "'Ship::install'", ";", "}", "if", "(", "is_null", "(", "$", "ship", "->", "uninstall", ")", ")", "{", "$", "ship", "->", "uninstall", "=", "'Ship::uninstall'", ";", "}", "}", "return", "$", "ship", ";", "}" ]
create new ship with given data @param array $data @return CCOrbit_Ship
[ "create", "new", "ship", "with", "given", "data" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCOrbit/Ship.php#L61-L146
ClanCats/Core
src/classes/CCOrbit/Ship.php
CCOrbit_Ship.event
public function event( $event ) { // call the wake event if ( is_string( $this->namespace ) ) { if ( strpos( $event, '::' ) !== false ) { $callback = explode( '::', $event ); $class = $this->namespace."\\".$callback[0]; if ( class_exists( $class ) ) { call_user_func( array( $this, $callback[1] ) ); } } else { if ( is_file( $this->path.$event ) ) { require $this->path.$event; } } } else { if ( is_file( $this->path.$event ) ) { require $this->path.$event; } } }
php
public function event( $event ) { // call the wake event if ( is_string( $this->namespace ) ) { if ( strpos( $event, '::' ) !== false ) { $callback = explode( '::', $event ); $class = $this->namespace."\\".$callback[0]; if ( class_exists( $class ) ) { call_user_func( array( $this, $callback[1] ) ); } } else { if ( is_file( $this->path.$event ) ) { require $this->path.$event; } } } else { if ( is_file( $this->path.$event ) ) { require $this->path.$event; } } }
[ "public", "function", "event", "(", "$", "event", ")", "{", "// call the wake event", "if", "(", "is_string", "(", "$", "this", "->", "namespace", ")", ")", "{", "if", "(", "strpos", "(", "$", "event", ",", "'::'", ")", "!==", "false", ")", "{", "$", "callback", "=", "explode", "(", "'::'", ",", "$", "event", ")", ";", "$", "class", "=", "$", "this", "->", "namespace", ".", "\"\\\\\"", ".", "$", "callback", "[", "0", "]", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "call_user_func", "(", "array", "(", "$", "this", ",", "$", "callback", "[", "1", "]", ")", ")", ";", "}", "}", "else", "{", "if", "(", "is_file", "(", "$", "this", "->", "path", ".", "$", "event", ")", ")", "{", "require", "$", "this", "->", "path", ".", "$", "event", ";", "}", "}", "}", "else", "{", "if", "(", "is_file", "(", "$", "this", "->", "path", ".", "$", "event", ")", ")", "{", "require", "$", "this", "->", "path", ".", "$", "event", ";", "}", "}", "}" ]
run an event on this object
[ "run", "an", "event", "on", "this", "object" ]
train
https://github.com/ClanCats/Core/blob/9f6ec72c1a439de4b253d0223f1029f7f85b6ef8/src/classes/CCOrbit/Ship.php#L202-L232
nyeholt/silverstripe-external-content
thirdparty/Zend/Validate/Ip.php
Zend_Validate_Ip.isValid
public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if ((ip2long($valueString) === false) || (long2ip(ip2long($valueString)) !== $valueString)) { if (!function_exists('inet_pton')) { $this->_error(); return false; } else if ((@inet_pton($value) === false) ||(inet_ntop(@inet_pton($value)) !== $valueString)) { $this->_error(); return false; } } return true; }
php
public function isValid($value) { $valueString = (string) $value; $this->_setValue($valueString); if ((ip2long($valueString) === false) || (long2ip(ip2long($valueString)) !== $valueString)) { if (!function_exists('inet_pton')) { $this->_error(); return false; } else if ((@inet_pton($value) === false) ||(inet_ntop(@inet_pton($value)) !== $valueString)) { $this->_error(); return false; } } return true; }
[ "public", "function", "isValid", "(", "$", "value", ")", "{", "$", "valueString", "=", "(", "string", ")", "$", "value", ";", "$", "this", "->", "_setValue", "(", "$", "valueString", ")", ";", "if", "(", "(", "ip2long", "(", "$", "valueString", ")", "===", "false", ")", "||", "(", "long2ip", "(", "ip2long", "(", "$", "valueString", ")", ")", "!==", "$", "valueString", ")", ")", "{", "if", "(", "!", "function_exists", "(", "'inet_pton'", ")", ")", "{", "$", "this", "->", "_error", "(", ")", ";", "return", "false", ";", "}", "else", "if", "(", "(", "@", "inet_pton", "(", "$", "value", ")", "===", "false", ")", "||", "(", "inet_ntop", "(", "@", "inet_pton", "(", "$", "value", ")", ")", "!==", "$", "valueString", ")", ")", "{", "$", "this", "->", "_error", "(", ")", ";", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Defined by Zend_Validate_Interface Returns true if and only if $value is a valid IP address @param mixed $value @return boolean
[ "Defined", "by", "Zend_Validate_Interface" ]
train
https://github.com/nyeholt/silverstripe-external-content/blob/1c6da8c56ef717225ff904e1522aff94ed051601/thirdparty/Zend/Validate/Ip.php#L52-L69
Kylob/Bootstrap
src/Form.php
Form.message
public function message($status, $message) { $this->page->session->setFlash(array(__CLASS__, $this->header['name']), array( 'status' => $status, 'msg' => $message, )); }
php
public function message($status, $message) { $this->page->session->setFlash(array(__CLASS__, $this->header['name']), array( 'status' => $status, 'msg' => $message, )); }
[ "public", "function", "message", "(", "$", "status", ",", "$", "message", ")", "{", "$", "this", "->", "page", "->", "session", "->", "setFlash", "(", "array", "(", "__CLASS__", ",", "$", "this", "->", "header", "[", "'name'", "]", ")", ",", "array", "(", "'status'", "=>", "$", "status", ",", "'msg'", "=>", "$", "message", ",", ")", ")", ";", "}" ]
Display a message to your user after ``$form->eject()``ing them. The Bootstrap alert status message will be displayed at the top of the form when you return ``$form->header()``. @param string $status Either '**success**', '**info**', '**warning**', or '**danger**'. If this is '**html**', then the $message will be delivered as is. @param string $message The message you would like to get across to your user. ``<h1-6>`` headers and ``<a>`` links will be appropriately classed. @example ```php if ($vars = $form->validator->certified()) { $form->message('info', 'Good job, you are doing great!'); $form->eject(); } ```
[ "Display", "a", "message", "to", "your", "user", "after", "$form", "-", ">", "eject", "()", "ing", "them", ".", "The", "Bootstrap", "alert", "status", "message", "will", "be", "displayed", "at", "the", "top", "of", "the", "form", "when", "you", "return", "$form", "-", ">", "header", "()", "." ]
train
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Form.php#L77-L83
Kylob/Bootstrap
src/Form.php
Form.align
public function align($direction = 'horizontal', $collapse = 'sm', $indent = 2) { if ($direction == 'collapse') { $this->align = ''; } elseif ($direction == 'inline') { $this->align = 'form-inline'; } else { $this->align = 'form-horizontal'; $this->collapse = (in_array($collapse, array('xs', 'sm', 'md', 'lg'))) ? $collapse : 'sm'; $this->indent = (is_numeric($indent) && $indent > 0 && $indent < 12) ? $indent : 2; } }
php
public function align($direction = 'horizontal', $collapse = 'sm', $indent = 2) { if ($direction == 'collapse') { $this->align = ''; } elseif ($direction == 'inline') { $this->align = 'form-inline'; } else { $this->align = 'form-horizontal'; $this->collapse = (in_array($collapse, array('xs', 'sm', 'md', 'lg'))) ? $collapse : 'sm'; $this->indent = (is_numeric($indent) && $indent > 0 && $indent < 12) ? $indent : 2; } }
[ "public", "function", "align", "(", "$", "direction", "=", "'horizontal'", ",", "$", "collapse", "=", "'sm'", ",", "$", "indent", "=", "2", ")", "{", "if", "(", "$", "direction", "==", "'collapse'", ")", "{", "$", "this", "->", "align", "=", "''", ";", "}", "elseif", "(", "$", "direction", "==", "'inline'", ")", "{", "$", "this", "->", "align", "=", "'form-inline'", ";", "}", "else", "{", "$", "this", "->", "align", "=", "'form-horizontal'", ";", "$", "this", "->", "collapse", "=", "(", "in_array", "(", "$", "collapse", ",", "array", "(", "'xs'", ",", "'sm'", ",", "'md'", ",", "'lg'", ")", ")", ")", "?", "$", "collapse", ":", "'sm'", ";", "$", "this", "->", "indent", "=", "(", "is_numeric", "(", "$", "indent", ")", "&&", "$", "indent", ">", "0", "&&", "$", "indent", "<", "12", ")", "?", "$", "indent", ":", "2", ";", "}", "}" ]
Utilize any Bootstrap form style. @param string $direction The options are: - '**collapse**' - This will display the form prompt immediately above the field. - '**inline**' - All of the fields will be inline with each other, and the form prompts will be removed. - '**horizontal**' - Vertically aligns all of the fields with the prompt immediately preceding, and right aligned. @param string $collapse Either '**xs**', '**sm**', '**md**', or '**lg**'. This is the breaking point so to speak for a '**horizontal**' form. It is the device size on which the form will '**collapse**'. @param int $indent The number of columns (up to 12) that you would like to indent the field in a '**horizontal**' form. @example ```php $form->align('collapse'); ```
[ "Utilize", "any", "Bootstrap", "form", "style", "." ]
train
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Form.php#L118-L129
Kylob/Bootstrap
src/Form.php
Form.prompt
public function prompt($place, $html, $required = false) { switch ($place) { case 'info': case 'append': $this->prompt[$place] = $html; break; case 'prepend': $this->prompt['prepend'] = array('html' => $html, 'required' => (bool) $required); break; } }
php
public function prompt($place, $html, $required = false) { switch ($place) { case 'info': case 'append': $this->prompt[$place] = $html; break; case 'prepend': $this->prompt['prepend'] = array('html' => $html, 'required' => (bool) $required); break; } }
[ "public", "function", "prompt", "(", "$", "place", ",", "$", "html", ",", "$", "required", "=", "false", ")", "{", "switch", "(", "$", "place", ")", "{", "case", "'info'", ":", "case", "'append'", ":", "$", "this", "->", "prompt", "[", "$", "place", "]", "=", "$", "html", ";", "break", ";", "case", "'prepend'", ":", "$", "this", "->", "prompt", "[", "'prepend'", "]", "=", "array", "(", "'html'", "=>", "$", "html", ",", "'required'", "=>", "(", "bool", ")", "$", "required", ")", ";", "break", ";", "}", "}" ]
This is to add html tags, or semicolons, or asterisks, or whatever you would like to all of the form's prompts. @param string $place Either '**info**', '**append**', or '**prepend**' to the prompt. You only have one shot at each. @param string $html Whatever you would like to add. For '**info**', this will be the icon class you want to use. @param mixed $required If ``$place == 'prepend'`` and this is anything but (bool) false, then the **$html** will only be prepended if the ``$form->validator->required('field')``. @example ```php $form->prompt('prepend', '<font color="red">*</font> ', 'required'); // If the field is required it will add a red asterisk to the front. $form->prompt('append', ':'); // Adds a semicolon to all of the prompts. ```
[ "This", "is", "to", "add", "html", "tags", "or", "semicolons", "or", "asterisks", "or", "whatever", "you", "would", "like", "to", "all", "of", "the", "form", "s", "prompts", "." ]
train
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Form.php#L146-L157
Kylob/Bootstrap
src/Form.php
Form.header
public function header(array $validate = array()) { $this->validator->jquery('form[name='.$this->header['name'].']', array_merge(array( 'ignore' => '[]', 'errorClass' => '"has-error"', 'validClass' => '""', 'errorElement' => '"span"', 'highlight' => 'function(element, errorClass, validClass){ $(element).closest("div.form-group").addClass(errorClass).removeClass(validClass).find("p.validation").show(); }', 'unhighlight' => 'function(element, errorClass, validClass){ $(element).closest("div.form-group").removeClass(errorClass).addClass(validClass).find("p.validation").text("").hide(); }', 'errorPlacement' => 'function(error, element){ $(element).closest("div.form-group").find("p.validation").html(error); }', 'submitHandler' => 'function(form, event){ event.preventDefault(); $(form).find("button[type=submit]").button("loading"); form.submit(); }', 'onkeyup' => 'false', ), $validate)); $html = "\n"; if ($flash = $this->page->session->getFlash(array(__CLASS__, $this->header['name']))) { $html .= ($flash['status'] == 'html') ? $flash['msg'] : $this->bp->alert($flash['status'], $flash['msg']); } $html .= trim(parent::header()); if (!empty($this->align)) { $html = $this->addClass($html, array('form' => $this->align)); } return $html; }
php
public function header(array $validate = array()) { $this->validator->jquery('form[name='.$this->header['name'].']', array_merge(array( 'ignore' => '[]', 'errorClass' => '"has-error"', 'validClass' => '""', 'errorElement' => '"span"', 'highlight' => 'function(element, errorClass, validClass){ $(element).closest("div.form-group").addClass(errorClass).removeClass(validClass).find("p.validation").show(); }', 'unhighlight' => 'function(element, errorClass, validClass){ $(element).closest("div.form-group").removeClass(errorClass).addClass(validClass).find("p.validation").text("").hide(); }', 'errorPlacement' => 'function(error, element){ $(element).closest("div.form-group").find("p.validation").html(error); }', 'submitHandler' => 'function(form, event){ event.preventDefault(); $(form).find("button[type=submit]").button("loading"); form.submit(); }', 'onkeyup' => 'false', ), $validate)); $html = "\n"; if ($flash = $this->page->session->getFlash(array(__CLASS__, $this->header['name']))) { $html .= ($flash['status'] == 'html') ? $flash['msg'] : $this->bp->alert($flash['status'], $flash['msg']); } $html .= trim(parent::header()); if (!empty($this->align)) { $html = $this->addClass($html, array('form' => $this->align)); } return $html; }
[ "public", "function", "header", "(", "array", "$", "validate", "=", "array", "(", ")", ")", "{", "$", "this", "->", "validator", "->", "jquery", "(", "'form[name='", ".", "$", "this", "->", "header", "[", "'name'", "]", ".", "']'", ",", "array_merge", "(", "array", "(", "'ignore'", "=>", "'[]'", ",", "'errorClass'", "=>", "'\"has-error\"'", ",", "'validClass'", "=>", "'\"\"'", ",", "'errorElement'", "=>", "'\"span\"'", ",", "'highlight'", "=>", "'function(element, errorClass, validClass){ $(element).closest(\"div.form-group\").addClass(errorClass).removeClass(validClass).find(\"p.validation\").show(); }'", ",", "'unhighlight'", "=>", "'function(element, errorClass, validClass){ $(element).closest(\"div.form-group\").removeClass(errorClass).addClass(validClass).find(\"p.validation\").text(\"\").hide(); }'", ",", "'errorPlacement'", "=>", "'function(error, element){ $(element).closest(\"div.form-group\").find(\"p.validation\").html(error); }'", ",", "'submitHandler'", "=>", "'function(form, event){ event.preventDefault(); $(form).find(\"button[type=submit]\").button(\"loading\"); form.submit(); }'", ",", "'onkeyup'", "=>", "'false'", ",", ")", ",", "$", "validate", ")", ")", ";", "$", "html", "=", "\"\\n\"", ";", "if", "(", "$", "flash", "=", "$", "this", "->", "page", "->", "session", "->", "getFlash", "(", "array", "(", "__CLASS__", ",", "$", "this", "->", "header", "[", "'name'", "]", ")", ")", ")", "{", "$", "html", ".=", "(", "$", "flash", "[", "'status'", "]", "==", "'html'", ")", "?", "$", "flash", "[", "'msg'", "]", ":", "$", "this", "->", "bp", "->", "alert", "(", "$", "flash", "[", "'status'", "]", ",", "$", "flash", "[", "'msg'", "]", ")", ";", "}", "$", "html", ".=", "trim", "(", "parent", "::", "header", "(", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "align", ")", ")", "{", "$", "html", "=", "$", "this", "->", "addClass", "(", "$", "html", ",", "array", "(", "'form'", "=>", "$", "this", "->", "align", ")", ")", ";", "}", "return", "$", "html", ";", "}" ]
Creates the ``<form>``, invokes the Validator jQuery, and displays your message (if any). @param array $validate Override the custom validator settings we have created for Bootstrap @return string @example ```php echo $form->header(); ```
[ "Creates", "the", "<form", ">", "invokes", "the", "Validator", "jQuery", "and", "displays", "your", "message", "(", "if", "any", ")", "." ]
train
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Form.php#L172-L195
Kylob/Bootstrap
src/Form.php
Form.checkbox
public function checkbox($field, array $attributes = array(), $inline = false) { $disabled = in_array('disabled', $attributes) ? 'disabled' : ''; if ($inline !== false) { $wrap = $this->page->tag('label', array('class' => array('checkbox-inline', $this->input, $disabled)), '%s'); } else { $wrap = $this->page->tag('div', array('class' => array('checkbox', $this->input, $disabled)), '<label>%s</label>'); } return parent::checkbox($field, $attributes, $wrap); }
php
public function checkbox($field, array $attributes = array(), $inline = false) { $disabled = in_array('disabled', $attributes) ? 'disabled' : ''; if ($inline !== false) { $wrap = $this->page->tag('label', array('class' => array('checkbox-inline', $this->input, $disabled)), '%s'); } else { $wrap = $this->page->tag('div', array('class' => array('checkbox', $this->input, $disabled)), '<label>%s</label>'); } return parent::checkbox($field, $attributes, $wrap); }
[ "public", "function", "checkbox", "(", "$", "field", ",", "array", "$", "attributes", "=", "array", "(", ")", ",", "$", "inline", "=", "false", ")", "{", "$", "disabled", "=", "in_array", "(", "'disabled'", ",", "$", "attributes", ")", "?", "'disabled'", ":", "''", ";", "if", "(", "$", "inline", "!==", "false", ")", "{", "$", "wrap", "=", "$", "this", "->", "page", "->", "tag", "(", "'label'", ",", "array", "(", "'class'", "=>", "array", "(", "'checkbox-inline'", ",", "$", "this", "->", "input", ",", "$", "disabled", ")", ")", ",", "'%s'", ")", ";", "}", "else", "{", "$", "wrap", "=", "$", "this", "->", "page", "->", "tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "array", "(", "'checkbox'", ",", "$", "this", "->", "input", ",", "$", "disabled", ")", ")", ",", "'<label>%s</label>'", ")", ";", "}", "return", "parent", "::", "checkbox", "(", "$", "field", ",", "$", "attributes", ",", "$", "wrap", ")", ";", "}" ]
Creates checkboxes from the ``$form->menu($field)`` you set earlier. @param string $field The checkbox's name. @param array $attributes Anything else you would like to add besides the 'name', 'value', 'checked', and data validation attributes. @param mixed $inline This tells us if you want the checkboxes to be inline (any value but false), or not (false). @return string A checkbox ``<label><input type="checkbox" ...></label>`` html tag. @example ```php $form->menu('remember', array('Y'=>'Remember Me')); $form->validator->set('remember', 'yesNo'); echo $form->checkbox('remember'); ```
[ "Creates", "checkboxes", "from", "the", "$form", "-", ">", "menu", "(", "$field", ")", "you", "set", "earlier", "." ]
train
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Form.php#L215-L225
Kylob/Bootstrap
src/Form.php
Form.group
public function group($prepend, $append, $input) { if (!empty($prepend)) { foreach ((array) $prepend as $html) { $class = (strpos($html, 'btn') !== false) ? 'input-group-btn' : 'input-group-addon'; $input = $this->page->tag('div', array('class' => $class), $html).$input; } } if (!empty($append)) { foreach ((array) $append as $html) { $class = (strpos($html, 'btn') !== false) ? 'input-group-btn' : 'input-group-addon'; $input = $input.$this->page->tag('div', array('class' => $class), $html); } } $group = array('input-group'); if (!empty($this->input)) { $group[] = str_replace('-', '-group-', $this->input); } return $this->page->tag('div', array('class' => $group), $input); }
php
public function group($prepend, $append, $input) { if (!empty($prepend)) { foreach ((array) $prepend as $html) { $class = (strpos($html, 'btn') !== false) ? 'input-group-btn' : 'input-group-addon'; $input = $this->page->tag('div', array('class' => $class), $html).$input; } } if (!empty($append)) { foreach ((array) $append as $html) { $class = (strpos($html, 'btn') !== false) ? 'input-group-btn' : 'input-group-addon'; $input = $input.$this->page->tag('div', array('class' => $class), $html); } } $group = array('input-group'); if (!empty($this->input)) { $group[] = str_replace('-', '-group-', $this->input); } return $this->page->tag('div', array('class' => $group), $input); }
[ "public", "function", "group", "(", "$", "prepend", ",", "$", "append", ",", "$", "input", ")", "{", "if", "(", "!", "empty", "(", "$", "prepend", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "prepend", "as", "$", "html", ")", "{", "$", "class", "=", "(", "strpos", "(", "$", "html", ",", "'btn'", ")", "!==", "false", ")", "?", "'input-group-btn'", ":", "'input-group-addon'", ";", "$", "input", "=", "$", "this", "->", "page", "->", "tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "$", "class", ")", ",", "$", "html", ")", ".", "$", "input", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "append", ")", ")", "{", "foreach", "(", "(", "array", ")", "$", "append", "as", "$", "html", ")", "{", "$", "class", "=", "(", "strpos", "(", "$", "html", ",", "'btn'", ")", "!==", "false", ")", "?", "'input-group-btn'", ":", "'input-group-addon'", ";", "$", "input", "=", "$", "input", ".", "$", "this", "->", "page", "->", "tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "$", "class", ")", ",", "$", "html", ")", ";", "}", "}", "$", "group", "=", "array", "(", "'input-group'", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "input", ")", ")", "{", "$", "group", "[", "]", "=", "str_replace", "(", "'-'", ",", "'-group-'", ",", "$", "this", "->", "input", ")", ";", "}", "return", "$", "this", "->", "page", "->", "tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "$", "group", ")", ",", "$", "input", ")", ";", "}" ]
Group an input field with addons. You can prepend and/or append a ``$bp->button(...)``, ``$bp->icon(...)``, or just a string of text. To prepend or append multiple elements, then make it an ``array($html, ...)`` of addons. @param string|array $prepend An element to place before the $input. @param string|array $append An element to place after the $input. @param string $input The form field to wrap. @return string A ``<div class="input-group">...</div>`` html string. @example ```php echo $form->group('$', '.00', $form->text('amount')); ```
[ "Group", "an", "input", "field", "with", "addons", ".", "You", "can", "prepend", "and", "/", "or", "append", "a", "$bp", "-", ">", "button", "(", "...", ")", "$bp", "-", ">", "icon", "(", "...", ")", "or", "just", "a", "string", "of", "text", ".", "To", "prepend", "or", "append", "multiple", "elements", "then", "make", "it", "an", "array", "(", "$html", "...", ")", "of", "addons", "." ]
train
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Form.php#L272-L292
Kylob/Bootstrap
src/Form.php
Form.field
public function field($prompt, $input, $error = null) { foreach (array('input', 'select', 'textarea', 'button', 'p') as $tag) { if ($this->firstTagAttributes($input, $matches, '<'.$tag)) { break; } } list($first, $tag, $attributes) = $matches; $type = (isset($attributes['type'])) ? $attributes['type'] : ''; $name = (isset($attributes['name'])) ? $attributes['name'] : ''; $id = (isset($attributes['id'])) ? $attributes['id'] : ''; $prompt = $this->label($prompt, $name, $id); switch ($tag) { case 'input': case 'select': case 'textarea': $input = $this->addClass($input, array('p' => 'help-block')); if ($tag != 'input' || !in_array($type, array('checkbox', 'radio', 'file', 'submit', 'reset', 'button'))) { $input = $this->addClass($input, array($tag => 'form-control '.$this->input)); } break; case 'p': $input = $this->addClass($input, array('p' => 'form-control-static')); break; } $group = array('form-group'); $msg = (empty($name)) ? null : $this->validator->error($name); if (!is_null($error)) { $msg = $error; // override all } if (!empty($msg)) { $group[] = 'has-error'; $error = '<p class="validation help-block">'.$msg.'</p>'; } elseif (!empty($name)) { // only include this when needed for validation $error = '<p class="validation help-block" style="display:none;"></p>'; } if ($this->align == 'form-horizontal') { $class = array('col-'.$this->collapse.'-'.(12 - $this->indent)); if (empty($prompt)) { $class[] = 'col-'.$this->collapse.'-offset-'.$this->indent; } $html = $prompt.$this->page->tag('div', array('class' => $class), $error.$input); } else { $html = $prompt.$error.$input; } return "\n\t".$this->page->tag('div', array('class' => $group), $html); }
php
public function field($prompt, $input, $error = null) { foreach (array('input', 'select', 'textarea', 'button', 'p') as $tag) { if ($this->firstTagAttributes($input, $matches, '<'.$tag)) { break; } } list($first, $tag, $attributes) = $matches; $type = (isset($attributes['type'])) ? $attributes['type'] : ''; $name = (isset($attributes['name'])) ? $attributes['name'] : ''; $id = (isset($attributes['id'])) ? $attributes['id'] : ''; $prompt = $this->label($prompt, $name, $id); switch ($tag) { case 'input': case 'select': case 'textarea': $input = $this->addClass($input, array('p' => 'help-block')); if ($tag != 'input' || !in_array($type, array('checkbox', 'radio', 'file', 'submit', 'reset', 'button'))) { $input = $this->addClass($input, array($tag => 'form-control '.$this->input)); } break; case 'p': $input = $this->addClass($input, array('p' => 'form-control-static')); break; } $group = array('form-group'); $msg = (empty($name)) ? null : $this->validator->error($name); if (!is_null($error)) { $msg = $error; // override all } if (!empty($msg)) { $group[] = 'has-error'; $error = '<p class="validation help-block">'.$msg.'</p>'; } elseif (!empty($name)) { // only include this when needed for validation $error = '<p class="validation help-block" style="display:none;"></p>'; } if ($this->align == 'form-horizontal') { $class = array('col-'.$this->collapse.'-'.(12 - $this->indent)); if (empty($prompt)) { $class[] = 'col-'.$this->collapse.'-offset-'.$this->indent; } $html = $prompt.$this->page->tag('div', array('class' => $class), $error.$input); } else { $html = $prompt.$error.$input; } return "\n\t".$this->page->tag('div', array('class' => $group), $html); }
[ "public", "function", "field", "(", "$", "prompt", ",", "$", "input", ",", "$", "error", "=", "null", ")", "{", "foreach", "(", "array", "(", "'input'", ",", "'select'", ",", "'textarea'", ",", "'button'", ",", "'p'", ")", "as", "$", "tag", ")", "{", "if", "(", "$", "this", "->", "firstTagAttributes", "(", "$", "input", ",", "$", "matches", ",", "'<'", ".", "$", "tag", ")", ")", "{", "break", ";", "}", "}", "list", "(", "$", "first", ",", "$", "tag", ",", "$", "attributes", ")", "=", "$", "matches", ";", "$", "type", "=", "(", "isset", "(", "$", "attributes", "[", "'type'", "]", ")", ")", "?", "$", "attributes", "[", "'type'", "]", ":", "''", ";", "$", "name", "=", "(", "isset", "(", "$", "attributes", "[", "'name'", "]", ")", ")", "?", "$", "attributes", "[", "'name'", "]", ":", "''", ";", "$", "id", "=", "(", "isset", "(", "$", "attributes", "[", "'id'", "]", ")", ")", "?", "$", "attributes", "[", "'id'", "]", ":", "''", ";", "$", "prompt", "=", "$", "this", "->", "label", "(", "$", "prompt", ",", "$", "name", ",", "$", "id", ")", ";", "switch", "(", "$", "tag", ")", "{", "case", "'input'", ":", "case", "'select'", ":", "case", "'textarea'", ":", "$", "input", "=", "$", "this", "->", "addClass", "(", "$", "input", ",", "array", "(", "'p'", "=>", "'help-block'", ")", ")", ";", "if", "(", "$", "tag", "!=", "'input'", "||", "!", "in_array", "(", "$", "type", ",", "array", "(", "'checkbox'", ",", "'radio'", ",", "'file'", ",", "'submit'", ",", "'reset'", ",", "'button'", ")", ")", ")", "{", "$", "input", "=", "$", "this", "->", "addClass", "(", "$", "input", ",", "array", "(", "$", "tag", "=>", "'form-control '", ".", "$", "this", "->", "input", ")", ")", ";", "}", "break", ";", "case", "'p'", ":", "$", "input", "=", "$", "this", "->", "addClass", "(", "$", "input", ",", "array", "(", "'p'", "=>", "'form-control-static'", ")", ")", ";", "break", ";", "}", "$", "group", "=", "array", "(", "'form-group'", ")", ";", "$", "msg", "=", "(", "empty", "(", "$", "name", ")", ")", "?", "null", ":", "$", "this", "->", "validator", "->", "error", "(", "$", "name", ")", ";", "if", "(", "!", "is_null", "(", "$", "error", ")", ")", "{", "$", "msg", "=", "$", "error", ";", "// override all", "}", "if", "(", "!", "empty", "(", "$", "msg", ")", ")", "{", "$", "group", "[", "]", "=", "'has-error'", ";", "$", "error", "=", "'<p class=\"validation help-block\">'", ".", "$", "msg", ".", "'</p>'", ";", "}", "elseif", "(", "!", "empty", "(", "$", "name", ")", ")", "{", "// only include this when needed for validation", "$", "error", "=", "'<p class=\"validation help-block\" style=\"display:none;\"></p>'", ";", "}", "if", "(", "$", "this", "->", "align", "==", "'form-horizontal'", ")", "{", "$", "class", "=", "array", "(", "'col-'", ".", "$", "this", "->", "collapse", ".", "'-'", ".", "(", "12", "-", "$", "this", "->", "indent", ")", ")", ";", "if", "(", "empty", "(", "$", "prompt", ")", ")", "{", "$", "class", "[", "]", "=", "'col-'", ".", "$", "this", "->", "collapse", ".", "'-offset-'", ".", "$", "this", "->", "indent", ";", "}", "$", "html", "=", "$", "prompt", ".", "$", "this", "->", "page", "->", "tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "$", "class", ")", ",", "$", "error", ".", "$", "input", ")", ";", "}", "else", "{", "$", "html", "=", "$", "prompt", ".", "$", "error", ".", "$", "input", ";", "}", "return", "\"\\n\\t\"", ".", "$", "this", "->", "page", "->", "tag", "(", "'div'", ",", "array", "(", "'class'", "=>", "$", "group", ")", ",", "$", "html", ")", ";", "}" ]
Adds a (properly formatted) **$prompt** to your **$input** field, and manages any error messages. @param string|array $prompt For the **$input** field. If you want to include additional info that will appear when clicked or hovered over, then you can make this an ``array($prompt => $info)``. To customize the icon used, set ``$form->prompt('info', 'fa fa-info-circle')``. @param string $input A form field, or help block, etc. @param string $error An optional error to override, and include with the field. @return string A ``<div class="form-group">...</div>`` html string. @example ```php echo $form->field('Amount', $form->group('$', '.00', $form->text('amount'))); ```
[ "Adds", "a", "(", "properly", "formatted", ")", "**", "$prompt", "**", "to", "your", "**", "$input", "**", "field", "and", "manages", "any", "error", "messages", "." ]
train
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Form.php#L309-L356
Kylob/Bootstrap
src/Form.php
Form.submit
public function submit($submit = 'Submit', $reset = '') { // never use name="submit" per: http://jqueryvalidation.org/reference/#developing-and-debugging-a-form $buttons = func_get_args(); if (substr($submit, 0, 1) != '<') { $buttons[0] = $this->page->tag('button', array( 'type' => 'submit', 'class' => array('btn', 'btn-primary', str_replace('input', 'btn', $this->input)), 'data-loading-text' => 'Submitting...', ), $submit); } if (isset($buttons[1]) && substr($reset, 0, 1) != '<') { $buttons[1] = $this->page->tag('button', array( 'type' => 'reset', 'class' => array('btn', 'btn-default', str_replace('input', 'btn', $this->input)), ), $reset); } return $this->field('', implode(' ', $buttons)); }
php
public function submit($submit = 'Submit', $reset = '') { // never use name="submit" per: http://jqueryvalidation.org/reference/#developing-and-debugging-a-form $buttons = func_get_args(); if (substr($submit, 0, 1) != '<') { $buttons[0] = $this->page->tag('button', array( 'type' => 'submit', 'class' => array('btn', 'btn-primary', str_replace('input', 'btn', $this->input)), 'data-loading-text' => 'Submitting...', ), $submit); } if (isset($buttons[1]) && substr($reset, 0, 1) != '<') { $buttons[1] = $this->page->tag('button', array( 'type' => 'reset', 'class' => array('btn', 'btn-default', str_replace('input', 'btn', $this->input)), ), $reset); } return $this->field('', implode(' ', $buttons)); }
[ "public", "function", "submit", "(", "$", "submit", "=", "'Submit'", ",", "$", "reset", "=", "''", ")", "{", "// never use name=\"submit\" per: http://jqueryvalidation.org/reference/#developing-and-debugging-a-form", "$", "buttons", "=", "func_get_args", "(", ")", ";", "if", "(", "substr", "(", "$", "submit", ",", "0", ",", "1", ")", "!=", "'<'", ")", "{", "$", "buttons", "[", "0", "]", "=", "$", "this", "->", "page", "->", "tag", "(", "'button'", ",", "array", "(", "'type'", "=>", "'submit'", ",", "'class'", "=>", "array", "(", "'btn'", ",", "'btn-primary'", ",", "str_replace", "(", "'input'", ",", "'btn'", ",", "$", "this", "->", "input", ")", ")", ",", "'data-loading-text'", "=>", "'Submitting...'", ",", ")", ",", "$", "submit", ")", ";", "}", "if", "(", "isset", "(", "$", "buttons", "[", "1", "]", ")", "&&", "substr", "(", "$", "reset", ",", "0", ",", "1", ")", "!=", "'<'", ")", "{", "$", "buttons", "[", "1", "]", "=", "$", "this", "->", "page", "->", "tag", "(", "'button'", ",", "array", "(", "'type'", "=>", "'reset'", ",", "'class'", "=>", "array", "(", "'btn'", ",", "'btn-default'", ",", "str_replace", "(", "'input'", ",", "'btn'", ",", "$", "this", "->", "input", ")", ")", ",", ")", ",", "$", "reset", ")", ";", "}", "return", "$", "this", "->", "field", "(", "''", ",", "implode", "(", "' '", ",", "$", "buttons", ")", ")", ";", "}" ]
Quickly adds a submit button to your form. @param string $submit What you would like the submit button to say. If it starts with a '**<**', then we assume you have spelled it all out for us. @param string $reset This will add a reset button if you give it a value, and if it starts with a '**<**' then it can be whatever you want it to be. You can keep adding args until you run out of ideas for buttons to include. @return string A ``<div class="form-group">...</div>`` html string with buttons. @example ```php echo $form->submit(); ```
[ "Quickly", "adds", "a", "submit", "button", "to", "your", "form", "." ]
train
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Form.php#L372-L391
Kylob/Bootstrap
src/Form.php
Form.label
private function label($prompt, $name, $id) { if (empty($prompt)) { return ''; } if (is_array($prompt)) { list($prompt, $info) = (count($prompt) > 1) ? array_values($prompt) : each($prompt); } if (empty($prompt) || strpos($prompt, '<label') !== false) { return $prompt; } if (isset($this->prompt['prepend'])) { if (!$this->prompt['prepend']['required'] || $this->validator->required($name)) { $prompt = $this->prompt['prepend']['html'].$prompt; } } if (isset($this->prompt['append'])) { $prompt .= $this->prompt['append']; } if (isset($info)) { $prompt .= ' '.$this->page->tag('i', array( 'title' => htmlspecialchars($info), 'class' => $this->prompt['info'], 'style' => 'cursor:pointer;', 'data-html' => 'true', 'data-toggle' => 'tooltip', 'data-placement' => 'bottom', 'data-container' => 'form[name='.$this->header['name'].']', ), ''); $this->page->jquery('$(\'[data-toggle="tooltip"]\').tooltip();'); } switch ($this->align) { case 'form-inline': $class = 'sr-only'; break; case 'form-horizontal': $class = array( "col-{$this->collapse}-{$this->indent}", 'control-label', $this->input, ); break; default: $class = $this->input; break; } return $this->page->tag('label', array( 'class' => $class, 'for' => $id, ), $prompt); }
php
private function label($prompt, $name, $id) { if (empty($prompt)) { return ''; } if (is_array($prompt)) { list($prompt, $info) = (count($prompt) > 1) ? array_values($prompt) : each($prompt); } if (empty($prompt) || strpos($prompt, '<label') !== false) { return $prompt; } if (isset($this->prompt['prepend'])) { if (!$this->prompt['prepend']['required'] || $this->validator->required($name)) { $prompt = $this->prompt['prepend']['html'].$prompt; } } if (isset($this->prompt['append'])) { $prompt .= $this->prompt['append']; } if (isset($info)) { $prompt .= ' '.$this->page->tag('i', array( 'title' => htmlspecialchars($info), 'class' => $this->prompt['info'], 'style' => 'cursor:pointer;', 'data-html' => 'true', 'data-toggle' => 'tooltip', 'data-placement' => 'bottom', 'data-container' => 'form[name='.$this->header['name'].']', ), ''); $this->page->jquery('$(\'[data-toggle="tooltip"]\').tooltip();'); } switch ($this->align) { case 'form-inline': $class = 'sr-only'; break; case 'form-horizontal': $class = array( "col-{$this->collapse}-{$this->indent}", 'control-label', $this->input, ); break; default: $class = $this->input; break; } return $this->page->tag('label', array( 'class' => $class, 'for' => $id, ), $prompt); }
[ "private", "function", "label", "(", "$", "prompt", ",", "$", "name", ",", "$", "id", ")", "{", "if", "(", "empty", "(", "$", "prompt", ")", ")", "{", "return", "''", ";", "}", "if", "(", "is_array", "(", "$", "prompt", ")", ")", "{", "list", "(", "$", "prompt", ",", "$", "info", ")", "=", "(", "count", "(", "$", "prompt", ")", ">", "1", ")", "?", "array_values", "(", "$", "prompt", ")", ":", "each", "(", "$", "prompt", ")", ";", "}", "if", "(", "empty", "(", "$", "prompt", ")", "||", "strpos", "(", "$", "prompt", ",", "'<label'", ")", "!==", "false", ")", "{", "return", "$", "prompt", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "prompt", "[", "'prepend'", "]", ")", ")", "{", "if", "(", "!", "$", "this", "->", "prompt", "[", "'prepend'", "]", "[", "'required'", "]", "||", "$", "this", "->", "validator", "->", "required", "(", "$", "name", ")", ")", "{", "$", "prompt", "=", "$", "this", "->", "prompt", "[", "'prepend'", "]", "[", "'html'", "]", ".", "$", "prompt", ";", "}", "}", "if", "(", "isset", "(", "$", "this", "->", "prompt", "[", "'append'", "]", ")", ")", "{", "$", "prompt", ".=", "$", "this", "->", "prompt", "[", "'append'", "]", ";", "}", "if", "(", "isset", "(", "$", "info", ")", ")", "{", "$", "prompt", ".=", "' '", ".", "$", "this", "->", "page", "->", "tag", "(", "'i'", ",", "array", "(", "'title'", "=>", "htmlspecialchars", "(", "$", "info", ")", ",", "'class'", "=>", "$", "this", "->", "prompt", "[", "'info'", "]", ",", "'style'", "=>", "'cursor:pointer;'", ",", "'data-html'", "=>", "'true'", ",", "'data-toggle'", "=>", "'tooltip'", ",", "'data-placement'", "=>", "'bottom'", ",", "'data-container'", "=>", "'form[name='", ".", "$", "this", "->", "header", "[", "'name'", "]", ".", "']'", ",", ")", ",", "''", ")", ";", "$", "this", "->", "page", "->", "jquery", "(", "'$(\\'[data-toggle=\"tooltip\"]\\').tooltip();'", ")", ";", "}", "switch", "(", "$", "this", "->", "align", ")", "{", "case", "'form-inline'", ":", "$", "class", "=", "'sr-only'", ";", "break", ";", "case", "'form-horizontal'", ":", "$", "class", "=", "array", "(", "\"col-{$this->collapse}-{$this->indent}\"", ",", "'control-label'", ",", "$", "this", "->", "input", ",", ")", ";", "break", ";", "default", ":", "$", "class", "=", "$", "this", "->", "input", ";", "break", ";", "}", "return", "$", "this", "->", "page", "->", "tag", "(", "'label'", ",", "array", "(", "'class'", "=>", "$", "class", ",", "'for'", "=>", "$", "id", ",", ")", ",", "$", "prompt", ")", ";", "}" ]
Used by ``$this->field()`` to create a ``<label>`` prompt. @param string|array $prompt The form label reference. @param string $name The name of the associated input field. @param string $id The id of the associated input field. @return string The generated HTML ``<label>``.
[ "Used", "by", "$this", "-", ">", "field", "()", "to", "create", "a", "<label", ">", "prompt", "." ]
train
https://github.com/Kylob/Bootstrap/blob/0d7677a90656fbc461eabb5512ab16f9d5f728c6/src/Form.php#L402-L453
Double-Opt-in/php-client-api
src/Client/Commands/Responses/DecryptedCommandResponse.php
DecryptedCommandResponse.assignCryptographyEngine
public function assignCryptographyEngine(CryptographyEngine $cryptographyEngine, $email) { $this->cryptographyEngine = $cryptographyEngine; $this->email = $email; }
php
public function assignCryptographyEngine(CryptographyEngine $cryptographyEngine, $email) { $this->cryptographyEngine = $cryptographyEngine; $this->email = $email; }
[ "public", "function", "assignCryptographyEngine", "(", "CryptographyEngine", "$", "cryptographyEngine", ",", "$", "email", ")", "{", "$", "this", "->", "cryptographyEngine", "=", "$", "cryptographyEngine", ";", "$", "this", "->", "email", "=", "$", "email", ";", "}" ]
assigns the cryptography engine @param \DoubleOptIn\ClientApi\Security\CryptographyEngine $cryptographyEngine @param string $email @return void
[ "assigns", "the", "cryptography", "engine" ]
train
https://github.com/Double-Opt-in/php-client-api/blob/2f17da58ec20a408bbd55b2cdd053bc689f995f4/src/Client/Commands/Responses/DecryptedCommandResponse.php#L38-L42