repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
oxygen-cms/core
src/Form/Type/BooleanType.php
BooleanType.transformOutput
public function transformOutput(FieldMetadata $metadata, $value) { if($value === true || $value === 1) { return 'true'; } else { if($value === false || $value === 0) { return 'false'; } else { return 'unknown'; } } }
php
public function transformOutput(FieldMetadata $metadata, $value) { if($value === true || $value === 1) { return 'true'; } else { if($value === false || $value === 0) { return 'false'; } else { return 'unknown'; } } }
[ "public", "function", "transformOutput", "(", "FieldMetadata", "$", "metadata", ",", "$", "value", ")", "{", "if", "(", "$", "value", "===", "true", "||", "$", "value", "===", "1", ")", "{", "return", "'true'", ";", "}", "else", "{", "if", "(", "$", ...
Transforms the given value into a string representation. @param FieldMetadata $metadata @param mixed $value @return string
[ "Transforms", "the", "given", "value", "into", "a", "string", "representation", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/Form/Type/BooleanType.php#L27-L37
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Export/Format/JsonFormat.php
JsonFormat.export
public function export() { $result = []; foreach ($this->getListBuilder()->getResult() as $item) { foreach ($item->getFields() as $field) { $result[$item->getIdentifier()][$field->getName()] = $field->getValue(); } } return $this->createResponse(Response::json($result)->getContent()); }
php
public function export() { $result = []; foreach ($this->getListBuilder()->getResult() as $item) { foreach ($item->getFields() as $field) { $result[$item->getIdentifier()][$field->getName()] = $field->getValue(); } } return $this->createResponse(Response::json($result)->getContent()); }
[ "public", "function", "export", "(", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getListBuilder", "(", ")", "->", "getResult", "(", ")", "as", "$", "item", ")", "{", "foreach", "(", "$", "item", "->", "getFields...
Create the json response. @access public @return JsonResponse|mixed
[ "Create", "the", "json", "response", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Export/Format/JsonFormat.php#L43-L53
schmunk42/p3extensions
components/P3LangHandler.php
P3LangHandler.init
public function init() { // parsing needed if urlFormat 'path' if (Yii::app() instanceof CWebApplication) { Yii::app()->urlManager->parseUrl(Yii::app()->getRequest()); } // 1. get language preference $preferred = null; if (isset($_GET[self::DATA_KEY])) { // use language from URL $preferred = $_GET[self::DATA_KEY]; } elseif ($this->usePreferred) { // use preferred browser language as default $preferred = Yii::app()->request->preferredLanguage; } else { $preferred = Yii::app()->language; } // 2. select language based on available languages and mappings $lang = $this->resolveLanguage($preferred); if (is_null($lang) && $this->matchShort === true) { $preferredShort = substr($preferred, 0, 2); $lang = $this->resolveLanguage($preferredShort); } // 3. set the language if (in_array($lang, $this->languages)) { Yii::app()->setLanguage($lang); } else { // fallback or output error if ($this->fallback) { // default app language } else { throw new CHttpException(404, "Language '{$_GET[self::DATA_KEY]}' is not available."); } } if ($this->localizedHomeUrl) { $controller = new CController('P3LangHandlerDummy'); Yii::app()->homeUrl = $controller->createUrl('/'); } }
php
public function init() { // parsing needed if urlFormat 'path' if (Yii::app() instanceof CWebApplication) { Yii::app()->urlManager->parseUrl(Yii::app()->getRequest()); } // 1. get language preference $preferred = null; if (isset($_GET[self::DATA_KEY])) { // use language from URL $preferred = $_GET[self::DATA_KEY]; } elseif ($this->usePreferred) { // use preferred browser language as default $preferred = Yii::app()->request->preferredLanguage; } else { $preferred = Yii::app()->language; } // 2. select language based on available languages and mappings $lang = $this->resolveLanguage($preferred); if (is_null($lang) && $this->matchShort === true) { $preferredShort = substr($preferred, 0, 2); $lang = $this->resolveLanguage($preferredShort); } // 3. set the language if (in_array($lang, $this->languages)) { Yii::app()->setLanguage($lang); } else { // fallback or output error if ($this->fallback) { // default app language } else { throw new CHttpException(404, "Language '{$_GET[self::DATA_KEY]}' is not available."); } } if ($this->localizedHomeUrl) { $controller = new CController('P3LangHandlerDummy'); Yii::app()->homeUrl = $controller->createUrl('/'); } }
[ "public", "function", "init", "(", ")", "{", "// parsing needed if urlFormat 'path'\r", "if", "(", "Yii", "::", "app", "(", ")", "instanceof", "CWebApplication", ")", "{", "Yii", "::", "app", "(", ")", "->", "urlManager", "->", "parseUrl", "(", "Yii", "::", ...
Handles language detection and application setting by URL parm specified in DATA_KEY
[ "Handles", "language", "detection", "and", "application", "setting", "by", "URL", "parm", "specified", "in", "DATA_KEY" ]
train
https://github.com/schmunk42/p3extensions/blob/93999c06fc8e3eadd83983d001df231e46b06838/components/P3LangHandler.php#L62-L104
schmunk42/p3extensions
components/P3LangHandler.php
P3LangHandler.getCountry
public function getCountry() { if (strstr(Yii::app()->language, '_')) { return substr(strstr(Yii::app()->language, '_'), 1); } else { return null; } }
php
public function getCountry() { if (strstr(Yii::app()->language, '_')) { return substr(strstr(Yii::app()->language, '_'), 1); } else { return null; } }
[ "public", "function", "getCountry", "(", ")", "{", "if", "(", "strstr", "(", "Yii", "::", "app", "(", ")", "->", "language", ",", "'_'", ")", ")", "{", "return", "substr", "(", "strstr", "(", "Yii", "::", "app", "(", ")", "->", "language", ",", "...
Returns the region part for application language, `null` if the short form is used. Eg. `ch` for `Yii::app()->langauge = 'de_ch` @return string
[ "Returns", "the", "region", "part", "for", "application", "language", "null", "if", "the", "short", "form", "is", "used", ".", "Eg", ".", "ch", "for", "Yii", "::", "app", "()", "-", ">", "langauge", "=", "de_ch" ]
train
https://github.com/schmunk42/p3extensions/blob/93999c06fc8e3eadd83983d001df231e46b06838/components/P3LangHandler.php#L121-L128
schmunk42/p3extensions
components/P3LangHandler.php
P3LangHandler.resolveLanguage
private function resolveLanguage($preferred) { if (in_array($preferred, $this->languages)) { return $preferred; } elseif (isset($this->mappings[$preferred])) { return $this->mappings[$preferred]; } return null; }
php
private function resolveLanguage($preferred) { if (in_array($preferred, $this->languages)) { return $preferred; } elseif (isset($this->mappings[$preferred])) { return $this->mappings[$preferred]; } return null; }
[ "private", "function", "resolveLanguage", "(", "$", "preferred", ")", "{", "if", "(", "in_array", "(", "$", "preferred", ",", "$", "this", "->", "languages", ")", ")", "{", "return", "$", "preferred", ";", "}", "elseif", "(", "isset", "(", "$", "this",...
Resolves an available language from a preferred language. @param type $preferred @return Resolved language if configured app language or available through fallback mapping
[ "Resolves", "an", "available", "language", "from", "a", "preferred", "language", "." ]
train
https://github.com/schmunk42/p3extensions/blob/93999c06fc8e3eadd83983d001df231e46b06838/components/P3LangHandler.php#L138-L146
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/MimeType.php
Zend_Validate_File_MimeType.isValid
public function isValid($value, $file = null) { // Is file readable ? if (!@is_readable($value)) { $this->_throw($file, self::NOT_READABLE); return false; } if ($file !== null) { $info['type'] = $file['type']; } else { $this->_throw($file, self::NOT_DETECTED); return false; } $mimetype = $this->getMimeType(true); if (in_array($info['type'], $mimetype)) { return true; } foreach($mimetype as $mime) { $types = explode('/', $info['type']); if (in_array($mime, $types)) { return true; } } $this->_throw($file, self::FALSE_TYPE); return false; }
php
public function isValid($value, $file = null) { // Is file readable ? if (!@is_readable($value)) { $this->_throw($file, self::NOT_READABLE); return false; } if ($file !== null) { $info['type'] = $file['type']; } else { $this->_throw($file, self::NOT_DETECTED); return false; } $mimetype = $this->getMimeType(true); if (in_array($info['type'], $mimetype)) { return true; } foreach($mimetype as $mime) { $types = explode('/', $info['type']); if (in_array($mime, $types)) { return true; } } $this->_throw($file, self::FALSE_TYPE); return false; }
[ "public", "function", "isValid", "(", "$", "value", ",", "$", "file", "=", "null", ")", "{", "// Is file readable ?", "if", "(", "!", "@", "is_readable", "(", "$", "value", ")", ")", "{", "$", "this", "->", "_throw", "(", "$", "file", ",", "self", ...
Defined by Zend_Validate_Interface Returns true if the mimetype of the file matches the given ones. Also parts of mimetypes can be checked. If you give for example "image" all image mime types will be accepted like "image/gif", "image/jpeg" and so on. @param string $value Real file to check for mimetype @param array $file File data from Zend_File_Transfer @return boolean
[ "Defined", "by", "Zend_Validate_Interface" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/MimeType.php#L153-L182
superrbstudio/async
src/Superrb/Async/Socket.php
Socket.send
public function send($msg): bool { // JSON encode message if supplied in array or object form if (is_array($msg) || is_object($msg)) { $msg = json_encode($msg); } // Ensure message is a string $msg = (string) $msg; // Check the message fits within the buffer if (strlen($msg) > $this->buffer) { throw new SocketCommunicationException('Tried to send data larger than buffer size of '.$this->buffer.' bytes. Recreate channel with a larger buffer to send this data'); } // Pad the message to the buffer size $msg = str_pad($msg, $this->buffer, ' '); // Write the message to the socket return socket_write($this->socket, $msg, $this->buffer); }
php
public function send($msg): bool { // JSON encode message if supplied in array or object form if (is_array($msg) || is_object($msg)) { $msg = json_encode($msg); } // Ensure message is a string $msg = (string) $msg; // Check the message fits within the buffer if (strlen($msg) > $this->buffer) { throw new SocketCommunicationException('Tried to send data larger than buffer size of '.$this->buffer.' bytes. Recreate channel with a larger buffer to send this data'); } // Pad the message to the buffer size $msg = str_pad($msg, $this->buffer, ' '); // Write the message to the socket return socket_write($this->socket, $msg, $this->buffer); }
[ "public", "function", "send", "(", "$", "msg", ")", ":", "bool", "{", "// JSON encode message if supplied in array or object form", "if", "(", "is_array", "(", "$", "msg", ")", "||", "is_object", "(", "$", "msg", ")", ")", "{", "$", "msg", "=", "json_encode"...
Send a message to the socket. @param mixed $msg @return bool
[ "Send", "a", "message", "to", "the", "socket", "." ]
train
https://github.com/superrbstudio/async/blob/8ca958dd453588c8b474ccba01bc7f709714a03b/src/Superrb/Async/Socket.php#L47-L67
superrbstudio/async
src/Superrb/Async/Socket.php
Socket.receive
public function receive() { // Read data from the socket socket_recv($this->socket, $msg, $this->buffer, MSG_DONTWAIT); if ($msg === false) { return null; } // Trim the padding from the message content $msg = trim($msg); // If message is not valid JSON, return it verbatim if (json_decode($msg) === null) { return $msg; } // Decode and return the message content return json_decode($msg); }
php
public function receive() { // Read data from the socket socket_recv($this->socket, $msg, $this->buffer, MSG_DONTWAIT); if ($msg === false) { return null; } // Trim the padding from the message content $msg = trim($msg); // If message is not valid JSON, return it verbatim if (json_decode($msg) === null) { return $msg; } // Decode and return the message content return json_decode($msg); }
[ "public", "function", "receive", "(", ")", "{", "// Read data from the socket", "socket_recv", "(", "$", "this", "->", "socket", ",", "$", "msg", ",", "$", "this", "->", "buffer", ",", "MSG_DONTWAIT", ")", ";", "if", "(", "$", "msg", "===", "false", ")",...
Receive data from the socket. @return mixed
[ "Receive", "data", "from", "the", "socket", "." ]
train
https://github.com/superrbstudio/async/blob/8ca958dd453588c8b474ccba01bc7f709714a03b/src/Superrb/Async/Socket.php#L74-L93
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Menu/Builder.php
Builder.build
public function build() { $menu = $this->items; $html = ''; if (isset($menu['right'])) { $html.= '<ul class="nav navbar-nav navbar-right">'; $html.= $this->buildMenu($menu['right']); $html.= '</ul>'; } $html.= '<ul class="nav navbar-nav">'; $html.= sprintf('<li><a href="%s">Dashboard</a></li>', route('admin.dashboard')); $html.= $this->buildMenu($menu['left']); $html.= '</ul>'; return $html; }
php
public function build() { $menu = $this->items; $html = ''; if (isset($menu['right'])) { $html.= '<ul class="nav navbar-nav navbar-right">'; $html.= $this->buildMenu($menu['right']); $html.= '</ul>'; } $html.= '<ul class="nav navbar-nav">'; $html.= sprintf('<li><a href="%s">Dashboard</a></li>', route('admin.dashboard')); $html.= $this->buildMenu($menu['left']); $html.= '</ul>'; return $html; }
[ "public", "function", "build", "(", ")", "{", "$", "menu", "=", "$", "this", "->", "items", ";", "$", "html", "=", "''", ";", "if", "(", "isset", "(", "$", "menu", "[", "'right'", "]", ")", ")", "{", "$", "html", ".=", "'<ul class=\"nav navbar-nav ...
Build the menu html. @access public @return string
[ "Build", "the", "menu", "html", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Menu/Builder.php#L76-L94
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Menu/Builder.php
Builder.buildMenu
private function buildMenu($menu) { $html = ''; foreach ($menu as $value) { $icon = ''; if (isset($value['icon'])) { $icon = sprintf('<i class="fa fa-%s"></i> ', $value['icon']); } if (isset($value['children'])) { $html.= '<li class="dropdown">'; $html.= sprintf('<a href="#" class="dropdown-toggle" data-toggle="dropdown">%s%s<b class="caret"></b></a>', $icon, $value['title']); $html.= '<ul class="dropdown-menu">'; $html.= $this->buildMenu($value['children']); $html.= '</ul>'; $html.= '</li>'; continue; } $url = ''; if (isset($value['class'])) { $url = route('admin.model.index', urlencode($value['class'])); } elseif (isset($value['url'])) { $url = url($value['url']); } elseif (isset($value['route'])) { $url = route($value['route']); } if (isset($value['text'])) { $html.= sprintf('<li><p class="navbar-text">%s</p></li>', $value['text']); } elseif (isset($value['image'])) { $html.= sprintf('<li><img src="%s" class="navbar-image"></li>', $value['image']); } else { $html.= sprintf('<li><a href="%s">%s%s</a></li>', $url, $icon, $value['title']); } } return $html; }
php
private function buildMenu($menu) { $html = ''; foreach ($menu as $value) { $icon = ''; if (isset($value['icon'])) { $icon = sprintf('<i class="fa fa-%s"></i> ', $value['icon']); } if (isset($value['children'])) { $html.= '<li class="dropdown">'; $html.= sprintf('<a href="#" class="dropdown-toggle" data-toggle="dropdown">%s%s<b class="caret"></b></a>', $icon, $value['title']); $html.= '<ul class="dropdown-menu">'; $html.= $this->buildMenu($value['children']); $html.= '</ul>'; $html.= '</li>'; continue; } $url = ''; if (isset($value['class'])) { $url = route('admin.model.index', urlencode($value['class'])); } elseif (isset($value['url'])) { $url = url($value['url']); } elseif (isset($value['route'])) { $url = route($value['route']); } if (isset($value['text'])) { $html.= sprintf('<li><p class="navbar-text">%s</p></li>', $value['text']); } elseif (isset($value['image'])) { $html.= sprintf('<li><img src="%s" class="navbar-image"></li>', $value['image']); } else { $html.= sprintf('<li><a href="%s">%s%s</a></li>', $url, $icon, $value['title']); } } return $html; }
[ "private", "function", "buildMenu", "(", "$", "menu", ")", "{", "$", "html", "=", "''", ";", "foreach", "(", "$", "menu", "as", "$", "value", ")", "{", "$", "icon", "=", "''", ";", "if", "(", "isset", "(", "$", "value", "[", "'icon'", "]", ")",...
Iterator method for the build() function. @param array $menu @access public @return string
[ "Iterator", "method", "for", "the", "build", "()", "function", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Menu/Builder.php#L104-L145
hannesvdvreken/guzzle-profiler
src/DescriptionMaker.php
DescriptionMaker.describe
protected function describe(RequestInterface $request, ResponseInterface $response = null) { if (!$response) { return sprintf('%s %s failed', $request->getMethod(), $request->getUri()); } return sprintf( '%s %s returned %s %s', $request->getMethod(), $request->getUri(), $response->getStatusCode(), $response->getReasonPhrase() ); }
php
protected function describe(RequestInterface $request, ResponseInterface $response = null) { if (!$response) { return sprintf('%s %s failed', $request->getMethod(), $request->getUri()); } return sprintf( '%s %s returned %s %s', $request->getMethod(), $request->getUri(), $response->getStatusCode(), $response->getReasonPhrase() ); }
[ "protected", "function", "describe", "(", "RequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", "=", "null", ")", "{", "if", "(", "!", "$", "response", ")", "{", "return", "sprintf", "(", "'%s %s failed'", ",", "$", "request", "->", ...
@param \Psr\Http\Message\RequestInterface $request @param \Psr\Http\Message\ResponseInterface $response @return string
[ "@param", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "RequestInterface", "$request", "@param", "\\", "Psr", "\\", "Http", "\\", "Message", "\\", "ResponseInterface", "$response" ]
train
https://github.com/hannesvdvreken/guzzle-profiler/blob/23b938f25f1d4be943c29b4e030a17e55dbcb3ae/src/DescriptionMaker.php#L15-L28
oxygen-cms/core
src/View/Factory.php
Factory.model
public function model($model, $field, $data = [], $mergeData = []) { $contents = $model->getAttribute($field); $path = $this->pathFromModel(get_class($model), $model->getId(), $field); $timestamp = class_uses($model, 'Oxygen\Data\Behaviour\Timestamps') ? $model->getAttribute('updatedAt')->getTimestamp() : 0; return $this->string($contents, $path, $timestamp, $data, $mergeData); }
php
public function model($model, $field, $data = [], $mergeData = []) { $contents = $model->getAttribute($field); $path = $this->pathFromModel(get_class($model), $model->getId(), $field); $timestamp = class_uses($model, 'Oxygen\Data\Behaviour\Timestamps') ? $model->getAttribute('updatedAt')->getTimestamp() : 0; return $this->string($contents, $path, $timestamp, $data, $mergeData); }
[ "public", "function", "model", "(", "$", "model", ",", "$", "field", ",", "$", "data", "=", "[", "]", ",", "$", "mergeData", "=", "[", "]", ")", "{", "$", "contents", "=", "$", "model", "->", "getAttribute", "(", "$", "field", ")", ";", "$", "p...
Get the evaluated view contents for the given model and field. If the model doesn't use timestamps then the view will be re-compiled on every request. @param object $model @param string $field @param array $data @param array $mergeData @return \Illuminate\View\View
[ "Get", "the", "evaluated", "view", "contents", "for", "the", "given", "model", "and", "field", ".", "If", "the", "model", "doesn", "t", "use", "timestamps", "then", "the", "view", "will", "be", "re", "-", "compiled", "on", "every", "request", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/Factory.php#L19-L25
oxygen-cms/core
src/View/Factory.php
Factory.pathFromModel
public function pathFromModel($className, $id, $field) { $path = 'db_' . $className . '_' . $id . '_' . $field; return strtolower(str_replace(['-', '.'], '_', $path)); }
php
public function pathFromModel($className, $id, $field) { $path = 'db_' . $className . '_' . $id . '_' . $field; return strtolower(str_replace(['-', '.'], '_', $path)); }
[ "public", "function", "pathFromModel", "(", "$", "className", ",", "$", "id", ",", "$", "field", ")", "{", "$", "path", "=", "'db_'", ".", "$", "className", ".", "'_'", ".", "$", "id", ".", "'_'", ".", "$", "field", ";", "return", "strtolower", "("...
Generates a unique path from a model. @param $className @param $id @param string $field @return string
[ "Generates", "a", "unique", "path", "from", "a", "model", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/Factory.php#L35-L39
oxygen-cms/core
src/View/Factory.php
Factory.string
public function string($contents, $unique, $timestamp, $data = [], $mergeData = []) { $data = array_merge($mergeData, $this->parseData($data)); $this->callCreator($view = new StringView($this, $this->engines->resolve('blade.string'), $contents, $unique, $timestamp, $data)); return $view; }
php
public function string($contents, $unique, $timestamp, $data = [], $mergeData = []) { $data = array_merge($mergeData, $this->parseData($data)); $this->callCreator($view = new StringView($this, $this->engines->resolve('blade.string'), $contents, $unique, $timestamp, $data)); return $view; }
[ "public", "function", "string", "(", "$", "contents", ",", "$", "unique", ",", "$", "timestamp", ",", "$", "data", "=", "[", "]", ",", "$", "mergeData", "=", "[", "]", ")", "{", "$", "data", "=", "array_merge", "(", "$", "mergeData", ",", "$", "t...
Get the evaluated view contents for the given string. @param string $contents @param string $unique @param int $timestamp @param array $data @param array $mergeData @return \Illuminate\View\View
[ "Get", "the", "evaluated", "view", "contents", "for", "the", "given", "string", "." ]
train
https://github.com/oxygen-cms/core/blob/8f8349c669771d9a7a719a7b120821e06cb5a20b/src/View/Factory.php#L51-L57
Lansoweb/LosLog
src/ErrorLogger.php
ErrorLogger.registerHandlers
public static function registerHandlers($logFile = 'error.log', $logDir = 'data/logs', $continue = true) { $logger = AbstractLogger::generateFileLogger($logFile, $logDir); Logger::registerErrorHandler($logger->getLogger(), $continue); Logger::registerFatalErrorShutdownFunction($logger->getLogger()); }
php
public static function registerHandlers($logFile = 'error.log', $logDir = 'data/logs', $continue = true) { $logger = AbstractLogger::generateFileLogger($logFile, $logDir); Logger::registerErrorHandler($logger->getLogger(), $continue); Logger::registerFatalErrorShutdownFunction($logger->getLogger()); }
[ "public", "static", "function", "registerHandlers", "(", "$", "logFile", "=", "'error.log'", ",", "$", "logDir", "=", "'data/logs'", ",", "$", "continue", "=", "true", ")", "{", "$", "logger", "=", "AbstractLogger", "::", "generateFileLogger", "(", "$", "log...
Registers the handlers for errors and exceptions. @param string $logFile @param string $logDir @param bool $continue @throws Exception\InvalidArgumentException
[ "Registers", "the", "handlers", "for", "errors", "and", "exceptions", "." ]
train
https://github.com/Lansoweb/LosLog/blob/1d7d24db66a8f77da2b7e33bb10d6665133c9199/src/ErrorLogger.php#L40-L46
dave-redfern/laravel-doctrine-tenancy
src/Foundation/TenantAwareApplication.php
TenantAwareApplication.registerBaseTenantBindings
protected function registerBaseTenantBindings() { $this->singleton(TenantContract::class, function ($app) { return new Tenant(new NullUser(), new NullTenant(), new NullTenant()); }); $this->alias(TenantContract::class, 'auth.tenant'); }
php
protected function registerBaseTenantBindings() { $this->singleton(TenantContract::class, function ($app) { return new Tenant(new NullUser(), new NullTenant(), new NullTenant()); }); $this->alias(TenantContract::class, 'auth.tenant'); }
[ "protected", "function", "registerBaseTenantBindings", "(", ")", "{", "$", "this", "->", "singleton", "(", "TenantContract", "::", "class", ",", "function", "(", "$", "app", ")", "{", "return", "new", "Tenant", "(", "new", "NullUser", "(", ")", ",", "new",...
Register the root Tenant instance @return void
[ "Register", "the", "root", "Tenant", "instance" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Foundation/TenantAwareApplication.php#L62-L69
dave-redfern/laravel-doctrine-tenancy
src/Foundation/TenantAwareApplication.php
TenantAwareApplication.getTenantCacheName
protected function getTenantCacheName($default) { if ($this->isMultiSiteTenant()) { $creator = $this['auth.tenant']->getTenantCreator()->getDomain(); $owner = $this['auth.tenant']->getTenantOwner()->getDomain(); if ($creator && $creator != $owner) { return $creator; } else { return $owner; } } return $default; }
php
protected function getTenantCacheName($default) { if ($this->isMultiSiteTenant()) { $creator = $this['auth.tenant']->getTenantCreator()->getDomain(); $owner = $this['auth.tenant']->getTenantOwner()->getDomain(); if ($creator && $creator != $owner) { return $creator; } else { return $owner; } } return $default; }
[ "protected", "function", "getTenantCacheName", "(", "$", "default", ")", "{", "if", "(", "$", "this", "->", "isMultiSiteTenant", "(", ")", ")", "{", "$", "creator", "=", "$", "this", "[", "'auth.tenant'", "]", "->", "getTenantCreator", "(", ")", "->", "g...
@param string $default @return string
[ "@param", "string", "$default" ]
train
https://github.com/dave-redfern/laravel-doctrine-tenancy/blob/3307fc57ad64d5a4dd5dfb235e19b301661255f9/src/Foundation/TenantAwareApplication.php#L84-L98
willemo/flightstats
src/Api/AbstractApi.php
AbstractApi.sendRequest
protected function sendRequest($endpoint, array $queryParams) { return $this->flexClient->sendRequest( $this->getApiName(), $this->getApiVersion(), $endpoint, $queryParams ); }
php
protected function sendRequest($endpoint, array $queryParams) { return $this->flexClient->sendRequest( $this->getApiName(), $this->getApiVersion(), $endpoint, $queryParams ); }
[ "protected", "function", "sendRequest", "(", "$", "endpoint", ",", "array", "$", "queryParams", ")", "{", "return", "$", "this", "->", "flexClient", "->", "sendRequest", "(", "$", "this", "->", "getApiName", "(", ")", ",", "$", "this", "->", "getApiVersion...
Send the request through the FlexClient. @param string $endpoint The endpoint to make the request to @param array $queryParams The query parameters @return array The response from the API
[ "Send", "the", "request", "through", "the", "FlexClient", "." ]
train
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/Api/AbstractApi.php#L50-L58
willemo/flightstats
src/Api/AbstractApi.php
AbstractApi.parseAirlines
protected function parseAirlines(array $airlines) { $parsed = []; foreach ($airlines as $airline) { $parsed[$airline['fs']] = $airline; } return $parsed; }
php
protected function parseAirlines(array $airlines) { $parsed = []; foreach ($airlines as $airline) { $parsed[$airline['fs']] = $airline; } return $parsed; }
[ "protected", "function", "parseAirlines", "(", "array", "$", "airlines", ")", "{", "$", "parsed", "=", "[", "]", ";", "foreach", "(", "$", "airlines", "as", "$", "airline", ")", "{", "$", "parsed", "[", "$", "airline", "[", "'fs'", "]", "]", "=", "...
Parse the airlines array into an associative array with the airline's FS code as the key. @param array $airlines The airlines from the response @return array The associative array of airlines
[ "Parse", "the", "airlines", "array", "into", "an", "associative", "array", "with", "the", "airline", "s", "FS", "code", "as", "the", "key", "." ]
train
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/Api/AbstractApi.php#L67-L76
willemo/flightstats
src/Api/AbstractApi.php
AbstractApi.parseAirports
protected function parseAirports(array $airports) { $parsed = []; foreach ($airports as $airport) { $parsed[$airport['fs']] = $airport; } return $parsed; }
php
protected function parseAirports(array $airports) { $parsed = []; foreach ($airports as $airport) { $parsed[$airport['fs']] = $airport; } return $parsed; }
[ "protected", "function", "parseAirports", "(", "array", "$", "airports", ")", "{", "$", "parsed", "=", "[", "]", ";", "foreach", "(", "$", "airports", "as", "$", "airport", ")", "{", "$", "parsed", "[", "$", "airport", "[", "'fs'", "]", "]", "=", "...
Parse the airports array into an associative array with the airport's FS code as the key. @param array $airports The airports from the response @return array The associative array of airports
[ "Parse", "the", "airports", "array", "into", "an", "associative", "array", "with", "the", "airport", "s", "FS", "code", "as", "the", "key", "." ]
train
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/Api/AbstractApi.php#L85-L94
willemo/flightstats
src/Api/AbstractApi.php
AbstractApi.dateToUtc
protected function dateToUtc( $dateTimeString, $timeZone, $shouldFormat = true ) { $date = new DateTime($dateTimeString, new DateTimeZone($timeZone)); $date->setTimeZone(new DateTimeZone('UTC')); if (!$shouldFormat) { return $date; } return $date->format('c'); }
php
protected function dateToUtc( $dateTimeString, $timeZone, $shouldFormat = true ) { $date = new DateTime($dateTimeString, new DateTimeZone($timeZone)); $date->setTimeZone(new DateTimeZone('UTC')); if (!$shouldFormat) { return $date; } return $date->format('c'); }
[ "protected", "function", "dateToUtc", "(", "$", "dateTimeString", ",", "$", "timeZone", ",", "$", "shouldFormat", "=", "true", ")", "{", "$", "date", "=", "new", "DateTime", "(", "$", "dateTimeString", ",", "new", "DateTimeZone", "(", "$", "timeZone", ")",...
Change a date/time in a local time zone to UTC. @param string $dateTimeString The local date/time as a string @param string $timeZone The local time zone name @param boolean $shouldFormat Should the response be formatted ('c') @return DateTime|string The date/time in UTC
[ "Change", "a", "date", "/", "time", "in", "a", "local", "time", "zone", "to", "UTC", "." ]
train
https://github.com/willemo/flightstats/blob/32ee99110a86a3d418bc15ab7863b89e0ad3a65d/src/Api/AbstractApi.php#L104-L118
txj123/zilf
src/Zilf/Cache/RateLimiter.php
RateLimiter.tooManyAttempts
public function tooManyAttempts($key, $maxAttempts, $decayMinutes = 1) { if ($this->cache->has($key.':lockout')) { return true; } if ($this->attempts($key) >= $maxAttempts) { $this->lockout($key, $decayMinutes); $this->resetAttempts($key); return true; } return false; }
php
public function tooManyAttempts($key, $maxAttempts, $decayMinutes = 1) { if ($this->cache->has($key.':lockout')) { return true; } if ($this->attempts($key) >= $maxAttempts) { $this->lockout($key, $decayMinutes); $this->resetAttempts($key); return true; } return false; }
[ "public", "function", "tooManyAttempts", "(", "$", "key", ",", "$", "maxAttempts", ",", "$", "decayMinutes", "=", "1", ")", "{", "if", "(", "$", "this", "->", "cache", "->", "has", "(", "$", "key", ".", "':lockout'", ")", ")", "{", "return", "true", ...
Determine if the given key has been "accessed" too many times. @param string $key @param int $maxAttempts @param float|int $decayMinutes @return bool
[ "Determine", "if", "the", "given", "key", "has", "been", "accessed", "too", "many", "times", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/RateLimiter.php#L36-L51
txj123/zilf
src/Zilf/Cache/RateLimiter.php
RateLimiter.lockout
protected function lockout($key, $decayMinutes) { $this->cache->add( $key.':lockout', Carbon::now()->getTimestamp() + ($decayMinutes * 60), $decayMinutes ); }
php
protected function lockout($key, $decayMinutes) { $this->cache->add( $key.':lockout', Carbon::now()->getTimestamp() + ($decayMinutes * 60), $decayMinutes ); }
[ "protected", "function", "lockout", "(", "$", "key", ",", "$", "decayMinutes", ")", "{", "$", "this", "->", "cache", "->", "add", "(", "$", "key", ".", "':lockout'", ",", "Carbon", "::", "now", "(", ")", "->", "getTimestamp", "(", ")", "+", "(", "$...
Add the lockout key to the cache. @param string $key @param int $decayMinutes @return void
[ "Add", "the", "lockout", "key", "to", "the", "cache", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/RateLimiter.php#L60-L65
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Size.php
Zend_Validate_File_Size.getMin
public function getMin($unit = true) { $unit = (bool) $unit; $min = $this->_min; if ($unit) { $min = $this->_toByteString($min); } return $min; }
php
public function getMin($unit = true) { $unit = (bool) $unit; $min = $this->_min; if ($unit) { $min = $this->_toByteString($min); } return $min; }
[ "public", "function", "getMin", "(", "$", "unit", "=", "true", ")", "{", "$", "unit", "=", "(", "bool", ")", "$", "unit", ";", "$", "min", "=", "$", "this", "->", "_min", ";", "if", "(", "$", "unit", ")", "{", "$", "min", "=", "$", "this", ...
Returns the minimum filesize @param boolean $unit Return the value with unit, when false the plan bytes will be returned @return integer
[ "Returns", "the", "minimum", "filesize" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Size.php#L130-L138
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Size.php
Zend_Validate_File_Size.getMax
public function getMax($unit = true) { $unit = (bool) $unit; $max = $this->_max; if ($unit) { $max = $this->_toByteString($max); } return $max; }
php
public function getMax($unit = true) { $unit = (bool) $unit; $max = $this->_max; if ($unit) { $max = $this->_toByteString($max); } return $max; }
[ "public", "function", "getMax", "(", "$", "unit", "=", "true", ")", "{", "$", "unit", "=", "(", "bool", ")", "$", "unit", ";", "$", "max", "=", "$", "this", "->", "_max", ";", "if", "(", "$", "unit", ")", "{", "$", "max", "=", "$", "this", ...
Returns the maximum filesize @param boolean $unit Return the value with unit, when false the plan bytes will be returned @return integer|null
[ "Returns", "the", "maximum", "filesize" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Size.php#L168-L176
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Size.php
Zend_Validate_File_Size.isValid
public function isValid($value, $file = null) { // Is file readable ? if (!@is_readable($value)) { $this->_throw($file, self::NOT_FOUND); return false; } // limited to 4GB files $size = sprintf("%u", @filesize($value)); $this->_setValue($size); // Check to see if it's smaller than min size if (($this->_min !== null) && ($size < $this->_min)) { $this->_throw($file, self::TOO_SMALL); } // Check to see if it's larger than max size if (($this->_max !== null) && ($this->_max < $size)) { $this->_throw($file, self::TOO_BIG); } if (count($this->_messages) > 0) { return false; } else { return true; } }
php
public function isValid($value, $file = null) { // Is file readable ? if (!@is_readable($value)) { $this->_throw($file, self::NOT_FOUND); return false; } // limited to 4GB files $size = sprintf("%u", @filesize($value)); $this->_setValue($size); // Check to see if it's smaller than min size if (($this->_min !== null) && ($size < $this->_min)) { $this->_throw($file, self::TOO_SMALL); } // Check to see if it's larger than max size if (($this->_max !== null) && ($this->_max < $size)) { $this->_throw($file, self::TOO_BIG); } if (count($this->_messages) > 0) { return false; } else { return true; } }
[ "public", "function", "isValid", "(", "$", "value", ",", "$", "file", "=", "null", ")", "{", "// Is file readable ?", "if", "(", "!", "@", "is_readable", "(", "$", "value", ")", ")", "{", "$", "this", "->", "_throw", "(", "$", "file", ",", "self", ...
Defined by Zend_Validate_Interface Returns true if and only if the filesize of $value is at least min and not bigger than max (when max is not null). @param string $value Real file to check for size @param array $file File data from Zend_File_Transfer @return boolean
[ "Defined", "by", "Zend_Validate_Interface" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/Size.php#L211-L238
krafthaus/bauhaus
src/KraftHaus/Bauhaus/Field/LabelField.php
LabelField.getState
public function getState($state = null) { if ($state === null) { $state = $this->getValue(); } if (!isset($this->states[$state])) { return 'default'; } return $this->states[$state]; }
php
public function getState($state = null) { if ($state === null) { $state = $this->getValue(); } if (!isset($this->states[$state])) { return 'default'; } return $this->states[$state]; }
[ "public", "function", "getState", "(", "$", "state", "=", "null", ")", "{", "if", "(", "$", "state", "===", "null", ")", "{", "$", "state", "=", "$", "this", "->", "getValue", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "this", "->",...
Get the current or a specific state. @param string null $state @access public @return string
[ "Get", "the", "current", "or", "a", "specific", "state", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/KraftHaus/Bauhaus/Field/LabelField.php#L69-L80
txj123/zilf
src/Zilf/Queue/FailingJob.php
FailingJob.handle
public static function handle($connectionName, $job, $e = null) { $job->markAsFailed(); if ($job->isDeleted()) { return; } try { // If the job has failed, we will delete it, call the "failed" method and then call // an event indicating the job has failed so it can be logged if needed. This is // to allow every developer to better keep monitor of their failed queue jobs. $job->delete(); $job->failed($e); } finally { } }
php
public static function handle($connectionName, $job, $e = null) { $job->markAsFailed(); if ($job->isDeleted()) { return; } try { // If the job has failed, we will delete it, call the "failed" method and then call // an event indicating the job has failed so it can be logged if needed. This is // to allow every developer to better keep monitor of their failed queue jobs. $job->delete(); $job->failed($e); } finally { } }
[ "public", "static", "function", "handle", "(", "$", "connectionName", ",", "$", "job", ",", "$", "e", "=", "null", ")", "{", "$", "job", "->", "markAsFailed", "(", ")", ";", "if", "(", "$", "job", "->", "isDeleted", "(", ")", ")", "{", "return", ...
Delete the job, call the "failed" method, and raise the failed job event. @param string $connectionName @param \Illuminate\Queue\Jobs\Job $job @param \Exception $e @return void
[ "Delete", "the", "job", "call", "the", "failed", "method", "and", "raise", "the", "failed", "job", "event", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Queue/FailingJob.php#L20-L38
txj123/zilf
src/Zilf/Console/Command.php
Command.run
public function run(InputInterface $input, OutputInterface $output) { return parent::run( $this->input = $input, $this->output = new OutputStyle($input, $output) ); }
php
public function run(InputInterface $input, OutputInterface $output) { return parent::run( $this->input = $input, $this->output = new OutputStyle($input, $output) ); }
[ "public", "function", "run", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "return", "parent", "::", "run", "(", "$", "this", "->", "input", "=", "$", "input", ",", "$", "this", "->", "output", "=", "new", "Outpu...
Run the console command. @param \Symfony\Component\Console\Input\InputInterface $input @param \Symfony\Component\Console\Output\OutputInterface $output @return int
[ "Run", "the", "console", "command", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Console/Command.php#L158-L163
txj123/zilf
src/Zilf/Console/Command.php
Command.createInputFromArguments
protected function createInputFromArguments(array $arguments) { return tap( new ArrayInput($arguments), function ($input) { if ($input->hasParameterOption(['--no-interaction'], true)) { $input->setInteractive(false); } } ); }
php
protected function createInputFromArguments(array $arguments) { return tap( new ArrayInput($arguments), function ($input) { if ($input->hasParameterOption(['--no-interaction'], true)) { $input->setInteractive(false); } } ); }
[ "protected", "function", "createInputFromArguments", "(", "array", "$", "arguments", ")", "{", "return", "tap", "(", "new", "ArrayInput", "(", "$", "arguments", ")", ",", "function", "(", "$", "input", ")", "{", "if", "(", "$", "input", "->", "hasParameter...
Create an input instance from the given arguments. @param array $arguments @return \Symfony\Component\Console\Input\ArrayInput
[ "Create", "an", "input", "instance", "from", "the", "given", "arguments", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Console/Command.php#L215-L224
txj123/zilf
src/Zilf/Validation/Factory.php
Factory.addExtensions
protected function addExtensions(Validator $validator) { $validator->addExtensions($this->extensions); // Next, we will add the implicit extensions, which are similar to the required // and accepted rule in that they are run even if the attributes is not in a // array of data that is given to a validator instances via instantiation. $implicit = $this->implicitExtensions; $validator->addImplicitExtensions($implicit); $validator->addReplacers($this->replacers); $validator->setFallbackMessages($this->fallbackMessages); }
php
protected function addExtensions(Validator $validator) { $validator->addExtensions($this->extensions); // Next, we will add the implicit extensions, which are similar to the required // and accepted rule in that they are run even if the attributes is not in a // array of data that is given to a validator instances via instantiation. $implicit = $this->implicitExtensions; $validator->addImplicitExtensions($implicit); $validator->addReplacers($this->replacers); $validator->setFallbackMessages($this->fallbackMessages); }
[ "protected", "function", "addExtensions", "(", "Validator", "$", "validator", ")", "{", "$", "validator", "->", "addExtensions", "(", "$", "this", "->", "extensions", ")", ";", "// Next, we will add the implicit extensions, which are similar to the required", "// and accept...
Add the extensions to a validator instance. @param \Zilf\Validation\Validator $validator
[ "Add", "the", "extensions", "to", "a", "validator", "instance", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Factory.php#L110-L124
txj123/zilf
src/Zilf/Validation/Factory.php
Factory.resolve
protected function resolve(array $data, array $rules, array $messages, array $customAttributes) { if (is_null($this->resolver)) { return new Validator($this->translator, $data, $rules, $messages, $customAttributes); } else { return call_user_func($this->resolver, $this->translator, $data, $rules, $messages, $customAttributes); } }
php
protected function resolve(array $data, array $rules, array $messages, array $customAttributes) { if (is_null($this->resolver)) { return new Validator($this->translator, $data, $rules, $messages, $customAttributes); } else { return call_user_func($this->resolver, $this->translator, $data, $rules, $messages, $customAttributes); } }
[ "protected", "function", "resolve", "(", "array", "$", "data", ",", "array", "$", "rules", ",", "array", "$", "messages", ",", "array", "$", "customAttributes", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "resolver", ")", ")", "{", "return"...
Resolve a new Validator instance. @param array $data @param array $rules @param array $messages @param array $customAttributes @return \Zilf\Validation\Validator
[ "Resolve", "a", "new", "Validator", "instance", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Validation/Factory.php#L136-L143
txj123/zilf
src/Zilf/Redis/Connections/PhpRedisConnection.php
PhpRedisConnection.get
public function get($key) { $result = $this->client->get($key); return $result !== false ? $result : null; }
php
public function get($key) { $result = $this->client->get($key); return $result !== false ? $result : null; }
[ "public", "function", "get", "(", "$", "key", ")", "{", "$", "result", "=", "$", "this", "->", "client", "->", "get", "(", "$", "key", ")", ";", "return", "$", "result", "!==", "false", "?", "$", "result", ":", "null", ";", "}" ]
Returns the value of the given key. @param string $key @return string|null
[ "Returns", "the", "value", "of", "the", "given", "key", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Redis/Connections/PhpRedisConnection.php#L26-L31
txj123/zilf
src/Zilf/Redis/Connections/PhpRedisConnection.php
PhpRedisConnection.mget
public function mget(array $keys) { return array_map( function ($value) { return $value !== false ? $value : null; }, $this->client->mget($keys) ); }
php
public function mget(array $keys) { return array_map( function ($value) { return $value !== false ? $value : null; }, $this->client->mget($keys) ); }
[ "public", "function", "mget", "(", "array", "$", "keys", ")", "{", "return", "array_map", "(", "function", "(", "$", "value", ")", "{", "return", "$", "value", "!==", "false", "?", "$", "value", ":", "null", ";", "}", ",", "$", "this", "->", "clien...
Get the values of all the given keys. @param array $keys @return array
[ "Get", "the", "values", "of", "all", "the", "given", "keys", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Redis/Connections/PhpRedisConnection.php#L39-L46
txj123/zilf
src/Zilf/Redis/Connections/PhpRedisConnection.php
PhpRedisConnection.set
public function set($key, $value, $expireResolution = null, $expireTTL = null, $flag = null) { return $this->command( 'set', [ $key, $value, $expireResolution ? [$expireResolution, $flag => $expireTTL] : null, ] ); }
php
public function set($key, $value, $expireResolution = null, $expireTTL = null, $flag = null) { return $this->command( 'set', [ $key, $value, $expireResolution ? [$expireResolution, $flag => $expireTTL] : null, ] ); }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "expireResolution", "=", "null", ",", "$", "expireTTL", "=", "null", ",", "$", "flag", "=", "null", ")", "{", "return", "$", "this", "->", "command", "(", "'set'", ",", "[",...
Set the string value in argument as value of the key. @param string $key @param mixed $value @param string|null $expireResolution @param int|null $expireTTL @param string|null $flag @return bool
[ "Set", "the", "string", "value", "in", "argument", "as", "value", "of", "the", "key", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Redis/Connections/PhpRedisConnection.php#L58-L67
txj123/zilf
src/Zilf/Redis/Connections/PhpRedisConnection.php
PhpRedisConnection.zadd
public function zadd($key, ...$dictionary) { if (count($dictionary) === 1) { $_dictionary = []; foreach ($dictionary[0] as $member => $score) { $_dictionary[] = $score; $_dictionary[] = $member; } $dictionary = $_dictionary; } return $this->client->zadd($key, ...$dictionary); }
php
public function zadd($key, ...$dictionary) { if (count($dictionary) === 1) { $_dictionary = []; foreach ($dictionary[0] as $member => $score) { $_dictionary[] = $score; $_dictionary[] = $member; } $dictionary = $_dictionary; } return $this->client->zadd($key, ...$dictionary); }
[ "public", "function", "zadd", "(", "$", "key", ",", "...", "$", "dictionary", ")", "{", "if", "(", "count", "(", "$", "dictionary", ")", "===", "1", ")", "{", "$", "_dictionary", "=", "[", "]", ";", "foreach", "(", "$", "dictionary", "[", "0", "]...
Add one or more members to a sorted set or update its score if it already exists. @param string $key @param mixed $dictionary @return int
[ "Add", "one", "or", "more", "members", "to", "a", "sorted", "set", "or", "update", "its", "score", "if", "it", "already", "exists", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Redis/Connections/PhpRedisConnection.php#L101-L115
txj123/zilf
src/Zilf/Redis/Connections/PhpRedisConnection.php
PhpRedisConnection.proxyToEval
protected function proxyToEval(array $parameters) { return $this->command( 'eval', [ isset($parameters[0]) ? $parameters[0] : null, array_slice($parameters, 2), isset($parameters[1]) ? $parameters[1] : null, ] ); }
php
protected function proxyToEval(array $parameters) { return $this->command( 'eval', [ isset($parameters[0]) ? $parameters[0] : null, array_slice($parameters, 2), isset($parameters[1]) ? $parameters[1] : null, ] ); }
[ "protected", "function", "proxyToEval", "(", "array", "$", "parameters", ")", "{", "return", "$", "this", "->", "command", "(", "'eval'", ",", "[", "isset", "(", "$", "parameters", "[", "0", "]", ")", "?", "$", "parameters", "[", "0", "]", ":", "null...
Proxy a call to the eval function of PhpRedis. @param array $parameters @return mixed
[ "Proxy", "a", "call", "to", "the", "eval", "function", "of", "PhpRedis", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Redis/Connections/PhpRedisConnection.php#L170-L179
txj123/zilf
src/Zilf/Filesystem/Filesystem.php
Filesystem.mkdir
public function mkdir($dirs, $mode = 0777) { foreach ($this->toIterator($dirs) as $dir) { if (is_dir($dir)) { continue; } if (true !== @mkdir($dir, $mode, true)) { $error = error_get_last(); if (!is_dir($dir)) { // The directory was not created by a concurrent process. Let's throw an exception with a developer friendly error message if we have one if ($error) { throw new IOException(sprintf('Failed to create "%s": %s.', $dir, $error['message']), 0, null, $dir); } throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir); } } } }
php
public function mkdir($dirs, $mode = 0777) { foreach ($this->toIterator($dirs) as $dir) { if (is_dir($dir)) { continue; } if (true !== @mkdir($dir, $mode, true)) { $error = error_get_last(); if (!is_dir($dir)) { // The directory was not created by a concurrent process. Let's throw an exception with a developer friendly error message if we have one if ($error) { throw new IOException(sprintf('Failed to create "%s": %s.', $dir, $error['message']), 0, null, $dir); } throw new IOException(sprintf('Failed to create "%s"', $dir), 0, null, $dir); } } } }
[ "public", "function", "mkdir", "(", "$", "dirs", ",", "$", "mode", "=", "0777", ")", "{", "foreach", "(", "$", "this", "->", "toIterator", "(", "$", "dirs", ")", "as", "$", "dir", ")", "{", "if", "(", "is_dir", "(", "$", "dir", ")", ")", "{", ...
Creates a directory recursively. @param string|array|\Traversable $dirs The directory path @param int $mode The directory mode @throws IOException On any directory creation failure
[ "Creates", "a", "directory", "recursively", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Filesystem/Filesystem.php#L90-L108
txj123/zilf
src/Zilf/Filesystem/Filesystem.php
Filesystem.exists
public function exists($files) { foreach ($this->toIterator($files) as $file) { if ('\\' === DIRECTORY_SEPARATOR && strlen($file) > 258) { throw new IOException('Could not check if file exist because path length exceeds 258 characters.', 0, null, $file); } if (!file_exists($file)) { return false; } } return true; }
php
public function exists($files) { foreach ($this->toIterator($files) as $file) { if ('\\' === DIRECTORY_SEPARATOR && strlen($file) > 258) { throw new IOException('Could not check if file exist because path length exceeds 258 characters.', 0, null, $file); } if (!file_exists($file)) { return false; } } return true; }
[ "public", "function", "exists", "(", "$", "files", ")", "{", "foreach", "(", "$", "this", "->", "toIterator", "(", "$", "files", ")", "as", "$", "file", ")", "{", "if", "(", "'\\\\'", "===", "DIRECTORY_SEPARATOR", "&&", "strlen", "(", "$", "file", ")...
Checks the existence of files or directories. @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to check @return bool true if the file exists, false otherwise
[ "Checks", "the", "existence", "of", "files", "or", "directories", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Filesystem/Filesystem.php#L117-L130
txj123/zilf
src/Zilf/Filesystem/Filesystem.php
Filesystem.remove
public function remove($files) { if ($files instanceof \Traversable) { $files = iterator_to_array($files, false); } elseif (!is_array($files)) { $files = array($files); } $files = array_reverse($files); foreach ($files as $file) { if (is_link($file)) { // See https://bugs.php.net/52176 if (!@(unlink($file) || '\\' !== DIRECTORY_SEPARATOR || rmdir($file)) && file_exists($file)) { $error = error_get_last(); throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, $error['message'])); } } elseif (is_dir($file)) { $this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS)); if (!@rmdir($file) && file_exists($file)) { $error = error_get_last(); throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, $error['message'])); } } elseif (!@unlink($file) && file_exists($file)) { $error = error_get_last(); throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, $error['message'])); } } }
php
public function remove($files) { if ($files instanceof \Traversable) { $files = iterator_to_array($files, false); } elseif (!is_array($files)) { $files = array($files); } $files = array_reverse($files); foreach ($files as $file) { if (is_link($file)) { // See https://bugs.php.net/52176 if (!@(unlink($file) || '\\' !== DIRECTORY_SEPARATOR || rmdir($file)) && file_exists($file)) { $error = error_get_last(); throw new IOException(sprintf('Failed to remove symlink "%s": %s.', $file, $error['message'])); } } elseif (is_dir($file)) { $this->remove(new \FilesystemIterator($file, \FilesystemIterator::CURRENT_AS_PATHNAME | \FilesystemIterator::SKIP_DOTS)); if (!@rmdir($file) && file_exists($file)) { $error = error_get_last(); throw new IOException(sprintf('Failed to remove directory "%s": %s.', $file, $error['message'])); } } elseif (!@unlink($file) && file_exists($file)) { $error = error_get_last(); throw new IOException(sprintf('Failed to remove file "%s": %s.', $file, $error['message'])); } } }
[ "public", "function", "remove", "(", "$", "files", ")", "{", "if", "(", "$", "files", "instanceof", "\\", "Traversable", ")", "{", "$", "files", "=", "iterator_to_array", "(", "$", "files", ",", "false", ")", ";", "}", "elseif", "(", "!", "is_array", ...
Removes files or directories. @param string|array|\Traversable $files A filename, an array of files, or a \Traversable instance to remove @throws IOException When removal fails
[ "Removes", "files", "or", "directories", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Filesystem/Filesystem.php#L158-L185
txj123/zilf
src/Zilf/Filesystem/Filesystem.php
Filesystem.isReadable
private function isReadable($filename) { if ('\\' === DIRECTORY_SEPARATOR && strlen($filename) > 258) { throw new IOException('Could not check if file is readable because path length exceeds 258 characters.', 0, null, $filename); } return is_readable($filename); }
php
private function isReadable($filename) { if ('\\' === DIRECTORY_SEPARATOR && strlen($filename) > 258) { throw new IOException('Could not check if file is readable because path length exceeds 258 characters.', 0, null, $filename); } return is_readable($filename); }
[ "private", "function", "isReadable", "(", "$", "filename", ")", "{", "if", "(", "'\\\\'", "===", "DIRECTORY_SEPARATOR", "&&", "strlen", "(", "$", "filename", ")", ">", "258", ")", "{", "throw", "new", "IOException", "(", "'Could not check if file is readable bec...
Tells whether a file exists and is readable. @param string $filename Path to the file @return bool @throws IOException When windows path is longer than 258 characters
[ "Tells", "whether", "a", "file", "exists", "and", "is", "readable", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Filesystem/Filesystem.php#L294-L301
txj123/zilf
src/Zilf/Filesystem/Filesystem.php
Filesystem.symlink
public function symlink($originDir, $targetDir, $copyOnWindows = false) { if ('\\' === DIRECTORY_SEPARATOR) { $originDir = strtr($originDir, '/', '\\'); $targetDir = strtr($targetDir, '/', '\\'); if ($copyOnWindows) { $this->mirror($originDir, $targetDir); return; } } $this->mkdir(dirname($targetDir)); $ok = false; if (is_link($targetDir)) { if (readlink($targetDir) != $originDir) { $this->remove($targetDir); } else { $ok = true; } } if (!$ok && true !== @symlink($originDir, $targetDir)) { $this->linkException($originDir, $targetDir, 'symbolic'); } }
php
public function symlink($originDir, $targetDir, $copyOnWindows = false) { if ('\\' === DIRECTORY_SEPARATOR) { $originDir = strtr($originDir, '/', '\\'); $targetDir = strtr($targetDir, '/', '\\'); if ($copyOnWindows) { $this->mirror($originDir, $targetDir); return; } } $this->mkdir(dirname($targetDir)); $ok = false; if (is_link($targetDir)) { if (readlink($targetDir) != $originDir) { $this->remove($targetDir); } else { $ok = true; } } if (!$ok && true !== @symlink($originDir, $targetDir)) { $this->linkException($originDir, $targetDir, 'symbolic'); } }
[ "public", "function", "symlink", "(", "$", "originDir", ",", "$", "targetDir", ",", "$", "copyOnWindows", "=", "false", ")", "{", "if", "(", "'\\\\'", "===", "DIRECTORY_SEPARATOR", ")", "{", "$", "originDir", "=", "strtr", "(", "$", "originDir", ",", "'/...
Creates a symbolic link or copy a directory. @param string $originDir The origin directory path @param string $targetDir The symbolic link name @param bool $copyOnWindows Whether to copy files if on Windows @throws IOException When symlink fails
[ "Creates", "a", "symbolic", "link", "or", "copy", "a", "directory", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Filesystem/Filesystem.php#L312-L339
txj123/zilf
src/Zilf/Filesystem/Filesystem.php
Filesystem.hardlink
public function hardlink($originFile, $targetFiles) { if (!$this->exists($originFile)) { throw new FileNotFoundException(null, 0, null, $originFile); } if (!is_file($originFile)) { throw new FileNotFoundException(sprintf('Origin file "%s" is not a file', $originFile)); } foreach ($this->toIterator($targetFiles) as $targetFile) { if (is_file($targetFile)) { if (fileinode($originFile) === fileinode($targetFile)) { continue; } $this->remove($targetFile); } if (true !== @link($originFile, $targetFile)) { $this->linkException($originFile, $targetFile, 'hard'); } } }
php
public function hardlink($originFile, $targetFiles) { if (!$this->exists($originFile)) { throw new FileNotFoundException(null, 0, null, $originFile); } if (!is_file($originFile)) { throw new FileNotFoundException(sprintf('Origin file "%s" is not a file', $originFile)); } foreach ($this->toIterator($targetFiles) as $targetFile) { if (is_file($targetFile)) { if (fileinode($originFile) === fileinode($targetFile)) { continue; } $this->remove($targetFile); } if (true !== @link($originFile, $targetFile)) { $this->linkException($originFile, $targetFile, 'hard'); } } }
[ "public", "function", "hardlink", "(", "$", "originFile", ",", "$", "targetFiles", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", "$", "originFile", ")", ")", "{", "throw", "new", "FileNotFoundException", "(", "null", ",", "0", ",", "null"...
Creates a hard link, or several hard links to a file. @param string $originFile The original file @param string|string[] $targetFiles The target file(s) @throws FileNotFoundException When original file is missing or not a file @throws IOException When link fails, including if link already exists
[ "Creates", "a", "hard", "link", "or", "several", "hard", "links", "to", "a", "file", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Filesystem/Filesystem.php#L350-L372
txj123/zilf
src/Zilf/Filesystem/Filesystem.php
Filesystem.makePathRelative
public function makePathRelative($endPath, $startPath) { // Normalize separators on Windows if ('\\' === DIRECTORY_SEPARATOR) { $endPath = str_replace('\\', '/', $endPath); $startPath = str_replace('\\', '/', $startPath); } // Split the paths into arrays $startPathArr = explode('/', trim($startPath, '/')); $endPathArr = explode('/', trim($endPath, '/')); if ('/' !== $startPath[0]) { array_shift($startPathArr); } if ('/' !== $endPath[0]) { array_shift($endPathArr); } $normalizePathArray = function ($pathSegments) { $result = array(); foreach ($pathSegments as $segment) { if ('..' === $segment) { array_pop($result); } else { $result[] = $segment; } } return $result; }; $startPathArr = $normalizePathArray($startPathArr); $endPathArr = $normalizePathArray($endPathArr); // Find for which directory the common path stops $index = 0; while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) { ++$index; } // Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels) if (count($startPathArr) === 1 && $startPathArr[0] === '') { $depth = 0; } else { $depth = count($startPathArr) - $index; } // When we need to traverse from the start, and we are starting from a root path, don't add '../' if ('/' === $startPath[0] && 0 === $index && 0 === $depth) { $traverser = ''; } else { // Repeated "../" for each level need to reach the common path $traverser = str_repeat('../', $depth); } $endPathRemainder = implode('/', array_slice($endPathArr, $index)); // Construct $endPath from traversing to the common path, then to the remaining $endPath $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : ''); return '' === $relativePath ? './' : $relativePath; }
php
public function makePathRelative($endPath, $startPath) { // Normalize separators on Windows if ('\\' === DIRECTORY_SEPARATOR) { $endPath = str_replace('\\', '/', $endPath); $startPath = str_replace('\\', '/', $startPath); } // Split the paths into arrays $startPathArr = explode('/', trim($startPath, '/')); $endPathArr = explode('/', trim($endPath, '/')); if ('/' !== $startPath[0]) { array_shift($startPathArr); } if ('/' !== $endPath[0]) { array_shift($endPathArr); } $normalizePathArray = function ($pathSegments) { $result = array(); foreach ($pathSegments as $segment) { if ('..' === $segment) { array_pop($result); } else { $result[] = $segment; } } return $result; }; $startPathArr = $normalizePathArray($startPathArr); $endPathArr = $normalizePathArray($endPathArr); // Find for which directory the common path stops $index = 0; while (isset($startPathArr[$index]) && isset($endPathArr[$index]) && $startPathArr[$index] === $endPathArr[$index]) { ++$index; } // Determine how deep the start path is relative to the common path (ie, "web/bundles" = 2 levels) if (count($startPathArr) === 1 && $startPathArr[0] === '') { $depth = 0; } else { $depth = count($startPathArr) - $index; } // When we need to traverse from the start, and we are starting from a root path, don't add '../' if ('/' === $startPath[0] && 0 === $index && 0 === $depth) { $traverser = ''; } else { // Repeated "../" for each level need to reach the common path $traverser = str_repeat('../', $depth); } $endPathRemainder = implode('/', array_slice($endPathArr, $index)); // Construct $endPath from traversing to the common path, then to the remaining $endPath $relativePath = $traverser.('' !== $endPathRemainder ? $endPathRemainder.'/' : ''); return '' === $relativePath ? './' : $relativePath; }
[ "public", "function", "makePathRelative", "(", "$", "endPath", ",", "$", "startPath", ")", "{", "// Normalize separators on Windows", "if", "(", "'\\\\'", "===", "DIRECTORY_SEPARATOR", ")", "{", "$", "endPath", "=", "str_replace", "(", "'\\\\'", ",", "'/'", ",",...
Given an existing path, convert it to a path relative to a given starting path. @param string $endPath Absolute path of target @param string $startPath Absolute path where traversal begins @return string Path of target relative to starting path
[ "Given", "an", "existing", "path", "convert", "it", "to", "a", "path", "relative", "to", "a", "given", "starting", "path", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Filesystem/Filesystem.php#L439-L503
txj123/zilf
src/Zilf/Filesystem/Filesystem.php
Filesystem.dumpFile
public function dumpFile($filename, $content) { $dir = dirname($filename); if (!is_dir($dir)) { $this->mkdir($dir); } if (!is_writable($dir)) { throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir); } // Will create a temp file with 0600 access rights // when the filesystem supports chmod. $tmpFile = $this->tempnam($dir, basename($filename)); if (false === @file_put_contents($tmpFile, $content)) { throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename); } @chmod($tmpFile, file_exists($filename) ? fileperms($filename) : 0666 & ~umask()); $this->rename($tmpFile, $filename, true); }
php
public function dumpFile($filename, $content) { $dir = dirname($filename); if (!is_dir($dir)) { $this->mkdir($dir); } if (!is_writable($dir)) { throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir); } // Will create a temp file with 0600 access rights // when the filesystem supports chmod. $tmpFile = $this->tempnam($dir, basename($filename)); if (false === @file_put_contents($tmpFile, $content)) { throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename); } @chmod($tmpFile, file_exists($filename) ? fileperms($filename) : 0666 & ~umask()); $this->rename($tmpFile, $filename, true); }
[ "public", "function", "dumpFile", "(", "$", "filename", ",", "$", "content", ")", "{", "$", "dir", "=", "dirname", "(", "$", "filename", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "$", "this", "->", "mkdir", "(", "$", "...
Atomically dumps content into a file. @param string $filename The file to be written to @param string $content The data to write into the file @throws IOException If the file cannot be written to
[ "Atomically", "dumps", "content", "into", "a", "file", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Filesystem/Filesystem.php#L655-L678
txj123/zilf
src/Zilf/Filesystem/Filesystem.php
Filesystem.appendToFile
public function appendToFile($filename, $content) { $dir = dirname($filename); if (!is_dir($dir)) { $this->mkdir($dir); } if (!is_writable($dir)) { throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir); } if (false === @file_put_contents($filename, $content, FILE_APPEND)) { throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename); } }
php
public function appendToFile($filename, $content) { $dir = dirname($filename); if (!is_dir($dir)) { $this->mkdir($dir); } if (!is_writable($dir)) { throw new IOException(sprintf('Unable to write to the "%s" directory.', $dir), 0, null, $dir); } if (false === @file_put_contents($filename, $content, FILE_APPEND)) { throw new IOException(sprintf('Failed to write file "%s".', $filename), 0, null, $filename); } }
[ "public", "function", "appendToFile", "(", "$", "filename", ",", "$", "content", ")", "{", "$", "dir", "=", "dirname", "(", "$", "filename", ")", ";", "if", "(", "!", "is_dir", "(", "$", "dir", ")", ")", "{", "$", "this", "->", "mkdir", "(", "$",...
Appends content to an existing file. @param string $filename The file to which to append content @param string $content The content to append @throws IOException If the file is not writable
[ "Appends", "content", "to", "an", "existing", "file", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Filesystem/Filesystem.php#L688-L703
txj123/zilf
src/Zilf/Filesystem/Filesystem.php
Filesystem.allFiles
public function allFiles($directory, $hidden = false) { return iterator_to_array(Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory), false); }
php
public function allFiles($directory, $hidden = false) { return iterator_to_array(Finder::create()->files()->ignoreDotFiles(! $hidden)->in($directory), false); }
[ "public", "function", "allFiles", "(", "$", "directory", ",", "$", "hidden", "=", "false", ")", "{", "return", "iterator_to_array", "(", "Finder", "::", "create", "(", ")", "->", "files", "(", ")", "->", "ignoreDotFiles", "(", "!", "$", "hidden", ")", ...
Get all of the files from the given directory (recursive). @param string $directory @param bool $hidden @return array
[ "Get", "all", "of", "the", "files", "from", "the", "given", "directory", "(", "recursive", ")", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Filesystem/Filesystem.php#L1052-L1055
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/NotExists.php
Zend_Validate_File_NotExists.isValid
public function isValid($value, $file = null) { $directories = $this->getDirectory(true); if (($file !== null) and (!empty($file['destination']))) { $directories[] = $file['destination']; } else if (!isset($file['name'])) { $file['name'] = $value; } foreach ($directories as $directory) { if (empty($directory)) { continue; } $check = true; if (file_exists($directory . DIRECTORY_SEPARATOR . $file['name'])) { $this->_throw($file, self::DOES_EXIST); return false; } } if (!isset($check)) { $this->_throw($file, self::DOES_EXIST); return false; } return true; }
php
public function isValid($value, $file = null) { $directories = $this->getDirectory(true); if (($file !== null) and (!empty($file['destination']))) { $directories[] = $file['destination']; } else if (!isset($file['name'])) { $file['name'] = $value; } foreach ($directories as $directory) { if (empty($directory)) { continue; } $check = true; if (file_exists($directory . DIRECTORY_SEPARATOR . $file['name'])) { $this->_throw($file, self::DOES_EXIST); return false; } } if (!isset($check)) { $this->_throw($file, self::DOES_EXIST); return false; } return true; }
[ "public", "function", "isValid", "(", "$", "value", ",", "$", "file", "=", "null", ")", "{", "$", "directories", "=", "$", "this", "->", "getDirectory", "(", "true", ")", ";", "if", "(", "(", "$", "file", "!==", "null", ")", "and", "(", "!", "emp...
Defined by Zend_Validate_Interface Returns true if and only if the file does not exist in the set destinations @param string $value Real file to check for @param array $file File data from Zend_File_Transfer @return boolean
[ "Defined", "by", "Zend_Validate_Interface" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Validate/File/NotExists.php#L58-L85
txj123/zilf
src/Zilf/Facades/Facade.php
Facade.resolveFacadeInstance
protected static function resolveFacadeInstance($name) { if (is_object($name)) { return $name; } if (isset(static::$resolvedInstance[$name])) { return static::$resolvedInstance[$name]; } return static::$resolvedInstance[$name] = Zilf::$container->getShare($name); }
php
protected static function resolveFacadeInstance($name) { if (is_object($name)) { return $name; } if (isset(static::$resolvedInstance[$name])) { return static::$resolvedInstance[$name]; } return static::$resolvedInstance[$name] = Zilf::$container->getShare($name); }
[ "protected", "static", "function", "resolveFacadeInstance", "(", "$", "name", ")", "{", "if", "(", "is_object", "(", "$", "name", ")", ")", "{", "return", "$", "name", ";", "}", "if", "(", "isset", "(", "static", "::", "$", "resolvedInstance", "[", "$"...
Resolve the facade root instance from the container. @param string|object $name @return mixed
[ "Resolve", "the", "facade", "root", "instance", "from", "the", "container", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Facades/Facade.php#L51-L62
txj123/zilf
src/Zilf/Cache/CacheServiceProvider.php
CacheServiceProvider.register
public function register() { Zilf::$container->register( 'cache', function () { return new CacheManager(); } ); Zilf::$container->register( 'cache.store', function ($app) { return Zilf::$container->getShare('cache')->driver(); } ); Zilf::$container->register( 'memcached.connector', function () { return new MemcachedConnector; } ); }
php
public function register() { Zilf::$container->register( 'cache', function () { return new CacheManager(); } ); Zilf::$container->register( 'cache.store', function ($app) { return Zilf::$container->getShare('cache')->driver(); } ); Zilf::$container->register( 'memcached.connector', function () { return new MemcachedConnector; } ); }
[ "public", "function", "register", "(", ")", "{", "Zilf", "::", "$", "container", "->", "register", "(", "'cache'", ",", "function", "(", ")", "{", "return", "new", "CacheManager", "(", ")", ";", "}", ")", ";", "Zilf", "::", "$", "container", "->", "r...
Register the service provider. @return void
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Cache/CacheServiceProvider.php#L22-L41
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php
Zend_Http_Response.getBody
public function getBody() { $body = ''; // Decode the body if it was transfer-encoded switch ($this->getHeader('transfer-encoding')) { // Handle chunked body case 'chunked': $body = self::decodeChunkedBody($this->body); break; // No transfer encoding, or unknown encoding extension: // return body as is default: $body = $this->body; break; } // Decode any content-encoding (gzip or deflate) if needed switch (strtolower($this->getHeader('content-encoding'))) { // Handle gzip encoding case 'gzip': $body = self::decodeGzip($body); break; // Handle deflate encoding case 'deflate': $body = self::decodeDeflate($body); break; default: break; } return $body; }
php
public function getBody() { $body = ''; // Decode the body if it was transfer-encoded switch ($this->getHeader('transfer-encoding')) { // Handle chunked body case 'chunked': $body = self::decodeChunkedBody($this->body); break; // No transfer encoding, or unknown encoding extension: // return body as is default: $body = $this->body; break; } // Decode any content-encoding (gzip or deflate) if needed switch (strtolower($this->getHeader('content-encoding'))) { // Handle gzip encoding case 'gzip': $body = self::decodeGzip($body); break; // Handle deflate encoding case 'deflate': $body = self::decodeDeflate($body); break; default: break; } return $body; }
[ "public", "function", "getBody", "(", ")", "{", "$", "body", "=", "''", ";", "// Decode the body if it was transfer-encoded", "switch", "(", "$", "this", "->", "getHeader", "(", "'transfer-encoding'", ")", ")", "{", "// Handle chunked body", "case", "'chunked'", "...
Get the response body as string This method returns the body of the HTTP response (the content), as it should be in it's readable version - that is, after decoding it (if it was decoded), deflating it (if it was gzip compressed), etc. If you want to get the raw body (as transfered on wire) use $this->getRawBody() instead. @return string
[ "Get", "the", "response", "body", "as", "string" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php#L252-L289
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php
Zend_Http_Response.responseCodeAsText
public static function responseCodeAsText($code = null, $http11 = true) { $messages = self::$messages; if (! $http11) { $messages[302] = 'Moved Temporarily'; } if ($code === null) { return $messages; } elseif (isset($messages[$code])) { return $messages[$code]; } else { return 'Unknown'; } }
php
public static function responseCodeAsText($code = null, $http11 = true) { $messages = self::$messages; if (! $http11) { $messages[302] = 'Moved Temporarily'; } if ($code === null) { return $messages; } elseif (isset($messages[$code])) { return $messages[$code]; } else { return 'Unknown'; } }
[ "public", "static", "function", "responseCodeAsText", "(", "$", "code", "=", "null", ",", "$", "http11", "=", "true", ")", "{", "$", "messages", "=", "self", "::", "$", "messages", ";", "if", "(", "!", "$", "http11", ")", "{", "$", "messages", "[", ...
A convenience function that returns a text representation of HTTP response codes. Returns 'Unknown' for unknown codes. Returns array of all codes, if $code is not specified. Conforms to HTTP/1.1 as defined in RFC 2616 (except for 'Unknown') See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10 for reference @param int $code HTTP response code @param boolean $http11 Use HTTP version 1.1 @return string
[ "A", "convenience", "function", "that", "returns", "a", "text", "representation", "of", "HTTP", "response", "codes", ".", "Returns", "Unknown", "for", "unknown", "codes", ".", "Returns", "array", "of", "all", "codes", "if", "$code", "is", "not", "specified", ...
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php#L414-L427
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php
Zend_Http_Response.extractCode
public static function extractCode($response_str) { preg_match("|^HTTP/[\d\.x]+ (\d+)|", $response_str, $m); if (isset($m[1])) { return (int) $m[1]; } else { return false; } }
php
public static function extractCode($response_str) { preg_match("|^HTTP/[\d\.x]+ (\d+)|", $response_str, $m); if (isset($m[1])) { return (int) $m[1]; } else { return false; } }
[ "public", "static", "function", "extractCode", "(", "$", "response_str", ")", "{", "preg_match", "(", "\"|^HTTP/[\\d\\.x]+ (\\d+)|\"", ",", "$", "response_str", ",", "$", "m", ")", ";", "if", "(", "isset", "(", "$", "m", "[", "1", "]", ")", ")", "{", "...
Extract the response code from a response string @param string $response_str @return int
[ "Extract", "the", "response", "code", "from", "a", "response", "string" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php#L435-L444
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php
Zend_Http_Response.fromString
public static function fromString($response_str) { $code = self::extractCode($response_str); $headers = self::extractHeaders($response_str); $body = self::extractBody($response_str); $version = self::extractVersion($response_str); $message = self::extractMessage($response_str); return new Zend_Http_Response($code, $headers, $body, $version, $message); }
php
public static function fromString($response_str) { $code = self::extractCode($response_str); $headers = self::extractHeaders($response_str); $body = self::extractBody($response_str); $version = self::extractVersion($response_str); $message = self::extractMessage($response_str); return new Zend_Http_Response($code, $headers, $body, $version, $message); }
[ "public", "static", "function", "fromString", "(", "$", "response_str", ")", "{", "$", "code", "=", "self", "::", "extractCode", "(", "$", "response_str", ")", ";", "$", "headers", "=", "self", "::", "extractHeaders", "(", "$", "response_str", ")", ";", ...
Create a new Zend_Http_Response object from a string @param string $response_str @return Zend_Http_Response
[ "Create", "a", "new", "Zend_Http_Response", "object", "from", "a", "string" ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Http/Response.php#L624-L633
txj123/zilf
src/Zilf/Redis/RedisServiceProvider.php
RedisServiceProvider.register
public function register() { /** * redis 的连接对象 */ Zilf::$container->register( 'redis', function () { $config = Zilf::$container->getShare('config')->get('cache.redis'); return new RedisManager(Arr::pull($config, 'client', 'predis'), $config); } ); /** * redis的连接服务 */ Zilf::$container->register( 'redis.connection', function () { return Zilf::$container->get('redis')->connection(); } ); }
php
public function register() { /** * redis 的连接对象 */ Zilf::$container->register( 'redis', function () { $config = Zilf::$container->getShare('config')->get('cache.redis'); return new RedisManager(Arr::pull($config, 'client', 'predis'), $config); } ); /** * redis的连接服务 */ Zilf::$container->register( 'redis.connection', function () { return Zilf::$container->get('redis')->connection(); } ); }
[ "public", "function", "register", "(", ")", "{", "/**\n * redis 的连接对象\n */", "Zilf", "::", "$", "container", "->", "register", "(", "'redis'", ",", "function", "(", ")", "{", "$", "config", "=", "Zilf", "::", "$", "container", "->", "getShare",...
Register the service provider. @throws \Exception
[ "Register", "the", "service", "provider", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Redis/RedisServiceProvider.php#L22-L43
Kaishiyoku/laravel-menu
src/Kaishiyoku/Menu/Menu.php
Menu.register
public function register($name = null, $entries = [], $attributes = []) { if (empty($name)) { $name = self::DEFAULT_MENU_NAME; } // check if menu's name does not exist $exists = false; foreach ($this->menus as $menu) { if ($menu->getName() == $name) { $exists = true; } } if (!$exists) { $this->menus->push(new MenuContainer($name, $entries, $attributes)); } else { throw new MenuExistsException($name); } }
php
public function register($name = null, $entries = [], $attributes = []) { if (empty($name)) { $name = self::DEFAULT_MENU_NAME; } // check if menu's name does not exist $exists = false; foreach ($this->menus as $menu) { if ($menu->getName() == $name) { $exists = true; } } if (!$exists) { $this->menus->push(new MenuContainer($name, $entries, $attributes)); } else { throw new MenuExistsException($name); } }
[ "public", "function", "register", "(", "$", "name", "=", "null", ",", "$", "entries", "=", "[", "]", ",", "$", "attributes", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "$", "name", "=", "self", "::", "DEFAULT_...
Registers a new menu container. @param string|null $name @param array $entries @param array $attributes @throws MenuExistsException
[ "Registers", "a", "new", "menu", "container", "." ]
train
https://github.com/Kaishiyoku/laravel-menu/blob/0a1aa772f19002d354f0c338e603d98c49d10a7a/src/Kaishiyoku/Menu/Menu.php#L49-L69
Kaishiyoku/laravel-menu
src/Kaishiyoku/Menu/Menu.php
Menu.linkRoute
public function linkRoute($routeName, $title = null, $parameters = [], $attributes = [], $additionalRouteNames = [], $isVisible = true) { return new LinkRoute($routeName, $title, $parameters, $attributes, $additionalRouteNames, $isVisible); }
php
public function linkRoute($routeName, $title = null, $parameters = [], $attributes = [], $additionalRouteNames = [], $isVisible = true) { return new LinkRoute($routeName, $title, $parameters, $attributes, $additionalRouteNames, $isVisible); }
[ "public", "function", "linkRoute", "(", "$", "routeName", ",", "$", "title", "=", "null", ",", "$", "parameters", "=", "[", "]", ",", "$", "attributes", "=", "[", "]", ",", "$", "additionalRouteNames", "=", "[", "]", ",", "$", "isVisible", "=", "true...
Returns a new html anchor. @param string, $routeName @param string|null $title @param array $parameters @param array $attributes @param array $additionalRouteNames @param bool $isVisible @return LinkRoute
[ "Returns", "a", "new", "html", "anchor", "." ]
train
https://github.com/Kaishiyoku/laravel-menu/blob/0a1aa772f19002d354f0c338e603d98c49d10a7a/src/Kaishiyoku/Menu/Menu.php#L94-L97
Kaishiyoku/laravel-menu
src/Kaishiyoku/Menu/Menu.php
Menu.dropdown
public function dropdown($entries, $title, $name = null, $parameters = [], $attributes = [], $isVisible = true) { return new Dropdown($entries, $title, $name, $parameters, $attributes, $isVisible); }
php
public function dropdown($entries, $title, $name = null, $parameters = [], $attributes = [], $isVisible = true) { return new Dropdown($entries, $title, $name, $parameters, $attributes, $isVisible); }
[ "public", "function", "dropdown", "(", "$", "entries", ",", "$", "title", ",", "$", "name", "=", "null", ",", "$", "parameters", "=", "[", "]", ",", "$", "attributes", "=", "[", "]", ",", "$", "isVisible", "=", "true", ")", "{", "return", "new", ...
Returns a new html ul-like dropdown menu with sub-elements. @param array $entries @param string $title @param string|null $name @param array $parameters @param array $attributes @param bool $isVisible @return Dropdown
[ "Returns", "a", "new", "html", "ul", "-", "like", "dropdown", "menu", "with", "sub", "-", "elements", "." ]
train
https://github.com/Kaishiyoku/laravel-menu/blob/0a1aa772f19002d354f0c338e603d98c49d10a7a/src/Kaishiyoku/Menu/Menu.php#L115-L118
Kaishiyoku/laravel-menu
src/Kaishiyoku/Menu/Menu.php
Menu.render
public function render($menuName = null) { if (empty($menuName)) { $menuName = self::DEFAULT_MENU_NAME; } $menu = $this->menus->filter(function (MenuContainer $menu) use ($menuName) { return $menu->getName() == $menuName; })->first(); if ($menu instanceof MenuContainer) { return MenuHelper::purifyHtml(Html::decode($menu->render())); } else { throw new MenuNotFoundException($menuName); } }
php
public function render($menuName = null) { if (empty($menuName)) { $menuName = self::DEFAULT_MENU_NAME; } $menu = $this->menus->filter(function (MenuContainer $menu) use ($menuName) { return $menu->getName() == $menuName; })->first(); if ($menu instanceof MenuContainer) { return MenuHelper::purifyHtml(Html::decode($menu->render())); } else { throw new MenuNotFoundException($menuName); } }
[ "public", "function", "render", "(", "$", "menuName", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "menuName", ")", ")", "{", "$", "menuName", "=", "self", "::", "DEFAULT_MENU_NAME", ";", "}", "$", "menu", "=", "$", "this", "->", "menus", "...
Get the evaluated contents of the specified menu container. @param string|null $menuName @return string @throws MenuNotFoundException
[ "Get", "the", "evaluated", "contents", "of", "the", "specified", "menu", "container", "." ]
train
https://github.com/Kaishiyoku/laravel-menu/blob/0a1aa772f19002d354f0c338e603d98c49d10a7a/src/Kaishiyoku/Menu/Menu.php#L156-L171
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri.php
Zend_Uri.check
public static function check($uri) { try { $uri = self::factory($uri); } catch (Exception $e) { return false; } return $uri->valid(); }
php
public static function check($uri) { try { $uri = self::factory($uri); } catch (Exception $e) { return false; } return $uri->valid(); }
[ "public", "static", "function", "check", "(", "$", "uri", ")", "{", "try", "{", "$", "uri", "=", "self", "::", "factory", "(", "$", "uri", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "return", "false", ";", "}", "return", "$", ...
Convenience function, checks that a $uri string is well-formed by validating it but not returning an object. Returns TRUE if $uri is a well-formed URI, or FALSE otherwise. @param string $uri The URI to check @return boolean
[ "Convenience", "function", "checks", "that", "a", "$uri", "string", "is", "well", "-", "formed", "by", "validating", "it", "but", "not", "returning", "an", "object", ".", "Returns", "TRUE", "if", "$uri", "is", "a", "well", "-", "formed", "URI", "or", "FA...
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri.php#L63-L72
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri.php
Zend_Uri.factory
public static function factory($uri = 'http') { // Separate the scheme from the scheme-specific parts $uri = explode(':', $uri, 2); $scheme = strtolower($uri[0]); $schemeSpecific = isset($uri[1]) === true ? $uri[1] : ''; if (strlen($scheme) === 0) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('An empty string was supplied for the scheme'); } // Security check: $scheme is used to load a class file, so only alphanumerics are allowed. if (ctype_alnum($scheme) === false) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Illegal scheme supplied, only alphanumeric characters are permitted'); } /** * Create a new Zend_Uri object for the $uri. If a subclass of Zend_Uri exists for the * scheme, return an instance of that class. Otherwise, a Zend_Uri_Exception is thrown. */ switch ($scheme) { case 'http': // Break intentionally omitted case 'https': $className = 'Zend_Uri_Http'; break; case 'mailto': // TODO default: include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Scheme \"$scheme\" is not supported"); break; } Zend_Loader::loadClass($className); $schemeHandler = new $className($scheme, $schemeSpecific); return $schemeHandler; }
php
public static function factory($uri = 'http') { // Separate the scheme from the scheme-specific parts $uri = explode(':', $uri, 2); $scheme = strtolower($uri[0]); $schemeSpecific = isset($uri[1]) === true ? $uri[1] : ''; if (strlen($scheme) === 0) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('An empty string was supplied for the scheme'); } // Security check: $scheme is used to load a class file, so only alphanumerics are allowed. if (ctype_alnum($scheme) === false) { include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception('Illegal scheme supplied, only alphanumeric characters are permitted'); } /** * Create a new Zend_Uri object for the $uri. If a subclass of Zend_Uri exists for the * scheme, return an instance of that class. Otherwise, a Zend_Uri_Exception is thrown. */ switch ($scheme) { case 'http': // Break intentionally omitted case 'https': $className = 'Zend_Uri_Http'; break; case 'mailto': // TODO default: include_once 'Zend/Uri/Exception.php'; throw new Zend_Uri_Exception("Scheme \"$scheme\" is not supported"); break; } Zend_Loader::loadClass($className); $schemeHandler = new $className($scheme, $schemeSpecific); return $schemeHandler; }
[ "public", "static", "function", "factory", "(", "$", "uri", "=", "'http'", ")", "{", "// Separate the scheme from the scheme-specific parts", "$", "uri", "=", "explode", "(", "':'", ",", "$", "uri", ",", "2", ")", ";", "$", "scheme", "=", "strtolower", "(", ...
Create a new Zend_Uri object for a URI. If building a new URI, then $uri should contain only the scheme (http, ftp, etc). Otherwise, supply $uri with the complete URI. @param string $uri The URI form which a Zend_Uri instance is created @throws Zend_Uri_Exception When an empty string was supplied for the scheme @throws Zend_Uri_Exception When an illegal scheme is supplied @throws Zend_Uri_Exception When the scheme is not supported @return Zend_Uri @link http://www.faqs.org/rfcs/rfc2396.html
[ "Create", "a", "new", "Zend_Uri", "object", "for", "a", "URI", ".", "If", "building", "a", "new", "URI", "then", "$uri", "should", "contain", "only", "the", "scheme", "(", "http", "ftp", "etc", ")", ".", "Otherwise", "supply", "$uri", "with", "the", "c...
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery/Zend/Uri.php#L85-L126
mcustiel/php-simple-di
src/DependencyContainer.php
DependencyContainer.add
public function add($identifier, callable $loader, $singleton = true) { $this->dependencies[$identifier] = new Dependency($loader, $singleton); }
php
public function add($identifier, callable $loader, $singleton = true) { $this->dependencies[$identifier] = new Dependency($loader, $singleton); }
[ "public", "function", "add", "(", "$", "identifier", ",", "callable", "$", "loader", ",", "$", "singleton", "=", "true", ")", "{", "$", "this", "->", "dependencies", "[", "$", "identifier", "]", "=", "new", "Dependency", "(", "$", "loader", ",", "$", ...
Adds an object generator and the identifier for that object, with the option of make the object 'singleton' or not. @param string $identifier The identifier of the dependency @param callable $loader The generator for the dependency object @param string $singleton Whether or not to return always the same instance of the object
[ "Adds", "an", "object", "generator", "and", "the", "identifier", "for", "that", "object", "with", "the", "option", "of", "make", "the", "object", "singleton", "or", "not", "." ]
train
https://github.com/mcustiel/php-simple-di/blob/da0116625d9704185c4a9f01210469266970b265/src/DependencyContainer.php#L62-L65
mcustiel/php-simple-di
src/DependencyContainer.php
DependencyContainer.get
public function get($identifier) { if (!isset($this->dependencies[$identifier])) { throw new DependencyDoesNotExistException( "Dependency identified by '$identifier' does not exist" ); } return $this->dependencies[$identifier]->get(); }
php
public function get($identifier) { if (!isset($this->dependencies[$identifier])) { throw new DependencyDoesNotExistException( "Dependency identified by '$identifier' does not exist" ); } return $this->dependencies[$identifier]->get(); }
[ "public", "function", "get", "(", "$", "identifier", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "dependencies", "[", "$", "identifier", "]", ")", ")", "{", "throw", "new", "DependencyDoesNotExistException", "(", "\"Dependency identified by '$id...
Gets the dependency identified by the given identifier. @param string $identifier The identifier of the dependency @return object The object identified by the given id @throws DependencyDoesNotExistException If there's not dependency with the given id
[ "Gets", "the", "dependency", "identified", "by", "the", "given", "identifier", "." ]
train
https://github.com/mcustiel/php-simple-di/blob/da0116625d9704185c4a9f01210469266970b265/src/DependencyContainer.php#L75-L83
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.pq
public static function pq($arg1, $context = null) { if ($arg1 instanceof DOMNODE && ! isset($context)) { foreach(phpQuery::$documents as $documentWrapper) { $compare = $arg1 instanceof DOMDocument ? $arg1 : $arg1->ownerDocument; if ($documentWrapper->document->isSameNode($compare)) { $context = $documentWrapper->id; } } } if (! $context) { $domId = self::$defaultDocumentID; if (! $domId) { throw new Exception("Can't use last created DOM, because there isn't any. Use phpQuery::newDocument() first."); } // } else if (is_object($context) && ($context instanceof PHPQUERY || is_subclass_of($context, 'phpQueryObject'))) } else if (is_object($context) && $context instanceof phpQueryObject) { $domId = $context->getDocumentID(); } else if ($context instanceof DOMDOCUMENT) { $domId = self::getDocumentID($context); if (! $domId) { //throw new Exception('Orphaned DOMDocument'); $domId = self::newDocument($context)->getDocumentID(); } } else if ($context instanceof DOMNODE) { $domId = self::getDocumentID($context); if (! $domId) { throw new Exception('Orphaned DOMNode'); // $domId = self::newDocument($context->ownerDocument); } } else { $domId = $context; } if ($arg1 instanceof phpQueryObject) { // if (is_object($arg1) && (get_class($arg1) == 'phpQueryObject' || $arg1 instanceof PHPQUERY || is_subclass_of($arg1, 'phpQueryObject'))) { /** * Return $arg1 or import $arg1 stack if document differs: * pq(pq('<div/>')) */ if ($arg1->getDocumentID() == $domId) { return $arg1; } $class = get_class($arg1); // support inheritance by passing old object to overloaded constructor $phpQuery = $class != 'phpQuery' ? new $class($arg1, $domId) : new phpQueryObject($domId); $phpQuery->elements = array(); foreach($arg1->elements as $node) { $phpQuery->elements[] = $phpQuery->document->importNode($node, true); } return $phpQuery; } else if ($arg1 instanceof DOMNODE || (is_array($arg1) && isset($arg1[0]) && $arg1[0] instanceof DOMNODE)) { /* * Wrap DOM nodes with phpQuery object, import into document when needed: * pq(array($domNode1, $domNode2)) */ $phpQuery = new phpQueryObject($domId); if (!($arg1 instanceof DOMNODELIST) && ! is_array($arg1)) { $arg1 = array($arg1); } $phpQuery->elements = array(); foreach($arg1 as $node) { $sameDocument = $node->ownerDocument instanceof DOMDOCUMENT && ! $node->ownerDocument->isSameNode($phpQuery->document); $phpQuery->elements[] = $sameDocument ? $phpQuery->document->importNode($node, true) : $node; } return $phpQuery; } else if (self::isMarkup($arg1)) { /** * Import HTML: * pq('<div/>') */ $phpQuery = new phpQueryObject($domId); return $phpQuery->newInstance( $phpQuery->documentWrapper->import($arg1) ); } else { /** * Run CSS query: * pq('div.myClass') */ $phpQuery = new phpQueryObject($domId); // if ($context && ($context instanceof PHPQUERY || is_subclass_of($context, 'phpQueryObject'))) if ($context && $context instanceof phpQueryObject) { $phpQuery->elements = $context->elements; } else if ($context && $context instanceof DOMNODELIST) { $phpQuery->elements = array(); foreach($context as $node) { $phpQuery->elements[] = $node; } } else if ($context && $context instanceof DOMNODE) { $phpQuery->elements = array($context); } return $phpQuery->find($arg1); } }
php
public static function pq($arg1, $context = null) { if ($arg1 instanceof DOMNODE && ! isset($context)) { foreach(phpQuery::$documents as $documentWrapper) { $compare = $arg1 instanceof DOMDocument ? $arg1 : $arg1->ownerDocument; if ($documentWrapper->document->isSameNode($compare)) { $context = $documentWrapper->id; } } } if (! $context) { $domId = self::$defaultDocumentID; if (! $domId) { throw new Exception("Can't use last created DOM, because there isn't any. Use phpQuery::newDocument() first."); } // } else if (is_object($context) && ($context instanceof PHPQUERY || is_subclass_of($context, 'phpQueryObject'))) } else if (is_object($context) && $context instanceof phpQueryObject) { $domId = $context->getDocumentID(); } else if ($context instanceof DOMDOCUMENT) { $domId = self::getDocumentID($context); if (! $domId) { //throw new Exception('Orphaned DOMDocument'); $domId = self::newDocument($context)->getDocumentID(); } } else if ($context instanceof DOMNODE) { $domId = self::getDocumentID($context); if (! $domId) { throw new Exception('Orphaned DOMNode'); // $domId = self::newDocument($context->ownerDocument); } } else { $domId = $context; } if ($arg1 instanceof phpQueryObject) { // if (is_object($arg1) && (get_class($arg1) == 'phpQueryObject' || $arg1 instanceof PHPQUERY || is_subclass_of($arg1, 'phpQueryObject'))) { /** * Return $arg1 or import $arg1 stack if document differs: * pq(pq('<div/>')) */ if ($arg1->getDocumentID() == $domId) { return $arg1; } $class = get_class($arg1); // support inheritance by passing old object to overloaded constructor $phpQuery = $class != 'phpQuery' ? new $class($arg1, $domId) : new phpQueryObject($domId); $phpQuery->elements = array(); foreach($arg1->elements as $node) { $phpQuery->elements[] = $phpQuery->document->importNode($node, true); } return $phpQuery; } else if ($arg1 instanceof DOMNODE || (is_array($arg1) && isset($arg1[0]) && $arg1[0] instanceof DOMNODE)) { /* * Wrap DOM nodes with phpQuery object, import into document when needed: * pq(array($domNode1, $domNode2)) */ $phpQuery = new phpQueryObject($domId); if (!($arg1 instanceof DOMNODELIST) && ! is_array($arg1)) { $arg1 = array($arg1); } $phpQuery->elements = array(); foreach($arg1 as $node) { $sameDocument = $node->ownerDocument instanceof DOMDOCUMENT && ! $node->ownerDocument->isSameNode($phpQuery->document); $phpQuery->elements[] = $sameDocument ? $phpQuery->document->importNode($node, true) : $node; } return $phpQuery; } else if (self::isMarkup($arg1)) { /** * Import HTML: * pq('<div/>') */ $phpQuery = new phpQueryObject($domId); return $phpQuery->newInstance( $phpQuery->documentWrapper->import($arg1) ); } else { /** * Run CSS query: * pq('div.myClass') */ $phpQuery = new phpQueryObject($domId); // if ($context && ($context instanceof PHPQUERY || is_subclass_of($context, 'phpQueryObject'))) if ($context && $context instanceof phpQueryObject) { $phpQuery->elements = $context->elements; } else if ($context && $context instanceof DOMNODELIST) { $phpQuery->elements = array(); foreach($context as $node) { $phpQuery->elements[] = $node; } } else if ($context && $context instanceof DOMNODE) { $phpQuery->elements = array($context); } return $phpQuery->find($arg1); } }
[ "public", "static", "function", "pq", "(", "$", "arg1", ",", "$", "context", "=", "null", ")", "{", "if", "(", "$", "arg1", "instanceof", "DOMNODE", "&&", "!", "isset", "(", "$", "context", ")", ")", "{", "foreach", "(", "phpQuery", "::", "$", "doc...
Multi-purpose function. Use pq() as shortcut. In below examples, $pq is any result of pq(); function. 1. Import markup into existing document (without any attaching): - Import into selected document: pq('<div/>') // DOESNT accept text nodes at beginning of input string ! - Import into document with ID from $pq->getDocumentID(): pq('<div/>', $pq->getDocumentID()) - Import into same document as DOMNode belongs to: pq('<div/>', DOMNode) - Import into document from phpQuery object: pq('<div/>', $pq) 2. Run query: - Run query on last selected document: pq('div.myClass') - Run query on document with ID from $pq->getDocumentID(): pq('div.myClass', $pq->getDocumentID()) - Run query on same document as DOMNode belongs to and use node(s)as root for query: pq('div.myClass', DOMNode) - Run query on document from phpQuery object and use object's stack as root node(s) for query: pq('div.myClass', $pq) @param string|DOMNode|DOMNodeList|array $arg1 HTML markup, CSS Selector, DOMNode or array of DOMNodes @param string|phpQueryObject|DOMNode $context DOM ID from $pq->getDocumentID(), phpQuery object (determines also query root) or DOMNode (determines also query root) @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery|QueryTemplatesPhpQuery|false phpQuery object or false in case of error.
[ "Multi", "-", "purpose", "function", ".", "Use", "pq", "()", "as", "shortcut", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L145-L244
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.selectDocument
public static function selectDocument($id) { $id = self::getDocumentID($id); self::debug("Selecting document '$id' as default one"); self::$defaultDocumentID = self::getDocumentID($id); }
php
public static function selectDocument($id) { $id = self::getDocumentID($id); self::debug("Selecting document '$id' as default one"); self::$defaultDocumentID = self::getDocumentID($id); }
[ "public", "static", "function", "selectDocument", "(", "$", "id", ")", "{", "$", "id", "=", "self", "::", "getDocumentID", "(", "$", "id", ")", ";", "self", "::", "debug", "(", "\"Selecting document '$id' as default one\"", ")", ";", "self", "::", "$", "de...
Sets default document to $id. Document has to be loaded prior to using this method. $id can be retrived via getDocumentID() or getDocumentIDRef(). @param unknown_type $id
[ "Sets", "default", "document", "to", "$id", ".", "Document", "has", "to", "be", "loaded", "prior", "to", "using", "this", "method", ".", "$id", "can", "be", "retrived", "via", "getDocumentID", "()", "or", "getDocumentIDRef", "()", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L252-L257
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.getDocument
public static function getDocument($id = null) { if ($id) { phpQuery::selectDocument($id); } else { $id = phpQuery::$defaultDocumentID; } return new phpQueryObject($id); }
php
public static function getDocument($id = null) { if ($id) { phpQuery::selectDocument($id); } else { $id = phpQuery::$defaultDocumentID; } return new phpQueryObject($id); }
[ "public", "static", "function", "getDocument", "(", "$", "id", "=", "null", ")", "{", "if", "(", "$", "id", ")", "{", "phpQuery", "::", "selectDocument", "(", "$", "id", ")", ";", "}", "else", "{", "$", "id", "=", "phpQuery", "::", "$", "defaultDoc...
Returns document with id $id or last used as phpQueryObject. $id can be retrived via getDocumentID() or getDocumentIDRef(). Chainable. @see phpQuery::selectDocument() @param unknown_type $id @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
[ "Returns", "document", "with", "id", "$id", "or", "last", "used", "as", "phpQueryObject", ".", "$id", "can", "be", "retrived", "via", "getDocumentID", "()", "or", "getDocumentIDRef", "()", ".", "Chainable", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L267-L275
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.newDocument
public static function newDocument($markup = null, $contentType = null) { if (! $markup) { $markup = ''; } $documentID = phpQuery::createDocumentWrapper($markup, $contentType); return new phpQueryObject($documentID); }
php
public static function newDocument($markup = null, $contentType = null) { if (! $markup) { $markup = ''; } $documentID = phpQuery::createDocumentWrapper($markup, $contentType); return new phpQueryObject($documentID); }
[ "public", "static", "function", "newDocument", "(", "$", "markup", "=", "null", ",", "$", "contentType", "=", "null", ")", "{", "if", "(", "!", "$", "markup", ")", "{", "$", "markup", "=", "''", ";", "}", "$", "documentID", "=", "phpQuery", "::", "...
Creates new document from markup. Chainable. @param unknown_type $markup @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
[ "Creates", "new", "document", "from", "markup", ".", "Chainable", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L283-L290
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.newDocumentHTML
public static function newDocumentHTML($markup = null, $charset = null) { $contentType = $charset ? ";charset=$charset" : ''; return self::newDocument($markup, "text/html{$contentType}"); }
php
public static function newDocumentHTML($markup = null, $charset = null) { $contentType = $charset ? ";charset=$charset" : ''; return self::newDocument($markup, "text/html{$contentType}"); }
[ "public", "static", "function", "newDocumentHTML", "(", "$", "markup", "=", "null", ",", "$", "charset", "=", "null", ")", "{", "$", "contentType", "=", "$", "charset", "?", "\";charset=$charset\"", ":", "''", ";", "return", "self", "::", "newDocument", "(...
Creates new document from markup. Chainable. @param unknown_type $markup @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
[ "Creates", "new", "document", "from", "markup", ".", "Chainable", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L298-L304
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.newDocumentXML
public static function newDocumentXML($markup = null, $charset = null) { $contentType = $charset ? ";charset=$charset" : ''; return self::newDocument($markup, "text/xml{$contentType}"); }
php
public static function newDocumentXML($markup = null, $charset = null) { $contentType = $charset ? ";charset=$charset" : ''; return self::newDocument($markup, "text/xml{$contentType}"); }
[ "public", "static", "function", "newDocumentXML", "(", "$", "markup", "=", "null", ",", "$", "charset", "=", "null", ")", "{", "$", "contentType", "=", "$", "charset", "?", "\";charset=$charset\"", ":", "''", ";", "return", "self", "::", "newDocument", "("...
Creates new document from markup. Chainable. @param unknown_type $markup @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
[ "Creates", "new", "document", "from", "markup", ".", "Chainable", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L312-L318
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.newDocumentXHTML
public static function newDocumentXHTML($markup = null, $charset = null) { $contentType = $charset ? ";charset=$charset" : ''; return self::newDocument($markup, "application/xhtml+xml{$contentType}"); }
php
public static function newDocumentXHTML($markup = null, $charset = null) { $contentType = $charset ? ";charset=$charset" : ''; return self::newDocument($markup, "application/xhtml+xml{$contentType}"); }
[ "public", "static", "function", "newDocumentXHTML", "(", "$", "markup", "=", "null", ",", "$", "charset", "=", "null", ")", "{", "$", "contentType", "=", "$", "charset", "?", "\";charset=$charset\"", ":", "''", ";", "return", "self", "::", "newDocument", "...
Creates new document from markup. Chainable. @param unknown_type $markup @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
[ "Creates", "new", "document", "from", "markup", ".", "Chainable", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L326-L332
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.newDocumentPHP
public static function newDocumentPHP($markup = null, $contentType = "text/html") { // TODO pass charset to phpToMarkup if possible (use DOMDocumentWrapper function) $markup = phpQuery::phpToMarkup($markup, self::$defaultCharset); return self::newDocument($markup, $contentType); }
php
public static function newDocumentPHP($markup = null, $contentType = "text/html") { // TODO pass charset to phpToMarkup if possible (use DOMDocumentWrapper function) $markup = phpQuery::phpToMarkup($markup, self::$defaultCharset); return self::newDocument($markup, $contentType); }
[ "public", "static", "function", "newDocumentPHP", "(", "$", "markup", "=", "null", ",", "$", "contentType", "=", "\"text/html\"", ")", "{", "// TODO pass charset to phpToMarkup if possible (use DOMDocumentWrapper function)", "$", "markup", "=", "phpQuery", "::", "phpToMar...
Creates new document from markup. Chainable. @param unknown_type $markup @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
[ "Creates", "new", "document", "from", "markup", ".", "Chainable", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L340-L345
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.markupToPHP
public static function markupToPHP($content) { if ($content instanceof phpQueryObject) { $content = $content->markupOuter(); } /* <php>...</php> to <?php...? > */ $content = preg_replace_callback( '@<php>\s*<!--(.*?)-->\s*</php>@s', // create_function('$m', // 'return "<'.'?php ".htmlspecialchars_decode($m[1])." ?'.'>";' // ), array('phpQuery', '_markupToPHPCallback'), $content ); /* <node attr='< ?php ? >'> extra space added to save highlighters */ $regexes = array( '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(\')([^\']*)(?:&lt;|%3C)\\?(?:php)?(.*?)(?:\\?(?:&gt;|%3E))([^\']*)\'@s', '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(")([^"]*)(?:&lt;|%3C)\\?(?:php)?(.*?)(?:\\?(?:&gt;|%3E))([^"]*)"@s', ); foreach($regexes as $regex) { while (preg_match($regex, $content)) { $content = preg_replace_callback( $regex, create_function( '$m', 'return $m[1].$m[2].$m[3]."<?php " .str_replace( array("%20", "%3E", "%09", "&#10;", "&#9;", "%7B", "%24", "%7D", "%22", "%5B", "%5D"), array(" ", ">", " ", "\n", " ", "{", "$", "}", \'"\', "[", "]"), htmlspecialchars_decode($m[4]) ) ." ?>".$m[5].$m[2];' ), $content ); } } return $content; }
php
public static function markupToPHP($content) { if ($content instanceof phpQueryObject) { $content = $content->markupOuter(); } /* <php>...</php> to <?php...? > */ $content = preg_replace_callback( '@<php>\s*<!--(.*?)-->\s*</php>@s', // create_function('$m', // 'return "<'.'?php ".htmlspecialchars_decode($m[1])." ?'.'>";' // ), array('phpQuery', '_markupToPHPCallback'), $content ); /* <node attr='< ?php ? >'> extra space added to save highlighters */ $regexes = array( '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(\')([^\']*)(?:&lt;|%3C)\\?(?:php)?(.*?)(?:\\?(?:&gt;|%3E))([^\']*)\'@s', '@(<(?!\\?)(?:[^>]|\\?>)+\\w+\\s*=\\s*)(")([^"]*)(?:&lt;|%3C)\\?(?:php)?(.*?)(?:\\?(?:&gt;|%3E))([^"]*)"@s', ); foreach($regexes as $regex) { while (preg_match($regex, $content)) { $content = preg_replace_callback( $regex, create_function( '$m', 'return $m[1].$m[2].$m[3]."<?php " .str_replace( array("%20", "%3E", "%09", "&#10;", "&#9;", "%7B", "%24", "%7D", "%22", "%5B", "%5D"), array(" ", ">", " ", "\n", " ", "{", "$", "}", \'"\', "[", "]"), htmlspecialchars_decode($m[4]) ) ." ?>".$m[5].$m[2];' ), $content ); } } return $content; }
[ "public", "static", "function", "markupToPHP", "(", "$", "content", ")", "{", "if", "(", "$", "content", "instanceof", "phpQueryObject", ")", "{", "$", "content", "=", "$", "content", "->", "markupOuter", "(", ")", ";", "}", "/* <php>...</php> to <?php...? > *...
Converts document markup containing PHP code generated by phpQuery::php() into valid (executable) PHP code syntax. @param string|phpQueryObject $content @return string PHP code.
[ "Converts", "document", "markup", "containing", "PHP", "code", "generated", "by", "phpQuery", "::", "php", "()", "into", "valid", "(", "executable", ")", "PHP", "code", "syntax", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L389-L427
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.newDocumentFile
public static function newDocumentFile($file, $contentType = null) { $documentID = self::createDocumentWrapper( file_get_contents($file), $contentType ); return new phpQueryObject($documentID); }
php
public static function newDocumentFile($file, $contentType = null) { $documentID = self::createDocumentWrapper( file_get_contents($file), $contentType ); return new phpQueryObject($documentID); }
[ "public", "static", "function", "newDocumentFile", "(", "$", "file", ",", "$", "contentType", "=", "null", ")", "{", "$", "documentID", "=", "self", "::", "createDocumentWrapper", "(", "file_get_contents", "(", "$", "file", ")", ",", "$", "contentType", ")",...
Creates new document from file $file. Chainable. @param string $file URLs allowed. See File wrapper page at php.net for more supported sources. @return phpQueryObject|QueryTemplatesSource|QueryTemplatesParse|QueryTemplatesSourceQuery
[ "Creates", "new", "document", "from", "file", "$file", ".", "Chainable", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L435-L441
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.createDocumentWrapper
protected static function createDocumentWrapper($html, $contentType = null, $documentID = null) { if (function_exists('domxml_open_mem')) { throw new Exception("Old PHP4 DOM XML extension detected. phpQuery won't work until this extension is enabled."); } // $id = $documentID // ? $documentID // : md5(microtime()); $document = null; if ($html instanceof DOMDOCUMENT) { if (self::getDocumentID($html)) { // document already exists in phpQuery::$documents, make a copy $document = clone $html; } else { // new document, add it to phpQuery::$documents $wrapper = new DOMDocumentWrapper($html, $contentType, $documentID); } } else { $wrapper = new DOMDocumentWrapper($html, $contentType, $documentID); } // $wrapper->id = $id; // bind document phpQuery::$documents[$wrapper->id] = $wrapper; // remember last loaded document phpQuery::selectDocument($wrapper->id); return $wrapper->id; }
php
protected static function createDocumentWrapper($html, $contentType = null, $documentID = null) { if (function_exists('domxml_open_mem')) { throw new Exception("Old PHP4 DOM XML extension detected. phpQuery won't work until this extension is enabled."); } // $id = $documentID // ? $documentID // : md5(microtime()); $document = null; if ($html instanceof DOMDOCUMENT) { if (self::getDocumentID($html)) { // document already exists in phpQuery::$documents, make a copy $document = clone $html; } else { // new document, add it to phpQuery::$documents $wrapper = new DOMDocumentWrapper($html, $contentType, $documentID); } } else { $wrapper = new DOMDocumentWrapper($html, $contentType, $documentID); } // $wrapper->id = $id; // bind document phpQuery::$documents[$wrapper->id] = $wrapper; // remember last loaded document phpQuery::selectDocument($wrapper->id); return $wrapper->id; }
[ "protected", "static", "function", "createDocumentWrapper", "(", "$", "html", ",", "$", "contentType", "=", "null", ",", "$", "documentID", "=", "null", ")", "{", "if", "(", "function_exists", "(", "'domxml_open_mem'", ")", ")", "{", "throw", "new", "Excepti...
Enter description here... @param unknown_type $html @param unknown_type $domId @return unknown New DOM ID @todo support PHP tags in input @todo support passing DOMDocument object from self::loadDocument
[ "Enter", "description", "here", "..." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L517-L543
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.extend
public static function extend($target, $source) { switch($target) { case 'phpQueryObject': $targetRef = &self::$extendMethods; $targetRef2 = &self::$pluginsMethods; break; case 'phpQuery': $targetRef = &self::$extendStaticMethods; $targetRef2 = &self::$pluginsStaticMethods; break; default: throw new Exception("Unsupported \$target type"); } if (is_string($source)) { $source = array($source => $source); } foreach($source as $method => $callback) { if (isset($targetRef[$method])) { // throw new Exception self::debug("Duplicate method '{$method}', can\'t extend '{$target}'"); continue; } if (isset($targetRef2[$method])) { // throw new Exception self::debug( "Duplicate method '{$method}' from plugin '{$targetRef2[$method]}'," ." can\'t extend '{$target}'" ); continue; } $targetRef[$method] = $callback; } return true; }
php
public static function extend($target, $source) { switch($target) { case 'phpQueryObject': $targetRef = &self::$extendMethods; $targetRef2 = &self::$pluginsMethods; break; case 'phpQuery': $targetRef = &self::$extendStaticMethods; $targetRef2 = &self::$pluginsStaticMethods; break; default: throw new Exception("Unsupported \$target type"); } if (is_string($source)) { $source = array($source => $source); } foreach($source as $method => $callback) { if (isset($targetRef[$method])) { // throw new Exception self::debug("Duplicate method '{$method}', can\'t extend '{$target}'"); continue; } if (isset($targetRef2[$method])) { // throw new Exception self::debug( "Duplicate method '{$method}' from plugin '{$targetRef2[$method]}'," ." can\'t extend '{$target}'" ); continue; } $targetRef[$method] = $callback; } return true; }
[ "public", "static", "function", "extend", "(", "$", "target", ",", "$", "source", ")", "{", "switch", "(", "$", "target", ")", "{", "case", "'phpQueryObject'", ":", "$", "targetRef", "=", "&", "self", "::", "$", "extendMethods", ";", "$", "targetRef2", ...
Extend class namespace. @param string|array $target @param array $source @TODO support string $source @return unknown_type
[ "Extend", "class", "namespace", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L552-L586
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.plugin
public static function plugin($class, $file = null) { // TODO $class checked agains phpQuery_$class // if (strpos($class, 'phpQuery') === 0) // $class = substr($class, 8); if (in_array($class, self::$pluginsLoaded)) { return true; } if (! $file) { $file = $class.'.php'; } $objectClassExists = class_exists('phpQueryObjectPlugin_'.$class); $staticClassExists = class_exists('phpQueryPlugin_'.$class); if (! $objectClassExists && ! $staticClassExists) { include_once $file; } self::$pluginsLoaded[] = $class; // static methods if (class_exists('phpQueryPlugin_'.$class)) { $realClass = 'phpQueryPlugin_'.$class; $vars = get_class_vars($realClass); $loop = isset($vars['phpQueryMethods']) && ! is_null($vars['phpQueryMethods']) ? $vars['phpQueryMethods'] : get_class_methods($realClass); foreach($loop as $method) { if ($method == '__initialize') { continue; } if (! is_callable(array($realClass, $method))) { continue; } if (isset(self::$pluginsStaticMethods[$method])) { throw new Exception("Duplicate method '{$method}' from plugin '{$c}' conflicts with same method from plugin '".self::$pluginsStaticMethods[$method]."'"); return; } self::$pluginsStaticMethods[$method] = $class; } if (method_exists($realClass, '__initialize')) { call_user_func_array(array($realClass, '__initialize'), array()); } } // object methods if (class_exists('phpQueryObjectPlugin_'.$class)) { $realClass = 'phpQueryObjectPlugin_'.$class; $vars = get_class_vars($realClass); $loop = isset($vars['phpQueryMethods']) && ! is_null($vars['phpQueryMethods']) ? $vars['phpQueryMethods'] : get_class_methods($realClass); foreach($loop as $method) { if (! is_callable(array($realClass, $method))) { continue; } if (isset(self::$pluginsMethods[$method])) { throw new Exception("Duplicate method '{$method}' from plugin '{$c}' conflicts with same method from plugin '".self::$pluginsMethods[$method]."'"); continue; } self::$pluginsMethods[$method] = $class; } } return true; }
php
public static function plugin($class, $file = null) { // TODO $class checked agains phpQuery_$class // if (strpos($class, 'phpQuery') === 0) // $class = substr($class, 8); if (in_array($class, self::$pluginsLoaded)) { return true; } if (! $file) { $file = $class.'.php'; } $objectClassExists = class_exists('phpQueryObjectPlugin_'.$class); $staticClassExists = class_exists('phpQueryPlugin_'.$class); if (! $objectClassExists && ! $staticClassExists) { include_once $file; } self::$pluginsLoaded[] = $class; // static methods if (class_exists('phpQueryPlugin_'.$class)) { $realClass = 'phpQueryPlugin_'.$class; $vars = get_class_vars($realClass); $loop = isset($vars['phpQueryMethods']) && ! is_null($vars['phpQueryMethods']) ? $vars['phpQueryMethods'] : get_class_methods($realClass); foreach($loop as $method) { if ($method == '__initialize') { continue; } if (! is_callable(array($realClass, $method))) { continue; } if (isset(self::$pluginsStaticMethods[$method])) { throw new Exception("Duplicate method '{$method}' from plugin '{$c}' conflicts with same method from plugin '".self::$pluginsStaticMethods[$method]."'"); return; } self::$pluginsStaticMethods[$method] = $class; } if (method_exists($realClass, '__initialize')) { call_user_func_array(array($realClass, '__initialize'), array()); } } // object methods if (class_exists('phpQueryObjectPlugin_'.$class)) { $realClass = 'phpQueryObjectPlugin_'.$class; $vars = get_class_vars($realClass); $loop = isset($vars['phpQueryMethods']) && ! is_null($vars['phpQueryMethods']) ? $vars['phpQueryMethods'] : get_class_methods($realClass); foreach($loop as $method) { if (! is_callable(array($realClass, $method))) { continue; } if (isset(self::$pluginsMethods[$method])) { throw new Exception("Duplicate method '{$method}' from plugin '{$c}' conflicts with same method from plugin '".self::$pluginsMethods[$method]."'"); continue; } self::$pluginsMethods[$method] = $class; } } return true; }
[ "public", "static", "function", "plugin", "(", "$", "class", ",", "$", "file", "=", "null", ")", "{", "// TODO $class checked agains phpQuery_$class", "// if (strpos($class, 'phpQuery') === 0)", "// $class = substr($class, 8);", "if", "(", "in_array", "(", ...
Extend phpQuery with $class from $file. @param string $class Extending class name. Real class name can be prepended phpQuery_. @param string $file Filename to include. Defaults to "{$class}.php".
[ "Extend", "phpQuery", "with", "$class", "from", "$file", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L593-L655
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.unloadDocuments
public static function unloadDocuments($id = null) { if (isset($id)) { if ($id = self::getDocumentID($id)) { unset(phpQuery::$documents[$id]); } } else { foreach(phpQuery::$documents as $k => $v) { unset(phpQuery::$documents[$k]); } } }
php
public static function unloadDocuments($id = null) { if (isset($id)) { if ($id = self::getDocumentID($id)) { unset(phpQuery::$documents[$id]); } } else { foreach(phpQuery::$documents as $k => $v) { unset(phpQuery::$documents[$k]); } } }
[ "public", "static", "function", "unloadDocuments", "(", "$", "id", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "id", ")", ")", "{", "if", "(", "$", "id", "=", "self", "::", "getDocumentID", "(", "$", "id", ")", ")", "{", "unset", "(", ...
Unloades all or specified document from memory. @param mixed $documentID @see phpQuery::getDocumentID() for supported types.
[ "Unloades", "all", "or", "specified", "document", "from", "memory", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L661-L672
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.ajax
public static function ajax($options = array(), $xhr = null) { $options = array_merge( self::$ajaxSettings, $options ); $documentID = isset($options['document']) ? self::getDocumentID($options['document']) : null; if ($xhr) { // reuse existing XHR object, but clean it up $client = $xhr; // $client->setParameterPost(null); // $client->setParameterGet(null); $client->setAuth(false); $client->setHeaders("If-Modified-Since", null); $client->setHeaders("Referer", null); $client->resetParameters(); } else { // create new XHR object include_once 'Zend/Http/Client.php'; $client = new Zend_Http_Client(); $client->setCookieJar(); } if (isset($options['timeout'])) { $client->setConfig( array( 'timeout' => $options['timeout'], ) ); } // 'maxredirects' => 0, foreach(self::$ajaxAllowedHosts as $k => $host) { if ($host == '.' && isset($_SERVER['HTTP_HOST'])) { self::$ajaxAllowedHosts[$k] = $_SERVER['HTTP_HOST']; } } $host = parse_url($options['url'], PHP_URL_HOST); if (! in_array($host, self::$ajaxAllowedHosts)) { throw new Exception( "Request not permitted, host '$host' not present in " ."phpQuery::\$ajaxAllowedHosts" ); } // JSONP $jsre = "/=\\?(&|$)/"; if (isset($options['dataType']) && $options['dataType'] == 'jsonp') { $jsonpCallbackParam = $options['jsonp'] ? $options['jsonp'] : 'callback'; if (strtolower($options['type']) == 'get') { if (! preg_match($jsre, $options['url'])) { $sep = strpos($options['url'], '?') ? '&' : '?'; $options['url'] .= "$sep$jsonpCallbackParam=?"; } } else if ($options['data']) { $jsonp = false; foreach($options['data'] as $n => $v) { if ($v == '?') { $jsonp = true; } } if (! $jsonp) { $options['data'][$jsonpCallbackParam] = '?'; } } $options['dataType'] = 'json'; } if (isset($options['dataType']) && $options['dataType'] == 'json') { $jsonpCallback = 'json_'.md5(microtime()); $jsonpData = $jsonpUrl = false; if ($options['data']) { foreach($options['data'] as $n => $v) { if ($v == '?') { $jsonpData = $n; } } } if (preg_match($jsre, $options['url'])) { $jsonpUrl = true; } if ($jsonpData !== false || $jsonpUrl) { // remember callback name for httpData() $options['_jsonp'] = $jsonpCallback; if ($jsonpData !== false) { $options['data'][$jsonpData] = $jsonpCallback; } if ($jsonpUrl) { $options['url'] = preg_replace($jsre, "=$jsonpCallback\\1", $options['url']); } } } $client->setUri($options['url']); $client->setMethod(strtoupper($options['type'])); if (isset($options['referer']) && $options['referer']) { $client->setHeaders('Referer', $options['referer']); } $client->setHeaders( array( // 'content-type' => $options['contentType'], 'User-Agent' => 'Mozilla/5.0 (X11; U; Linux x86; en-US; rv:1.9.0.5) Gecko' .'/2008122010 Firefox/3.0.5', // TODO custom charset 'Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', // 'Connection' => 'keep-alive', // 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language' => 'en-us,en;q=0.5', ) ); if ($options['username']) { $client->setAuth($options['username'], $options['password']); } if (isset($options['ifModified']) && $options['ifModified']) { $client->setHeaders( "If-Modified-Since", self::$lastModified ? self::$lastModified : "Thu, 01 Jan 1970 00:00:00 GMT" ); } $client->setHeaders( "Accept", isset($options['dataType']) && isset(self::$ajaxSettings['accepts'][ $options['dataType'] ]) ? self::$ajaxSettings['accepts'][ $options['dataType'] ].", */*" : self::$ajaxSettings['accepts']['_default'] ); // TODO $options['processData'] if ($options['data'] instanceof phpQueryObject) { $serialized = $options['data']->serializeArray($options['data']); $options['data'] = array(); foreach($serialized as $r) { $options['data'][ $r['name'] ] = $r['value']; } } if (strtolower($options['type']) == 'get') { $client->setParameterGet($options['data']); } else if (strtolower($options['type']) == 'post') { $client->setEncType($options['contentType']); $client->setParameterPost($options['data']); } if (self::$active == 0 && $options['global']) { phpQueryEvents::trigger($documentID, 'ajaxStart'); } self::$active++; // beforeSend callback if (isset($options['beforeSend']) && $options['beforeSend']) { phpQuery::callbackRun($options['beforeSend'], array($client)); } // ajaxSend event if ($options['global']) { phpQueryEvents::trigger($documentID, 'ajaxSend', array($client, $options)); } if (phpQuery::$debug) { self::debug("{$options['type']}: {$options['url']}\n"); self::debug("Options: <pre>".var_export($options, true)."</pre>\n"); // if ($client->getCookieJar()) // self::debug("Cookies: <pre>".var_export($client->getCookieJar()->getMatchingCookies($options['url']), true)."</pre>\n"); } // request $response = $client->request(); if (phpQuery::$debug) { self::debug('Status: '.$response->getStatus().' / '.$response->getMessage()); self::debug($client->getLastRequest()); self::debug($response->getHeaders()); } if ($response->isSuccessful()) { // XXX tempolary self::$lastModified = $response->getHeader('Last-Modified'); $data = self::httpData($response->getBody(), $options['dataType'], $options); if (isset($options['success']) && $options['success']) { phpQuery::callbackRun($options['success'], array($data, $response->getStatus(), $options)); } if ($options['global']) { phpQueryEvents::trigger($documentID, 'ajaxSuccess', array($client, $options)); } } else { if (isset($options['error']) && $options['error']) { phpQuery::callbackRun($options['error'], array($client, $response->getStatus(), $response->getMessage())); } if ($options['global']) { phpQueryEvents::trigger($documentID, 'ajaxError', array($client, /*$response->getStatus(),*/$response->getMessage(), $options)); } } if (isset($options['complete']) && $options['complete']) { phpQuery::callbackRun($options['complete'], array($client, $response->getStatus())); } if ($options['global']) { phpQueryEvents::trigger($documentID, 'ajaxComplete', array($client, $options)); } if ($options['global'] && ! --self::$active) { phpQueryEvents::trigger($documentID, 'ajaxStop'); } return $client; // if (is_null($domId)) // $domId = self::$defaultDocumentID ? self::$defaultDocumentID : false; // return new phpQueryAjaxResponse($response, $domId); }
php
public static function ajax($options = array(), $xhr = null) { $options = array_merge( self::$ajaxSettings, $options ); $documentID = isset($options['document']) ? self::getDocumentID($options['document']) : null; if ($xhr) { // reuse existing XHR object, but clean it up $client = $xhr; // $client->setParameterPost(null); // $client->setParameterGet(null); $client->setAuth(false); $client->setHeaders("If-Modified-Since", null); $client->setHeaders("Referer", null); $client->resetParameters(); } else { // create new XHR object include_once 'Zend/Http/Client.php'; $client = new Zend_Http_Client(); $client->setCookieJar(); } if (isset($options['timeout'])) { $client->setConfig( array( 'timeout' => $options['timeout'], ) ); } // 'maxredirects' => 0, foreach(self::$ajaxAllowedHosts as $k => $host) { if ($host == '.' && isset($_SERVER['HTTP_HOST'])) { self::$ajaxAllowedHosts[$k] = $_SERVER['HTTP_HOST']; } } $host = parse_url($options['url'], PHP_URL_HOST); if (! in_array($host, self::$ajaxAllowedHosts)) { throw new Exception( "Request not permitted, host '$host' not present in " ."phpQuery::\$ajaxAllowedHosts" ); } // JSONP $jsre = "/=\\?(&|$)/"; if (isset($options['dataType']) && $options['dataType'] == 'jsonp') { $jsonpCallbackParam = $options['jsonp'] ? $options['jsonp'] : 'callback'; if (strtolower($options['type']) == 'get') { if (! preg_match($jsre, $options['url'])) { $sep = strpos($options['url'], '?') ? '&' : '?'; $options['url'] .= "$sep$jsonpCallbackParam=?"; } } else if ($options['data']) { $jsonp = false; foreach($options['data'] as $n => $v) { if ($v == '?') { $jsonp = true; } } if (! $jsonp) { $options['data'][$jsonpCallbackParam] = '?'; } } $options['dataType'] = 'json'; } if (isset($options['dataType']) && $options['dataType'] == 'json') { $jsonpCallback = 'json_'.md5(microtime()); $jsonpData = $jsonpUrl = false; if ($options['data']) { foreach($options['data'] as $n => $v) { if ($v == '?') { $jsonpData = $n; } } } if (preg_match($jsre, $options['url'])) { $jsonpUrl = true; } if ($jsonpData !== false || $jsonpUrl) { // remember callback name for httpData() $options['_jsonp'] = $jsonpCallback; if ($jsonpData !== false) { $options['data'][$jsonpData] = $jsonpCallback; } if ($jsonpUrl) { $options['url'] = preg_replace($jsre, "=$jsonpCallback\\1", $options['url']); } } } $client->setUri($options['url']); $client->setMethod(strtoupper($options['type'])); if (isset($options['referer']) && $options['referer']) { $client->setHeaders('Referer', $options['referer']); } $client->setHeaders( array( // 'content-type' => $options['contentType'], 'User-Agent' => 'Mozilla/5.0 (X11; U; Linux x86; en-US; rv:1.9.0.5) Gecko' .'/2008122010 Firefox/3.0.5', // TODO custom charset 'Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.7', // 'Connection' => 'keep-alive', // 'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8', 'Accept-Language' => 'en-us,en;q=0.5', ) ); if ($options['username']) { $client->setAuth($options['username'], $options['password']); } if (isset($options['ifModified']) && $options['ifModified']) { $client->setHeaders( "If-Modified-Since", self::$lastModified ? self::$lastModified : "Thu, 01 Jan 1970 00:00:00 GMT" ); } $client->setHeaders( "Accept", isset($options['dataType']) && isset(self::$ajaxSettings['accepts'][ $options['dataType'] ]) ? self::$ajaxSettings['accepts'][ $options['dataType'] ].", */*" : self::$ajaxSettings['accepts']['_default'] ); // TODO $options['processData'] if ($options['data'] instanceof phpQueryObject) { $serialized = $options['data']->serializeArray($options['data']); $options['data'] = array(); foreach($serialized as $r) { $options['data'][ $r['name'] ] = $r['value']; } } if (strtolower($options['type']) == 'get') { $client->setParameterGet($options['data']); } else if (strtolower($options['type']) == 'post') { $client->setEncType($options['contentType']); $client->setParameterPost($options['data']); } if (self::$active == 0 && $options['global']) { phpQueryEvents::trigger($documentID, 'ajaxStart'); } self::$active++; // beforeSend callback if (isset($options['beforeSend']) && $options['beforeSend']) { phpQuery::callbackRun($options['beforeSend'], array($client)); } // ajaxSend event if ($options['global']) { phpQueryEvents::trigger($documentID, 'ajaxSend', array($client, $options)); } if (phpQuery::$debug) { self::debug("{$options['type']}: {$options['url']}\n"); self::debug("Options: <pre>".var_export($options, true)."</pre>\n"); // if ($client->getCookieJar()) // self::debug("Cookies: <pre>".var_export($client->getCookieJar()->getMatchingCookies($options['url']), true)."</pre>\n"); } // request $response = $client->request(); if (phpQuery::$debug) { self::debug('Status: '.$response->getStatus().' / '.$response->getMessage()); self::debug($client->getLastRequest()); self::debug($response->getHeaders()); } if ($response->isSuccessful()) { // XXX tempolary self::$lastModified = $response->getHeader('Last-Modified'); $data = self::httpData($response->getBody(), $options['dataType'], $options); if (isset($options['success']) && $options['success']) { phpQuery::callbackRun($options['success'], array($data, $response->getStatus(), $options)); } if ($options['global']) { phpQueryEvents::trigger($documentID, 'ajaxSuccess', array($client, $options)); } } else { if (isset($options['error']) && $options['error']) { phpQuery::callbackRun($options['error'], array($client, $response->getStatus(), $response->getMessage())); } if ($options['global']) { phpQueryEvents::trigger($documentID, 'ajaxError', array($client, /*$response->getStatus(),*/$response->getMessage(), $options)); } } if (isset($options['complete']) && $options['complete']) { phpQuery::callbackRun($options['complete'], array($client, $response->getStatus())); } if ($options['global']) { phpQueryEvents::trigger($documentID, 'ajaxComplete', array($client, $options)); } if ($options['global'] && ! --self::$active) { phpQueryEvents::trigger($documentID, 'ajaxStop'); } return $client; // if (is_null($domId)) // $domId = self::$defaultDocumentID ? self::$defaultDocumentID : false; // return new phpQueryAjaxResponse($response, $domId); }
[ "public", "static", "function", "ajax", "(", "$", "options", "=", "array", "(", ")", ",", "$", "xhr", "=", "null", ")", "{", "$", "options", "=", "array_merge", "(", "self", "::", "$", "ajaxSettings", ",", "$", "options", ")", ";", "$", "documentID",...
Make an AJAX request. @param array See $options http://docs.jquery.com/Ajax/jQuery.ajax#toptions Additional options are: 'document' - document for global events, @see phpQuery::getDocumentID() 'referer' - implemented 'requested_with' - TODO; not implemented (X-Requested-With) @return Zend_Http_Client @link http://docs.jquery.com/Ajax/jQuery.ajax @TODO $options['cache'] @TODO $options['processData'] @TODO $options['xhr'] @TODO $options['data'] as string @TODO XHR interface
[ "Make", "an", "AJAX", "request", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L730-L926
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.parseJSON
public static function parseJSON($json) { if (function_exists('json_decode')) { $return = json_decode(trim($json), true); // json_decode and UTF8 issues if (isset($return)) { return $return; } } include_once 'Zend/Json/Decoder.php'; return Zend_Json_Decoder::decode($json); }
php
public static function parseJSON($json) { if (function_exists('json_decode')) { $return = json_decode(trim($json), true); // json_decode and UTF8 issues if (isset($return)) { return $return; } } include_once 'Zend/Json/Decoder.php'; return Zend_Json_Decoder::decode($json); }
[ "public", "static", "function", "parseJSON", "(", "$", "json", ")", "{", "if", "(", "function_exists", "(", "'json_decode'", ")", ")", "{", "$", "return", "=", "json_decode", "(", "trim", "(", "$", "json", ")", ",", "true", ")", ";", "// json_decode and ...
Parses JSON into proper PHP type. @static @param string $json @return mixed
[ "Parses", "JSON", "into", "proper", "PHP", "type", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L1050-L1061
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.getDocumentID
public static function getDocumentID($source) { if ($source instanceof DOMDOCUMENT) { foreach(phpQuery::$documents as $id => $document) { if ($source->isSameNode($document->document)) { return $id; } } } else if ($source instanceof DOMNODE) { foreach(phpQuery::$documents as $id => $document) { if ($source->ownerDocument->isSameNode($document->document)) { return $id; } } } else if ($source instanceof phpQueryObject) { return $source->getDocumentID(); } else if (is_string($source) && isset(phpQuery::$documents[$source])) { return $source; } }
php
public static function getDocumentID($source) { if ($source instanceof DOMDOCUMENT) { foreach(phpQuery::$documents as $id => $document) { if ($source->isSameNode($document->document)) { return $id; } } } else if ($source instanceof DOMNODE) { foreach(phpQuery::$documents as $id => $document) { if ($source->ownerDocument->isSameNode($document->document)) { return $id; } } } else if ($source instanceof phpQueryObject) { return $source->getDocumentID(); } else if (is_string($source) && isset(phpQuery::$documents[$source])) { return $source; } }
[ "public", "static", "function", "getDocumentID", "(", "$", "source", ")", "{", "if", "(", "$", "source", "instanceof", "DOMDOCUMENT", ")", "{", "foreach", "(", "phpQuery", "::", "$", "documents", "as", "$", "id", "=>", "$", "document", ")", "{", "if", ...
Returns source's document ID. @param $source DOMNode|phpQueryObject @return string
[ "Returns", "source", "s", "document", "ID", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L1068-L1087
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.getDOMDocument
public static function getDOMDocument($source) { if ($source instanceof DOMDOCUMENT) { return $source; } $source = self::getDocumentID($source); return $source ? self::$documents[$id]['document'] : null; }
php
public static function getDOMDocument($source) { if ($source instanceof DOMDOCUMENT) { return $source; } $source = self::getDocumentID($source); return $source ? self::$documents[$id]['document'] : null; }
[ "public", "static", "function", "getDOMDocument", "(", "$", "source", ")", "{", "if", "(", "$", "source", "instanceof", "DOMDOCUMENT", ")", "{", "return", "$", "source", ";", "}", "$", "source", "=", "self", "::", "getDocumentID", "(", "$", "source", ")"...
Get DOMDocument object related to $source. Returns null if such document doesn't exist. @param $source DOMNode|phpQueryObject|string @return string
[ "Get", "DOMDocument", "object", "related", "to", "$source", ".", "Returns", "null", "if", "such", "document", "doesn", "t", "exist", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L1095-L1104
txj123/zilf
src/Zilf/DataCrawler/PhpQuery/phpQuery.php
phpQuery.merge
public static function merge($one, $two) { $elements = $one->elements; foreach($two->elements as $node) { $exists = false; foreach($elements as $node2) { if ($node2->isSameNode($node)) { $exists = true; } } if (! $exists) { $elements[] = $node; } } return $elements; // $one = $one->newInstance(); // $one->elements = $elements; // return $one; }
php
public static function merge($one, $two) { $elements = $one->elements; foreach($two->elements as $node) { $exists = false; foreach($elements as $node2) { if ($node2->isSameNode($node)) { $exists = true; } } if (! $exists) { $elements[] = $node; } } return $elements; // $one = $one->newInstance(); // $one->elements = $elements; // return $one; }
[ "public", "static", "function", "merge", "(", "$", "one", ",", "$", "two", ")", "{", "$", "elements", "=", "$", "one", "->", "elements", ";", "foreach", "(", "$", "two", "->", "elements", "as", "$", "node", ")", "{", "$", "exists", "=", "false", ...
Merge 2 phpQuery objects. @param array $one @param array $two @protected @todo node lists, phpQueryObject
[ "Merge", "2", "phpQuery", "objects", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/DataCrawler/PhpQuery/phpQuery.php#L1233-L1251
crysalead/sql-dialect
src/Statement/Behavior/HasOrder.php
HasOrder.order
public function order($fields = null) { if (!$fields) { return $this; } if ($fields = is_array($fields) ? $fields : func_get_args()) { $this->_parts['order'] = array_merge($this->_parts['order'], $this->_order($fields)); } return $this; }
php
public function order($fields = null) { if (!$fields) { return $this; } if ($fields = is_array($fields) ? $fields : func_get_args()) { $this->_parts['order'] = array_merge($this->_parts['order'], $this->_order($fields)); } return $this; }
[ "public", "function", "order", "(", "$", "fields", "=", "null", ")", "{", "if", "(", "!", "$", "fields", ")", "{", "return", "$", "this", ";", "}", "if", "(", "$", "fields", "=", "is_array", "(", "$", "fields", ")", "?", "$", "fields", ":", "fu...
Adds some order by fields to the query. @param string|array $fields The fields. @return object Returns `$this`.
[ "Adds", "some", "order", "by", "fields", "to", "the", "query", "." ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Behavior/HasOrder.php#L12-L21
crysalead/sql-dialect
src/Statement/Behavior/HasOrder.php
HasOrder._order
protected function _order($fields) { $direction = 'ASC'; $result = []; foreach ($fields as $field => $value) { if (!is_int($field)) { $result[$field] = $value; continue; } if (preg_match('/^(.*?)\s+((?:a|de)sc)$/i', $value, $match)) { $value = $match[1]; $dir = $match[2]; } else { $dir = $direction; } $result[$value] = $dir; } return $result; }
php
protected function _order($fields) { $direction = 'ASC'; $result = []; foreach ($fields as $field => $value) { if (!is_int($field)) { $result[$field] = $value; continue; } if (preg_match('/^(.*?)\s+((?:a|de)sc)$/i', $value, $match)) { $value = $match[1]; $dir = $match[2]; } else { $dir = $direction; } $result[$value] = $dir; } return $result; }
[ "protected", "function", "_order", "(", "$", "fields", ")", "{", "$", "direction", "=", "'ASC'", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "fields", "as", "$", "field", "=>", "$", "value", ")", "{", "if", "(", "!", "is_int", "(...
Order formatter helper method @param string|array $fields The fields. @return string Formatted fields.
[ "Order", "formatter", "helper", "method" ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Behavior/HasOrder.php#L29-L48
crysalead/sql-dialect
src/Statement/Behavior/HasOrder.php
HasOrder._buildOrder
protected function _buildOrder($aliases = []) { $result = []; foreach ($this->_parts['order'] as $column => $dir) { $column = $this->dialect()->name($column, $aliases); $result[] = "{$column} {$dir}"; } return $this->_buildClause('ORDER BY', join(', ', $result)); }
php
protected function _buildOrder($aliases = []) { $result = []; foreach ($this->_parts['order'] as $column => $dir) { $column = $this->dialect()->name($column, $aliases); $result[] = "{$column} {$dir}"; } return $this->_buildClause('ORDER BY', join(', ', $result)); }
[ "protected", "function", "_buildOrder", "(", "$", "aliases", "=", "[", "]", ")", "{", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "_parts", "[", "'order'", "]", "as", "$", "column", "=>", "$", "dir", ")", "{", "$", "colu...
Builds the `ORDER BY` clause. @return string The `ORDER BY` clause.
[ "Builds", "the", "ORDER", "BY", "clause", "." ]
train
https://github.com/crysalead/sql-dialect/blob/867a768086fb3eb539752671a0dd54b949fe9d79/src/Statement/Behavior/HasOrder.php#L55-L63
txj123/zilf
src/Zilf/Db/base/Widget.php
Widget.begin
public static function begin($config = []) { $config['class'] = get_called_class(); /* @var $widget Widget */ $widget = Zilf::createObject($config); self::$stack[] = $widget; return $widget; }
php
public static function begin($config = []) { $config['class'] = get_called_class(); /* @var $widget Widget */ $widget = Zilf::createObject($config); self::$stack[] = $widget; return $widget; }
[ "public", "static", "function", "begin", "(", "$", "config", "=", "[", "]", ")", "{", "$", "config", "[", "'class'", "]", "=", "get_called_class", "(", ")", ";", "/* @var $widget Widget */", "$", "widget", "=", "Zilf", "::", "createObject", "(", "$", "co...
Begins a widget. This method creates an instance of the calling class. It will apply the configuration to the created instance. A matching [[end()]] call should be called later. As some widgets may use output buffering, the [[end()]] call should be made in the same view to avoid breaking the nesting of output buffers. @param array $config name-value pairs that will be used to initialize the object properties @return static the newly created widget instance @see end()
[ "Begins", "a", "widget", ".", "This", "method", "creates", "an", "instance", "of", "the", "calling", "class", ".", "It", "will", "apply", "the", "configuration", "to", "the", "created", "instance", ".", "A", "matching", "[[", "end", "()", "]]", "call", "...
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Db/base/Widget.php#L86-L94
txj123/zilf
src/Zilf/Helpers/Html.php
Html.assetCss
public static function assetCss($url, $options = [], $urlName = 'default') { $html = ''; if (is_array($url)) { foreach ($url as $item) { $html .= self::getCssHtml($item, $options, $urlName); } } else { $html = self::getCssHtml($url, $options, $urlName); } return $html; }
php
public static function assetCss($url, $options = [], $urlName = 'default') { $html = ''; if (is_array($url)) { foreach ($url as $item) { $html .= self::getCssHtml($item, $options, $urlName); } } else { $html = self::getCssHtml($url, $options, $urlName); } return $html; }
[ "public", "static", "function", "assetCss", "(", "$", "url", ",", "$", "options", "=", "[", "]", ",", "$", "urlName", "=", "'default'", ")", "{", "$", "html", "=", "''", ";", "if", "(", "is_array", "(", "$", "url", ")", ")", "{", "foreach", "(", ...
Generates a link tag that refers to an external CSS file. @param array|string $url the URL of the external CSS file. This parameter will be processed by [[Url::assetUrl()]]. @param array $options the tag options in terms of name-value pairs. The following option is specially handled: - condition: specifies the conditional comments for IE, e.g., `lt IE 9`. When this is specified, the generated `link` tag will be enclosed within the conditional comments. This is mainly useful for supporting old versions of IE browsers. - noscript: if set to true, `link` tag will be wrapped into `<noscript>` tags. The rest of the options will be rendered as the attributes of the resulting link tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. @param string $urlName @return string the generated link tag @see Url::assetUrl()
[ "Generates", "a", "link", "tag", "that", "refers", "to", "an", "external", "CSS", "file", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Helpers/Html.php#L156-L168
txj123/zilf
src/Zilf/Helpers/Html.php
Html.assetJs
public static function assetJs($url, $options = [], $urlName = 'default') { $html = ''; if (is_array($url)) { foreach ($url as $item) { $html .= self::getJsHtml($item, $options, $urlName); } } else { $html = self::getJsHtml($url, $options, $urlName); } return $html; }
php
public static function assetJs($url, $options = [], $urlName = 'default') { $html = ''; if (is_array($url)) { foreach ($url as $item) { $html .= self::getJsHtml($item, $options, $urlName); } } else { $html = self::getJsHtml($url, $options, $urlName); } return $html; }
[ "public", "static", "function", "assetJs", "(", "$", "url", ",", "$", "options", "=", "[", "]", ",", "$", "urlName", "=", "'default'", ")", "{", "$", "html", "=", "''", ";", "if", "(", "is_array", "(", "$", "url", ")", ")", "{", "foreach", "(", ...
Generates a script tag that refers to an external JavaScript file. @param string $url the URL of the external JavaScript file. This parameter will be processed by [[Url::assetUrl()]]. @param array $options the tag options in terms of name-value pairs. The following option is specially handled: - condition: specifies the conditional comments for IE, e.g., `lt IE 9`. When this is specified, the generated `script` tag will be enclosed within the conditional comments. This is mainly useful for supporting old versions of IE browsers. The rest of the options will be rendered as the attributes of the resulting script tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. @param string $urlName @return string the generated script tag @see Url::assetUrl()
[ "Generates", "a", "script", "tag", "that", "refers", "to", "an", "external", "JavaScript", "file", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Helpers/Html.php#L217-L229
txj123/zilf
src/Zilf/Helpers/Html.php
Html.a
public static function a($text, $url = null, $options = []) { if ($url !== null) { $options['href'] = Url::toRoute($url); } return static::tag('a', $text, $options); }
php
public static function a($text, $url = null, $options = []) { if ($url !== null) { $options['href'] = Url::toRoute($url); } return static::tag('a', $text, $options); }
[ "public", "static", "function", "a", "(", "$", "text", ",", "$", "url", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "url", "!==", "null", ")", "{", "$", "options", "[", "'href'", "]", "=", "Url", "::", "toRoute", ...
Generates a hyperlink tag. @param string $text link body. It will NOT be HTML-encoded. Therefore you can pass in HTML code such as an image tag. If this is coming from end users, you should consider [[encode()]] it to prevent XSS attacks. @param array|string|null $url the URL for the hyperlink tag. This parameter will be processed by [[Url::toRoute()]] and will be used for the "href" attribute of the tag. If this parameter is null, the "href" attribute will not be generated. If you want to use an absolute url you can call [[Url::assetUrl()]] yourself, before passing the URL to this method, like this: ```php Html::a('link text', Url::toRoute($url, true)) ``` @param array $options the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. @return string the generated hyperlink @see \Zilf\Helpers\Url::toRoute()
[ "Generates", "a", "hyperlink", "tag", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Helpers/Html.php#L272-L278
txj123/zilf
src/Zilf/Helpers/Html.php
Html.assetImg
public static function assetImg($src, $options = [], $urlName= 'default') { $html = ''; if (is_array($src)) { foreach ($src as $item) { $html .= self::getImgHtml($item, $options, $urlName); } } else { $html = self::getImgHtml($src, $options, $urlName); } return $html; }
php
public static function assetImg($src, $options = [], $urlName= 'default') { $html = ''; if (is_array($src)) { foreach ($src as $item) { $html .= self::getImgHtml($item, $options, $urlName); } } else { $html = self::getImgHtml($src, $options, $urlName); } return $html; }
[ "public", "static", "function", "assetImg", "(", "$", "src", ",", "$", "options", "=", "[", "]", ",", "$", "urlName", "=", "'default'", ")", "{", "$", "html", "=", "''", ";", "if", "(", "is_array", "(", "$", "src", ")", ")", "{", "foreach", "(", ...
Generates an image tag. @param array|string $src the image URL. This parameter will be processed by [[Url::toRoute()]]. @param array $options the tag options in terms of name-value pairs. These will be rendered as the attributes of the resulting tag. The values will be HTML-encoded using [[encode()]]. If a value is null, the corresponding attribute will not be rendered. See [[renderTagAttributes()]] for details on how attributes are being rendered. @param string $urlName @return string the generated image tag
[ "Generates", "an", "image", "tag", "." ]
train
https://github.com/txj123/zilf/blob/8fc979ae338e850e6f40bfb97d4d57869f9e4480/src/Zilf/Helpers/Html.php#L313-L325
krafthaus/bauhaus
src/controllers/ModelController.php
ModelController.index
public function index($name) { $model = Bauhaus::getInstance($name) ->buildList() ->buildFilters() ->buildScopes(); return View::make($model->getView('list')) ->with('name', $name) ->with('model', $model); }
php
public function index($name) { $model = Bauhaus::getInstance($name) ->buildList() ->buildFilters() ->buildScopes(); return View::make($model->getView('list')) ->with('name', $name) ->with('model', $model); }
[ "public", "function", "index", "(", "$", "name", ")", "{", "$", "model", "=", "Bauhaus", "::", "getInstance", "(", "$", "name", ")", "->", "buildList", "(", ")", "->", "buildFilters", "(", ")", "->", "buildScopes", "(", ")", ";", "return", "View", ":...
Display a listing of the resource. @param string $name @access public @return Response
[ "Display", "a", "listing", "of", "the", "resource", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/controllers/ModelController.php#L37-L47
krafthaus/bauhaus
src/controllers/ModelController.php
ModelController.create
public function create($name) { $model = Bauhaus::getInstance($name)->buildForm(); return View::make($model->getView('create')) ->with('name', $name) ->with('model', $model); }
php
public function create($name) { $model = Bauhaus::getInstance($name)->buildForm(); return View::make($model->getView('create')) ->with('name', $name) ->with('model', $model); }
[ "public", "function", "create", "(", "$", "name", ")", "{", "$", "model", "=", "Bauhaus", "::", "getInstance", "(", "$", "name", ")", "->", "buildForm", "(", ")", ";", "return", "View", "::", "make", "(", "$", "model", "->", "getView", "(", "'create'...
Show the form for creating a new resource. @param string $model @access public @return Response
[ "Show", "the", "form", "for", "creating", "a", "new", "resource", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/controllers/ModelController.php#L57-L64
krafthaus/bauhaus
src/controllers/ModelController.php
ModelController.store
public function store($name) { $model = Bauhaus::getInstance($name); $result = $model->buildForm() ->getFormBuilder() ->create(Input::except('_token')); // Check validation errors if (get_class($result) == 'Illuminate\Validation\Validator') { Session::flash('message.error', trans('bauhaus::messages.error.validation-errors')); return Redirect::route('admin.model.create', [$name]) ->withInput() ->withErrors($result); } // Set the flash message Session::flash('message.success', trans('bauhaus::messages.success.model-created', [ 'model' => $model->getSingularName() ])); // afterStore hook if (method_exists($model, 'afterStore')) { return $model->afterStore(Redirect::route('admin.model.index', $name)); } return Redirect::route('admin.model.index', $name); }
php
public function store($name) { $model = Bauhaus::getInstance($name); $result = $model->buildForm() ->getFormBuilder() ->create(Input::except('_token')); // Check validation errors if (get_class($result) == 'Illuminate\Validation\Validator') { Session::flash('message.error', trans('bauhaus::messages.error.validation-errors')); return Redirect::route('admin.model.create', [$name]) ->withInput() ->withErrors($result); } // Set the flash message Session::flash('message.success', trans('bauhaus::messages.success.model-created', [ 'model' => $model->getSingularName() ])); // afterStore hook if (method_exists($model, 'afterStore')) { return $model->afterStore(Redirect::route('admin.model.index', $name)); } return Redirect::route('admin.model.index', $name); }
[ "public", "function", "store", "(", "$", "name", ")", "{", "$", "model", "=", "Bauhaus", "::", "getInstance", "(", "$", "name", ")", ";", "$", "result", "=", "$", "model", "->", "buildForm", "(", ")", "->", "getFormBuilder", "(", ")", "->", "create",...
Store a newly created resource in storage. @param string $name @access public @return Response
[ "Store", "a", "newly", "created", "resource", "in", "storage", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/controllers/ModelController.php#L74-L100
krafthaus/bauhaus
src/controllers/ModelController.php
ModelController.edit
public function edit($name, $id) { $model = Bauhaus::getInstance($name)->buildForm($id); return View::make($model->getView('edit')) ->with('name', $name) ->with('model', $model) ->with('id', $id); }
php
public function edit($name, $id) { $model = Bauhaus::getInstance($name)->buildForm($id); return View::make($model->getView('edit')) ->with('name', $name) ->with('model', $model) ->with('id', $id); }
[ "public", "function", "edit", "(", "$", "name", ",", "$", "id", ")", "{", "$", "model", "=", "Bauhaus", "::", "getInstance", "(", "$", "name", ")", "->", "buildForm", "(", "$", "id", ")", ";", "return", "View", "::", "make", "(", "$", "model", "-...
Show the form for editing the specified resource. @param string $name @param int $id @access public @return Response
[ "Show", "the", "form", "for", "editing", "the", "specified", "resource", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/controllers/ModelController.php#L111-L119
krafthaus/bauhaus
src/controllers/ModelController.php
ModelController.update
public function update($name, $id) { $model = Bauhaus::getInstance($name); $result = $model->buildForm($id) ->getFormBuilder() ->update(Input::except('_token')); // Check validation errors if (get_class($result) == 'Illuminate\Validation\Validator') { Session::flash('message.error', trans('bauhaus::messages.error.validation-errors')); return Redirect::route('admin.model.edit', [$name, $id]) ->withInput() ->withErrors($result); } // Set the flash message Session::flash('message.success', trans('bauhaus::messages.success.model-updated', [ 'model' => $model->getSingularName() ])); // afterUpdate hook if (method_exists($model, 'afterUpdate')) { return $model->afterUpdate(Redirect::route('admin.model.index', $name)); } return Redirect::route('admin.model.index', $name); }
php
public function update($name, $id) { $model = Bauhaus::getInstance($name); $result = $model->buildForm($id) ->getFormBuilder() ->update(Input::except('_token')); // Check validation errors if (get_class($result) == 'Illuminate\Validation\Validator') { Session::flash('message.error', trans('bauhaus::messages.error.validation-errors')); return Redirect::route('admin.model.edit', [$name, $id]) ->withInput() ->withErrors($result); } // Set the flash message Session::flash('message.success', trans('bauhaus::messages.success.model-updated', [ 'model' => $model->getSingularName() ])); // afterUpdate hook if (method_exists($model, 'afterUpdate')) { return $model->afterUpdate(Redirect::route('admin.model.index', $name)); } return Redirect::route('admin.model.index', $name); }
[ "public", "function", "update", "(", "$", "name", ",", "$", "id", ")", "{", "$", "model", "=", "Bauhaus", "::", "getInstance", "(", "$", "name", ")", ";", "$", "result", "=", "$", "model", "->", "buildForm", "(", "$", "id", ")", "->", "getFormBuild...
Update the specified resource in storage. @param string $name @param int $id @access public @return Response
[ "Update", "the", "specified", "resource", "in", "storage", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/controllers/ModelController.php#L130-L156
krafthaus/bauhaus
src/controllers/ModelController.php
ModelController.multiDestroy
public function multiDestroy($name) { $items = Input::get('delete'); $model = Bauhaus::getInstance($name); if (count($items) === 0) { return Redirect::route('admin.model.index', $name); } foreach ($items as $id => $item) { $model->buildForm($id) ->getFormBuilder() ->destroy(); } // Set the flash message Session::flash('message.success', trans('bauhaus::messages.success.model-deleted', [ 'count' => (count($items) > 1 ? 'multiple' : 'one'), 'model' => $model->getPluralName() ])); // afterMultiDestroy hook if (method_exists($model, 'afterMultiDestroy')) { return $model->afterMultiDestroy(Redirect::route('admin.model.index', $name)); } return Redirect::route('admin.model.index', $name); }
php
public function multiDestroy($name) { $items = Input::get('delete'); $model = Bauhaus::getInstance($name); if (count($items) === 0) { return Redirect::route('admin.model.index', $name); } foreach ($items as $id => $item) { $model->buildForm($id) ->getFormBuilder() ->destroy(); } // Set the flash message Session::flash('message.success', trans('bauhaus::messages.success.model-deleted', [ 'count' => (count($items) > 1 ? 'multiple' : 'one'), 'model' => $model->getPluralName() ])); // afterMultiDestroy hook if (method_exists($model, 'afterMultiDestroy')) { return $model->afterMultiDestroy(Redirect::route('admin.model.index', $name)); } return Redirect::route('admin.model.index', $name); }
[ "public", "function", "multiDestroy", "(", "$", "name", ")", "{", "$", "items", "=", "Input", "::", "get", "(", "'delete'", ")", ";", "$", "model", "=", "Bauhaus", "::", "getInstance", "(", "$", "name", ")", ";", "if", "(", "count", "(", "$", "item...
Remove the specified resources from storage. @param string $model @param int $id @access public @return Response
[ "Remove", "the", "specified", "resources", "from", "storage", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/controllers/ModelController.php#L167-L194
krafthaus/bauhaus
src/controllers/ModelController.php
ModelController.export
public function export($name, $type) { $model = Bauhaus::getInstance($name) ->buildList() ->buildFilters() ->buildScopes(); return $model->getExportBuilder() ->export($type); }
php
public function export($name, $type) { $model = Bauhaus::getInstance($name) ->buildList() ->buildFilters() ->buildScopes(); return $model->getExportBuilder() ->export($type); }
[ "public", "function", "export", "(", "$", "name", ",", "$", "type", ")", "{", "$", "model", "=", "Bauhaus", "::", "getInstance", "(", "$", "name", ")", "->", "buildList", "(", ")", "->", "buildFilters", "(", ")", "->", "buildScopes", "(", ")", ";", ...
Export the current listing of the resources. @param string $name @param string $type @access public @return Response
[ "Export", "the", "current", "listing", "of", "the", "resources", "." ]
train
https://github.com/krafthaus/bauhaus/blob/02b6c5f4f7e5b5748d5300ab037feaff2a84ca80/src/controllers/ModelController.php#L205-L214
railken/search-query
src/Languages/BoomTree/Nodes/Node.php
Node.addChild
public function addChild(NodeContract $child) { $this->children[] = $child; $child->setParent($this); $child->setIndex(count($this->children) - 1); return $this; }
php
public function addChild(NodeContract $child) { $this->children[] = $child; $child->setParent($this); $child->setIndex(count($this->children) - 1); return $this; }
[ "public", "function", "addChild", "(", "NodeContract", "$", "child", ")", "{", "$", "this", "->", "children", "[", "]", "=", "$", "child", ";", "$", "child", "->", "setParent", "(", "$", "this", ")", ";", "$", "child", "->", "setIndex", "(", "count",...
Add a child. @param NodeContract $child @return $this
[ "Add", "a", "child", "." ]
train
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L140-L148
railken/search-query
src/Languages/BoomTree/Nodes/Node.php
Node.getChildByIndex
public function getChildByIndex($index) { return isset($this->children[$index]) ? $this->children[$index] : null; }
php
public function getChildByIndex($index) { return isset($this->children[$index]) ? $this->children[$index] : null; }
[ "public", "function", "getChildByIndex", "(", "$", "index", ")", "{", "return", "isset", "(", "$", "this", "->", "children", "[", "$", "index", "]", ")", "?", "$", "this", "->", "children", "[", "$", "index", "]", ":", "null", ";", "}" ]
Get a child by index. @param int $index @return NodeContract|null
[ "Get", "a", "child", "by", "index", "." ]
train
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L183-L186
railken/search-query
src/Languages/BoomTree/Nodes/Node.php
Node.prev
public function prev() { return $this->getParent() !== null ? $this->getParent()->getChildByIndex($this->getIndex() - 1) : null; }
php
public function prev() { return $this->getParent() !== null ? $this->getParent()->getChildByIndex($this->getIndex() - 1) : null; }
[ "public", "function", "prev", "(", ")", "{", "return", "$", "this", "->", "getParent", "(", ")", "!==", "null", "?", "$", "this", "->", "getParent", "(", ")", "->", "getChildByIndex", "(", "$", "this", "->", "getIndex", "(", ")", "-", "1", ")", ":"...
Retrieve prev node. @return NodeContract|null
[ "Retrieve", "prev", "node", "." ]
train
https://github.com/railken/search-query/blob/06e1bfb3eb59347afec9ca764d6f8c3b691d6889/src/Languages/BoomTree/Nodes/Node.php#L203-L206