id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
21,200
nabab/bbn
src/bbn/api/cloudmin.php
cloudmin.get_args
public function get_args($name){ if ( $this->checked ){ $cmd_name = str_replace('_', '-', $name); return isset($this->commands[$cmd_name], $this->commands[$cmd_name]['args']) ? $this->commands[$cmd_name]['args'] : []; } }
php
public function get_args($name){ if ( $this->checked ){ $cmd_name = str_replace('_', '-', $name); return isset($this->commands[$cmd_name], $this->commands[$cmd_name]['args']) ? $this->commands[$cmd_name]['args'] : []; } }
[ "public", "function", "get_args", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "checked", ")", "{", "$", "cmd_name", "=", "str_replace", "(", "'_'", ",", "'-'", ",", "$", "name", ")", ";", "return", "isset", "(", "$", "this", "->", "commands", "[", "$", "cmd_name", "]", ",", "$", "this", "->", "commands", "[", "$", "cmd_name", "]", "[", "'args'", "]", ")", "?", "$", "this", "->", "commands", "[", "$", "cmd_name", "]", "[", "'args'", "]", ":", "[", "]", ";", "}", "}" ]
Returns the arguments description of a given command @param $name The command name @return array
[ "Returns", "the", "arguments", "description", "of", "a", "given", "command" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/cloudmin.php#L310-L315
21,201
nabab/bbn
src/bbn/api/cloudmin.php
cloudmin.generate
public function generate($command){ $perl_cmd = str_replace('_', '-', $command); if ( isset($this->commands[$perl_cmd]) ){ $cmd = $this->commands[$perl_cmd]; $st = '$vm->'.$command.'(['.PHP_EOL; foreach ( $cmd['args'] as $k => $v ){ $st .= "'$k' => ".($v['binary'] ? '0' : "''").PHP_EOL; } $st .= ']);'; return $st; } return false; }
php
public function generate($command){ $perl_cmd = str_replace('_', '-', $command); if ( isset($this->commands[$perl_cmd]) ){ $cmd = $this->commands[$perl_cmd]; $st = '$vm->'.$command.'(['.PHP_EOL; foreach ( $cmd['args'] as $k => $v ){ $st .= "'$k' => ".($v['binary'] ? '0' : "''").PHP_EOL; } $st .= ']);'; return $st; } return false; }
[ "public", "function", "generate", "(", "$", "command", ")", "{", "$", "perl_cmd", "=", "str_replace", "(", "'_'", ",", "'-'", ",", "$", "command", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "commands", "[", "$", "perl_cmd", "]", ")", ")", "{", "$", "cmd", "=", "$", "this", "->", "commands", "[", "$", "perl_cmd", "]", ";", "$", "st", "=", "'$vm->'", ".", "$", "command", ".", "'(['", ".", "PHP_EOL", ";", "foreach", "(", "$", "cmd", "[", "'args'", "]", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "st", ".=", "\"'$k' => \"", ".", "(", "$", "v", "[", "'binary'", "]", "?", "'0'", ":", "\"''\"", ")", ".", "PHP_EOL", ";", "}", "$", "st", ".=", "']);'", ";", "return", "$", "st", ";", "}", "return", "false", ";", "}" ]
Returns a string of PHP code for executing a given command with all its possible parameters pre-populated @param $command @return bool|string
[ "Returns", "a", "string", "of", "PHP", "code", "for", "executing", "a", "given", "command", "with", "all", "its", "possible", "parameters", "pre", "-", "populated" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/api/cloudmin.php#L380-L392
21,202
alevilar/ristorantino-vendor
Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php
Hasar441FiscalHelper.openFiscalReceipt
public function openFiscalReceipt( $tipo_ticket ){ $tipo_ticket = $this->arrayMapTipoTicket[$tipo_ticket]; return "@".$this->cm('FS').$tipo_ticket.$this->cm('FS')."T"; }
php
public function openFiscalReceipt( $tipo_ticket ){ $tipo_ticket = $this->arrayMapTipoTicket[$tipo_ticket]; return "@".$this->cm('FS').$tipo_ticket.$this->cm('FS')."T"; }
[ "public", "function", "openFiscalReceipt", "(", "$", "tipo_ticket", ")", "{", "$", "tipo_ticket", "=", "$", "this", "->", "arrayMapTipoTicket", "[", "$", "tipo_ticket", "]", ";", "return", "\"@\"", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "tipo_ticket", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "\"T\"", ";", "}" ]
Me abre un documento fiscal @param $tipo_ticket el topo de ticket que quiero abrir las psobilidades son: "T": abre un ticket "A": abre ticket factura 'A' "B": abre ticket factura 'B' o 'C' "a": abre recibo 'A' "b": abre recibo 'B' "D": Nota de Débito 'A' "E": Nota de Débito B/C
[ "Me", "abre", "un", "documento", "fiscal" ]
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L47-L51
21,203
alevilar/ristorantino-vendor
Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php
Hasar441FiscalHelper.printFiscalText
public function printFiscalText($texto, $doble_ancho = false ,$display = 0){ $texto = substr($texto,0,30); if($doble_ancho){ $texto = $this->cm('DOBLE_ANCHO').$texto; } return "A".$this->cm('FS').$texto.$this->cm('FS').$display; }
php
public function printFiscalText($texto, $doble_ancho = false ,$display = 0){ $texto = substr($texto,0,30); if($doble_ancho){ $texto = $this->cm('DOBLE_ANCHO').$texto; } return "A".$this->cm('FS').$texto.$this->cm('FS').$display; }
[ "public", "function", "printFiscalText", "(", "$", "texto", ",", "$", "doble_ancho", "=", "false", ",", "$", "display", "=", "0", ")", "{", "$", "texto", "=", "substr", "(", "$", "texto", ",", "0", ",", "30", ")", ";", "if", "(", "$", "doble_ancho", ")", "{", "$", "texto", "=", "$", "this", "->", "cm", "(", "'DOBLE_ANCHO'", ")", ".", "$", "texto", ";", "}", "return", "\"A\"", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "texto", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "display", ";", "}" ]
Imprime texto fiscal que se muestra por lo general antes de los articulos. No puede contener la palabra TOTAL, porque se puede bloquear la impresora
[ "Imprime", "texto", "fiscal", "que", "se", "muestra", "por", "lo", "general", "antes", "de", "los", "articulos", ".", "No", "puede", "contener", "la", "palabra", "TOTAL", "porque", "se", "puede", "bloquear", "la", "impresora" ]
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L57-L63
21,204
alevilar/ristorantino-vendor
Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php
Hasar441FiscalHelper.setDateTime
public function setDateTime($fecha = 'now', $hora = 'now'){ $ymd = date("ymd",strtotime($fecha)) ; $his = date("His",strtotime($hora)) ; return "X".$this->cm('FS').$ymd.$this->cm('FS').$his; }
php
public function setDateTime($fecha = 'now', $hora = 'now'){ $ymd = date("ymd",strtotime($fecha)) ; $his = date("His",strtotime($hora)) ; return "X".$this->cm('FS').$ymd.$this->cm('FS').$his; }
[ "public", "function", "setDateTime", "(", "$", "fecha", "=", "'now'", ",", "$", "hora", "=", "'now'", ")", "{", "$", "ymd", "=", "date", "(", "\"ymd\"", ",", "strtotime", "(", "$", "fecha", ")", ")", ";", "$", "his", "=", "date", "(", "\"His\"", ",", "strtotime", "(", "$", "hora", ")", ")", ";", "return", "\"X\"", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "ymd", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "his", ";", "}" ]
Setea fecha y hora
[ "Setea", "fecha", "y", "hora" ]
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L189-L193
21,205
alevilar/ristorantino-vendor
Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php
Hasar441FiscalHelper.setHeaderTrailer
public function setHeaderTrailer($numero_de_linea,$texto = "-",$doble_ancho = false){ $texto = substr($texto,0,45); if ($numero_de_linea > -3 && $numero_de_linea <= 0){ $comando = "]".$this->cm('FS').$numero_de_linea; } if ($numero_de_linea > 0 && $numero_de_linea < 21){ if($doble_ancho){ $texto = $this->cm('DOBLE_ANCHO').$texto; } $comando = "]".$this->cm('FS').$numero_de_linea.$this->cm('FS').$texto; } else{ $comando = false; } return $comando; }
php
public function setHeaderTrailer($numero_de_linea,$texto = "-",$doble_ancho = false){ $texto = substr($texto,0,45); if ($numero_de_linea > -3 && $numero_de_linea <= 0){ $comando = "]".$this->cm('FS').$numero_de_linea; } if ($numero_de_linea > 0 && $numero_de_linea < 21){ if($doble_ancho){ $texto = $this->cm('DOBLE_ANCHO').$texto; } $comando = "]".$this->cm('FS').$numero_de_linea.$this->cm('FS').$texto; } else{ $comando = false; } return $comando; }
[ "public", "function", "setHeaderTrailer", "(", "$", "numero_de_linea", ",", "$", "texto", "=", "\"-\"", ",", "$", "doble_ancho", "=", "false", ")", "{", "$", "texto", "=", "substr", "(", "$", "texto", ",", "0", ",", "45", ")", ";", "if", "(", "$", "numero_de_linea", ">", "-", "3", "&&", "$", "numero_de_linea", "<=", "0", ")", "{", "$", "comando", "=", "\"]\"", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "numero_de_linea", ";", "}", "if", "(", "$", "numero_de_linea", ">", "0", "&&", "$", "numero_de_linea", "<", "21", ")", "{", "if", "(", "$", "doble_ancho", ")", "{", "$", "texto", "=", "$", "this", "->", "cm", "(", "'DOBLE_ANCHO'", ")", ".", "$", "texto", ";", "}", "$", "comando", "=", "\"]\"", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "numero_de_linea", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "texto", ";", "}", "else", "{", "$", "comando", "=", "false", ";", "}", "return", "$", "comando", ";", "}" ]
Setea el encabezado y el pie de pagina @param integer $numero_de_linea ENCABEZADO: linea 1 - 10 COLA: linea 11 - 20 BORRA ENCABEZADO Y COLA: linea = 0 BORRA ENCABEZADO: numero linea = -1 BORRA COLA: numero linea = -2 @param $texto 45 caracteres maximo
[ "Setea", "el", "encabezado", "y", "el", "pie", "de", "pagina" ]
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L208-L223
21,206
alevilar/ristorantino-vendor
Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php
Hasar441FiscalHelper.setTrailer
public function setTrailer($linea ,$texto,$doble_ancho = false){ //COLA: linea 11 - 20 $texto = substr($texto,0,45); $comando = ''; if ($linea > -1 && $linea < 10){ if($doble_ancho){ $texto = $this->cm('DOBLE_ANCHO').$texto; } $numero_de_linea = 11+$linea; $comando = "]" . $this->cm('FS') . $numero_de_linea . $this->cm('FS') . $texto; } return $comando; }
php
public function setTrailer($linea ,$texto,$doble_ancho = false){ //COLA: linea 11 - 20 $texto = substr($texto,0,45); $comando = ''; if ($linea > -1 && $linea < 10){ if($doble_ancho){ $texto = $this->cm('DOBLE_ANCHO').$texto; } $numero_de_linea = 11+$linea; $comando = "]" . $this->cm('FS') . $numero_de_linea . $this->cm('FS') . $texto; } return $comando; }
[ "public", "function", "setTrailer", "(", "$", "linea", ",", "$", "texto", ",", "$", "doble_ancho", "=", "false", ")", "{", "//COLA: \t\tlinea 11 - 20", "$", "texto", "=", "substr", "(", "$", "texto", ",", "0", ",", "45", ")", ";", "$", "comando", "=", "''", ";", "if", "(", "$", "linea", ">", "-", "1", "&&", "$", "linea", "<", "10", ")", "{", "if", "(", "$", "doble_ancho", ")", "{", "$", "texto", "=", "$", "this", "->", "cm", "(", "'DOBLE_ANCHO'", ")", ".", "$", "texto", ";", "}", "$", "numero_de_linea", "=", "11", "+", "$", "linea", ";", "$", "comando", "=", "\"]\"", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "numero_de_linea", ".", "$", "this", "->", "cm", "(", "'FS'", ")", ".", "$", "texto", ";", "}", "return", "$", "comando", ";", "}" ]
Setea el pie de pagina @param integer $linea de 0 a 9 @param string $texto 45 caracteres maximo
[ "Setea", "el", "pie", "de", "pagina" ]
6b91a1e20cc0ba09a1968d77e3de6512cfa2d966
https://github.com/alevilar/ristorantino-vendor/blob/6b91a1e20cc0ba09a1968d77e3de6512cfa2d966/Printers/Lib/DriverView/Helper/Hasar441FiscalHelper.php#L285-L297
21,207
songshenzong/log
src/DataCollector/ViewCollector.php
ViewCollector.addView
public function addView(View $view) { $name = $view->getName(); $path = $view->getPath(); if (!is_object($path)) { if ($path) { $path = ltrim(str_replace(base_path(), '', realpath($path)), '/'); } if (substr($path, -10) == '.blade.php') { $type = 'blade'; } else { $type = pathinfo($path, PATHINFO_EXTENSION); } } else { $type = get_class($view); $path = ''; } if (!$this->collect_data) { $params = array_keys($view->getData()); } else { $data = []; foreach ($view->getData() as $key => $value) { $data[$key] = $this->exporter->exportValue($value); } $params = $data; } $this->templates[] = [ 'name' => $path ? sprintf('%s (%s)', $name, $path) : $name, 'param_count' => count($params), 'params' => $params, 'type' => $type, ]; }
php
public function addView(View $view) { $name = $view->getName(); $path = $view->getPath(); if (!is_object($path)) { if ($path) { $path = ltrim(str_replace(base_path(), '', realpath($path)), '/'); } if (substr($path, -10) == '.blade.php') { $type = 'blade'; } else { $type = pathinfo($path, PATHINFO_EXTENSION); } } else { $type = get_class($view); $path = ''; } if (!$this->collect_data) { $params = array_keys($view->getData()); } else { $data = []; foreach ($view->getData() as $key => $value) { $data[$key] = $this->exporter->exportValue($value); } $params = $data; } $this->templates[] = [ 'name' => $path ? sprintf('%s (%s)', $name, $path) : $name, 'param_count' => count($params), 'params' => $params, 'type' => $type, ]; }
[ "public", "function", "addView", "(", "View", "$", "view", ")", "{", "$", "name", "=", "$", "view", "->", "getName", "(", ")", ";", "$", "path", "=", "$", "view", "->", "getPath", "(", ")", ";", "if", "(", "!", "is_object", "(", "$", "path", ")", ")", "{", "if", "(", "$", "path", ")", "{", "$", "path", "=", "ltrim", "(", "str_replace", "(", "base_path", "(", ")", ",", "''", ",", "realpath", "(", "$", "path", ")", ")", ",", "'/'", ")", ";", "}", "if", "(", "substr", "(", "$", "path", ",", "-", "10", ")", "==", "'.blade.php'", ")", "{", "$", "type", "=", "'blade'", ";", "}", "else", "{", "$", "type", "=", "pathinfo", "(", "$", "path", ",", "PATHINFO_EXTENSION", ")", ";", "}", "}", "else", "{", "$", "type", "=", "get_class", "(", "$", "view", ")", ";", "$", "path", "=", "''", ";", "}", "if", "(", "!", "$", "this", "->", "collect_data", ")", "{", "$", "params", "=", "array_keys", "(", "$", "view", "->", "getData", "(", ")", ")", ";", "}", "else", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "view", "->", "getData", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "data", "[", "$", "key", "]", "=", "$", "this", "->", "exporter", "->", "exportValue", "(", "$", "value", ")", ";", "}", "$", "params", "=", "$", "data", ";", "}", "$", "this", "->", "templates", "[", "]", "=", "[", "'name'", "=>", "$", "path", "?", "sprintf", "(", "'%s (%s)'", ",", "$", "name", ",", "$", "path", ")", ":", "$", "name", ",", "'param_count'", "=>", "count", "(", "$", "params", ")", ",", "'params'", "=>", "$", "params", ",", "'type'", "=>", "$", "type", ",", "]", ";", "}" ]
Add a View instance to the Collector @param \Illuminate\View\View $view
[ "Add", "a", "View", "instance", "to", "the", "Collector" ]
b1e01f7994da47737866eabf82367490eab17c46
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/DataCollector/ViewCollector.php#L52-L88
21,208
RhubarbPHP/Module.RestApi
src/Resources/ModelRestResource.php
ModelRestResource.getSummaryColumns
protected function getSummaryColumns() { $columns = []; $model = $this->getSampleModel(); $columnName = $model->getLabelColumnName(); if ($columnName != "") { $columns[] = $columnName; } return $columns; }
php
protected function getSummaryColumns() { $columns = []; $model = $this->getSampleModel(); $columnName = $model->getLabelColumnName(); if ($columnName != "") { $columns[] = $columnName; } return $columns; }
[ "protected", "function", "getSummaryColumns", "(", ")", "{", "$", "columns", "=", "[", "]", ";", "$", "model", "=", "$", "this", "->", "getSampleModel", "(", ")", ";", "$", "columnName", "=", "$", "model", "->", "getLabelColumnName", "(", ")", ";", "if", "(", "$", "columnName", "!=", "\"\"", ")", "{", "$", "columns", "[", "]", "=", "$", "columnName", ";", "}", "return", "$", "columns", ";", "}" ]
Override to control the columns returned in HEAD requests @return string[]
[ "Override", "to", "control", "the", "columns", "returned", "in", "HEAD", "requests" ]
825d2b920caed13811971c5eb2784a94417787bd
https://github.com/RhubarbPHP/Module.RestApi/blob/825d2b920caed13811971c5eb2784a94417787bd/src/Resources/ModelRestResource.php#L210-L222
21,209
hametuha/wpametu
src/WPametu/UI/Field/GeoPoint.php
GeoPoint.get_field
protected function get_field( \WP_Post $post ){ $field = parent::get_field($post); $automatic = $this->original_callback ? ' original' : ''; $geocder = $this->show_geocoder ? $this->geocoder() : ''; return <<<HTML {$field} <div id="{$this->name}-map" class="wpametu-map{$automatic}"></div> {$geocder} HTML; }
php
protected function get_field( \WP_Post $post ){ $field = parent::get_field($post); $automatic = $this->original_callback ? ' original' : ''; $geocder = $this->show_geocoder ? $this->geocoder() : ''; return <<<HTML {$field} <div id="{$this->name}-map" class="wpametu-map{$automatic}"></div> {$geocder} HTML; }
[ "protected", "function", "get_field", "(", "\\", "WP_Post", "$", "post", ")", "{", "$", "field", "=", "parent", "::", "get_field", "(", "$", "post", ")", ";", "$", "automatic", "=", "$", "this", "->", "original_callback", "?", "' original'", ":", "''", ";", "$", "geocder", "=", "$", "this", "->", "show_geocoder", "?", "$", "this", "->", "geocoder", "(", ")", ":", "''", ";", "return", " <<<HTML\n {$field}\n <div id=\"{$this->name}-map\" class=\"wpametu-map{$automatic}\"></div>\n {$geocder}\nHTML", ";", "}" ]
Add map canvas @param \WP_Post $post @return string
[ "Add", "map", "canvas" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/GeoPoint.php#L51-L61
21,210
hametuha/wpametu
src/WPametu/UI/Field/GeoPoint.php
GeoPoint.geocoder
protected function geocoder(){ $helper = $this->__('Input address'); $btn = $this->__('Move point'); $fail = esc_attr($this->__('Sorry, but nothing found with input address')); return <<<HTML <p> <input type="text" class="gmap-geocoder regular-text" placeholder="{$helper}" /> <a class="button gmap-geocoder-btn" href="#" data-failure="{$fail}">{$btn}</a> </p> HTML; }
php
protected function geocoder(){ $helper = $this->__('Input address'); $btn = $this->__('Move point'); $fail = esc_attr($this->__('Sorry, but nothing found with input address')); return <<<HTML <p> <input type="text" class="gmap-geocoder regular-text" placeholder="{$helper}" /> <a class="button gmap-geocoder-btn" href="#" data-failure="{$fail}">{$btn}</a> </p> HTML; }
[ "protected", "function", "geocoder", "(", ")", "{", "$", "helper", "=", "$", "this", "->", "__", "(", "'Input address'", ")", ";", "$", "btn", "=", "$", "this", "->", "__", "(", "'Move point'", ")", ";", "$", "fail", "=", "esc_attr", "(", "$", "this", "->", "__", "(", "'Sorry, but nothing found with input address'", ")", ")", ";", "return", " <<<HTML\n <p>\n <input type=\"text\" class=\"gmap-geocoder regular-text\" placeholder=\"{$helper}\" />\n <a class=\"button gmap-geocoder-btn\" href=\"#\" data-failure=\"{$fail}\">{$btn}</a>\n </p>\nHTML", ";", "}" ]
Get GeoCoder input @return string
[ "Get", "GeoCoder", "input" ]
0939373800815a8396291143d2a57967340da5aa
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/UI/Field/GeoPoint.php#L103-L114
21,211
skmetaly/laravel-twitch-restful-api
src/API/Channels.php
Channels.channel
public function channel($channel) { $channel = $this->client->get(config('twitch-api.api_url') . '/kraken/channels/' . $channel); return $channel->json(); }
php
public function channel($channel) { $channel = $this->client->get(config('twitch-api.api_url') . '/kraken/channels/' . $channel); return $channel->json(); }
[ "public", "function", "channel", "(", "$", "channel", ")", "{", "$", "channel", "=", "$", "this", "->", "client", "->", "get", "(", "config", "(", "'twitch-api.api_url'", ")", ".", "'/kraken/channels/'", ".", "$", "channel", ")", ";", "return", "$", "channel", "->", "json", "(", ")", ";", "}" ]
Returns a channel object. @param $channel @return mixed
[ "Returns", "a", "channel", "object", "." ]
70c83e441deb411ade2e343ad5cb0339c90dc6c2
https://github.com/skmetaly/laravel-twitch-restful-api/blob/70c83e441deb411ade2e343ad5cb0339c90dc6c2/src/API/Channels.php#L25-L30
21,212
ekuiter/feature-php
FeaturePhp/ProductLine/ProductLine.php
ProductLine.getGeneratorSettings
public function getGeneratorSettings($generator) { return $this->settings->getOptional("generators", $generator, fphp\Generator\Settings::emptyInstance()); }
php
public function getGeneratorSettings($generator) { return $this->settings->getOptional("generators", $generator, fphp\Generator\Settings::emptyInstance()); }
[ "public", "function", "getGeneratorSettings", "(", "$", "generator", ")", "{", "return", "$", "this", "->", "settings", "->", "getOptional", "(", "\"generators\"", ",", "$", "generator", ",", "fphp", "\\", "Generator", "\\", "Settings", "::", "emptyInstance", "(", ")", ")", ";", "}" ]
Returns the product line's settings for a generator. @param string $generator @return \FeaturePhp\Generator\Settings
[ "Returns", "the", "product", "line", "s", "settings", "for", "a", "generator", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/ProductLine.php#L88-L90
21,213
ekuiter/feature-php
FeaturePhp/ProductLine/ProductLine.php
ProductLine.getProduct
public function getProduct($configuration = null) { if (!$configuration) $configuration = $this->getDefaultConfiguration(); return new Product($this, $configuration); }
php
public function getProduct($configuration = null) { if (!$configuration) $configuration = $this->getDefaultConfiguration(); return new Product($this, $configuration); }
[ "public", "function", "getProduct", "(", "$", "configuration", "=", "null", ")", "{", "if", "(", "!", "$", "configuration", ")", "$", "configuration", "=", "$", "this", "->", "getDefaultConfiguration", "(", ")", ";", "return", "new", "Product", "(", "$", "this", ",", "$", "configuration", ")", ";", "}" ]
Returns a product of the product line for a configuration. If the configuration is omitted, the default configuration is used. @param \FeaturePhp\Model\Configuration $configuration @return Product
[ "Returns", "a", "product", "of", "the", "product", "line", "for", "a", "configuration", ".", "If", "the", "configuration", "is", "omitted", "the", "default", "configuration", "is", "used", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/ProductLine.php#L98-L102
21,214
ekuiter/feature-php
FeaturePhp/ProductLine/ProductLine.php
ProductLine.trace
public function trace($artifact) { $featureName = str_replace("\"", "&quot;", $artifact->getFeature()->getName()); $xmlConfiguration = fphp\Model\XmlConfiguration::fromString( '<configuration><feature name="' . $featureName . '" automatic="undefined" manual="selected"/></configuration>'); $configuration = new fphp\Model\Configuration($this->getModel(), $xmlConfiguration); $product = new Product($this, $configuration, true); return $product->trace(); }
php
public function trace($artifact) { $featureName = str_replace("\"", "&quot;", $artifact->getFeature()->getName()); $xmlConfiguration = fphp\Model\XmlConfiguration::fromString( '<configuration><feature name="' . $featureName . '" automatic="undefined" manual="selected"/></configuration>'); $configuration = new fphp\Model\Configuration($this->getModel(), $xmlConfiguration); $product = new Product($this, $configuration, true); return $product->trace(); }
[ "public", "function", "trace", "(", "$", "artifact", ")", "{", "$", "featureName", "=", "str_replace", "(", "\"\\\"\"", ",", "\"&quot;\"", ",", "$", "artifact", "->", "getFeature", "(", ")", "->", "getName", "(", ")", ")", ";", "$", "xmlConfiguration", "=", "fphp", "\\", "Model", "\\", "XmlConfiguration", "::", "fromString", "(", "'<configuration><feature name=\"'", ".", "$", "featureName", ".", "'\" automatic=\"undefined\" manual=\"selected\"/></configuration>'", ")", ";", "$", "configuration", "=", "new", "fphp", "\\", "Model", "\\", "Configuration", "(", "$", "this", "->", "getModel", "(", ")", ",", "$", "xmlConfiguration", ")", ";", "$", "product", "=", "new", "Product", "(", "$", "this", ",", "$", "configuration", ",", "true", ")", ";", "return", "$", "product", "->", "trace", "(", ")", ";", "}" ]
Returns tracing links for an artifact. @param \FeaturePhp\Artifact\Artifact $artifact @return \FeaturePhp\Artifact\TracingLink[]
[ "Returns", "tracing", "links", "for", "an", "artifact", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/ProductLine.php#L109-L116
21,215
ekuiter/feature-php
FeaturePhp/ProductLine/ProductLine.php
ProductLine.renderTracingLinkAnalysis
public function renderTracingLinkAnalysis($artifact, $textOnly = false) { return (new fphp\Artifact\TracingLinkRenderer($this->trace($artifact)))->render($textOnly); }
php
public function renderTracingLinkAnalysis($artifact, $textOnly = false) { return (new fphp\Artifact\TracingLinkRenderer($this->trace($artifact)))->render($textOnly); }
[ "public", "function", "renderTracingLinkAnalysis", "(", "$", "artifact", ",", "$", "textOnly", "=", "false", ")", "{", "return", "(", "new", "fphp", "\\", "Artifact", "\\", "TracingLinkRenderer", "(", "$", "this", "->", "trace", "(", "$", "artifact", ")", ")", ")", "->", "render", "(", "$", "textOnly", ")", ";", "}" ]
Analyzes an artifact's tracing links by returning a web page. @param \FeaturePhp\Artifact\Artifact $artifact @param bool $textOnly whether to render text or HTML @return string
[ "Analyzes", "an", "artifact", "s", "tracing", "links", "by", "returning", "a", "web", "page", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/ProductLine.php#L124-L126
21,216
martin-helmich/flow-eventbroker
Classes/Helmich/EventBroker/Broker/Broker.php
Broker.initializeObject
public function initializeObject() { $this->queue = new \SplQueue(); $this->synchronousEventMap = $this->cache->get('DispatcherConfiguration_Synchronous'); $this->asynchronousEventMap = $this->cache->get('DispatcherConfiguration_Asynchronous'); if (FALSE === ($this->synchronousEventMap || $this->asynchronousEventMap)) { $this->buildEventMap(); $this->cache->set('DispatcherConfiguration_Asynchronous', $this->asynchronousEventMap); $this->cache->set('DispatcherConfiguration_Synchronous', $this->synchronousEventMap); } }
php
public function initializeObject() { $this->queue = new \SplQueue(); $this->synchronousEventMap = $this->cache->get('DispatcherConfiguration_Synchronous'); $this->asynchronousEventMap = $this->cache->get('DispatcherConfiguration_Asynchronous'); if (FALSE === ($this->synchronousEventMap || $this->asynchronousEventMap)) { $this->buildEventMap(); $this->cache->set('DispatcherConfiguration_Asynchronous', $this->asynchronousEventMap); $this->cache->set('DispatcherConfiguration_Synchronous', $this->synchronousEventMap); } }
[ "public", "function", "initializeObject", "(", ")", "{", "$", "this", "->", "queue", "=", "new", "\\", "SplQueue", "(", ")", ";", "$", "this", "->", "synchronousEventMap", "=", "$", "this", "->", "cache", "->", "get", "(", "'DispatcherConfiguration_Synchronous'", ")", ";", "$", "this", "->", "asynchronousEventMap", "=", "$", "this", "->", "cache", "->", "get", "(", "'DispatcherConfiguration_Asynchronous'", ")", ";", "if", "(", "FALSE", "===", "(", "$", "this", "->", "synchronousEventMap", "||", "$", "this", "->", "asynchronousEventMap", ")", ")", "{", "$", "this", "->", "buildEventMap", "(", ")", ";", "$", "this", "->", "cache", "->", "set", "(", "'DispatcherConfiguration_Asynchronous'", ",", "$", "this", "->", "asynchronousEventMap", ")", ";", "$", "this", "->", "cache", "->", "set", "(", "'DispatcherConfiguration_Synchronous'", ",", "$", "this", "->", "synchronousEventMap", ")", ";", "}", "}" ]
Initializes the broker. Loads the dispatching configuration from cache or builds it.
[ "Initializes", "the", "broker", ".", "Loads", "the", "dispatching", "configuration", "from", "cache", "or", "builds", "it", "." ]
a08dc966cfddbee4f8ea75d1c682320ac196352d
https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/Broker.php#L75-L89
21,217
martin-helmich/flow-eventbroker
Classes/Helmich/EventBroker/Broker/Broker.php
Broker.queueEvent
public function queueEvent($event) { $this->queue->enqueue($event); $class = get_class($event); foreach ($this->synchronousEventMap->getListenersForEvent($class) as $listener) { $this->invokeListener($listener, $event); } }
php
public function queueEvent($event) { $this->queue->enqueue($event); $class = get_class($event); foreach ($this->synchronousEventMap->getListenersForEvent($class) as $listener) { $this->invokeListener($listener, $event); } }
[ "public", "function", "queueEvent", "(", "$", "event", ")", "{", "$", "this", "->", "queue", "->", "enqueue", "(", "$", "event", ")", ";", "$", "class", "=", "get_class", "(", "$", "event", ")", ";", "foreach", "(", "$", "this", "->", "synchronousEventMap", "->", "getListenersForEvent", "(", "$", "class", ")", "as", "$", "listener", ")", "{", "$", "this", "->", "invokeListener", "(", "$", "listener", ",", "$", "event", ")", ";", "}", "}" ]
Enqueues an arbitrary event. @param mixed $event The event object to publish. @return void
[ "Enqueues", "an", "arbitrary", "event", "." ]
a08dc966cfddbee4f8ea75d1c682320ac196352d
https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/Broker.php#L99-L108
21,218
martin-helmich/flow-eventbroker
Classes/Helmich/EventBroker/Broker/Broker.php
Broker.flush
public function flush() { $this->queue->setIteratorMode(\SplQueue::IT_MODE_DELETE); foreach ($this->queue as $event) { $class = get_class($event); foreach ($this->asynchronousEventMap->getListenersForEvent($class) as $listener) { $this->invokeListener($listener, $event); } } }
php
public function flush() { $this->queue->setIteratorMode(\SplQueue::IT_MODE_DELETE); foreach ($this->queue as $event) { $class = get_class($event); foreach ($this->asynchronousEventMap->getListenersForEvent($class) as $listener) { $this->invokeListener($listener, $event); } } }
[ "public", "function", "flush", "(", ")", "{", "$", "this", "->", "queue", "->", "setIteratorMode", "(", "\\", "SplQueue", "::", "IT_MODE_DELETE", ")", ";", "foreach", "(", "$", "this", "->", "queue", "as", "$", "event", ")", "{", "$", "class", "=", "get_class", "(", "$", "event", ")", ";", "foreach", "(", "$", "this", "->", "asynchronousEventMap", "->", "getListenersForEvent", "(", "$", "class", ")", "as", "$", "listener", ")", "{", "$", "this", "->", "invokeListener", "(", "$", "listener", ",", "$", "event", ")", ";", "}", "}", "}" ]
Publishes queued events. @return void
[ "Publishes", "queued", "events", "." ]
a08dc966cfddbee4f8ea75d1c682320ac196352d
https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/Broker.php#L117-L130
21,219
martin-helmich/flow-eventbroker
Classes/Helmich/EventBroker/Broker/Broker.php
Broker.invokeListener
private function invokeListener($listener, $event) { if (is_array($listener)) { list($listenerClass, $method) = $listener; $listenerInstance = $this->objectManager->get($listenerClass); $listenerInstance->{$method}($event); } else { call_user_func($listener, $event); } }
php
private function invokeListener($listener, $event) { if (is_array($listener)) { list($listenerClass, $method) = $listener; $listenerInstance = $this->objectManager->get($listenerClass); $listenerInstance->{$method}($event); } else { call_user_func($listener, $event); } }
[ "private", "function", "invokeListener", "(", "$", "listener", ",", "$", "event", ")", "{", "if", "(", "is_array", "(", "$", "listener", ")", ")", "{", "list", "(", "$", "listenerClass", ",", "$", "method", ")", "=", "$", "listener", ";", "$", "listenerInstance", "=", "$", "this", "->", "objectManager", "->", "get", "(", "$", "listenerClass", ")", ";", "$", "listenerInstance", "->", "{", "$", "method", "}", "(", "$", "event", ")", ";", "}", "else", "{", "call_user_func", "(", "$", "listener", ",", "$", "event", ")", ";", "}", "}" ]
Invokes a listener for an event. @param callable $listener Any type of callable. @param object $event The event object. @return void @throws UnknownObjectException May be thrown when the listener class cannot be instantiated.
[ "Invokes", "a", "listener", "for", "an", "event", "." ]
a08dc966cfddbee4f8ea75d1c682320ac196352d
https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/Broker.php#L143-L156
21,220
martin-helmich/flow-eventbroker
Classes/Helmich/EventBroker/Broker/Broker.php
Broker.buildEventMap
private function buildEventMap() { $this->synchronousEventMap = new EventMapping(); $this->asynchronousEventMap = new EventMapping(); $eventMap = NULL; $annotationName = 'Helmich\\EventBroker\\Annotations\\Listener'; $classes = $this->reflectionService->getClassesContainingMethodsAnnotatedWith($annotationName); foreach ($classes as $class) { $classReflection = new ClassReflection($class); /** @var MethodReflection $method */ foreach ($classReflection->getMethods() as $method) { if ($this->reflectionService->isMethodAnnotatedWith($class, $method->getName(), $annotationName)) { /** @var Listener $annotation */ $annotation = $this->reflectionService->getMethodAnnotation( $class, $method->getName(), $annotationName ); $event = $annotation->event; $this ->getEventMap($annotation->synchronous) ->addListenerForEvent($event, [$class, $method->getName()]); } } } }
php
private function buildEventMap() { $this->synchronousEventMap = new EventMapping(); $this->asynchronousEventMap = new EventMapping(); $eventMap = NULL; $annotationName = 'Helmich\\EventBroker\\Annotations\\Listener'; $classes = $this->reflectionService->getClassesContainingMethodsAnnotatedWith($annotationName); foreach ($classes as $class) { $classReflection = new ClassReflection($class); /** @var MethodReflection $method */ foreach ($classReflection->getMethods() as $method) { if ($this->reflectionService->isMethodAnnotatedWith($class, $method->getName(), $annotationName)) { /** @var Listener $annotation */ $annotation = $this->reflectionService->getMethodAnnotation( $class, $method->getName(), $annotationName ); $event = $annotation->event; $this ->getEventMap($annotation->synchronous) ->addListenerForEvent($event, [$class, $method->getName()]); } } } }
[ "private", "function", "buildEventMap", "(", ")", "{", "$", "this", "->", "synchronousEventMap", "=", "new", "EventMapping", "(", ")", ";", "$", "this", "->", "asynchronousEventMap", "=", "new", "EventMapping", "(", ")", ";", "$", "eventMap", "=", "NULL", ";", "$", "annotationName", "=", "'Helmich\\\\EventBroker\\\\Annotations\\\\Listener'", ";", "$", "classes", "=", "$", "this", "->", "reflectionService", "->", "getClassesContainingMethodsAnnotatedWith", "(", "$", "annotationName", ")", ";", "foreach", "(", "$", "classes", "as", "$", "class", ")", "{", "$", "classReflection", "=", "new", "ClassReflection", "(", "$", "class", ")", ";", "/** @var MethodReflection $method */", "foreach", "(", "$", "classReflection", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "if", "(", "$", "this", "->", "reflectionService", "->", "isMethodAnnotatedWith", "(", "$", "class", ",", "$", "method", "->", "getName", "(", ")", ",", "$", "annotationName", ")", ")", "{", "/** @var Listener $annotation */", "$", "annotation", "=", "$", "this", "->", "reflectionService", "->", "getMethodAnnotation", "(", "$", "class", ",", "$", "method", "->", "getName", "(", ")", ",", "$", "annotationName", ")", ";", "$", "event", "=", "$", "annotation", "->", "event", ";", "$", "this", "->", "getEventMap", "(", "$", "annotation", "->", "synchronous", ")", "->", "addListenerForEvent", "(", "$", "event", ",", "[", "$", "class", ",", "$", "method", "->", "getName", "(", ")", "]", ")", ";", "}", "}", "}", "}" ]
Builds the event dispatching configuration.
[ "Builds", "the", "event", "dispatching", "configuration", "." ]
a08dc966cfddbee4f8ea75d1c682320ac196352d
https://github.com/martin-helmich/flow-eventbroker/blob/a08dc966cfddbee4f8ea75d1c682320ac196352d/Classes/Helmich/EventBroker/Broker/Broker.php#L163-L194
21,221
fccn/oai-pmh-core
src/schemas/ands_lom.php
ANDS_LOM.create_regObjects
protected function create_regObjects() { $this->working_node = $this->oai_pmh->addChild($this->working_node, 'lom:lom'); $this->working_node->setAttribute('xmlns:lom', "http://ltsc.ieee.org/xsd/LOM"); $this->working_node->setAttribute('xmlns:dc', "http://purl.org/dc/elements/1.1/"); }
php
protected function create_regObjects() { $this->working_node = $this->oai_pmh->addChild($this->working_node, 'lom:lom'); $this->working_node->setAttribute('xmlns:lom', "http://ltsc.ieee.org/xsd/LOM"); $this->working_node->setAttribute('xmlns:dc', "http://purl.org/dc/elements/1.1/"); }
[ "protected", "function", "create_regObjects", "(", ")", "{", "$", "this", "->", "working_node", "=", "$", "this", "->", "oai_pmh", "->", "addChild", "(", "$", "this", "->", "working_node", ",", "'lom:lom'", ")", ";", "$", "this", "->", "working_node", "->", "setAttribute", "(", "'xmlns:lom'", ",", "\"http://ltsc.ieee.org/xsd/LOM\"", ")", ";", "$", "this", "->", "working_node", "->", "setAttribute", "(", "'xmlns:dc'", ",", "\"http://purl.org/dc/elements/1.1/\"", ")", ";", "}" ]
Override create registry objects to use oai_lom as holder
[ "Override", "create", "registry", "objects", "to", "use", "oai_lom", "as", "holder" ]
a9c6852482c7bd7c48911a2165120325ecc27ea2
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_lom.php#L92-L97
21,222
fccn/oai-pmh-core
src/schemas/ands_lom.php
ANDS_LOM.generate_metadata
public function generate_metadata($lom_identifier, $res) { debug_message('****** In '.__FILE__.' function '.__FUNCTION__.' was called.'); $lom_data = new LOM_DataHolder(); $lom_data->setIdentifiers($lom_identifier, $this->def_catalog); //debug_var_dump('lom_data->lomdata', $lom_data->lomdata['general']); //debug_var_dump('result', $res->fetch(PDO::FETCH_OBJ)); $res->setFetchMode(\PDO::FETCH_CLASS, LOM_DataHolder::getKlass()); while ($row = $res->fetch()) { // debug_var_dump('lom_data', $lom_data); // debug_var_dump('query row', $row); $lom_data->combine($row); } $res->closeCursor(); //debug_var_dump('lom_data', $lom_data); //write metadata to XML $this->write_xml_meta($lom_data->to_array()); }
php
public function generate_metadata($lom_identifier, $res) { debug_message('****** In '.__FILE__.' function '.__FUNCTION__.' was called.'); $lom_data = new LOM_DataHolder(); $lom_data->setIdentifiers($lom_identifier, $this->def_catalog); //debug_var_dump('lom_data->lomdata', $lom_data->lomdata['general']); //debug_var_dump('result', $res->fetch(PDO::FETCH_OBJ)); $res->setFetchMode(\PDO::FETCH_CLASS, LOM_DataHolder::getKlass()); while ($row = $res->fetch()) { // debug_var_dump('lom_data', $lom_data); // debug_var_dump('query row', $row); $lom_data->combine($row); } $res->closeCursor(); //debug_var_dump('lom_data', $lom_data); //write metadata to XML $this->write_xml_meta($lom_data->to_array()); }
[ "public", "function", "generate_metadata", "(", "$", "lom_identifier", ",", "$", "res", ")", "{", "debug_message", "(", "'****** In '", ".", "__FILE__", ".", "' function '", ".", "__FUNCTION__", ".", "' was called.'", ")", ";", "$", "lom_data", "=", "new", "LOM_DataHolder", "(", ")", ";", "$", "lom_data", "->", "setIdentifiers", "(", "$", "lom_identifier", ",", "$", "this", "->", "def_catalog", ")", ";", "//debug_var_dump('lom_data->lomdata', $lom_data->lomdata['general']);", "//debug_var_dump('result', $res->fetch(PDO::FETCH_OBJ));", "$", "res", "->", "setFetchMode", "(", "\\", "PDO", "::", "FETCH_CLASS", ",", "LOM_DataHolder", "::", "getKlass", "(", ")", ")", ";", "while", "(", "$", "row", "=", "$", "res", "->", "fetch", "(", ")", ")", "{", "// debug_var_dump('lom_data', $lom_data);", "// debug_var_dump('query row', $row);", "$", "lom_data", "->", "combine", "(", "$", "row", ")", ";", "}", "$", "res", "->", "closeCursor", "(", ")", ";", "//debug_var_dump('lom_data', $lom_data);", "//write metadata to XML", "$", "this", "->", "write_xml_meta", "(", "$", "lom_data", "->", "to_array", "(", ")", ")", ";", "}" ]
Generates metadata xml
[ "Generates", "metadata", "xml" ]
a9c6852482c7bd7c48911a2165120325ecc27ea2
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_lom.php#L102-L120
21,223
fccn/oai-pmh-core
src/schemas/ands_lom.php
LOM_DataHolder.combine
public function combine($another) { debug_message(__CLASS__.'.'.__FUNCTION__." LLOM_DataHolder class is ".LOM_DataHolder::getKlass()); debug_message(__CLASS__.'.'.__FUNCTION__." another is ".get_class($another)); if (is_a($another, LOM_DataHolder::getKlass())) { debug_message('entering function '.__FUNCTION__.' in '.__CLASS__); // debug_var_dump("another", $another); //identifier if (empty($this->identifier)) { debug_message("LOM_DataHolder::identifier should not be empty!!"); $this->identifier = $another->identifier; } elseif (strcmp(substr($this->identifier, - strlen($another->identifier)), $another->identifier) !== 0) { // debug_var_dump('comparison', strcmp(substr($this->identifier, - strlen($another->identifier)), $another->identifier)); // debug_message("found a different identifier for this element ".$this->identifier." != ".$another->identifier); error_log("found a different identifier for this element ".$this->identifier." != ".$another->identifier); return; } debug_message("Identity ok. Adding elements"); //continue with other db elements $this->addElement('contributor', $another); $this->addElement('coverage', $another); $this->addElement('creator', $another); $this->addElement('date_', $another); $this->addElement('description', $another); $this->addElement('format_', $another); $this->addElement('language', $another); $this->addElement('publisher', $another); $this->addElement('relation', $another); $this->addElement('rights', $another); $this->addElement('source', $another); $this->addElement('subject', $another); $this->addElement('title', $another); $this->addElement('type_', $another); $this->addElement('thumbnail', $another); } }
php
public function combine($another) { debug_message(__CLASS__.'.'.__FUNCTION__." LLOM_DataHolder class is ".LOM_DataHolder::getKlass()); debug_message(__CLASS__.'.'.__FUNCTION__." another is ".get_class($another)); if (is_a($another, LOM_DataHolder::getKlass())) { debug_message('entering function '.__FUNCTION__.' in '.__CLASS__); // debug_var_dump("another", $another); //identifier if (empty($this->identifier)) { debug_message("LOM_DataHolder::identifier should not be empty!!"); $this->identifier = $another->identifier; } elseif (strcmp(substr($this->identifier, - strlen($another->identifier)), $another->identifier) !== 0) { // debug_var_dump('comparison', strcmp(substr($this->identifier, - strlen($another->identifier)), $another->identifier)); // debug_message("found a different identifier for this element ".$this->identifier." != ".$another->identifier); error_log("found a different identifier for this element ".$this->identifier." != ".$another->identifier); return; } debug_message("Identity ok. Adding elements"); //continue with other db elements $this->addElement('contributor', $another); $this->addElement('coverage', $another); $this->addElement('creator', $another); $this->addElement('date_', $another); $this->addElement('description', $another); $this->addElement('format_', $another); $this->addElement('language', $another); $this->addElement('publisher', $another); $this->addElement('relation', $another); $this->addElement('rights', $another); $this->addElement('source', $another); $this->addElement('subject', $another); $this->addElement('title', $another); $this->addElement('type_', $another); $this->addElement('thumbnail', $another); } }
[ "public", "function", "combine", "(", "$", "another", ")", "{", "debug_message", "(", "__CLASS__", ".", "'.'", ".", "__FUNCTION__", ".", "\" LLOM_DataHolder class is \"", ".", "LOM_DataHolder", "::", "getKlass", "(", ")", ")", ";", "debug_message", "(", "__CLASS__", ".", "'.'", ".", "__FUNCTION__", ".", "\" another is \"", ".", "get_class", "(", "$", "another", ")", ")", ";", "if", "(", "is_a", "(", "$", "another", ",", "LOM_DataHolder", "::", "getKlass", "(", ")", ")", ")", "{", "debug_message", "(", "'entering function '", ".", "__FUNCTION__", ".", "' in '", ".", "__CLASS__", ")", ";", "// debug_var_dump(\"another\", $another);", "//identifier", "if", "(", "empty", "(", "$", "this", "->", "identifier", ")", ")", "{", "debug_message", "(", "\"LOM_DataHolder::identifier should not be empty!!\"", ")", ";", "$", "this", "->", "identifier", "=", "$", "another", "->", "identifier", ";", "}", "elseif", "(", "strcmp", "(", "substr", "(", "$", "this", "->", "identifier", ",", "-", "strlen", "(", "$", "another", "->", "identifier", ")", ")", ",", "$", "another", "->", "identifier", ")", "!==", "0", ")", "{", "// debug_var_dump('comparison', strcmp(substr($this->identifier, - strlen($another->identifier)), $another->identifier));", "// debug_message(\"found a different identifier for this element \".$this->identifier.\" != \".$another->identifier);", "error_log", "(", "\"found a different identifier for this element \"", ".", "$", "this", "->", "identifier", ".", "\" != \"", ".", "$", "another", "->", "identifier", ")", ";", "return", ";", "}", "debug_message", "(", "\"Identity ok. Adding elements\"", ")", ";", "//continue with other db elements", "$", "this", "->", "addElement", "(", "'contributor'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'coverage'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'creator'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'date_'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'description'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'format_'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'language'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'publisher'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'relation'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'rights'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'source'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'subject'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'title'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'type_'", ",", "$", "another", ")", ";", "$", "this", "->", "addElement", "(", "'thumbnail'", ",", "$", "another", ")", ";", "}", "}" ]
Combines this object with another LOM_DataHolder object
[ "Combines", "this", "object", "with", "another", "LOM_DataHolder", "object" ]
a9c6852482c7bd7c48911a2165120325ecc27ea2
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_lom.php#L319-L354
21,224
fccn/oai-pmh-core
src/schemas/ands_lom.php
LOM_DataHolder.addElement
private function addElement($elem, $to_add) { //debug_var_dump("to_add->$elem", $to_add->$elem); if (isset($to_add->$elem) && !empty($to_add->$elem) && $to_add->$elem != ' ') {//&& !empty(str_replace(' ', '', $to_add->$elem)) ){ $elem_to_add = str_replace('&', '-and-', $to_add->$elem); //replace amperstamps for -and- if (!in_array($elem_to_add, $this->$elem)) { array_push($this->$elem, $elem_to_add); //debug_var_dump("this->$elem", $this->$elem); } } }
php
private function addElement($elem, $to_add) { //debug_var_dump("to_add->$elem", $to_add->$elem); if (isset($to_add->$elem) && !empty($to_add->$elem) && $to_add->$elem != ' ') {//&& !empty(str_replace(' ', '', $to_add->$elem)) ){ $elem_to_add = str_replace('&', '-and-', $to_add->$elem); //replace amperstamps for -and- if (!in_array($elem_to_add, $this->$elem)) { array_push($this->$elem, $elem_to_add); //debug_var_dump("this->$elem", $this->$elem); } } }
[ "private", "function", "addElement", "(", "$", "elem", ",", "$", "to_add", ")", "{", "//debug_var_dump(\"to_add->$elem\", $to_add->$elem);", "if", "(", "isset", "(", "$", "to_add", "->", "$", "elem", ")", "&&", "!", "empty", "(", "$", "to_add", "->", "$", "elem", ")", "&&", "$", "to_add", "->", "$", "elem", "!=", "' '", ")", "{", "//&& !empty(str_replace(' ', '', $to_add->$elem)) ){", "$", "elem_to_add", "=", "str_replace", "(", "'&'", ",", "'-and-'", ",", "$", "to_add", "->", "$", "elem", ")", ";", "//replace amperstamps for -and-", "if", "(", "!", "in_array", "(", "$", "elem_to_add", ",", "$", "this", "->", "$", "elem", ")", ")", "{", "array_push", "(", "$", "this", "->", "$", "elem", ",", "$", "elem_to_add", ")", ";", "//debug_var_dump(\"this->$elem\", $this->$elem);", "}", "}", "}" ]
adds a db element only if it is new
[ "adds", "a", "db", "element", "only", "if", "it", "is", "new" ]
a9c6852482c7bd7c48911a2165120325ecc27ea2
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_lom.php#L359-L369
21,225
fccn/oai-pmh-core
src/schemas/ands_lom.php
LOM_DataHolder.asVcard
private function asVcard($name) { $name = preg_replace('/\s\s+/i', '', $name); //remove extra white spaces $name = preg_replace('/[^A-Za-z0-9\x{002D}\x{002E}\x{00C0}-\x{00FF} -]/', '', $name); //remove special chars $name = trim($name); // trim $nm_expl = explode(' ', $name); $head = ''; if (in_array($nm_expl[0], array('Prof.', 'Professor', 'Dr.', 'Doutor' ))) { $head = array_shift($nm_expl); } $lastnm = array_pop($nm_expl); $n = $lastnm.';'.implode(' ', $nm_expl).';'.$head.';'; return "BEGIN:VCARD\nVERSION:4.0\nN:$n\nFN:$name\nEND:VCARD"; }
php
private function asVcard($name) { $name = preg_replace('/\s\s+/i', '', $name); //remove extra white spaces $name = preg_replace('/[^A-Za-z0-9\x{002D}\x{002E}\x{00C0}-\x{00FF} -]/', '', $name); //remove special chars $name = trim($name); // trim $nm_expl = explode(' ', $name); $head = ''; if (in_array($nm_expl[0], array('Prof.', 'Professor', 'Dr.', 'Doutor' ))) { $head = array_shift($nm_expl); } $lastnm = array_pop($nm_expl); $n = $lastnm.';'.implode(' ', $nm_expl).';'.$head.';'; return "BEGIN:VCARD\nVERSION:4.0\nN:$n\nFN:$name\nEND:VCARD"; }
[ "private", "function", "asVcard", "(", "$", "name", ")", "{", "$", "name", "=", "preg_replace", "(", "'/\\s\\s+/i'", ",", "''", ",", "$", "name", ")", ";", "//remove extra white spaces", "$", "name", "=", "preg_replace", "(", "'/[^A-Za-z0-9\\x{002D}\\x{002E}\\x{00C0}-\\x{00FF} -]/'", ",", "''", ",", "$", "name", ")", ";", "//remove special chars", "$", "name", "=", "trim", "(", "$", "name", ")", ";", "// trim", "$", "nm_expl", "=", "explode", "(", "' '", ",", "$", "name", ")", ";", "$", "head", "=", "''", ";", "if", "(", "in_array", "(", "$", "nm_expl", "[", "0", "]", ",", "array", "(", "'Prof.'", ",", "'Professor'", ",", "'Dr.'", ",", "'Doutor'", ")", ")", ")", "{", "$", "head", "=", "array_shift", "(", "$", "nm_expl", ")", ";", "}", "$", "lastnm", "=", "array_pop", "(", "$", "nm_expl", ")", ";", "$", "n", "=", "$", "lastnm", ".", "';'", ".", "implode", "(", "' '", ",", "$", "nm_expl", ")", ".", "';'", ".", "$", "head", ".", "';'", ";", "return", "\"BEGIN:VCARD\\nVERSION:4.0\\nN:$n\\nFN:$name\\nEND:VCARD\"", ";", "}" ]
turns the elements into a string formatted for VCard
[ "turns", "the", "elements", "into", "a", "string", "formatted", "for", "VCard" ]
a9c6852482c7bd7c48911a2165120325ecc27ea2
https://github.com/fccn/oai-pmh-core/blob/a9c6852482c7bd7c48911a2165120325ecc27ea2/src/schemas/ands_lom.php#L582-L595
21,226
nabab/bbn
src/bbn/mvc/view.php
view.get
public function get(array $data=null) { if ( $this->check() ){ if ( \is_null($this->content) ){ $this->content = file_get_contents($this->file); } if ( empty($this->content) ){ return ''; } if ( $this->checkers ){ $st = ''; foreach ( $this->checkers as $chk ){ $st .= file_get_contents($chk); } $this->content = $st.$this->content; } switch ( $this->ext ){ case 'js': // Language variables inclusions in the javascript files if ( !empty($this->lang_file) ){ $tmp = json_decode(file_get_contents($this->lang_file), true); $path = $this->plugin ? substr($this->path, \strlen($this->plugin) + 1) : $this->path; //die(var_dump(count($tmp), 'components/'.$this->path.'/'.$this->path, $tmp)); if ( $translations = $tmp['mvc/'.$path] ?? ($tmp['components/'.$path] ?? null) ){ $json = json_encode($translations); $tmp = <<<JAVASCRIPT (data) => { bbn.fn.autoExtend("lng", $json) }; JAVASCRIPT; $this->content = $tmp.$this->content; } unset($tmp, $translations); } return $this->content; case 'coffee': return $this->content; case 'css': return $this->content; case 'less': $less = new \lessc(); return $less->compile($this->content); case 'scss': $scss = new \Leafo\ScssPhp\Compiler(); return $scss->compile($this->content); case 'html': return empty($data) ? $this->content : bbn\tpl::render($this->content, $data); case 'php': $dir = getcwd(); chdir(dirname($this->file)); $r = bbn\mvc::include_php_view($this->file, $this->content, $data ?: []); chdir($dir); return $r; } } return false; }
php
public function get(array $data=null) { if ( $this->check() ){ if ( \is_null($this->content) ){ $this->content = file_get_contents($this->file); } if ( empty($this->content) ){ return ''; } if ( $this->checkers ){ $st = ''; foreach ( $this->checkers as $chk ){ $st .= file_get_contents($chk); } $this->content = $st.$this->content; } switch ( $this->ext ){ case 'js': // Language variables inclusions in the javascript files if ( !empty($this->lang_file) ){ $tmp = json_decode(file_get_contents($this->lang_file), true); $path = $this->plugin ? substr($this->path, \strlen($this->plugin) + 1) : $this->path; //die(var_dump(count($tmp), 'components/'.$this->path.'/'.$this->path, $tmp)); if ( $translations = $tmp['mvc/'.$path] ?? ($tmp['components/'.$path] ?? null) ){ $json = json_encode($translations); $tmp = <<<JAVASCRIPT (data) => { bbn.fn.autoExtend("lng", $json) }; JAVASCRIPT; $this->content = $tmp.$this->content; } unset($tmp, $translations); } return $this->content; case 'coffee': return $this->content; case 'css': return $this->content; case 'less': $less = new \lessc(); return $less->compile($this->content); case 'scss': $scss = new \Leafo\ScssPhp\Compiler(); return $scss->compile($this->content); case 'html': return empty($data) ? $this->content : bbn\tpl::render($this->content, $data); case 'php': $dir = getcwd(); chdir(dirname($this->file)); $r = bbn\mvc::include_php_view($this->file, $this->content, $data ?: []); chdir($dir); return $r; } } return false; }
[ "public", "function", "get", "(", "array", "$", "data", "=", "null", ")", "{", "if", "(", "$", "this", "->", "check", "(", ")", ")", "{", "if", "(", "\\", "is_null", "(", "$", "this", "->", "content", ")", ")", "{", "$", "this", "->", "content", "=", "file_get_contents", "(", "$", "this", "->", "file", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "content", ")", ")", "{", "return", "''", ";", "}", "if", "(", "$", "this", "->", "checkers", ")", "{", "$", "st", "=", "''", ";", "foreach", "(", "$", "this", "->", "checkers", "as", "$", "chk", ")", "{", "$", "st", ".=", "file_get_contents", "(", "$", "chk", ")", ";", "}", "$", "this", "->", "content", "=", "$", "st", ".", "$", "this", "->", "content", ";", "}", "switch", "(", "$", "this", "->", "ext", ")", "{", "case", "'js'", ":", "// Language variables inclusions in the javascript files", "if", "(", "!", "empty", "(", "$", "this", "->", "lang_file", ")", ")", "{", "$", "tmp", "=", "json_decode", "(", "file_get_contents", "(", "$", "this", "->", "lang_file", ")", ",", "true", ")", ";", "$", "path", "=", "$", "this", "->", "plugin", "?", "substr", "(", "$", "this", "->", "path", ",", "\\", "strlen", "(", "$", "this", "->", "plugin", ")", "+", "1", ")", ":", "$", "this", "->", "path", ";", "//die(var_dump(count($tmp), 'components/'.$this->path.'/'.$this->path, $tmp));", "if", "(", "$", "translations", "=", "$", "tmp", "[", "'mvc/'", ".", "$", "path", "]", "??", "(", "$", "tmp", "[", "'components/'", ".", "$", "path", "]", "??", "null", ")", ")", "{", "$", "json", "=", "json_encode", "(", "$", "translations", ")", ";", "$", "tmp", "=", " <<<JAVASCRIPT\n(data) => {\n bbn.fn.autoExtend(\"lng\", $json)\n};\nJAVASCRIPT", ";", "$", "this", "->", "content", "=", "$", "tmp", ".", "$", "this", "->", "content", ";", "}", "unset", "(", "$", "tmp", ",", "$", "translations", ")", ";", "}", "return", "$", "this", "->", "content", ";", "case", "'coffee'", ":", "return", "$", "this", "->", "content", ";", "case", "'css'", ":", "return", "$", "this", "->", "content", ";", "case", "'less'", ":", "$", "less", "=", "new", "\\", "lessc", "(", ")", ";", "return", "$", "less", "->", "compile", "(", "$", "this", "->", "content", ")", ";", "case", "'scss'", ":", "$", "scss", "=", "new", "\\", "Leafo", "\\", "ScssPhp", "\\", "Compiler", "(", ")", ";", "return", "$", "scss", "->", "compile", "(", "$", "this", "->", "content", ")", ";", "case", "'html'", ":", "return", "empty", "(", "$", "data", ")", "?", "$", "this", "->", "content", ":", "bbn", "\\", "tpl", "::", "render", "(", "$", "this", "->", "content", ",", "$", "data", ")", ";", "case", "'php'", ":", "$", "dir", "=", "getcwd", "(", ")", ";", "chdir", "(", "dirname", "(", "$", "this", "->", "file", ")", ")", ";", "$", "r", "=", "bbn", "\\", "mvc", "::", "include_php_view", "(", "$", "this", "->", "file", ",", "$", "this", "->", "content", ",", "$", "data", "?", ":", "[", "]", ")", ";", "chdir", "(", "$", "dir", ")", ";", "return", "$", "r", ";", "}", "}", "return", "false", ";", "}" ]
Processes the controller and checks whether it has been routed or not. @return bool
[ "Processes", "the", "controller", "and", "checks", "whether", "it", "has", "been", "routed", "or", "not", "." ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/mvc/view.php#L88-L144
21,227
songshenzong/log
src/SymfonyHttpDriver.php
SymfonyHttpDriver.setSessionValue
public function setSessionValue($name, $value) { // In Laravel 5.4 the session changed to use their own custom implementation // instead of the one from Symfony. One of the changes was the set method // that was changed to put. Here we check if we are using the new one. if (method_exists($this->session, 'driver') && $this->session->driver() instanceof \Illuminate\Contracts\Session\Session) { $this->session->put($name, $value); return; } $this->session->set($name, $value); }
php
public function setSessionValue($name, $value) { // In Laravel 5.4 the session changed to use their own custom implementation // instead of the one from Symfony. One of the changes was the set method // that was changed to put. Here we check if we are using the new one. if (method_exists($this->session, 'driver') && $this->session->driver() instanceof \Illuminate\Contracts\Session\Session) { $this->session->put($name, $value); return; } $this->session->set($name, $value); }
[ "public", "function", "setSessionValue", "(", "$", "name", ",", "$", "value", ")", "{", "// In Laravel 5.4 the session changed to use their own custom implementation", "// instead of the one from Symfony. One of the changes was the set method", "// that was changed to put. Here we check if we are using the new one.", "if", "(", "method_exists", "(", "$", "this", "->", "session", ",", "'driver'", ")", "&&", "$", "this", "->", "session", "->", "driver", "(", ")", "instanceof", "\\", "Illuminate", "\\", "Contracts", "\\", "Session", "\\", "Session", ")", "{", "$", "this", "->", "session", "->", "put", "(", "$", "name", ",", "$", "value", ")", ";", "return", ";", "}", "$", "this", "->", "session", "->", "set", "(", "$", "name", ",", "$", "value", ")", ";", "}" ]
Sets a value in the session @param string $name @param string $value
[ "Sets", "a", "value", "in", "the", "session" ]
b1e01f7994da47737866eabf82367490eab17c46
https://github.com/songshenzong/log/blob/b1e01f7994da47737866eabf82367490eab17c46/src/SymfonyHttpDriver.php#L63-L73
21,228
gregorybesson/PlaygroundCms
src/Form/Admin/Page.php
Page.getCmsCategories
public function getCmsCategories() { $categories = array('' => 'No category'); $results = $this->getEventManager() ->trigger(__FUNCTION__, $this, array( 'categories' => $categories )) ->last(); if ($results) { $categories = $results; } return $categories; }
php
public function getCmsCategories() { $categories = array('' => 'No category'); $results = $this->getEventManager() ->trigger(__FUNCTION__, $this, array( 'categories' => $categories )) ->last(); if ($results) { $categories = $results; } return $categories; }
[ "public", "function", "getCmsCategories", "(", ")", "{", "$", "categories", "=", "array", "(", "''", "=>", "'No category'", ")", ";", "$", "results", "=", "$", "this", "->", "getEventManager", "(", ")", "->", "trigger", "(", "__FUNCTION__", ",", "$", "this", ",", "array", "(", "'categories'", "=>", "$", "categories", ")", ")", "->", "last", "(", ")", ";", "if", "(", "$", "results", ")", "{", "$", "categories", "=", "$", "results", ";", "}", "return", "$", "categories", ";", "}" ]
An event is triggered so that the modules wishing to associate a category to a CMS page can add their own categories without adherence between the 2 modules @return array
[ "An", "event", "is", "triggered", "so", "that", "the", "modules", "wishing", "to", "associate", "a", "category", "to", "a", "CMS", "page", "can", "add", "their", "own", "categories", "without", "adherence", "between", "the", "2", "modules" ]
e929a283f2a6e82d4f248c930f7aa454ce20cbc3
https://github.com/gregorybesson/PlaygroundCms/blob/e929a283f2a6e82d4f248c930f7aa454ce20cbc3/src/Form/Admin/Page.php#L208-L223
21,229
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/schema.php
ezcDbSchema.createNewTable
static public function createNewTable( $fields, $indexes ) { self::initOptions(); $className = ezcDbSchema::$options->tableClassName; return new $className( $fields, $indexes ); }
php
static public function createNewTable( $fields, $indexes ) { self::initOptions(); $className = ezcDbSchema::$options->tableClassName; return new $className( $fields, $indexes ); }
[ "static", "public", "function", "createNewTable", "(", "$", "fields", ",", "$", "indexes", ")", "{", "self", "::", "initOptions", "(", ")", ";", "$", "className", "=", "ezcDbSchema", "::", "$", "options", "->", "tableClassName", ";", "return", "new", "$", "className", "(", "$", "fields", ",", "$", "indexes", ")", ";", "}" ]
Returns an object to represent a table in the schema. @param array(string=>ezcDbSchemaField) $fields @param array(string=>ezcDbSchemaIndex) $indexes @return ezcDbSchemaTable or an inherited class
[ "Returns", "an", "object", "to", "represent", "a", "table", "in", "the", "schema", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/DatabaseSchema/src/schema.php#L304-L309
21,230
oroinc/OroLayoutComponent
Extension/Theme/ThemeExtension.php
ThemeExtension.getPaths
protected function getPaths(ContextInterface $context) { if ($this->pathProvider instanceof ContextAwareInterface) { $this->pathProvider->setContext($context); } return $this->pathProvider->getPaths([]); }
php
protected function getPaths(ContextInterface $context) { if ($this->pathProvider instanceof ContextAwareInterface) { $this->pathProvider->setContext($context); } return $this->pathProvider->getPaths([]); }
[ "protected", "function", "getPaths", "(", "ContextInterface", "$", "context", ")", "{", "if", "(", "$", "this", "->", "pathProvider", "instanceof", "ContextAwareInterface", ")", "{", "$", "this", "->", "pathProvider", "->", "setContext", "(", "$", "context", ")", ";", "}", "return", "$", "this", "->", "pathProvider", "->", "getPaths", "(", "[", "]", ")", ";", "}" ]
Return paths that comes from provider and returns array of resource files @param ContextInterface $context @return array
[ "Return", "paths", "that", "comes", "from", "provider", "and", "returns", "array", "of", "resource", "files" ]
682a96672393d81c63728e47c4a4c3618c515be0
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Extension/Theme/ThemeExtension.php#L108-L115
21,231
inhere/php-librarys
src/Helpers/CurlHelper.php
CurlHelper.get
public static function get($url, array $params = [], array $headers = []) { if ($params) { $url .= (strpos($url, '?') ? '&' : '?') . http_build_query($params); } // $headers = [ 'Content-Type: application/json' ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //伪造网页来源地址,伪造来自百度的表单提交 // curl_setopt($ch, CURLOPT_REFERER, "http://www.baidu.com"); return self::execute($ch); }
php
public static function get($url, array $params = [], array $headers = []) { if ($params) { $url .= (strpos($url, '?') ? '&' : '?') . http_build_query($params); } // $headers = [ 'Content-Type: application/json' ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); //伪造网页来源地址,伪造来自百度的表单提交 // curl_setopt($ch, CURLOPT_REFERER, "http://www.baidu.com"); return self::execute($ch); }
[ "public", "static", "function", "get", "(", "$", "url", ",", "array", "$", "params", "=", "[", "]", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "if", "(", "$", "params", ")", "{", "$", "url", ".=", "(", "strpos", "(", "$", "url", ",", "'?'", ")", "?", "'&'", ":", "'?'", ")", ".", "http_build_query", "(", "$", "params", ")", ";", "}", "// $headers = [ 'Content-Type: application/json' ];", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "url", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HTTPHEADER", ",", "$", "headers", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "//伪造网页来源地址,伪造来自百度的表单提交", "// curl_setopt($ch, CURLOPT_REFERER, \"http://www.baidu.com\");", "return", "self", "::", "execute", "(", "$", "ch", ")", ";", "}" ]
send GET request @param string $url url @param array $params url params @param array $headers HEADER info @return string
[ "send", "GET", "request" ]
e6ca598685469794f310e3ab0e2bc19519cd0ae6
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/CurlHelper.php#L89-L106
21,232
inhere/php-librarys
src/Helpers/CurlHelper.php
CurlHelper.post
public static function post($url, array $data = [], array $headers = []) { // $headers = [ 'Content-Type: application/json' ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // 发送数据 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 执行HTTP请求 return self::execute($ch); }
php
public static function post($url, array $data = [], array $headers = []) { // $headers = [ 'Content-Type: application/json' ]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); // 发送数据 curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 执行HTTP请求 return self::execute($ch); }
[ "public", "static", "function", "post", "(", "$", "url", ",", "array", "$", "data", "=", "[", "]", ",", "array", "$", "headers", "=", "[", "]", ")", "{", "// $headers = [ 'Content-Type: application/json' ];", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "url", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "data", ")", ";", "// 发送数据", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_HTTPHEADER", ",", "$", "headers", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "// 执行HTTP请求", "return", "self", "::", "execute", "(", "$", "ch", ")", ";", "}" ]
send POST request @param string $url submit url @param array|string $data post data. array: form data, string: json data @param array $headers HEADER info @return string
[ "send", "POST", "request" ]
e6ca598685469794f310e3ab0e2bc19519cd0ae6
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Helpers/CurlHelper.php#L115-L129
21,233
adman9000/laravel-bittrex
src/BittrexAPI.php
BittrexAPI.marketRequest
public function marketRequest($segment, array $parameters=[]) { $baseUrl = $this->market_url; return $this->privateRequest($baseUrl, $segment, $parameters); }
php
public function marketRequest($segment, array $parameters=[]) { $baseUrl = $this->market_url; return $this->privateRequest($baseUrl, $segment, $parameters); }
[ "public", "function", "marketRequest", "(", "$", "segment", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "baseUrl", "=", "$", "this", "->", "market_url", ";", "return", "$", "this", "->", "privateRequest", "(", "$", "baseUrl", ",", "$", "segment", ",", "$", "parameters", ")", ";", "}" ]
Execute a market API request @param $segment @param array $parameters @return array
[ "Execute", "a", "market", "API", "request" ]
bd82b7926b23bd5e450b0a4232a91f176a78072d
https://github.com/adman9000/laravel-bittrex/blob/bd82b7926b23bd5e450b0a4232a91f176a78072d/src/BittrexAPI.php#L324-L327
21,234
adman9000/laravel-bittrex
src/BittrexAPI.php
BittrexAPI.accountRequest
public function accountRequest($segment, array $parameters=[]) { $baseUrl = $this->account_url; return $this->privateRequest($baseUrl, $segment, $parameters); }
php
public function accountRequest($segment, array $parameters=[]) { $baseUrl = $this->account_url; return $this->privateRequest($baseUrl, $segment, $parameters); }
[ "public", "function", "accountRequest", "(", "$", "segment", ",", "array", "$", "parameters", "=", "[", "]", ")", "{", "$", "baseUrl", "=", "$", "this", "->", "account_url", ";", "return", "$", "this", "->", "privateRequest", "(", "$", "baseUrl", ",", "$", "segment", ",", "$", "parameters", ")", ";", "}" ]
Execute an account API request @param $segment @param array $parameters @return array
[ "Execute", "an", "account", "API", "request" ]
bd82b7926b23bd5e450b0a4232a91f176a78072d
https://github.com/adman9000/laravel-bittrex/blob/bd82b7926b23bd5e450b0a4232a91f176a78072d/src/BittrexAPI.php#L336-L339
21,235
99designs/ergo-http
src/Transport.php
Transport._curlConnection
private function _curlConnection($request) { // create a new curl resource $curl = curl_init(); $method = $request->getRequestMethod(); $headers = array('Expect:'); // add existing headers into a flat string format foreach ($request->getHeaders() as $header) { $headers[] = rtrim($header->__toString()); } // set URL and other appropriate options curl_setopt($curl, CURLOPT_URL, $request->getUrl()); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_VERBOSE, false); curl_setopt($curl, CURLOPT_TIMEOUT_MS, $this->_timeout * 1000); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, $this->_connectTimeoutMs); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_PROTOCOLS, (CURLPROTO_HTTP | CURLPROTO_HTTPS)); curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, (CURLPROTO_HTTP | CURLPROTO_HTTPS)); // Prevents issues with curl timing out much faster than the specified timeout curl_setopt($curl, CURLOPT_NOSIGNAL, 1); if (isset($this->_ipFamily)) { curl_setopt($curl, CURLOPT_IPRESOLVE, $this->_ipFamily); } // enable proxy support if (isset($this->_proxy)) { curl_setopt($curl, CURLOPT_PROXY, $this->_proxy); } // enable http authentication if (isset($this->_auth)) { curl_setopt($curl, CURLOPT_USERPWD, $this->_auth); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); } if ($method == 'PUT' || $method == 'POST') { $headers[] = 'Content-Length: ' . strlen($request->getBody()); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getBody()); } elseif ($method == 'DELETE') { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); } // add HTTP headers curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); return $curl; }
php
private function _curlConnection($request) { // create a new curl resource $curl = curl_init(); $method = $request->getRequestMethod(); $headers = array('Expect:'); // add existing headers into a flat string format foreach ($request->getHeaders() as $header) { $headers[] = rtrim($header->__toString()); } // set URL and other appropriate options curl_setopt($curl, CURLOPT_URL, $request->getUrl()); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_VERBOSE, false); curl_setopt($curl, CURLOPT_TIMEOUT_MS, $this->_timeout * 1000); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT_MS, $this->_connectTimeoutMs); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($curl, CURLOPT_PROTOCOLS, (CURLPROTO_HTTP | CURLPROTO_HTTPS)); curl_setopt($curl, CURLOPT_REDIR_PROTOCOLS, (CURLPROTO_HTTP | CURLPROTO_HTTPS)); // Prevents issues with curl timing out much faster than the specified timeout curl_setopt($curl, CURLOPT_NOSIGNAL, 1); if (isset($this->_ipFamily)) { curl_setopt($curl, CURLOPT_IPRESOLVE, $this->_ipFamily); } // enable proxy support if (isset($this->_proxy)) { curl_setopt($curl, CURLOPT_PROXY, $this->_proxy); } // enable http authentication if (isset($this->_auth)) { curl_setopt($curl, CURLOPT_USERPWD, $this->_auth); curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); } if ($method == 'PUT' || $method == 'POST') { $headers[] = 'Content-Length: ' . strlen($request->getBody()); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_POSTFIELDS, $request->getBody()); } elseif ($method == 'DELETE') { curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); } // add HTTP headers curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); return $curl; }
[ "private", "function", "_curlConnection", "(", "$", "request", ")", "{", "// create a new curl resource", "$", "curl", "=", "curl_init", "(", ")", ";", "$", "method", "=", "$", "request", "->", "getRequestMethod", "(", ")", ";", "$", "headers", "=", "array", "(", "'Expect:'", ")", ";", "// add existing headers into a flat string format", "foreach", "(", "$", "request", "->", "getHeaders", "(", ")", "as", "$", "header", ")", "{", "$", "headers", "[", "]", "=", "rtrim", "(", "$", "header", "->", "__toString", "(", ")", ")", ";", "}", "// set URL and other appropriate options", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_URL", ",", "$", "request", "->", "getUrl", "(", ")", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_RETURNTRANSFER", ",", "true", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_HEADER", ",", "true", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_VERBOSE", ",", "false", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_TIMEOUT_MS", ",", "$", "this", "->", "_timeout", "*", "1000", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_CONNECTTIMEOUT_MS", ",", "$", "this", "->", "_connectTimeoutMs", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_SSL_VERIFYPEER", ",", "false", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_SSL_VERIFYHOST", ",", "false", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_PROTOCOLS", ",", "(", "CURLPROTO_HTTP", "|", "CURLPROTO_HTTPS", ")", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_REDIR_PROTOCOLS", ",", "(", "CURLPROTO_HTTP", "|", "CURLPROTO_HTTPS", ")", ")", ";", "// Prevents issues with curl timing out much faster than the specified timeout", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_NOSIGNAL", ",", "1", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_ipFamily", ")", ")", "{", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_IPRESOLVE", ",", "$", "this", "->", "_ipFamily", ")", ";", "}", "// enable proxy support", "if", "(", "isset", "(", "$", "this", "->", "_proxy", ")", ")", "{", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_PROXY", ",", "$", "this", "->", "_proxy", ")", ";", "}", "// enable http authentication", "if", "(", "isset", "(", "$", "this", "->", "_auth", ")", ")", "{", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_USERPWD", ",", "$", "this", "->", "_auth", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_HTTPAUTH", ",", "CURLAUTH_BASIC", ")", ";", "}", "if", "(", "$", "method", "==", "'PUT'", "||", "$", "method", "==", "'POST'", ")", "{", "$", "headers", "[", "]", "=", "'Content-Length: '", ".", "strlen", "(", "$", "request", "->", "getBody", "(", ")", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_CUSTOMREQUEST", ",", "$", "method", ")", ";", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_POSTFIELDS", ",", "$", "request", "->", "getBody", "(", ")", ")", ";", "}", "elseif", "(", "$", "method", "==", "'DELETE'", ")", "{", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_CUSTOMREQUEST", ",", "$", "method", ")", ";", "}", "// add HTTP headers", "curl_setopt", "(", "$", "curl", ",", "CURLOPT_HTTPHEADER", ",", "$", "headers", ")", ";", "return", "$", "curl", ";", "}" ]
Initializes the curl connection
[ "Initializes", "the", "curl", "connection" ]
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Transport.php#L75-L129
21,236
99designs/ergo-http
src/Transport.php
Transport._buildResponse
private function _buildResponse($response) { $sections = explode("\r\n\r\n", $response, 2); $body = isset($sections[1]) ? $sections[1] : NULL; $headers = array(); $headerlines = explode("\n", $sections[0]); // process status list($http, $code, $message) = explode(' ', $headerlines[0], 3); // process headers foreach (array_slice($headerlines, 1) as $headerline) { $headers[] = HeaderField::fromString($headerline); } $response = new Response($code, $headers, $body); return $response; }
php
private function _buildResponse($response) { $sections = explode("\r\n\r\n", $response, 2); $body = isset($sections[1]) ? $sections[1] : NULL; $headers = array(); $headerlines = explode("\n", $sections[0]); // process status list($http, $code, $message) = explode(' ', $headerlines[0], 3); // process headers foreach (array_slice($headerlines, 1) as $headerline) { $headers[] = HeaderField::fromString($headerline); } $response = new Response($code, $headers, $body); return $response; }
[ "private", "function", "_buildResponse", "(", "$", "response", ")", "{", "$", "sections", "=", "explode", "(", "\"\\r\\n\\r\\n\"", ",", "$", "response", ",", "2", ")", ";", "$", "body", "=", "isset", "(", "$", "sections", "[", "1", "]", ")", "?", "$", "sections", "[", "1", "]", ":", "NULL", ";", "$", "headers", "=", "array", "(", ")", ";", "$", "headerlines", "=", "explode", "(", "\"\\n\"", ",", "$", "sections", "[", "0", "]", ")", ";", "// process status", "list", "(", "$", "http", ",", "$", "code", ",", "$", "message", ")", "=", "explode", "(", "' '", ",", "$", "headerlines", "[", "0", "]", ",", "3", ")", ";", "// process headers", "foreach", "(", "array_slice", "(", "$", "headerlines", ",", "1", ")", "as", "$", "headerline", ")", "{", "$", "headers", "[", "]", "=", "HeaderField", "::", "fromString", "(", "$", "headerline", ")", ";", "}", "$", "response", "=", "new", "Response", "(", "$", "code", ",", "$", "headers", ",", "$", "body", ")", ";", "return", "$", "response", ";", "}" ]
Parses a response into headers and a body
[ "Parses", "a", "response", "into", "headers", "and", "a", "body" ]
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Transport.php#L134-L152
21,237
thelia-modules/CustomerGroup
EventListener/CustomerCustomerGroup.php
CustomerCustomerGroup.addCustomer
public function addCustomer(AddCustomerToCustomerGroupEvent $event) { (new CustomerCustomerGroupQuery()) ->filterByCustomerId($event->getCustomerId()) ->filterByCustomerGroupId($event->getCustomerGroupId()) ->findOneOrCreate() ->save(); }
php
public function addCustomer(AddCustomerToCustomerGroupEvent $event) { (new CustomerCustomerGroupQuery()) ->filterByCustomerId($event->getCustomerId()) ->filterByCustomerGroupId($event->getCustomerGroupId()) ->findOneOrCreate() ->save(); }
[ "public", "function", "addCustomer", "(", "AddCustomerToCustomerGroupEvent", "$", "event", ")", "{", "(", "new", "CustomerCustomerGroupQuery", "(", ")", ")", "->", "filterByCustomerId", "(", "$", "event", "->", "getCustomerId", "(", ")", ")", "->", "filterByCustomerGroupId", "(", "$", "event", "->", "getCustomerGroupId", "(", ")", ")", "->", "findOneOrCreate", "(", ")", "->", "save", "(", ")", ";", "}" ]
Add a customer to a customer group. @param AddCustomerToCustomerGroupEvent $event
[ "Add", "a", "customer", "to", "a", "customer", "group", "." ]
672cc64c686812f6a95cf0d702111f93d8c0e850
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/EventListener/CustomerCustomerGroup.php#L42-L49
21,238
nabab/bbn
src/bbn/time.php
time.compare
public function compare($date, $comparator) { //check if the argument $date is an instance of this class if ( $date instanceof $this){ $tmp = $date; } else { $tmp = new \bbn\time($date); } switch ( $comparator ){ case $comparator === '>': return $this->get_time() > $tmp->get_time(); break; case $comparator === '>=': return $this->get_time() >= $tmp->get_time(); break; case $comparator === '<': return $this->get_time() < $tmp->get_time(); break; case $comparator === '<=': return $this->get_time() <= $tmp->get_time(); break; case $comparator === '=': return $this->get_time() == $tmp->get_time(); break; } }
php
public function compare($date, $comparator) { //check if the argument $date is an instance of this class if ( $date instanceof $this){ $tmp = $date; } else { $tmp = new \bbn\time($date); } switch ( $comparator ){ case $comparator === '>': return $this->get_time() > $tmp->get_time(); break; case $comparator === '>=': return $this->get_time() >= $tmp->get_time(); break; case $comparator === '<': return $this->get_time() < $tmp->get_time(); break; case $comparator === '<=': return $this->get_time() <= $tmp->get_time(); break; case $comparator === '=': return $this->get_time() == $tmp->get_time(); break; } }
[ "public", "function", "compare", "(", "$", "date", ",", "$", "comparator", ")", "{", "//check if the argument $date is an instance of this class", "if", "(", "$", "date", "instanceof", "$", "this", ")", "{", "$", "tmp", "=", "$", "date", ";", "}", "else", "{", "$", "tmp", "=", "new", "\\", "bbn", "\\", "time", "(", "$", "date", ")", ";", "}", "switch", "(", "$", "comparator", ")", "{", "case", "$", "comparator", "===", "'>'", ":", "return", "$", "this", "->", "get_time", "(", ")", ">", "$", "tmp", "->", "get_time", "(", ")", ";", "break", ";", "case", "$", "comparator", "===", "'>='", ":", "return", "$", "this", "->", "get_time", "(", ")", ">=", "$", "tmp", "->", "get_time", "(", ")", ";", "break", ";", "case", "$", "comparator", "===", "'<'", ":", "return", "$", "this", "->", "get_time", "(", ")", "<", "$", "tmp", "->", "get_time", "(", ")", ";", "break", ";", "case", "$", "comparator", "===", "'<='", ":", "return", "$", "this", "->", "get_time", "(", ")", "<=", "$", "tmp", "->", "get_time", "(", ")", ";", "break", ";", "case", "$", "comparator", "===", "'='", ":", "return", "$", "this", "->", "get_time", "(", ")", "==", "$", "tmp", "->", "get_time", "(", ")", ";", "break", ";", "}", "}" ]
Compares two dates @param [String|Object] $date the string of the date to compare or an object of this class @param [String] $comparator allowed comparators '>','>=', '<','<=', '=' @return Boolean
[ "Compares", "two", "dates" ]
439fea2faa0de22fdaae2611833bab8061f40c37
https://github.com/nabab/bbn/blob/439fea2faa0de22fdaae2611833bab8061f40c37/src/bbn/time.php#L98-L124
21,239
wenbinye/PhalconX
src/Session/Adapter/Cache.php
Cache.write
public function write($sessionId, $data) { $this->cache->save($this->prefix . $sessionId, $data, $this->lifetime); }
php
public function write($sessionId, $data) { $this->cache->save($this->prefix . $sessionId, $data, $this->lifetime); }
[ "public", "function", "write", "(", "$", "sessionId", ",", "$", "data", ")", "{", "$", "this", "->", "cache", "->", "save", "(", "$", "this", "->", "prefix", ".", "$", "sessionId", ",", "$", "data", ",", "$", "this", "->", "lifetime", ")", ";", "}" ]
Writes the data to the table @param string $sessionId @param string $data
[ "Writes", "the", "data", "to", "the", "table" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Session/Adapter/Cache.php#L94-L97
21,240
wenbinye/PhalconX
src/Session/Adapter/Cache.php
Cache.destroy
public function destroy($session_id = null) { @session_unset(); if ($session_id === null) { $session_id = $this->getId(); } return $this->cache->delete($this->prefix.$session_id); }
php
public function destroy($session_id = null) { @session_unset(); if ($session_id === null) { $session_id = $this->getId(); } return $this->cache->delete($this->prefix.$session_id); }
[ "public", "function", "destroy", "(", "$", "session_id", "=", "null", ")", "{", "@", "session_unset", "(", ")", ";", "if", "(", "$", "session_id", "===", "null", ")", "{", "$", "session_id", "=", "$", "this", "->", "getId", "(", ")", ";", "}", "return", "$", "this", "->", "cache", "->", "delete", "(", "$", "this", "->", "prefix", ".", "$", "session_id", ")", ";", "}" ]
Destroyes the session
[ "Destroyes", "the", "session" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Session/Adapter/Cache.php#L103-L110
21,241
PHPPowertools/HTML5
src/PowerTools/HTML5/Serializer/OutputRules.php
HTML5_Serializer_OutputRules.text
public function text($ele) { if (isset($ele->parentNode) && isset($ele->parentNode->tagName) && HTML5_Elements::isA($ele->parentNode->localName, HTML5_Elements::TEXT_RAW)) { $this->wr($ele->data); return; } // FIXME: This probably needs some flags set. $this->wr($this->enc($ele->data)); }
php
public function text($ele) { if (isset($ele->parentNode) && isset($ele->parentNode->tagName) && HTML5_Elements::isA($ele->parentNode->localName, HTML5_Elements::TEXT_RAW)) { $this->wr($ele->data); return; } // FIXME: This probably needs some flags set. $this->wr($this->enc($ele->data)); }
[ "public", "function", "text", "(", "$", "ele", ")", "{", "if", "(", "isset", "(", "$", "ele", "->", "parentNode", ")", "&&", "isset", "(", "$", "ele", "->", "parentNode", "->", "tagName", ")", "&&", "HTML5_Elements", "::", "isA", "(", "$", "ele", "->", "parentNode", "->", "localName", ",", "HTML5_Elements", "::", "TEXT_RAW", ")", ")", "{", "$", "this", "->", "wr", "(", "$", "ele", "->", "data", ")", ";", "return", ";", "}", "// FIXME: This probably needs some flags set.", "$", "this", "->", "wr", "(", "$", "this", "->", "enc", "(", "$", "ele", "->", "data", ")", ")", ";", "}" ]
Write a text node. @param \DOMText $ele The text node to write.
[ "Write", "a", "text", "node", "." ]
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Serializer/OutputRules.php#L244-L252
21,242
PHPPowertools/HTML5
src/PowerTools/HTML5/Serializer/OutputRules.php
HTML5_Serializer_OutputRules.namespaceAttrs
protected function namespaceAttrs($ele) { if (!$this->xpath || $this->xpath->document !== $ele->ownerDocument) { $this->xpath = new \DOMXPath($ele->ownerDocument); } foreach ($this->xpath->query('namespace::*[not(.=../../namespace::*)]', $ele) as $nsNode) { if (!in_array($nsNode->nodeValue, $this->implicitNamespaces)) { $this->wr(' ')->wr($nsNode->nodeName)->wr('="')->wr($nsNode->nodeValue)->wr('"'); } } }
php
protected function namespaceAttrs($ele) { if (!$this->xpath || $this->xpath->document !== $ele->ownerDocument) { $this->xpath = new \DOMXPath($ele->ownerDocument); } foreach ($this->xpath->query('namespace::*[not(.=../../namespace::*)]', $ele) as $nsNode) { if (!in_array($nsNode->nodeValue, $this->implicitNamespaces)) { $this->wr(' ')->wr($nsNode->nodeName)->wr('="')->wr($nsNode->nodeValue)->wr('"'); } } }
[ "protected", "function", "namespaceAttrs", "(", "$", "ele", ")", "{", "if", "(", "!", "$", "this", "->", "xpath", "||", "$", "this", "->", "xpath", "->", "document", "!==", "$", "ele", "->", "ownerDocument", ")", "{", "$", "this", "->", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "ele", "->", "ownerDocument", ")", ";", "}", "foreach", "(", "$", "this", "->", "xpath", "->", "query", "(", "'namespace::*[not(.=../../namespace::*)]'", ",", "$", "ele", ")", "as", "$", "nsNode", ")", "{", "if", "(", "!", "in_array", "(", "$", "nsNode", "->", "nodeValue", ",", "$", "this", "->", "implicitNamespaces", ")", ")", "{", "$", "this", "->", "wr", "(", "' '", ")", "->", "wr", "(", "$", "nsNode", "->", "nodeName", ")", "->", "wr", "(", "'=\"'", ")", "->", "wr", "(", "$", "nsNode", "->", "nodeValue", ")", "->", "wr", "(", "'\"'", ")", ";", "}", "}", "}" ]
Write the namespace attributes @param \DOMNode $ele The element being written.
[ "Write", "the", "namespace", "attributes" ]
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Serializer/OutputRules.php#L280-L290
21,243
PHPPowertools/HTML5
src/PowerTools/HTML5/Serializer/OutputRules.php
HTML5_Serializer_OutputRules.closeTag
protected function closeTag($ele) { if ($this->outputMode == static::IM_IN_HTML || $ele->hasChildNodes()) { $this->wr('</')->wr($this->traverser->isLocalElement($ele) ? $ele->localName : $ele->tagName)->wr('>'); } }
php
protected function closeTag($ele) { if ($this->outputMode == static::IM_IN_HTML || $ele->hasChildNodes()) { $this->wr('</')->wr($this->traverser->isLocalElement($ele) ? $ele->localName : $ele->tagName)->wr('>'); } }
[ "protected", "function", "closeTag", "(", "$", "ele", ")", "{", "if", "(", "$", "this", "->", "outputMode", "==", "static", "::", "IM_IN_HTML", "||", "$", "ele", "->", "hasChildNodes", "(", ")", ")", "{", "$", "this", "->", "wr", "(", "'</'", ")", "->", "wr", "(", "$", "this", "->", "traverser", "->", "isLocalElement", "(", "$", "ele", ")", "?", "$", "ele", "->", "localName", ":", "$", "ele", "->", "tagName", ")", "->", "wr", "(", "'>'", ")", ";", "}", "}" ]
Write the closing tag. Tags for HTML, MathML, and SVG are in the local name. Otherwise, use the qualified name (8.3). @param \DOMNode $ele The element being written.
[ "Write", "the", "closing", "tag", "." ]
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Serializer/OutputRules.php#L415-L419
21,244
PHPPowertools/HTML5
src/PowerTools/HTML5/Serializer/OutputRules.php
HTML5_Serializer_OutputRules.enc
protected function enc($text, $attribute = false) { // Escape the text rather than convert to named character references. if (!$this->encode) { return $this->escape($text, $attribute); } // If we are in PHP 5.4+ we can use the native html5 entity functionality to // convert the named character references. if ($this->hasHTML5) { return htmlentities($text, ENT_HTML5 | ENT_SUBSTITUTE | ENT_QUOTES, 'UTF-8', false); } // If a version earlier than 5.4 html5 entities are not entirely handled. // This manually handles them. else { return strtr($text, HTML5_Serializer_HTML5Entities::$map); } }
php
protected function enc($text, $attribute = false) { // Escape the text rather than convert to named character references. if (!$this->encode) { return $this->escape($text, $attribute); } // If we are in PHP 5.4+ we can use the native html5 entity functionality to // convert the named character references. if ($this->hasHTML5) { return htmlentities($text, ENT_HTML5 | ENT_SUBSTITUTE | ENT_QUOTES, 'UTF-8', false); } // If a version earlier than 5.4 html5 entities are not entirely handled. // This manually handles them. else { return strtr($text, HTML5_Serializer_HTML5Entities::$map); } }
[ "protected", "function", "enc", "(", "$", "text", ",", "$", "attribute", "=", "false", ")", "{", "// Escape the text rather than convert to named character references.", "if", "(", "!", "$", "this", "->", "encode", ")", "{", "return", "$", "this", "->", "escape", "(", "$", "text", ",", "$", "attribute", ")", ";", "}", "// If we are in PHP 5.4+ we can use the native html5 entity functionality to", "// convert the named character references.", "if", "(", "$", "this", "->", "hasHTML5", ")", "{", "return", "htmlentities", "(", "$", "text", ",", "ENT_HTML5", "|", "ENT_SUBSTITUTE", "|", "ENT_QUOTES", ",", "'UTF-8'", ",", "false", ")", ";", "}", "// If a version earlier than 5.4 html5 entities are not entirely handled.", "// This manually handles them.", "else", "{", "return", "strtr", "(", "$", "text", ",", "HTML5_Serializer_HTML5Entities", "::", "$", "map", ")", ";", "}", "}" ]
Encode text. When encode is set to false, the default value, the text passed in is escaped per section 8.3 of the html5 spec. For details on how text is escaped see the escape() method. When encoding is set to true the text is converted to named character references where appropriate. Section 8.1.4 Character references of the html5 spec refers to using named character references. This is useful for characters that can't otherwise legally be used in the text. The named character references are listed in section 8.5. @see http://www.w3.org/TR/2013/CR-html5-20130806/syntax.html#named-character-references True encoding will turn all named character references into their entities. This includes such characters as +.# and many other common ones. By default encoding here will just escape &'<>". Note, PHP 5.4+ has better html5 encoding. @todo Use the Entities class in php 5.3 to have html5 entities. @param string $text text to encode. @param boolean $attribute True if we are encoding an attrubute, false otherwise @return string The encoded text.
[ "Encode", "text", "." ]
4ea8caf5b2618a82ca5061dcbb7421b31065c1c7
https://github.com/PHPPowertools/HTML5/blob/4ea8caf5b2618a82ca5061dcbb7421b31065c1c7/src/PowerTools/HTML5/Serializer/OutputRules.php#L473-L490
21,245
zhouyl/mellivora
Mellivora/Encryption/Crypt.php
Crypt.padText
protected function padText($text, $mode, $blockSize, $paddingType) { $paddingSize = 0; $padding = ''; if ($mode === 'cbc' || $mode === 'ecb') { $paddingSize = $blockSize - (strlen($text) % $blockSize); if ($paddingSize >= 256) { throw new InvalidArgumentException("Block size [$blockSize] is bigger than 256"); } switch ($paddingType) { case self::PADDING_ANSI_X_923: $padding = str_repeat(chr(0), $paddingSize - 1) . chr($paddingSize); break; case self::PADDING_PKCS7: $padding = str_repeat(chr($paddingSize), $paddingSize); break; case self::PADDING_ISO_10126: $padding = ''; foreach (range(0, $paddingSize - 2) as $i) { $padding .= chr(rand()); } $padding .= chr($paddingSize); break; case self::PADDING_ISO_IEC_7816_4: $padding = chr(0x80) . str_repeat(chr(0), $paddingSize - 1); break; case self::PADDING_ZERO: $padding = str_repeat(chr(0), $paddingSize); break; case self::PADDING_SPACE: $padding = str_repeat(' ', $paddingSize); break; default: $paddingSize = 0; break; } } if (!$paddingSize) { return $text; } if ($paddingSize > $blockSize) { throw new InvalidArgumentException("Invalid padding size [$paddingSize]"); } return $text . substr($padding, 0, $paddingSize); }
php
protected function padText($text, $mode, $blockSize, $paddingType) { $paddingSize = 0; $padding = ''; if ($mode === 'cbc' || $mode === 'ecb') { $paddingSize = $blockSize - (strlen($text) % $blockSize); if ($paddingSize >= 256) { throw new InvalidArgumentException("Block size [$blockSize] is bigger than 256"); } switch ($paddingType) { case self::PADDING_ANSI_X_923: $padding = str_repeat(chr(0), $paddingSize - 1) . chr($paddingSize); break; case self::PADDING_PKCS7: $padding = str_repeat(chr($paddingSize), $paddingSize); break; case self::PADDING_ISO_10126: $padding = ''; foreach (range(0, $paddingSize - 2) as $i) { $padding .= chr(rand()); } $padding .= chr($paddingSize); break; case self::PADDING_ISO_IEC_7816_4: $padding = chr(0x80) . str_repeat(chr(0), $paddingSize - 1); break; case self::PADDING_ZERO: $padding = str_repeat(chr(0), $paddingSize); break; case self::PADDING_SPACE: $padding = str_repeat(' ', $paddingSize); break; default: $paddingSize = 0; break; } } if (!$paddingSize) { return $text; } if ($paddingSize > $blockSize) { throw new InvalidArgumentException("Invalid padding size [$paddingSize]"); } return $text . substr($padding, 0, $paddingSize); }
[ "protected", "function", "padText", "(", "$", "text", ",", "$", "mode", ",", "$", "blockSize", ",", "$", "paddingType", ")", "{", "$", "paddingSize", "=", "0", ";", "$", "padding", "=", "''", ";", "if", "(", "$", "mode", "===", "'cbc'", "||", "$", "mode", "===", "'ecb'", ")", "{", "$", "paddingSize", "=", "$", "blockSize", "-", "(", "strlen", "(", "$", "text", ")", "%", "$", "blockSize", ")", ";", "if", "(", "$", "paddingSize", ">=", "256", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Block size [$blockSize] is bigger than 256\"", ")", ";", "}", "switch", "(", "$", "paddingType", ")", "{", "case", "self", "::", "PADDING_ANSI_X_923", ":", "$", "padding", "=", "str_repeat", "(", "chr", "(", "0", ")", ",", "$", "paddingSize", "-", "1", ")", ".", "chr", "(", "$", "paddingSize", ")", ";", "break", ";", "case", "self", "::", "PADDING_PKCS7", ":", "$", "padding", "=", "str_repeat", "(", "chr", "(", "$", "paddingSize", ")", ",", "$", "paddingSize", ")", ";", "break", ";", "case", "self", "::", "PADDING_ISO_10126", ":", "$", "padding", "=", "''", ";", "foreach", "(", "range", "(", "0", ",", "$", "paddingSize", "-", "2", ")", "as", "$", "i", ")", "{", "$", "padding", ".=", "chr", "(", "rand", "(", ")", ")", ";", "}", "$", "padding", ".=", "chr", "(", "$", "paddingSize", ")", ";", "break", ";", "case", "self", "::", "PADDING_ISO_IEC_7816_4", ":", "$", "padding", "=", "chr", "(", "0x80", ")", ".", "str_repeat", "(", "chr", "(", "0", ")", ",", "$", "paddingSize", "-", "1", ")", ";", "break", ";", "case", "self", "::", "PADDING_ZERO", ":", "$", "padding", "=", "str_repeat", "(", "chr", "(", "0", ")", ",", "$", "paddingSize", ")", ";", "break", ";", "case", "self", "::", "PADDING_SPACE", ":", "$", "padding", "=", "str_repeat", "(", "' '", ",", "$", "paddingSize", ")", ";", "break", ";", "default", ":", "$", "paddingSize", "=", "0", ";", "break", ";", "}", "}", "if", "(", "!", "$", "paddingSize", ")", "{", "return", "$", "text", ";", "}", "if", "(", "$", "paddingSize", ">", "$", "blockSize", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Invalid padding size [$paddingSize]\"", ")", ";", "}", "return", "$", "text", ".", "substr", "(", "$", "padding", ",", "0", ",", "$", "paddingSize", ")", ";", "}" ]
Pads texts before encryption @see http://www.di-mgt.com.au/cryptopad.html @param mixed $text @param mixed $mode @param mixed $blockSize @param mixed $paddingType
[ "Pads", "texts", "before", "encryption" ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Encryption/Crypt.php#L121-L177
21,246
zhouyl/mellivora
Mellivora/Encryption/Crypt.php
Crypt.encryptBase64
public function encryptBase64($text, $key = null, $safe = false) { if ($safe === true) { return strtr(base64_encode($this->encrypt($text, $key)), '+/', '-_'); } return base64_encode($this->encrypt($text, $key)); }
php
public function encryptBase64($text, $key = null, $safe = false) { if ($safe === true) { return strtr(base64_encode($this->encrypt($text, $key)), '+/', '-_'); } return base64_encode($this->encrypt($text, $key)); }
[ "public", "function", "encryptBase64", "(", "$", "text", ",", "$", "key", "=", "null", ",", "$", "safe", "=", "false", ")", "{", "if", "(", "$", "safe", "===", "true", ")", "{", "return", "strtr", "(", "base64_encode", "(", "$", "this", "->", "encrypt", "(", "$", "text", ",", "$", "key", ")", ")", ",", "'+/'", ",", "'-_'", ")", ";", "}", "return", "base64_encode", "(", "$", "this", "->", "encrypt", "(", "$", "text", ",", "$", "key", ")", ")", ";", "}" ]
Encrypts a text returning the result as a base64 string @param mixed $text @param null|mixed $key @param mixed $safe
[ "Encrypts", "a", "text", "returning", "the", "result", "as", "a", "base64", "string" ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Encryption/Crypt.php#L385-L392
21,247
zhouyl/mellivora
Mellivora/Encryption/Crypt.php
Crypt.decryptBase64
public function decryptBase64($text, $key = null, $safe = false) { if ($safe === true) { return $this->decrypt(base64_decode(strtr($text, '-_', '+/')), $key); } return $this->decrypt(base64_decode($text), $key); }
php
public function decryptBase64($text, $key = null, $safe = false) { if ($safe === true) { return $this->decrypt(base64_decode(strtr($text, '-_', '+/')), $key); } return $this->decrypt(base64_decode($text), $key); }
[ "public", "function", "decryptBase64", "(", "$", "text", ",", "$", "key", "=", "null", ",", "$", "safe", "=", "false", ")", "{", "if", "(", "$", "safe", "===", "true", ")", "{", "return", "$", "this", "->", "decrypt", "(", "base64_decode", "(", "strtr", "(", "$", "text", ",", "'-_'", ",", "'+/'", ")", ")", ",", "$", "key", ")", ";", "}", "return", "$", "this", "->", "decrypt", "(", "base64_decode", "(", "$", "text", ")", ",", "$", "key", ")", ";", "}" ]
Decrypt a text that is coded as a base64 string @param mixed $text @param null|mixed $key @param mixed $safe
[ "Decrypt", "a", "text", "that", "is", "coded", "as", "a", "base64", "string" ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Encryption/Crypt.php#L401-L408
21,248
grozzzny/catalog
models/Category.php
Category.getListItems
public function getListItems() { $item_arr = []; foreach ($this->items as $item) { $item_arr[$item->id] = $item->title; } return $item_arr; }
php
public function getListItems() { $item_arr = []; foreach ($this->items as $item) { $item_arr[$item->id] = $item->title; } return $item_arr; }
[ "public", "function", "getListItems", "(", ")", "{", "$", "item_arr", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "items", "as", "$", "item", ")", "{", "$", "item_arr", "[", "$", "item", "->", "id", "]", "=", "$", "item", "->", "title", ";", "}", "return", "$", "item_arr", ";", "}" ]
For special widget
[ "For", "special", "widget" ]
ff1cac10a5f3a89f3ef2767f9ede6b2d74e1849a
https://github.com/grozzzny/catalog/blob/ff1cac10a5f3a89f3ef2767f9ede6b2d74e1849a/models/Category.php#L293-L301
21,249
heidelpay/PhpDoc
src/phpDocumentor/Descriptor/Builder/Reflector/FunctionAssembler.php
FunctionAssembler.createArgumentDescriptor
protected function createArgumentDescriptor($functionDescriptor, $argument) { $params = $functionDescriptor->getTags()->get('param', array()); if (!$this->argumentAssembler->getBuilder()) { $this->argumentAssembler->setBuilder($this->builder); } return $this->argumentAssembler->create($argument, $params); }
php
protected function createArgumentDescriptor($functionDescriptor, $argument) { $params = $functionDescriptor->getTags()->get('param', array()); if (!$this->argumentAssembler->getBuilder()) { $this->argumentAssembler->setBuilder($this->builder); } return $this->argumentAssembler->create($argument, $params); }
[ "protected", "function", "createArgumentDescriptor", "(", "$", "functionDescriptor", ",", "$", "argument", ")", "{", "$", "params", "=", "$", "functionDescriptor", "->", "getTags", "(", ")", "->", "get", "(", "'param'", ",", "array", "(", ")", ")", ";", "if", "(", "!", "$", "this", "->", "argumentAssembler", "->", "getBuilder", "(", ")", ")", "{", "$", "this", "->", "argumentAssembler", "->", "setBuilder", "(", "$", "this", "->", "builder", ")", ";", "}", "return", "$", "this", "->", "argumentAssembler", "->", "create", "(", "$", "argument", ",", "$", "params", ")", ";", "}" ]
Creates a new ArgumentDescriptor from the given Reflector and Param. @param FunctionDescriptor $functionDescriptor @param FunctionReflector\ArgumentReflector $argument @return ArgumentDescriptor
[ "Creates", "a", "new", "ArgumentDescriptor", "from", "the", "given", "Reflector", "and", "Param", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Builder/Reflector/FunctionAssembler.php#L118-L127
21,250
kecik-framework/kecik
Kecik/Kecik.php
Kecik.createCallbackFromString
private function createCallbackFromString( $callFunc, $params ) { if ( is_string( $callFunc ) ) { $callFunc = function () use ( $callFunc, $params ) { $controllerParts = explode( '@', $callFunc ); $controllerParts[0] = explode( '\\', $controllerParts[0] ); $hmvc = ''; $controllerPaths = count( $controllerParts[0] ); if ( $controllerPaths > 1 ) { foreach ( $controllerParts[0] as $idx => $controllerPart ) { if ( $idx == ( $controllerPaths - 1 ) ) { break; } $hmvc .= '\\' . $controllerPart; } } $controller = $hmvc . '\\Controllers\\' . $controllerParts[0][ $controllerPaths - 1 ]; $c = new \ReflectionClass( $controller ); $c = $c->newInstanceArgs( $params ); return call_user_func_array( array( $c, $controllerParts[1] ), $this->route->getParams() ); }; return $callFunc; } return $callFunc; }
php
private function createCallbackFromString( $callFunc, $params ) { if ( is_string( $callFunc ) ) { $callFunc = function () use ( $callFunc, $params ) { $controllerParts = explode( '@', $callFunc ); $controllerParts[0] = explode( '\\', $controllerParts[0] ); $hmvc = ''; $controllerPaths = count( $controllerParts[0] ); if ( $controllerPaths > 1 ) { foreach ( $controllerParts[0] as $idx => $controllerPart ) { if ( $idx == ( $controllerPaths - 1 ) ) { break; } $hmvc .= '\\' . $controllerPart; } } $controller = $hmvc . '\\Controllers\\' . $controllerParts[0][ $controllerPaths - 1 ]; $c = new \ReflectionClass( $controller ); $c = $c->newInstanceArgs( $params ); return call_user_func_array( array( $c, $controllerParts[1] ), $this->route->getParams() ); }; return $callFunc; } return $callFunc; }
[ "private", "function", "createCallbackFromString", "(", "$", "callFunc", ",", "$", "params", ")", "{", "if", "(", "is_string", "(", "$", "callFunc", ")", ")", "{", "$", "callFunc", "=", "function", "(", ")", "use", "(", "$", "callFunc", ",", "$", "params", ")", "{", "$", "controllerParts", "=", "explode", "(", "'@'", ",", "$", "callFunc", ")", ";", "$", "controllerParts", "[", "0", "]", "=", "explode", "(", "'\\\\'", ",", "$", "controllerParts", "[", "0", "]", ")", ";", "$", "hmvc", "=", "''", ";", "$", "controllerPaths", "=", "count", "(", "$", "controllerParts", "[", "0", "]", ")", ";", "if", "(", "$", "controllerPaths", ">", "1", ")", "{", "foreach", "(", "$", "controllerParts", "[", "0", "]", "as", "$", "idx", "=>", "$", "controllerPart", ")", "{", "if", "(", "$", "idx", "==", "(", "$", "controllerPaths", "-", "1", ")", ")", "{", "break", ";", "}", "$", "hmvc", ".=", "'\\\\'", ".", "$", "controllerPart", ";", "}", "}", "$", "controller", "=", "$", "hmvc", ".", "'\\\\Controllers\\\\'", ".", "$", "controllerParts", "[", "0", "]", "[", "$", "controllerPaths", "-", "1", "]", ";", "$", "c", "=", "new", "\\", "ReflectionClass", "(", "$", "controller", ")", ";", "$", "c", "=", "$", "c", "->", "newInstanceArgs", "(", "$", "params", ")", ";", "return", "call_user_func_array", "(", "array", "(", "$", "c", ",", "$", "controllerParts", "[", "1", "]", ")", ",", "$", "this", "->", "route", "->", "getParams", "(", ")", ")", ";", "}", ";", "return", "$", "callFunc", ";", "}", "return", "$", "callFunc", ";", "}" ]
Create Callback from string @param $callFunc @param $params @return Closure
[ "Create", "Callback", "from", "string" ]
fa87e593affe1c9c51a2acd264b85ec06df31d7c
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Kecik.php#L376-L410
21,251
kecik-framework/kecik
Kecik/Kecik.php
Kecik.get
public function get() { $this->RoutedStatus = FALSE; if ( ! $this->route->isGet() ) { return $this; } if ( is_callable( $this->callable ) ) { //$this->RoutedStatus = FALSE; return $this; } $this->middleware = array( 'before' => array(), 'after' => array() ); self::$FullRender = ''; $args = func_get_args(); if ( ! empty( self::$group ) ) { if ( $args[0] == '/' ) { $args[0] = substr( self::$group, 0, - 1 ); } else { $args[0] = self::$group . $args[0]; } } array_push( Route::$list, $args[0] ); $this->setCallable( $args ); return $this; }
php
public function get() { $this->RoutedStatus = FALSE; if ( ! $this->route->isGet() ) { return $this; } if ( is_callable( $this->callable ) ) { //$this->RoutedStatus = FALSE; return $this; } $this->middleware = array( 'before' => array(), 'after' => array() ); self::$FullRender = ''; $args = func_get_args(); if ( ! empty( self::$group ) ) { if ( $args[0] == '/' ) { $args[0] = substr( self::$group, 0, - 1 ); } else { $args[0] = self::$group . $args[0]; } } array_push( Route::$list, $args[0] ); $this->setCallable( $args ); return $this; }
[ "public", "function", "get", "(", ")", "{", "$", "this", "->", "RoutedStatus", "=", "FALSE", ";", "if", "(", "!", "$", "this", "->", "route", "->", "isGet", "(", ")", ")", "{", "return", "$", "this", ";", "}", "if", "(", "is_callable", "(", "$", "this", "->", "callable", ")", ")", "{", "//$this->RoutedStatus = FALSE;\r", "return", "$", "this", ";", "}", "$", "this", "->", "middleware", "=", "array", "(", "'before'", "=>", "array", "(", ")", ",", "'after'", "=>", "array", "(", ")", ")", ";", "self", "::", "$", "FullRender", "=", "''", ";", "$", "args", "=", "func_get_args", "(", ")", ";", "if", "(", "!", "empty", "(", "self", "::", "$", "group", ")", ")", "{", "if", "(", "$", "args", "[", "0", "]", "==", "'/'", ")", "{", "$", "args", "[", "0", "]", "=", "substr", "(", "self", "::", "$", "group", ",", "0", ",", "-", "1", ")", ";", "}", "else", "{", "$", "args", "[", "0", "]", "=", "self", "::", "$", "group", ".", "$", "args", "[", "0", "]", ";", "}", "}", "array_push", "(", "Route", "::", "$", "list", ",", "$", "args", "[", "0", "]", ")", ";", "$", "this", "->", "setCallable", "(", "$", "args", ")", ";", "return", "$", "this", ";", "}" ]
Set route for Get Method request @return $this
[ "Set", "route", "for", "Get", "Method", "request" ]
fa87e593affe1c9c51a2acd264b85ec06df31d7c
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Kecik.php#L417-L447
21,252
kecik-framework/kecik
Kecik/Kecik.php
Kecik.group
public function group() { if ( is_callable( $this->callable ) ) { //$this->RoutedStatus = FALSE; return $this; } self::$FullRender = ''; $args = func_get_args(); self::$group .= $args[0] . '/'; if ( is_callable( $args[1] ) ) { $this->GroupFunc = Closure::bind( $args[1], $this, get_class() ); call_user_func_array( $this->GroupFunc, array() ); } self::$group = ''; }
php
public function group() { if ( is_callable( $this->callable ) ) { //$this->RoutedStatus = FALSE; return $this; } self::$FullRender = ''; $args = func_get_args(); self::$group .= $args[0] . '/'; if ( is_callable( $args[1] ) ) { $this->GroupFunc = Closure::bind( $args[1], $this, get_class() ); call_user_func_array( $this->GroupFunc, array() ); } self::$group = ''; }
[ "public", "function", "group", "(", ")", "{", "if", "(", "is_callable", "(", "$", "this", "->", "callable", ")", ")", "{", "//$this->RoutedStatus = FALSE;\r", "return", "$", "this", ";", "}", "self", "::", "$", "FullRender", "=", "''", ";", "$", "args", "=", "func_get_args", "(", ")", ";", "self", "::", "$", "group", ".=", "$", "args", "[", "0", "]", ".", "'/'", ";", "if", "(", "is_callable", "(", "$", "args", "[", "1", "]", ")", ")", "{", "$", "this", "->", "GroupFunc", "=", "Closure", "::", "bind", "(", "$", "args", "[", "1", "]", ",", "$", "this", ",", "get_class", "(", ")", ")", ";", "call_user_func_array", "(", "$", "this", "->", "GroupFunc", ",", "array", "(", ")", ")", ";", "}", "self", "::", "$", "group", "=", "''", ";", "}" ]
Set of Group route @return $this
[ "Set", "of", "Group", "route" ]
fa87e593affe1c9c51a2acd264b85ec06df31d7c
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Kecik.php#L639-L656
21,253
kecik-framework/kecik
Kecik/Kecik.php
Kecik.template
public function template( $template, $replace = FALSE ) { if ( $this->RoutedStatus || $replace === TRUE ) { self::$FullRender = $template; } return $this; }
php
public function template( $template, $replace = FALSE ) { if ( $this->RoutedStatus || $replace === TRUE ) { self::$FullRender = $template; } return $this; }
[ "public", "function", "template", "(", "$", "template", ",", "$", "replace", "=", "FALSE", ")", "{", "if", "(", "$", "this", "->", "RoutedStatus", "||", "$", "replace", "===", "TRUE", ")", "{", "self", "::", "$", "FullRender", "=", "$", "template", ";", "}", "return", "$", "this", ";", "}" ]
Set template before render @param $template @param bool $replace @return $this
[ "Set", "template", "before", "render" ]
fa87e593affe1c9c51a2acd264b85ec06df31d7c
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Kecik.php#L693-L699
21,254
kecik-framework/kecik
Kecik/Kecik.php
Kecik.header
public function header( $code = 200 ) { if ( ! is_array( $code ) ) { $code = array( $code ); } self::$header = array(); foreach ( $code as $value ) { if ( is_int( $value ) ) { self::$header[] = $_SERVER["SERVER_PROTOCOL"] . ' ' . Route::$HttpResponse[ $value ]; } else { self::$header[] = $value; } } }
php
public function header( $code = 200 ) { if ( ! is_array( $code ) ) { $code = array( $code ); } self::$header = array(); foreach ( $code as $value ) { if ( is_int( $value ) ) { self::$header[] = $_SERVER["SERVER_PROTOCOL"] . ' ' . Route::$HttpResponse[ $value ]; } else { self::$header[] = $value; } } }
[ "public", "function", "header", "(", "$", "code", "=", "200", ")", "{", "if", "(", "!", "is_array", "(", "$", "code", ")", ")", "{", "$", "code", "=", "array", "(", "$", "code", ")", ";", "}", "self", "::", "$", "header", "=", "array", "(", ")", ";", "foreach", "(", "$", "code", "as", "$", "value", ")", "{", "if", "(", "is_int", "(", "$", "value", ")", ")", "{", "self", "::", "$", "header", "[", "]", "=", "$", "_SERVER", "[", "\"SERVER_PROTOCOL\"", "]", ".", "' '", ".", "Route", "::", "$", "HttpResponse", "[", "$", "value", "]", ";", "}", "else", "{", "self", "::", "$", "header", "[", "]", "=", "$", "value", ";", "}", "}", "}" ]
Set Header Response @param int $code
[ "Set", "Header", "Response" ]
fa87e593affe1c9c51a2acd264b85ec06df31d7c
https://github.com/kecik-framework/kecik/blob/fa87e593affe1c9c51a2acd264b85ec06df31d7c/Kecik/Kecik.php#L946-L964
21,255
jaeger-app/db-mysql
src/Traits/MySQL/Mycnf.php
Mycnf.createMyCnf
private function createMyCnf(array $db_info, $path) { $this->db_info = $db_info; $data = array( 'head' => '[client]', 'user' => 'user = ' . $this->db_info['user'], 'password' => 'password = ' . $this->db_info['password'], 'host' => 'host = ' . $this->db_info['host'] ); $content = implode(PHP_EOL, $data); $path = $path . DIRECTORY_SEPARATOR . 'my.cnf'; $fp = fopen($path, "wb"); fwrite($fp, $content); fclose($fp); return $path; }
php
private function createMyCnf(array $db_info, $path) { $this->db_info = $db_info; $data = array( 'head' => '[client]', 'user' => 'user = ' . $this->db_info['user'], 'password' => 'password = ' . $this->db_info['password'], 'host' => 'host = ' . $this->db_info['host'] ); $content = implode(PHP_EOL, $data); $path = $path . DIRECTORY_SEPARATOR . 'my.cnf'; $fp = fopen($path, "wb"); fwrite($fp, $content); fclose($fp); return $path; }
[ "private", "function", "createMyCnf", "(", "array", "$", "db_info", ",", "$", "path", ")", "{", "$", "this", "->", "db_info", "=", "$", "db_info", ";", "$", "data", "=", "array", "(", "'head'", "=>", "'[client]'", ",", "'user'", "=>", "'user = '", ".", "$", "this", "->", "db_info", "[", "'user'", "]", ",", "'password'", "=>", "'password = '", ".", "$", "this", "->", "db_info", "[", "'password'", "]", ",", "'host'", "=>", "'host = '", ".", "$", "this", "->", "db_info", "[", "'host'", "]", ")", ";", "$", "content", "=", "implode", "(", "PHP_EOL", ",", "$", "data", ")", ";", "$", "path", "=", "$", "path", ".", "DIRECTORY_SEPARATOR", ".", "'my.cnf'", ";", "$", "fp", "=", "fopen", "(", "$", "path", ",", "\"wb\"", ")", ";", "fwrite", "(", "$", "fp", ",", "$", "content", ")", ";", "fclose", "(", "$", "fp", ")", ";", "return", "$", "path", ";", "}" ]
Creates the my.cnf file for @param array $db_info @param unknown $path @return string
[ "Creates", "the", "my", ".", "cnf", "file", "for" ]
8211957b97dbcebeb7e65e0e5ab686c12992da72
https://github.com/jaeger-app/db-mysql/blob/8211957b97dbcebeb7e65e0e5ab686c12992da72/src/Traits/MySQL/Mycnf.php#L30-L47
21,256
petrica/php-statsd-system
Model/TopCommand.php
TopCommand.run
public function run() { $result = $this->getCommand()->run(); if ($result->getExitCode() != 0) { throw new \RuntimeException(sprintf( 'Command failed. Exit code %d, output %s', $result->getExitCode(), $result->getStdErr())); } return $this->parse($result->getStdOut()); }
php
public function run() { $result = $this->getCommand()->run(); if ($result->getExitCode() != 0) { throw new \RuntimeException(sprintf( 'Command failed. Exit code %d, output %s', $result->getExitCode(), $result->getStdErr())); } return $this->parse($result->getStdOut()); }
[ "public", "function", "run", "(", ")", "{", "$", "result", "=", "$", "this", "->", "getCommand", "(", ")", "->", "run", "(", ")", ";", "if", "(", "$", "result", "->", "getExitCode", "(", ")", "!=", "0", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "sprintf", "(", "'Command failed. Exit code %d, output %s'", ",", "$", "result", "->", "getExitCode", "(", ")", ",", "$", "result", "->", "getStdErr", "(", ")", ")", ")", ";", "}", "return", "$", "this", "->", "parse", "(", "$", "result", "->", "getStdOut", "(", ")", ")", ";", "}" ]
Run configured command @return string
[ "Run", "configured", "command" ]
c476be3514a631a605737888bb8f6eb096789c9d
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Model/TopCommand.php#L39-L51
21,257
petrica/php-statsd-system
Model/TopCommand.php
TopCommand.parse
protected function parse($output) { $lines = explode(PHP_EOL, $output); $stats = array(); foreach ($lines as $line) { $data = explode(' ', $line); array_walk($data, 'trim'); $stats[] = array_values(array_filter($data, function ($value) { return strlen($value) > 0; })); } return $stats; }
php
protected function parse($output) { $lines = explode(PHP_EOL, $output); $stats = array(); foreach ($lines as $line) { $data = explode(' ', $line); array_walk($data, 'trim'); $stats[] = array_values(array_filter($data, function ($value) { return strlen($value) > 0; })); } return $stats; }
[ "protected", "function", "parse", "(", "$", "output", ")", "{", "$", "lines", "=", "explode", "(", "PHP_EOL", ",", "$", "output", ")", ";", "$", "stats", "=", "array", "(", ")", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "$", "data", "=", "explode", "(", "' '", ",", "$", "line", ")", ";", "array_walk", "(", "$", "data", ",", "'trim'", ")", ";", "$", "stats", "[", "]", "=", "array_values", "(", "array_filter", "(", "$", "data", ",", "function", "(", "$", "value", ")", "{", "return", "strlen", "(", "$", "value", ")", ">", "0", ";", "}", ")", ")", ";", "}", "return", "$", "stats", ";", "}" ]
Parse top utility command output Returns an array of lines with the same top columns @param $output @return array
[ "Parse", "top", "utility", "command", "output" ]
c476be3514a631a605737888bb8f6eb096789c9d
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Model/TopCommand.php#L61-L74
21,258
petrica/php-statsd-system
Model/TopCommand.php
TopCommand.buildCommand
protected function buildCommand() { $command = new Command(\Tivie\Command\ESCAPE); $command ->setCommand('top') ->addArgument(new Argument('-b')) ->addArgument(new Argument('-n', 1)); return $command; }
php
protected function buildCommand() { $command = new Command(\Tivie\Command\ESCAPE); $command ->setCommand('top') ->addArgument(new Argument('-b')) ->addArgument(new Argument('-n', 1)); return $command; }
[ "protected", "function", "buildCommand", "(", ")", "{", "$", "command", "=", "new", "Command", "(", "\\", "Tivie", "\\", "Command", "\\", "ESCAPE", ")", ";", "$", "command", "->", "setCommand", "(", "'top'", ")", "->", "addArgument", "(", "new", "Argument", "(", "'-b'", ")", ")", "->", "addArgument", "(", "new", "Argument", "(", "'-n'", ",", "1", ")", ")", ";", "return", "$", "command", ";", "}" ]
Build commit command @return Command @throws \Tivie\Command\Exception\Exception @throws \Tivie\Command\Exception\InvalidArgumentException
[ "Build", "commit", "command" ]
c476be3514a631a605737888bb8f6eb096789c9d
https://github.com/petrica/php-statsd-system/blob/c476be3514a631a605737888bb8f6eb096789c9d/Model/TopCommand.php#L83-L92
21,259
wenbinye/PhalconX
src/Helper/ClassResolver.php
ClassResolver.resolve
public function resolve($name, $declaringClass) { if (strpos($name, '\\') !== false) { return $name; } $imports = $this->cache->get('_PHX.imports.'.$declaringClass); if (!isset($imports)) { $imports = ClassHelper::getImports($declaringClass); $this->cache->save('_PHX.imports.'.$declaringClass, $imports); } if (isset($imports[$name])) { return $imports[$name]; } $class = ClassHelper::getNamespaceName($declaringClass) . $name; if (class_exists($class)) { return $class; } }
php
public function resolve($name, $declaringClass) { if (strpos($name, '\\') !== false) { return $name; } $imports = $this->cache->get('_PHX.imports.'.$declaringClass); if (!isset($imports)) { $imports = ClassHelper::getImports($declaringClass); $this->cache->save('_PHX.imports.'.$declaringClass, $imports); } if (isset($imports[$name])) { return $imports[$name]; } $class = ClassHelper::getNamespaceName($declaringClass) . $name; if (class_exists($class)) { return $class; } }
[ "public", "function", "resolve", "(", "$", "name", ",", "$", "declaringClass", ")", "{", "if", "(", "strpos", "(", "$", "name", ",", "'\\\\'", ")", "!==", "false", ")", "{", "return", "$", "name", ";", "}", "$", "imports", "=", "$", "this", "->", "cache", "->", "get", "(", "'_PHX.imports.'", ".", "$", "declaringClass", ")", ";", "if", "(", "!", "isset", "(", "$", "imports", ")", ")", "{", "$", "imports", "=", "ClassHelper", "::", "getImports", "(", "$", "declaringClass", ")", ";", "$", "this", "->", "cache", "->", "save", "(", "'_PHX.imports.'", ".", "$", "declaringClass", ",", "$", "imports", ")", ";", "}", "if", "(", "isset", "(", "$", "imports", "[", "$", "name", "]", ")", ")", "{", "return", "$", "imports", "[", "$", "name", "]", ";", "}", "$", "class", "=", "ClassHelper", "::", "getNamespaceName", "(", "$", "declaringClass", ")", ".", "$", "name", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "return", "$", "class", ";", "}", "}" ]
Gets full class name @param string $name @param string $declaringClass @return string|null
[ "Gets", "full", "class", "name" ]
0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1
https://github.com/wenbinye/PhalconX/blob/0d2e1480e722dde56ccd23b2e8a5c8ac6ac2f8e1/src/Helper/ClassResolver.php#L28-L45
21,260
hnhdigital-os/laravel-html-builder
src/Tag.php
Tag.add
public function add($tag, ...$arguments) { $tag = strtolower($tag); $text = ''; $attributes = []; for ($i = 0; $i <= 1; $i++) { if (array_has($arguments, $i)) { if (is_array(array_get($arguments, $i))) { $attributes = array_get($arguments, $i); } elseif (is_string(array_get($arguments, $i)) || is_object(array_get($arguments, $i))) { $text = array_get($arguments, $i); } } } if ($this->tag === 'tag' || empty($this->allowed_tags) || in_array($tag, $this->allowed_tags) || in_array($tag, self::$special_tags)) { // Tag belongs to the special tags list. if (in_array($tag, self::$special_tags)) { $tag_object = Html::createElement($tag, $text, $attributes); $tag_object->text($text)->addAttributes($attributes); self::$tag_registry[] = &$tag_object; $this->child_nodes[] = &$tag_object; return $tag_object; } // Create the class name for this tag $class_name = 'Bluora\\LaravelHtmlBuilder\\Tag\\'.ucfirst($tag); // If the tag exists, otherwise we throw an exception. if (class_exists($class_name)) { $tag_object = (new $class_name()) ->setAttributes($attributes) ->setText($text); self::$tag_registry[] = &$tag_object; $this->child_nodes[] = &$tag_object; $tag_object->setParent($tag_object); return $tag_object; } throw new \Exception($tag.' does not exist.'); } throw new \Exception($this->tag.' does permit '.$tag); }
php
public function add($tag, ...$arguments) { $tag = strtolower($tag); $text = ''; $attributes = []; for ($i = 0; $i <= 1; $i++) { if (array_has($arguments, $i)) { if (is_array(array_get($arguments, $i))) { $attributes = array_get($arguments, $i); } elseif (is_string(array_get($arguments, $i)) || is_object(array_get($arguments, $i))) { $text = array_get($arguments, $i); } } } if ($this->tag === 'tag' || empty($this->allowed_tags) || in_array($tag, $this->allowed_tags) || in_array($tag, self::$special_tags)) { // Tag belongs to the special tags list. if (in_array($tag, self::$special_tags)) { $tag_object = Html::createElement($tag, $text, $attributes); $tag_object->text($text)->addAttributes($attributes); self::$tag_registry[] = &$tag_object; $this->child_nodes[] = &$tag_object; return $tag_object; } // Create the class name for this tag $class_name = 'Bluora\\LaravelHtmlBuilder\\Tag\\'.ucfirst($tag); // If the tag exists, otherwise we throw an exception. if (class_exists($class_name)) { $tag_object = (new $class_name()) ->setAttributes($attributes) ->setText($text); self::$tag_registry[] = &$tag_object; $this->child_nodes[] = &$tag_object; $tag_object->setParent($tag_object); return $tag_object; } throw new \Exception($tag.' does not exist.'); } throw new \Exception($this->tag.' does permit '.$tag); }
[ "public", "function", "add", "(", "$", "tag", ",", "...", "$", "arguments", ")", "{", "$", "tag", "=", "strtolower", "(", "$", "tag", ")", ";", "$", "text", "=", "''", ";", "$", "attributes", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<=", "1", ";", "$", "i", "++", ")", "{", "if", "(", "array_has", "(", "$", "arguments", ",", "$", "i", ")", ")", "{", "if", "(", "is_array", "(", "array_get", "(", "$", "arguments", ",", "$", "i", ")", ")", ")", "{", "$", "attributes", "=", "array_get", "(", "$", "arguments", ",", "$", "i", ")", ";", "}", "elseif", "(", "is_string", "(", "array_get", "(", "$", "arguments", ",", "$", "i", ")", ")", "||", "is_object", "(", "array_get", "(", "$", "arguments", ",", "$", "i", ")", ")", ")", "{", "$", "text", "=", "array_get", "(", "$", "arguments", ",", "$", "i", ")", ";", "}", "}", "}", "if", "(", "$", "this", "->", "tag", "===", "'tag'", "||", "empty", "(", "$", "this", "->", "allowed_tags", ")", "||", "in_array", "(", "$", "tag", ",", "$", "this", "->", "allowed_tags", ")", "||", "in_array", "(", "$", "tag", ",", "self", "::", "$", "special_tags", ")", ")", "{", "// Tag belongs to the special tags list.", "if", "(", "in_array", "(", "$", "tag", ",", "self", "::", "$", "special_tags", ")", ")", "{", "$", "tag_object", "=", "Html", "::", "createElement", "(", "$", "tag", ",", "$", "text", ",", "$", "attributes", ")", ";", "$", "tag_object", "->", "text", "(", "$", "text", ")", "->", "addAttributes", "(", "$", "attributes", ")", ";", "self", "::", "$", "tag_registry", "[", "]", "=", "&", "$", "tag_object", ";", "$", "this", "->", "child_nodes", "[", "]", "=", "&", "$", "tag_object", ";", "return", "$", "tag_object", ";", "}", "// Create the class name for this tag", "$", "class_name", "=", "'Bluora\\\\LaravelHtmlBuilder\\\\Tag\\\\'", ".", "ucfirst", "(", "$", "tag", ")", ";", "// If the tag exists, otherwise we throw an exception.", "if", "(", "class_exists", "(", "$", "class_name", ")", ")", "{", "$", "tag_object", "=", "(", "new", "$", "class_name", "(", ")", ")", "->", "setAttributes", "(", "$", "attributes", ")", "->", "setText", "(", "$", "text", ")", ";", "self", "::", "$", "tag_registry", "[", "]", "=", "&", "$", "tag_object", ";", "$", "this", "->", "child_nodes", "[", "]", "=", "&", "$", "tag_object", ";", "$", "tag_object", "->", "setParent", "(", "$", "tag_object", ")", ";", "return", "$", "tag_object", ";", "}", "throw", "new", "\\", "Exception", "(", "$", "tag", ".", "' does not exist.'", ")", ";", "}", "throw", "new", "\\", "Exception", "(", "$", "this", "->", "tag", ".", "' does permit '", ".", "$", "tag", ")", ";", "}" ]
Add a child node to this tag. @param string $tag @param array $arguments @return Bluora\LaravelHtmlBuilder\Tag
[ "Add", "a", "child", "node", "to", "this", "tag", "." ]
3c3c1f370e6ff77769b37130d12cbd041db3a841
https://github.com/hnhdigital-os/laravel-html-builder/blob/3c3c1f370e6ff77769b37130d12cbd041db3a841/src/Tag.php#L45-L95
21,261
hnhdigital-os/laravel-html-builder
src/Tag.php
Tag.setTag
public function setTag($tag) { if (in_array($tag, $this->getParent()->allowed_tags)) { throw new \Exception($tag.' can not be changed as it is not allowed under '.$this->getParent()->getTag().'.'); } $this->tag = $tag; return $this; }
php
public function setTag($tag) { if (in_array($tag, $this->getParent()->allowed_tags)) { throw new \Exception($tag.' can not be changed as it is not allowed under '.$this->getParent()->getTag().'.'); } $this->tag = $tag; return $this; }
[ "public", "function", "setTag", "(", "$", "tag", ")", "{", "if", "(", "in_array", "(", "$", "tag", ",", "$", "this", "->", "getParent", "(", ")", "->", "allowed_tags", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "$", "tag", ".", "' can not be changed as it is not allowed under '", ".", "$", "this", "->", "getParent", "(", ")", "->", "getTag", "(", ")", ".", "'.'", ")", ";", "}", "$", "this", "->", "tag", "=", "$", "tag", ";", "return", "$", "this", ";", "}" ]
Set the tag name. @return Bluora\LaravelHtmlBuilder\Tag
[ "Set", "the", "tag", "name", "." ]
3c3c1f370e6ff77769b37130d12cbd041db3a841
https://github.com/hnhdigital-os/laravel-html-builder/blob/3c3c1f370e6ff77769b37130d12cbd041db3a841/src/Tag.php#L126-L135
21,262
hnhdigital-os/laravel-html-builder
src/Tag.php
Tag.setText
public function setText($value) { $this->text = $value; // Auto-convert into html. if (is_object($value) && stripos(get_class($value), 'HtmlGenerator\\Html')) { $this->text = (string) $value; } return $this; }
php
public function setText($value) { $this->text = $value; // Auto-convert into html. if (is_object($value) && stripos(get_class($value), 'HtmlGenerator\\Html')) { $this->text = (string) $value; } return $this; }
[ "public", "function", "setText", "(", "$", "value", ")", "{", "$", "this", "->", "text", "=", "$", "value", ";", "// Auto-convert into html.", "if", "(", "is_object", "(", "$", "value", ")", "&&", "stripos", "(", "get_class", "(", "$", "value", ")", ",", "'HtmlGenerator\\\\Html'", ")", ")", "{", "$", "this", "->", "text", "=", "(", "string", ")", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Set the text for this tag. @param string $value @return Bluora\LaravelHtmlBuilder\Tag
[ "Set", "the", "text", "for", "this", "tag", "." ]
3c3c1f370e6ff77769b37130d12cbd041db3a841
https://github.com/hnhdigital-os/laravel-html-builder/blob/3c3c1f370e6ff77769b37130d12cbd041db3a841/src/Tag.php#L154-L164
21,263
hnhdigital-os/laravel-html-builder
src/Tag.php
Tag.setAttributes
public function setAttributes() { $attributes = func_get_args(); if (count($attributes)) { if (count($attributes) == 1 && is_array($attributes[0])) { $attributes = $attributes[0]; } $this->attributes = $attributes; } return $this; }
php
public function setAttributes() { $attributes = func_get_args(); if (count($attributes)) { if (count($attributes) == 1 && is_array($attributes[0])) { $attributes = $attributes[0]; } $this->attributes = $attributes; } return $this; }
[ "public", "function", "setAttributes", "(", ")", "{", "$", "attributes", "=", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "attributes", ")", ")", "{", "if", "(", "count", "(", "$", "attributes", ")", "==", "1", "&&", "is_array", "(", "$", "attributes", "[", "0", "]", ")", ")", "{", "$", "attributes", "=", "$", "attributes", "[", "0", "]", ";", "}", "$", "this", "->", "attributes", "=", "$", "attributes", ";", "}", "return", "$", "this", ";", "}" ]
Set one or many attributes. @param array ...$attributes @return Bluora\LaravelHtmlBuilder\Tag
[ "Set", "one", "or", "many", "attributes", "." ]
3c3c1f370e6ff77769b37130d12cbd041db3a841
https://github.com/hnhdigital-os/laravel-html-builder/blob/3c3c1f370e6ff77769b37130d12cbd041db3a841/src/Tag.php#L183-L194
21,264
hnhdigital-os/laravel-html-builder
src/Tag.php
Tag.buildHtml
private static function buildHtml(&$html, $tag_object, $options, $tab = 0) { self::checkBuildOptions($options); $tag_is_special = in_array($tag_object->getTag(), self::$special_tags); $tag_is_ignored = in_array($tag_object->getTag(), array_get($options, 'ignore_tags', [])); $ignore_tag = true; if (!isset($options['ignore_tags']) || !$tag_is_ignored) { $ignore_tag = false; } elseif (isset($options['ignore_tags']) && $tag_is_ignored) { $tab--; } $pad = ''; if ($tab > 0) { $pad = str_pad($pad, $tab * 2, ' ', STR_PAD_LEFT); } if (!$ignore_tag) { if ($tag_is_special) { $html .= $pad.trim((string) $tag_object)."\n"; } elseif (!$tag_is_special) { $html .= $pad; $html .= '<'.$tag_object->tag.''.self::buildHtmlAttribute($tag_object->getAttributes()).'>'; $html .= ($tag_object->use_whitespace) ? "\n" : ''; if (strlen($tag_object->getText())) { $html .= ($tag_object->use_whitespace) ? $pad.' ' : ''; $html .= $tag_object->getText(); } $html .= ($tag_object->use_whitespace && strlen($tag_object->getText())) ? "\n" : ''; } } if (!$tag_is_special && $tag_object->hasChildNodes()) { foreach ($tag_object->getChildNodes() as $child_tag_object) { self::buildHtml($html, $child_tag_object, $options, $tab + 1); } } $pad = ''; if ($tab > 0) { $pad = str_pad($pad, $tab * 2, ' ', STR_PAD_LEFT); } if (!$ignore_tag && !$tag_is_special) { $html .= ($tag_object->use_whitespace) ? $pad : ''; $html .= '</'.$tag_object->tag.'>'."\n"; } }
php
private static function buildHtml(&$html, $tag_object, $options, $tab = 0) { self::checkBuildOptions($options); $tag_is_special = in_array($tag_object->getTag(), self::$special_tags); $tag_is_ignored = in_array($tag_object->getTag(), array_get($options, 'ignore_tags', [])); $ignore_tag = true; if (!isset($options['ignore_tags']) || !$tag_is_ignored) { $ignore_tag = false; } elseif (isset($options['ignore_tags']) && $tag_is_ignored) { $tab--; } $pad = ''; if ($tab > 0) { $pad = str_pad($pad, $tab * 2, ' ', STR_PAD_LEFT); } if (!$ignore_tag) { if ($tag_is_special) { $html .= $pad.trim((string) $tag_object)."\n"; } elseif (!$tag_is_special) { $html .= $pad; $html .= '<'.$tag_object->tag.''.self::buildHtmlAttribute($tag_object->getAttributes()).'>'; $html .= ($tag_object->use_whitespace) ? "\n" : ''; if (strlen($tag_object->getText())) { $html .= ($tag_object->use_whitespace) ? $pad.' ' : ''; $html .= $tag_object->getText(); } $html .= ($tag_object->use_whitespace && strlen($tag_object->getText())) ? "\n" : ''; } } if (!$tag_is_special && $tag_object->hasChildNodes()) { foreach ($tag_object->getChildNodes() as $child_tag_object) { self::buildHtml($html, $child_tag_object, $options, $tab + 1); } } $pad = ''; if ($tab > 0) { $pad = str_pad($pad, $tab * 2, ' ', STR_PAD_LEFT); } if (!$ignore_tag && !$tag_is_special) { $html .= ($tag_object->use_whitespace) ? $pad : ''; $html .= '</'.$tag_object->tag.'>'."\n"; } }
[ "private", "static", "function", "buildHtml", "(", "&", "$", "html", ",", "$", "tag_object", ",", "$", "options", ",", "$", "tab", "=", "0", ")", "{", "self", "::", "checkBuildOptions", "(", "$", "options", ")", ";", "$", "tag_is_special", "=", "in_array", "(", "$", "tag_object", "->", "getTag", "(", ")", ",", "self", "::", "$", "special_tags", ")", ";", "$", "tag_is_ignored", "=", "in_array", "(", "$", "tag_object", "->", "getTag", "(", ")", ",", "array_get", "(", "$", "options", ",", "'ignore_tags'", ",", "[", "]", ")", ")", ";", "$", "ignore_tag", "=", "true", ";", "if", "(", "!", "isset", "(", "$", "options", "[", "'ignore_tags'", "]", ")", "||", "!", "$", "tag_is_ignored", ")", "{", "$", "ignore_tag", "=", "false", ";", "}", "elseif", "(", "isset", "(", "$", "options", "[", "'ignore_tags'", "]", ")", "&&", "$", "tag_is_ignored", ")", "{", "$", "tab", "--", ";", "}", "$", "pad", "=", "''", ";", "if", "(", "$", "tab", ">", "0", ")", "{", "$", "pad", "=", "str_pad", "(", "$", "pad", ",", "$", "tab", "*", "2", ",", "' '", ",", "STR_PAD_LEFT", ")", ";", "}", "if", "(", "!", "$", "ignore_tag", ")", "{", "if", "(", "$", "tag_is_special", ")", "{", "$", "html", ".=", "$", "pad", ".", "trim", "(", "(", "string", ")", "$", "tag_object", ")", ".", "\"\\n\"", ";", "}", "elseif", "(", "!", "$", "tag_is_special", ")", "{", "$", "html", ".=", "$", "pad", ";", "$", "html", ".=", "'<'", ".", "$", "tag_object", "->", "tag", ".", "''", ".", "self", "::", "buildHtmlAttribute", "(", "$", "tag_object", "->", "getAttributes", "(", ")", ")", ".", "'>'", ";", "$", "html", ".=", "(", "$", "tag_object", "->", "use_whitespace", ")", "?", "\"\\n\"", ":", "''", ";", "if", "(", "strlen", "(", "$", "tag_object", "->", "getText", "(", ")", ")", ")", "{", "$", "html", ".=", "(", "$", "tag_object", "->", "use_whitespace", ")", "?", "$", "pad", ".", "' '", ":", "''", ";", "$", "html", ".=", "$", "tag_object", "->", "getText", "(", ")", ";", "}", "$", "html", ".=", "(", "$", "tag_object", "->", "use_whitespace", "&&", "strlen", "(", "$", "tag_object", "->", "getText", "(", ")", ")", ")", "?", "\"\\n\"", ":", "''", ";", "}", "}", "if", "(", "!", "$", "tag_is_special", "&&", "$", "tag_object", "->", "hasChildNodes", "(", ")", ")", "{", "foreach", "(", "$", "tag_object", "->", "getChildNodes", "(", ")", "as", "$", "child_tag_object", ")", "{", "self", "::", "buildHtml", "(", "$", "html", ",", "$", "child_tag_object", ",", "$", "options", ",", "$", "tab", "+", "1", ")", ";", "}", "}", "$", "pad", "=", "''", ";", "if", "(", "$", "tab", ">", "0", ")", "{", "$", "pad", "=", "str_pad", "(", "$", "pad", ",", "$", "tab", "*", "2", ",", "' '", ",", "STR_PAD_LEFT", ")", ";", "}", "if", "(", "!", "$", "ignore_tag", "&&", "!", "$", "tag_is_special", ")", "{", "$", "html", ".=", "(", "$", "tag_object", "->", "use_whitespace", ")", "?", "$", "pad", ":", "''", ";", "$", "html", ".=", "'</'", ".", "$", "tag_object", "->", "tag", ".", "'>'", ".", "\"\\n\"", ";", "}", "}" ]
Build html from this object. @param string &$html @param LaravelHtmlBuilder\Tag $tag_object @param array $options @param int $tab @return void
[ "Build", "html", "from", "this", "object", "." ]
3c3c1f370e6ff77769b37130d12cbd041db3a841
https://github.com/hnhdigital-os/laravel-html-builder/blob/3c3c1f370e6ff77769b37130d12cbd041db3a841/src/Tag.php#L277-L326
21,265
hnhdigital-os/laravel-html-builder
src/Tag.php
Tag.buildHtmlAttribute
private static function buildHtmlAttribute($attributes) { $html = ''; foreach ($attributes as $name => $value) { $html .= ' '.$name.'="'.$value.'"'; $class_list = explode(' ', $value); foreach ($class_list as $class_name) { switch ($class_name) { case 'class': if (function_exists('hookAddClassHtmlTag')) { hookAddClassHtmlTag($class_name); } } } } return $html; }
php
private static function buildHtmlAttribute($attributes) { $html = ''; foreach ($attributes as $name => $value) { $html .= ' '.$name.'="'.$value.'"'; $class_list = explode(' ', $value); foreach ($class_list as $class_name) { switch ($class_name) { case 'class': if (function_exists('hookAddClassHtmlTag')) { hookAddClassHtmlTag($class_name); } } } } return $html; }
[ "private", "static", "function", "buildHtmlAttribute", "(", "$", "attributes", ")", "{", "$", "html", "=", "''", ";", "foreach", "(", "$", "attributes", "as", "$", "name", "=>", "$", "value", ")", "{", "$", "html", ".=", "' '", ".", "$", "name", ".", "'=\"'", ".", "$", "value", ".", "'\"'", ";", "$", "class_list", "=", "explode", "(", "' '", ",", "$", "value", ")", ";", "foreach", "(", "$", "class_list", "as", "$", "class_name", ")", "{", "switch", "(", "$", "class_name", ")", "{", "case", "'class'", ":", "if", "(", "function_exists", "(", "'hookAddClassHtmlTag'", ")", ")", "{", "hookAddClassHtmlTag", "(", "$", "class_name", ")", ";", "}", "}", "}", "}", "return", "$", "html", ";", "}" ]
Build html attributes from array. @param array $attributes @return string
[ "Build", "html", "attributes", "from", "array", "." ]
3c3c1f370e6ff77769b37130d12cbd041db3a841
https://github.com/hnhdigital-os/laravel-html-builder/blob/3c3c1f370e6ff77769b37130d12cbd041db3a841/src/Tag.php#L335-L352
21,266
hnhdigital-os/laravel-html-builder
src/Tag.php
Tag.buildArray
private static function buildArray(&$array, $tag_object, $options = []) { self::checkBuildOptions($options); if (in_array($tag_object->getTag(), self::$special_tags)) { $array[] = [trim((string) $tag_object)]; } elseif (!isset($options['ignore_tags']) || !in_array($tag_object->getTag(), $options['ignore_tags'])) { $array[] = [ $tag_object->getTag(), self::buildHtmlAttribute($tag_object->getAttributes()), $tag_object->getText(), [], ]; } if ($tag_object->hasChildNodes()) { if (isset($options['ignore_tags']) && in_array($tag_object->getTag(), $options['ignore_tags'])) { foreach ($tag_object->getChildNodes() as $child_tag_object) { self::buildArray($array, $child_tag_object); } return; } foreach ($tag_object->getChildNodes() as $child_tag_object) { $current_position = count($array) - 1; if (isset($array[$current_position][3]) && !is_null($array[$current_position][3])) { self::buildArray($array[count($array) - 1][3], $child_tag_object); } } } }
php
private static function buildArray(&$array, $tag_object, $options = []) { self::checkBuildOptions($options); if (in_array($tag_object->getTag(), self::$special_tags)) { $array[] = [trim((string) $tag_object)]; } elseif (!isset($options['ignore_tags']) || !in_array($tag_object->getTag(), $options['ignore_tags'])) { $array[] = [ $tag_object->getTag(), self::buildHtmlAttribute($tag_object->getAttributes()), $tag_object->getText(), [], ]; } if ($tag_object->hasChildNodes()) { if (isset($options['ignore_tags']) && in_array($tag_object->getTag(), $options['ignore_tags'])) { foreach ($tag_object->getChildNodes() as $child_tag_object) { self::buildArray($array, $child_tag_object); } return; } foreach ($tag_object->getChildNodes() as $child_tag_object) { $current_position = count($array) - 1; if (isset($array[$current_position][3]) && !is_null($array[$current_position][3])) { self::buildArray($array[count($array) - 1][3], $child_tag_object); } } } }
[ "private", "static", "function", "buildArray", "(", "&", "$", "array", ",", "$", "tag_object", ",", "$", "options", "=", "[", "]", ")", "{", "self", "::", "checkBuildOptions", "(", "$", "options", ")", ";", "if", "(", "in_array", "(", "$", "tag_object", "->", "getTag", "(", ")", ",", "self", "::", "$", "special_tags", ")", ")", "{", "$", "array", "[", "]", "=", "[", "trim", "(", "(", "string", ")", "$", "tag_object", ")", "]", ";", "}", "elseif", "(", "!", "isset", "(", "$", "options", "[", "'ignore_tags'", "]", ")", "||", "!", "in_array", "(", "$", "tag_object", "->", "getTag", "(", ")", ",", "$", "options", "[", "'ignore_tags'", "]", ")", ")", "{", "$", "array", "[", "]", "=", "[", "$", "tag_object", "->", "getTag", "(", ")", ",", "self", "::", "buildHtmlAttribute", "(", "$", "tag_object", "->", "getAttributes", "(", ")", ")", ",", "$", "tag_object", "->", "getText", "(", ")", ",", "[", "]", ",", "]", ";", "}", "if", "(", "$", "tag_object", "->", "hasChildNodes", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'ignore_tags'", "]", ")", "&&", "in_array", "(", "$", "tag_object", "->", "getTag", "(", ")", ",", "$", "options", "[", "'ignore_tags'", "]", ")", ")", "{", "foreach", "(", "$", "tag_object", "->", "getChildNodes", "(", ")", "as", "$", "child_tag_object", ")", "{", "self", "::", "buildArray", "(", "$", "array", ",", "$", "child_tag_object", ")", ";", "}", "return", ";", "}", "foreach", "(", "$", "tag_object", "->", "getChildNodes", "(", ")", "as", "$", "child_tag_object", ")", "{", "$", "current_position", "=", "count", "(", "$", "array", ")", "-", "1", ";", "if", "(", "isset", "(", "$", "array", "[", "$", "current_position", "]", "[", "3", "]", ")", "&&", "!", "is_null", "(", "$", "array", "[", "$", "current_position", "]", "[", "3", "]", ")", ")", "{", "self", "::", "buildArray", "(", "$", "array", "[", "count", "(", "$", "array", ")", "-", "1", "]", "[", "3", "]", ",", "$", "child_tag_object", ")", ";", "}", "}", "}", "}" ]
Build an array from this object. @param array &$array @param LaravelHtmlBuilder\Tag $tag_object @param array $options @return void
[ "Build", "an", "array", "from", "this", "object", "." ]
3c3c1f370e6ff77769b37130d12cbd041db3a841
https://github.com/hnhdigital-os/laravel-html-builder/blob/3c3c1f370e6ff77769b37130d12cbd041db3a841/src/Tag.php#L363-L394
21,267
hnhdigital-os/laravel-html-builder
src/Tag.php
Tag.buildFromArray
public static function buildFromArray(&$html, $array, $tab = 0) { $pad = ''; if ($tab > 0) { $pad = str_pad($pad, $tab * 2, ' ', STR_PAD_LEFT); } if (!isset($array[1])) { $html .= $array[0]."\n"; return; } if (!empty($array[0])) { $html .= $pad; $html .= '<'.$array[0].$array[1].'>'; $html .= "\n"; } if (!empty($array[2])) { $html .= $pad.' '; $html .= $array[2]; $html .= "\n"; } if (isset($array[3]) && is_array($array[3])) { foreach ($array[3] as $child_array) { self::buildFromArray($html, $child_array, $tab + 1); } } if (!empty($array[0])) { $html .= $pad; $html .= '</'.$array[0].'>'; $html .= "\n"; } }
php
public static function buildFromArray(&$html, $array, $tab = 0) { $pad = ''; if ($tab > 0) { $pad = str_pad($pad, $tab * 2, ' ', STR_PAD_LEFT); } if (!isset($array[1])) { $html .= $array[0]."\n"; return; } if (!empty($array[0])) { $html .= $pad; $html .= '<'.$array[0].$array[1].'>'; $html .= "\n"; } if (!empty($array[2])) { $html .= $pad.' '; $html .= $array[2]; $html .= "\n"; } if (isset($array[3]) && is_array($array[3])) { foreach ($array[3] as $child_array) { self::buildFromArray($html, $child_array, $tab + 1); } } if (!empty($array[0])) { $html .= $pad; $html .= '</'.$array[0].'>'; $html .= "\n"; } }
[ "public", "static", "function", "buildFromArray", "(", "&", "$", "html", ",", "$", "array", ",", "$", "tab", "=", "0", ")", "{", "$", "pad", "=", "''", ";", "if", "(", "$", "tab", ">", "0", ")", "{", "$", "pad", "=", "str_pad", "(", "$", "pad", ",", "$", "tab", "*", "2", ",", "' '", ",", "STR_PAD_LEFT", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "array", "[", "1", "]", ")", ")", "{", "$", "html", ".=", "$", "array", "[", "0", "]", ".", "\"\\n\"", ";", "return", ";", "}", "if", "(", "!", "empty", "(", "$", "array", "[", "0", "]", ")", ")", "{", "$", "html", ".=", "$", "pad", ";", "$", "html", ".=", "'<'", ".", "$", "array", "[", "0", "]", ".", "$", "array", "[", "1", "]", ".", "'>'", ";", "$", "html", ".=", "\"\\n\"", ";", "}", "if", "(", "!", "empty", "(", "$", "array", "[", "2", "]", ")", ")", "{", "$", "html", ".=", "$", "pad", ".", "' '", ";", "$", "html", ".=", "$", "array", "[", "2", "]", ";", "$", "html", ".=", "\"\\n\"", ";", "}", "if", "(", "isset", "(", "$", "array", "[", "3", "]", ")", "&&", "is_array", "(", "$", "array", "[", "3", "]", ")", ")", "{", "foreach", "(", "$", "array", "[", "3", "]", "as", "$", "child_array", ")", "{", "self", "::", "buildFromArray", "(", "$", "html", ",", "$", "child_array", ",", "$", "tab", "+", "1", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "array", "[", "0", "]", ")", ")", "{", "$", "html", ".=", "$", "pad", ";", "$", "html", ".=", "'</'", ".", "$", "array", "[", "0", "]", ".", "'>'", ";", "$", "html", ".=", "\"\\n\"", ";", "}", "}" ]
Build html from an array. @param string &$html @param array $array @param int $tab @return void
[ "Build", "html", "from", "an", "array", "." ]
3c3c1f370e6ff77769b37130d12cbd041db3a841
https://github.com/hnhdigital-os/laravel-html-builder/blob/3c3c1f370e6ff77769b37130d12cbd041db3a841/src/Tag.php#L405-L441
21,268
hnhdigital-os/laravel-html-builder
src/Tag.php
Tag.prepare
public function prepare($options = []) { if (request()->ajax()) { return $this->getArray($options); } return $this->getHtml($options); }
php
public function prepare($options = []) { if (request()->ajax()) { return $this->getArray($options); } return $this->getHtml($options); }
[ "public", "function", "prepare", "(", "$", "options", "=", "[", "]", ")", "{", "if", "(", "request", "(", ")", "->", "ajax", "(", ")", ")", "{", "return", "$", "this", "->", "getArray", "(", "$", "options", ")", ";", "}", "return", "$", "this", "->", "getHtml", "(", "$", "options", ")", ";", "}" ]
Automatically returns the object based on the http request. @return html|array
[ "Automatically", "returns", "the", "object", "based", "on", "the", "http", "request", "." ]
3c3c1f370e6ff77769b37130d12cbd041db3a841
https://github.com/hnhdigital-os/laravel-html-builder/blob/3c3c1f370e6ff77769b37130d12cbd041db3a841/src/Tag.php#L448-L455
21,269
xiewulong/yii2-fileupload
oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php
ClassCollectionLoader.fixNamespaceDeclarations
public static function fixNamespaceDeclarations($source) { if (!function_exists('token_get_all') || !self::$useTokenizer) { if (preg_match('/namespace(.*?)\s*;/', $source)) { $source = preg_replace('/namespace(.*?)\s*;/', "namespace$1\n{", $source)."}\n"; } return $source; } $rawChunk = ''; $output = ''; $inNamespace = false; $tokens = token_get_all($source); for (reset($tokens); false !== $token = current($tokens); next($tokens)) { if (is_string($token)) { $rawChunk .= $token; } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { // strip comments continue; } elseif (T_NAMESPACE === $token[0]) { if ($inNamespace) { $rawChunk .= "}\n"; } $rawChunk .= $token[1]; // namespace name and whitespaces while (($t = next($tokens)) && is_array($t) && in_array($t[0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) { $rawChunk .= $t[1]; } if ('{' === $t) { $inNamespace = false; prev($tokens); } else { $rawChunk = rtrim($rawChunk)."\n{"; $inNamespace = true; } } elseif (T_START_HEREDOC === $token[0]) { $output .= self::compressCode($rawChunk).$token[1]; do { $token = next($tokens); $output .= is_string($token) ? $token : $token[1]; } while ($token[0] !== T_END_HEREDOC); $output .= "\n"; $rawChunk = ''; } elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) { $output .= self::compressCode($rawChunk).$token[1]; $rawChunk = ''; } else { $rawChunk .= $token[1]; } } if ($inNamespace) { $rawChunk .= "}\n"; } return $output.self::compressCode($rawChunk); }
php
public static function fixNamespaceDeclarations($source) { if (!function_exists('token_get_all') || !self::$useTokenizer) { if (preg_match('/namespace(.*?)\s*;/', $source)) { $source = preg_replace('/namespace(.*?)\s*;/', "namespace$1\n{", $source)."}\n"; } return $source; } $rawChunk = ''; $output = ''; $inNamespace = false; $tokens = token_get_all($source); for (reset($tokens); false !== $token = current($tokens); next($tokens)) { if (is_string($token)) { $rawChunk .= $token; } elseif (in_array($token[0], array(T_COMMENT, T_DOC_COMMENT))) { // strip comments continue; } elseif (T_NAMESPACE === $token[0]) { if ($inNamespace) { $rawChunk .= "}\n"; } $rawChunk .= $token[1]; // namespace name and whitespaces while (($t = next($tokens)) && is_array($t) && in_array($t[0], array(T_WHITESPACE, T_NS_SEPARATOR, T_STRING))) { $rawChunk .= $t[1]; } if ('{' === $t) { $inNamespace = false; prev($tokens); } else { $rawChunk = rtrim($rawChunk)."\n{"; $inNamespace = true; } } elseif (T_START_HEREDOC === $token[0]) { $output .= self::compressCode($rawChunk).$token[1]; do { $token = next($tokens); $output .= is_string($token) ? $token : $token[1]; } while ($token[0] !== T_END_HEREDOC); $output .= "\n"; $rawChunk = ''; } elseif (T_CONSTANT_ENCAPSED_STRING === $token[0]) { $output .= self::compressCode($rawChunk).$token[1]; $rawChunk = ''; } else { $rawChunk .= $token[1]; } } if ($inNamespace) { $rawChunk .= "}\n"; } return $output.self::compressCode($rawChunk); }
[ "public", "static", "function", "fixNamespaceDeclarations", "(", "$", "source", ")", "{", "if", "(", "!", "function_exists", "(", "'token_get_all'", ")", "||", "!", "self", "::", "$", "useTokenizer", ")", "{", "if", "(", "preg_match", "(", "'/namespace(.*?)\\s*;/'", ",", "$", "source", ")", ")", "{", "$", "source", "=", "preg_replace", "(", "'/namespace(.*?)\\s*;/'", ",", "\"namespace$1\\n{\"", ",", "$", "source", ")", ".", "\"}\\n\"", ";", "}", "return", "$", "source", ";", "}", "$", "rawChunk", "=", "''", ";", "$", "output", "=", "''", ";", "$", "inNamespace", "=", "false", ";", "$", "tokens", "=", "token_get_all", "(", "$", "source", ")", ";", "for", "(", "reset", "(", "$", "tokens", ")", ";", "false", "!==", "$", "token", "=", "current", "(", "$", "tokens", ")", ";", "next", "(", "$", "tokens", ")", ")", "{", "if", "(", "is_string", "(", "$", "token", ")", ")", "{", "$", "rawChunk", ".=", "$", "token", ";", "}", "elseif", "(", "in_array", "(", "$", "token", "[", "0", "]", ",", "array", "(", "T_COMMENT", ",", "T_DOC_COMMENT", ")", ")", ")", "{", "// strip comments", "continue", ";", "}", "elseif", "(", "T_NAMESPACE", "===", "$", "token", "[", "0", "]", ")", "{", "if", "(", "$", "inNamespace", ")", "{", "$", "rawChunk", ".=", "\"}\\n\"", ";", "}", "$", "rawChunk", ".=", "$", "token", "[", "1", "]", ";", "// namespace name and whitespaces", "while", "(", "(", "$", "t", "=", "next", "(", "$", "tokens", ")", ")", "&&", "is_array", "(", "$", "t", ")", "&&", "in_array", "(", "$", "t", "[", "0", "]", ",", "array", "(", "T_WHITESPACE", ",", "T_NS_SEPARATOR", ",", "T_STRING", ")", ")", ")", "{", "$", "rawChunk", ".=", "$", "t", "[", "1", "]", ";", "}", "if", "(", "'{'", "===", "$", "t", ")", "{", "$", "inNamespace", "=", "false", ";", "prev", "(", "$", "tokens", ")", ";", "}", "else", "{", "$", "rawChunk", "=", "rtrim", "(", "$", "rawChunk", ")", ".", "\"\\n{\"", ";", "$", "inNamespace", "=", "true", ";", "}", "}", "elseif", "(", "T_START_HEREDOC", "===", "$", "token", "[", "0", "]", ")", "{", "$", "output", ".=", "self", "::", "compressCode", "(", "$", "rawChunk", ")", ".", "$", "token", "[", "1", "]", ";", "do", "{", "$", "token", "=", "next", "(", "$", "tokens", ")", ";", "$", "output", ".=", "is_string", "(", "$", "token", ")", "?", "$", "token", ":", "$", "token", "[", "1", "]", ";", "}", "while", "(", "$", "token", "[", "0", "]", "!==", "T_END_HEREDOC", ")", ";", "$", "output", ".=", "\"\\n\"", ";", "$", "rawChunk", "=", "''", ";", "}", "elseif", "(", "T_CONSTANT_ENCAPSED_STRING", "===", "$", "token", "[", "0", "]", ")", "{", "$", "output", ".=", "self", "::", "compressCode", "(", "$", "rawChunk", ")", ".", "$", "token", "[", "1", "]", ";", "$", "rawChunk", "=", "''", ";", "}", "else", "{", "$", "rawChunk", ".=", "$", "token", "[", "1", "]", ";", "}", "}", "if", "(", "$", "inNamespace", ")", "{", "$", "rawChunk", ".=", "\"}\\n\"", ";", "}", "return", "$", "output", ".", "self", "::", "compressCode", "(", "$", "rawChunk", ")", ";", "}" ]
Adds brackets around each namespace if it's not already the case. @param string $source Namespace string @return string Namespaces with brackets
[ "Adds", "brackets", "around", "each", "namespace", "if", "it", "s", "not", "already", "the", "case", "." ]
3e75b17a4a18dd8466e3f57c63136de03470ca82
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php#L137-L196
21,270
xiewulong/yii2-fileupload
oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php
ClassCollectionLoader.resolveDependencies
private static function resolveDependencies(array $tree, $node, \ArrayObject $resolved = null, \ArrayObject $unresolved = null) { if (null === $resolved) { $resolved = new \ArrayObject(); } if (null === $unresolved) { $unresolved = new \ArrayObject(); } $nodeName = $node->getName(); $unresolved[$nodeName] = $node; foreach ($tree[$nodeName] as $dependency) { if (!$resolved->offsetExists($dependency->getName())) { self::resolveDependencies($tree, $dependency, $resolved, $unresolved); } } $resolved[$nodeName] = $node; unset($unresolved[$nodeName]); return $resolved; }
php
private static function resolveDependencies(array $tree, $node, \ArrayObject $resolved = null, \ArrayObject $unresolved = null) { if (null === $resolved) { $resolved = new \ArrayObject(); } if (null === $unresolved) { $unresolved = new \ArrayObject(); } $nodeName = $node->getName(); $unresolved[$nodeName] = $node; foreach ($tree[$nodeName] as $dependency) { if (!$resolved->offsetExists($dependency->getName())) { self::resolveDependencies($tree, $dependency, $resolved, $unresolved); } } $resolved[$nodeName] = $node; unset($unresolved[$nodeName]); return $resolved; }
[ "private", "static", "function", "resolveDependencies", "(", "array", "$", "tree", ",", "$", "node", ",", "\\", "ArrayObject", "$", "resolved", "=", "null", ",", "\\", "ArrayObject", "$", "unresolved", "=", "null", ")", "{", "if", "(", "null", "===", "$", "resolved", ")", "{", "$", "resolved", "=", "new", "\\", "ArrayObject", "(", ")", ";", "}", "if", "(", "null", "===", "$", "unresolved", ")", "{", "$", "unresolved", "=", "new", "\\", "ArrayObject", "(", ")", ";", "}", "$", "nodeName", "=", "$", "node", "->", "getName", "(", ")", ";", "$", "unresolved", "[", "$", "nodeName", "]", "=", "$", "node", ";", "foreach", "(", "$", "tree", "[", "$", "nodeName", "]", "as", "$", "dependency", ")", "{", "if", "(", "!", "$", "resolved", "->", "offsetExists", "(", "$", "dependency", "->", "getName", "(", ")", ")", ")", "{", "self", "::", "resolveDependencies", "(", "$", "tree", ",", "$", "dependency", ",", "$", "resolved", ",", "$", "unresolved", ")", ";", "}", "}", "$", "resolved", "[", "$", "nodeName", "]", "=", "$", "node", ";", "unset", "(", "$", "unresolved", "[", "$", "nodeName", "]", ")", ";", "return", "$", "resolved", ";", "}" ]
Dependencies resolution. This function does not check for circular dependencies as it should never occur with PHP traits. @param array $tree The dependency tree @param \ReflectionClass $node The node @param \ArrayObject $resolved An array of already resolved dependencies @param \ArrayObject $unresolved An array of dependencies to be resolved @return \ArrayObject The dependencies for the given node @throws \RuntimeException if a circular dependency is detected
[ "Dependencies", "resolution", "." ]
3e75b17a4a18dd8466e3f57c63136de03470ca82
https://github.com/xiewulong/yii2-fileupload/blob/3e75b17a4a18dd8466e3f57c63136de03470ca82/oss/libs/symfony/class-loader/Symfony/Component/ClassLoader/ClassCollectionLoader.php#L347-L366
21,271
surebert/surebert-framework
src/sb/SFTP/Client.php
Client.ls
public function ls($remote_dir) { $dir = "ssh2.sftp://".$this->sftp.$remote_dir; $handle = opendir($dir); $files = Array(); while (false !== ($file = readdir($handle))) { if (substr($file, 0, 1) != '.'){ $files[] = $file; } } closedir($handle); return $files; }
php
public function ls($remote_dir) { $dir = "ssh2.sftp://".$this->sftp.$remote_dir; $handle = opendir($dir); $files = Array(); while (false !== ($file = readdir($handle))) { if (substr($file, 0, 1) != '.'){ $files[] = $file; } } closedir($handle); return $files; }
[ "public", "function", "ls", "(", "$", "remote_dir", ")", "{", "$", "dir", "=", "\"ssh2.sftp://\"", ".", "$", "this", "->", "sftp", ".", "$", "remote_dir", ";", "$", "handle", "=", "opendir", "(", "$", "dir", ")", ";", "$", "files", "=", "Array", "(", ")", ";", "while", "(", "false", "!==", "(", "$", "file", "=", "readdir", "(", "$", "handle", ")", ")", ")", "{", "if", "(", "substr", "(", "$", "file", ",", "0", ",", "1", ")", "!=", "'.'", ")", "{", "$", "files", "[", "]", "=", "$", "file", ";", "}", "}", "closedir", "(", "$", "handle", ")", ";", "return", "$", "files", ";", "}" ]
Lists the contents of a remote directory @param string $remote_dir @return Array The array of files
[ "Lists", "the", "contents", "of", "a", "remote", "directory" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/SFTP/Client.php#L149-L164
21,272
surebert/surebert-framework
src/sb/SFTP/Client.php
Client.renameRemoteFile
public function renameRemoteFile($from, $to) { if(@ssh2_sftp_rename($this->sftp, $from, $to)){ throw new \Exception("Could not rename file from $from to $to"); } return true; }
php
public function renameRemoteFile($from, $to) { if(@ssh2_sftp_rename($this->sftp, $from, $to)){ throw new \Exception("Could not rename file from $from to $to"); } return true; }
[ "public", "function", "renameRemoteFile", "(", "$", "from", ",", "$", "to", ")", "{", "if", "(", "@", "ssh2_sftp_rename", "(", "$", "this", "->", "sftp", ",", "$", "from", ",", "$", "to", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Could not rename file from $from to $to\"", ")", ";", "}", "return", "true", ";", "}" ]
Renames remote files @param string $from The old path/file name @param string $to The new path/file name
[ "Renames", "remote", "files" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/SFTP/Client.php#L181-L188
21,273
surebert/surebert-framework
src/sb/SFTP/Client.php
Client.getFileStats
public function getFileStats($path) { $stats = @ssh2_sftp_stat($this->sftp, $path); if(!$stats['size']){ throw new \Exception("Could get file stat: ".$path); } return $stats; }
php
public function getFileStats($path) { $stats = @ssh2_sftp_stat($this->sftp, $path); if(!$stats['size']){ throw new \Exception("Could get file stat: ".$path); } return $stats; }
[ "public", "function", "getFileStats", "(", "$", "path", ")", "{", "$", "stats", "=", "@", "ssh2_sftp_stat", "(", "$", "this", "->", "sftp", ",", "$", "path", ")", ";", "if", "(", "!", "$", "stats", "[", "'size'", "]", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Could get file stat: \"", ".", "$", "path", ")", ";", "}", "return", "$", "stats", ";", "}" ]
Gets remote file stats @param string $path The path to the file to get stats for @return Array with size, gid, uid, atime, mtime, mode keys
[ "Gets", "remote", "file", "stats" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/SFTP/Client.php#L230-L237
21,274
surebert/surebert-framework
src/sb/SFTP/Client.php
Client.ssh2SftpSymlink
public function ssh2SftpSymlink($orig_path, $symlink_path) { $result = @ssh2_sftp_symlink($this->sftp, $orig_path, $symlink_path); if(!$result){ throw new \Exception("Could create symlink: ".$path); } return $result; }
php
public function ssh2SftpSymlink($orig_path, $symlink_path) { $result = @ssh2_sftp_symlink($this->sftp, $orig_path, $symlink_path); if(!$result){ throw new \Exception("Could create symlink: ".$path); } return $result; }
[ "public", "function", "ssh2SftpSymlink", "(", "$", "orig_path", ",", "$", "symlink_path", ")", "{", "$", "result", "=", "@", "ssh2_sftp_symlink", "(", "$", "this", "->", "sftp", ",", "$", "orig_path", ",", "$", "symlink_path", ")", ";", "if", "(", "!", "$", "result", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Could create symlink: \"", ".", "$", "path", ")", ";", "}", "return", "$", "result", ";", "}" ]
Create a symlink on the remote system @param string $orig_path The path to the original remote file @param string $symlink_path The path to the symlink you want to create @return boolean success or failure
[ "Create", "a", "symlink", "on", "the", "remote", "system" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/SFTP/Client.php#L259-L266
21,275
Eresus/EresusCMS
src/core/framework/core/3rdparty/ezcomponents/Cache/src/manager.php
ezcCacheManager.createCache
public static function createCache( $id, $location = null, $storageClass, $options = array() ) { // BC for missing location. The location should not be missing. if ( $location !== null ) { // Unifiy file system locations if ( substr( $location, 0, 1 ) === '/' ) { // If non-existent if ( ( $realLocation = realpath( $location ) ) === false ) { throw new ezcBaseFileNotFoundException( $location, 'cache location', 'Does not exist or is no directory.' ); } $location = $realLocation; } // Sanity check double taken locations. foreach ( self::$configurations as $confId => $config ) { if ( $config['location'] === $location ) { throw new ezcCacheUsedLocationException( $location, $confId ); } } } // Sanity check storage class. if ( !ezcBaseFeatures::classExists( $storageClass ) || !is_subclass_of( $storageClass, 'ezcCacheStorage' ) ) { throw new ezcCacheInvalidStorageClassException( $storageClass ); } self::$configurations[$id] = array( 'location' => $location, 'class' => $storageClass, 'options' => $options, ); }
php
public static function createCache( $id, $location = null, $storageClass, $options = array() ) { // BC for missing location. The location should not be missing. if ( $location !== null ) { // Unifiy file system locations if ( substr( $location, 0, 1 ) === '/' ) { // If non-existent if ( ( $realLocation = realpath( $location ) ) === false ) { throw new ezcBaseFileNotFoundException( $location, 'cache location', 'Does not exist or is no directory.' ); } $location = $realLocation; } // Sanity check double taken locations. foreach ( self::$configurations as $confId => $config ) { if ( $config['location'] === $location ) { throw new ezcCacheUsedLocationException( $location, $confId ); } } } // Sanity check storage class. if ( !ezcBaseFeatures::classExists( $storageClass ) || !is_subclass_of( $storageClass, 'ezcCacheStorage' ) ) { throw new ezcCacheInvalidStorageClassException( $storageClass ); } self::$configurations[$id] = array( 'location' => $location, 'class' => $storageClass, 'options' => $options, ); }
[ "public", "static", "function", "createCache", "(", "$", "id", ",", "$", "location", "=", "null", ",", "$", "storageClass", ",", "$", "options", "=", "array", "(", ")", ")", "{", "// BC for missing location. The location should not be missing.", "if", "(", "$", "location", "!==", "null", ")", "{", "// Unifiy file system locations", "if", "(", "substr", "(", "$", "location", ",", "0", ",", "1", ")", "===", "'/'", ")", "{", "// If non-existent", "if", "(", "(", "$", "realLocation", "=", "realpath", "(", "$", "location", ")", ")", "===", "false", ")", "{", "throw", "new", "ezcBaseFileNotFoundException", "(", "$", "location", ",", "'cache location'", ",", "'Does not exist or is no directory.'", ")", ";", "}", "$", "location", "=", "$", "realLocation", ";", "}", "// Sanity check double taken locations.", "foreach", "(", "self", "::", "$", "configurations", "as", "$", "confId", "=>", "$", "config", ")", "{", "if", "(", "$", "config", "[", "'location'", "]", "===", "$", "location", ")", "{", "throw", "new", "ezcCacheUsedLocationException", "(", "$", "location", ",", "$", "confId", ")", ";", "}", "}", "}", "// Sanity check storage class.", "if", "(", "!", "ezcBaseFeatures", "::", "classExists", "(", "$", "storageClass", ")", "||", "!", "is_subclass_of", "(", "$", "storageClass", ",", "'ezcCacheStorage'", ")", ")", "{", "throw", "new", "ezcCacheInvalidStorageClassException", "(", "$", "storageClass", ")", ";", "}", "self", "::", "$", "configurations", "[", "$", "id", "]", "=", "array", "(", "'location'", "=>", "$", "location", ",", "'class'", "=>", "$", "storageClass", ",", "'options'", "=>", "$", "options", ",", ")", ";", "}" ]
Creates a new cache in the manager. This method is used to create a new cache inside the manager. Each cache has a unique ID to access it during the application runtime. Each location may only be used by 1 cache. The $storageClass parameter must be a subclass of {@link ezcCacheStorage} and tells the manager which object will be used for the cache. The $location parameter depends on the kind of {@link ezcCacheStorage} used for the cache you create. Usually this is a directory on your file system, but may also be e.g. a data source name, if you cache in a database or similar. For memory-based storage ({@link ezcCacheStorageApcPlain} or {@link ezcCacheStorageMemcachePlain}) it is null, but for memory/file hybrid storage ({@link ezcCacheStorageFileApcArray}) it should be an existing writeable path. The $options array consists of several standard attributes and can additionally contain options defined by the {@link ezcCacheStorage} class. Standard options are: <code> array( 'ttl' => 60*60*24, // Time-to-life, default: 1 day ); </code> @param string $id ID of the cache to create. @param string $location Location to create the cache in. Null for memory-based storage and an existing writeable path for file or memory/file storage. @param string $storageClass Subclass of {@link ezcCacheStorage}. @param array(string=>string) $options Options for the cache. @return void @throws ezcBaseFileNotFoundException If the given location does not exist or is not a directory (thrown by sanity checks performed when storing the configuration of a cache to ensure the latter calls to {@link ezcCacheManager::getCache()} do not fail). @throws ezcBaseFilePermissionException If the given location is not read/writeable (thrown by sanity checks performed when storing the configuration of a cache to ensure the latter calls to {@link ezcCacheManager::getCache()} do not fail). @throws ezcCacheUsedLocationException If the given location is already in use by another cache. @throws ezcCacheInvalidStorageClassException If the given storage class does not exist or is no subclass of ezcCacheStorage.
[ "Creates", "a", "new", "cache", "in", "the", "manager", ".", "This", "method", "is", "used", "to", "create", "a", "new", "cache", "inside", "the", "manager", ".", "Each", "cache", "has", "a", "unique", "ID", "to", "access", "it", "during", "the", "application", "runtime", ".", "Each", "location", "may", "only", "be", "used", "by", "1", "cache", "." ]
b0afc661105f0a2f65d49abac13956cc93c5188d
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Cache/src/manager.php#L196-L236
21,276
ShaoZeMing/laravel-merchant
src/Form/Builder.php
Builder.addRedirectUrlField
protected function addRedirectUrlField() { $previous = URL::previous(); if (!$previous || $previous == URL::current()) { return; } if (Str::contains($previous, url($this->getResource()))) { $this->addHiddenField((new Form\Field\Hidden(static::PREVIOUS_URL_KEY))->value($previous)); } }
php
protected function addRedirectUrlField() { $previous = URL::previous(); if (!$previous || $previous == URL::current()) { return; } if (Str::contains($previous, url($this->getResource()))) { $this->addHiddenField((new Form\Field\Hidden(static::PREVIOUS_URL_KEY))->value($previous)); } }
[ "protected", "function", "addRedirectUrlField", "(", ")", "{", "$", "previous", "=", "URL", "::", "previous", "(", ")", ";", "if", "(", "!", "$", "previous", "||", "$", "previous", "==", "URL", "::", "current", "(", ")", ")", "{", "return", ";", "}", "if", "(", "Str", "::", "contains", "(", "$", "previous", ",", "url", "(", "$", "this", "->", "getResource", "(", ")", ")", ")", ")", "{", "$", "this", "->", "addHiddenField", "(", "(", "new", "Form", "\\", "Field", "\\", "Hidden", "(", "static", "::", "PREVIOUS_URL_KEY", ")", ")", "->", "value", "(", "$", "previous", ")", ")", ";", "}", "}" ]
Add field for store redirect url after update or store. @return void
[ "Add", "field", "for", "store", "redirect", "url", "after", "update", "or", "store", "." ]
20801b1735e7832a6e58b37c2c391328f8d626fa
https://github.com/ShaoZeMing/laravel-merchant/blob/20801b1735e7832a6e58b37c2c391328f8d626fa/src/Form/Builder.php#L371-L382
21,277
zicht/z
src/Zicht/Tool/Configuration/FileLoader.php
FileLoader.processPlugins
protected function processPlugins($plugins, $dir) { foreach ($plugins as $plugin) { $this->addPlugin($plugin, $dir); } }
php
protected function processPlugins($plugins, $dir) { foreach ($plugins as $plugin) { $this->addPlugin($plugin, $dir); } }
[ "protected", "function", "processPlugins", "(", "$", "plugins", ",", "$", "dir", ")", "{", "foreach", "(", "$", "plugins", "as", "$", "plugin", ")", "{", "$", "this", "->", "addPlugin", "(", "$", "plugin", ",", "$", "dir", ")", ";", "}", "}" ]
Processes plugin definitions @param array $plugins @param string $dir @return void
[ "Processes", "plugin", "definitions" ]
6a1731dad20b018555a96b726a61d4bf8ec8c886
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Configuration/FileLoader.php#L191-L196
21,278
zicht/z
src/Zicht/Tool/Configuration/FileLoader.php
FileLoader.addPlugin
public function addPlugin($name, $dir) { Debug::enterScope($name); $hasPlugin = $hasZfile = false; try { $this->plugins[$name] = $this->getLocator()->locate($name . '/Plugin.php', $dir, true); $this->pluginPaths[$name] = dirname($this->plugins[$name]); $hasPlugin = true; $this->sourceFiles[] = $this->plugins[$name]; } catch (\InvalidArgumentException $e) { } try { $zFileLocation = $this->getLocator()->locate($name . '/z.yml', $dir); $this->import($zFileLocation, self::PLUGIN); if (!isset($this->pluginPaths[$name])) { $this->pluginPaths[$name] = dirname($zFileLocation); } else if ($this->pluginPaths[$name] != dirname($zFileLocation)) { throw new \UnexpectedValueException( "Ambiguous plugin configuration:\n" . "There was a Plugin.php found in {$this->pluginPaths[$name]}, but also a z.yml at $zFileLocation" ); } $hasZfile = true; $this->sourceFiles[] = $zFileLocation; } catch (\InvalidArgumentException $e) { } if (!$hasPlugin && !$hasZfile) { throw new \InvalidArgumentException("You need at least either a z.yml or a Plugin.php in the plugin path for '{$name}'"); } Debug::exitScope($name); }
php
public function addPlugin($name, $dir) { Debug::enterScope($name); $hasPlugin = $hasZfile = false; try { $this->plugins[$name] = $this->getLocator()->locate($name . '/Plugin.php', $dir, true); $this->pluginPaths[$name] = dirname($this->plugins[$name]); $hasPlugin = true; $this->sourceFiles[] = $this->plugins[$name]; } catch (\InvalidArgumentException $e) { } try { $zFileLocation = $this->getLocator()->locate($name . '/z.yml', $dir); $this->import($zFileLocation, self::PLUGIN); if (!isset($this->pluginPaths[$name])) { $this->pluginPaths[$name] = dirname($zFileLocation); } else if ($this->pluginPaths[$name] != dirname($zFileLocation)) { throw new \UnexpectedValueException( "Ambiguous plugin configuration:\n" . "There was a Plugin.php found in {$this->pluginPaths[$name]}, but also a z.yml at $zFileLocation" ); } $hasZfile = true; $this->sourceFiles[] = $zFileLocation; } catch (\InvalidArgumentException $e) { } if (!$hasPlugin && !$hasZfile) { throw new \InvalidArgumentException("You need at least either a z.yml or a Plugin.php in the plugin path for '{$name}'"); } Debug::exitScope($name); }
[ "public", "function", "addPlugin", "(", "$", "name", ",", "$", "dir", ")", "{", "Debug", "::", "enterScope", "(", "$", "name", ")", ";", "$", "hasPlugin", "=", "$", "hasZfile", "=", "false", ";", "try", "{", "$", "this", "->", "plugins", "[", "$", "name", "]", "=", "$", "this", "->", "getLocator", "(", ")", "->", "locate", "(", "$", "name", ".", "'/Plugin.php'", ",", "$", "dir", ",", "true", ")", ";", "$", "this", "->", "pluginPaths", "[", "$", "name", "]", "=", "dirname", "(", "$", "this", "->", "plugins", "[", "$", "name", "]", ")", ";", "$", "hasPlugin", "=", "true", ";", "$", "this", "->", "sourceFiles", "[", "]", "=", "$", "this", "->", "plugins", "[", "$", "name", "]", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "}", "try", "{", "$", "zFileLocation", "=", "$", "this", "->", "getLocator", "(", ")", "->", "locate", "(", "$", "name", ".", "'/z.yml'", ",", "$", "dir", ")", ";", "$", "this", "->", "import", "(", "$", "zFileLocation", ",", "self", "::", "PLUGIN", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "pluginPaths", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "pluginPaths", "[", "$", "name", "]", "=", "dirname", "(", "$", "zFileLocation", ")", ";", "}", "else", "if", "(", "$", "this", "->", "pluginPaths", "[", "$", "name", "]", "!=", "dirname", "(", "$", "zFileLocation", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Ambiguous plugin configuration:\\n\"", ".", "\"There was a Plugin.php found in {$this->pluginPaths[$name]}, but also a z.yml at $zFileLocation\"", ")", ";", "}", "$", "hasZfile", "=", "true", ";", "$", "this", "->", "sourceFiles", "[", "]", "=", "$", "zFileLocation", ";", "}", "catch", "(", "\\", "InvalidArgumentException", "$", "e", ")", "{", "}", "if", "(", "!", "$", "hasPlugin", "&&", "!", "$", "hasZfile", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"You need at least either a z.yml or a Plugin.php in the plugin path for '{$name}'\"", ")", ";", "}", "Debug", "::", "exitScope", "(", "$", "name", ")", ";", "}" ]
Add a plugin at the passed location @param string $name @param string $dir @return void @throws \InvalidArgumentException @throws \UnexpectedValueException
[ "Add", "a", "plugin", "at", "the", "passed", "location" ]
6a1731dad20b018555a96b726a61d4bf8ec8c886
https://github.com/zicht/z/blob/6a1731dad20b018555a96b726a61d4bf8ec8c886/src/Zicht/Tool/Configuration/FileLoader.php#L208-L243
21,279
zhouyl/mellivora
Mellivora/Database/Eloquent/FactoryBuilder.php
FactoryBuilder.callClosureAttributes
protected function callClosureAttributes(array $attributes) { foreach ($attributes as &$attribute) { $attribute = $attribute instanceof Closure ? $attribute($attributes) : $attribute; } return $attributes; }
php
protected function callClosureAttributes(array $attributes) { foreach ($attributes as &$attribute) { $attribute = $attribute instanceof Closure ? $attribute($attributes) : $attribute; } return $attributes; }
[ "protected", "function", "callClosureAttributes", "(", "array", "$", "attributes", ")", "{", "foreach", "(", "$", "attributes", "as", "&", "$", "attribute", ")", "{", "$", "attribute", "=", "$", "attribute", "instanceof", "Closure", "?", "$", "attribute", "(", "$", "attributes", ")", ":", "$", "attribute", ";", "}", "return", "$", "attributes", ";", "}" ]
Evaluate any Closure attributes on the attribute array. @param array $attributes @return array
[ "Evaluate", "any", "Closure", "attributes", "on", "the", "attribute", "array", "." ]
79f844c5c9c25ffbe18d142062e9bc3df00b36a1
https://github.com/zhouyl/mellivora/blob/79f844c5c9c25ffbe18d142062e9bc3df00b36a1/Mellivora/Database/Eloquent/FactoryBuilder.php#L210-L218
21,280
Salamek/nette-tempnam
src/Salamek/Tempnam/Tempnam.php
Tempnam.remove
public function remove($key) { $keyGen = $this->generateKey($key); $this->cache->remove($keyGen); @unlink($this->getFilePath($keyGen)); }
php
public function remove($key) { $keyGen = $this->generateKey($key); $this->cache->remove($keyGen); @unlink($this->getFilePath($keyGen)); }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "$", "keyGen", "=", "$", "this", "->", "generateKey", "(", "$", "key", ")", ";", "$", "this", "->", "cache", "->", "remove", "(", "$", "keyGen", ")", ";", "@", "unlink", "(", "$", "this", "->", "getFilePath", "(", "$", "keyGen", ")", ")", ";", "}" ]
Removes tempnam file by its key @param $key string tempnam key
[ "Removes", "tempnam", "file", "by", "its", "key" ]
47af43ec9a3f9f812177c83f021ffafeeff0305e
https://github.com/Salamek/nette-tempnam/blob/47af43ec9a3f9f812177c83f021ffafeeff0305e/src/Salamek/Tempnam/Tempnam.php#L116-L121
21,281
Salamek/nette-tempnam
src/Salamek/Tempnam/Tempnam.php
Tempnam.load
public function load($key, \DateTimeInterface $updatedAt = null) { $keyGen = $this->generateKey($key); $updateDate = $this->cache->load($keyGen); if ($updateDate === null || $updateDate != $updatedAt) { if ($updateDate) { $this->remove($key); } return null; } return $this->getFilePath($keyGen); }
php
public function load($key, \DateTimeInterface $updatedAt = null) { $keyGen = $this->generateKey($key); $updateDate = $this->cache->load($keyGen); if ($updateDate === null || $updateDate != $updatedAt) { if ($updateDate) { $this->remove($key); } return null; } return $this->getFilePath($keyGen); }
[ "public", "function", "load", "(", "$", "key", ",", "\\", "DateTimeInterface", "$", "updatedAt", "=", "null", ")", "{", "$", "keyGen", "=", "$", "this", "->", "generateKey", "(", "$", "key", ")", ";", "$", "updateDate", "=", "$", "this", "->", "cache", "->", "load", "(", "$", "keyGen", ")", ";", "if", "(", "$", "updateDate", "===", "null", "||", "$", "updateDate", "!=", "$", "updatedAt", ")", "{", "if", "(", "$", "updateDate", ")", "{", "$", "this", "->", "remove", "(", "$", "key", ")", ";", "}", "return", "null", ";", "}", "return", "$", "this", "->", "getFilePath", "(", "$", "keyGen", ")", ";", "}" ]
Loads tempnam file path @param $key string tempnam key @param \DateTimeInterface|null $updatedAt When data was last updated @return null|string path to tempnam
[ "Loads", "tempnam", "file", "path" ]
47af43ec9a3f9f812177c83f021ffafeeff0305e
https://github.com/Salamek/nette-tempnam/blob/47af43ec9a3f9f812177c83f021ffafeeff0305e/src/Salamek/Tempnam/Tempnam.php#L129-L142
21,282
Salamek/nette-tempnam
src/Salamek/Tempnam/Tempnam.php
Tempnam.save
public function save($key, $data, \DateTimeInterface $updatedAt = null) { $keyGen = $this->generateKey($key); $path = $this->putFile($keyGen, $data); $this->cache->save($keyGen, $updatedAt); return $path; }
php
public function save($key, $data, \DateTimeInterface $updatedAt = null) { $keyGen = $this->generateKey($key); $path = $this->putFile($keyGen, $data); $this->cache->save($keyGen, $updatedAt); return $path; }
[ "public", "function", "save", "(", "$", "key", ",", "$", "data", ",", "\\", "DateTimeInterface", "$", "updatedAt", "=", "null", ")", "{", "$", "keyGen", "=", "$", "this", "->", "generateKey", "(", "$", "key", ")", ";", "$", "path", "=", "$", "this", "->", "putFile", "(", "$", "keyGen", ",", "$", "data", ")", ";", "$", "this", "->", "cache", "->", "save", "(", "$", "keyGen", ",", "$", "updatedAt", ")", ";", "return", "$", "path", ";", "}" ]
Saves tempnam file and returns its path @param $key string tempnam key @param $data string content of file @param \DateTimeInterface|null $updatedAt When data was last updated @return string path to tempnam
[ "Saves", "tempnam", "file", "and", "returns", "its", "path" ]
47af43ec9a3f9f812177c83f021ffafeeff0305e
https://github.com/Salamek/nette-tempnam/blob/47af43ec9a3f9f812177c83f021ffafeeff0305e/src/Salamek/Tempnam/Tempnam.php#L151-L157
21,283
Salamek/nette-tempnam
src/Salamek/Tempnam/Tempnam.php
Tempnam.clean
private function clean() { foreach (Finder::find($this->namespace . '*')->from($this->tempDir)->childFirst() as $entry) { $path = (string)$entry; if ($entry->isDir()) { //We dont use dirs, ignore continue; } $updateDate = $this->cache->load($entry->getFilename()); if ($updateDate === null) { @unlink($path); } } return; }
php
private function clean() { foreach (Finder::find($this->namespace . '*')->from($this->tempDir)->childFirst() as $entry) { $path = (string)$entry; if ($entry->isDir()) { //We dont use dirs, ignore continue; } $updateDate = $this->cache->load($entry->getFilename()); if ($updateDate === null) { @unlink($path); } } return; }
[ "private", "function", "clean", "(", ")", "{", "foreach", "(", "Finder", "::", "find", "(", "$", "this", "->", "namespace", ".", "'*'", ")", "->", "from", "(", "$", "this", "->", "tempDir", ")", "->", "childFirst", "(", ")", "as", "$", "entry", ")", "{", "$", "path", "=", "(", "string", ")", "$", "entry", ";", "if", "(", "$", "entry", "->", "isDir", "(", ")", ")", "{", "//We dont use dirs, ignore", "continue", ";", "}", "$", "updateDate", "=", "$", "this", "->", "cache", "->", "load", "(", "$", "entry", "->", "getFilename", "(", ")", ")", ";", "if", "(", "$", "updateDate", "===", "null", ")", "{", "@", "unlink", "(", "$", "path", ")", ";", "}", "}", "return", ";", "}" ]
Cleans unused tempnam files @return void
[ "Cleans", "unused", "tempnam", "files" ]
47af43ec9a3f9f812177c83f021ffafeeff0305e
https://github.com/Salamek/nette-tempnam/blob/47af43ec9a3f9f812177c83f021ffafeeff0305e/src/Salamek/Tempnam/Tempnam.php#L163-L179
21,284
willhoffmann/domuserp-php
src/Resources/People/People.php
People.deliveryAddresses
public function deliveryAddresses($personId) { $deliveryAddresses = $this->execute( self::HTTP_GET, self::DOMUSERP_API_PEDIDOVENDA . '/pessoas/' . $personId . '/enderecosentrega' ); return $deliveryAddresses; }
php
public function deliveryAddresses($personId) { $deliveryAddresses = $this->execute( self::HTTP_GET, self::DOMUSERP_API_PEDIDOVENDA . '/pessoas/' . $personId . '/enderecosentrega' ); return $deliveryAddresses; }
[ "public", "function", "deliveryAddresses", "(", "$", "personId", ")", "{", "$", "deliveryAddresses", "=", "$", "this", "->", "execute", "(", "self", "::", "HTTP_GET", ",", "self", "::", "DOMUSERP_API_PEDIDOVENDA", ".", "'/pessoas/'", ".", "$", "personId", ".", "'/enderecosentrega'", ")", ";", "return", "$", "deliveryAddresses", ";", "}" ]
Gets the delivery address of the person according to the id passed as parameter @param $personId @return string @throws \GuzzleHttp\Exception\GuzzleException
[ "Gets", "the", "delivery", "address", "of", "the", "person", "according", "to", "the", "id", "passed", "as", "parameter" ]
44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6
https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/People/People.php#L47-L55
21,285
willhoffmann/domuserp-php
src/Resources/People/People.php
People.orderDefaultValues
public function orderDefaultValues($personId) { $orderDefaultValues = $this->execute( self::HTTP_GET, self::DOMUSERP_API_PEDIDOVENDA . '/pessoas/' . $personId . '/valoresPadraoPedido' ); return $orderDefaultValues; }
php
public function orderDefaultValues($personId) { $orderDefaultValues = $this->execute( self::HTTP_GET, self::DOMUSERP_API_PEDIDOVENDA . '/pessoas/' . $personId . '/valoresPadraoPedido' ); return $orderDefaultValues; }
[ "public", "function", "orderDefaultValues", "(", "$", "personId", ")", "{", "$", "orderDefaultValues", "=", "$", "this", "->", "execute", "(", "self", "::", "HTTP_GET", ",", "self", "::", "DOMUSERP_API_PEDIDOVENDA", ".", "'/pessoas/'", ".", "$", "personId", ".", "'/valoresPadraoPedido'", ")", ";", "return", "$", "orderDefaultValues", ";", "}" ]
Gets the order default values of a person according to the person id passed as parameter @param $personId @return string @throws \GuzzleHttp\Exception\GuzzleException
[ "Gets", "the", "order", "default", "values", "of", "a", "person", "according", "to", "the", "person", "id", "passed", "as", "parameter" ]
44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6
https://github.com/willhoffmann/domuserp-php/blob/44e77a4f02b0252bc26cae4c0e6b2b7d578f10a6/src/Resources/People/People.php#L64-L72
21,286
surebert/surebert-framework
src/sb/Excel/Workbook.php
Workbook.addStyle
public function addStyle($name, $properties) { $style = $this->createElement('ss:Style'); $style->setAttribute('ss:ID', $name); $this->styles->appendChild($style); $font = $this->createElement('ss:Font'); $style->appendChild($font); foreach($properties as $prop=>$val){ $font->setAttribute('ss:'.$prop, $val); } return $style; }
php
public function addStyle($name, $properties) { $style = $this->createElement('ss:Style'); $style->setAttribute('ss:ID', $name); $this->styles->appendChild($style); $font = $this->createElement('ss:Font'); $style->appendChild($font); foreach($properties as $prop=>$val){ $font->setAttribute('ss:'.$prop, $val); } return $style; }
[ "public", "function", "addStyle", "(", "$", "name", ",", "$", "properties", ")", "{", "$", "style", "=", "$", "this", "->", "createElement", "(", "'ss:Style'", ")", ";", "$", "style", "->", "setAttribute", "(", "'ss:ID'", ",", "$", "name", ")", ";", "$", "this", "->", "styles", "->", "appendChild", "(", "$", "style", ")", ";", "$", "font", "=", "$", "this", "->", "createElement", "(", "'ss:Font'", ")", ";", "$", "style", "->", "appendChild", "(", "$", "font", ")", ";", "foreach", "(", "$", "properties", "as", "$", "prop", "=>", "$", "val", ")", "{", "$", "font", "->", "setAttribute", "(", "'ss:'", ".", "$", "prop", ",", "$", "val", ")", ";", "}", "return", "$", "style", ";", "}" ]
Creates a new style node and adds it to the styles section @param string $name The name of the style, used when assigning it @param array $properties http://msdn.microsoft.com/en-us/library/aa140066%28office.10%29.aspx#odc_xmlss_ss:font e.g. Array('Color' => '#FF0000', 'Bold' => 1); @return DOMElement The Style tag itself
[ "Creates", "a", "new", "style", "node", "and", "adds", "it", "to", "the", "styles", "section" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Workbook.php#L82-L93
21,287
surebert/surebert-framework
src/sb/Excel/Workbook.php
Workbook.addWorksheet
public function addWorksheet($title) { $worksheet = $this->workbook->appendChild($this->createElement('Worksheet')); $title = preg_replace("/[\\\|:|\/|\?|\*|\[|\]]/", "", $title); $title = substr($title, 0, 31); $worksheet->setAttribute('ss:Name', $title); $worksheet->table = $worksheet->appendChild($this->createElement('Table')); $this->worksheets[md5($title)] = $worksheet; return $worksheet; }
php
public function addWorksheet($title) { $worksheet = $this->workbook->appendChild($this->createElement('Worksheet')); $title = preg_replace("/[\\\|:|\/|\?|\*|\[|\]]/", "", $title); $title = substr($title, 0, 31); $worksheet->setAttribute('ss:Name', $title); $worksheet->table = $worksheet->appendChild($this->createElement('Table')); $this->worksheets[md5($title)] = $worksheet; return $worksheet; }
[ "public", "function", "addWorksheet", "(", "$", "title", ")", "{", "$", "worksheet", "=", "$", "this", "->", "workbook", "->", "appendChild", "(", "$", "this", "->", "createElement", "(", "'Worksheet'", ")", ")", ";", "$", "title", "=", "preg_replace", "(", "\"/[\\\\\\|:|\\/|\\?|\\*|\\[|\\]]/\"", ",", "\"\"", ",", "$", "title", ")", ";", "$", "title", "=", "substr", "(", "$", "title", ",", "0", ",", "31", ")", ";", "$", "worksheet", "->", "setAttribute", "(", "'ss:Name'", ",", "$", "title", ")", ";", "$", "worksheet", "->", "table", "=", "$", "worksheet", "->", "appendChild", "(", "$", "this", "->", "createElement", "(", "'Table'", ")", ")", ";", "$", "this", "->", "worksheets", "[", "md5", "(", "$", "title", ")", "]", "=", "$", "worksheet", ";", "return", "$", "worksheet", ";", "}" ]
Adds a new worksheet to the workbook @param string $title @return DOMElement The worksheet itself
[ "Adds", "a", "new", "worksheet", "to", "the", "workbook" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Workbook.php#L115-L124
21,288
surebert/surebert-framework
src/sb/Excel/Workbook.php
Workbook.setActiveWorksheet
public function setActiveWorksheet($worksheet) { if(is_string($worksheet)){ $worksheet = $this->worksheets[md5($worksheet)]; } $this->active_worksheet = $worksheet; return $worksheet; }
php
public function setActiveWorksheet($worksheet) { if(is_string($worksheet)){ $worksheet = $this->worksheets[md5($worksheet)]; } $this->active_worksheet = $worksheet; return $worksheet; }
[ "public", "function", "setActiveWorksheet", "(", "$", "worksheet", ")", "{", "if", "(", "is_string", "(", "$", "worksheet", ")", ")", "{", "$", "worksheet", "=", "$", "this", "->", "worksheets", "[", "md5", "(", "$", "worksheet", ")", "]", ";", "}", "$", "this", "->", "active_worksheet", "=", "$", "worksheet", ";", "return", "$", "worksheet", ";", "}" ]
Sets the active worksheet @param string $worksheet The name of the worksheet or a reference to the DOMElement itself @return DOMElement The active worksheet
[ "Sets", "the", "active", "worksheet" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Workbook.php#L131-L139
21,289
surebert/surebert-framework
src/sb/Excel/Workbook.php
Workbook.setRow
public function setRow($row_index, $values_arr, $type=null) { $cell = null; foreach($values_arr as $col_index=>$val){ $cell = $this->setCell($col_index+1, $row_index, $val, $type); } if($cell){ return $cell->parentNode; } return false; }
php
public function setRow($row_index, $values_arr, $type=null) { $cell = null; foreach($values_arr as $col_index=>$val){ $cell = $this->setCell($col_index+1, $row_index, $val, $type); } if($cell){ return $cell->parentNode; } return false; }
[ "public", "function", "setRow", "(", "$", "row_index", ",", "$", "values_arr", ",", "$", "type", "=", "null", ")", "{", "$", "cell", "=", "null", ";", "foreach", "(", "$", "values_arr", "as", "$", "col_index", "=>", "$", "val", ")", "{", "$", "cell", "=", "$", "this", "->", "setCell", "(", "$", "col_index", "+", "1", ",", "$", "row_index", ",", "$", "val", ",", "$", "type", ")", ";", "}", "if", "(", "$", "cell", ")", "{", "return", "$", "cell", "->", "parentNode", ";", "}", "return", "false", ";", "}" ]
Sets an entire row of data @param integer $row_index The 1 based row index to use @param array $values_arr An array of values @param string $type ss:Type attribute @return DOMElement The row
[ "Sets", "an", "entire", "row", "of", "data" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Workbook.php#L148-L159
21,290
surebert/surebert-framework
src/sb/Excel/Workbook.php
Workbook.setCell
public function setCell($col_index, $row_index, $val, $type=null) { $result = $this->xpath->query("//Row[@Index='".$row_index."']/Cell[@Index='".$col_index."']/Data", $this->active_worksheet); $data = $result->item(0); $type = $type ? $type : $this->getValueType($val); if($data){ $data->setAttribute('ss:Type', $type); $data->firstChild->nodeValue = $val; } else { $result = $this->xpath->query("//Row[@Index='".$row_index."']"); $row = $result->item(0); if(!$row){ $row = $this->createElement('Row'); $this->active_worksheet->table->appendChild($row); $row->setAttribute('Index', $row_index); } $result = $this->xpath->query("//Row[@Index='".$row_index."']/Cell[@Index='".$col_index."']", $row); $cell = $result->item(0); if(!$cell){ $cell = $this->createElement('Cell'); $row->appendChild($cell); $cell->setAttribute('Index', $col_index); $data = $this->createElement('Data'); $cell->appendChild($data); $data->setAttribute('ss:Type', $type); $data->appendChild($this->createTextNode($val)); } else { $data = $cell->getElementsByTagName('Data')->item(0); $data->setAttribute('ss:Type', $type); $data->firstChild->nodeValue = $val; } } return $data->parentNode; }
php
public function setCell($col_index, $row_index, $val, $type=null) { $result = $this->xpath->query("//Row[@Index='".$row_index."']/Cell[@Index='".$col_index."']/Data", $this->active_worksheet); $data = $result->item(0); $type = $type ? $type : $this->getValueType($val); if($data){ $data->setAttribute('ss:Type', $type); $data->firstChild->nodeValue = $val; } else { $result = $this->xpath->query("//Row[@Index='".$row_index."']"); $row = $result->item(0); if(!$row){ $row = $this->createElement('Row'); $this->active_worksheet->table->appendChild($row); $row->setAttribute('Index', $row_index); } $result = $this->xpath->query("//Row[@Index='".$row_index."']/Cell[@Index='".$col_index."']", $row); $cell = $result->item(0); if(!$cell){ $cell = $this->createElement('Cell'); $row->appendChild($cell); $cell->setAttribute('Index', $col_index); $data = $this->createElement('Data'); $cell->appendChild($data); $data->setAttribute('ss:Type', $type); $data->appendChild($this->createTextNode($val)); } else { $data = $cell->getElementsByTagName('Data')->item(0); $data->setAttribute('ss:Type', $type); $data->firstChild->nodeValue = $val; } } return $data->parentNode; }
[ "public", "function", "setCell", "(", "$", "col_index", ",", "$", "row_index", ",", "$", "val", ",", "$", "type", "=", "null", ")", "{", "$", "result", "=", "$", "this", "->", "xpath", "->", "query", "(", "\"//Row[@Index='\"", ".", "$", "row_index", ".", "\"']/Cell[@Index='\"", ".", "$", "col_index", ".", "\"']/Data\"", ",", "$", "this", "->", "active_worksheet", ")", ";", "$", "data", "=", "$", "result", "->", "item", "(", "0", ")", ";", "$", "type", "=", "$", "type", "?", "$", "type", ":", "$", "this", "->", "getValueType", "(", "$", "val", ")", ";", "if", "(", "$", "data", ")", "{", "$", "data", "->", "setAttribute", "(", "'ss:Type'", ",", "$", "type", ")", ";", "$", "data", "->", "firstChild", "->", "nodeValue", "=", "$", "val", ";", "}", "else", "{", "$", "result", "=", "$", "this", "->", "xpath", "->", "query", "(", "\"//Row[@Index='\"", ".", "$", "row_index", ".", "\"']\"", ")", ";", "$", "row", "=", "$", "result", "->", "item", "(", "0", ")", ";", "if", "(", "!", "$", "row", ")", "{", "$", "row", "=", "$", "this", "->", "createElement", "(", "'Row'", ")", ";", "$", "this", "->", "active_worksheet", "->", "table", "->", "appendChild", "(", "$", "row", ")", ";", "$", "row", "->", "setAttribute", "(", "'Index'", ",", "$", "row_index", ")", ";", "}", "$", "result", "=", "$", "this", "->", "xpath", "->", "query", "(", "\"//Row[@Index='\"", ".", "$", "row_index", ".", "\"']/Cell[@Index='\"", ".", "$", "col_index", ".", "\"']\"", ",", "$", "row", ")", ";", "$", "cell", "=", "$", "result", "->", "item", "(", "0", ")", ";", "if", "(", "!", "$", "cell", ")", "{", "$", "cell", "=", "$", "this", "->", "createElement", "(", "'Cell'", ")", ";", "$", "row", "->", "appendChild", "(", "$", "cell", ")", ";", "$", "cell", "->", "setAttribute", "(", "'Index'", ",", "$", "col_index", ")", ";", "$", "data", "=", "$", "this", "->", "createElement", "(", "'Data'", ")", ";", "$", "cell", "->", "appendChild", "(", "$", "data", ")", ";", "$", "data", "->", "setAttribute", "(", "'ss:Type'", ",", "$", "type", ")", ";", "$", "data", "->", "appendChild", "(", "$", "this", "->", "createTextNode", "(", "$", "val", ")", ")", ";", "}", "else", "{", "$", "data", "=", "$", "cell", "->", "getElementsByTagName", "(", "'Data'", ")", "->", "item", "(", "0", ")", ";", "$", "data", "->", "setAttribute", "(", "'ss:Type'", ",", "$", "type", ")", ";", "$", "data", "->", "firstChild", "->", "nodeValue", "=", "$", "val", ";", "}", "}", "return", "$", "data", "->", "parentNode", ";", "}" ]
Sets a cell by 1 based column and row index @param integer $col_index 1based column index @param integer $row_index 1 based row index @param mixed $val The value to insert @param string $type The ss:Type attribute @return DOMElement the cell itself
[ "Sets", "a", "cell", "by", "1", "based", "column", "and", "row", "index" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Workbook.php#L169-L210
21,291
surebert/surebert-framework
src/sb/Excel/Workbook.php
Workbook.outputWithHeaders
public function outputWithHeaders($filename='worksheet') { $filename = preg_replace('/[^aA-zZ0-9\_\-]/', '', $filename); header("Content-Type: application/msexcel; charset=" . $this->encoding); header("Content-Disposition: inline; filename=\"" . $filename . ".xlsx\""); echo $this->__toString(); }
php
public function outputWithHeaders($filename='worksheet') { $filename = preg_replace('/[^aA-zZ0-9\_\-]/', '', $filename); header("Content-Type: application/msexcel; charset=" . $this->encoding); header("Content-Disposition: inline; filename=\"" . $filename . ".xlsx\""); echo $this->__toString(); }
[ "public", "function", "outputWithHeaders", "(", "$", "filename", "=", "'worksheet'", ")", "{", "$", "filename", "=", "preg_replace", "(", "'/[^aA-zZ0-9\\_\\-]/'", ",", "''", ",", "$", "filename", ")", ";", "header", "(", "\"Content-Type: application/msexcel; charset=\"", ".", "$", "this", "->", "encoding", ")", ";", "header", "(", "\"Content-Disposition: inline; filename=\\\"\"", ".", "$", "filename", ".", "\".xlsx\\\"\"", ")", ";", "echo", "$", "this", "->", "__toString", "(", ")", ";", "}" ]
Used to generate the xml with output headers @param string $filename Name of excel file to generate (...xls) default worksheet.xls
[ "Used", "to", "generate", "the", "xml", "with", "output", "headers" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Workbook.php#L242-L249
21,292
surebert/surebert-framework
src/sb/Excel/Workbook.php
Workbook.getValueType
protected function getValueType($val) { $type = 'String'; if ($this->auto_convert_types === true && is_numeric($val)) { $type = 'Number'; } return $type; }
php
protected function getValueType($val) { $type = 'String'; if ($this->auto_convert_types === true && is_numeric($val)) { $type = 'Number'; } return $type; }
[ "protected", "function", "getValueType", "(", "$", "val", ")", "{", "$", "type", "=", "'String'", ";", "if", "(", "$", "this", "->", "auto_convert_types", "===", "true", "&&", "is_numeric", "(", "$", "val", ")", ")", "{", "$", "type", "=", "'Number'", ";", "}", "return", "$", "type", ";", "}" ]
Determines value type @param string $val @return string
[ "Determines", "value", "type" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Workbook.php#L274-L282
21,293
surebert/surebert-framework
src/sb/Excel/Workbook.php
Workbook.alphaIndexToNumeric
protected function alphaIndexToNumeric($alpha_index) { preg_match("~([A-Z]+)(\d)+~", $alpha_index, $match); $letters = range('A', 'Z'); $letters = array_flip($letters); $col_index = 0; $strlen = strlen($match[1]); if($strlen== 1){ $col_index += ($letters[$match[1]]+1); } elseif($strlen > 1){ $arr = str_split($match[1]); $last = array_pop($arr); foreach($arr as $letter){ $col_index += ($letters[$letter]+1)*26; } $col_index += ($letters[$last]+1); } return Array($col_index, $match[2]); }
php
protected function alphaIndexToNumeric($alpha_index) { preg_match("~([A-Z]+)(\d)+~", $alpha_index, $match); $letters = range('A', 'Z'); $letters = array_flip($letters); $col_index = 0; $strlen = strlen($match[1]); if($strlen== 1){ $col_index += ($letters[$match[1]]+1); } elseif($strlen > 1){ $arr = str_split($match[1]); $last = array_pop($arr); foreach($arr as $letter){ $col_index += ($letters[$letter]+1)*26; } $col_index += ($letters[$last]+1); } return Array($col_index, $match[2]); }
[ "protected", "function", "alphaIndexToNumeric", "(", "$", "alpha_index", ")", "{", "preg_match", "(", "\"~([A-Z]+)(\\d)+~\"", ",", "$", "alpha_index", ",", "$", "match", ")", ";", "$", "letters", "=", "range", "(", "'A'", ",", "'Z'", ")", ";", "$", "letters", "=", "array_flip", "(", "$", "letters", ")", ";", "$", "col_index", "=", "0", ";", "$", "strlen", "=", "strlen", "(", "$", "match", "[", "1", "]", ")", ";", "if", "(", "$", "strlen", "==", "1", ")", "{", "$", "col_index", "+=", "(", "$", "letters", "[", "$", "match", "[", "1", "]", "]", "+", "1", ")", ";", "}", "elseif", "(", "$", "strlen", ">", "1", ")", "{", "$", "arr", "=", "str_split", "(", "$", "match", "[", "1", "]", ")", ";", "$", "last", "=", "array_pop", "(", "$", "arr", ")", ";", "foreach", "(", "$", "arr", "as", "$", "letter", ")", "{", "$", "col_index", "+=", "(", "$", "letters", "[", "$", "letter", "]", "+", "1", ")", "*", "26", ";", "}", "$", "col_index", "+=", "(", "$", "letters", "[", "$", "last", "]", "+", "1", ")", ";", "}", "return", "Array", "(", "$", "col_index", ",", "$", "match", "[", "2", "]", ")", ";", "}" ]
Converts Alpha column data to numeric indexes @param string $alpha_index e.g. A1 or AA4 @return array (col, row)
[ "Converts", "Alpha", "column", "data", "to", "numeric", "indexes" ]
f2f32eb693bd39385ceb93355efb5b2a429f27ce
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Workbook.php#L289-L310
21,294
ronaldborla/chikka
src/Borla/Chikka/Models/Message.php
Message.getMessageType
public function getMessageType() { // Get message type $messageType = static::types()[$this->type]; // If not incoming if ($this->type != static::INCOMING) { // Change to uppercase $messageType = strtoupper($messageType); } // Return return $messageType; }
php
public function getMessageType() { // Get message type $messageType = static::types()[$this->type]; // If not incoming if ($this->type != static::INCOMING) { // Change to uppercase $messageType = strtoupper($messageType); } // Return return $messageType; }
[ "public", "function", "getMessageType", "(", ")", "{", "// Get message type", "$", "messageType", "=", "static", "::", "types", "(", ")", "[", "$", "this", "->", "type", "]", ";", "// If not incoming", "if", "(", "$", "this", "->", "type", "!=", "static", "::", "INCOMING", ")", "{", "// Change to uppercase", "$", "messageType", "=", "strtoupper", "(", "$", "messageType", ")", ";", "}", "// Return", "return", "$", "messageType", ";", "}" ]
Get message type
[ "Get", "message", "type" ]
446987706f81d5a0efbc8bd6b7d3b259d0527719
https://github.com/ronaldborla/chikka/blob/446987706f81d5a0efbc8bd6b7d3b259d0527719/src/Borla/Chikka/Models/Message.php#L249-L259
21,295
heidelpay/PhpDoc
src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/TraitConverter.php
TraitConverter.convert
public function convert(\DOMElement $parent, TraitDescriptor $trait) { $child = new \DOMElement('trait'); $parent->appendChild($child); $namespace = $trait->getNamespace()->getFullyQualifiedStructuralElementName(); $child->setAttribute('namespace', ltrim($namespace, '\\')); $child->setAttribute('line', $trait->getLine()); $child->appendChild(new \DOMElement('name', $trait->getName())); $child->appendChild(new \DOMElement('full_name', $trait->getFullyQualifiedStructuralElementName())); $this->docBlockConverter->convert($child, $trait); foreach ($trait->getProperties() as $property) { $this->propertyConverter->convert($child, $property); } foreach ($trait->getMethods() as $method) { $this->methodConverter->convert($child, $method); } return $child; }
php
public function convert(\DOMElement $parent, TraitDescriptor $trait) { $child = new \DOMElement('trait'); $parent->appendChild($child); $namespace = $trait->getNamespace()->getFullyQualifiedStructuralElementName(); $child->setAttribute('namespace', ltrim($namespace, '\\')); $child->setAttribute('line', $trait->getLine()); $child->appendChild(new \DOMElement('name', $trait->getName())); $child->appendChild(new \DOMElement('full_name', $trait->getFullyQualifiedStructuralElementName())); $this->docBlockConverter->convert($child, $trait); foreach ($trait->getProperties() as $property) { $this->propertyConverter->convert($child, $property); } foreach ($trait->getMethods() as $method) { $this->methodConverter->convert($child, $method); } return $child; }
[ "public", "function", "convert", "(", "\\", "DOMElement", "$", "parent", ",", "TraitDescriptor", "$", "trait", ")", "{", "$", "child", "=", "new", "\\", "DOMElement", "(", "'trait'", ")", ";", "$", "parent", "->", "appendChild", "(", "$", "child", ")", ";", "$", "namespace", "=", "$", "trait", "->", "getNamespace", "(", ")", "->", "getFullyQualifiedStructuralElementName", "(", ")", ";", "$", "child", "->", "setAttribute", "(", "'namespace'", ",", "ltrim", "(", "$", "namespace", ",", "'\\\\'", ")", ")", ";", "$", "child", "->", "setAttribute", "(", "'line'", ",", "$", "trait", "->", "getLine", "(", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'name'", ",", "$", "trait", "->", "getName", "(", ")", ")", ")", ";", "$", "child", "->", "appendChild", "(", "new", "\\", "DOMElement", "(", "'full_name'", ",", "$", "trait", "->", "getFullyQualifiedStructuralElementName", "(", ")", ")", ")", ";", "$", "this", "->", "docBlockConverter", "->", "convert", "(", "$", "child", ",", "$", "trait", ")", ";", "foreach", "(", "$", "trait", "->", "getProperties", "(", ")", "as", "$", "property", ")", "{", "$", "this", "->", "propertyConverter", "->", "convert", "(", "$", "child", ",", "$", "property", ")", ";", "}", "foreach", "(", "$", "trait", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "$", "this", "->", "methodConverter", "->", "convert", "(", "$", "child", ",", "$", "method", ")", ";", "}", "return", "$", "child", ";", "}" ]
Export the given reflected Trait definition to the provided parent element. This method creates a new child element on the given parent XML element and takes the properties of the Reflection argument and sets the elements and attributes on the child. If a child DOMElement is provided then the properties and attributes are set on this but the child element is not appended onto the parent. This is the responsibility of the invoker. Essentially this means that the $parent argument is ignored in this case. @param \DOMElement $parent Element to augment. @param TraitDescriptor $trait Element to export. @return \DOMElement
[ "Export", "the", "given", "reflected", "Trait", "definition", "to", "the", "provided", "parent", "element", "." ]
5ac9e842cbd4cbb70900533b240c131f3515ee02
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Xml/TraitConverter.php#L66-L89
21,296
ekuiter/feature-php
FeaturePhp/Specification/ChunkSpecification.php
ChunkSpecification.fromArrayAndSettings
public static function fromArrayAndSettings($cfg, $settings, $artifact = null) { $chunkSpecification = new static($cfg, $settings->getDirectory()); $chunkSpecification->set("source", null); $chunkSpecification->set("target", fphp\Helper\Path::join( $settings->getOptional("target", null), $chunkSpecification->getTarget())); return $chunkSpecification; }
php
public static function fromArrayAndSettings($cfg, $settings, $artifact = null) { $chunkSpecification = new static($cfg, $settings->getDirectory()); $chunkSpecification->set("source", null); $chunkSpecification->set("target", fphp\Helper\Path::join( $settings->getOptional("target", null), $chunkSpecification->getTarget())); return $chunkSpecification; }
[ "public", "static", "function", "fromArrayAndSettings", "(", "$", "cfg", ",", "$", "settings", ",", "$", "artifact", "=", "null", ")", "{", "$", "chunkSpecification", "=", "new", "static", "(", "$", "cfg", ",", "$", "settings", "->", "getDirectory", "(", ")", ")", ";", "$", "chunkSpecification", "->", "set", "(", "\"source\"", ",", "null", ")", ";", "$", "chunkSpecification", "->", "set", "(", "\"target\"", ",", "fphp", "\\", "Helper", "\\", "Path", "::", "join", "(", "$", "settings", "->", "getOptional", "(", "\"target\"", ",", "null", ")", ",", "$", "chunkSpecification", "->", "getTarget", "(", ")", ")", ")", ";", "return", "$", "chunkSpecification", ";", "}" ]
Creates a chunk specification from a plain settings array. The settings context is taken into consideration to generate paths relative to the settings. @param array $cfg a plain settings array @param \FeaturePhp\Settings $settings the settings context @param \FeaturePhp\Artifact\Artifact $artifact is ignored @return ChunkSpecification
[ "Creates", "a", "chunk", "specification", "from", "a", "plain", "settings", "array", ".", "The", "settings", "context", "is", "taken", "into", "consideration", "to", "generate", "paths", "relative", "to", "the", "settings", "." ]
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Specification/ChunkSpecification.php#L57-L63
21,297
OKTOTV/OktolabMediaBundle
Model/SpriteService.php
SpriteService.getSpriteWebvttForEpisode
public function getSpriteWebvttForEpisode($episode, $player_type = "jwplayer") { $this->calculateInterval($episode); switch ($player_type) { case 'jwplayer': return $this->getSpriteWebvttForJwPlayer($episode); break; default: return $this->getSpriteWebvttForJwPlayer($episode); break; } }
php
public function getSpriteWebvttForEpisode($episode, $player_type = "jwplayer") { $this->calculateInterval($episode); switch ($player_type) { case 'jwplayer': return $this->getSpriteWebvttForJwPlayer($episode); break; default: return $this->getSpriteWebvttForJwPlayer($episode); break; } }
[ "public", "function", "getSpriteWebvttForEpisode", "(", "$", "episode", ",", "$", "player_type", "=", "\"jwplayer\"", ")", "{", "$", "this", "->", "calculateInterval", "(", "$", "episode", ")", ";", "switch", "(", "$", "player_type", ")", "{", "case", "'jwplayer'", ":", "return", "$", "this", "->", "getSpriteWebvttForJwPlayer", "(", "$", "episode", ")", ";", "break", ";", "default", ":", "return", "$", "this", "->", "getSpriteWebvttForJwPlayer", "(", "$", "episode", ")", ";", "break", ";", "}", "}" ]
returns webvtt formated string for webplayers to display thumbnails
[ "returns", "webvtt", "formated", "string", "for", "webplayers", "to", "display", "thumbnails" ]
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/SpriteService.php#L23-L35
21,298
OKTOTV/OktolabMediaBundle
Model/SpriteService.php
SpriteService.calculateInterval
private function calculateInterval($episode) { $max_image = floor(65500/$this->sprite_height); $calculated_interval = ceil($episode->getDuration()/$max_image); if ($calculated_interval > $this->sprite_interval) { $this->sprite_interval = $calculated_interval; } }
php
private function calculateInterval($episode) { $max_image = floor(65500/$this->sprite_height); $calculated_interval = ceil($episode->getDuration()/$max_image); if ($calculated_interval > $this->sprite_interval) { $this->sprite_interval = $calculated_interval; } }
[ "private", "function", "calculateInterval", "(", "$", "episode", ")", "{", "$", "max_image", "=", "floor", "(", "65500", "/", "$", "this", "->", "sprite_height", ")", ";", "$", "calculated_interval", "=", "ceil", "(", "$", "episode", "->", "getDuration", "(", ")", "/", "$", "max_image", ")", ";", "if", "(", "$", "calculated_interval", ">", "$", "this", "->", "sprite_interval", ")", "{", "$", "this", "->", "sprite_interval", "=", "$", "calculated_interval", ";", "}", "}" ]
calculates the interval time for the length of an episode and considers jpeg dimension limit of 65500 px.
[ "calculates", "the", "interval", "time", "for", "the", "length", "of", "an", "episode", "and", "considers", "jpeg", "dimension", "limit", "of", "65500", "px", "." ]
f9c1eac4f6b19d2ab25288b301dd0d9350478bb3
https://github.com/OKTOTV/OktolabMediaBundle/blob/f9c1eac4f6b19d2ab25288b301dd0d9350478bb3/Model/SpriteService.php#L66-L73
21,299
eghojansu/moe
src/tools/Markdown.php
Markdown._auto
protected function _auto($str) { $self=$this; return preg_replace_callback( '/`.*?<(.+?)>.*?`|<(.+?)>/', function($expr) use($self) { if (empty($expr[1]) && parse_url($expr[2],PHP_URL_SCHEME)) { $expr[2]=$self->esc($expr[2]); return '<a href="'.$expr[2].'">'.$expr[2].'</a>'; } return $expr[0]; }, $str ); }
php
protected function _auto($str) { $self=$this; return preg_replace_callback( '/`.*?<(.+?)>.*?`|<(.+?)>/', function($expr) use($self) { if (empty($expr[1]) && parse_url($expr[2],PHP_URL_SCHEME)) { $expr[2]=$self->esc($expr[2]); return '<a href="'.$expr[2].'">'.$expr[2].'</a>'; } return $expr[0]; }, $str ); }
[ "protected", "function", "_auto", "(", "$", "str", ")", "{", "$", "self", "=", "$", "this", ";", "return", "preg_replace_callback", "(", "'/`.*?<(.+?)>.*?`|<(.+?)>/'", ",", "function", "(", "$", "expr", ")", "use", "(", "$", "self", ")", "{", "if", "(", "empty", "(", "$", "expr", "[", "1", "]", ")", "&&", "parse_url", "(", "$", "expr", "[", "2", "]", ",", "PHP_URL_SCHEME", ")", ")", "{", "$", "expr", "[", "2", "]", "=", "$", "self", "->", "esc", "(", "$", "expr", "[", "2", "]", ")", ";", "return", "'<a href=\"'", ".", "$", "expr", "[", "2", "]", ".", "'\">'", ".", "$", "expr", "[", "2", "]", ".", "'</a>'", ";", "}", "return", "$", "expr", "[", "0", "]", ";", "}", ",", "$", "str", ")", ";", "}" ]
Auto-convert links @return string @param $str string
[ "Auto", "-", "convert", "links" ]
f58ec75a3116d1a572782256e2b38bb9aab95e3c
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Markdown.php#L376-L389