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
222,500
contao-bootstrap/grid
src/GridBuilder.php
GridBuilder.buildSize
private function buildSize(string $size, array $definition, array $sizes): void { foreach ($definition as $columnDefinition) { $column = $this->buildColumn($columnDefinition, $size, $sizes); $this->grid->addColumn($column, $size); } }
php
private function buildSize(string $size, array $definition, array $sizes): void { foreach ($definition as $columnDefinition) { $column = $this->buildColumn($columnDefinition, $size, $sizes); $this->grid->addColumn($column, $size); } }
[ "private", "function", "buildSize", "(", "string", "$", "size", ",", "array", "$", "definition", ",", "array", "$", "sizes", ")", ":", "void", "{", "foreach", "(", "$", "definition", "as", "$", "columnDefinition", ")", "{", "$", "column", "=", "$", "this", "->", "buildColumn", "(", "$", "columnDefinition", ",", "$", "size", ",", "$", "sizes", ")", ";", "$", "this", "->", "grid", "->", "addColumn", "(", "$", "column", ",", "$", "size", ")", ";", "}", "}" ]
Build a grid size. @param string $size Grid size. @param array $definition Definition. @param array $sizes List of defined sizes. @return void
[ "Build", "a", "grid", "size", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/GridBuilder.php#L139-L146
222,501
contao-bootstrap/grid
src/GridBuilder.php
GridBuilder.finish
private function finish(): Grid { $grid = $this->grid; $this->grid = null; $this->model = null; return $grid; }
php
private function finish(): Grid { $grid = $this->grid; $this->grid = null; $this->model = null; return $grid; }
[ "private", "function", "finish", "(", ")", ":", "Grid", "{", "$", "grid", "=", "$", "this", "->", "grid", ";", "$", "this", "->", "grid", "=", "null", ";", "$", "this", "->", "model", "=", "null", ";", "return", "$", "grid", ";", "}" ]
Finish the grid building. @return Grid
[ "Finish", "the", "grid", "building", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/GridBuilder.php#L189-L196
222,502
contao-bootstrap/grid
src/GridBuilder.php
GridBuilder.parseOffset
private function parseOffset($offset) { if ($offset === 'null') { $offset = 0; } elseif (is_numeric($offset)) { $offset = (int) $offset; } return $offset; }
php
private function parseOffset($offset) { if ($offset === 'null') { $offset = 0; } elseif (is_numeric($offset)) { $offset = (int) $offset; } return $offset; }
[ "private", "function", "parseOffset", "(", "$", "offset", ")", "{", "if", "(", "$", "offset", "===", "'null'", ")", "{", "$", "offset", "=", "0", ";", "}", "elseif", "(", "is_numeric", "(", "$", "offset", ")", ")", "{", "$", "offset", "=", "(", "int", ")", "$", "offset", ";", "}", "return", "$", "offset", ";", "}" ]
Parse the offset definition value. @param mixed $offset Raw offset value. @return mixed
[ "Parse", "the", "offset", "definition", "value", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/GridBuilder.php#L205-L214
222,503
contao-bootstrap/grid
src/GridBuilder.php
GridBuilder.buildColumnWidth
private function buildColumnWidth(array $definition, Column $column): void { if ($definition['width']) { switch ($definition['width']) { case 'variable': $column->variableWidth(); break; case 'auto': case 'equal': break; case 'null': $column->width(0); break; default: $column->width((int) $definition['width']); } } }
php
private function buildColumnWidth(array $definition, Column $column): void { if ($definition['width']) { switch ($definition['width']) { case 'variable': $column->variableWidth(); break; case 'auto': case 'equal': break; case 'null': $column->width(0); break; default: $column->width((int) $definition['width']); } } }
[ "private", "function", "buildColumnWidth", "(", "array", "$", "definition", ",", "Column", "$", "column", ")", ":", "void", "{", "if", "(", "$", "definition", "[", "'width'", "]", ")", "{", "switch", "(", "$", "definition", "[", "'width'", "]", ")", "{", "case", "'variable'", ":", "$", "column", "->", "variableWidth", "(", ")", ";", "break", ";", "case", "'auto'", ":", "case", "'equal'", ":", "break", ";", "case", "'null'", ":", "$", "column", "->", "width", "(", "0", ")", ";", "break", ";", "default", ":", "$", "column", "->", "width", "(", "(", "int", ")", "$", "definition", "[", "'width'", "]", ")", ";", "}", "}", "}" ]
Build the column width. @param array $definition The grid column definition. @param Column $column The column. @return void
[ "Build", "the", "column", "width", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/GridBuilder.php#L224-L241
222,504
contao-bootstrap/grid
src/GridBuilder.php
GridBuilder.buildColumnResets
private function buildColumnResets(array $definition, Column $column, string $size, array $sizes): void { switch ($definition['reset']) { case '2': $key = array_search($size, $sizes); $next = ($sizes[($key + 1)] ?? null); if ($next) { $column->limitedReset((string) $next); break; } // No break here, case '1': $column->reset(); break; default: // Do nothing. } }
php
private function buildColumnResets(array $definition, Column $column, string $size, array $sizes): void { switch ($definition['reset']) { case '2': $key = array_search($size, $sizes); $next = ($sizes[($key + 1)] ?? null); if ($next) { $column->limitedReset((string) $next); break; } // No break here, case '1': $column->reset(); break; default: // Do nothing. } }
[ "private", "function", "buildColumnResets", "(", "array", "$", "definition", ",", "Column", "$", "column", ",", "string", "$", "size", ",", "array", "$", "sizes", ")", ":", "void", "{", "switch", "(", "$", "definition", "[", "'reset'", "]", ")", "{", "case", "'2'", ":", "$", "key", "=", "array_search", "(", "$", "size", ",", "$", "sizes", ")", ";", "$", "next", "=", "(", "$", "sizes", "[", "(", "$", "key", "+", "1", ")", "]", "??", "null", ")", ";", "if", "(", "$", "next", ")", "{", "$", "column", "->", "limitedReset", "(", "(", "string", ")", "$", "next", ")", ";", "break", ";", "}", "// No break here,", "case", "'1'", ":", "$", "column", "->", "reset", "(", ")", ";", "break", ";", "default", ":", "// Do nothing.", "}", "}" ]
Build the column resets. @param array $definition The grid column definition. @param Column $column The column. @param string $size The column size. @param array $sizes List of defined sizes. @return void
[ "Build", "the", "column", "resets", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/GridBuilder.php#L253-L274
222,505
Flowpack/Flowpack.NodeTemplates
Classes/NodeCreationHandler/TemplateNodeCreationHandler.php
TemplateNodeCreationHandler.handle
public function handle(NodeInterface $node, array $data) { if ($node->getNodeType()->hasConfiguration('options.template')) { $templateConfiguration = $node->getNodeType()->getConfiguration('options.template'); } else { return; } $propertyMappingConfiguration = $this->propertyMapper->buildPropertyMappingConfiguration(); $subPropertyMappingConfiguration = $propertyMappingConfiguration; for ($i = 0; $i < 10; $i++) { $subPropertyMappingConfiguration = $subPropertyMappingConfiguration ->forProperty('childNodes.*') ->allowAllProperties(); } /** @var Template $template */ $template = $this->propertyMapper->convert($templateConfiguration, Template::class, $propertyMappingConfiguration); $context = [ 'data' => $data, 'triggeringNode' => $node, ]; $template->apply($node, $context); return; }
php
public function handle(NodeInterface $node, array $data) { if ($node->getNodeType()->hasConfiguration('options.template')) { $templateConfiguration = $node->getNodeType()->getConfiguration('options.template'); } else { return; } $propertyMappingConfiguration = $this->propertyMapper->buildPropertyMappingConfiguration(); $subPropertyMappingConfiguration = $propertyMappingConfiguration; for ($i = 0; $i < 10; $i++) { $subPropertyMappingConfiguration = $subPropertyMappingConfiguration ->forProperty('childNodes.*') ->allowAllProperties(); } /** @var Template $template */ $template = $this->propertyMapper->convert($templateConfiguration, Template::class, $propertyMappingConfiguration); $context = [ 'data' => $data, 'triggeringNode' => $node, ]; $template->apply($node, $context); return; }
[ "public", "function", "handle", "(", "NodeInterface", "$", "node", ",", "array", "$", "data", ")", "{", "if", "(", "$", "node", "->", "getNodeType", "(", ")", "->", "hasConfiguration", "(", "'options.template'", ")", ")", "{", "$", "templateConfiguration", "=", "$", "node", "->", "getNodeType", "(", ")", "->", "getConfiguration", "(", "'options.template'", ")", ";", "}", "else", "{", "return", ";", "}", "$", "propertyMappingConfiguration", "=", "$", "this", "->", "propertyMapper", "->", "buildPropertyMappingConfiguration", "(", ")", ";", "$", "subPropertyMappingConfiguration", "=", "$", "propertyMappingConfiguration", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "10", ";", "$", "i", "++", ")", "{", "$", "subPropertyMappingConfiguration", "=", "$", "subPropertyMappingConfiguration", "->", "forProperty", "(", "'childNodes.*'", ")", "->", "allowAllProperties", "(", ")", ";", "}", "/** @var Template $template */", "$", "template", "=", "$", "this", "->", "propertyMapper", "->", "convert", "(", "$", "templateConfiguration", ",", "Template", "::", "class", ",", "$", "propertyMappingConfiguration", ")", ";", "$", "context", "=", "[", "'data'", "=>", "$", "data", ",", "'triggeringNode'", "=>", "$", "node", ",", "]", ";", "$", "template", "->", "apply", "(", "$", "node", ",", "$", "context", ")", ";", "return", ";", "}" ]
Create child nodes and change properties upon node creation @param NodeInterface $node The newly created node @param array $data incoming data from the creationDialog @return void
[ "Create", "child", "nodes", "and", "change", "properties", "upon", "node", "creation" ]
a9bb6efdbbca4d8d1c7cda048c9a58bc9c4cb519
https://github.com/Flowpack/Flowpack.NodeTemplates/blob/a9bb6efdbbca4d8d1c7cda048c9a58bc9c4cb519/Classes/NodeCreationHandler/TemplateNodeCreationHandler.php#L27-L54
222,506
contao-bootstrap/grid
src/Listener/Dca/ContentListener.php
ContentListener.initializeDca
public function initializeDca(): void { /** @var Input $input */ $input = $this->framework->getAdapter(Input::class); if ($input->get('act') !== 'edit') { return; } $model = $this->repository->findByPk(Input::get('id')); if (!$model || $model->type !== 'bs_grid_gallery') { return; } $GLOBALS['TL_CSS'][] = 'bundles/contaobootstrapgrid/css/backend.css'; $GLOBALS['TL_DCA']['tl_content']['fields']['galleryTpl']['options_callback'] = [ 'contao_bootstrap.grid.listeners.dca.content', 'getGalleryTemplates', ]; }
php
public function initializeDca(): void { /** @var Input $input */ $input = $this->framework->getAdapter(Input::class); if ($input->get('act') !== 'edit') { return; } $model = $this->repository->findByPk(Input::get('id')); if (!$model || $model->type !== 'bs_grid_gallery') { return; } $GLOBALS['TL_CSS'][] = 'bundles/contaobootstrapgrid/css/backend.css'; $GLOBALS['TL_DCA']['tl_content']['fields']['galleryTpl']['options_callback'] = [ 'contao_bootstrap.grid.listeners.dca.content', 'getGalleryTemplates', ]; }
[ "public", "function", "initializeDca", "(", ")", ":", "void", "{", "/** @var Input $input */", "$", "input", "=", "$", "this", "->", "framework", "->", "getAdapter", "(", "Input", "::", "class", ")", ";", "if", "(", "$", "input", "->", "get", "(", "'act'", ")", "!==", "'edit'", ")", "{", "return", ";", "}", "$", "model", "=", "$", "this", "->", "repository", "->", "findByPk", "(", "Input", "::", "get", "(", "'id'", ")", ")", ";", "if", "(", "!", "$", "model", "||", "$", "model", "->", "type", "!==", "'bs_grid_gallery'", ")", "{", "return", ";", "}", "$", "GLOBALS", "[", "'TL_CSS'", "]", "[", "]", "=", "'bundles/contaobootstrapgrid/css/backend.css'", ";", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "'tl_content'", "]", "[", "'fields'", "]", "[", "'galleryTpl'", "]", "[", "'options_callback'", "]", "=", "[", "'contao_bootstrap.grid.listeners.dca.content'", ",", "'getGalleryTemplates'", ",", "]", ";", "}" ]
Initialize the dca. @return void @SuppressWarnings(PHPMD.Superglobals)
[ "Initialize", "the", "dca", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/ContentListener.php#L105-L125
222,507
contao-bootstrap/grid
src/Listener/Dca/ContentListener.php
ContentListener.setMultiSrcFlags
public function setMultiSrcFlags($value, DataContainer $dataContainer) { if ($dataContainer->activeRecord && $dataContainer->activeRecord->type === 'bs_grid_gallery') { $fieldsDca =& $GLOBALS['TL_DCA'][$dataContainer->table]['fields'][$dataContainer->field]['eval']; $fieldsDca['isGallery'] = true; $fieldsDca['extensions'] = Config::get('validImageTypes'); } return $value; }
php
public function setMultiSrcFlags($value, DataContainer $dataContainer) { if ($dataContainer->activeRecord && $dataContainer->activeRecord->type === 'bs_grid_gallery') { $fieldsDca =& $GLOBALS['TL_DCA'][$dataContainer->table]['fields'][$dataContainer->field]['eval']; $fieldsDca['isGallery'] = true; $fieldsDca['extensions'] = Config::get('validImageTypes'); } return $value; }
[ "public", "function", "setMultiSrcFlags", "(", "$", "value", ",", "DataContainer", "$", "dataContainer", ")", "{", "if", "(", "$", "dataContainer", "->", "activeRecord", "&&", "$", "dataContainer", "->", "activeRecord", "->", "type", "===", "'bs_grid_gallery'", ")", "{", "$", "fieldsDca", "=", "&", "$", "GLOBALS", "[", "'TL_DCA'", "]", "[", "$", "dataContainer", "->", "table", "]", "[", "'fields'", "]", "[", "$", "dataContainer", "->", "field", "]", "[", "'eval'", "]", ";", "$", "fieldsDca", "[", "'isGallery'", "]", "=", "true", ";", "$", "fieldsDca", "[", "'extensions'", "]", "=", "Config", "::", "get", "(", "'validImageTypes'", ")", ";", "}", "return", "$", "value", ";", "}" ]
Dynamically add flags to the "multiSRC" field. @param mixed $value Given value. @param DataContainer $dataContainer Data Container driver. @return mixed @SuppressWarnings(PHPMD.Superglobals)
[ "Dynamically", "add", "flags", "to", "the", "multiSRC", "field", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/ContentListener.php#L183-L193
222,508
contao-bootstrap/grid
src/Listener/Dca/ContentListener.php
ContentListener.createGridElement
protected function createGridElement($current, string $type, int &$sorting): Model { $model = new ContentModel(); $model->tstamp = time(); $model->pid = $current->pid; $model->ptable = $current->ptable; $model->sorting = $sorting; $model->type = $type; $model->bs_grid_parent = $current->id; $model->save(); return $model; }
php
protected function createGridElement($current, string $type, int &$sorting): Model { $model = new ContentModel(); $model->tstamp = time(); $model->pid = $current->pid; $model->ptable = $current->ptable; $model->sorting = $sorting; $model->type = $type; $model->bs_grid_parent = $current->id; $model->save(); return $model; }
[ "protected", "function", "createGridElement", "(", "$", "current", ",", "string", "$", "type", ",", "int", "&", "$", "sorting", ")", ":", "Model", "{", "$", "model", "=", "new", "ContentModel", "(", ")", ";", "$", "model", "->", "tstamp", "=", "time", "(", ")", ";", "$", "model", "->", "pid", "=", "$", "current", "->", "pid", ";", "$", "model", "->", "ptable", "=", "$", "current", "->", "ptable", ";", "$", "model", "->", "sorting", "=", "$", "sorting", ";", "$", "model", "->", "type", "=", "$", "type", ";", "$", "model", "->", "bs_grid_parent", "=", "$", "current", "->", "id", ";", "$", "model", "->", "save", "(", ")", ";", "return", "$", "model", ";", "}" ]
Create a grid element. @param ContentModel $current Current content model. @param string $type Type of the content model. @param int $sorting The sorting value. @return Model
[ "Create", "a", "grid", "element", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/ContentListener.php#L214-L226
222,509
contao-bootstrap/grid
src/Listener/Dca/ModuleListener.php
ModuleListener.getAllModules
public function getAllModules(\MultiColumnWizard $multiColumnWizard = null): array { if ($multiColumnWizard && $multiColumnWizard->dataContainer && $multiColumnWizard->dataContainer->activeRecord) { $collection = ModuleModel::findBy( ['tl_module.pid = ?', 'tl_module.id != ?'], [ $multiColumnWizard->dataContainer->activeRecord->pid, $multiColumnWizard->dataContainer->activeRecord->id ] ); } else { $collection = ModuleModel::findAll(); } $modules = [ 'grid' => [ 'separator' => $GLOBALS['TL_LANG']['tl_module']['bs_separatorTitle'] ] ]; if ($collection) { foreach ($collection as $model) { $label = isset($GLOBALS['TL_LANG']['FMD'][$model->type][0]) ? $GLOBALS['TL_LANG']['FMD'][$model->type][0] : $model->type; $modules['module'][$model->id] = sprintf('%s [%s]', $model->name, $label); } } return $modules; }
php
public function getAllModules(\MultiColumnWizard $multiColumnWizard = null): array { if ($multiColumnWizard && $multiColumnWizard->dataContainer && $multiColumnWizard->dataContainer->activeRecord) { $collection = ModuleModel::findBy( ['tl_module.pid = ?', 'tl_module.id != ?'], [ $multiColumnWizard->dataContainer->activeRecord->pid, $multiColumnWizard->dataContainer->activeRecord->id ] ); } else { $collection = ModuleModel::findAll(); } $modules = [ 'grid' => [ 'separator' => $GLOBALS['TL_LANG']['tl_module']['bs_separatorTitle'] ] ]; if ($collection) { foreach ($collection as $model) { $label = isset($GLOBALS['TL_LANG']['FMD'][$model->type][0]) ? $GLOBALS['TL_LANG']['FMD'][$model->type][0] : $model->type; $modules['module'][$model->id] = sprintf('%s [%s]', $model->name, $label); } } return $modules; }
[ "public", "function", "getAllModules", "(", "\\", "MultiColumnWizard", "$", "multiColumnWizard", "=", "null", ")", ":", "array", "{", "if", "(", "$", "multiColumnWizard", "&&", "$", "multiColumnWizard", "->", "dataContainer", "&&", "$", "multiColumnWizard", "->", "dataContainer", "->", "activeRecord", ")", "{", "$", "collection", "=", "ModuleModel", "::", "findBy", "(", "[", "'tl_module.pid = ?'", ",", "'tl_module.id != ?'", "]", ",", "[", "$", "multiColumnWizard", "->", "dataContainer", "->", "activeRecord", "->", "pid", ",", "$", "multiColumnWizard", "->", "dataContainer", "->", "activeRecord", "->", "id", "]", ")", ";", "}", "else", "{", "$", "collection", "=", "ModuleModel", "::", "findAll", "(", ")", ";", "}", "$", "modules", "=", "[", "'grid'", "=>", "[", "'separator'", "=>", "$", "GLOBALS", "[", "'TL_LANG'", "]", "[", "'tl_module'", "]", "[", "'bs_separatorTitle'", "]", "]", "]", ";", "if", "(", "$", "collection", ")", "{", "foreach", "(", "$", "collection", "as", "$", "model", ")", "{", "$", "label", "=", "isset", "(", "$", "GLOBALS", "[", "'TL_LANG'", "]", "[", "'FMD'", "]", "[", "$", "model", "->", "type", "]", "[", "0", "]", ")", "?", "$", "GLOBALS", "[", "'TL_LANG'", "]", "[", "'FMD'", "]", "[", "$", "model", "->", "type", "]", "[", "0", "]", ":", "$", "model", "->", "type", ";", "$", "modules", "[", "'module'", "]", "[", "$", "model", "->", "id", "]", "=", "sprintf", "(", "'%s [%s]'", ",", "$", "model", "->", "name", ",", "$", "label", ")", ";", "}", "}", "return", "$", "modules", ";", "}" ]
Get all modules for the grid module. @param \MultiColumnWizard $multiColumnWizard Multicolumnwizard. @return array @SuppressWarnings(PHPMD.Superglobals)
[ "Get", "all", "modules", "for", "the", "grid", "module", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/ModuleListener.php#L36-L69
222,510
contao-bootstrap/grid
src/Listener/Dca/GridListener.php
GridListener.enterContext
public function enterContext(): void { if (Input::get('act') === 'edit') { $model = GridModel::findByPk(Input::get('id')); if ($model) { $this->environment->enterContext(ThemeContext::forTheme((int) $model->pid)); } } }
php
public function enterContext(): void { if (Input::get('act') === 'edit') { $model = GridModel::findByPk(Input::get('id')); if ($model) { $this->environment->enterContext(ThemeContext::forTheme((int) $model->pid)); } } }
[ "public", "function", "enterContext", "(", ")", ":", "void", "{", "if", "(", "Input", "::", "get", "(", "'act'", ")", "===", "'edit'", ")", "{", "$", "model", "=", "GridModel", "::", "findByPk", "(", "Input", "::", "get", "(", "'id'", ")", ")", ";", "if", "(", "$", "model", ")", "{", "$", "this", "->", "environment", "->", "enterContext", "(", "ThemeContext", "::", "forTheme", "(", "(", "int", ")", "$", "model", "->", "pid", ")", ")", ";", "}", "}", "}" ]
Enter a bootstrap environment context. @return void
[ "Enter", "a", "bootstrap", "environment", "context", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/GridListener.php#L54-L63
222,511
contao-bootstrap/grid
src/Listener/Dca/GridListener.php
GridListener.initializePalette
public function initializePalette(): void { if (Input::get('act') === 'edit') { $model = GridModel::findByPk(Input::get('id')); $sizes = array_map( function ($value) { return $value . 'Size'; }, StringUtil::deserialize($model->sizes, true) ); PaletteManipulator::create() ->addField($sizes, 'sizes') ->applyToPalette('default', 'tl_bs_grid'); } }
php
public function initializePalette(): void { if (Input::get('act') === 'edit') { $model = GridModel::findByPk(Input::get('id')); $sizes = array_map( function ($value) { return $value . 'Size'; }, StringUtil::deserialize($model->sizes, true) ); PaletteManipulator::create() ->addField($sizes, 'sizes') ->applyToPalette('default', 'tl_bs_grid'); } }
[ "public", "function", "initializePalette", "(", ")", ":", "void", "{", "if", "(", "Input", "::", "get", "(", "'act'", ")", "===", "'edit'", ")", "{", "$", "model", "=", "GridModel", "::", "findByPk", "(", "Input", "::", "get", "(", "'id'", ")", ")", ";", "$", "sizes", "=", "array_map", "(", "function", "(", "$", "value", ")", "{", "return", "$", "value", ".", "'Size'", ";", "}", ",", "StringUtil", "::", "deserialize", "(", "$", "model", "->", "sizes", ",", "true", ")", ")", ";", "PaletteManipulator", "::", "create", "(", ")", "->", "addField", "(", "$", "sizes", ",", "'sizes'", ")", "->", "applyToPalette", "(", "'default'", ",", "'tl_bs_grid'", ")", ";", "}", "}" ]
Initialize the palette. @return void
[ "Initialize", "the", "palette", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/GridListener.php#L70-L85
222,512
contao-bootstrap/grid
src/Listener/Dca/GridListener.php
GridListener.getWidths
public function getWidths(): array { $columns = $this->getColumns(); $values = ['equal', 'variable', 'null']; $values = array_merge($values, range(1, $columns)); return array_combine($values, $values); }
php
public function getWidths(): array { $columns = $this->getColumns(); $values = ['equal', 'variable', 'null']; $values = array_merge($values, range(1, $columns)); return array_combine($values, $values); }
[ "public", "function", "getWidths", "(", ")", ":", "array", "{", "$", "columns", "=", "$", "this", "->", "getColumns", "(", ")", ";", "$", "values", "=", "[", "'equal'", ",", "'variable'", ",", "'null'", "]", ";", "$", "values", "=", "array_merge", "(", "$", "values", ",", "range", "(", "1", ",", "$", "columns", ")", ")", ";", "return", "array_combine", "(", "$", "values", ",", "$", "values", ")", ";", "}" ]
Get all widths. @return array
[ "Get", "all", "widths", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/GridListener.php#L108-L115
222,513
lootils/uuid
src/Lootils/Uuid/Uuid.php
Uuid.setVersion
protected function setVersion($version) { if ($version == self::V3 || $version == self::V4 || $version == self::V5) { $this->version = $version; } else { throw new Exception('An invalid UUID version was specified.'); } }
php
protected function setVersion($version) { if ($version == self::V3 || $version == self::V4 || $version == self::V5) { $this->version = $version; } else { throw new Exception('An invalid UUID version was specified.'); } }
[ "protected", "function", "setVersion", "(", "$", "version", ")", "{", "if", "(", "$", "version", "==", "self", "::", "V3", "||", "$", "version", "==", "self", "::", "V4", "||", "$", "version", "==", "self", "::", "V5", ")", "{", "$", "this", "->", "version", "=", "$", "version", ";", "}", "else", "{", "throw", "new", "Exception", "(", "'An invalid UUID version was specified.'", ")", ";", "}", "}" ]
Set the version of the UUID. @param string $version 3, 4, or 5 which are the possible suppored versions.
[ "Set", "the", "version", "of", "the", "UUID", "." ]
7658af1e06c4cce26f932d034798eb33bc9e0e7a
https://github.com/lootils/uuid/blob/7658af1e06c4cce26f932d034798eb33bc9e0e7a/src/Lootils/Uuid/Uuid.php#L180-L187
222,514
lootils/uuid
src/Lootils/Uuid/Uuid.php
Uuid.getUuid
function getUuid() { return $this->time_low . '-' . $this->time_mid . '-' . $this->time_hi_version . '-' . $this->clock_seq_hi_variant . $this->clock_seq_low . '-' . $this->node; }
php
function getUuid() { return $this->time_low . '-' . $this->time_mid . '-' . $this->time_hi_version . '-' . $this->clock_seq_hi_variant . $this->clock_seq_low . '-' . $this->node; }
[ "function", "getUuid", "(", ")", "{", "return", "$", "this", "->", "time_low", ".", "'-'", ".", "$", "this", "->", "time_mid", ".", "'-'", ".", "$", "this", "->", "time_hi_version", ".", "'-'", ".", "$", "this", "->", "clock_seq_hi_variant", ".", "$", "this", "->", "clock_seq_low", ".", "'-'", ".", "$", "this", "->", "node", ";", "}" ]
Get the UUID. @return string A string containing a properly formatted UUID.
[ "Get", "the", "UUID", "." ]
7658af1e06c4cce26f932d034798eb33bc9e0e7a
https://github.com/lootils/uuid/blob/7658af1e06c4cce26f932d034798eb33bc9e0e7a/src/Lootils/Uuid/Uuid.php#L202-L204
222,515
lootils/uuid
src/Lootils/Uuid/Uuid.php
Uuid.parse
protected function parse($uuid) { // The UUID as a standard string was passed in. if (is_string($uuid)) { if (substr($uuid, 0, 1) === '{' && substr($uuid, -1, 1) === '}') { $string = substr($uuid, 1, strlen($uuid) - 2); $this->parseStringToParts($string); } // The case where a URL was supplied. elseif (substr($uuid, 0, 9) === 'urn:uuid:') { $string = substr($uuid, 9); $this->parseStringToParts($string); } else { throw new Exception('The UUID string supplied could not be parsed.'); } } elseif (is_array($uuid)) { if (count($uuid) != 6) { throw new Exception('The UUID array supplied could not be parsed.'); } // For the case where a UUID is passed in via the format: // array('35e872b4', '190a', '5faa', 'a0', 'f6', '09da0d4f9c01'); if (isset($uuid[0]) && !empty($uuid[0])) { $this->time_low = $uuid[0]; $this->time_mid = $uuid[1]; $this->time_hi_version =$uuid[2]; $this->clock_seq_hi_variant = $uuid[3]; $this->clock_seq_low =$uuid[4]; $this->node = $uuid[5]; } // For the case where the UUID is passed in via the format: // array( // 'time_low' => '35e872b4', // 'time_mid' => '190a', // 'time_hi_version' => '5faa', // 'clock_seq_hi_variant' => 'a0', // 'clock_seq_low' => 'f6', // 'node' => '09da0d4f9c01', // ); elseif (isset($uuid['time_low']) && !empty($uuid['time_low'])) { $this->time_low = $uuid['time_low']; $this->time_mid = $uuid['time_mid']; $this->time_hi_version =$uuid['time_hi_version']; $this->clock_seq_hi_variant = $uuid['clock_seq_hi_variant']; $this->clock_seq_low =$uuid['clock_seq_low']; $this->node = $uuid['node']; } else { throw new Exception('The UUID array supplied could not be parsed.'); } } else { throw new Exception('The UUID supplied could not be parsed.'); } }
php
protected function parse($uuid) { // The UUID as a standard string was passed in. if (is_string($uuid)) { if (substr($uuid, 0, 1) === '{' && substr($uuid, -1, 1) === '}') { $string = substr($uuid, 1, strlen($uuid) - 2); $this->parseStringToParts($string); } // The case where a URL was supplied. elseif (substr($uuid, 0, 9) === 'urn:uuid:') { $string = substr($uuid, 9); $this->parseStringToParts($string); } else { throw new Exception('The UUID string supplied could not be parsed.'); } } elseif (is_array($uuid)) { if (count($uuid) != 6) { throw new Exception('The UUID array supplied could not be parsed.'); } // For the case where a UUID is passed in via the format: // array('35e872b4', '190a', '5faa', 'a0', 'f6', '09da0d4f9c01'); if (isset($uuid[0]) && !empty($uuid[0])) { $this->time_low = $uuid[0]; $this->time_mid = $uuid[1]; $this->time_hi_version =$uuid[2]; $this->clock_seq_hi_variant = $uuid[3]; $this->clock_seq_low =$uuid[4]; $this->node = $uuid[5]; } // For the case where the UUID is passed in via the format: // array( // 'time_low' => '35e872b4', // 'time_mid' => '190a', // 'time_hi_version' => '5faa', // 'clock_seq_hi_variant' => 'a0', // 'clock_seq_low' => 'f6', // 'node' => '09da0d4f9c01', // ); elseif (isset($uuid['time_low']) && !empty($uuid['time_low'])) { $this->time_low = $uuid['time_low']; $this->time_mid = $uuid['time_mid']; $this->time_hi_version =$uuid['time_hi_version']; $this->clock_seq_hi_variant = $uuid['clock_seq_hi_variant']; $this->clock_seq_low =$uuid['clock_seq_low']; $this->node = $uuid['node']; } else { throw new Exception('The UUID array supplied could not be parsed.'); } } else { throw new Exception('The UUID supplied could not be parsed.'); } }
[ "protected", "function", "parse", "(", "$", "uuid", ")", "{", "// The UUID as a standard string was passed in.", "if", "(", "is_string", "(", "$", "uuid", ")", ")", "{", "if", "(", "substr", "(", "$", "uuid", ",", "0", ",", "1", ")", "===", "'{'", "&&", "substr", "(", "$", "uuid", ",", "-", "1", ",", "1", ")", "===", "'}'", ")", "{", "$", "string", "=", "substr", "(", "$", "uuid", ",", "1", ",", "strlen", "(", "$", "uuid", ")", "-", "2", ")", ";", "$", "this", "->", "parseStringToParts", "(", "$", "string", ")", ";", "}", "// The case where a URL was supplied.", "elseif", "(", "substr", "(", "$", "uuid", ",", "0", ",", "9", ")", "===", "'urn:uuid:'", ")", "{", "$", "string", "=", "substr", "(", "$", "uuid", ",", "9", ")", ";", "$", "this", "->", "parseStringToParts", "(", "$", "string", ")", ";", "}", "else", "{", "throw", "new", "Exception", "(", "'The UUID string supplied could not be parsed.'", ")", ";", "}", "}", "elseif", "(", "is_array", "(", "$", "uuid", ")", ")", "{", "if", "(", "count", "(", "$", "uuid", ")", "!=", "6", ")", "{", "throw", "new", "Exception", "(", "'The UUID array supplied could not be parsed.'", ")", ";", "}", "// For the case where a UUID is passed in via the format:", "// array('35e872b4', '190a', '5faa', 'a0', 'f6', '09da0d4f9c01');", "if", "(", "isset", "(", "$", "uuid", "[", "0", "]", ")", "&&", "!", "empty", "(", "$", "uuid", "[", "0", "]", ")", ")", "{", "$", "this", "->", "time_low", "=", "$", "uuid", "[", "0", "]", ";", "$", "this", "->", "time_mid", "=", "$", "uuid", "[", "1", "]", ";", "$", "this", "->", "time_hi_version", "=", "$", "uuid", "[", "2", "]", ";", "$", "this", "->", "clock_seq_hi_variant", "=", "$", "uuid", "[", "3", "]", ";", "$", "this", "->", "clock_seq_low", "=", "$", "uuid", "[", "4", "]", ";", "$", "this", "->", "node", "=", "$", "uuid", "[", "5", "]", ";", "}", "// For the case where the UUID is passed in via the format:", "// array(", "// 'time_low' => '35e872b4',", "// 'time_mid' => '190a',", "// 'time_hi_version' => '5faa',", "// 'clock_seq_hi_variant' => 'a0',", "// 'clock_seq_low' => 'f6',", "// 'node' => '09da0d4f9c01',", "// );", "elseif", "(", "isset", "(", "$", "uuid", "[", "'time_low'", "]", ")", "&&", "!", "empty", "(", "$", "uuid", "[", "'time_low'", "]", ")", ")", "{", "$", "this", "->", "time_low", "=", "$", "uuid", "[", "'time_low'", "]", ";", "$", "this", "->", "time_mid", "=", "$", "uuid", "[", "'time_mid'", "]", ";", "$", "this", "->", "time_hi_version", "=", "$", "uuid", "[", "'time_hi_version'", "]", ";", "$", "this", "->", "clock_seq_hi_variant", "=", "$", "uuid", "[", "'clock_seq_hi_variant'", "]", ";", "$", "this", "->", "clock_seq_low", "=", "$", "uuid", "[", "'clock_seq_low'", "]", ";", "$", "this", "->", "node", "=", "$", "uuid", "[", "'node'", "]", ";", "}", "else", "{", "throw", "new", "Exception", "(", "'The UUID array supplied could not be parsed.'", ")", ";", "}", "}", "else", "{", "throw", "new", "Exception", "(", "'The UUID supplied could not be parsed.'", ")", ";", "}", "}" ]
Parse the UUID from the available formats. @todo this should be written prettier. For realz.
[ "Parse", "the", "UUID", "from", "the", "available", "formats", "." ]
7658af1e06c4cce26f932d034798eb33bc9e0e7a
https://github.com/lootils/uuid/blob/7658af1e06c4cce26f932d034798eb33bc9e0e7a/src/Lootils/Uuid/Uuid.php#L238-L294
222,516
lootils/uuid
src/Lootils/Uuid/Uuid.php
Uuid.parseStringToParts
protected function parseStringToParts($string) { $parts = explode('-', $string); if (count($parts) != 5) { throw new Exception('The UUID string supplied could not be parsed.'); } foreach ($parts as $id => $part) { switch ($id) { case 0: $this->time_low = $part; break; case 1: $this->time_mid = $part; break; case 2: $this->time_hi_version = $part; break; case 3: $this->clock_seq_hi_variant = substr($part, 0, 2); $this->clock_seq_low = substr($part, 2); break; case 4: $this->node = $part; break; } } }
php
protected function parseStringToParts($string) { $parts = explode('-', $string); if (count($parts) != 5) { throw new Exception('The UUID string supplied could not be parsed.'); } foreach ($parts as $id => $part) { switch ($id) { case 0: $this->time_low = $part; break; case 1: $this->time_mid = $part; break; case 2: $this->time_hi_version = $part; break; case 3: $this->clock_seq_hi_variant = substr($part, 0, 2); $this->clock_seq_low = substr($part, 2); break; case 4: $this->node = $part; break; } } }
[ "protected", "function", "parseStringToParts", "(", "$", "string", ")", "{", "$", "parts", "=", "explode", "(", "'-'", ",", "$", "string", ")", ";", "if", "(", "count", "(", "$", "parts", ")", "!=", "5", ")", "{", "throw", "new", "Exception", "(", "'The UUID string supplied could not be parsed.'", ")", ";", "}", "foreach", "(", "$", "parts", "as", "$", "id", "=>", "$", "part", ")", "{", "switch", "(", "$", "id", ")", "{", "case", "0", ":", "$", "this", "->", "time_low", "=", "$", "part", ";", "break", ";", "case", "1", ":", "$", "this", "->", "time_mid", "=", "$", "part", ";", "break", ";", "case", "2", ":", "$", "this", "->", "time_hi_version", "=", "$", "part", ";", "break", ";", "case", "3", ":", "$", "this", "->", "clock_seq_hi_variant", "=", "substr", "(", "$", "part", ",", "0", ",", "2", ")", ";", "$", "this", "->", "clock_seq_low", "=", "substr", "(", "$", "part", ",", "2", ")", ";", "break", ";", "case", "4", ":", "$", "this", "->", "node", "=", "$", "part", ";", "break", ";", "}", "}", "}" ]
Parse a string in the form of 12345678-1234-5678-1234-567812345678.
[ "Parse", "a", "string", "in", "the", "form", "of", "12345678", "-", "1234", "-", "5678", "-", "1234", "-", "567812345678", "." ]
7658af1e06c4cce26f932d034798eb33bc9e0e7a
https://github.com/lootils/uuid/blob/7658af1e06c4cce26f932d034798eb33bc9e0e7a/src/Lootils/Uuid/Uuid.php#L299-L326
222,517
lootils/uuid
src/Lootils/Uuid/Uuid.php
Uuid.createV5
public static function createV5($namespace, $name) { // If the namespace is not a valid UUID we throw an error. if (!self::isValid($namespace)) { throw new Exception('The UUID provided for the namespace is not valid.'); } $bin = self::bin($namespace); $hash = sha1($bin . $name); return new self (sprintf('{%08s-%04s-%04x-%04x-%12s}', // 32 bits for "time_low" substr($hash, 0, 8), // 16 bits for "time_mid" substr($hash, 8, 4), // 16 bits for "time_hi_and_version", // four most significant bits holds version number 5 (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000, // 16 bits, 8 bits for "clk_seq_hi_res", // 8 bits for "clk_seq_low", // two most significant bits holds zero and one for variant DCE1.1 (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000, // 48 bits for "node" substr($hash, 20, 12) ), self::V5, $namespace, $name); }
php
public static function createV5($namespace, $name) { // If the namespace is not a valid UUID we throw an error. if (!self::isValid($namespace)) { throw new Exception('The UUID provided for the namespace is not valid.'); } $bin = self::bin($namespace); $hash = sha1($bin . $name); return new self (sprintf('{%08s-%04s-%04x-%04x-%12s}', // 32 bits for "time_low" substr($hash, 0, 8), // 16 bits for "time_mid" substr($hash, 8, 4), // 16 bits for "time_hi_and_version", // four most significant bits holds version number 5 (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x5000, // 16 bits, 8 bits for "clk_seq_hi_res", // 8 bits for "clk_seq_low", // two most significant bits holds zero and one for variant DCE1.1 (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000, // 48 bits for "node" substr($hash, 20, 12) ), self::V5, $namespace, $name); }
[ "public", "static", "function", "createV5", "(", "$", "namespace", ",", "$", "name", ")", "{", "// If the namespace is not a valid UUID we throw an error.", "if", "(", "!", "self", "::", "isValid", "(", "$", "namespace", ")", ")", "{", "throw", "new", "Exception", "(", "'The UUID provided for the namespace is not valid.'", ")", ";", "}", "$", "bin", "=", "self", "::", "bin", "(", "$", "namespace", ")", ";", "$", "hash", "=", "sha1", "(", "$", "bin", ".", "$", "name", ")", ";", "return", "new", "self", "(", "sprintf", "(", "'{%08s-%04s-%04x-%04x-%12s}'", ",", "// 32 bits for \"time_low\"", "substr", "(", "$", "hash", ",", "0", ",", "8", ")", ",", "// 16 bits for \"time_mid\"", "substr", "(", "$", "hash", ",", "8", ",", "4", ")", ",", "// 16 bits for \"time_hi_and_version\",", "// four most significant bits holds version number 5", "(", "hexdec", "(", "substr", "(", "$", "hash", ",", "12", ",", "4", ")", ")", "&", "0x0fff", ")", "|", "0x5000", ",", "// 16 bits, 8 bits for \"clk_seq_hi_res\",", "// 8 bits for \"clk_seq_low\",", "// two most significant bits holds zero and one for variant DCE1.1", "(", "hexdec", "(", "substr", "(", "$", "hash", ",", "16", ",", "4", ")", ")", "&", "0x3fff", ")", "|", "0x8000", ",", "// 48 bits for \"node\"", "substr", "(", "$", "hash", ",", "20", ",", "12", ")", ")", ",", "self", "::", "V5", ",", "$", "namespace", ",", "$", "name", ")", ";", "}" ]
Version 5 UUIDs are based on a namespace and name. If you have the same namespace and name you can recreate the namespace. V5 UUIDs are prefered over v3. V5 is based on sha1 while v3 is based on md5. @see https://en.wikipedia.org/wiki/UUID#Version_5_.28SHA-1_hash.29 @param string $namespace The UUID of the given namespace. @param string $name The name we are creating the UUID for.
[ "Version", "5", "UUIDs", "are", "based", "on", "a", "namespace", "and", "name", "." ]
7658af1e06c4cce26f932d034798eb33bc9e0e7a
https://github.com/lootils/uuid/blob/7658af1e06c4cce26f932d034798eb33bc9e0e7a/src/Lootils/Uuid/Uuid.php#L361-L391
222,518
lootils/uuid
src/Lootils/Uuid/Uuid.php
Uuid.createV4
public static function createV4() { return new self (sprintf('{%04x%04x-%04x-%04x-%04x-%04x%04x%04x}', // 32 bits for "time_low" mt_rand(0, 65535), mt_rand(0, 65535), // 16 bits for "time_mid" mt_rand(0, 65535), // 12 bits before the 0100 of (version) 4 for "time_hi_and_version" mt_rand(0, 4095) | 0x4000, // 16 bits, 8 bits for "clk_seq_hi_res", // 8 bits for "clk_seq_low", // two most significant bits holds zero and one for variant DCE1.1 mt_rand(0, 0x3fff) | 0x8000, // 48 bits for "node" mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535) )); }
php
public static function createV4() { return new self (sprintf('{%04x%04x-%04x-%04x-%04x-%04x%04x%04x}', // 32 bits for "time_low" mt_rand(0, 65535), mt_rand(0, 65535), // 16 bits for "time_mid" mt_rand(0, 65535), // 12 bits before the 0100 of (version) 4 for "time_hi_and_version" mt_rand(0, 4095) | 0x4000, // 16 bits, 8 bits for "clk_seq_hi_res", // 8 bits for "clk_seq_low", // two most significant bits holds zero and one for variant DCE1.1 mt_rand(0, 0x3fff) | 0x8000, // 48 bits for "node" mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535) )); }
[ "public", "static", "function", "createV4", "(", ")", "{", "return", "new", "self", "(", "sprintf", "(", "'{%04x%04x-%04x-%04x-%04x-%04x%04x%04x}'", ",", "// 32 bits for \"time_low\"", "mt_rand", "(", "0", ",", "65535", ")", ",", "mt_rand", "(", "0", ",", "65535", ")", ",", "// 16 bits for \"time_mid\"", "mt_rand", "(", "0", ",", "65535", ")", ",", "// 12 bits before the 0100 of (version) 4 for \"time_hi_and_version\"", "mt_rand", "(", "0", ",", "4095", ")", "|", "0x4000", ",", "// 16 bits, 8 bits for \"clk_seq_hi_res\",", "// 8 bits for \"clk_seq_low\",", "// two most significant bits holds zero and one for variant DCE1.1", "mt_rand", "(", "0", ",", "0x3fff", ")", "|", "0x8000", ",", "// 48 bits for \"node\"", "mt_rand", "(", "0", ",", "65535", ")", ",", "mt_rand", "(", "0", ",", "65535", ")", ",", "mt_rand", "(", "0", ",", "65535", ")", ")", ")", ";", "}" ]
Version 4 UUIDs are random. @see https://en.wikipedia.org/wiki/UUID#Version_4_.28random.29 @return string A properly formatted v4 UUID.
[ "Version", "4", "UUIDs", "are", "random", "." ]
7658af1e06c4cce26f932d034798eb33bc9e0e7a
https://github.com/lootils/uuid/blob/7658af1e06c4cce26f932d034798eb33bc9e0e7a/src/Lootils/Uuid/Uuid.php#L401-L420
222,519
lootils/uuid
src/Lootils/Uuid/Uuid.php
Uuid.createV3
public static function createV3($namespace, $name) { // If the namespace is not a valid UUID we throw an error. if (!self::isValid($namespace)) { throw new Exception('The UUID provided for the namespace is not valid.'); } $bin = self::bin($namespace); $hash = md5($bin . $name); return new self (sprintf('{%08s-%04s-%04x-%04x-%12s}', // 32 bits for "time_low" substr($hash, 0, 8), // 16 bits for "time_mid" substr($hash, 8, 4), // 16 bits for "time_hi_and_version", // four most significant bits holds version number 3 (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000, // 16 bits, 8 bits for "clk_seq_hi_res", // 8 bits for "clk_seq_low", // two most significant bits holds zero and one for variant DCE1.1 (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000, // 48 bits for "node" substr($hash, 20, 12) ), self::V3, $namespace, $name); }
php
public static function createV3($namespace, $name) { // If the namespace is not a valid UUID we throw an error. if (!self::isValid($namespace)) { throw new Exception('The UUID provided for the namespace is not valid.'); } $bin = self::bin($namespace); $hash = md5($bin . $name); return new self (sprintf('{%08s-%04s-%04x-%04x-%12s}', // 32 bits for "time_low" substr($hash, 0, 8), // 16 bits for "time_mid" substr($hash, 8, 4), // 16 bits for "time_hi_and_version", // four most significant bits holds version number 3 (hexdec(substr($hash, 12, 4)) & 0x0fff) | 0x3000, // 16 bits, 8 bits for "clk_seq_hi_res", // 8 bits for "clk_seq_low", // two most significant bits holds zero and one for variant DCE1.1 (hexdec(substr($hash, 16, 4)) & 0x3fff) | 0x8000, // 48 bits for "node" substr($hash, 20, 12) ), self::V3, $namespace, $name); }
[ "public", "static", "function", "createV3", "(", "$", "namespace", ",", "$", "name", ")", "{", "// If the namespace is not a valid UUID we throw an error.", "if", "(", "!", "self", "::", "isValid", "(", "$", "namespace", ")", ")", "{", "throw", "new", "Exception", "(", "'The UUID provided for the namespace is not valid.'", ")", ";", "}", "$", "bin", "=", "self", "::", "bin", "(", "$", "namespace", ")", ";", "$", "hash", "=", "md5", "(", "$", "bin", ".", "$", "name", ")", ";", "return", "new", "self", "(", "sprintf", "(", "'{%08s-%04s-%04x-%04x-%12s}'", ",", "// 32 bits for \"time_low\"", "substr", "(", "$", "hash", ",", "0", ",", "8", ")", ",", "// 16 bits for \"time_mid\"", "substr", "(", "$", "hash", ",", "8", ",", "4", ")", ",", "// 16 bits for \"time_hi_and_version\",", "// four most significant bits holds version number 3", "(", "hexdec", "(", "substr", "(", "$", "hash", ",", "12", ",", "4", ")", ")", "&", "0x0fff", ")", "|", "0x3000", ",", "// 16 bits, 8 bits for \"clk_seq_hi_res\",", "// 8 bits for \"clk_seq_low\",", "// two most significant bits holds zero and one for variant DCE1.1", "(", "hexdec", "(", "substr", "(", "$", "hash", ",", "16", ",", "4", ")", ")", "&", "0x3fff", ")", "|", "0x8000", ",", "// 48 bits for \"node\"", "substr", "(", "$", "hash", ",", "20", ",", "12", ")", ")", ",", "self", "::", "V3", ",", "$", "namespace", ",", "$", "name", ")", ";", "}" ]
Version 3 UUID are based on namespace and name utilizing a md5 hash. If you are considering using v3 consider using v5 instead as that is what is recommended. @see https://en.wikipedia.org/wiki/UUID#Version_3_.28MD5_hash.29
[ "Version", "3", "UUID", "are", "based", "on", "namespace", "and", "name", "utilizing", "a", "md5", "hash", "." ]
7658af1e06c4cce26f932d034798eb33bc9e0e7a
https://github.com/lootils/uuid/blob/7658af1e06c4cce26f932d034798eb33bc9e0e7a/src/Lootils/Uuid/Uuid.php#L430-L461
222,520
lootils/uuid
src/Lootils/Uuid/Uuid.php
Uuid.bin
public static function bin($uuid) { if (!self::isValid($uuid)) { throw new Exception('The UUID provided for the namespace is not valid.'); } // Get hexadecimal components of namespace $hex = str_replace(array('-','{','}'), '', $uuid); $bin = ''; // Convert to bits for ($i = 0; $i < strlen($hex); $i += 2) { $bin .= chr(hexdec($hex[$i] . $hex[$i+1])); } return $bin; }
php
public static function bin($uuid) { if (!self::isValid($uuid)) { throw new Exception('The UUID provided for the namespace is not valid.'); } // Get hexadecimal components of namespace $hex = str_replace(array('-','{','}'), '', $uuid); $bin = ''; // Convert to bits for ($i = 0; $i < strlen($hex); $i += 2) { $bin .= chr(hexdec($hex[$i] . $hex[$i+1])); } return $bin; }
[ "public", "static", "function", "bin", "(", "$", "uuid", ")", "{", "if", "(", "!", "self", "::", "isValid", "(", "$", "uuid", ")", ")", "{", "throw", "new", "Exception", "(", "'The UUID provided for the namespace is not valid.'", ")", ";", "}", "// Get hexadecimal components of namespace", "$", "hex", "=", "str_replace", "(", "array", "(", "'-'", ",", "'{'", ",", "'}'", ")", ",", "''", ",", "$", "uuid", ")", ";", "$", "bin", "=", "''", ";", "// Convert to bits", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "hex", ")", ";", "$", "i", "+=", "2", ")", "{", "$", "bin", ".=", "chr", "(", "hexdec", "(", "$", "hex", "[", "$", "i", "]", ".", "$", "hex", "[", "$", "i", "+", "1", "]", ")", ")", ";", "}", "return", "$", "bin", ";", "}" ]
Utility function to convert hex into bin for a UUID. @param string $uuid A UUID to convert into binary format. @return string A UUID in binary format.
[ "Utility", "function", "to", "convert", "hex", "into", "bin", "for", "a", "UUID", "." ]
7658af1e06c4cce26f932d034798eb33bc9e0e7a
https://github.com/lootils/uuid/blob/7658af1e06c4cce26f932d034798eb33bc9e0e7a/src/Lootils/Uuid/Uuid.php#L472-L488
222,521
contao-bootstrap/grid
src/Listener/ThemeExportListener.php
ThemeExportListener.onExportTheme
public function onExportTheme(DOMDocument $xml, ZipWriter $archive, $themeId): void { // Add the tables $table = $xml->createElement('table'); $table->setAttribute('name', 'tl_bs_grid'); $tables = $xml->getElementsByTagName('tables')->item(0); $table = $tables->appendChild($table); /** @var GridModel $adapter */ $adapter = $this->framework->getAdapter(GridModel::class); $collection = $adapter->findBy('pid', $themeId); if ($collection) { foreach ($collection as $model) { $this->addDataRow($xml, $table, $model->row()); } } }
php
public function onExportTheme(DOMDocument $xml, ZipWriter $archive, $themeId): void { // Add the tables $table = $xml->createElement('table'); $table->setAttribute('name', 'tl_bs_grid'); $tables = $xml->getElementsByTagName('tables')->item(0); $table = $tables->appendChild($table); /** @var GridModel $adapter */ $adapter = $this->framework->getAdapter(GridModel::class); $collection = $adapter->findBy('pid', $themeId); if ($collection) { foreach ($collection as $model) { $this->addDataRow($xml, $table, $model->row()); } } }
[ "public", "function", "onExportTheme", "(", "DOMDocument", "$", "xml", ",", "ZipWriter", "$", "archive", ",", "$", "themeId", ")", ":", "void", "{", "// Add the tables", "$", "table", "=", "$", "xml", "->", "createElement", "(", "'table'", ")", ";", "$", "table", "->", "setAttribute", "(", "'name'", ",", "'tl_bs_grid'", ")", ";", "$", "tables", "=", "$", "xml", "->", "getElementsByTagName", "(", "'tables'", ")", "->", "item", "(", "0", ")", ";", "$", "table", "=", "$", "tables", "->", "appendChild", "(", "$", "table", ")", ";", "/** @var GridModel $adapter */", "$", "adapter", "=", "$", "this", "->", "framework", "->", "getAdapter", "(", "GridModel", "::", "class", ")", ";", "$", "collection", "=", "$", "adapter", "->", "findBy", "(", "'pid'", ",", "$", "themeId", ")", ";", "if", "(", "$", "collection", ")", "{", "foreach", "(", "$", "collection", "as", "$", "model", ")", "{", "$", "this", "->", "addDataRow", "(", "$", "xml", ",", "$", "table", ",", "$", "model", "->", "row", "(", ")", ")", ";", "}", "}", "}" ]
Handle the export theme hook. @param DOMDocument $xml Xml document. @param ZipWriter $archive Zip archive. @param int|string $themeId Theme id. @return void @SuppressWarnings(PHPMD.UnusedFormalParameter)
[ "Handle", "the", "export", "theme", "hook", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/ThemeExportListener.php#L59-L77
222,522
contao-bootstrap/grid
src/Listener/Dca/AbstractDcaListener.php
AbstractDcaListener.getGridOptions
public function getGridOptions(): array { $collection = GridModel::findAll(['order' => 'tl_bs_grid.title']); $options = []; if ($collection) { foreach ($collection as $model) { $parent = sprintf( '%s [ID %s]', $model->getRelated('pid')->name, $model->pid ); $options[$parent][$model->id] = sprintf('%s [ID %s]', $model->title, $model->id); } } return $options; }
php
public function getGridOptions(): array { $collection = GridModel::findAll(['order' => 'tl_bs_grid.title']); $options = []; if ($collection) { foreach ($collection as $model) { $parent = sprintf( '%s [ID %s]', $model->getRelated('pid')->name, $model->pid ); $options[$parent][$model->id] = sprintf('%s [ID %s]', $model->title, $model->id); } } return $options; }
[ "public", "function", "getGridOptions", "(", ")", ":", "array", "{", "$", "collection", "=", "GridModel", "::", "findAll", "(", "[", "'order'", "=>", "'tl_bs_grid.title'", "]", ")", ";", "$", "options", "=", "[", "]", ";", "if", "(", "$", "collection", ")", "{", "foreach", "(", "$", "collection", "as", "$", "model", ")", "{", "$", "parent", "=", "sprintf", "(", "'%s [ID %s]'", ",", "$", "model", "->", "getRelated", "(", "'pid'", ")", "->", "name", ",", "$", "model", "->", "pid", ")", ";", "$", "options", "[", "$", "parent", "]", "[", "$", "model", "->", "id", "]", "=", "sprintf", "(", "'%s [ID %s]'", ",", "$", "model", "->", "title", ",", "$", "model", "->", "id", ")", ";", "}", "}", "return", "$", "options", ";", "}" ]
Get all available grids. @return array
[ "Get", "all", "available", "grids", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/AbstractDcaListener.php#L64-L82
222,523
contao-bootstrap/grid
src/Listener/Dca/AbstractDcaListener.php
AbstractDcaListener.generateGridName
public function generateGridName($value, $dataContainer): string { if (!$value) { $value = 'grid_' . $dataContainer->activeRecord->id; } return $value; }
php
public function generateGridName($value, $dataContainer): string { if (!$value) { $value = 'grid_' . $dataContainer->activeRecord->id; } return $value; }
[ "public", "function", "generateGridName", "(", "$", "value", ",", "$", "dataContainer", ")", ":", "string", "{", "if", "(", "!", "$", "value", ")", "{", "$", "value", "=", "'grid_'", ".", "$", "dataContainer", "->", "activeRecord", "->", "id", ";", "}", "return", "$", "value", ";", "}" ]
Generate a grid name if not given. @param string $value Grid name. @param DataContainer $dataContainer Data container driver. @return string
[ "Generate", "a", "grid", "name", "if", "not", "given", "." ]
6e41d00822afa52eac46eb20fb49ce4abcdc199b
https://github.com/contao-bootstrap/grid/blob/6e41d00822afa52eac46eb20fb49ce4abcdc199b/src/Listener/Dca/AbstractDcaListener.php#L92-L99
222,524
Flowpack/Flowpack.NodeTemplates
Classes/Template.php
Template.apply
public function apply(NodeInterface $node, array $context) { $context['node'] = $node; // Check if this template should be applied at all if (!$this->isApplicable($context)) { return; } $this->setProperties($node, $context); // Create child nodes if applicable /** @var Template $childNodeTemplate */ foreach ($this->childNodes as $childNodeTemplate) { $childNodeTemplate->createOrFetchAndApply($node, $context); } $this->emitNodeTemplateApplied($node, $context, $this->options); }
php
public function apply(NodeInterface $node, array $context) { $context['node'] = $node; // Check if this template should be applied at all if (!$this->isApplicable($context)) { return; } $this->setProperties($node, $context); // Create child nodes if applicable /** @var Template $childNodeTemplate */ foreach ($this->childNodes as $childNodeTemplate) { $childNodeTemplate->createOrFetchAndApply($node, $context); } $this->emitNodeTemplateApplied($node, $context, $this->options); }
[ "public", "function", "apply", "(", "NodeInterface", "$", "node", ",", "array", "$", "context", ")", "{", "$", "context", "[", "'node'", "]", "=", "$", "node", ";", "// Check if this template should be applied at all", "if", "(", "!", "$", "this", "->", "isApplicable", "(", "$", "context", ")", ")", "{", "return", ";", "}", "$", "this", "->", "setProperties", "(", "$", "node", ",", "$", "context", ")", ";", "// Create child nodes if applicable", "/** @var Template $childNodeTemplate */", "foreach", "(", "$", "this", "->", "childNodes", "as", "$", "childNodeTemplate", ")", "{", "$", "childNodeTemplate", "->", "createOrFetchAndApply", "(", "$", "node", ",", "$", "context", ")", ";", "}", "$", "this", "->", "emitNodeTemplateApplied", "(", "$", "node", ",", "$", "context", ",", "$", "this", "->", "options", ")", ";", "}" ]
Apply this template to the given node while providing context for EEL processing @param NodeInterface $node @param array $context
[ "Apply", "this", "template", "to", "the", "given", "node", "while", "providing", "context", "for", "EEL", "processing" ]
a9bb6efdbbca4d8d1c7cda048c9a58bc9c4cb519
https://github.com/Flowpack/Flowpack.NodeTemplates/blob/a9bb6efdbbca4d8d1c7cda048c9a58bc9c4cb519/Classes/Template.php#L105-L122
222,525
frostealth/php-data-storage
src/storage/ArrayData.php
ArrayData.set
public function set($key, $value) { $data = &$this->data; if ($this->isDotNotation($key)) { $keys = explode('.', $key); $key = array_pop($keys); foreach ($keys as $segment) { if (!isset($data[$segment]) || !is_array($data[$segment])) { $data[$segment] = []; } $data = &$data[$segment]; } } $data[$key] = $value; }
php
public function set($key, $value) { $data = &$this->data; if ($this->isDotNotation($key)) { $keys = explode('.', $key); $key = array_pop($keys); foreach ($keys as $segment) { if (!isset($data[$segment]) || !is_array($data[$segment])) { $data[$segment] = []; } $data = &$data[$segment]; } } $data[$key] = $value; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "$", "data", "=", "&", "$", "this", "->", "data", ";", "if", "(", "$", "this", "->", "isDotNotation", "(", "$", "key", ")", ")", "{", "$", "keys", "=", "explode", "(", "'.'", ",", "$", "key", ")", ";", "$", "key", "=", "array_pop", "(", "$", "keys", ")", ";", "foreach", "(", "$", "keys", "as", "$", "segment", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "$", "segment", "]", ")", "||", "!", "is_array", "(", "$", "data", "[", "$", "segment", "]", ")", ")", "{", "$", "data", "[", "$", "segment", "]", "=", "[", "]", ";", "}", "$", "data", "=", "&", "$", "data", "[", "$", "segment", "]", ";", "}", "}", "$", "data", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Set an array item to a given value using "dot" notation If no key is given to the method, the entire array will be replaced @param string $key @param mixed $value
[ "Set", "an", "array", "item", "to", "a", "given", "value", "using", "dot", "notation", "If", "no", "key", "is", "given", "to", "the", "method", "the", "entire", "array", "will", "be", "replaced" ]
2fc11b1e835a660dd5e519467c84c5ba5ef83e0e
https://github.com/frostealth/php-data-storage/blob/2fc11b1e835a660dd5e519467c84c5ba5ef83e0e/src/storage/ArrayData.php#L32-L49
222,526
frostealth/php-data-storage
src/storage/ArrayData.php
ArrayData.get
public function get($key, $default = null) { if (array_key_exists($key, $this->data)) { return $this->data[$key]; } $value = $default; if ($this->isDotNotation($key)) { $keys = explode('.', $key); $value = $this->data; foreach ($keys as $segment) { if (!is_array($value) || !array_key_exists($segment, $value)) { $value = $default; break; } $value = $value[$segment]; } } return $value; }
php
public function get($key, $default = null) { if (array_key_exists($key, $this->data)) { return $this->data[$key]; } $value = $default; if ($this->isDotNotation($key)) { $keys = explode('.', $key); $value = $this->data; foreach ($keys as $segment) { if (!is_array($value) || !array_key_exists($segment, $value)) { $value = $default; break; } $value = $value[$segment]; } } return $value; }
[ "public", "function", "get", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "data", ")", ")", "{", "return", "$", "this", "->", "data", "[", "$", "key", "]", ";", "}", "$", "value", "=", "$", "default", ";", "if", "(", "$", "this", "->", "isDotNotation", "(", "$", "key", ")", ")", "{", "$", "keys", "=", "explode", "(", "'.'", ",", "$", "key", ")", ";", "$", "value", "=", "$", "this", "->", "data", ";", "foreach", "(", "$", "keys", "as", "$", "segment", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", "||", "!", "array_key_exists", "(", "$", "segment", ",", "$", "value", ")", ")", "{", "$", "value", "=", "$", "default", ";", "break", ";", "}", "$", "value", "=", "$", "value", "[", "$", "segment", "]", ";", "}", "}", "return", "$", "value", ";", "}" ]
Get an item from an array using "dot" notation @param string $key @param mixed $default @return mixed
[ "Get", "an", "item", "from", "an", "array", "using", "dot", "notation" ]
2fc11b1e835a660dd5e519467c84c5ba5ef83e0e
https://github.com/frostealth/php-data-storage/blob/2fc11b1e835a660dd5e519467c84c5ba5ef83e0e/src/storage/ArrayData.php#L59-L81
222,527
frostealth/php-data-storage
src/storage/ArrayData.php
ArrayData.has
public function has($key) { $result = array_key_exists($key, $this->data); if (!$result && $this->isDotNotation($key)) { $result = true; $keys = explode('.', $key); $data = $this->data; foreach ($keys as $key) { if (!is_array($data) || !array_key_exists($key, $data)) { $result = false; break; } $data = $data[$key]; } } return $result; }
php
public function has($key) { $result = array_key_exists($key, $this->data); if (!$result && $this->isDotNotation($key)) { $result = true; $keys = explode('.', $key); $data = $this->data; foreach ($keys as $key) { if (!is_array($data) || !array_key_exists($key, $data)) { $result = false; break; } $data = $data[$key]; } } return $result; }
[ "public", "function", "has", "(", "$", "key", ")", "{", "$", "result", "=", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "data", ")", ";", "if", "(", "!", "$", "result", "&&", "$", "this", "->", "isDotNotation", "(", "$", "key", ")", ")", "{", "$", "result", "=", "true", ";", "$", "keys", "=", "explode", "(", "'.'", ",", "$", "key", ")", ";", "$", "data", "=", "$", "this", "->", "data", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "!", "is_array", "(", "$", "data", ")", "||", "!", "array_key_exists", "(", "$", "key", ",", "$", "data", ")", ")", "{", "$", "result", "=", "false", ";", "break", ";", "}", "$", "data", "=", "$", "data", "[", "$", "key", "]", ";", "}", "}", "return", "$", "result", ";", "}" ]
Check if an item exists in an array using "dot" notation @param string $key @return bool
[ "Check", "if", "an", "item", "exists", "in", "an", "array", "using", "dot", "notation" ]
2fc11b1e835a660dd5e519467c84c5ba5ef83e0e
https://github.com/frostealth/php-data-storage/blob/2fc11b1e835a660dd5e519467c84c5ba5ef83e0e/src/storage/ArrayData.php#L90-L109
222,528
arrilot/dotenv-php
src/DotEnv.php
DotEnv.load
public static function load($source) { self::$variables = is_array($source) ? $source : require $source; self::$isLoaded = true; self::checkRequiredVariables(); }
php
public static function load($source) { self::$variables = is_array($source) ? $source : require $source; self::$isLoaded = true; self::checkRequiredVariables(); }
[ "public", "static", "function", "load", "(", "$", "source", ")", "{", "self", "::", "$", "variables", "=", "is_array", "(", "$", "source", ")", "?", "$", "source", ":", "require", "$", "source", ";", "self", "::", "$", "isLoaded", "=", "true", ";", "self", "::", "checkRequiredVariables", "(", ")", ";", "}" ]
Load .env.php file or array. @param string|array $source @return void
[ "Load", ".", "env", ".", "php", "file", "or", "array", "." ]
dd21b6878b62b2945d5bc75d0c40143c2cfe2c3b
https://github.com/arrilot/dotenv-php/blob/dd21b6878b62b2945d5bc75d0c40143c2cfe2c3b/src/DotEnv.php#L37-L43
222,529
arrilot/dotenv-php
src/DotEnv.php
DotEnv.get
public static function get($key, $default = null) { return isset(self::$variables[$key]) ? self::$variables[$key] : $default; }
php
public static function get($key, $default = null) { return isset(self::$variables[$key]) ? self::$variables[$key] : $default; }
[ "public", "static", "function", "get", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "return", "isset", "(", "self", "::", "$", "variables", "[", "$", "key", "]", ")", "?", "self", "::", "$", "variables", "[", "$", "key", "]", ":", "$", "default", ";", "}" ]
Get env variable. @param string $key @param mixed $default @return mixed
[ "Get", "env", "variable", "." ]
dd21b6878b62b2945d5bc75d0c40143c2cfe2c3b
https://github.com/arrilot/dotenv-php/blob/dd21b6878b62b2945d5bc75d0c40143c2cfe2c3b/src/DotEnv.php#L99-L102
222,530
arrilot/dotenv-php
src/DotEnv.php
DotEnv.set
public static function set($keys, $value = null) { if (is_array($keys)) { self::$variables = array_merge(self::$variables, $keys); } else { self::$variables[$keys] = $value; } }
php
public static function set($keys, $value = null) { if (is_array($keys)) { self::$variables = array_merge(self::$variables, $keys); } else { self::$variables[$keys] = $value; } }
[ "public", "static", "function", "set", "(", "$", "keys", ",", "$", "value", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "keys", ")", ")", "{", "self", "::", "$", "variables", "=", "array_merge", "(", "self", "::", "$", "variables", ",", "$", "keys", ")", ";", "}", "else", "{", "self", "::", "$", "variables", "[", "$", "keys", "]", "=", "$", "value", ";", "}", "}" ]
Set env variable. @param string|array $keys @param mixed $value @return void
[ "Set", "env", "variable", "." ]
dd21b6878b62b2945d5bc75d0c40143c2cfe2c3b
https://github.com/arrilot/dotenv-php/blob/dd21b6878b62b2945d5bc75d0c40143c2cfe2c3b/src/DotEnv.php#L112-L119
222,531
arrilot/dotenv-php
src/DotEnv.php
DotEnv.checkRequiredVariables
protected static function checkRequiredVariables() { foreach (self::$required as $key) { if (!isset(self::$variables[$key])) { throw new MissingVariableException(".env variable '{$key}' is missing"); } } }
php
protected static function checkRequiredVariables() { foreach (self::$required as $key) { if (!isset(self::$variables[$key])) { throw new MissingVariableException(".env variable '{$key}' is missing"); } } }
[ "protected", "static", "function", "checkRequiredVariables", "(", ")", "{", "foreach", "(", "self", "::", "$", "required", "as", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "variables", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "MissingVariableException", "(", "\".env variable '{$key}' is missing\"", ")", ";", "}", "}", "}" ]
Throw exception if any of required variables was not loaded. @throws MissingVariableException @return void
[ "Throw", "exception", "if", "any", "of", "required", "variables", "was", "not", "loaded", "." ]
dd21b6878b62b2945d5bc75d0c40143c2cfe2c3b
https://github.com/arrilot/dotenv-php/blob/dd21b6878b62b2945d5bc75d0c40143c2cfe2c3b/src/DotEnv.php#L153-L160
222,532
thephpleague/omnipay-multisafepay
src/Message/RestAbstractRequest.php
RestAbstractRequest.sendRequest
protected function sendRequest($method, $endpoint, $data = null) { return $this->httpClient->request( $method, $this->getEndpoint() . $endpoint, $this->getHeaders(), $data ); }
php
protected function sendRequest($method, $endpoint, $data = null) { return $this->httpClient->request( $method, $this->getEndpoint() . $endpoint, $this->getHeaders(), $data ); }
[ "protected", "function", "sendRequest", "(", "$", "method", ",", "$", "endpoint", ",", "$", "data", "=", "null", ")", "{", "return", "$", "this", "->", "httpClient", "->", "request", "(", "$", "method", ",", "$", "this", "->", "getEndpoint", "(", ")", ".", "$", "endpoint", ",", "$", "this", "->", "getHeaders", "(", ")", ",", "$", "data", ")", ";", "}" ]
Execute the Guzzle request. @param $method @param $endpoint @param null $data @return ResponseInterface
[ "Execute", "the", "Guzzle", "request", "." ]
532adb628b4b21504c00788e659406ff0c889e25
https://github.com/thephpleague/omnipay-multisafepay/blob/532adb628b4b21504c00788e659406ff0c889e25/src/Message/RestAbstractRequest.php#L153-L161
222,533
fastdlabs/swoole
src/Client.php
Client.start
public function start() { foreach ($this->callbacks as $event => $callback) { $this->client->on($event, $callback); } $this->connect(); }
php
public function start() { foreach ($this->callbacks as $event => $callback) { $this->client->on($event, $callback); } $this->connect(); }
[ "public", "function", "start", "(", ")", "{", "foreach", "(", "$", "this", "->", "callbacks", "as", "$", "event", "=>", "$", "callback", ")", "{", "$", "this", "->", "client", "->", "on", "(", "$", "event", ",", "$", "callback", ")", ";", "}", "$", "this", "->", "connect", "(", ")", ";", "}" ]
start async client
[ "start", "async", "client" ]
043be98edcf87a3eb752446c8e9b2f88c4034ff2
https://github.com/fastdlabs/swoole/blob/043be98edcf87a3eb752446c8e9b2f88c4034ff2/src/Client.php#L383-L389
222,534
mdmsoft/yii2-gii
generators/mvc/Generator.php
Generator.isFormAction
public function isFormAction($action) { $formActionss = preg_split('/[\s,]+/', $this->formActions, -1, PREG_SPLIT_NO_EMPTY); return !empty($this->modelClass) && in_array($action, $formActionss); }
php
public function isFormAction($action) { $formActionss = preg_split('/[\s,]+/', $this->formActions, -1, PREG_SPLIT_NO_EMPTY); return !empty($this->modelClass) && in_array($action, $formActionss); }
[ "public", "function", "isFormAction", "(", "$", "action", ")", "{", "$", "formActionss", "=", "preg_split", "(", "'/[\\s,]+/'", ",", "$", "this", "->", "formActions", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ";", "return", "!", "empty", "(", "$", "this", "->", "modelClass", ")", "&&", "in_array", "(", "$", "action", ",", "$", "formActionss", ")", ";", "}" ]
Check if action use for render form @param string $action @return boolean
[ "Check", "if", "action", "use", "for", "render", "form" ]
ce535fe33add991776006f3f5e36a6e0c79a4e3c
https://github.com/mdmsoft/yii2-gii/blob/ce535fe33add991776006f3f5e36a6e0c79a4e3c/generators/mvc/Generator.php#L246-L250
222,535
php-http/buzz-adapter
src/Client.php
Client.createRequest
private function createRequest(RequestInterface $request) { $buzzRequest = new BuzzRequest(); $buzzRequest->setMethod($request->getMethod()); $buzzRequest->fromUrl($request->getUri()->__toString()); $buzzRequest->setProtocolVersion($request->getProtocolVersion()); $buzzRequest->setContent((string) $request->getBody()); $this->addPsrHeadersToBuzzRequest($request, $buzzRequest); return $buzzRequest; }
php
private function createRequest(RequestInterface $request) { $buzzRequest = new BuzzRequest(); $buzzRequest->setMethod($request->getMethod()); $buzzRequest->fromUrl($request->getUri()->__toString()); $buzzRequest->setProtocolVersion($request->getProtocolVersion()); $buzzRequest->setContent((string) $request->getBody()); $this->addPsrHeadersToBuzzRequest($request, $buzzRequest); return $buzzRequest; }
[ "private", "function", "createRequest", "(", "RequestInterface", "$", "request", ")", "{", "$", "buzzRequest", "=", "new", "BuzzRequest", "(", ")", ";", "$", "buzzRequest", "->", "setMethod", "(", "$", "request", "->", "getMethod", "(", ")", ")", ";", "$", "buzzRequest", "->", "fromUrl", "(", "$", "request", "->", "getUri", "(", ")", "->", "__toString", "(", ")", ")", ";", "$", "buzzRequest", "->", "setProtocolVersion", "(", "$", "request", "->", "getProtocolVersion", "(", ")", ")", ";", "$", "buzzRequest", "->", "setContent", "(", "(", "string", ")", "$", "request", "->", "getBody", "(", ")", ")", ";", "$", "this", "->", "addPsrHeadersToBuzzRequest", "(", "$", "request", ",", "$", "buzzRequest", ")", ";", "return", "$", "buzzRequest", ";", "}" ]
Converts a PSR request into a BuzzRequest request. @param RequestInterface $request @return BuzzRequest
[ "Converts", "a", "PSR", "request", "into", "a", "BuzzRequest", "request", "." ]
8b49145160113b4ca85c778d88c1666b8605d67a
https://github.com/php-http/buzz-adapter/blob/8b49145160113b4ca85c778d88c1666b8605d67a/src/Client.php#L95-L106
222,536
php-http/buzz-adapter
src/Client.php
Client.createResponse
private function createResponse(BuzzResponse $response) { $body = $response->getContent(); return $this->responseFactory->createResponse( $response->getStatusCode(), null, $this->getBuzzHeaders($response), $body, number_format($response->getProtocolVersion(), 1) ); }
php
private function createResponse(BuzzResponse $response) { $body = $response->getContent(); return $this->responseFactory->createResponse( $response->getStatusCode(), null, $this->getBuzzHeaders($response), $body, number_format($response->getProtocolVersion(), 1) ); }
[ "private", "function", "createResponse", "(", "BuzzResponse", "$", "response", ")", "{", "$", "body", "=", "$", "response", "->", "getContent", "(", ")", ";", "return", "$", "this", "->", "responseFactory", "->", "createResponse", "(", "$", "response", "->", "getStatusCode", "(", ")", ",", "null", ",", "$", "this", "->", "getBuzzHeaders", "(", "$", "response", ")", ",", "$", "body", ",", "number_format", "(", "$", "response", "->", "getProtocolVersion", "(", ")", ",", "1", ")", ")", ";", "}" ]
Converts a Buzz response into a PSR response. @param BuzzResponse $response @return ResponseInterface
[ "Converts", "a", "Buzz", "response", "into", "a", "PSR", "response", "." ]
8b49145160113b4ca85c778d88c1666b8605d67a
https://github.com/php-http/buzz-adapter/blob/8b49145160113b4ca85c778d88c1666b8605d67a/src/Client.php#L115-L126
222,537
php-http/buzz-adapter
src/Client.php
Client.addPsrHeadersToBuzzRequest
private function addPsrHeadersToBuzzRequest(RequestInterface $request, BuzzRequest $buzzRequest) { $headers = $request->getHeaders(); foreach ($headers as $name => $values) { foreach ($values as $header) { $buzzRequest->addHeader($name.': '.$header); } } }
php
private function addPsrHeadersToBuzzRequest(RequestInterface $request, BuzzRequest $buzzRequest) { $headers = $request->getHeaders(); foreach ($headers as $name => $values) { foreach ($values as $header) { $buzzRequest->addHeader($name.': '.$header); } } }
[ "private", "function", "addPsrHeadersToBuzzRequest", "(", "RequestInterface", "$", "request", ",", "BuzzRequest", "$", "buzzRequest", ")", "{", "$", "headers", "=", "$", "request", "->", "getHeaders", "(", ")", ";", "foreach", "(", "$", "headers", "as", "$", "name", "=>", "$", "values", ")", "{", "foreach", "(", "$", "values", "as", "$", "header", ")", "{", "$", "buzzRequest", "->", "addHeader", "(", "$", "name", ".", "': '", ".", "$", "header", ")", ";", "}", "}", "}" ]
Apply headers on a Buzz request. @param RequestInterface $request @param BuzzRequest $buzzRequest
[ "Apply", "headers", "on", "a", "Buzz", "request", "." ]
8b49145160113b4ca85c778d88c1666b8605d67a
https://github.com/php-http/buzz-adapter/blob/8b49145160113b4ca85c778d88c1666b8605d67a/src/Client.php#L134-L142
222,538
php-http/buzz-adapter
src/Client.php
Client.getBuzzHeaders
private function getBuzzHeaders(BuzzResponse $response) { $buzzHeaders = $response->getHeaders(); unset($buzzHeaders[0]); $headers = []; foreach ($buzzHeaders as $headerLine) { list($name, $value) = explode(':', $headerLine, 2); $headers[$name] = trim($value); } return $headers; }
php
private function getBuzzHeaders(BuzzResponse $response) { $buzzHeaders = $response->getHeaders(); unset($buzzHeaders[0]); $headers = []; foreach ($buzzHeaders as $headerLine) { list($name, $value) = explode(':', $headerLine, 2); $headers[$name] = trim($value); } return $headers; }
[ "private", "function", "getBuzzHeaders", "(", "BuzzResponse", "$", "response", ")", "{", "$", "buzzHeaders", "=", "$", "response", "->", "getHeaders", "(", ")", ";", "unset", "(", "$", "buzzHeaders", "[", "0", "]", ")", ";", "$", "headers", "=", "[", "]", ";", "foreach", "(", "$", "buzzHeaders", "as", "$", "headerLine", ")", "{", "list", "(", "$", "name", ",", "$", "value", ")", "=", "explode", "(", "':'", ",", "$", "headerLine", ",", "2", ")", ";", "$", "headers", "[", "$", "name", "]", "=", "trim", "(", "$", "value", ")", ";", "}", "return", "$", "headers", ";", "}" ]
Get headers from a Buzz response. @param BuzzResponse $response @return array
[ "Get", "headers", "from", "a", "Buzz", "response", "." ]
8b49145160113b4ca85c778d88c1666b8605d67a
https://github.com/php-http/buzz-adapter/blob/8b49145160113b4ca85c778d88c1666b8605d67a/src/Client.php#L151-L162
222,539
php-http/buzz-adapter
src/Client.php
Client.assertRequestHasValidBody
private function assertRequestHasValidBody(RequestInterface $request) { $validMethods = [ BuzzRequestInterface::METHOD_POST, BuzzRequestInterface::METHOD_PUT, BuzzRequestInterface::METHOD_DELETE, BuzzRequestInterface::METHOD_PATCH, BuzzRequestInterface::METHOD_OPTIONS, ]; // The Buzz Curl client does not send request bodies for request methods such as GET, HEAD and TRACE. Instead of // silently ignoring the request body in these cases, throw an exception to make users aware. if ($this->client instanceof Curl && $request->getBody()->getSize() && !in_array(strtoupper($request->getMethod()), $validMethods, true) ) { throw new HttplugException\RequestException( sprintf('%s does not support %s requests with a body', Curl::class, $request->getMethod()), $request ); } }
php
private function assertRequestHasValidBody(RequestInterface $request) { $validMethods = [ BuzzRequestInterface::METHOD_POST, BuzzRequestInterface::METHOD_PUT, BuzzRequestInterface::METHOD_DELETE, BuzzRequestInterface::METHOD_PATCH, BuzzRequestInterface::METHOD_OPTIONS, ]; // The Buzz Curl client does not send request bodies for request methods such as GET, HEAD and TRACE. Instead of // silently ignoring the request body in these cases, throw an exception to make users aware. if ($this->client instanceof Curl && $request->getBody()->getSize() && !in_array(strtoupper($request->getMethod()), $validMethods, true) ) { throw new HttplugException\RequestException( sprintf('%s does not support %s requests with a body', Curl::class, $request->getMethod()), $request ); } }
[ "private", "function", "assertRequestHasValidBody", "(", "RequestInterface", "$", "request", ")", "{", "$", "validMethods", "=", "[", "BuzzRequestInterface", "::", "METHOD_POST", ",", "BuzzRequestInterface", "::", "METHOD_PUT", ",", "BuzzRequestInterface", "::", "METHOD_DELETE", ",", "BuzzRequestInterface", "::", "METHOD_PATCH", ",", "BuzzRequestInterface", "::", "METHOD_OPTIONS", ",", "]", ";", "// The Buzz Curl client does not send request bodies for request methods such as GET, HEAD and TRACE. Instead of", "// silently ignoring the request body in these cases, throw an exception to make users aware.", "if", "(", "$", "this", "->", "client", "instanceof", "Curl", "&&", "$", "request", "->", "getBody", "(", ")", "->", "getSize", "(", ")", "&&", "!", "in_array", "(", "strtoupper", "(", "$", "request", "->", "getMethod", "(", ")", ")", ",", "$", "validMethods", ",", "true", ")", ")", "{", "throw", "new", "HttplugException", "\\", "RequestException", "(", "sprintf", "(", "'%s does not support %s requests with a body'", ",", "Curl", "::", "class", ",", "$", "request", "->", "getMethod", "(", ")", ")", ",", "$", "request", ")", ";", "}", "}" ]
Assert that the request has a valid body based on the request method. @param RequestInterface $request
[ "Assert", "that", "the", "request", "has", "a", "valid", "body", "based", "on", "the", "request", "method", "." ]
8b49145160113b4ca85c778d88c1666b8605d67a
https://github.com/php-http/buzz-adapter/blob/8b49145160113b4ca85c778d88c1666b8605d67a/src/Client.php#L169-L190
222,540
thephpleague/omnipay-multisafepay
src/Message/CompletePurchaseResponse.php
CompletePurchaseResponse.getPaymentStatus
public function getPaymentStatus() { if (isset($this->data->ewallet->status)) { return (string)$this->data->ewallet->status; } }
php
public function getPaymentStatus() { if (isset($this->data->ewallet->status)) { return (string)$this->data->ewallet->status; } }
[ "public", "function", "getPaymentStatus", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "->", "ewallet", "->", "status", ")", ")", "{", "return", "(", "string", ")", "$", "this", "->", "data", "->", "ewallet", "->", "status", ";", "}", "}" ]
Get raw payment status. @return null|string
[ "Get", "raw", "payment", "status", "." ]
532adb628b4b21504c00788e659406ff0c889e25
https://github.com/thephpleague/omnipay-multisafepay/blob/532adb628b4b21504c00788e659406ff0c889e25/src/Message/CompletePurchaseResponse.php#L99-L104
222,541
fastdlabs/swoole
src/Server.php
Server.onStart
public function onStart(swoole_server $server) { if (version_compare(SWOOLE_VERSION, '1.9.5', '<')) { file_put_contents($this->pidFile, $server->master_pid); $this->pid = $server->master_pid; } process_rename($this->name . ' master'); $this->output->writeln(sprintf("Listen: <info>%s://%s:%s</info>", $this->getScheme(), $this->getHost(), $this->getPort())); foreach ($this->listens as $listen) { $this->output->writeln(sprintf(" <info> ></info> Listen: <info>%s://%s:%s</info>", $listen->getScheme(), $listen->getHost(), $listen->getPort())); } $this->output->writeln(sprintf('PID file: <info>%s</info>, PID: <info>%s</info>', $this->pidFile, $server->master_pid)); $this->output->writeln(sprintf('Server Master[<info>%s</info>] is started', $server->master_pid), OutputInterface::VERBOSITY_DEBUG); }
php
public function onStart(swoole_server $server) { if (version_compare(SWOOLE_VERSION, '1.9.5', '<')) { file_put_contents($this->pidFile, $server->master_pid); $this->pid = $server->master_pid; } process_rename($this->name . ' master'); $this->output->writeln(sprintf("Listen: <info>%s://%s:%s</info>", $this->getScheme(), $this->getHost(), $this->getPort())); foreach ($this->listens as $listen) { $this->output->writeln(sprintf(" <info> ></info> Listen: <info>%s://%s:%s</info>", $listen->getScheme(), $listen->getHost(), $listen->getPort())); } $this->output->writeln(sprintf('PID file: <info>%s</info>, PID: <info>%s</info>', $this->pidFile, $server->master_pid)); $this->output->writeln(sprintf('Server Master[<info>%s</info>] is started', $server->master_pid), OutputInterface::VERBOSITY_DEBUG); }
[ "public", "function", "onStart", "(", "swoole_server", "$", "server", ")", "{", "if", "(", "version_compare", "(", "SWOOLE_VERSION", ",", "'1.9.5'", ",", "'<'", ")", ")", "{", "file_put_contents", "(", "$", "this", "->", "pidFile", ",", "$", "server", "->", "master_pid", ")", ";", "$", "this", "->", "pid", "=", "$", "server", "->", "master_pid", ";", "}", "process_rename", "(", "$", "this", "->", "name", ".", "' master'", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", "sprintf", "(", "\"Listen: <info>%s://%s:%s</info>\"", ",", "$", "this", "->", "getScheme", "(", ")", ",", "$", "this", "->", "getHost", "(", ")", ",", "$", "this", "->", "getPort", "(", ")", ")", ")", ";", "foreach", "(", "$", "this", "->", "listens", "as", "$", "listen", ")", "{", "$", "this", "->", "output", "->", "writeln", "(", "sprintf", "(", "\" <info> ></info> Listen: <info>%s://%s:%s</info>\"", ",", "$", "listen", "->", "getScheme", "(", ")", ",", "$", "listen", "->", "getHost", "(", ")", ",", "$", "listen", "->", "getPort", "(", ")", ")", ")", ";", "}", "$", "this", "->", "output", "->", "writeln", "(", "sprintf", "(", "'PID file: <info>%s</info>, PID: <info>%s</info>'", ",", "$", "this", "->", "pidFile", ",", "$", "server", "->", "master_pid", ")", ")", ";", "$", "this", "->", "output", "->", "writeln", "(", "sprintf", "(", "'Server Master[<info>%s</info>] is started'", ",", "$", "server", "->", "master_pid", ")", ",", "OutputInterface", "::", "VERBOSITY_DEBUG", ")", ";", "}" ]
Base start handle. Storage process id. @param swoole_server $server @return void
[ "Base", "start", "handle", ".", "Storage", "process", "id", "." ]
043be98edcf87a3eb752446c8e9b2f88c4034ff2
https://github.com/fastdlabs/swoole/blob/043be98edcf87a3eb752446c8e9b2f88c4034ff2/src/Server.php#L560-L576
222,542
jamiehollern/eventbrite
src/Eventbrite.php
Eventbrite.call
public function call($verb, $endpoint, $options = []) { if ($this->validMethod($verb)) { // Get the headers and body from the options. $headers = isset($options['headers']) ? $options['headers'] : []; $body = isset($options['body']) ? $options['body'] : null; $pv = isset($options['protocol_version']) ? $options['protocol_version'] : '1.1'; // Make the request. $request = new Request($verb, $endpoint, $headers, $body, $pv); // Save the request as the last request. $this->last_request = $request; // Send it. $response = $this->client->send($request, $options); if ($response instanceof ResponseInterface) { // Set the last response. $this->last_response = $response; // If the caller wants the raw response, give it to them. if (isset($options['parse_response']) && $options['parse_response'] === false) { return $response; } $parsed_response = $this->parseResponse($response); return $parsed_response; } else { // This only really happens when the network is interrupted. throw new BadResponseException('A bad response was received.', $request); } } else { throw new \Exception('Unrecognised HTTP verb.'); } }
php
public function call($verb, $endpoint, $options = []) { if ($this->validMethod($verb)) { // Get the headers and body from the options. $headers = isset($options['headers']) ? $options['headers'] : []; $body = isset($options['body']) ? $options['body'] : null; $pv = isset($options['protocol_version']) ? $options['protocol_version'] : '1.1'; // Make the request. $request = new Request($verb, $endpoint, $headers, $body, $pv); // Save the request as the last request. $this->last_request = $request; // Send it. $response = $this->client->send($request, $options); if ($response instanceof ResponseInterface) { // Set the last response. $this->last_response = $response; // If the caller wants the raw response, give it to them. if (isset($options['parse_response']) && $options['parse_response'] === false) { return $response; } $parsed_response = $this->parseResponse($response); return $parsed_response; } else { // This only really happens when the network is interrupted. throw new BadResponseException('A bad response was received.', $request); } } else { throw new \Exception('Unrecognised HTTP verb.'); } }
[ "public", "function", "call", "(", "$", "verb", ",", "$", "endpoint", ",", "$", "options", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "validMethod", "(", "$", "verb", ")", ")", "{", "// Get the headers and body from the options.", "$", "headers", "=", "isset", "(", "$", "options", "[", "'headers'", "]", ")", "?", "$", "options", "[", "'headers'", "]", ":", "[", "]", ";", "$", "body", "=", "isset", "(", "$", "options", "[", "'body'", "]", ")", "?", "$", "options", "[", "'body'", "]", ":", "null", ";", "$", "pv", "=", "isset", "(", "$", "options", "[", "'protocol_version'", "]", ")", "?", "$", "options", "[", "'protocol_version'", "]", ":", "'1.1'", ";", "// Make the request.", "$", "request", "=", "new", "Request", "(", "$", "verb", ",", "$", "endpoint", ",", "$", "headers", ",", "$", "body", ",", "$", "pv", ")", ";", "// Save the request as the last request.", "$", "this", "->", "last_request", "=", "$", "request", ";", "// Send it.", "$", "response", "=", "$", "this", "->", "client", "->", "send", "(", "$", "request", ",", "$", "options", ")", ";", "if", "(", "$", "response", "instanceof", "ResponseInterface", ")", "{", "// Set the last response.", "$", "this", "->", "last_response", "=", "$", "response", ";", "// If the caller wants the raw response, give it to them.", "if", "(", "isset", "(", "$", "options", "[", "'parse_response'", "]", ")", "&&", "$", "options", "[", "'parse_response'", "]", "===", "false", ")", "{", "return", "$", "response", ";", "}", "$", "parsed_response", "=", "$", "this", "->", "parseResponse", "(", "$", "response", ")", ";", "return", "$", "parsed_response", ";", "}", "else", "{", "// This only really happens when the network is interrupted.", "throw", "new", "BadResponseException", "(", "'A bad response was received.'", ",", "$", "request", ")", ";", "}", "}", "else", "{", "throw", "new", "\\", "Exception", "(", "'Unrecognised HTTP verb.'", ")", ";", "}", "}" ]
Make the call to Eventbrite, only synchronous calls at present. @param string $verb @param string $endpoint @param array $options @return array|mixed|\Psr\Http\Message\ResponseInterface @throws \Exception
[ "Make", "the", "call", "to", "Eventbrite", "only", "synchronous", "calls", "at", "present", "." ]
c2c93811ec622c3bcea3b3ff561ba3b1b9c6c472
https://github.com/jamiehollern/eventbrite/blob/c2c93811ec622c3bcea3b3ff561ba3b1b9c6c472/src/Eventbrite.php#L99-L129
222,543
jamiehollern/eventbrite
src/Eventbrite.php
Eventbrite.parseResponse
public function parseResponse(ResponseInterface $response) { $body = $response->getBody()->getContents(); return [ 'code' => $response->getStatusCode(), 'headers' => $response->getHeaders(), 'body' => ($this->isValidJson($body)) ? json_decode($body, true) : $body, ]; }
php
public function parseResponse(ResponseInterface $response) { $body = $response->getBody()->getContents(); return [ 'code' => $response->getStatusCode(), 'headers' => $response->getHeaders(), 'body' => ($this->isValidJson($body)) ? json_decode($body, true) : $body, ]; }
[ "public", "function", "parseResponse", "(", "ResponseInterface", "$", "response", ")", "{", "$", "body", "=", "$", "response", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ";", "return", "[", "'code'", "=>", "$", "response", "->", "getStatusCode", "(", ")", ",", "'headers'", "=>", "$", "response", "->", "getHeaders", "(", ")", ",", "'body'", "=>", "(", "$", "this", "->", "isValidJson", "(", "$", "body", ")", ")", "?", "json_decode", "(", "$", "body", ",", "true", ")", ":", "$", "body", ",", "]", ";", "}" ]
Parses the response from @param \Psr\Http\Message\ResponseInterface $response @return array
[ "Parses", "the", "response", "from" ]
c2c93811ec622c3bcea3b3ff561ba3b1b9c6c472
https://github.com/jamiehollern/eventbrite/blob/c2c93811ec622c3bcea3b3ff561ba3b1b9c6c472/src/Eventbrite.php#L193-L202
222,544
jamiehollern/eventbrite
src/Eventbrite.php
Eventbrite.canConnect
public function canConnect() { $data = $this->get(self::CURRENT_USER_ENDPOINT); if (strpos($data['code'], '2') === 0) { return true; } return false; }
php
public function canConnect() { $data = $this->get(self::CURRENT_USER_ENDPOINT); if (strpos($data['code'], '2') === 0) { return true; } return false; }
[ "public", "function", "canConnect", "(", ")", "{", "$", "data", "=", "$", "this", "->", "get", "(", "self", "::", "CURRENT_USER_ENDPOINT", ")", ";", "if", "(", "strpos", "(", "$", "data", "[", "'code'", "]", ",", "'2'", ")", "===", "0", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Checks if the class can connect to the Eventbrite API. Checks if we can connect to the API by calling the user endpoint and checking the response code. If the response code is 2xx it returns true, otherwise false. @return bool
[ "Checks", "if", "the", "class", "can", "connect", "to", "the", "Eventbrite", "API", "." ]
c2c93811ec622c3bcea3b3ff561ba3b1b9c6c472
https://github.com/jamiehollern/eventbrite/blob/c2c93811ec622c3bcea3b3ff561ba3b1b9c6c472/src/Eventbrite.php#L229-L236
222,545
Cysha/casino
src/Cards/CardCollection.php
CardCollection.whereSuit
public function whereSuit(string $name) { $name = rtrim($name, 's'); return $this->filter(function (Card $card) use ($name) { return $card->suit()->equals(call_user_func(Suit::class . '::' . $name)); }); }
php
public function whereSuit(string $name) { $name = rtrim($name, 's'); return $this->filter(function (Card $card) use ($name) { return $card->suit()->equals(call_user_func(Suit::class . '::' . $name)); }); }
[ "public", "function", "whereSuit", "(", "string", "$", "name", ")", "{", "$", "name", "=", "rtrim", "(", "$", "name", ",", "'s'", ")", ";", "return", "$", "this", "->", "filter", "(", "function", "(", "Card", "$", "card", ")", "use", "(", "$", "name", ")", "{", "return", "$", "card", "->", "suit", "(", ")", "->", "equals", "(", "call_user_func", "(", "Suit", "::", "class", ".", "'::'", ".", "$", "name", ")", ")", ";", "}", ")", ";", "}" ]
Get cards where Suit value is... @param string $name @return static
[ "Get", "cards", "where", "Suit", "value", "is", "..." ]
61e8b8639f0a6a87d0bab4f1826cf6bc3519000c
https://github.com/Cysha/casino/blob/61e8b8639f0a6a87d0bab4f1826cf6bc3519000c/src/Cards/CardCollection.php#L31-L38
222,546
Cysha/casino
src/Cards/CardCollection.php
CardCollection.whereValue
public function whereValue(int $value) { return $this->filter(function (Card $card) use ($value) { return $card->value() === $value; }); }
php
public function whereValue(int $value) { return $this->filter(function (Card $card) use ($value) { return $card->value() === $value; }); }
[ "public", "function", "whereValue", "(", "int", "$", "value", ")", "{", "return", "$", "this", "->", "filter", "(", "function", "(", "Card", "$", "card", ")", "use", "(", "$", "value", ")", "{", "return", "$", "card", "->", "value", "(", ")", "===", "$", "value", ";", "}", ")", ";", "}" ]
Get cards where Card Value is.. @param int $value @return static
[ "Get", "cards", "where", "Card", "Value", "is", ".." ]
61e8b8639f0a6a87d0bab4f1826cf6bc3519000c
https://github.com/Cysha/casino/blob/61e8b8639f0a6a87d0bab4f1826cf6bc3519000c/src/Cards/CardCollection.php#L47-L52
222,547
Cysha/casino
src/Cards/CardCollection.php
CardCollection.sortByValue
public function sortByValue($sort = SORT_NUMERIC) { return $this ->groupBy(function (Card $card) { return $card->value(); }) ->map(function (CardCollection $valueGroup) { return $valueGroup->sortBySuitValue(); }) ->flatten() ->sortBy(function (Card $card) { return $card->value(); }, $sort) ->values(); }
php
public function sortByValue($sort = SORT_NUMERIC) { return $this ->groupBy(function (Card $card) { return $card->value(); }) ->map(function (CardCollection $valueGroup) { return $valueGroup->sortBySuitValue(); }) ->flatten() ->sortBy(function (Card $card) { return $card->value(); }, $sort) ->values(); }
[ "public", "function", "sortByValue", "(", "$", "sort", "=", "SORT_NUMERIC", ")", "{", "return", "$", "this", "->", "groupBy", "(", "function", "(", "Card", "$", "card", ")", "{", "return", "$", "card", "->", "value", "(", ")", ";", "}", ")", "->", "map", "(", "function", "(", "CardCollection", "$", "valueGroup", ")", "{", "return", "$", "valueGroup", "->", "sortBySuitValue", "(", ")", ";", "}", ")", "->", "flatten", "(", ")", "->", "sortBy", "(", "function", "(", "Card", "$", "card", ")", "{", "return", "$", "card", "->", "value", "(", ")", ";", "}", ",", "$", "sort", ")", "->", "values", "(", ")", ";", "}" ]
Sort cards by their value, and then by Suit. @param int $sort @return static
[ "Sort", "cards", "by", "their", "value", "and", "then", "by", "Suit", "." ]
61e8b8639f0a6a87d0bab4f1826cf6bc3519000c
https://github.com/Cysha/casino/blob/61e8b8639f0a6a87d0bab4f1826cf6bc3519000c/src/Cards/CardCollection.php#L89-L103
222,548
Cysha/casino
src/Cards/CardCollection.php
CardCollection.groupByValue
public function groupByValue() { return $this ->sortByDesc(function (Card $card) { return $card->value(); }, SORT_NUMERIC) ->groupBy(function (Card $card) { return $card->value(); }) ->sortByDesc(function ($group) { return count($group); }, SORT_NUMERIC) ->values(); }
php
public function groupByValue() { return $this ->sortByDesc(function (Card $card) { return $card->value(); }, SORT_NUMERIC) ->groupBy(function (Card $card) { return $card->value(); }) ->sortByDesc(function ($group) { return count($group); }, SORT_NUMERIC) ->values(); }
[ "public", "function", "groupByValue", "(", ")", "{", "return", "$", "this", "->", "sortByDesc", "(", "function", "(", "Card", "$", "card", ")", "{", "return", "$", "card", "->", "value", "(", ")", ";", "}", ",", "SORT_NUMERIC", ")", "->", "groupBy", "(", "function", "(", "Card", "$", "card", ")", "{", "return", "$", "card", "->", "value", "(", ")", ";", "}", ")", "->", "sortByDesc", "(", "function", "(", "$", "group", ")", "{", "return", "count", "(", "$", "group", ")", ";", "}", ",", "SORT_NUMERIC", ")", "->", "values", "(", ")", ";", "}" ]
Group cards by the value and sort by highest card count first. @return static
[ "Group", "cards", "by", "the", "value", "and", "sort", "by", "highest", "card", "count", "first", "." ]
61e8b8639f0a6a87d0bab4f1826cf6bc3519000c
https://github.com/Cysha/casino/blob/61e8b8639f0a6a87d0bab4f1826cf6bc3519000c/src/Cards/CardCollection.php#L110-L123
222,549
Cysha/casino
src/Cards/CardCollection.php
CardCollection.uniqueByValue
public function uniqueByValue() { return $this ->sortByDesc(function (Card $card) { return $card->value(); }, SORT_NUMERIC) ->groupBy(function (Card $card) { return $card->value(); }) ->map(function($group) { return $group->first(); }) ->reverse() ->values(); }
php
public function uniqueByValue() { return $this ->sortByDesc(function (Card $card) { return $card->value(); }, SORT_NUMERIC) ->groupBy(function (Card $card) { return $card->value(); }) ->map(function($group) { return $group->first(); }) ->reverse() ->values(); }
[ "public", "function", "uniqueByValue", "(", ")", "{", "return", "$", "this", "->", "sortByDesc", "(", "function", "(", "Card", "$", "card", ")", "{", "return", "$", "card", "->", "value", "(", ")", ";", "}", ",", "SORT_NUMERIC", ")", "->", "groupBy", "(", "function", "(", "Card", "$", "card", ")", "{", "return", "$", "card", "->", "value", "(", ")", ";", "}", ")", "->", "map", "(", "function", "(", "$", "group", ")", "{", "return", "$", "group", "->", "first", "(", ")", ";", "}", ")", "->", "reverse", "(", ")", "->", "values", "(", ")", ";", "}" ]
Filter out duplicate card values out of the collection. @return static
[ "Filter", "out", "duplicate", "card", "values", "out", "of", "the", "collection", "." ]
61e8b8639f0a6a87d0bab4f1826cf6bc3519000c
https://github.com/Cysha/casino/blob/61e8b8639f0a6a87d0bab4f1826cf6bc3519000c/src/Cards/CardCollection.php#L130-L144
222,550
Cysha/casino
src/Cards/CardCollection.php
CardCollection.switchAceValue
public function switchAceValue() { return $this->map(function (Card $card) { if ($card->isAce() === false) { return $card; } return new Card(14, $card->suit()); }); }
php
public function switchAceValue() { return $this->map(function (Card $card) { if ($card->isAce() === false) { return $card; } return new Card(14, $card->suit()); }); }
[ "public", "function", "switchAceValue", "(", ")", "{", "return", "$", "this", "->", "map", "(", "function", "(", "Card", "$", "card", ")", "{", "if", "(", "$", "card", "->", "isAce", "(", ")", "===", "false", ")", "{", "return", "$", "card", ";", "}", "return", "new", "Card", "(", "14", ",", "$", "card", "->", "suit", "(", ")", ")", ";", "}", ")", ";", "}" ]
Replaces any Aces found in the collection with values of 14. @return static
[ "Replaces", "any", "Aces", "found", "in", "the", "collection", "with", "values", "of", "14", "." ]
61e8b8639f0a6a87d0bab4f1826cf6bc3519000c
https://github.com/Cysha/casino/blob/61e8b8639f0a6a87d0bab4f1826cf6bc3519000c/src/Cards/CardCollection.php#L151-L160
222,551
Cysha/casino
src/Cards/Suit.php
Suit.name
public function name() { switch ($this->suit) { case static::CLUB: $suit = static::CLUB_LONG_NAME; break; case static::DIAMOND: $suit = static::DIAMOND_LONG_NAME; break; case static::HEART: $suit = static::HEART_LONG_NAME; break; default: case static::SPADE: $suit = static::SPADE_LONG_NAME; break; } return $suit; }
php
public function name() { switch ($this->suit) { case static::CLUB: $suit = static::CLUB_LONG_NAME; break; case static::DIAMOND: $suit = static::DIAMOND_LONG_NAME; break; case static::HEART: $suit = static::HEART_LONG_NAME; break; default: case static::SPADE: $suit = static::SPADE_LONG_NAME; break; } return $suit; }
[ "public", "function", "name", "(", ")", "{", "switch", "(", "$", "this", "->", "suit", ")", "{", "case", "static", "::", "CLUB", ":", "$", "suit", "=", "static", "::", "CLUB_LONG_NAME", ";", "break", ";", "case", "static", "::", "DIAMOND", ":", "$", "suit", "=", "static", "::", "DIAMOND_LONG_NAME", ";", "break", ";", "case", "static", "::", "HEART", ":", "$", "suit", "=", "static", "::", "HEART_LONG_NAME", ";", "break", ";", "default", ":", "case", "static", "::", "SPADE", ":", "$", "suit", "=", "static", "::", "SPADE_LONG_NAME", ";", "break", ";", "}", "return", "$", "suit", ";", "}" ]
Get the suit name. @return string
[ "Get", "the", "suit", "name", "." ]
61e8b8639f0a6a87d0bab4f1826cf6bc3519000c
https://github.com/Cysha/casino/blob/61e8b8639f0a6a87d0bab4f1826cf6bc3519000c/src/Cards/Suit.php#L149-L168
222,552
Cysha/casino
src/Cards/Suit.php
Suit.symbol
public function symbol() { switch ($this->suit) { case static::CLUB: $symbol = self::CLUB_SYMBOL; break; case static::DIAMOND: $symbol = self::DIAMOND_SYMBOL; break; case static::HEART: $symbol = self::HEART_SYMBOL; break; default: case static::SPADE: $symbol = self::SPADE_SYMBOL; break; } return $symbol; }
php
public function symbol() { switch ($this->suit) { case static::CLUB: $symbol = self::CLUB_SYMBOL; break; case static::DIAMOND: $symbol = self::DIAMOND_SYMBOL; break; case static::HEART: $symbol = self::HEART_SYMBOL; break; default: case static::SPADE: $symbol = self::SPADE_SYMBOL; break; } return $symbol; }
[ "public", "function", "symbol", "(", ")", "{", "switch", "(", "$", "this", "->", "suit", ")", "{", "case", "static", "::", "CLUB", ":", "$", "symbol", "=", "self", "::", "CLUB_SYMBOL", ";", "break", ";", "case", "static", "::", "DIAMOND", ":", "$", "symbol", "=", "self", "::", "DIAMOND_SYMBOL", ";", "break", ";", "case", "static", "::", "HEART", ":", "$", "symbol", "=", "self", "::", "HEART_SYMBOL", ";", "break", ";", "default", ":", "case", "static", "::", "SPADE", ":", "$", "symbol", "=", "self", "::", "SPADE_SYMBOL", ";", "break", ";", "}", "return", "$", "symbol", ";", "}" ]
Get the suit symbol. @return string
[ "Get", "the", "suit", "symbol", "." ]
61e8b8639f0a6a87d0bab4f1826cf6bc3519000c
https://github.com/Cysha/casino/blob/61e8b8639f0a6a87d0bab4f1826cf6bc3519000c/src/Cards/Suit.php#L175-L194
222,553
thephpleague/omnipay-multisafepay
src/Message/RestFetchPaymentMethodsRequest.php
RestFetchPaymentMethodsRequest.sendData
public function sendData($data) { $httpResponse = $this->sendRequest('GET', '/gateways', json_encode($data)); $this->response = new RestFetchPaymentMethodsResponse( $this, json_decode($httpResponse->getBody()->getContents(), true) ); return $this->response; }
php
public function sendData($data) { $httpResponse = $this->sendRequest('GET', '/gateways', json_encode($data)); $this->response = new RestFetchPaymentMethodsResponse( $this, json_decode($httpResponse->getBody()->getContents(), true) ); return $this->response; }
[ "public", "function", "sendData", "(", "$", "data", ")", "{", "$", "httpResponse", "=", "$", "this", "->", "sendRequest", "(", "'GET'", ",", "'/gateways'", ",", "json_encode", "(", "$", "data", ")", ")", ";", "$", "this", "->", "response", "=", "new", "RestFetchPaymentMethodsResponse", "(", "$", "this", ",", "json_decode", "(", "$", "httpResponse", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ",", "true", ")", ")", ";", "return", "$", "this", "->", "response", ";", "}" ]
Execute the API request. @param mixed $data @return RestFetchPaymentMethodsResponse
[ "Execute", "the", "API", "request", "." ]
532adb628b4b21504c00788e659406ff0c889e25
https://github.com/thephpleague/omnipay-multisafepay/blob/532adb628b4b21504c00788e659406ff0c889e25/src/Message/RestFetchPaymentMethodsRequest.php#L73-L83
222,554
arandilopez/laravel-feed-parser
src/Adapters/SimplePieItemAdapter.php
SimplePieItemAdapter.toArray
public function toArray() { return [ 'title' => $this->title, 'description' => $this->description, 'content' => $this->content, 'authors' => array_map(function ($author) { return $author->toArray(); }, isset($this->authors) ? $this->authors : []), 'date' => $this->date, 'permalink' => $this->permalink, ]; }
php
public function toArray() { return [ 'title' => $this->title, 'description' => $this->description, 'content' => $this->content, 'authors' => array_map(function ($author) { return $author->toArray(); }, isset($this->authors) ? $this->authors : []), 'date' => $this->date, 'permalink' => $this->permalink, ]; }
[ "public", "function", "toArray", "(", ")", "{", "return", "[", "'title'", "=>", "$", "this", "->", "title", ",", "'description'", "=>", "$", "this", "->", "description", ",", "'content'", "=>", "$", "this", "->", "content", ",", "'authors'", "=>", "array_map", "(", "function", "(", "$", "author", ")", "{", "return", "$", "author", "->", "toArray", "(", ")", ";", "}", ",", "isset", "(", "$", "this", "->", "authors", ")", "?", "$", "this", "->", "authors", ":", "[", "]", ")", ",", "'date'", "=>", "$", "this", "->", "date", ",", "'permalink'", "=>", "$", "this", "->", "permalink", ",", "]", ";", "}" ]
Return basic item data. Authors in array @method toArray @return [type]
[ "Return", "basic", "item", "data", ".", "Authors", "in", "array" ]
a4b7747e28a9a2fce9d0d7aeff07d4129263fc42
https://github.com/arandilopez/laravel-feed-parser/blob/a4b7747e28a9a2fce9d0d7aeff07d4129263fc42/src/Adapters/SimplePieItemAdapter.php#L72-L84
222,555
sylouuu/php-curl
src/Curl.php
Curl.setCurlOption
public function setCurlOption($option, $value) { curl_setopt($this->ch, $option, $value); $this->curl_options[$option] = $value; return $this; }
php
public function setCurlOption($option, $value) { curl_setopt($this->ch, $option, $value); $this->curl_options[$option] = $value; return $this; }
[ "public", "function", "setCurlOption", "(", "$", "option", ",", "$", "value", ")", "{", "curl_setopt", "(", "$", "this", "->", "ch", ",", "$", "option", ",", "$", "value", ")", ";", "$", "this", "->", "curl_options", "[", "$", "option", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Setter Curl option See options list: http://php.net/manual/en/function.curl-setopt.php @param const $option @param mixed $value @return mixed
[ "Setter", "Curl", "option" ]
3386f2085a97aa0683ac80aaea2403fcde488f28
https://github.com/sylouuu/php-curl/blob/3386f2085a97aa0683ac80aaea2403fcde488f28/src/Curl.php#L94-L101
222,556
thephpleague/omnipay-multisafepay
src/Message/RestCompletePurchaseRequest.php
RestCompletePurchaseRequest.sendData
public function sendData($data) { $httpResponse = $this->sendRequest( 'get', '/orders/' . $data['transactionId'] ); $this->response = new RestCompletePurchaseResponse( $this, json_decode($httpResponse->getBody()->getContents(), true) ); return $this->response; }
php
public function sendData($data) { $httpResponse = $this->sendRequest( 'get', '/orders/' . $data['transactionId'] ); $this->response = new RestCompletePurchaseResponse( $this, json_decode($httpResponse->getBody()->getContents(), true) ); return $this->response; }
[ "public", "function", "sendData", "(", "$", "data", ")", "{", "$", "httpResponse", "=", "$", "this", "->", "sendRequest", "(", "'get'", ",", "'/orders/'", ".", "$", "data", "[", "'transactionId'", "]", ")", ";", "$", "this", "->", "response", "=", "new", "RestCompletePurchaseResponse", "(", "$", "this", ",", "json_decode", "(", "$", "httpResponse", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ",", "true", ")", ")", ";", "return", "$", "this", "->", "response", ";", "}" ]
Send the API request. @param mixed $data @return RestCompletePurchaseResponse
[ "Send", "the", "API", "request", "." ]
532adb628b4b21504c00788e659406ff0c889e25
https://github.com/thephpleague/omnipay-multisafepay/blob/532adb628b4b21504c00788e659406ff0c889e25/src/Message/RestCompletePurchaseRequest.php#L44-L57
222,557
thephpleague/omnipay-multisafepay
src/Message/RestFetchPaymentMethodsResponse.php
RestFetchPaymentMethodsResponse.getPaymentMethods
public function getPaymentMethods() { $paymentMethods = array(); foreach ($this->data['data'] as $method) { $paymentMethods[] = new PaymentMethod( $method['id'], $method['description'] ); } return $paymentMethods; }
php
public function getPaymentMethods() { $paymentMethods = array(); foreach ($this->data['data'] as $method) { $paymentMethods[] = new PaymentMethod( $method['id'], $method['description'] ); } return $paymentMethods; }
[ "public", "function", "getPaymentMethods", "(", ")", "{", "$", "paymentMethods", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "data", "[", "'data'", "]", "as", "$", "method", ")", "{", "$", "paymentMethods", "[", "]", "=", "new", "PaymentMethod", "(", "$", "method", "[", "'id'", "]", ",", "$", "method", "[", "'description'", "]", ")", ";", "}", "return", "$", "paymentMethods", ";", "}" ]
Get the returned list of payment methods. These represent separate payment methods which the user must choose between. @return \Omnipay\Common\PaymentMethod[]
[ "Get", "the", "returned", "list", "of", "payment", "methods", "." ]
532adb628b4b21504c00788e659406ff0c889e25
https://github.com/thephpleague/omnipay-multisafepay/blob/532adb628b4b21504c00788e659406ff0c889e25/src/Message/RestFetchPaymentMethodsResponse.php#L39-L51
222,558
thephpleague/omnipay-multisafepay
src/Message/RestPurchaseRequest.php
RestPurchaseRequest.getPaymentData
protected function getPaymentData() { $data = array( 'cancel_url' => $this->getCancelUrl(), 'close_window' => $this->getCloseWindow(), 'notification_url' => $this->getNotifyUrl(), 'redirect_url' => $this->getReturnUrl(), ); return array_filter($data); }
php
protected function getPaymentData() { $data = array( 'cancel_url' => $this->getCancelUrl(), 'close_window' => $this->getCloseWindow(), 'notification_url' => $this->getNotifyUrl(), 'redirect_url' => $this->getReturnUrl(), ); return array_filter($data); }
[ "protected", "function", "getPaymentData", "(", ")", "{", "$", "data", "=", "array", "(", "'cancel_url'", "=>", "$", "this", "->", "getCancelUrl", "(", ")", ",", "'close_window'", "=>", "$", "this", "->", "getCloseWindow", "(", ")", ",", "'notification_url'", "=>", "$", "this", "->", "getNotifyUrl", "(", ")", ",", "'redirect_url'", "=>", "$", "this", "->", "getReturnUrl", "(", ")", ",", ")", ";", "return", "array_filter", "(", "$", "data", ")", ";", "}" ]
Get the payment options. @return array
[ "Get", "the", "payment", "options", "." ]
532adb628b4b21504c00788e659406ff0c889e25
https://github.com/thephpleague/omnipay-multisafepay/blob/532adb628b4b21504c00788e659406ff0c889e25/src/Message/RestPurchaseRequest.php#L411-L421
222,559
thephpleague/omnipay-multisafepay
src/Message/RestPurchaseRequest.php
RestPurchaseRequest.getCustomerData
public function getCustomerData() { $data = array( 'disable_send_mail' => $this->getSendMail(), 'locale' => $this->getLocale(), ); if (is_null($this->getCard())) { return array_filter($data); } $cardData = array( 'address1' => $this->getCard()->getAddress1(), 'address2' => $this->getCard()->getAddress2(), 'city' => $this->getCard()->getCity(), 'country' => $this->getCard()->getCountry(), 'email' => $this->getCard()->getEmail(), 'first_name' => $this->getCard()->getFirstName(), 'house_number' => $this->getVar1(), 'last_name' => $this->getCard()->getLastName(), 'phone' => $this->getCard()->getPhone(), 'state' => $this->getCard()->getState(), 'zip_code' => $this->getCard()->getPostcode(), ); return array_filter( array_merge($data, $cardData) ); }
php
public function getCustomerData() { $data = array( 'disable_send_mail' => $this->getSendMail(), 'locale' => $this->getLocale(), ); if (is_null($this->getCard())) { return array_filter($data); } $cardData = array( 'address1' => $this->getCard()->getAddress1(), 'address2' => $this->getCard()->getAddress2(), 'city' => $this->getCard()->getCity(), 'country' => $this->getCard()->getCountry(), 'email' => $this->getCard()->getEmail(), 'first_name' => $this->getCard()->getFirstName(), 'house_number' => $this->getVar1(), 'last_name' => $this->getCard()->getLastName(), 'phone' => $this->getCard()->getPhone(), 'state' => $this->getCard()->getState(), 'zip_code' => $this->getCard()->getPostcode(), ); return array_filter( array_merge($data, $cardData) ); }
[ "public", "function", "getCustomerData", "(", ")", "{", "$", "data", "=", "array", "(", "'disable_send_mail'", "=>", "$", "this", "->", "getSendMail", "(", ")", ",", "'locale'", "=>", "$", "this", "->", "getLocale", "(", ")", ",", ")", ";", "if", "(", "is_null", "(", "$", "this", "->", "getCard", "(", ")", ")", ")", "{", "return", "array_filter", "(", "$", "data", ")", ";", "}", "$", "cardData", "=", "array", "(", "'address1'", "=>", "$", "this", "->", "getCard", "(", ")", "->", "getAddress1", "(", ")", ",", "'address2'", "=>", "$", "this", "->", "getCard", "(", ")", "->", "getAddress2", "(", ")", ",", "'city'", "=>", "$", "this", "->", "getCard", "(", ")", "->", "getCity", "(", ")", ",", "'country'", "=>", "$", "this", "->", "getCard", "(", ")", "->", "getCountry", "(", ")", ",", "'email'", "=>", "$", "this", "->", "getCard", "(", ")", "->", "getEmail", "(", ")", ",", "'first_name'", "=>", "$", "this", "->", "getCard", "(", ")", "->", "getFirstName", "(", ")", ",", "'house_number'", "=>", "$", "this", "->", "getVar1", "(", ")", ",", "'last_name'", "=>", "$", "this", "->", "getCard", "(", ")", "->", "getLastName", "(", ")", ",", "'phone'", "=>", "$", "this", "->", "getCard", "(", ")", "->", "getPhone", "(", ")", ",", "'state'", "=>", "$", "this", "->", "getCard", "(", ")", "->", "getState", "(", ")", ",", "'zip_code'", "=>", "$", "this", "->", "getCard", "(", ")", "->", "getPostcode", "(", ")", ",", ")", ";", "return", "array_filter", "(", "array_merge", "(", "$", "data", ",", "$", "cardData", ")", ")", ";", "}" ]
Customer information. This function returns all the provided client related parameters. @return array
[ "Customer", "information", "." ]
532adb628b4b21504c00788e659406ff0c889e25
https://github.com/thephpleague/omnipay-multisafepay/blob/532adb628b4b21504c00788e659406ff0c889e25/src/Message/RestPurchaseRequest.php#L431-L459
222,560
thephpleague/omnipay-multisafepay
src/Message/RestPurchaseRequest.php
RestPurchaseRequest.getItemBagData
protected function getItemBagData() { $items = array(); $itemBag = $this->getItems(); if (! empty($itemBag)) { foreach ($itemBag->all() as $item) { $items[] = array( 'name' => $item->getName(), 'description' => $item->getDescription(), 'quantity' => $item->getQuantity(), 'unit_price' => $item->getPrice(), ); } } return $items; }
php
protected function getItemBagData() { $items = array(); $itemBag = $this->getItems(); if (! empty($itemBag)) { foreach ($itemBag->all() as $item) { $items[] = array( 'name' => $item->getName(), 'description' => $item->getDescription(), 'quantity' => $item->getQuantity(), 'unit_price' => $item->getPrice(), ); } } return $items; }
[ "protected", "function", "getItemBagData", "(", ")", "{", "$", "items", "=", "array", "(", ")", ";", "$", "itemBag", "=", "$", "this", "->", "getItems", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "itemBag", ")", ")", "{", "foreach", "(", "$", "itemBag", "->", "all", "(", ")", "as", "$", "item", ")", "{", "$", "items", "[", "]", "=", "array", "(", "'name'", "=>", "$", "item", "->", "getName", "(", ")", ",", "'description'", "=>", "$", "item", "->", "getDescription", "(", ")", ",", "'quantity'", "=>", "$", "item", "->", "getQuantity", "(", ")", ",", "'unit_price'", "=>", "$", "item", "->", "getPrice", "(", ")", ",", ")", ";", "}", "}", "return", "$", "items", ";", "}" ]
Get itembag data. @return array
[ "Get", "itembag", "data", "." ]
532adb628b4b21504c00788e659406ff0c889e25
https://github.com/thephpleague/omnipay-multisafepay/blob/532adb628b4b21504c00788e659406ff0c889e25/src/Message/RestPurchaseRequest.php#L480-L496
222,561
oscarotero/middleland
src/Dispatcher.php
Dispatcher.get
private function get(ServerRequestInterface $request) { $middleware = current($this->middleware); next($this->middleware); if ($middleware === false) { return $middleware; } if (is_array($middleware)) { $conditions = $middleware; $middleware = array_pop($conditions); foreach ($conditions as $condition) { if ($condition === true) { continue; } if ($condition === false) { return $this->get($request); } if (is_string($condition)) { $condition = new Matchers\Path($condition); } elseif (!is_callable($condition)) { throw new InvalidArgumentException('Invalid matcher. Must be a boolean, string or a callable'); } if (!$condition($request)) { return $this->get($request); } } } if (is_string($middleware)) { if ($this->container === null) { throw new InvalidArgumentException(sprintf('No valid middleware provided (%s)', $middleware)); } $middleware = $this->container->get($middleware); } if ($middleware instanceof Closure) { return self::createMiddlewareFromClosure($middleware); } if ($middleware instanceof MiddlewareInterface) { return $middleware; } throw new InvalidArgumentException(sprintf('No valid middleware provided (%s)', is_object($middleware) ? get_class($middleware) : gettype($middleware))); }
php
private function get(ServerRequestInterface $request) { $middleware = current($this->middleware); next($this->middleware); if ($middleware === false) { return $middleware; } if (is_array($middleware)) { $conditions = $middleware; $middleware = array_pop($conditions); foreach ($conditions as $condition) { if ($condition === true) { continue; } if ($condition === false) { return $this->get($request); } if (is_string($condition)) { $condition = new Matchers\Path($condition); } elseif (!is_callable($condition)) { throw new InvalidArgumentException('Invalid matcher. Must be a boolean, string or a callable'); } if (!$condition($request)) { return $this->get($request); } } } if (is_string($middleware)) { if ($this->container === null) { throw new InvalidArgumentException(sprintf('No valid middleware provided (%s)', $middleware)); } $middleware = $this->container->get($middleware); } if ($middleware instanceof Closure) { return self::createMiddlewareFromClosure($middleware); } if ($middleware instanceof MiddlewareInterface) { return $middleware; } throw new InvalidArgumentException(sprintf('No valid middleware provided (%s)', is_object($middleware) ? get_class($middleware) : gettype($middleware))); }
[ "private", "function", "get", "(", "ServerRequestInterface", "$", "request", ")", "{", "$", "middleware", "=", "current", "(", "$", "this", "->", "middleware", ")", ";", "next", "(", "$", "this", "->", "middleware", ")", ";", "if", "(", "$", "middleware", "===", "false", ")", "{", "return", "$", "middleware", ";", "}", "if", "(", "is_array", "(", "$", "middleware", ")", ")", "{", "$", "conditions", "=", "$", "middleware", ";", "$", "middleware", "=", "array_pop", "(", "$", "conditions", ")", ";", "foreach", "(", "$", "conditions", "as", "$", "condition", ")", "{", "if", "(", "$", "condition", "===", "true", ")", "{", "continue", ";", "}", "if", "(", "$", "condition", "===", "false", ")", "{", "return", "$", "this", "->", "get", "(", "$", "request", ")", ";", "}", "if", "(", "is_string", "(", "$", "condition", ")", ")", "{", "$", "condition", "=", "new", "Matchers", "\\", "Path", "(", "$", "condition", ")", ";", "}", "elseif", "(", "!", "is_callable", "(", "$", "condition", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Invalid matcher. Must be a boolean, string or a callable'", ")", ";", "}", "if", "(", "!", "$", "condition", "(", "$", "request", ")", ")", "{", "return", "$", "this", "->", "get", "(", "$", "request", ")", ";", "}", "}", "}", "if", "(", "is_string", "(", "$", "middleware", ")", ")", "{", "if", "(", "$", "this", "->", "container", "===", "null", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'No valid middleware provided (%s)'", ",", "$", "middleware", ")", ")", ";", "}", "$", "middleware", "=", "$", "this", "->", "container", "->", "get", "(", "$", "middleware", ")", ";", "}", "if", "(", "$", "middleware", "instanceof", "Closure", ")", "{", "return", "self", "::", "createMiddlewareFromClosure", "(", "$", "middleware", ")", ";", "}", "if", "(", "$", "middleware", "instanceof", "MiddlewareInterface", ")", "{", "return", "$", "middleware", ";", "}", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'No valid middleware provided (%s)'", ",", "is_object", "(", "$", "middleware", ")", "?", "get_class", "(", "$", "middleware", ")", ":", "gettype", "(", "$", "middleware", ")", ")", ")", ";", "}" ]
Return the next available middleware in the stack. @return MiddlewareInterface|false
[ "Return", "the", "next", "available", "middleware", "in", "the", "stack", "." ]
abd480afe264714095d043edd76c542a99f1695b
https://github.com/oscarotero/middleland/blob/abd480afe264714095d043edd76c542a99f1695b/src/Dispatcher.php#L58-L109
222,562
oscarotero/middleland
src/Dispatcher.php
Dispatcher.createMiddlewareFromClosure
private static function createMiddlewareFromClosure(Closure $handler): MiddlewareInterface { return new class($handler) implements MiddlewareInterface { private $handler; public function __construct(Closure $handler) { $this->handler = $handler; } public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface { return call_user_func($this->handler, $request, $next); } }; }
php
private static function createMiddlewareFromClosure(Closure $handler): MiddlewareInterface { return new class($handler) implements MiddlewareInterface { private $handler; public function __construct(Closure $handler) { $this->handler = $handler; } public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface { return call_user_func($this->handler, $request, $next); } }; }
[ "private", "static", "function", "createMiddlewareFromClosure", "(", "Closure", "$", "handler", ")", ":", "MiddlewareInterface", "{", "return", "new", "class", "(", "$", "handler", ")", "implements", "MiddlewareInterface", "{", "private", "$", "handler", ";", "public", "function", "__construct", "(", "Closure", "$", "handler", ")", "{", "$", "this", "->", "handler", "=", "$", "handler", ";", "}", "public", "function", "process", "(", "ServerRequestInterface", "$", "request", ",", "RequestHandlerInterface", "$", "next", ")", ":", "ResponseInterface", "{", "return", "call_user_func", "(", "$", "this", "->", "handler", ",", "$", "request", ",", "$", "next", ")", ";", "}", "}", ";", "}" ]
Create a middleware from a closure
[ "Create", "a", "middleware", "from", "a", "closure" ]
abd480afe264714095d043edd76c542a99f1695b
https://github.com/oscarotero/middleland/blob/abd480afe264714095d043edd76c542a99f1695b/src/Dispatcher.php#L152-L167
222,563
Fleshgrinder/php-url-validator
src/Fleshgrinder/Validator/URL.php
URL.setAllowedSchemes
public function setAllowedSchemes($allowedSchemes) { if (empty($allowedSchemes)) { throw new \InvalidArgumentException("Allowed schemes cannot be empty."); } $allowedSchemes = (array) $allowedSchemes; $c = count($allowedSchemes); for ($i = 0; $i < $c; ++$i) { if (empty($allowedSchemes[$i])) { throw new \InvalidArgumentException("An allowed scheme cannot be empty."); } elseif (!preg_match(static::SCHEME_PATTERN, $allowedSchemes[$i])) { throw new \InvalidArgumentException("Allowed scheme [{$allowedSchemes[$i]}] contains illegal characters (see RFC3986)."); } } $this->allowedSchemes = $allowedSchemes; return $this; }
php
public function setAllowedSchemes($allowedSchemes) { if (empty($allowedSchemes)) { throw new \InvalidArgumentException("Allowed schemes cannot be empty."); } $allowedSchemes = (array) $allowedSchemes; $c = count($allowedSchemes); for ($i = 0; $i < $c; ++$i) { if (empty($allowedSchemes[$i])) { throw new \InvalidArgumentException("An allowed scheme cannot be empty."); } elseif (!preg_match(static::SCHEME_PATTERN, $allowedSchemes[$i])) { throw new \InvalidArgumentException("Allowed scheme [{$allowedSchemes[$i]}] contains illegal characters (see RFC3986)."); } } $this->allowedSchemes = $allowedSchemes; return $this; }
[ "public", "function", "setAllowedSchemes", "(", "$", "allowedSchemes", ")", "{", "if", "(", "empty", "(", "$", "allowedSchemes", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Allowed schemes cannot be empty.\"", ")", ";", "}", "$", "allowedSchemes", "=", "(", "array", ")", "$", "allowedSchemes", ";", "$", "c", "=", "count", "(", "$", "allowedSchemes", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "c", ";", "++", "$", "i", ")", "{", "if", "(", "empty", "(", "$", "allowedSchemes", "[", "$", "i", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"An allowed scheme cannot be empty.\"", ")", ";", "}", "elseif", "(", "!", "preg_match", "(", "static", "::", "SCHEME_PATTERN", ",", "$", "allowedSchemes", "[", "$", "i", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Allowed scheme [{$allowedSchemes[$i]}] contains illegal characters (see RFC3986).\"", ")", ";", "}", "}", "$", "this", "->", "allowedSchemes", "=", "$", "allowedSchemes", ";", "return", "$", "this", ";", "}" ]
Set the allowed schemes. By default `http` and `https` are allowed. @param array|string $allowedSchemes The schemes to allow. @return $this @throws \InvalidArgumentException If a scheme is empty or contains illegal characters.
[ "Set", "the", "allowed", "schemes", "." ]
7994026e45d9ce1612599e569ca3cc80c785acb5
https://github.com/Fleshgrinder/php-url-validator/blob/7994026e45d9ce1612599e569ca3cc80c785acb5/src/Fleshgrinder/Validator/URL.php#L261-L279
222,564
Fleshgrinder/php-url-validator
src/Fleshgrinder/Validator/URL.php
URL.reset
public function reset() { $this->domain = null; $this->fragment = null; $this->hostname = null; $this->ipv4 = null; $this->ipv6 = null; $this->password = null; $this->path = null; $this->port = null; $this->query = null; $this->scheme = null; $this->tld = null; $this->url = null; $this->username = null; return $this; }
php
public function reset() { $this->domain = null; $this->fragment = null; $this->hostname = null; $this->ipv4 = null; $this->ipv6 = null; $this->password = null; $this->path = null; $this->port = null; $this->query = null; $this->scheme = null; $this->tld = null; $this->url = null; $this->username = null; return $this; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "domain", "=", "null", ";", "$", "this", "->", "fragment", "=", "null", ";", "$", "this", "->", "hostname", "=", "null", ";", "$", "this", "->", "ipv4", "=", "null", ";", "$", "this", "->", "ipv6", "=", "null", ";", "$", "this", "->", "password", "=", "null", ";", "$", "this", "->", "path", "=", "null", ";", "$", "this", "->", "port", "=", "null", ";", "$", "this", "->", "query", "=", "null", ";", "$", "this", "->", "scheme", "=", "null", ";", "$", "this", "->", "tld", "=", "null", ";", "$", "this", "->", "url", "=", "null", ";", "$", "this", "->", "username", "=", "null", ";", "return", "$", "this", ";", "}" ]
Reset all properties to their defaults. @return $this
[ "Reset", "all", "properties", "to", "their", "defaults", "." ]
7994026e45d9ce1612599e569ca3cc80c785acb5
https://github.com/Fleshgrinder/php-url-validator/blob/7994026e45d9ce1612599e569ca3cc80c785acb5/src/Fleshgrinder/Validator/URL.php#L286-L303
222,565
Cysha/casino
src/Cards/Deck.php
Deck.draw
public function draw() { if ($this->count() == 0) { throw new \UnderflowException('No more cards in the deck!'); } $card = array_pop($this->cards); $this->cardsDrawn[] = $card; return $card; }
php
public function draw() { if ($this->count() == 0) { throw new \UnderflowException('No more cards in the deck!'); } $card = array_pop($this->cards); $this->cardsDrawn[] = $card; return $card; }
[ "public", "function", "draw", "(", ")", "{", "if", "(", "$", "this", "->", "count", "(", ")", "==", "0", ")", "{", "throw", "new", "\\", "UnderflowException", "(", "'No more cards in the deck!'", ")", ";", "}", "$", "card", "=", "array_pop", "(", "$", "this", "->", "cards", ")", ";", "$", "this", "->", "cardsDrawn", "[", "]", "=", "$", "card", ";", "return", "$", "card", ";", "}" ]
Draw a card from the deck. @return Card @throws UnderflowException
[ "Draw", "a", "card", "from", "the", "deck", "." ]
61e8b8639f0a6a87d0bab4f1826cf6bc3519000c
https://github.com/Cysha/casino/blob/61e8b8639f0a6a87d0bab4f1826cf6bc3519000c/src/Cards/Deck.php#L30-L41
222,566
Cysha/casino
src/Cards/Deck.php
Deck.drawHand
public function drawHand($size = 1) { $hand = []; for ($i = 0; $i < $size; ++$i) { $hand[] = $this->draw(); } return $hand; }
php
public function drawHand($size = 1) { $hand = []; for ($i = 0; $i < $size; ++$i) { $hand[] = $this->draw(); } return $hand; }
[ "public", "function", "drawHand", "(", "$", "size", "=", "1", ")", "{", "$", "hand", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "size", ";", "++", "$", "i", ")", "{", "$", "hand", "[", "]", "=", "$", "this", "->", "draw", "(", ")", ";", "}", "return", "$", "hand", ";", "}" ]
Draw a hand of cards from the deck. @param int $size the number of cards to draw @return array return array of Card @throws UnderflowException
[ "Draw", "a", "hand", "of", "cards", "from", "the", "deck", "." ]
61e8b8639f0a6a87d0bab4f1826cf6bc3519000c
https://github.com/Cysha/casino/blob/61e8b8639f0a6a87d0bab4f1826cf6bc3519000c/src/Cards/Deck.php#L52-L61
222,567
Cysha/casino
src/Cards/Deck.php
Deck.reset
public function reset() { $this->cards = array_merge($this->cards, $this->cardsDrawn); $this->cardsDrawn = []; }
php
public function reset() { $this->cards = array_merge($this->cards, $this->cardsDrawn); $this->cardsDrawn = []; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "cards", "=", "array_merge", "(", "$", "this", "->", "cards", ",", "$", "this", "->", "cardsDrawn", ")", ";", "$", "this", "->", "cardsDrawn", "=", "[", "]", ";", "}" ]
ReAdds cards from the drawn pile back to the main deck.
[ "ReAdds", "cards", "from", "the", "drawn", "pile", "back", "to", "the", "main", "deck", "." ]
61e8b8639f0a6a87d0bab4f1826cf6bc3519000c
https://github.com/Cysha/casino/blob/61e8b8639f0a6a87d0bab4f1826cf6bc3519000c/src/Cards/Deck.php#L118-L122
222,568
fastdlabs/swoole
src/Support/Watcher.php
Watcher.clearWatch
public function clearWatch() { foreach ($this->watchDir as $wd) { inotify_rm_watch($this->inotify, $wd); } $this->watchDir = []; }
php
public function clearWatch() { foreach ($this->watchDir as $wd) { inotify_rm_watch($this->inotify, $wd); } $this->watchDir = []; }
[ "public", "function", "clearWatch", "(", ")", "{", "foreach", "(", "$", "this", "->", "watchDir", "as", "$", "wd", ")", "{", "inotify_rm_watch", "(", "$", "this", "->", "inotify", ",", "$", "wd", ")", ";", "}", "$", "this", "->", "watchDir", "=", "[", "]", ";", "}" ]
Clear all watching. @return void
[ "Clear", "all", "watching", "." ]
043be98edcf87a3eb752446c8e9b2f88c4034ff2
https://github.com/fastdlabs/swoole/blob/043be98edcf87a3eb752446c8e9b2f88c4034ff2/src/Support/Watcher.php#L73-L79
222,569
gidlov/copycat
src/Gidlov/Copycat/Copycat.php
Copycat.setCURL
public function setCURL($const) { $this->_curl_options = $const + $this->_curl_options; $this->_curl = curl_init(); curl_setopt_array($this->_curl, $this->_curl_options); //curl_exec($this->_curl); return $this; }
php
public function setCURL($const) { $this->_curl_options = $const + $this->_curl_options; $this->_curl = curl_init(); curl_setopt_array($this->_curl, $this->_curl_options); //curl_exec($this->_curl); return $this; }
[ "public", "function", "setCURL", "(", "$", "const", ")", "{", "$", "this", "->", "_curl_options", "=", "$", "const", "+", "$", "this", "->", "_curl_options", ";", "$", "this", "->", "_curl", "=", "curl_init", "(", ")", ";", "curl_setopt_array", "(", "$", "this", "->", "_curl", ",", "$", "this", "->", "_curl_options", ")", ";", "//curl_exec($this->_curl);\r", "return", "$", "this", ";", "}" ]
Custom CURL settings Set A multidimensional array where the key represents a predefined CURL-constant and where the value is the value of the constant. This method is optional. @param array const @return object
[ "Custom", "CURL", "settings" ]
bfe8b95b0c32a58e9619224e9fd61a5026a2021f
https://github.com/gidlov/copycat/blob/bfe8b95b0c32a58e9619224e9fd61a5026a2021f/src/Gidlov/Copycat/Copycat.php#L176-L182
222,570
gidlov/copycat
src/Gidlov/Copycat/Copycat.php
Copycat._getURLs
protected function _getURLs() { if ($this->_post) { $this->_sendPost(); } if ($this->_fill_urls) { $this->_getFillURLs(); } if (is_array($this->_urls) == false OR count($this->_urls) < 1) { return false; } foreach ($this->_urls as $name => $url) { $this->_setHTML($url); $this->_getMatch($name); $this->_getMatchAll($name); } }
php
protected function _getURLs() { if ($this->_post) { $this->_sendPost(); } if ($this->_fill_urls) { $this->_getFillURLs(); } if (is_array($this->_urls) == false OR count($this->_urls) < 1) { return false; } foreach ($this->_urls as $name => $url) { $this->_setHTML($url); $this->_getMatch($name); $this->_getMatchAll($name); } }
[ "protected", "function", "_getURLs", "(", ")", "{", "if", "(", "$", "this", "->", "_post", ")", "{", "$", "this", "->", "_sendPost", "(", ")", ";", "}", "if", "(", "$", "this", "->", "_fill_urls", ")", "{", "$", "this", "->", "_getFillURLs", "(", ")", ";", "}", "if", "(", "is_array", "(", "$", "this", "->", "_urls", ")", "==", "false", "OR", "count", "(", "$", "this", "->", "_urls", ")", "<", "1", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "this", "->", "_urls", "as", "$", "name", "=>", "$", "url", ")", "{", "$", "this", "->", "_setHTML", "(", "$", "url", ")", ";", "$", "this", "->", "_getMatch", "(", "$", "name", ")", ";", "$", "this", "->", "_getMatchAll", "(", "$", "name", ")", ";", "}", "}" ]
Starts the process to load pages and saves the matching results.
[ "Starts", "the", "process", "to", "load", "pages", "and", "saves", "the", "matching", "results", "." ]
bfe8b95b0c32a58e9619224e9fd61a5026a2021f
https://github.com/gidlov/copycat/blob/bfe8b95b0c32a58e9619224e9fd61a5026a2021f/src/Gidlov/Copycat/Copycat.php#L288-L303
222,571
gidlov/copycat
src/Gidlov/Copycat/Copycat.php
Copycat._getMatch
protected function _getMatch($key = 0) { foreach ($this->_regex['match'] as $name => $regex) { if (is_array($regex)) { $this->_setFile($name, $regex, $key, 1, $name); } else { $match = $this->_filter($regex, $this->_html, 1, $name); $this->_output[$key][$name] = $match; } } }
php
protected function _getMatch($key = 0) { foreach ($this->_regex['match'] as $name => $regex) { if (is_array($regex)) { $this->_setFile($name, $regex, $key, 1, $name); } else { $match = $this->_filter($regex, $this->_html, 1, $name); $this->_output[$key][$name] = $match; } } }
[ "protected", "function", "_getMatch", "(", "$", "key", "=", "0", ")", "{", "foreach", "(", "$", "this", "->", "_regex", "[", "'match'", "]", "as", "$", "name", "=>", "$", "regex", ")", "{", "if", "(", "is_array", "(", "$", "regex", ")", ")", "{", "$", "this", "->", "_setFile", "(", "$", "name", ",", "$", "regex", ",", "$", "key", ",", "1", ",", "$", "name", ")", ";", "}", "else", "{", "$", "match", "=", "$", "this", "->", "_filter", "(", "$", "regex", ",", "$", "this", "->", "_html", ",", "1", ",", "$", "name", ")", ";", "$", "this", "->", "_output", "[", "$", "key", "]", "[", "$", "name", "]", "=", "$", "match", ";", "}", "}", "}" ]
Find and save the results of the current page. @param string $key
[ "Find", "and", "save", "the", "results", "of", "the", "current", "page", "." ]
bfe8b95b0c32a58e9619224e9fd61a5026a2021f
https://github.com/gidlov/copycat/blob/bfe8b95b0c32a58e9619224e9fd61a5026a2021f/src/Gidlov/Copycat/Copycat.php#L310-L319
222,572
gidlov/copycat
src/Gidlov/Copycat/Copycat.php
Copycat._getFillURLs
protected function _getFillURLs() { foreach ($this->_fill_urls['keywords'] as $name => $keyword) { $content = $this->_getCURL($this->_fill_urls['query'] . $keyword); if (isset($this->_fill_urls['to']) && $this->_fill_urls['to'] == 'matches') { $url = $this->_filterAll($this->_fill_urls['regex'], $content, 1); } else { $url = $this->_filter($this->_fill_urls['regex'], $content, 1); } if (isset($url)) { if (! is_integer($name)) { $this->_urls[$name] = $url; } else { $this->_urls[] = $url; } } } }
php
protected function _getFillURLs() { foreach ($this->_fill_urls['keywords'] as $name => $keyword) { $content = $this->_getCURL($this->_fill_urls['query'] . $keyword); if (isset($this->_fill_urls['to']) && $this->_fill_urls['to'] == 'matches') { $url = $this->_filterAll($this->_fill_urls['regex'], $content, 1); } else { $url = $this->_filter($this->_fill_urls['regex'], $content, 1); } if (isset($url)) { if (! is_integer($name)) { $this->_urls[$name] = $url; } else { $this->_urls[] = $url; } } } }
[ "protected", "function", "_getFillURLs", "(", ")", "{", "foreach", "(", "$", "this", "->", "_fill_urls", "[", "'keywords'", "]", "as", "$", "name", "=>", "$", "keyword", ")", "{", "$", "content", "=", "$", "this", "->", "_getCURL", "(", "$", "this", "->", "_fill_urls", "[", "'query'", "]", ".", "$", "keyword", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_fill_urls", "[", "'to'", "]", ")", "&&", "$", "this", "->", "_fill_urls", "[", "'to'", "]", "==", "'matches'", ")", "{", "$", "url", "=", "$", "this", "->", "_filterAll", "(", "$", "this", "->", "_fill_urls", "[", "'regex'", "]", ",", "$", "content", ",", "1", ")", ";", "}", "else", "{", "$", "url", "=", "$", "this", "->", "_filter", "(", "$", "this", "->", "_fill_urls", "[", "'regex'", "]", ",", "$", "content", ",", "1", ")", ";", "}", "if", "(", "isset", "(", "$", "url", ")", ")", "{", "if", "(", "!", "is_integer", "(", "$", "name", ")", ")", "{", "$", "this", "->", "_urls", "[", "$", "name", "]", "=", "$", "url", ";", "}", "else", "{", "$", "this", "->", "_urls", "[", "]", "=", "$", "url", ";", "}", "}", "}", "}" ]
Get the URL from eg. a search engine.
[ "Get", "the", "URL", "from", "eg", ".", "a", "search", "engine", "." ]
bfe8b95b0c32a58e9619224e9fd61a5026a2021f
https://github.com/gidlov/copycat/blob/bfe8b95b0c32a58e9619224e9fd61a5026a2021f/src/Gidlov/Copycat/Copycat.php#L378-L394
222,573
gidlov/copycat
src/Gidlov/Copycat/Copycat.php
Copycat._getCURL
protected function _getCURL($url) { curl_setopt($this->_curl, CURLOPT_URL, $url); $content = curl_exec($this->_curl); return $content; }
php
protected function _getCURL($url) { curl_setopt($this->_curl, CURLOPT_URL, $url); $content = curl_exec($this->_curl); return $content; }
[ "protected", "function", "_getCURL", "(", "$", "url", ")", "{", "curl_setopt", "(", "$", "this", "->", "_curl", ",", "CURLOPT_URL", ",", "$", "url", ")", ";", "$", "content", "=", "curl_exec", "(", "$", "this", "->", "_curl", ")", ";", "return", "$", "content", ";", "}" ]
Load the data from the URL. @param string $url @return string
[ "Load", "the", "data", "from", "the", "URL", "." ]
bfe8b95b0c32a58e9619224e9fd61a5026a2021f
https://github.com/gidlov/copycat/blob/bfe8b95b0c32a58e9619224e9fd61a5026a2021f/src/Gidlov/Copycat/Copycat.php#L402-L406
222,574
gidlov/copycat
src/Gidlov/Copycat/Copycat.php
Copycat._filterAll
protected function _filterAll($regex, $content, $i = 1, $key = '') { if (@preg_match_all($regex, $content, $matches) === false) { return false; } $result = isset($matches[$i]) ? $matches[$i] : $matches[0]; if (isset($this->_callback['_all_'])) { foreach ($this->_callback['_all_'] as $filter) { $result = array_map($filter, $result); } } if ($key != '' && isset($this->_callback[$key])) { foreach ($this->_callback[$key] as $filter) { $result = array_map($filter, $result); } } return $result; }
php
protected function _filterAll($regex, $content, $i = 1, $key = '') { if (@preg_match_all($regex, $content, $matches) === false) { return false; } $result = isset($matches[$i]) ? $matches[$i] : $matches[0]; if (isset($this->_callback['_all_'])) { foreach ($this->_callback['_all_'] as $filter) { $result = array_map($filter, $result); } } if ($key != '' && isset($this->_callback[$key])) { foreach ($this->_callback[$key] as $filter) { $result = array_map($filter, $result); } } return $result; }
[ "protected", "function", "_filterAll", "(", "$", "regex", ",", "$", "content", ",", "$", "i", "=", "1", ",", "$", "key", "=", "''", ")", "{", "if", "(", "@", "preg_match_all", "(", "$", "regex", ",", "$", "content", ",", "$", "matches", ")", "===", "false", ")", "{", "return", "false", ";", "}", "$", "result", "=", "isset", "(", "$", "matches", "[", "$", "i", "]", ")", "?", "$", "matches", "[", "$", "i", "]", ":", "$", "matches", "[", "0", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "_callback", "[", "'_all_'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "_callback", "[", "'_all_'", "]", "as", "$", "filter", ")", "{", "$", "result", "=", "array_map", "(", "$", "filter", ",", "$", "result", ")", ";", "}", "}", "if", "(", "$", "key", "!=", "''", "&&", "isset", "(", "$", "this", "->", "_callback", "[", "$", "key", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "_callback", "[", "$", "key", "]", "as", "$", "filter", ")", "{", "$", "result", "=", "array_map", "(", "$", "filter", ",", "$", "result", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Apply the regular expression to the content and return all matches. @param string $regex @param string $content @param int $i @return array
[ "Apply", "the", "regular", "expression", "to", "the", "content", "and", "return", "all", "matches", "." ]
bfe8b95b0c32a58e9619224e9fd61a5026a2021f
https://github.com/gidlov/copycat/blob/bfe8b95b0c32a58e9619224e9fd61a5026a2021f/src/Gidlov/Copycat/Copycat.php#L416-L432
222,575
gidlov/copycat
src/Gidlov/Copycat/Copycat.php
Copycat._filter
protected function _filter($regex, $content, $i = 1, $key = '') { if (@preg_match($regex, $content, $match) == 1) { $result = isset($match[$i]) ? $match[$i] : $match[0]; if (isset($this->_callback['_all_'])) { foreach ($this->_callback['_all_'] as $filter) { $result = call_user_func($filter, $result); } } if ($key != '' && isset($this->_callback[$key])) { foreach ($this->_callback[$key] as $filter) { $result = call_user_func($filter, $result); } } return $result; } return false; }
php
protected function _filter($regex, $content, $i = 1, $key = '') { if (@preg_match($regex, $content, $match) == 1) { $result = isset($match[$i]) ? $match[$i] : $match[0]; if (isset($this->_callback['_all_'])) { foreach ($this->_callback['_all_'] as $filter) { $result = call_user_func($filter, $result); } } if ($key != '' && isset($this->_callback[$key])) { foreach ($this->_callback[$key] as $filter) { $result = call_user_func($filter, $result); } } return $result; } return false; }
[ "protected", "function", "_filter", "(", "$", "regex", ",", "$", "content", ",", "$", "i", "=", "1", ",", "$", "key", "=", "''", ")", "{", "if", "(", "@", "preg_match", "(", "$", "regex", ",", "$", "content", ",", "$", "match", ")", "==", "1", ")", "{", "$", "result", "=", "isset", "(", "$", "match", "[", "$", "i", "]", ")", "?", "$", "match", "[", "$", "i", "]", ":", "$", "match", "[", "0", "]", ";", "if", "(", "isset", "(", "$", "this", "->", "_callback", "[", "'_all_'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "_callback", "[", "'_all_'", "]", "as", "$", "filter", ")", "{", "$", "result", "=", "call_user_func", "(", "$", "filter", ",", "$", "result", ")", ";", "}", "}", "if", "(", "$", "key", "!=", "''", "&&", "isset", "(", "$", "this", "->", "_callback", "[", "$", "key", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "_callback", "[", "$", "key", "]", "as", "$", "filter", ")", "{", "$", "result", "=", "call_user_func", "(", "$", "filter", ",", "$", "result", ")", ";", "}", "}", "return", "$", "result", ";", "}", "return", "false", ";", "}" ]
Apply the regular expression to the content and return first match. @param string $regex @param string $content @param int $i @return array
[ "Apply", "the", "regular", "expression", "to", "the", "content", "and", "return", "first", "match", "." ]
bfe8b95b0c32a58e9619224e9fd61a5026a2021f
https://github.com/gidlov/copycat/blob/bfe8b95b0c32a58e9619224e9fd61a5026a2021f/src/Gidlov/Copycat/Copycat.php#L442-L458
222,576
dmmlabo/dmm-php-sdk
src/Dmm/Apis/Series.php
Series.find
public function find($floor_id, array $params = []) { if (!is_integer($floor_id) && !is_numeric($floor_id)) { throw new DmmSDKException('a correct floor id must be set when call Series API.'); } $params['floor_id'] = $floor_id; return $this->get("/SeriesSearch", $params); }
php
public function find($floor_id, array $params = []) { if (!is_integer($floor_id) && !is_numeric($floor_id)) { throw new DmmSDKException('a correct floor id must be set when call Series API.'); } $params['floor_id'] = $floor_id; return $this->get("/SeriesSearch", $params); }
[ "public", "function", "find", "(", "$", "floor_id", ",", "array", "$", "params", "=", "[", "]", ")", "{", "if", "(", "!", "is_integer", "(", "$", "floor_id", ")", "&&", "!", "is_numeric", "(", "$", "floor_id", ")", ")", "{", "throw", "new", "DmmSDKException", "(", "'a correct floor id must be set when call Series API.'", ")", ";", "}", "$", "params", "[", "'floor_id'", "]", "=", "$", "floor_id", ";", "return", "$", "this", "->", "get", "(", "\"/SeriesSearch\"", ",", "$", "params", ")", ";", "}" ]
Sends a request to Series API and returns the result. @param integer|string $floor_id @param array $params @return DmmResponse @throws DmmSDKException
[ "Sends", "a", "request", "to", "Series", "API", "and", "returns", "the", "result", "." ]
027fbe8fbf07178460e449ede116f9eae91061eb
https://github.com/dmmlabo/dmm-php-sdk/blob/027fbe8fbf07178460e449ede116f9eae91061eb/src/Dmm/Apis/Series.php#L21-L30
222,577
zackslash/PHP-Web-Article-Extractor
src/HTMLParser.php
HTMLParser.getActionForTag
function getActionForTag($tag) { $tag = strtoupper($tag); // Ignorable elements foreach($this->ignoreElements->resourceContent as $ignoreElement) { if ($ignoreElement === $tag) { return 0; } } // Link elements foreach($this->linkElements->resourceContent as $linkElement) { if ($linkElement === $tag) { return 1; } } // Body elements foreach($this->bodyElements->resourceContent as $bodyElement) { if ($bodyElement === $tag) { return 2; } } // Inline elements foreach($this->inlineElements->resourceContent as $inlineElement) { if ($inlineElement === $tag) { return 3; } } return -1; }
php
function getActionForTag($tag) { $tag = strtoupper($tag); // Ignorable elements foreach($this->ignoreElements->resourceContent as $ignoreElement) { if ($ignoreElement === $tag) { return 0; } } // Link elements foreach($this->linkElements->resourceContent as $linkElement) { if ($linkElement === $tag) { return 1; } } // Body elements foreach($this->bodyElements->resourceContent as $bodyElement) { if ($bodyElement === $tag) { return 2; } } // Inline elements foreach($this->inlineElements->resourceContent as $inlineElement) { if ($inlineElement === $tag) { return 3; } } return -1; }
[ "function", "getActionForTag", "(", "$", "tag", ")", "{", "$", "tag", "=", "strtoupper", "(", "$", "tag", ")", ";", "// Ignorable elements", "foreach", "(", "$", "this", "->", "ignoreElements", "->", "resourceContent", "as", "$", "ignoreElement", ")", "{", "if", "(", "$", "ignoreElement", "===", "$", "tag", ")", "{", "return", "0", ";", "}", "}", "// Link elements", "foreach", "(", "$", "this", "->", "linkElements", "->", "resourceContent", "as", "$", "linkElement", ")", "{", "if", "(", "$", "linkElement", "===", "$", "tag", ")", "{", "return", "1", ";", "}", "}", "// Body elements", "foreach", "(", "$", "this", "->", "bodyElements", "->", "resourceContent", "as", "$", "bodyElement", ")", "{", "if", "(", "$", "bodyElement", "===", "$", "tag", ")", "{", "return", "2", ";", "}", "}", "// Inline elements", "foreach", "(", "$", "this", "->", "inlineElements", "->", "resourceContent", "as", "$", "inlineElement", ")", "{", "if", "(", "$", "inlineElement", "===", "$", "tag", ")", "{", "return", "3", ";", "}", "}", "return", "-", "1", ";", "}" ]
Returns the applicable action for a given HTML tag @param string $url the URL to extract an article from @return int action enumeration 0 = Element should be ignored 1 = Element should be treated as a link 2 = Element should be treated as HTML body 3 = Element should be treated as inline text
[ "Returns", "the", "applicable", "action", "for", "a", "given", "HTML", "tag" ]
f93d25d588dc0f8ddc4572429288edddb69386f6
https://github.com/zackslash/PHP-Web-Article-Extractor/blob/f93d25d588dc0f8ddc4572429288edddb69386f6/src/HTMLParser.php#L64-L105
222,578
zackslash/PHP-Web-Article-Extractor
src/HTMLParser.php
HTMLParser.parse
function parse($html) { $dom = new \DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html); $xpath = new \DOMXPath($dom); // Load resources for tag actions $this->ignoreElements = new ResourceProvider("html_tag_actions/ignore.lst"); $this->linkElements = new ResourceProvider("html_tag_actions/link.lst"); $this->bodyElements = new ResourceProvider("html_tag_actions/body.lst"); $this->inlineElements = new ResourceProvider("html_tag_actions/inline.lst"); /* * 1st retrieve page title * With this technique: only process the entire document here * as meta is excluded as 'content' and only required for initial title. */ // Extract title from DOM $body = $xpath->query('/')->item(0); $titleItem = $xpath->query('//title')->item(0); if(isset($titleItem)) { $title = $titleItem->textContent; } $body = $xpath->query('//body')->item(0); // Try to extract title from OG meta foreach ($xpath->query("//meta[@property='og:title']") as $el) { $title = $el->getAttribute("content"); } $this->recurse($body); $Article = new Article(); if(isset($title)) { $Article->title = $title; } $Article->textBlocks = $this->textBlocks; return $Article; }
php
function parse($html) { $dom = new \DOMDocument(); libxml_use_internal_errors(true); $dom->loadHTML($html); $xpath = new \DOMXPath($dom); // Load resources for tag actions $this->ignoreElements = new ResourceProvider("html_tag_actions/ignore.lst"); $this->linkElements = new ResourceProvider("html_tag_actions/link.lst"); $this->bodyElements = new ResourceProvider("html_tag_actions/body.lst"); $this->inlineElements = new ResourceProvider("html_tag_actions/inline.lst"); /* * 1st retrieve page title * With this technique: only process the entire document here * as meta is excluded as 'content' and only required for initial title. */ // Extract title from DOM $body = $xpath->query('/')->item(0); $titleItem = $xpath->query('//title')->item(0); if(isset($titleItem)) { $title = $titleItem->textContent; } $body = $xpath->query('//body')->item(0); // Try to extract title from OG meta foreach ($xpath->query("//meta[@property='og:title']") as $el) { $title = $el->getAttribute("content"); } $this->recurse($body); $Article = new Article(); if(isset($title)) { $Article->title = $title; } $Article->textBlocks = $this->textBlocks; return $Article; }
[ "function", "parse", "(", "$", "html", ")", "{", "$", "dom", "=", "new", "\\", "DOMDocument", "(", ")", ";", "libxml_use_internal_errors", "(", "true", ")", ";", "$", "dom", "->", "loadHTML", "(", "$", "html", ")", ";", "$", "xpath", "=", "new", "\\", "DOMXPath", "(", "$", "dom", ")", ";", "// Load resources for tag actions", "$", "this", "->", "ignoreElements", "=", "new", "ResourceProvider", "(", "\"html_tag_actions/ignore.lst\"", ")", ";", "$", "this", "->", "linkElements", "=", "new", "ResourceProvider", "(", "\"html_tag_actions/link.lst\"", ")", ";", "$", "this", "->", "bodyElements", "=", "new", "ResourceProvider", "(", "\"html_tag_actions/body.lst\"", ")", ";", "$", "this", "->", "inlineElements", "=", "new", "ResourceProvider", "(", "\"html_tag_actions/inline.lst\"", ")", ";", "/*\t\n\t\t\t * 1st retrieve page title\n\t\t\t * With this technique: only process the entire document here \n\t\t\t * as meta is excluded as 'content' and only required for initial title.\n\t\t\t */", "// Extract title from DOM", "$", "body", "=", "$", "xpath", "->", "query", "(", "'/'", ")", "->", "item", "(", "0", ")", ";", "$", "titleItem", "=", "$", "xpath", "->", "query", "(", "'//title'", ")", "->", "item", "(", "0", ")", ";", "if", "(", "isset", "(", "$", "titleItem", ")", ")", "{", "$", "title", "=", "$", "titleItem", "->", "textContent", ";", "}", "$", "body", "=", "$", "xpath", "->", "query", "(", "'//body'", ")", "->", "item", "(", "0", ")", ";", "// Try to extract title from OG meta", "foreach", "(", "$", "xpath", "->", "query", "(", "\"//meta[@property='og:title']\"", ")", "as", "$", "el", ")", "{", "$", "title", "=", "$", "el", "->", "getAttribute", "(", "\"content\"", ")", ";", "}", "$", "this", "->", "recurse", "(", "$", "body", ")", ";", "$", "Article", "=", "new", "Article", "(", ")", ";", "if", "(", "isset", "(", "$", "title", ")", ")", "{", "$", "Article", "->", "title", "=", "$", "title", ";", "}", "$", "Article", "->", "textBlocks", "=", "$", "this", "->", "textBlocks", ";", "return", "$", "Article", ";", "}" ]
Begins traversal of the HTML document @param string $url the raw HTML to extract an article from @return Article parsed HTML now in Article form
[ "Begins", "traversal", "of", "the", "HTML", "document" ]
f93d25d588dc0f8ddc4572429288edddb69386f6
https://github.com/zackslash/PHP-Web-Article-Extractor/blob/f93d25d588dc0f8ddc4572429288edddb69386f6/src/HTMLParser.php#L113-L156
222,579
apioo/psx-schema
src/Parser/Popo/ObjectReader.php
ObjectReader.getProperties
public static function getProperties(Reader $reader, ReflectionClass $class) { $props = $class->getProperties(); $result = []; foreach ($props as $property) { // skip statics if ($property->isStatic()) { continue; } // check whether we have an exclude annotation $exclude = $reader->getPropertyAnnotation($property, Annotation\Exclude::class); if ($exclude !== null) { continue; } // get the property name $key = $reader->getPropertyAnnotation($property, Annotation\Key::class); $name = null; if ($key !== null) { $name = $key->getKey(); } if (empty($name)) { $name = $property->getName(); } $result[$name] = $property; } return $result; }
php
public static function getProperties(Reader $reader, ReflectionClass $class) { $props = $class->getProperties(); $result = []; foreach ($props as $property) { // skip statics if ($property->isStatic()) { continue; } // check whether we have an exclude annotation $exclude = $reader->getPropertyAnnotation($property, Annotation\Exclude::class); if ($exclude !== null) { continue; } // get the property name $key = $reader->getPropertyAnnotation($property, Annotation\Key::class); $name = null; if ($key !== null) { $name = $key->getKey(); } if (empty($name)) { $name = $property->getName(); } $result[$name] = $property; } return $result; }
[ "public", "static", "function", "getProperties", "(", "Reader", "$", "reader", ",", "ReflectionClass", "$", "class", ")", "{", "$", "props", "=", "$", "class", "->", "getProperties", "(", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "props", "as", "$", "property", ")", "{", "// skip statics", "if", "(", "$", "property", "->", "isStatic", "(", ")", ")", "{", "continue", ";", "}", "// check whether we have an exclude annotation", "$", "exclude", "=", "$", "reader", "->", "getPropertyAnnotation", "(", "$", "property", ",", "Annotation", "\\", "Exclude", "::", "class", ")", ";", "if", "(", "$", "exclude", "!==", "null", ")", "{", "continue", ";", "}", "// get the property name", "$", "key", "=", "$", "reader", "->", "getPropertyAnnotation", "(", "$", "property", ",", "Annotation", "\\", "Key", "::", "class", ")", ";", "$", "name", "=", "null", ";", "if", "(", "$", "key", "!==", "null", ")", "{", "$", "name", "=", "$", "key", "->", "getKey", "(", ")", ";", "}", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "$", "name", "=", "$", "property", "->", "getName", "(", ")", ";", "}", "$", "result", "[", "$", "name", "]", "=", "$", "property", ";", "}", "return", "$", "result", ";", "}" ]
Returns all available properties of an object @param \Doctrine\Common\Annotations\Reader $reader @param \ReflectionClass $class @return \ReflectionProperty[]
[ "Returns", "all", "available", "properties", "of", "an", "object" ]
b06eebe847364c4b57e2447cd04be8eb75044947
https://github.com/apioo/psx-schema/blob/b06eebe847364c4b57e2447cd04be8eb75044947/src/Parser/Popo/ObjectReader.php#L42-L75
222,580
apioo/psx-schema
src/Validation/Validator.php
Validator.getField
protected function getField($name) { $name = ltrim($name, '/'); foreach ($this->fields as $field) { if (preg_match('#^' . ltrim($field->getName(), '/') . '$#', $name)) { return $field; } } return null; }
php
protected function getField($name) { $name = ltrim($name, '/'); foreach ($this->fields as $field) { if (preg_match('#^' . ltrim($field->getName(), '/') . '$#', $name)) { return $field; } } return null; }
[ "protected", "function", "getField", "(", "$", "name", ")", "{", "$", "name", "=", "ltrim", "(", "$", "name", ",", "'/'", ")", ";", "foreach", "(", "$", "this", "->", "fields", "as", "$", "field", ")", "{", "if", "(", "preg_match", "(", "'#^'", ".", "ltrim", "(", "$", "field", "->", "getName", "(", ")", ",", "'/'", ")", ".", "'$#'", ",", "$", "name", ")", ")", "{", "return", "$", "field", ";", "}", "}", "return", "null", ";", "}" ]
Returns the property defined by the name @param string $name @return \PSX\Schema\Validation\Field|null
[ "Returns", "the", "property", "defined", "by", "the", "name" ]
b06eebe847364c4b57e2447cd04be8eb75044947
https://github.com/apioo/psx-schema/blob/b06eebe847364c4b57e2447cd04be8eb75044947/src/Validation/Validator.php#L103-L114
222,581
dmmlabo/dmm-php-sdk
src/Dmm/DmmClient.php
DmmClient.detectHttpClientHandler
public function detectHttpClientHandler() { $handler = null; if (class_exists('GuzzleHttp\Client')) { $handler = new GuzzleHttpClient(); } elseif (function_exists('curl_init')) { $handler = new CurlHttpClient(); } else { $handler = new StreamHttpClient(); } return $handler; }
php
public function detectHttpClientHandler() { $handler = null; if (class_exists('GuzzleHttp\Client')) { $handler = new GuzzleHttpClient(); } elseif (function_exists('curl_init')) { $handler = new CurlHttpClient(); } else { $handler = new StreamHttpClient(); } return $handler; }
[ "public", "function", "detectHttpClientHandler", "(", ")", "{", "$", "handler", "=", "null", ";", "if", "(", "class_exists", "(", "'GuzzleHttp\\Client'", ")", ")", "{", "$", "handler", "=", "new", "GuzzleHttpClient", "(", ")", ";", "}", "elseif", "(", "function_exists", "(", "'curl_init'", ")", ")", "{", "$", "handler", "=", "new", "CurlHttpClient", "(", ")", ";", "}", "else", "{", "$", "handler", "=", "new", "StreamHttpClient", "(", ")", ";", "}", "return", "$", "handler", ";", "}" ]
Detects which HTTP client handler to use. @return HttpClientInterface
[ "Detects", "which", "HTTP", "client", "handler", "to", "use", "." ]
027fbe8fbf07178460e449ede116f9eae91061eb
https://github.com/dmmlabo/dmm-php-sdk/blob/027fbe8fbf07178460e449ede116f9eae91061eb/src/Dmm/DmmClient.php#L72-L83
222,582
dmmlabo/dmm-php-sdk
src/Dmm/DmmClient.php
DmmClient.sendRequest
public function sendRequest(DmmRequest $request) { if (get_class($request) === 'Dmm\DmmRequest') { $request->validateCredentials(); } list($url, $method, $headers, $body) = $this->prepareRequestMessage($request); // Since file uploads can take a while, we need to give more time for uploads $timeOut = static::DEFAULT_REQUEST_TIMEOUT; // Should throw `DmmSDKException` exception on HTTP client error. // Don't catch to allow it to bubble up. $rawResponse = $this->httpClientHandler->send($url, $method, $body, $headers, $timeOut); static::$requestCount++; $returnResponse = new DmmResponse( $request, $rawResponse->getBody(), $rawResponse->getHttpResponseCode(), $rawResponse->getHeaders() ); if ($returnResponse->isError()) { throw $returnResponse->getThrownException(); } return $returnResponse; }
php
public function sendRequest(DmmRequest $request) { if (get_class($request) === 'Dmm\DmmRequest') { $request->validateCredentials(); } list($url, $method, $headers, $body) = $this->prepareRequestMessage($request); // Since file uploads can take a while, we need to give more time for uploads $timeOut = static::DEFAULT_REQUEST_TIMEOUT; // Should throw `DmmSDKException` exception on HTTP client error. // Don't catch to allow it to bubble up. $rawResponse = $this->httpClientHandler->send($url, $method, $body, $headers, $timeOut); static::$requestCount++; $returnResponse = new DmmResponse( $request, $rawResponse->getBody(), $rawResponse->getHttpResponseCode(), $rawResponse->getHeaders() ); if ($returnResponse->isError()) { throw $returnResponse->getThrownException(); } return $returnResponse; }
[ "public", "function", "sendRequest", "(", "DmmRequest", "$", "request", ")", "{", "if", "(", "get_class", "(", "$", "request", ")", "===", "'Dmm\\DmmRequest'", ")", "{", "$", "request", "->", "validateCredentials", "(", ")", ";", "}", "list", "(", "$", "url", ",", "$", "method", ",", "$", "headers", ",", "$", "body", ")", "=", "$", "this", "->", "prepareRequestMessage", "(", "$", "request", ")", ";", "// Since file uploads can take a while, we need to give more time for uploads", "$", "timeOut", "=", "static", "::", "DEFAULT_REQUEST_TIMEOUT", ";", "// Should throw `DmmSDKException` exception on HTTP client error.", "// Don't catch to allow it to bubble up.", "$", "rawResponse", "=", "$", "this", "->", "httpClientHandler", "->", "send", "(", "$", "url", ",", "$", "method", ",", "$", "body", ",", "$", "headers", ",", "$", "timeOut", ")", ";", "static", "::", "$", "requestCount", "++", ";", "$", "returnResponse", "=", "new", "DmmResponse", "(", "$", "request", ",", "$", "rawResponse", "->", "getBody", "(", ")", ",", "$", "rawResponse", "->", "getHttpResponseCode", "(", ")", ",", "$", "rawResponse", "->", "getHeaders", "(", ")", ")", ";", "if", "(", "$", "returnResponse", "->", "isError", "(", ")", ")", "{", "throw", "$", "returnResponse", "->", "getThrownException", "(", ")", ";", "}", "return", "$", "returnResponse", ";", "}" ]
Makes the request to API and returns the result. @param DmmRequest $request @return DmmResponse @throws DmmSDKException
[ "Makes", "the", "request", "to", "API", "and", "returns", "the", "result", "." ]
027fbe8fbf07178460e449ede116f9eae91061eb
https://github.com/dmmlabo/dmm-php-sdk/blob/027fbe8fbf07178460e449ede116f9eae91061eb/src/Dmm/DmmClient.php#L129-L158
222,583
tabacitu/crud
src/CrudTrait.php
CrudTrait.addFakes
public function addFakes($columns = ['extras']) { foreach ($columns as $key => $column) { $column_contents = $this->{$column}; if (!is_object($this->{$column})) { $column_contents = json_decode($this->{$column}); } if (count($column_contents)) { foreach ($column_contents as $fake_field_name => $fake_field_value) { $this->setAttribute($fake_field_name, $fake_field_value); } } } }
php
public function addFakes($columns = ['extras']) { foreach ($columns as $key => $column) { $column_contents = $this->{$column}; if (!is_object($this->{$column})) { $column_contents = json_decode($this->{$column}); } if (count($column_contents)) { foreach ($column_contents as $fake_field_name => $fake_field_value) { $this->setAttribute($fake_field_name, $fake_field_value); } } } }
[ "public", "function", "addFakes", "(", "$", "columns", "=", "[", "'extras'", "]", ")", "{", "foreach", "(", "$", "columns", "as", "$", "key", "=>", "$", "column", ")", "{", "$", "column_contents", "=", "$", "this", "->", "{", "$", "column", "}", ";", "if", "(", "!", "is_object", "(", "$", "this", "->", "{", "$", "column", "}", ")", ")", "{", "$", "column_contents", "=", "json_decode", "(", "$", "this", "->", "{", "$", "column", "}", ")", ";", "}", "if", "(", "count", "(", "$", "column_contents", ")", ")", "{", "foreach", "(", "$", "column_contents", "as", "$", "fake_field_name", "=>", "$", "fake_field_value", ")", "{", "$", "this", "->", "setAttribute", "(", "$", "fake_field_name", ",", "$", "fake_field_value", ")", ";", "}", "}", "}", "}" ]
Add fake fields as regular attributes, even though they are stored as JSON. @param array $columns - the database columns that contain the JSONs @return -
[ "Add", "fake", "fields", "as", "regular", "attributes", "even", "though", "they", "are", "stored", "as", "JSON", "." ]
1236e1a51e75b86d48967272064b0f90c62568ad
https://github.com/tabacitu/crud/blob/1236e1a51e75b86d48967272064b0f90c62568ad/src/CrudTrait.php#L49-L66
222,584
tabacitu/crud
src/CrudTrait.php
CrudTrait.withFakes
public function withFakes($columns = []) { $model = '\\'.get_class($this); if (!count($columns)) { if (property_exists($model, 'fakeColumns')) { $columns = $this->fakeColumns; } else { $columns = ['extras']; } } $this->addFakes($columns); return $this; }
php
public function withFakes($columns = []) { $model = '\\'.get_class($this); if (!count($columns)) { if (property_exists($model, 'fakeColumns')) { $columns = $this->fakeColumns; } else { $columns = ['extras']; } } $this->addFakes($columns); return $this; }
[ "public", "function", "withFakes", "(", "$", "columns", "=", "[", "]", ")", "{", "$", "model", "=", "'\\\\'", ".", "get_class", "(", "$", "this", ")", ";", "if", "(", "!", "count", "(", "$", "columns", ")", ")", "{", "if", "(", "property_exists", "(", "$", "model", ",", "'fakeColumns'", ")", ")", "{", "$", "columns", "=", "$", "this", "->", "fakeColumns", ";", "}", "else", "{", "$", "columns", "=", "[", "'extras'", "]", ";", "}", "}", "$", "this", "->", "addFakes", "(", "$", "columns", ")", ";", "return", "$", "this", ";", "}" ]
Return the entity with fake fields as attributes. @param array $columns - the database columns that contain the JSONs @return obj
[ "Return", "the", "entity", "with", "fake", "fields", "as", "attributes", "." ]
1236e1a51e75b86d48967272064b0f90c62568ad
https://github.com/tabacitu/crud/blob/1236e1a51e75b86d48967272064b0f90c62568ad/src/CrudTrait.php#L74-L91
222,585
tabacitu/crud
src/CrudTrait.php
CrudTrait.allTranslations
public function allTranslations() { $model = '\\'.get_class($this); // the translations $translations = $this->translations(); $all_translations = new Collection(); // the original if ($this->translation_of) { $original = $model::find($this->translation_of); $all_translations = $all_translations->push($original); // get all translations from the original $translationsOfOriginal = $model::where('translation_of', $original->id)->get(); foreach($translationsOfOriginal as $translation) { $all_translations->push($translation); } } else { // prepend the translation to be first in the list of translations $all_translations = $translations->prepend($this); } return $all_translations; }
php
public function allTranslations() { $model = '\\'.get_class($this); // the translations $translations = $this->translations(); $all_translations = new Collection(); // the original if ($this->translation_of) { $original = $model::find($this->translation_of); $all_translations = $all_translations->push($original); // get all translations from the original $translationsOfOriginal = $model::where('translation_of', $original->id)->get(); foreach($translationsOfOriginal as $translation) { $all_translations->push($translation); } } else { // prepend the translation to be first in the list of translations $all_translations = $translations->prepend($this); } return $all_translations; }
[ "public", "function", "allTranslations", "(", ")", "{", "$", "model", "=", "'\\\\'", ".", "get_class", "(", "$", "this", ")", ";", "// the translations", "$", "translations", "=", "$", "this", "->", "translations", "(", ")", ";", "$", "all_translations", "=", "new", "Collection", "(", ")", ";", "// the original", "if", "(", "$", "this", "->", "translation_of", ")", "{", "$", "original", "=", "$", "model", "::", "find", "(", "$", "this", "->", "translation_of", ")", ";", "$", "all_translations", "=", "$", "all_translations", "->", "push", "(", "$", "original", ")", ";", "// get all translations from the original", "$", "translationsOfOriginal", "=", "$", "model", "::", "where", "(", "'translation_of'", ",", "$", "original", "->", "id", ")", "->", "get", "(", ")", ";", "foreach", "(", "$", "translationsOfOriginal", "as", "$", "translation", ")", "{", "$", "all_translations", "->", "push", "(", "$", "translation", ")", ";", "}", "}", "else", "{", "// prepend the translation to be first in the list of translations", "$", "all_translations", "=", "$", "translations", "->", "prepend", "(", "$", "this", ")", ";", "}", "return", "$", "all_translations", ";", "}" ]
get translations plus current item, plus original
[ "get", "translations", "plus", "current", "item", "plus", "original" ]
1236e1a51e75b86d48967272064b0f90c62568ad
https://github.com/tabacitu/crud/blob/1236e1a51e75b86d48967272064b0f90c62568ad/src/CrudTrait.php#L112-L136
222,586
apioo/psx-schema
src/Parser/JsonSchema/Document.php
Document.pointer
public function pointer($pointer) { $pointer = new Pointer($pointer); $data = $pointer->evaluate($this->data); if ($data !== null) { return $data; } else { throw new RuntimeException('Could not resolve pointer ' . $pointer->getPath()); } }
php
public function pointer($pointer) { $pointer = new Pointer($pointer); $data = $pointer->evaluate($this->data); if ($data !== null) { return $data; } else { throw new RuntimeException('Could not resolve pointer ' . $pointer->getPath()); } }
[ "public", "function", "pointer", "(", "$", "pointer", ")", "{", "$", "pointer", "=", "new", "Pointer", "(", "$", "pointer", ")", ";", "$", "data", "=", "$", "pointer", "->", "evaluate", "(", "$", "this", "->", "data", ")", ";", "if", "(", "$", "data", "!==", "null", ")", "{", "return", "$", "data", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "'Could not resolve pointer '", ".", "$", "pointer", "->", "getPath", "(", ")", ")", ";", "}", "}" ]
Resolves a json pointer on the document and returns the fitting array fragment. Throws an exception if the pointer could not be resolved @param string $pointer @return array
[ "Resolves", "a", "json", "pointer", "on", "the", "document", "and", "returns", "the", "fitting", "array", "fragment", ".", "Throws", "an", "exception", "if", "the", "pointer", "could", "not", "be", "resolved" ]
b06eebe847364c4b57e2447cd04be8eb75044947
https://github.com/apioo/psx-schema/blob/b06eebe847364c4b57e2447cd04be8eb75044947/src/Parser/JsonSchema/Document.php#L139-L149
222,587
zackslash/PHP-Web-Article-Extractor
src/Extract.php
Extract.extractFromURL
public static function extractFromURL($url) { $html = file_get_contents($url); if($html === FALSE) { return; } return self::extractFromHTML($html, $url); }
php
public static function extractFromURL($url) { $html = file_get_contents($url); if($html === FALSE) { return; } return self::extractFromHTML($html, $url); }
[ "public", "static", "function", "extractFromURL", "(", "$", "url", ")", "{", "$", "html", "=", "file_get_contents", "(", "$", "url", ")", ";", "if", "(", "$", "html", "===", "FALSE", ")", "{", "return", ";", "}", "return", "self", "::", "extractFromHTML", "(", "$", "html", ",", "$", "url", ")", ";", "}" ]
Extracts an article directly from a URL @param string $url the URL to extract an article from @return Article extraction result
[ "Extracts", "an", "article", "directly", "from", "a", "URL" ]
f93d25d588dc0f8ddc4572429288edddb69386f6
https://github.com/zackslash/PHP-Web-Article-Extractor/blob/f93d25d588dc0f8ddc4572429288edddb69386f6/src/Extract.php#L23-L33
222,588
zackslash/PHP-Web-Article-Extractor
src/Extract.php
Extract.extractFromHTML
public static function extractFromHTML($rawHTMLPage, $source = "") { $parser = new HTMLParser(); // Parse HTML into blocks $article = $parser->parse($rawHTMLPage); // Filter out clean article title Filters\TitleFilter::filter($article); // Discover article 'end' points using syntactic terminators Filters\EndBlockFilter::filter($article); // Filter content using word count and link density using algorithm from Machine learning Filters\NumberOfWordsFilter::filter($article); // Filter blocks that come after content Filters\PostcontentFilter::filter($article); // Merge close blocks Mergers\CloseBlockMerger::merge($article); // Remove blocks that are not content Filters\NonContentFilter::filter($article); // Mark largest block as 'content' Filters\LargestBlockFilter::filter($article); // Mark blocks found between the title and main content as content as well Filters\BetweenTitleAndContentFilter::filter($article); // Post-extraction cleanup removing now irrelevant blocks and sets full title Filters\PostextractionFilter::filter($article); // Scans article line by line removing non-content on a per-line basis Filters\LineFilter::filter($article); // Determine document language Filters\LanguageFilter::filter($article); // Filter keywords from the article document Filters\KeywordFilter::filter($article); $article->source = $source; return $article; }
php
public static function extractFromHTML($rawHTMLPage, $source = "") { $parser = new HTMLParser(); // Parse HTML into blocks $article = $parser->parse($rawHTMLPage); // Filter out clean article title Filters\TitleFilter::filter($article); // Discover article 'end' points using syntactic terminators Filters\EndBlockFilter::filter($article); // Filter content using word count and link density using algorithm from Machine learning Filters\NumberOfWordsFilter::filter($article); // Filter blocks that come after content Filters\PostcontentFilter::filter($article); // Merge close blocks Mergers\CloseBlockMerger::merge($article); // Remove blocks that are not content Filters\NonContentFilter::filter($article); // Mark largest block as 'content' Filters\LargestBlockFilter::filter($article); // Mark blocks found between the title and main content as content as well Filters\BetweenTitleAndContentFilter::filter($article); // Post-extraction cleanup removing now irrelevant blocks and sets full title Filters\PostextractionFilter::filter($article); // Scans article line by line removing non-content on a per-line basis Filters\LineFilter::filter($article); // Determine document language Filters\LanguageFilter::filter($article); // Filter keywords from the article document Filters\KeywordFilter::filter($article); $article->source = $source; return $article; }
[ "public", "static", "function", "extractFromHTML", "(", "$", "rawHTMLPage", ",", "$", "source", "=", "\"\"", ")", "{", "$", "parser", "=", "new", "HTMLParser", "(", ")", ";", "// Parse HTML into blocks", "$", "article", "=", "$", "parser", "->", "parse", "(", "$", "rawHTMLPage", ")", ";", "// Filter out clean article title", "Filters", "\\", "TitleFilter", "::", "filter", "(", "$", "article", ")", ";", "// Discover article 'end' points using syntactic terminators", "Filters", "\\", "EndBlockFilter", "::", "filter", "(", "$", "article", ")", ";", "// Filter content using word count and link density using algorithm from Machine learning", "Filters", "\\", "NumberOfWordsFilter", "::", "filter", "(", "$", "article", ")", ";", "// Filter blocks that come after content", "Filters", "\\", "PostcontentFilter", "::", "filter", "(", "$", "article", ")", ";", "// Merge close blocks", "Mergers", "\\", "CloseBlockMerger", "::", "merge", "(", "$", "article", ")", ";", "// Remove blocks that are not content", "Filters", "\\", "NonContentFilter", "::", "filter", "(", "$", "article", ")", ";", "// Mark largest block as 'content'", "Filters", "\\", "LargestBlockFilter", "::", "filter", "(", "$", "article", ")", ";", "// Mark blocks found between the title and main content as content as well", "Filters", "\\", "BetweenTitleAndContentFilter", "::", "filter", "(", "$", "article", ")", ";", "// Post-extraction cleanup removing now irrelevant blocks and sets full title", "Filters", "\\", "PostextractionFilter", "::", "filter", "(", "$", "article", ")", ";", "// Scans article line by line removing non-content on a per-line basis", "Filters", "\\", "LineFilter", "::", "filter", "(", "$", "article", ")", ";", "// Determine document language", "Filters", "\\", "LanguageFilter", "::", "filter", "(", "$", "article", ")", ";", "// Filter keywords from the article document", "Filters", "\\", "KeywordFilter", "::", "filter", "(", "$", "article", ")", ";", "$", "article", "->", "source", "=", "$", "source", ";", "return", "$", "article", ";", "}" ]
Extracts an article from HTML @param string $rawHTMLPage the raw HTML from which to extract an article @return Article extraction result
[ "Extracts", "an", "article", "from", "HTML" ]
f93d25d588dc0f8ddc4572429288edddb69386f6
https://github.com/zackslash/PHP-Web-Article-Extractor/blob/f93d25d588dc0f8ddc4572429288edddb69386f6/src/Extract.php#L41-L87
222,589
joomla-framework/form
src/FormHelper.php
FormHelper.loadClass
protected static function loadClass($entity, $type) { if (strpos($type, '.')) { list($prefix, $type) = explode('.', $type); } else { $prefix = 'Joomla'; } $class = ucfirst($prefix) . '\\Form\\' . ucfirst($entity); // If type is complex like modal\foo, do uppercase each term if (strpos($type, '\\')) { $class .= '\\' . StringHelper::ucfirst($type, '\\'); } else { $class .= '\\' . ucfirst($type); } $class .= ucfirst($entity); // Check for all if the class exists. return class_exists($class) ? $class : false; }
php
protected static function loadClass($entity, $type) { if (strpos($type, '.')) { list($prefix, $type) = explode('.', $type); } else { $prefix = 'Joomla'; } $class = ucfirst($prefix) . '\\Form\\' . ucfirst($entity); // If type is complex like modal\foo, do uppercase each term if (strpos($type, '\\')) { $class .= '\\' . StringHelper::ucfirst($type, '\\'); } else { $class .= '\\' . ucfirst($type); } $class .= ucfirst($entity); // Check for all if the class exists. return class_exists($class) ? $class : false; }
[ "protected", "static", "function", "loadClass", "(", "$", "entity", ",", "$", "type", ")", "{", "if", "(", "strpos", "(", "$", "type", ",", "'.'", ")", ")", "{", "list", "(", "$", "prefix", ",", "$", "type", ")", "=", "explode", "(", "'.'", ",", "$", "type", ")", ";", "}", "else", "{", "$", "prefix", "=", "'Joomla'", ";", "}", "$", "class", "=", "ucfirst", "(", "$", "prefix", ")", ".", "'\\\\Form\\\\'", ".", "ucfirst", "(", "$", "entity", ")", ";", "// If type is complex like modal\\foo, do uppercase each term", "if", "(", "strpos", "(", "$", "type", ",", "'\\\\'", ")", ")", "{", "$", "class", ".=", "'\\\\'", ".", "StringHelper", "::", "ucfirst", "(", "$", "type", ",", "'\\\\'", ")", ";", "}", "else", "{", "$", "class", ".=", "'\\\\'", ".", "ucfirst", "(", "$", "type", ")", ";", "}", "$", "class", ".=", "ucfirst", "(", "$", "entity", ")", ";", "// Check for all if the class exists.", "return", "class_exists", "(", "$", "class", ")", "?", "$", "class", ":", "false", ";", "}" ]
Load a class for one of the form's entities of a particular type. Currently, it makes sense to use this method for the "field" and "rule" entities (but you can support more entities in your subclass). @param string $entity One of the form entities (field or rule). @param string $type Type of an entity. @return boolean|string Class name on success or false otherwise. @since 1.0
[ "Load", "a", "class", "for", "one", "of", "the", "form", "s", "entities", "of", "a", "particular", "type", "." ]
3bc5e3bc3c5c8ba5374623785483f7a677bfb012
https://github.com/joomla-framework/form/blob/3bc5e3bc3c5c8ba5374623785483f7a677bfb012/src/FormHelper.php#L86-L113
222,590
dmmlabo/dmm-php-sdk
src/Dmm/DmmRequest.php
DmmRequest.setEndpoint
public function setEndpoint($endpoint) { // Clean the credential information from the endpoint. $filterParams = ['affiliate_id', 'api_id']; $this->endpoint = DmmUrlManipulator::removeParamsFromUrl($endpoint, $filterParams); return $this; }
php
public function setEndpoint($endpoint) { // Clean the credential information from the endpoint. $filterParams = ['affiliate_id', 'api_id']; $this->endpoint = DmmUrlManipulator::removeParamsFromUrl($endpoint, $filterParams); return $this; }
[ "public", "function", "setEndpoint", "(", "$", "endpoint", ")", "{", "// Clean the credential information from the endpoint.", "$", "filterParams", "=", "[", "'affiliate_id'", ",", "'api_id'", "]", ";", "$", "this", "->", "endpoint", "=", "DmmUrlManipulator", "::", "removeParamsFromUrl", "(", "$", "endpoint", ",", "$", "filterParams", ")", ";", "return", "$", "this", ";", "}" ]
Set the endpoint for this request. @param string @return DmmRequest @throws DmmSDKException
[ "Set", "the", "endpoint", "for", "this", "request", "." ]
027fbe8fbf07178460e449ede116f9eae91061eb
https://github.com/dmmlabo/dmm-php-sdk/blob/027fbe8fbf07178460e449ede116f9eae91061eb/src/Dmm/DmmRequest.php#L136-L143
222,591
dmmlabo/dmm-php-sdk
src/Dmm/DmmRequest.php
DmmRequest.getParams
public function getParams() { $params = $this->params; $credential = $this->getCredential(); if ($credential) { $params['affiliate_id'] = $credential->getAffiliateId(); $params['api_id'] = $credential->getApiId(); } return $params; }
php
public function getParams() { $params = $this->params; $credential = $this->getCredential(); if ($credential) { $params['affiliate_id'] = $credential->getAffiliateId(); $params['api_id'] = $credential->getApiId(); } return $params; }
[ "public", "function", "getParams", "(", ")", "{", "$", "params", "=", "$", "this", "->", "params", ";", "$", "credential", "=", "$", "this", "->", "getCredential", "(", ")", ";", "if", "(", "$", "credential", ")", "{", "$", "params", "[", "'affiliate_id'", "]", "=", "$", "credential", "->", "getAffiliateId", "(", ")", ";", "$", "params", "[", "'api_id'", "]", "=", "$", "credential", "->", "getApiId", "(", ")", ";", "}", "return", "$", "params", ";", "}" ]
Generate and return the params for this request. @return array
[ "Generate", "and", "return", "the", "params", "for", "this", "request", "." ]
027fbe8fbf07178460e449ede116f9eae91061eb
https://github.com/dmmlabo/dmm-php-sdk/blob/027fbe8fbf07178460e449ede116f9eae91061eb/src/Dmm/DmmRequest.php#L225-L236
222,592
dmmlabo/dmm-php-sdk
src/Dmm/DmmRequest.php
DmmRequest.getUrl
public function getUrl() { $this->validateMethod(); $endpoint = DmmUrlManipulator::forceSlashPrefix($this->getEndpoint()); $url = $endpoint; if ($this->getMethod() !== 'POST') { $params = $this->getParams(); $url = DmmUrlManipulator::appendParamsToUrl($url, $params); } return $url; }
php
public function getUrl() { $this->validateMethod(); $endpoint = DmmUrlManipulator::forceSlashPrefix($this->getEndpoint()); $url = $endpoint; if ($this->getMethod() !== 'POST') { $params = $this->getParams(); $url = DmmUrlManipulator::appendParamsToUrl($url, $params); } return $url; }
[ "public", "function", "getUrl", "(", ")", "{", "$", "this", "->", "validateMethod", "(", ")", ";", "$", "endpoint", "=", "DmmUrlManipulator", "::", "forceSlashPrefix", "(", "$", "this", "->", "getEndpoint", "(", ")", ")", ";", "$", "url", "=", "$", "endpoint", ";", "if", "(", "$", "this", "->", "getMethod", "(", ")", "!==", "'POST'", ")", "{", "$", "params", "=", "$", "this", "->", "getParams", "(", ")", ";", "$", "url", "=", "DmmUrlManipulator", "::", "appendParamsToUrl", "(", "$", "url", ",", "$", "params", ")", ";", "}", "return", "$", "url", ";", "}" ]
Generate and return the URL for this request. @return string
[ "Generate", "and", "return", "the", "URL", "for", "this", "request", "." ]
027fbe8fbf07178460e449ede116f9eae91061eb
https://github.com/dmmlabo/dmm-php-sdk/blob/027fbe8fbf07178460e449ede116f9eae91061eb/src/Dmm/DmmRequest.php#L257-L271
222,593
sheadawson/silverstripe-blocks
src/model/BlockSet.php
BlockSet.pageTypeOptions
protected function pageTypeOptions() { $pageTypes = []; $classes = ArrayLib::valueKey(SiteTree::page_type_classes()); unset($classes['VirtualPage']); unset($classes['ErrorPage']); unset($classes['RedirectorPage']); foreach ($classes as $pageTypeClass) { $pageTypes[$pageTypeClass] = singleton($pageTypeClass)->i18n_singular_name(); } asort($pageTypes); return $pageTypes; }
php
protected function pageTypeOptions() { $pageTypes = []; $classes = ArrayLib::valueKey(SiteTree::page_type_classes()); unset($classes['VirtualPage']); unset($classes['ErrorPage']); unset($classes['RedirectorPage']); foreach ($classes as $pageTypeClass) { $pageTypes[$pageTypeClass] = singleton($pageTypeClass)->i18n_singular_name(); } asort($pageTypes); return $pageTypes; }
[ "protected", "function", "pageTypeOptions", "(", ")", "{", "$", "pageTypes", "=", "[", "]", ";", "$", "classes", "=", "ArrayLib", "::", "valueKey", "(", "SiteTree", "::", "page_type_classes", "(", ")", ")", ";", "unset", "(", "$", "classes", "[", "'VirtualPage'", "]", ")", ";", "unset", "(", "$", "classes", "[", "'ErrorPage'", "]", ")", ";", "unset", "(", "$", "classes", "[", "'RedirectorPage'", "]", ")", ";", "foreach", "(", "$", "classes", "as", "$", "pageTypeClass", ")", "{", "$", "pageTypes", "[", "$", "pageTypeClass", "]", "=", "singleton", "(", "$", "pageTypeClass", ")", "->", "i18n_singular_name", "(", ")", ";", "}", "asort", "(", "$", "pageTypes", ")", ";", "return", "$", "pageTypes", ";", "}" ]
Returns a sorted array suitable for a dropdown with pagetypes and their translated name. @return array
[ "Returns", "a", "sorted", "array", "suitable", "for", "a", "dropdown", "with", "pagetypes", "and", "their", "translated", "name", "." ]
07b00124ea617f95f436fb98b09d304daf6334e1
https://github.com/sheadawson/silverstripe-blocks/blob/07b00124ea617f95f436fb98b09d304daf6334e1/src/model/BlockSet.php#L111-L124
222,594
sheadawson/silverstripe-blocks
src/model/BlockSet.php
BlockSet.Pages
public function Pages() { $pages = SiteTree::get(); $types = $this->PageTypes->getValue(); if (count($types)) { $pages = $pages->filter('ClassName', $types); } $parents = $this->PageParents()->column('ID'); if (count($parents)) { $pages = $pages->filter('ParentID', $parents); } return $pages; }
php
public function Pages() { $pages = SiteTree::get(); $types = $this->PageTypes->getValue(); if (count($types)) { $pages = $pages->filter('ClassName', $types); } $parents = $this->PageParents()->column('ID'); if (count($parents)) { $pages = $pages->filter('ParentID', $parents); } return $pages; }
[ "public", "function", "Pages", "(", ")", "{", "$", "pages", "=", "SiteTree", "::", "get", "(", ")", ";", "$", "types", "=", "$", "this", "->", "PageTypes", "->", "getValue", "(", ")", ";", "if", "(", "count", "(", "$", "types", ")", ")", "{", "$", "pages", "=", "$", "pages", "->", "filter", "(", "'ClassName'", ",", "$", "types", ")", ";", "}", "$", "parents", "=", "$", "this", "->", "PageParents", "(", ")", "->", "column", "(", "'ID'", ")", ";", "if", "(", "count", "(", "$", "parents", ")", ")", "{", "$", "pages", "=", "$", "pages", "->", "filter", "(", "'ParentID'", ",", "$", "parents", ")", ";", "}", "return", "$", "pages", ";", "}" ]
Returns a list of pages this BlockSet features on. @return DataList
[ "Returns", "a", "list", "of", "pages", "this", "BlockSet", "features", "on", "." ]
07b00124ea617f95f436fb98b09d304daf6334e1
https://github.com/sheadawson/silverstripe-blocks/blob/07b00124ea617f95f436fb98b09d304daf6334e1/src/model/BlockSet.php#L131-L145
222,595
sheadawson/silverstripe-blocks
src/model/Block.php
Block.forTemplate
public function forTemplate() { if ($this->BlockArea) { $template = [$this->class.'_'.$this->BlockArea]; if (SSViewer::hasTemplate($template)) { return $this->renderWith($template); } } return $this->renderWith($this->ClassName, $this->getController()); }
php
public function forTemplate() { if ($this->BlockArea) { $template = [$this->class.'_'.$this->BlockArea]; if (SSViewer::hasTemplate($template)) { return $this->renderWith($template); } } return $this->renderWith($this->ClassName, $this->getController()); }
[ "public", "function", "forTemplate", "(", ")", "{", "if", "(", "$", "this", "->", "BlockArea", ")", "{", "$", "template", "=", "[", "$", "this", "->", "class", ".", "'_'", ".", "$", "this", "->", "BlockArea", "]", ";", "if", "(", "SSViewer", "::", "hasTemplate", "(", "$", "template", ")", ")", "{", "return", "$", "this", "->", "renderWith", "(", "$", "template", ")", ";", "}", "}", "return", "$", "this", "->", "renderWith", "(", "$", "this", "->", "ClassName", ",", "$", "this", "->", "getController", "(", ")", ")", ";", "}" ]
Renders this block with appropriate templates looks for templates that match BlockClassName_AreaName falls back to BlockClassName. @return string
[ "Renders", "this", "block", "with", "appropriate", "templates", "looks", "for", "templates", "that", "match", "BlockClassName_AreaName", "falls", "back", "to", "BlockClassName", "." ]
07b00124ea617f95f436fb98b09d304daf6334e1
https://github.com/sheadawson/silverstripe-blocks/blob/07b00124ea617f95f436fb98b09d304daf6334e1/src/model/Block.php#L242-L253
222,596
sheadawson/silverstripe-blocks
src/model/Block.php
Block.pagesAffectedByChanges
public function pagesAffectedByChanges() { $pages = $this->Pages(); $urls = []; foreach ($pages as $page) { $urls[] = $page->Link(); } return $urls; }
php
public function pagesAffectedByChanges() { $pages = $this->Pages(); $urls = []; foreach ($pages as $page) { $urls[] = $page->Link(); } return $urls; }
[ "public", "function", "pagesAffectedByChanges", "(", ")", "{", "$", "pages", "=", "$", "this", "->", "Pages", "(", ")", ";", "$", "urls", "=", "[", "]", ";", "foreach", "(", "$", "pages", "as", "$", "page", ")", "{", "$", "urls", "[", "]", "=", "$", "page", "->", "Link", "(", ")", ";", "}", "return", "$", "urls", ";", "}" ]
Get a list of URL's to republish when this block changes if using StaticPublisher module.
[ "Get", "a", "list", "of", "URL", "s", "to", "republish", "when", "this", "block", "changes", "if", "using", "StaticPublisher", "module", "." ]
07b00124ea617f95f436fb98b09d304daf6334e1
https://github.com/sheadawson/silverstripe-blocks/blob/07b00124ea617f95f436fb98b09d304daf6334e1/src/model/Block.php#L381-L390
222,597
sheadawson/silverstripe-blocks
src/model/Block.php
Block.isPublishedNice
public function isPublishedNice() { $field = DBBoolean::create('isPublished'); $field->setValue($this->isPublished()); return $field->Nice(); }
php
public function isPublishedNice() { $field = DBBoolean::create('isPublished'); $field->setValue($this->isPublished()); return $field->Nice(); }
[ "public", "function", "isPublishedNice", "(", ")", "{", "$", "field", "=", "DBBoolean", "::", "create", "(", "'isPublished'", ")", ";", "$", "field", "->", "setValue", "(", "$", "this", "->", "isPublished", "(", ")", ")", ";", "return", "$", "field", "->", "Nice", "(", ")", ";", "}" ]
Check if this block has been published. @return bool True if this page has been published.
[ "Check", "if", "this", "block", "has", "been", "published", "." ]
07b00124ea617f95f436fb98b09d304daf6334e1
https://github.com/sheadawson/silverstripe-blocks/blob/07b00124ea617f95f436fb98b09d304daf6334e1/src/model/Block.php#L433-L439
222,598
sheadawson/silverstripe-blocks
src/model/Block.php
Block.CSSClasses
public function CSSClasses($stopAtClass = 'DataObject') { $classes = strtolower(parent::CSSClasses($stopAtClass)); if (!empty($classes) && ($prefix = $this->blockManager->getPrefixDefaultCSSClasses())) { $classes = $prefix.str_replace(' ', " {$prefix}", $classes); } if ($this->blockManager->getUseExtraCSSClasses()) { $classes = $this->ExtraCSSClasses ? $classes." $this->ExtraCSSClasses" : $classes; } return $classes; }
php
public function CSSClasses($stopAtClass = 'DataObject') { $classes = strtolower(parent::CSSClasses($stopAtClass)); if (!empty($classes) && ($prefix = $this->blockManager->getPrefixDefaultCSSClasses())) { $classes = $prefix.str_replace(' ', " {$prefix}", $classes); } if ($this->blockManager->getUseExtraCSSClasses()) { $classes = $this->ExtraCSSClasses ? $classes." $this->ExtraCSSClasses" : $classes; } return $classes; }
[ "public", "function", "CSSClasses", "(", "$", "stopAtClass", "=", "'DataObject'", ")", "{", "$", "classes", "=", "strtolower", "(", "parent", "::", "CSSClasses", "(", "$", "stopAtClass", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "classes", ")", "&&", "(", "$", "prefix", "=", "$", "this", "->", "blockManager", "->", "getPrefixDefaultCSSClasses", "(", ")", ")", ")", "{", "$", "classes", "=", "$", "prefix", ".", "str_replace", "(", "' '", ",", "\" {$prefix}\"", ",", "$", "classes", ")", ";", "}", "if", "(", "$", "this", "->", "blockManager", "->", "getUseExtraCSSClasses", "(", ")", ")", "{", "$", "classes", "=", "$", "this", "->", "ExtraCSSClasses", "?", "$", "classes", ".", "\" $this->ExtraCSSClasses\"", ":", "$", "classes", ";", "}", "return", "$", "classes", ";", "}" ]
CSS Classes to apply to block element in template. @return string $classes
[ "CSS", "Classes", "to", "apply", "to", "block", "element", "in", "template", "." ]
07b00124ea617f95f436fb98b09d304daf6334e1
https://github.com/sheadawson/silverstripe-blocks/blob/07b00124ea617f95f436fb98b09d304daf6334e1/src/model/Block.php#L460-L473
222,599
apioo/psx-schema
src/Parser/JsonSchema/RefResolver.php
RefResolver.extract
public function extract(Document $document, Uri $ref) { $uri = $this->resolver->resolve($document->getBaseUri(), $ref); $doc = $this->getDocument($uri, $document); $result = $doc->pointer($uri->getFragment()); $baseUri = $doc->getBaseUri(); // the extracted fragment gets merged into the root document so we must // resolve all $ref keys to the base uri so that the root document knows // where to find the $ref values array_walk_recursive($result, function (&$item, $key) use ($baseUri) { if ($key == '$ref') { $item = $this->resolver->resolve($baseUri, new Uri($item))->toString(); } }); return $result; }
php
public function extract(Document $document, Uri $ref) { $uri = $this->resolver->resolve($document->getBaseUri(), $ref); $doc = $this->getDocument($uri, $document); $result = $doc->pointer($uri->getFragment()); $baseUri = $doc->getBaseUri(); // the extracted fragment gets merged into the root document so we must // resolve all $ref keys to the base uri so that the root document knows // where to find the $ref values array_walk_recursive($result, function (&$item, $key) use ($baseUri) { if ($key == '$ref') { $item = $this->resolver->resolve($baseUri, new Uri($item))->toString(); } }); return $result; }
[ "public", "function", "extract", "(", "Document", "$", "document", ",", "Uri", "$", "ref", ")", "{", "$", "uri", "=", "$", "this", "->", "resolver", "->", "resolve", "(", "$", "document", "->", "getBaseUri", "(", ")", ",", "$", "ref", ")", ";", "$", "doc", "=", "$", "this", "->", "getDocument", "(", "$", "uri", ",", "$", "document", ")", ";", "$", "result", "=", "$", "doc", "->", "pointer", "(", "$", "uri", "->", "getFragment", "(", ")", ")", ";", "$", "baseUri", "=", "$", "doc", "->", "getBaseUri", "(", ")", ";", "// the extracted fragment gets merged into the root document so we must", "// resolve all $ref keys to the base uri so that the root document knows", "// where to find the $ref values", "array_walk_recursive", "(", "$", "result", ",", "function", "(", "&", "$", "item", ",", "$", "key", ")", "use", "(", "$", "baseUri", ")", "{", "if", "(", "$", "key", "==", "'$ref'", ")", "{", "$", "item", "=", "$", "this", "->", "resolver", "->", "resolve", "(", "$", "baseUri", ",", "new", "Uri", "(", "$", "item", ")", ")", "->", "toString", "(", ")", ";", "}", "}", ")", ";", "return", "$", "result", ";", "}" ]
Extracts an array part from the document @param \PSX\Schema\Parser\JsonSchema\Document $document @param \PSX\Uri\Uri $ref @return array
[ "Extracts", "an", "array", "part", "from", "the", "document" ]
b06eebe847364c4b57e2447cd04be8eb75044947
https://github.com/apioo/psx-schema/blob/b06eebe847364c4b57e2447cd04be8eb75044947/src/Parser/JsonSchema/RefResolver.php#L100-L117