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
237,200
wasabi-cms/core
src/MenuItem.php
MenuItem.icon
public function icon($icon = null) { if ($icon === null) { return $this->_icon; } $this->_icon = $icon; return $this; }
php
public function icon($icon = null) { if ($icon === null) { return $this->_icon; } $this->_icon = $icon; return $this; }
[ "public", "function", "icon", "(", "$", "icon", "=", "null", ")", "{", "if", "(", "$", "icon", "===", "null", ")", "{", "return", "$", "this", "->", "_icon", ";", "}", "$", "this", "->", "_icon", "=", "$", "icon", ";", "return", "$", "this", ";", "}" ]
Get or set the icon class. @param null|string $icon @return MenuItem|string
[ "Get", "or", "set", "the", "icon", "class", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L147-L155
237,201
wasabi-cms/core
src/MenuItem.php
MenuItem.url
public function url($url = null) { if ($url === null) { return $this->_url; } $this->_url = $url; return $this; }
php
public function url($url = null) { if ($url === null) { return $this->_url; } $this->_url = $url; return $this; }
[ "public", "function", "url", "(", "$", "url", "=", "null", ")", "{", "if", "(", "$", "url", "===", "null", ")", "{", "return", "$", "this", "->", "_url", ";", "}", "$", "this", "->", "_url", "=", "$", "url", ";", "return", "$", "this", ";", "}" ]
Get or set the url. @param null|array $url @return MenuItem|array
[ "Get", "or", "set", "the", "url", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L163-L171
237,202
wasabi-cms/core
src/MenuItem.php
MenuItem.parent
public function parent($parent = null) { if ($parent === null) { return $this->_parent; } $this->_parent = $parent; return $this; }
php
public function parent($parent = null) { if ($parent === null) { return $this->_parent; } $this->_parent = $parent; return $this; }
[ "public", "function", "parent", "(", "$", "parent", "=", "null", ")", "{", "if", "(", "$", "parent", "===", "null", ")", "{", "return", "$", "this", "->", "_parent", ";", "}", "$", "this", "->", "_parent", "=", "$", "parent", ";", "return", "$", "this", ";", "}" ]
Get or set the parent menu alias. @param bool|null|string $parent @return MenuItem|bool|string
[ "Get", "or", "set", "the", "parent", "menu", "alias", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L179-L187
237,203
wasabi-cms/core
src/MenuItem.php
MenuItem.matchAction
public function matchAction($matchAction = null) { if ($matchAction === null) { return $this->_matchAction; } $this->_matchAction = $matchAction; return $this; }
php
public function matchAction($matchAction = null) { if ($matchAction === null) { return $this->_matchAction; } $this->_matchAction = $matchAction; return $this; }
[ "public", "function", "matchAction", "(", "$", "matchAction", "=", "null", ")", "{", "if", "(", "$", "matchAction", "===", "null", ")", "{", "return", "$", "this", "->", "_matchAction", ";", "}", "$", "this", "->", "_matchAction", "=", "$", "matchAction", ";", "return", "$", "this", ";", "}" ]
Get or set match action. @param array|bool|null $matchAction @return MenuItem|array|bool
[ "Get", "or", "set", "match", "action", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L195-L203
237,204
wasabi-cms/core
src/MenuItem.php
MenuItem.doNotMatchAction
public function doNotMatchAction(array $action, $reset = false) { if ($reset) { $this->_doNotMatchAction = []; } if (!empty($action)) { $this->_doNotMatchAction[] = $action; } return $this; }
php
public function doNotMatchAction(array $action, $reset = false) { if ($reset) { $this->_doNotMatchAction = []; } if (!empty($action)) { $this->_doNotMatchAction[] = $action; } return $this; }
[ "public", "function", "doNotMatchAction", "(", "array", "$", "action", ",", "$", "reset", "=", "false", ")", "{", "if", "(", "$", "reset", ")", "{", "$", "this", "->", "_doNotMatchAction", "=", "[", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "action", ")", ")", "{", "$", "this", "->", "_doNotMatchAction", "[", "]", "=", "$", "action", ";", "}", "return", "$", "this", ";", "}" ]
Add an action which this menu item should not match for. @param array $action @param bool $reset Whether to reset existing 'doNotMatchAction' entries. @return MenuItem|array
[ "Add", "an", "action", "which", "this", "menu", "item", "should", "not", "match", "for", "." ]
0eadbb64d2fc201bacc63c93814adeca70e08f90
https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/MenuItem.php#L212-L222
237,205
chipaau/support
src/Support/Validation/AbstractValidator.php
AbstractValidator.getRules
public function getRules() { $rules = empty($this->rules) ? $this->rules($this->request, $this->params) : $this->rules; return $this->explodeRules($rules); }
php
public function getRules() { $rules = empty($this->rules) ? $this->rules($this->request, $this->params) : $this->rules; return $this->explodeRules($rules); }
[ "public", "function", "getRules", "(", ")", "{", "$", "rules", "=", "empty", "(", "$", "this", "->", "rules", ")", "?", "$", "this", "->", "rules", "(", "$", "this", "->", "request", ",", "$", "this", "->", "params", ")", ":", "$", "this", "->", "rules", ";", "return", "$", "this", "->", "explodeRules", "(", "$", "rules", ")", ";", "}" ]
get the rules from child class @return array
[ "get", "the", "rules", "from", "child", "class" ]
2fe3673ed2330bd064d37b2f0bac3e02ca110bef
https://github.com/chipaau/support/blob/2fe3673ed2330bd064d37b2f0bac3e02ca110bef/src/Support/Validation/AbstractValidator.php#L147-L151
237,206
chipaau/support
src/Support/Validation/AbstractValidator.php
AbstractValidator.removeRequired
public function removeRequired() { foreach ($this->getRules() as $key => $rules) { $newRules[$key] = preg_grep("/^required/", $rules, PREG_GREP_INVERT); } $this->rules = $newRules; return $this; }
php
public function removeRequired() { foreach ($this->getRules() as $key => $rules) { $newRules[$key] = preg_grep("/^required/", $rules, PREG_GREP_INVERT); } $this->rules = $newRules; return $this; }
[ "public", "function", "removeRequired", "(", ")", "{", "foreach", "(", "$", "this", "->", "getRules", "(", ")", "as", "$", "key", "=>", "$", "rules", ")", "{", "$", "newRules", "[", "$", "key", "]", "=", "preg_grep", "(", "\"/^required/\"", ",", "$", "rules", ",", "PREG_GREP_INVERT", ")", ";", "}", "$", "this", "->", "rules", "=", "$", "newRules", ";", "return", "$", "this", ";", "}" ]
remove required rule from rules function @return array
[ "remove", "required", "rule", "from", "rules", "function" ]
2fe3673ed2330bd064d37b2f0bac3e02ca110bef
https://github.com/chipaau/support/blob/2fe3673ed2330bd064d37b2f0bac3e02ca110bef/src/Support/Validation/AbstractValidator.php#L187-L194
237,207
chipaau/support
src/Support/Validation/AbstractValidator.php
AbstractValidator.getDbValues
public function getDbValues(array $input = [], $mappings = []) { $response = []; foreach ($mappings as $inputKey => $dbValue) { if (is_array($input) && array_get($input, $inputKey) !== null) { $value = array_get($input, $inputKey); if ($value instanceof UploadedFile) { array_set($response, $dbValue, $value); } elseif (is_array($value)) { if (class_exists($mappings[$inputKey]['class'])) { $class = new $mappings[$inputKey]['class']($this->app); foreach ($value as $v) { $response[$mappings[$inputKey]['key']][] = $this->getDbValues($v, $class->mappings()); } } else { array_set($response, $dbValue, $value); } } else { array_set($response, $dbValue, (is_bool($value) ? $value : trim($value))); } } } return $response; }
php
public function getDbValues(array $input = [], $mappings = []) { $response = []; foreach ($mappings as $inputKey => $dbValue) { if (is_array($input) && array_get($input, $inputKey) !== null) { $value = array_get($input, $inputKey); if ($value instanceof UploadedFile) { array_set($response, $dbValue, $value); } elseif (is_array($value)) { if (class_exists($mappings[$inputKey]['class'])) { $class = new $mappings[$inputKey]['class']($this->app); foreach ($value as $v) { $response[$mappings[$inputKey]['key']][] = $this->getDbValues($v, $class->mappings()); } } else { array_set($response, $dbValue, $value); } } else { array_set($response, $dbValue, (is_bool($value) ? $value : trim($value))); } } } return $response; }
[ "public", "function", "getDbValues", "(", "array", "$", "input", "=", "[", "]", ",", "$", "mappings", "=", "[", "]", ")", "{", "$", "response", "=", "[", "]", ";", "foreach", "(", "$", "mappings", "as", "$", "inputKey", "=>", "$", "dbValue", ")", "{", "if", "(", "is_array", "(", "$", "input", ")", "&&", "array_get", "(", "$", "input", ",", "$", "inputKey", ")", "!==", "null", ")", "{", "$", "value", "=", "array_get", "(", "$", "input", ",", "$", "inputKey", ")", ";", "if", "(", "$", "value", "instanceof", "UploadedFile", ")", "{", "array_set", "(", "$", "response", ",", "$", "dbValue", ",", "$", "value", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "if", "(", "class_exists", "(", "$", "mappings", "[", "$", "inputKey", "]", "[", "'class'", "]", ")", ")", "{", "$", "class", "=", "new", "$", "mappings", "[", "$", "inputKey", "]", "[", "'class'", "]", "(", "$", "this", "->", "app", ")", ";", "foreach", "(", "$", "value", "as", "$", "v", ")", "{", "$", "response", "[", "$", "mappings", "[", "$", "inputKey", "]", "[", "'key'", "]", "]", "[", "]", "=", "$", "this", "->", "getDbValues", "(", "$", "v", ",", "$", "class", "->", "mappings", "(", ")", ")", ";", "}", "}", "else", "{", "array_set", "(", "$", "response", ",", "$", "dbValue", ",", "$", "value", ")", ";", "}", "}", "else", "{", "array_set", "(", "$", "response", ",", "$", "dbValue", ",", "(", "is_bool", "(", "$", "value", ")", "?", "$", "value", ":", "trim", "(", "$", "value", ")", ")", ")", ";", "}", "}", "}", "return", "$", "response", ";", "}" ]
conver given array keys to mapper keys @param array $inputs @return array
[ "conver", "given", "array", "keys", "to", "mapper", "keys" ]
2fe3673ed2330bd064d37b2f0bac3e02ca110bef
https://github.com/chipaau/support/blob/2fe3673ed2330bd064d37b2f0bac3e02ca110bef/src/Support/Validation/AbstractValidator.php#L251-L275
237,208
tadcka/Mapper
src/Tadcka/Mapper/Extension/Source/Tree/MapperTree.php
MapperTree.findTreeItem
public function findTreeItem($id, MapperTreeItemInterface $item) { if ($id === $item->getId()) { return $item; } foreach ($item->getChildren() as $child) { if (null !== $treeItem = $this->findTreeItem($id, $child)) { return $treeItem; } } return null; }
php
public function findTreeItem($id, MapperTreeItemInterface $item) { if ($id === $item->getId()) { return $item; } foreach ($item->getChildren() as $child) { if (null !== $treeItem = $this->findTreeItem($id, $child)) { return $treeItem; } } return null; }
[ "public", "function", "findTreeItem", "(", "$", "id", ",", "MapperTreeItemInterface", "$", "item", ")", "{", "if", "(", "$", "id", "===", "$", "item", "->", "getId", "(", ")", ")", "{", "return", "$", "item", ";", "}", "foreach", "(", "$", "item", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "if", "(", "null", "!==", "$", "treeItem", "=", "$", "this", "->", "findTreeItem", "(", "$", "id", ",", "$", "child", ")", ")", "{", "return", "$", "treeItem", ";", "}", "}", "return", "null", ";", "}" ]
Find tree item by id. @param string $id @param MapperTreeItemInterface $item @return null|MapperTreeItemInterface
[ "Find", "tree", "item", "by", "id", "." ]
6853a2be08dcd35a1013c0a4aba9b71a727ff7da
https://github.com/tadcka/Mapper/blob/6853a2be08dcd35a1013c0a4aba9b71a727ff7da/src/Tadcka/Mapper/Extension/Source/Tree/MapperTree.php#L79-L91
237,209
xmlsquad/ping-drive
src/Command/PingDriveCommand.php
PingDriveCommand.getURLData
protected function getURLData(string $driveUrl): array { /* * Known URL types: * https://drive.google.com/file/d/0B5q9i2h-vGaCc1ZBVnFhRzN2a3c/view?ths=true A Word file from Google Drive * https://docs.google.com/document/d/1-phrJPVDf1SpQYU5SzJY00Ke0c6QJmILHrtm_pcQk4w/edit A Google Docs file * https://drive.google.com/drive/u/0/folders/0B5q9i2h-vGaCQXhLZFNLT2JyV0U A Google Drive folder * https://drive.google.com/open?id=0B5q9i2h-vGaCYUE0ZTM4MDhseTQ A Google Drive shared file * https://docs.google.com/spreadsheets/d/13QGip-d_Z88Xru64pEFRyFVDKujDOUjciy35Qytw-Qc/edit A Google Sheets file * https://docs.google.com/presentation/d/1R1oF7zmnSDX3w3FBpyCTJnjvOu68C7Q2MH4kI4xMFWc/edit A Google Slides file */ // Is it a Google Drive|Docs URL? if (preg_match( '~^(https?://)?(drive|docs)\.google\.[a-z]+/.*(/d/|/folders/|[\?&]id=)([a-z0-9\-_]{20,})([/?&#]|$)~i', $driveUrl, $matches )) { // Any Google Drive item can be obtained using a single API method: https://developers.google.com/drive/api/v3/reference/files/get return [ 'type' => 'google-drive', 'id' => $matches[4] ]; } // Is it a URL? if (preg_match('~^(https?://)?[a-z0-9.@\-_\x{0080}-\x{FFFF}]+(:[0-9]+)?(/|$)~iu', $driveUrl, $matches)) { return [ 'type' => 'http', 'driveUrl' => ($matches[1] ? '' : 'http://').$driveUrl ]; } return ['type' => 'unknown']; }
php
protected function getURLData(string $driveUrl): array { /* * Known URL types: * https://drive.google.com/file/d/0B5q9i2h-vGaCc1ZBVnFhRzN2a3c/view?ths=true A Word file from Google Drive * https://docs.google.com/document/d/1-phrJPVDf1SpQYU5SzJY00Ke0c6QJmILHrtm_pcQk4w/edit A Google Docs file * https://drive.google.com/drive/u/0/folders/0B5q9i2h-vGaCQXhLZFNLT2JyV0U A Google Drive folder * https://drive.google.com/open?id=0B5q9i2h-vGaCYUE0ZTM4MDhseTQ A Google Drive shared file * https://docs.google.com/spreadsheets/d/13QGip-d_Z88Xru64pEFRyFVDKujDOUjciy35Qytw-Qc/edit A Google Sheets file * https://docs.google.com/presentation/d/1R1oF7zmnSDX3w3FBpyCTJnjvOu68C7Q2MH4kI4xMFWc/edit A Google Slides file */ // Is it a Google Drive|Docs URL? if (preg_match( '~^(https?://)?(drive|docs)\.google\.[a-z]+/.*(/d/|/folders/|[\?&]id=)([a-z0-9\-_]{20,})([/?&#]|$)~i', $driveUrl, $matches )) { // Any Google Drive item can be obtained using a single API method: https://developers.google.com/drive/api/v3/reference/files/get return [ 'type' => 'google-drive', 'id' => $matches[4] ]; } // Is it a URL? if (preg_match('~^(https?://)?[a-z0-9.@\-_\x{0080}-\x{FFFF}]+(:[0-9]+)?(/|$)~iu', $driveUrl, $matches)) { return [ 'type' => 'http', 'driveUrl' => ($matches[1] ? '' : 'http://').$driveUrl ]; } return ['type' => 'unknown']; }
[ "protected", "function", "getURLData", "(", "string", "$", "driveUrl", ")", ":", "array", "{", "/*\n * Known URL types:\n * https://drive.google.com/file/d/0B5q9i2h-vGaCc1ZBVnFhRzN2a3c/view?ths=true A Word file from Google Drive\n * https://docs.google.com/document/d/1-phrJPVDf1SpQYU5SzJY00Ke0c6QJmILHrtm_pcQk4w/edit A Google Docs file\n * https://drive.google.com/drive/u/0/folders/0B5q9i2h-vGaCQXhLZFNLT2JyV0U A Google Drive folder\n * https://drive.google.com/open?id=0B5q9i2h-vGaCYUE0ZTM4MDhseTQ A Google Drive shared file\n * https://docs.google.com/spreadsheets/d/13QGip-d_Z88Xru64pEFRyFVDKujDOUjciy35Qytw-Qc/edit A Google Sheets file\n * https://docs.google.com/presentation/d/1R1oF7zmnSDX3w3FBpyCTJnjvOu68C7Q2MH4kI4xMFWc/edit A Google Slides file\n */", "// Is it a Google Drive|Docs URL?", "if", "(", "preg_match", "(", "'~^(https?://)?(drive|docs)\\.google\\.[a-z]+/.*(/d/|/folders/|[\\?&]id=)([a-z0-9\\-_]{20,})([/?&#]|$)~i'", ",", "$", "driveUrl", ",", "$", "matches", ")", ")", "{", "// Any Google Drive item can be obtained using a single API method: https://developers.google.com/drive/api/v3/reference/files/get", "return", "[", "'type'", "=>", "'google-drive'", ",", "'id'", "=>", "$", "matches", "[", "4", "]", "]", ";", "}", "// Is it a URL?", "if", "(", "preg_match", "(", "'~^(https?://)?[a-z0-9.@\\-_\\x{0080}-\\x{FFFF}]+(:[0-9]+)?(/|$)~iu'", ",", "$", "driveUrl", ",", "$", "matches", ")", ")", "{", "return", "[", "'type'", "=>", "'http'", ",", "'driveUrl'", "=>", "(", "$", "matches", "[", "1", "]", "?", "''", ":", "'http://'", ")", ".", "$", "driveUrl", "]", ";", "}", "return", "[", "'type'", "=>", "'unknown'", "]", ";", "}" ]
Gets a URL type and data @param string $driveUrl The driveUrl @return array The `type` key contains the type name. Other keys depend on the type.
[ "Gets", "a", "URL", "type", "and", "data" ]
c2e74309f27c88c07f5e0da6b9ed863217d1b5a3
https://github.com/xmlsquad/ping-drive/blob/c2e74309f27c88c07f5e0da6b9ed863217d1b5a3/src/Command/PingDriveCommand.php#L117-L151
237,210
xmlsquad/ping-drive
src/Command/PingDriveCommand.php
PingDriveCommand.writeGoogleDriveFolderData
protected function writeGoogleDriveFolderData( OutputInterface $output, \Google_Service_Drive $drive, \Google_Service_Drive_DriveFile $folder ) { $output->writeln('<info>The URL is a Google Drive folder</info>'); $output->writeln('Name: '.$folder->getName()); $output->writeln('Content:'); $pageToken = null; do { $children = $drive->files->listFiles([ 'pageSize' => 1000, 'pageToken' => $pageToken, 'q' => "'{$folder->getId()}' in parents", 'fields' => 'nextPageToken, files(id,name,mimeType)' ]); foreach ($children as $child) { /** @var \Google_Service_Drive_DriveFile $child */ $output->writeln( ' - A '.($child->getMimeType() === GoogleAPIClient::MIME_TYPE_DRIVE_FOLDER ? 'folder' : 'file') .'. Name: '.$child->getName() ); } $pageToken = $children->getNextPageToken(); } while ($pageToken); }
php
protected function writeGoogleDriveFolderData( OutputInterface $output, \Google_Service_Drive $drive, \Google_Service_Drive_DriveFile $folder ) { $output->writeln('<info>The URL is a Google Drive folder</info>'); $output->writeln('Name: '.$folder->getName()); $output->writeln('Content:'); $pageToken = null; do { $children = $drive->files->listFiles([ 'pageSize' => 1000, 'pageToken' => $pageToken, 'q' => "'{$folder->getId()}' in parents", 'fields' => 'nextPageToken, files(id,name,mimeType)' ]); foreach ($children as $child) { /** @var \Google_Service_Drive_DriveFile $child */ $output->writeln( ' - A '.($child->getMimeType() === GoogleAPIClient::MIME_TYPE_DRIVE_FOLDER ? 'folder' : 'file') .'. Name: '.$child->getName() ); } $pageToken = $children->getNextPageToken(); } while ($pageToken); }
[ "protected", "function", "writeGoogleDriveFolderData", "(", "OutputInterface", "$", "output", ",", "\\", "Google_Service_Drive", "$", "drive", ",", "\\", "Google_Service_Drive_DriveFile", "$", "folder", ")", "{", "$", "output", "->", "writeln", "(", "'<info>The URL is a Google Drive folder</info>'", ")", ";", "$", "output", "->", "writeln", "(", "'Name: '", ".", "$", "folder", "->", "getName", "(", ")", ")", ";", "$", "output", "->", "writeln", "(", "'Content:'", ")", ";", "$", "pageToken", "=", "null", ";", "do", "{", "$", "children", "=", "$", "drive", "->", "files", "->", "listFiles", "(", "[", "'pageSize'", "=>", "1000", ",", "'pageToken'", "=>", "$", "pageToken", ",", "'q'", "=>", "\"'{$folder->getId()}' in parents\"", ",", "'fields'", "=>", "'nextPageToken, files(id,name,mimeType)'", "]", ")", ";", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "/** @var \\Google_Service_Drive_DriveFile $child */", "$", "output", "->", "writeln", "(", "' - A '", ".", "(", "$", "child", "->", "getMimeType", "(", ")", "===", "GoogleAPIClient", "::", "MIME_TYPE_DRIVE_FOLDER", "?", "'folder'", ":", "'file'", ")", ".", "'. Name: '", ".", "$", "child", "->", "getName", "(", ")", ")", ";", "}", "$", "pageToken", "=", "$", "children", "->", "getNextPageToken", "(", ")", ";", "}", "while", "(", "$", "pageToken", ")", ";", "}" ]
Prints a URL ping result as if the result is a Google Drive folder @param OutputInterface $output @param \Google_Service_Drive $drive The Drive API service @param \Google_Service_Drive_DriveFile $folder The folder @link https://stackoverflow.com/a/42055925/1118709
[ "Prints", "a", "URL", "ping", "result", "as", "if", "the", "result", "is", "a", "Google", "Drive", "folder" ]
c2e74309f27c88c07f5e0da6b9ed863217d1b5a3
https://github.com/xmlsquad/ping-drive/blob/c2e74309f27c88c07f5e0da6b9ed863217d1b5a3/src/Command/PingDriveCommand.php#L233-L262
237,211
xmlsquad/ping-drive
src/Command/PingDriveCommand.php
PingDriveCommand.writeGoogleSheetData
protected function writeGoogleSheetData( OutputInterface $output, \Google_Service_Sheets $service, \Google_Service_Drive_DriveFile $spreadsheet ) { $output->writeln('<info>The URL is a Google Sheets file</info>'); $output->writeln('Name: '.$spreadsheet->getName()); // Getting the list of sheets $spreadsheetData = $service->spreadsheets->get($spreadsheet->getId(), [ 'includeGridData' => false ]); $sheetsNames = []; foreach ($spreadsheetData->getSheets() as $sheet) { /** @var \Google_Service_Sheets_Sheet $sheet (the SDK type hint is incorrect) */ $sheetsNames[] = $sheet->getProperties()->getTitle(); } if ($sheetsNames) { $output->writeln('Sheets: '.implode(', ', $sheetsNames)); } else { $output->writeln('The file has no sheets'); return; } // Getting a piece of the first sheet content $spreadsheetData = $service->spreadsheets->get($spreadsheet->getId(), [ 'includeGridData' => true, 'ranges' => ['A1:E5'] // Google returns only the data of the first sheet for this request ]); $output->writeln('A piece of the first sheet content:'); $this->writeGoogleSheetTable($output, $spreadsheetData->getSheets()[0]); }
php
protected function writeGoogleSheetData( OutputInterface $output, \Google_Service_Sheets $service, \Google_Service_Drive_DriveFile $spreadsheet ) { $output->writeln('<info>The URL is a Google Sheets file</info>'); $output->writeln('Name: '.$spreadsheet->getName()); // Getting the list of sheets $spreadsheetData = $service->spreadsheets->get($spreadsheet->getId(), [ 'includeGridData' => false ]); $sheetsNames = []; foreach ($spreadsheetData->getSheets() as $sheet) { /** @var \Google_Service_Sheets_Sheet $sheet (the SDK type hint is incorrect) */ $sheetsNames[] = $sheet->getProperties()->getTitle(); } if ($sheetsNames) { $output->writeln('Sheets: '.implode(', ', $sheetsNames)); } else { $output->writeln('The file has no sheets'); return; } // Getting a piece of the first sheet content $spreadsheetData = $service->spreadsheets->get($spreadsheet->getId(), [ 'includeGridData' => true, 'ranges' => ['A1:E5'] // Google returns only the data of the first sheet for this request ]); $output->writeln('A piece of the first sheet content:'); $this->writeGoogleSheetTable($output, $spreadsheetData->getSheets()[0]); }
[ "protected", "function", "writeGoogleSheetData", "(", "OutputInterface", "$", "output", ",", "\\", "Google_Service_Sheets", "$", "service", ",", "\\", "Google_Service_Drive_DriveFile", "$", "spreadsheet", ")", "{", "$", "output", "->", "writeln", "(", "'<info>The URL is a Google Sheets file</info>'", ")", ";", "$", "output", "->", "writeln", "(", "'Name: '", ".", "$", "spreadsheet", "->", "getName", "(", ")", ")", ";", "// Getting the list of sheets", "$", "spreadsheetData", "=", "$", "service", "->", "spreadsheets", "->", "get", "(", "$", "spreadsheet", "->", "getId", "(", ")", ",", "[", "'includeGridData'", "=>", "false", "]", ")", ";", "$", "sheetsNames", "=", "[", "]", ";", "foreach", "(", "$", "spreadsheetData", "->", "getSheets", "(", ")", "as", "$", "sheet", ")", "{", "/** @var \\Google_Service_Sheets_Sheet $sheet (the SDK type hint is incorrect) */", "$", "sheetsNames", "[", "]", "=", "$", "sheet", "->", "getProperties", "(", ")", "->", "getTitle", "(", ")", ";", "}", "if", "(", "$", "sheetsNames", ")", "{", "$", "output", "->", "writeln", "(", "'Sheets: '", ".", "implode", "(", "', '", ",", "$", "sheetsNames", ")", ")", ";", "}", "else", "{", "$", "output", "->", "writeln", "(", "'The file has no sheets'", ")", ";", "return", ";", "}", "// Getting a piece of the first sheet content", "$", "spreadsheetData", "=", "$", "service", "->", "spreadsheets", "->", "get", "(", "$", "spreadsheet", "->", "getId", "(", ")", ",", "[", "'includeGridData'", "=>", "true", ",", "'ranges'", "=>", "[", "'A1:E5'", "]", "// Google returns only the data of the first sheet for this request", "]", ")", ";", "$", "output", "->", "writeln", "(", "'A piece of the first sheet content:'", ")", ";", "$", "this", "->", "writeGoogleSheetTable", "(", "$", "output", ",", "$", "spreadsheetData", "->", "getSheets", "(", ")", "[", "0", "]", ")", ";", "}" ]
Prints a URL ping result as if the result is a Google Sheets file @param OutputInterface $output @param \Google_Service_Sheets $service The Sheets API service @param \Google_Service_Drive_DriveFile $spreadsheet The file @link https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get
[ "Prints", "a", "URL", "ping", "result", "as", "if", "the", "result", "is", "a", "Google", "Sheets", "file" ]
c2e74309f27c88c07f5e0da6b9ed863217d1b5a3
https://github.com/xmlsquad/ping-drive/blob/c2e74309f27c88c07f5e0da6b9ed863217d1b5a3/src/Command/PingDriveCommand.php#L272-L303
237,212
xmlsquad/ping-drive
src/Command/PingDriveCommand.php
PingDriveCommand.writeGoogleSheetTable
protected function writeGoogleSheetTable(OutputInterface $output, \Google_Service_Sheets_Sheet $sheet) { $table = new Table($output); $merges = $sheet->getMerges(); /** @var \Google_Service_Sheets_GridRange[] $merges (the SDK type hint is incorrect) */ foreach ($sheet->getData()[0]->getRowData() as $rowIndex => $sheetRow) { /** @var \Google_Service_Sheets_RowData $sheetRow */ // TableSeparator is not used here because it is not compatible with rowspan $tableRow = []; foreach ($sheetRow->getValues() as $columnIndex => $sheetCell) { $colspan = $rowspan = 1; /** @var \Google_Service_Sheets_CellData $sheetCell (the SDK type hint is incorrect) */ foreach ($merges as $merge) { // The end indexes are not inclusive if ( $columnIndex >= $merge->getStartColumnIndex() && $columnIndex < $merge->getEndColumnIndex() && $rowIndex >= $merge->getStartRowIndex() && $rowIndex < $merge->getEndRowIndex() ) { if ($columnIndex === $merge->getStartColumnIndex() && $rowIndex === $merge->getStartRowIndex()) { $colspan = $merge->getEndColumnIndex() - $columnIndex; $rowspan = $merge->getEndRowIndex() - $rowIndex; break; } else { continue 2; } } } $tableRow[] = new TableCell((string)$sheetCell->getFormattedValue(), [ 'colspan' => $colspan, 'rowspan' => $rowspan ]); } $table->addRow($tableRow); } $table->render(); }
php
protected function writeGoogleSheetTable(OutputInterface $output, \Google_Service_Sheets_Sheet $sheet) { $table = new Table($output); $merges = $sheet->getMerges(); /** @var \Google_Service_Sheets_GridRange[] $merges (the SDK type hint is incorrect) */ foreach ($sheet->getData()[0]->getRowData() as $rowIndex => $sheetRow) { /** @var \Google_Service_Sheets_RowData $sheetRow */ // TableSeparator is not used here because it is not compatible with rowspan $tableRow = []; foreach ($sheetRow->getValues() as $columnIndex => $sheetCell) { $colspan = $rowspan = 1; /** @var \Google_Service_Sheets_CellData $sheetCell (the SDK type hint is incorrect) */ foreach ($merges as $merge) { // The end indexes are not inclusive if ( $columnIndex >= $merge->getStartColumnIndex() && $columnIndex < $merge->getEndColumnIndex() && $rowIndex >= $merge->getStartRowIndex() && $rowIndex < $merge->getEndRowIndex() ) { if ($columnIndex === $merge->getStartColumnIndex() && $rowIndex === $merge->getStartRowIndex()) { $colspan = $merge->getEndColumnIndex() - $columnIndex; $rowspan = $merge->getEndRowIndex() - $rowIndex; break; } else { continue 2; } } } $tableRow[] = new TableCell((string)$sheetCell->getFormattedValue(), [ 'colspan' => $colspan, 'rowspan' => $rowspan ]); } $table->addRow($tableRow); } $table->render(); }
[ "protected", "function", "writeGoogleSheetTable", "(", "OutputInterface", "$", "output", ",", "\\", "Google_Service_Sheets_Sheet", "$", "sheet", ")", "{", "$", "table", "=", "new", "Table", "(", "$", "output", ")", ";", "$", "merges", "=", "$", "sheet", "->", "getMerges", "(", ")", ";", "/** @var \\Google_Service_Sheets_GridRange[] $merges (the SDK type hint is incorrect) */", "foreach", "(", "$", "sheet", "->", "getData", "(", ")", "[", "0", "]", "->", "getRowData", "(", ")", "as", "$", "rowIndex", "=>", "$", "sheetRow", ")", "{", "/** @var \\Google_Service_Sheets_RowData $sheetRow */", "// TableSeparator is not used here because it is not compatible with rowspan", "$", "tableRow", "=", "[", "]", ";", "foreach", "(", "$", "sheetRow", "->", "getValues", "(", ")", "as", "$", "columnIndex", "=>", "$", "sheetCell", ")", "{", "$", "colspan", "=", "$", "rowspan", "=", "1", ";", "/** @var \\Google_Service_Sheets_CellData $sheetCell (the SDK type hint is incorrect) */", "foreach", "(", "$", "merges", "as", "$", "merge", ")", "{", "// The end indexes are not inclusive", "if", "(", "$", "columnIndex", ">=", "$", "merge", "->", "getStartColumnIndex", "(", ")", "&&", "$", "columnIndex", "<", "$", "merge", "->", "getEndColumnIndex", "(", ")", "&&", "$", "rowIndex", ">=", "$", "merge", "->", "getStartRowIndex", "(", ")", "&&", "$", "rowIndex", "<", "$", "merge", "->", "getEndRowIndex", "(", ")", ")", "{", "if", "(", "$", "columnIndex", "===", "$", "merge", "->", "getStartColumnIndex", "(", ")", "&&", "$", "rowIndex", "===", "$", "merge", "->", "getStartRowIndex", "(", ")", ")", "{", "$", "colspan", "=", "$", "merge", "->", "getEndColumnIndex", "(", ")", "-", "$", "columnIndex", ";", "$", "rowspan", "=", "$", "merge", "->", "getEndRowIndex", "(", ")", "-", "$", "rowIndex", ";", "break", ";", "}", "else", "{", "continue", "2", ";", "}", "}", "}", "$", "tableRow", "[", "]", "=", "new", "TableCell", "(", "(", "string", ")", "$", "sheetCell", "->", "getFormattedValue", "(", ")", ",", "[", "'colspan'", "=>", "$", "colspan", ",", "'rowspan'", "=>", "$", "rowspan", "]", ")", ";", "}", "$", "table", "->", "addRow", "(", "$", "tableRow", ")", ";", "}", "$", "table", "->", "render", "(", ")", ";", "}" ]
Prints a Google Sheet to a console output as a table @param OutputInterface $output @param \Google_Service_Sheets_Sheet $sheet @link http://symfony.com/doc/3.4/components/console/helpers/table.html
[ "Prints", "a", "Google", "Sheet", "to", "a", "console", "output", "as", "a", "table" ]
c2e74309f27c88c07f5e0da6b9ed863217d1b5a3
https://github.com/xmlsquad/ping-drive/blob/c2e74309f27c88c07f5e0da6b9ed863217d1b5a3/src/Command/PingDriveCommand.php#L333-L374
237,213
Talesoft/tale-stream
src/Stream/Iterator/SplitIterator.php
SplitIterator.getIterator
public function getIterator(): \Generator { $line = ''; foreach ($this->readIterator as $content) { $parts = explode($this->delimiter, $content); $partCount = \count($parts); if ($partCount > 1) { foreach ($parts as $i => $part) { if ($i === 0) { yield $line.$part; continue; } if ($i === $partCount - 1) { $line = $part; continue; } yield $part; } continue; } $line .= $content; } yield $line; }
php
public function getIterator(): \Generator { $line = ''; foreach ($this->readIterator as $content) { $parts = explode($this->delimiter, $content); $partCount = \count($parts); if ($partCount > 1) { foreach ($parts as $i => $part) { if ($i === 0) { yield $line.$part; continue; } if ($i === $partCount - 1) { $line = $part; continue; } yield $part; } continue; } $line .= $content; } yield $line; }
[ "public", "function", "getIterator", "(", ")", ":", "\\", "Generator", "{", "$", "line", "=", "''", ";", "foreach", "(", "$", "this", "->", "readIterator", "as", "$", "content", ")", "{", "$", "parts", "=", "explode", "(", "$", "this", "->", "delimiter", ",", "$", "content", ")", ";", "$", "partCount", "=", "\\", "count", "(", "$", "parts", ")", ";", "if", "(", "$", "partCount", ">", "1", ")", "{", "foreach", "(", "$", "parts", "as", "$", "i", "=>", "$", "part", ")", "{", "if", "(", "$", "i", "===", "0", ")", "{", "yield", "$", "line", ".", "$", "part", ";", "continue", ";", "}", "if", "(", "$", "i", "===", "$", "partCount", "-", "1", ")", "{", "$", "line", "=", "$", "part", ";", "continue", ";", "}", "yield", "$", "part", ";", "}", "continue", ";", "}", "$", "line", ".=", "$", "content", ";", "}", "yield", "$", "line", ";", "}" ]
Generates parts of an iterator split by the specified delimiter. @return \Generator|string[]
[ "Generates", "parts", "of", "an", "iterator", "split", "by", "the", "specified", "delimiter", "." ]
13cdaa8cbc2daf833af98c67bf14121ea18c80aa
https://github.com/Talesoft/tale-stream/blob/13cdaa8cbc2daf833af98c67bf14121ea18c80aa/src/Stream/Iterator/SplitIterator.php#L71-L95
237,214
osflab/stream
Html.php
Html.buildHtmlElement
public static function buildHtmlElement($name, array $attributes = [], $content = null, $closeEmptyTag = true, array $cssClasses = []): string { $html = '<' . $name . self::buildAttrs($attributes, $cssClasses); if ($content !== null) { $html .= '>' . $content . '</' . $name . '>'; } else { $html .= $closeEmptyTag ? ' />' : '>'; } return $html; }
php
public static function buildHtmlElement($name, array $attributes = [], $content = null, $closeEmptyTag = true, array $cssClasses = []): string { $html = '<' . $name . self::buildAttrs($attributes, $cssClasses); if ($content !== null) { $html .= '>' . $content . '</' . $name . '>'; } else { $html .= $closeEmptyTag ? ' />' : '>'; } return $html; }
[ "public", "static", "function", "buildHtmlElement", "(", "$", "name", ",", "array", "$", "attributes", "=", "[", "]", ",", "$", "content", "=", "null", ",", "$", "closeEmptyTag", "=", "true", ",", "array", "$", "cssClasses", "=", "[", "]", ")", ":", "string", "{", "$", "html", "=", "'<'", ".", "$", "name", ".", "self", "::", "buildAttrs", "(", "$", "attributes", ",", "$", "cssClasses", ")", ";", "if", "(", "$", "content", "!==", "null", ")", "{", "$", "html", ".=", "'>'", ".", "$", "content", ".", "'</'", ".", "$", "name", ".", "'>'", ";", "}", "else", "{", "$", "html", ".=", "$", "closeEmptyTag", "?", "' />'", ":", "'>'", ";", "}", "return", "$", "html", ";", "}" ]
Build an html element @param string $name @param array $attributes @param string $content @param bool $closeEmptyTag @return string
[ "Build", "an", "html", "element" ]
7cec5e1eb36d20d36c08504580bd163576d68fd9
https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Html.php#L31-L40
237,215
osflab/stream
Html.php
Html.buildHtmlScript
public static function buildHtmlScript($script, array $attributes = []): string { $scriptCleaned = trim($script); if ($scriptCleaned !== '') { return self::buildHtmlElement('script', $attributes, "\n" . $scriptCleaned . "\n"); } return ''; }
php
public static function buildHtmlScript($script, array $attributes = []): string { $scriptCleaned = trim($script); if ($scriptCleaned !== '') { return self::buildHtmlElement('script', $attributes, "\n" . $scriptCleaned . "\n"); } return ''; }
[ "public", "static", "function", "buildHtmlScript", "(", "$", "script", ",", "array", "$", "attributes", "=", "[", "]", ")", ":", "string", "{", "$", "scriptCleaned", "=", "trim", "(", "$", "script", ")", ";", "if", "(", "$", "scriptCleaned", "!==", "''", ")", "{", "return", "self", "::", "buildHtmlElement", "(", "'script'", ",", "$", "attributes", ",", "\"\\n\"", ".", "$", "scriptCleaned", ".", "\"\\n\"", ")", ";", "}", "return", "''", ";", "}" ]
Build an html script element @param mixed $script @param array $attributes @return string
[ "Build", "an", "html", "script", "element" ]
7cec5e1eb36d20d36c08504580bd163576d68fd9
https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Html.php#L69-L76
237,216
osflab/stream
Html.php
Html.toText
public static function toText($html, bool $ignoreErrors = false): string { return (string) (new \Html2Text\Html2Text())->convert((string) $html, $ignoreErrors); }
php
public static function toText($html, bool $ignoreErrors = false): string { return (string) (new \Html2Text\Html2Text())->convert((string) $html, $ignoreErrors); }
[ "public", "static", "function", "toText", "(", "$", "html", ",", "bool", "$", "ignoreErrors", "=", "false", ")", ":", "string", "{", "return", "(", "string", ")", "(", "new", "\\", "Html2Text", "\\", "Html2Text", "(", ")", ")", "->", "convert", "(", "(", "string", ")", "$", "html", ",", "$", "ignoreErrors", ")", ";", "}" ]
Convert html to text using html2text @see https://github.com/soundasleep/html2text @param string $html @return string
[ "Convert", "html", "to", "text", "using", "html2text" ]
7cec5e1eb36d20d36c08504580bd163576d68fd9
https://github.com/osflab/stream/blob/7cec5e1eb36d20d36c08504580bd163576d68fd9/Html.php#L84-L87
237,217
mszewcz/php-light-framework
src/Validator/Specific/Iban.php
Iban.validateIban
private function validateIban(): bool { $value = \substr($this->value, 4).\substr($this->value, 0, 4); $value = \str_replace( ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'], ['10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35'], $value ); $tmp = \intval(\substr($value, 0, 1)); $len = \strlen($value); for ($i = 1; $i < $len; ++$i) { $tmp *= 10; $tmp += \intval(\substr($value, $i, 1)); $tmp %= 97; } $valid = $tmp == 1 ? true : false; if (!$valid) { $this->setError(self::VALIDATOR_ERROR_IBAN_INVALID_NUMBER); } return $valid; }
php
private function validateIban(): bool { $value = \substr($this->value, 4).\substr($this->value, 0, 4); $value = \str_replace( ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'], ['10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35'], $value ); $tmp = \intval(\substr($value, 0, 1)); $len = \strlen($value); for ($i = 1; $i < $len; ++$i) { $tmp *= 10; $tmp += \intval(\substr($value, $i, 1)); $tmp %= 97; } $valid = $tmp == 1 ? true : false; if (!$valid) { $this->setError(self::VALIDATOR_ERROR_IBAN_INVALID_NUMBER); } return $valid; }
[ "private", "function", "validateIban", "(", ")", ":", "bool", "{", "$", "value", "=", "\\", "substr", "(", "$", "this", "->", "value", ",", "4", ")", ".", "\\", "substr", "(", "$", "this", "->", "value", ",", "0", ",", "4", ")", ";", "$", "value", "=", "\\", "str_replace", "(", "[", "'A'", ",", "'B'", ",", "'C'", ",", "'D'", ",", "'E'", ",", "'F'", ",", "'G'", ",", "'H'", ",", "'I'", ",", "'J'", ",", "'K'", ",", "'L'", ",", "'M'", ",", "'N'", ",", "'O'", ",", "'P'", ",", "'Q'", ",", "'R'", ",", "'S'", ",", "'T'", ",", "'U'", ",", "'V'", ",", "'W'", ",", "'X'", ",", "'Y'", ",", "'Z'", "]", ",", "[", "'10'", ",", "'11'", ",", "'12'", ",", "'13'", ",", "'14'", ",", "'15'", ",", "'16'", ",", "'17'", ",", "'18'", ",", "'19'", ",", "'20'", ",", "'21'", ",", "'22'", ",", "'23'", ",", "'24'", ",", "'25'", ",", "'26'", ",", "'27'", ",", "'28'", ",", "'29'", ",", "'30'", ",", "'31'", ",", "'32'", ",", "'33'", ",", "'34'", ",", "'35'", "]", ",", "$", "value", ")", ";", "$", "tmp", "=", "\\", "intval", "(", "\\", "substr", "(", "$", "value", ",", "0", ",", "1", ")", ")", ";", "$", "len", "=", "\\", "strlen", "(", "$", "value", ")", ";", "for", "(", "$", "i", "=", "1", ";", "$", "i", "<", "$", "len", ";", "++", "$", "i", ")", "{", "$", "tmp", "*=", "10", ";", "$", "tmp", "+=", "\\", "intval", "(", "\\", "substr", "(", "$", "value", ",", "$", "i", ",", "1", ")", ")", ";", "$", "tmp", "%=", "97", ";", "}", "$", "valid", "=", "$", "tmp", "==", "1", "?", "true", ":", "false", ";", "if", "(", "!", "$", "valid", ")", "{", "$", "this", "->", "setError", "(", "self", "::", "VALIDATOR_ERROR_IBAN_INVALID_NUMBER", ")", ";", "}", "return", "$", "valid", ";", "}" ]
Validates IBAN number @return bool
[ "Validates", "IBAN", "number" ]
4d3b46781c387202c2dfbdb8760151b3ae8ef49c
https://github.com/mszewcz/php-light-framework/blob/4d3b46781c387202c2dfbdb8760151b3ae8ef49c/src/Validator/Specific/Iban.php#L116-L139
237,218
agalbourdin/agl-core
src/Mysql/Db.php
Db.connect
public function connect($pHost, $pDb, $pUser = NULL, $pPass = NULL) { try { if ($pUser !== NULL and $pPass !== NULL and is_string($pUser) and is_string($pPass)) { $connection = new PDO("mysql:host=$pHost;dbname=$pDb", $pUser, $pPass); } else { $connection = new PDO("mysql:host=$pHost;dbname=$pDb"); } } catch(PDOException $e) { throw new Exception("Unable to establish a connection to MySQL: Host '$pHost', DB '$pDb', User '$pUser', Password '$pPass' with message '" . $e->getMessage() . "'"); } $connection->query("SET NAMES 'utf8';"); return $connection; }
php
public function connect($pHost, $pDb, $pUser = NULL, $pPass = NULL) { try { if ($pUser !== NULL and $pPass !== NULL and is_string($pUser) and is_string($pPass)) { $connection = new PDO("mysql:host=$pHost;dbname=$pDb", $pUser, $pPass); } else { $connection = new PDO("mysql:host=$pHost;dbname=$pDb"); } } catch(PDOException $e) { throw new Exception("Unable to establish a connection to MySQL: Host '$pHost', DB '$pDb', User '$pUser', Password '$pPass' with message '" . $e->getMessage() . "'"); } $connection->query("SET NAMES 'utf8';"); return $connection; }
[ "public", "function", "connect", "(", "$", "pHost", ",", "$", "pDb", ",", "$", "pUser", "=", "NULL", ",", "$", "pPass", "=", "NULL", ")", "{", "try", "{", "if", "(", "$", "pUser", "!==", "NULL", "and", "$", "pPass", "!==", "NULL", "and", "is_string", "(", "$", "pUser", ")", "and", "is_string", "(", "$", "pPass", ")", ")", "{", "$", "connection", "=", "new", "PDO", "(", "\"mysql:host=$pHost;dbname=$pDb\"", ",", "$", "pUser", ",", "$", "pPass", ")", ";", "}", "else", "{", "$", "connection", "=", "new", "PDO", "(", "\"mysql:host=$pHost;dbname=$pDb\"", ")", ";", "}", "}", "catch", "(", "PDOException", "$", "e", ")", "{", "throw", "new", "Exception", "(", "\"Unable to establish a connection to MySQL: Host '$pHost', DB '$pDb', User '$pUser', Password '$pPass' with message '\"", ".", "$", "e", "->", "getMessage", "(", ")", ".", "\"'\"", ")", ";", "}", "$", "connection", "->", "query", "(", "\"SET NAMES 'utf8';\"", ")", ";", "return", "$", "connection", ";", "}" ]
Establish the database connection. @param string $pHost Database host @param string $pDb Database name @param string $pUser Database user @param string $pPass Database password @return PDO
[ "Establish", "the", "database", "connection", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Mysql/Db.php#L53-L68
237,219
agalbourdin/agl-core
src/Mysql/Db.php
Db.listCollections
public function listCollections(array $pWithFields = array()) { $tables = array(); $prepared = $this->getConnection()->prepare('SHOW TABLES FROM `' . $this->_dbName . '`'); if ($prepared->execute()) { while ($row = $prepared->fetchObject()) { $table = str_replace($this->getDbPrefix(), '', current($row)); foreach ($pWithFields as $field) { $preparedJoin = $this->getConnection()->prepare('SHOW COLUMNS FROM `' . current($row) . '` LIKE "' . $field . '"'); $preparedJoin->execute(); if ($preparedJoin->execute() and ! $preparedJoin->rowCount()) { continue 2; } } $tables[] = $table; } } return $tables; }
php
public function listCollections(array $pWithFields = array()) { $tables = array(); $prepared = $this->getConnection()->prepare('SHOW TABLES FROM `' . $this->_dbName . '`'); if ($prepared->execute()) { while ($row = $prepared->fetchObject()) { $table = str_replace($this->getDbPrefix(), '', current($row)); foreach ($pWithFields as $field) { $preparedJoin = $this->getConnection()->prepare('SHOW COLUMNS FROM `' . current($row) . '` LIKE "' . $field . '"'); $preparedJoin->execute(); if ($preparedJoin->execute() and ! $preparedJoin->rowCount()) { continue 2; } } $tables[] = $table; } } return $tables; }
[ "public", "function", "listCollections", "(", "array", "$", "pWithFields", "=", "array", "(", ")", ")", "{", "$", "tables", "=", "array", "(", ")", ";", "$", "prepared", "=", "$", "this", "->", "getConnection", "(", ")", "->", "prepare", "(", "'SHOW TABLES FROM `'", ".", "$", "this", "->", "_dbName", ".", "'`'", ")", ";", "if", "(", "$", "prepared", "->", "execute", "(", ")", ")", "{", "while", "(", "$", "row", "=", "$", "prepared", "->", "fetchObject", "(", ")", ")", "{", "$", "table", "=", "str_replace", "(", "$", "this", "->", "getDbPrefix", "(", ")", ",", "''", ",", "current", "(", "$", "row", ")", ")", ";", "foreach", "(", "$", "pWithFields", "as", "$", "field", ")", "{", "$", "preparedJoin", "=", "$", "this", "->", "getConnection", "(", ")", "->", "prepare", "(", "'SHOW COLUMNS FROM `'", ".", "current", "(", "$", "row", ")", ".", "'` LIKE \"'", ".", "$", "field", ".", "'\"'", ")", ";", "$", "preparedJoin", "->", "execute", "(", ")", ";", "if", "(", "$", "preparedJoin", "->", "execute", "(", ")", "and", "!", "$", "preparedJoin", "->", "rowCount", "(", ")", ")", "{", "continue", "2", ";", "}", "}", "$", "tables", "[", "]", "=", "$", "table", ";", "}", "}", "return", "$", "tables", ";", "}" ]
List all the database's collections. @param array $pWithFields Fields that must exist in collections @return array @todo Test this method with $pWithFields
[ "List", "all", "the", "database", "s", "collections", "." ]
1db556f9a49488aa9fab6887fefb7141a79ad97d
https://github.com/agalbourdin/agl-core/blob/1db556f9a49488aa9fab6887fefb7141a79ad97d/src/Mysql/Db.php#L77-L100
237,220
aufa/Encryption
src/Encryption/Cryptography/Util.php
Util.zeroFill
public static function zeroFill($a, $b) { $z = hexdec(80000000); if ($z & $a) { $a = ($a>>1); $a &= (~$z & 0xffffffff); $a |= 0x40000000; $a = ($a >> ($b-1)); } else { $a = ($a >> $b); } return $a; }
php
public static function zeroFill($a, $b) { $z = hexdec(80000000); if ($z & $a) { $a = ($a>>1); $a &= (~$z & 0xffffffff); $a |= 0x40000000; $a = ($a >> ($b-1)); } else { $a = ($a >> $b); } return $a; }
[ "public", "static", "function", "zeroFill", "(", "$", "a", ",", "$", "b", ")", "{", "$", "z", "=", "hexdec", "(", "80000000", ")", ";", "if", "(", "$", "z", "&", "$", "a", ")", "{", "$", "a", "=", "(", "$", "a", ">>", "1", ")", ";", "$", "a", "&=", "(", "~", "$", "z", "&", "0xffffffff", ")", ";", "$", "a", "|=", "0x40000000", ";", "$", "a", "=", "(", "$", "a", ">>", "(", "$", "b", "-", "1", ")", ")", ";", "}", "else", "{", "$", "a", "=", "(", "$", "a", ">>", "$", "b", ")", ";", "}", "return", "$", "a", ";", "}" ]
Fills the zero values @param int $a @param int $b @return int
[ "Fills", "the", "zero", "values" ]
f5772afed2629e3ad2303ff175a7a29c94e3483d
https://github.com/aufa/Encryption/blob/f5772afed2629e3ad2303ff175a7a29c94e3483d/src/Encryption/Cryptography/Util.php#L32-L44
237,221
aufa/Encryption
src/Encryption/Cryptography/Util.php
Util.str2bin
public static function str2bin($string) { if (is_array($string) || is_object($string)) { $caller = next(debug_backtrace()); $error['line'] = $caller['line']; $error['file'] = strip_tags($caller['file']); trigger_error( "str2bin() expects parameter 1 to be string, " . gettype($string) . " given in <b>{$error['file']}</b> on line <b>{$error['line']}</b><br />\n", E_USER_ERROR ); return ''; } if (strlen($string) <= 0) { return ''; } $string = str_split($string, 1); for ($i = 0, $n = count($string); $i < $n; ++$i) { $string[$i] = decbin(ord($string[$i])); $string[$i] = str_repeat("0", 8 - strlen($string[$i])) . $string[$i]; } return implode("", $string); }
php
public static function str2bin($string) { if (is_array($string) || is_object($string)) { $caller = next(debug_backtrace()); $error['line'] = $caller['line']; $error['file'] = strip_tags($caller['file']); trigger_error( "str2bin() expects parameter 1 to be string, " . gettype($string) . " given in <b>{$error['file']}</b> on line <b>{$error['line']}</b><br />\n", E_USER_ERROR ); return ''; } if (strlen($string) <= 0) { return ''; } $string = str_split($string, 1); for ($i = 0, $n = count($string); $i < $n; ++$i) { $string[$i] = decbin(ord($string[$i])); $string[$i] = str_repeat("0", 8 - strlen($string[$i])) . $string[$i]; } return implode("", $string); }
[ "public", "static", "function", "str2bin", "(", "$", "string", ")", "{", "if", "(", "is_array", "(", "$", "string", ")", "||", "is_object", "(", "$", "string", ")", ")", "{", "$", "caller", "=", "next", "(", "debug_backtrace", "(", ")", ")", ";", "$", "error", "[", "'line'", "]", "=", "$", "caller", "[", "'line'", "]", ";", "$", "error", "[", "'file'", "]", "=", "strip_tags", "(", "$", "caller", "[", "'file'", "]", ")", ";", "trigger_error", "(", "\"str2bin() expects parameter 1 to be string, \"", ".", "gettype", "(", "$", "string", ")", ".", "\" given in <b>{$error['file']}</b> on line <b>{$error['line']}</b><br />\\n\"", ",", "E_USER_ERROR", ")", ";", "return", "''", ";", "}", "if", "(", "strlen", "(", "$", "string", ")", "<=", "0", ")", "{", "return", "''", ";", "}", "$", "string", "=", "str_split", "(", "$", "string", ",", "1", ")", ";", "for", "(", "$", "i", "=", "0", ",", "$", "n", "=", "count", "(", "$", "string", ")", ";", "$", "i", "<", "$", "n", ";", "++", "$", "i", ")", "{", "$", "string", "[", "$", "i", "]", "=", "decbin", "(", "ord", "(", "$", "string", "[", "$", "i", "]", ")", ")", ";", "$", "string", "[", "$", "i", "]", "=", "str_repeat", "(", "\"0\"", ",", "8", "-", "strlen", "(", "$", "string", "[", "$", "i", "]", ")", ")", ".", "$", "string", "[", "$", "i", "]", ";", "}", "return", "implode", "(", "\"\"", ",", "$", "string", ")", ";", "}" ]
Converting string into binary @param string $string the string to convert @return string
[ "Converting", "string", "into", "binary" ]
f5772afed2629e3ad2303ff175a7a29c94e3483d
https://github.com/aufa/Encryption/blob/f5772afed2629e3ad2303ff175a7a29c94e3483d/src/Encryption/Cryptography/Util.php#L57-L84
237,222
aufa/Encryption
src/Encryption/Cryptography/Util.php
Util.bin2str
public static function bin2str($string) { if (is_array($string) || is_object($string)) { $caller = next(debug_backtrace()); $error['line'] = $caller['line']; $error['file'] = strip_tags($caller['file']); trigger_error( "bin2str() expects parameter 1 to be string, " . gettype($string) . " given in <b>{$error['file']}</b> on line <b>{$error['line']}</b><br />\n", E_USER_ERROR ); return ''; } if (strlen($string) <= 0) { return ''; } $string = str_split($string, 8); // NOTE: this function is PHP5 only for ($i = 0, $n = count($string); $i < $n; ++$i) { $string[$i] = chr(bindec($string[$i])); } return implode('', $string); }
php
public static function bin2str($string) { if (is_array($string) || is_object($string)) { $caller = next(debug_backtrace()); $error['line'] = $caller['line']; $error['file'] = strip_tags($caller['file']); trigger_error( "bin2str() expects parameter 1 to be string, " . gettype($string) . " given in <b>{$error['file']}</b> on line <b>{$error['line']}</b><br />\n", E_USER_ERROR ); return ''; } if (strlen($string) <= 0) { return ''; } $string = str_split($string, 8); // NOTE: this function is PHP5 only for ($i = 0, $n = count($string); $i < $n; ++$i) { $string[$i] = chr(bindec($string[$i])); } return implode('', $string); }
[ "public", "static", "function", "bin2str", "(", "$", "string", ")", "{", "if", "(", "is_array", "(", "$", "string", ")", "||", "is_object", "(", "$", "string", ")", ")", "{", "$", "caller", "=", "next", "(", "debug_backtrace", "(", ")", ")", ";", "$", "error", "[", "'line'", "]", "=", "$", "caller", "[", "'line'", "]", ";", "$", "error", "[", "'file'", "]", "=", "strip_tags", "(", "$", "caller", "[", "'file'", "]", ")", ";", "trigger_error", "(", "\"bin2str() expects parameter 1 to be string, \"", ".", "gettype", "(", "$", "string", ")", ".", "\" given in <b>{$error['file']}</b> on line <b>{$error['line']}</b><br />\\n\"", ",", "E_USER_ERROR", ")", ";", "return", "''", ";", "}", "if", "(", "strlen", "(", "$", "string", ")", "<=", "0", ")", "{", "return", "''", ";", "}", "$", "string", "=", "str_split", "(", "$", "string", ",", "8", ")", ";", "// NOTE: this function is PHP5 only", "for", "(", "$", "i", "=", "0", ",", "$", "n", "=", "count", "(", "$", "string", ")", ";", "$", "i", "<", "$", "n", ";", "++", "$", "i", ")", "{", "$", "string", "[", "$", "i", "]", "=", "chr", "(", "bindec", "(", "$", "string", "[", "$", "i", "]", ")", ")", ";", "}", "return", "implode", "(", "''", ",", "$", "string", ")", ";", "}" ]
Converting binary string into normal string @param string $string the string to convert @return string
[ "Converting", "binary", "string", "into", "normal", "string" ]
f5772afed2629e3ad2303ff175a7a29c94e3483d
https://github.com/aufa/Encryption/blob/f5772afed2629e3ad2303ff175a7a29c94e3483d/src/Encryption/Cryptography/Util.php#L92-L118
237,223
aufa/Encryption
src/Encryption/Cryptography/Util.php
Util.byte2intSplit
public static function byte2intSplit($input) { $l = strlen($input); if ($l <= 0) { // right... return 0; } elseif (($l % 4) != 0) { // invalid input return false; } $result = array(); for ($i = 0; $i < $l; $i += 4) { $int_build = (ord($input[$i]) << 24); $int_build += (ord($input[$i+1]) << 16); $int_build += (ord($input[$i+2]) << 8); $int_build += (ord($input[$i+3])); $result[] = $int_build; } return $result; }
php
public static function byte2intSplit($input) { $l = strlen($input); if ($l <= 0) { // right... return 0; } elseif (($l % 4) != 0) { // invalid input return false; } $result = array(); for ($i = 0; $i < $l; $i += 4) { $int_build = (ord($input[$i]) << 24); $int_build += (ord($input[$i+1]) << 16); $int_build += (ord($input[$i+2]) << 8); $int_build += (ord($input[$i+3])); $result[] = $int_build; } return $result; }
[ "public", "static", "function", "byte2intSplit", "(", "$", "input", ")", "{", "$", "l", "=", "strlen", "(", "$", "input", ")", ";", "if", "(", "$", "l", "<=", "0", ")", "{", "// right...", "return", "0", ";", "}", "elseif", "(", "(", "$", "l", "%", "4", ")", "!=", "0", ")", "{", "// invalid input", "return", "false", ";", "}", "$", "result", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "l", ";", "$", "i", "+=", "4", ")", "{", "$", "int_build", "=", "(", "ord", "(", "$", "input", "[", "$", "i", "]", ")", "<<", "24", ")", ";", "$", "int_build", "+=", "(", "ord", "(", "$", "input", "[", "$", "i", "+", "1", "]", ")", "<<", "16", ")", ";", "$", "int_build", "+=", "(", "ord", "(", "$", "input", "[", "$", "i", "+", "2", "]", ")", "<<", "8", ")", ";", "$", "int_build", "+=", "(", "ord", "(", "$", "input", "[", "$", "i", "+", "3", "]", ")", ")", ";", "$", "result", "[", "]", "=", "$", "int_build", ";", "}", "return", "$", "result", ";", "}" ]
split a byte-string into integer array values @param string $input @return array|bool|int
[ "split", "a", "byte", "-", "string", "into", "integer", "array", "values" ]
f5772afed2629e3ad2303ff175a7a29c94e3483d
https://github.com/aufa/Encryption/blob/f5772afed2629e3ad2303ff175a7a29c94e3483d/src/Encryption/Cryptography/Util.php#L127-L147
237,224
ThePHPAvengers/UniApi
src/UniApi/Common/FacadeFactory.php
FacadeFactory.find
public function find() { foreach ($this->getSupportedGateways() as $gateway) { $class = $this->helper-getFacadeClassName($gateway); if (class_exists($class)) { $this->register($gateway); } } ksort($this->gateways); return $this->all(); }
php
public function find() { foreach ($this->getSupportedGateways() as $gateway) { $class = $this->helper-getFacadeClassName($gateway); if (class_exists($class)) { $this->register($gateway); } } ksort($this->gateways); return $this->all(); }
[ "public", "function", "find", "(", ")", "{", "foreach", "(", "$", "this", "->", "getSupportedGateways", "(", ")", "as", "$", "gateway", ")", "{", "$", "class", "=", "$", "this", "->", "helper", "-", "getFacadeClassName", "(", "$", "gateway", ")", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "$", "this", "->", "register", "(", "$", "gateway", ")", ";", "}", "}", "ksort", "(", "$", "this", "->", "gateways", ")", ";", "return", "$", "this", "->", "all", "(", ")", ";", "}" ]
Automatically find and register all officially supported gateways @return array An array of gateway names
[ "Automatically", "find", "and", "register", "all", "officially", "supported", "gateways" ]
e63d79d926cfbaca28860e389c2625aaec81655c
https://github.com/ThePHPAvengers/UniApi/blob/e63d79d926cfbaca28860e389c2625aaec81655c/src/UniApi/Common/FacadeFactory.php#L76-L88
237,225
ThePHPAvengers/UniApi
src/UniApi/Common/FacadeFactory.php
FacadeFactory.create
public function create($className) { $facade = $this->helper->getFacadeClassName($className); if (!class_exists($facade)) { throw new RuntimeException("Class '$facade' not found"); } $className = $this->helper->getSDKClassName($className); return new $facade(new $className($this->httpClient)); }
php
public function create($className) { $facade = $this->helper->getFacadeClassName($className); if (!class_exists($facade)) { throw new RuntimeException("Class '$facade' not found"); } $className = $this->helper->getSDKClassName($className); return new $facade(new $className($this->httpClient)); }
[ "public", "function", "create", "(", "$", "className", ")", "{", "$", "facade", "=", "$", "this", "->", "helper", "->", "getFacadeClassName", "(", "$", "className", ")", ";", "if", "(", "!", "class_exists", "(", "$", "facade", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Class '$facade' not found\"", ")", ";", "}", "$", "className", "=", "$", "this", "->", "helper", "->", "getSDKClassName", "(", "$", "className", ")", ";", "return", "new", "$", "facade", "(", "new", "$", "className", "(", "$", "this", "->", "httpClient", ")", ")", ";", "}" ]
Get the facade for SDK @param $className @return mixed @throws Exception\RuntimeException
[ "Get", "the", "facade", "for", "SDK" ]
e63d79d926cfbaca28860e389c2625aaec81655c
https://github.com/ThePHPAvengers/UniApi/blob/e63d79d926cfbaca28860e389c2625aaec81655c/src/UniApi/Common/FacadeFactory.php#L98-L107
237,226
coolms/jquery
src/Stdlib/AbstractObject.php
AbstractObject.getOption
public function getOption($name) { $method = 'get' . ucfirst($name); if (method_exists($this, $method) && $method !== __FUNCTION__) { return $this->$method(); } elseif (isset($this->options[$name])) { return $this->options[$name]; } }
php
public function getOption($name) { $method = 'get' . ucfirst($name); if (method_exists($this, $method) && $method !== __FUNCTION__) { return $this->$method(); } elseif (isset($this->options[$name])) { return $this->options[$name]; } }
[ "public", "function", "getOption", "(", "$", "name", ")", "{", "$", "method", "=", "'get'", ".", "ucfirst", "(", "$", "name", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", "&&", "$", "method", "!==", "__FUNCTION__", ")", "{", "return", "$", "this", "->", "$", "method", "(", ")", ";", "}", "elseif", "(", "isset", "(", "$", "this", "->", "options", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "options", "[", "$", "name", "]", ";", "}", "}" ]
Get single option @param string $name name of option @return mixed
[ "Get", "single", "option" ]
e7a8b0890d1888b44a03dd6affe55a300cca9c73
https://github.com/coolms/jquery/blob/e7a8b0890d1888b44a03dd6affe55a300cca9c73/src/Stdlib/AbstractObject.php#L97-L105
237,227
coolms/jquery
src/Stdlib/AbstractObject.php
AbstractObject.setOption
public function setOption($name, $value) { $method = 'set' . ucfirst($name); if (method_exists($this, $method) && $method !== __FUNCTION__) { return $this->$method($value); } $this->options[$name] = $value; return $this; }
php
public function setOption($name, $value) { $method = 'set' . ucfirst($name); if (method_exists($this, $method) && $method !== __FUNCTION__) { return $this->$method($value); } $this->options[$name] = $value; return $this; }
[ "public", "function", "setOption", "(", "$", "name", ",", "$", "value", ")", "{", "$", "method", "=", "'set'", ".", "ucfirst", "(", "$", "name", ")", ";", "if", "(", "method_exists", "(", "$", "this", ",", "$", "method", ")", "&&", "$", "method", "!==", "__FUNCTION__", ")", "{", "return", "$", "this", "->", "$", "method", "(", "$", "value", ")", ";", "}", "$", "this", "->", "options", "[", "$", "name", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set single option @param string $name name of option @param mixed $value value of option @return self
[ "Set", "single", "option" ]
e7a8b0890d1888b44a03dd6affe55a300cca9c73
https://github.com/coolms/jquery/blob/e7a8b0890d1888b44a03dd6affe55a300cca9c73/src/Stdlib/AbstractObject.php#L114-L123
237,228
acantepie/CoreBundle
Form/UmbrellaFileType.php
FileUploadTransformer.transform
public function transform($umbrellaFile) { return array( 'file' => null, 'id' => $umbrellaFile ? $umbrellaFile->id : null, 'text' => $umbrellaFile ? $umbrellaFile->name . ' (' . $umbrellaFile->getHumanSize() .')' : null ); }
php
public function transform($umbrellaFile) { return array( 'file' => null, 'id' => $umbrellaFile ? $umbrellaFile->id : null, 'text' => $umbrellaFile ? $umbrellaFile->name . ' (' . $umbrellaFile->getHumanSize() .')' : null ); }
[ "public", "function", "transform", "(", "$", "umbrellaFile", ")", "{", "return", "array", "(", "'file'", "=>", "null", ",", "'id'", "=>", "$", "umbrellaFile", "?", "$", "umbrellaFile", "->", "id", ":", "null", ",", "'text'", "=>", "$", "umbrellaFile", "?", "$", "umbrellaFile", "->", "name", ".", "' ('", ".", "$", "umbrellaFile", "->", "getHumanSize", "(", ")", ".", "')'", ":", "null", ")", ";", "}" ]
Transform UmbrellaFile => array @param UmbrellaFile $umbrellaFile @return array
[ "Transform", "UmbrellaFile", "=", ">", "array" ]
e9f19194b105bfcc10c34ff0763e45436d719782
https://github.com/acantepie/CoreBundle/blob/e9f19194b105bfcc10c34ff0763e45436d719782/Form/UmbrellaFileType.php#L144-L151
237,229
acantepie/CoreBundle
Form/UmbrellaFileType.php
FileUploadTransformer.reverseTransform
public function reverseTransform($array) { $id = ArrayUtils::get($array, 'id', null); $umbrellaFile = $id ? $this->em->getRepository(UmbrellaFile::class)->find($id) : null; $uploadedFile = ArrayUtils::get($array, 'file', null); $delete = ArrayUtils::get($array, 'delete', false); if ($umbrellaFile && $uploadedFile) { // update $this->em->remove($umbrellaFile); return $this->manager->createUmbrellaFile($uploadedFile); } if ($umbrellaFile && $uploadedFile === null && $delete) { // delete $this->em->remove($umbrellaFile); return null; } if ($umbrellaFile === null && $uploadedFile) { // create return $this->manager->createUmbrellaFile($uploadedFile); } // nothing to do return $umbrellaFile; }
php
public function reverseTransform($array) { $id = ArrayUtils::get($array, 'id', null); $umbrellaFile = $id ? $this->em->getRepository(UmbrellaFile::class)->find($id) : null; $uploadedFile = ArrayUtils::get($array, 'file', null); $delete = ArrayUtils::get($array, 'delete', false); if ($umbrellaFile && $uploadedFile) { // update $this->em->remove($umbrellaFile); return $this->manager->createUmbrellaFile($uploadedFile); } if ($umbrellaFile && $uploadedFile === null && $delete) { // delete $this->em->remove($umbrellaFile); return null; } if ($umbrellaFile === null && $uploadedFile) { // create return $this->manager->createUmbrellaFile($uploadedFile); } // nothing to do return $umbrellaFile; }
[ "public", "function", "reverseTransform", "(", "$", "array", ")", "{", "$", "id", "=", "ArrayUtils", "::", "get", "(", "$", "array", ",", "'id'", ",", "null", ")", ";", "$", "umbrellaFile", "=", "$", "id", "?", "$", "this", "->", "em", "->", "getRepository", "(", "UmbrellaFile", "::", "class", ")", "->", "find", "(", "$", "id", ")", ":", "null", ";", "$", "uploadedFile", "=", "ArrayUtils", "::", "get", "(", "$", "array", ",", "'file'", ",", "null", ")", ";", "$", "delete", "=", "ArrayUtils", "::", "get", "(", "$", "array", ",", "'delete'", ",", "false", ")", ";", "if", "(", "$", "umbrellaFile", "&&", "$", "uploadedFile", ")", "{", "// update", "$", "this", "->", "em", "->", "remove", "(", "$", "umbrellaFile", ")", ";", "return", "$", "this", "->", "manager", "->", "createUmbrellaFile", "(", "$", "uploadedFile", ")", ";", "}", "if", "(", "$", "umbrellaFile", "&&", "$", "uploadedFile", "===", "null", "&&", "$", "delete", ")", "{", "// delete", "$", "this", "->", "em", "->", "remove", "(", "$", "umbrellaFile", ")", ";", "return", "null", ";", "}", "if", "(", "$", "umbrellaFile", "===", "null", "&&", "$", "uploadedFile", ")", "{", "// create", "return", "$", "this", "->", "manager", "->", "createUmbrellaFile", "(", "$", "uploadedFile", ")", ";", "}", "// nothing to do", "return", "$", "umbrellaFile", ";", "}" ]
Transform array => UmbrellaFile @param array $array @return UmbrellaFile|null
[ "Transform", "array", "=", ">", "UmbrellaFile" ]
e9f19194b105bfcc10c34ff0763e45436d719782
https://github.com/acantepie/CoreBundle/blob/e9f19194b105bfcc10c34ff0763e45436d719782/Form/UmbrellaFileType.php#L159-L182
237,230
znframework/package-console
Result.php
Result.outputSingleResult
protected function outputSingleResult() { echo $this->line(); echo $this->title(); echo $this->line(); echo $this->content(); echo $this->line(); }
php
protected function outputSingleResult() { echo $this->line(); echo $this->title(); echo $this->line(); echo $this->content(); echo $this->line(); }
[ "protected", "function", "outputSingleResult", "(", ")", "{", "echo", "$", "this", "->", "line", "(", ")", ";", "echo", "$", "this", "->", "title", "(", ")", ";", "echo", "$", "this", "->", "line", "(", ")", ";", "echo", "$", "this", "->", "content", "(", ")", ";", "echo", "$", "this", "->", "line", "(", ")", ";", "}" ]
Protected output single result
[ "Protected", "output", "single", "result" ]
fde428da8b9d926ea4256c235f542e6225c5d788
https://github.com/znframework/package-console/blob/fde428da8b9d926ea4256c235f542e6225c5d788/Result.php#L129-L136
237,231
znframework/package-console
Result.php
Result.outputMultipleResult
protected function outputMultipleResult() { $this->return = $max = max($this->print) . ' '; echo $this->line(); echo $this->title(); echo $this->line(); foreach( $this->print as $key => $ret ) { $diff = strlen($max) - strlen($return = $key . ' | ' . $ret); $this->return = $return . str_repeat(' ', $diff); echo $this->content(); echo $this->line(); } }
php
protected function outputMultipleResult() { $this->return = $max = max($this->print) . ' '; echo $this->line(); echo $this->title(); echo $this->line(); foreach( $this->print as $key => $ret ) { $diff = strlen($max) - strlen($return = $key . ' | ' . $ret); $this->return = $return . str_repeat(' ', $diff); echo $this->content(); echo $this->line(); } }
[ "protected", "function", "outputMultipleResult", "(", ")", "{", "$", "this", "->", "return", "=", "$", "max", "=", "max", "(", "$", "this", "->", "print", ")", ".", "' '", ";", "echo", "$", "this", "->", "line", "(", ")", ";", "echo", "$", "this", "->", "title", "(", ")", ";", "echo", "$", "this", "->", "line", "(", ")", ";", "foreach", "(", "$", "this", "->", "print", "as", "$", "key", "=>", "$", "ret", ")", "{", "$", "diff", "=", "strlen", "(", "$", "max", ")", "-", "strlen", "(", "$", "return", "=", "$", "key", ".", "' | '", ".", "$", "ret", ")", ";", "$", "this", "->", "return", "=", "$", "return", ".", "str_repeat", "(", "' '", ",", "$", "diff", ")", ";", "echo", "$", "this", "->", "content", "(", ")", ";", "echo", "$", "this", "->", "line", "(", ")", ";", "}", "}" ]
Protected output multiple result
[ "Protected", "output", "multiple", "result" ]
fde428da8b9d926ea4256c235f542e6225c5d788
https://github.com/znframework/package-console/blob/fde428da8b9d926ea4256c235f542e6225c5d788/Result.php#L141-L157
237,232
loopsframework/base
src/Loops/ArrayObject.php
ArrayObject.merge
public function merge(ArrayObject $other, $recursive = TRUE) { foreach($other as $key => $value) { if($recursive && $this->offsetExists($key)) { $ownvalue = $this->offsetGet($key); if($ownvalue instanceof ArrayObject && $value instanceof ArrayObject) { $ownvalue->merge($value, TRUE); continue; } } $this->offsetSet($key, $value); } return $this; }
php
public function merge(ArrayObject $other, $recursive = TRUE) { foreach($other as $key => $value) { if($recursive && $this->offsetExists($key)) { $ownvalue = $this->offsetGet($key); if($ownvalue instanceof ArrayObject && $value instanceof ArrayObject) { $ownvalue->merge($value, TRUE); continue; } } $this->offsetSet($key, $value); } return $this; }
[ "public", "function", "merge", "(", "ArrayObject", "$", "other", ",", "$", "recursive", "=", "TRUE", ")", "{", "foreach", "(", "$", "other", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "$", "recursive", "&&", "$", "this", "->", "offsetExists", "(", "$", "key", ")", ")", "{", "$", "ownvalue", "=", "$", "this", "->", "offsetGet", "(", "$", "key", ")", ";", "if", "(", "$", "ownvalue", "instanceof", "ArrayObject", "&&", "$", "value", "instanceof", "ArrayObject", ")", "{", "$", "ownvalue", "->", "merge", "(", "$", "value", ",", "TRUE", ")", ";", "continue", ";", "}", "}", "$", "this", "->", "offsetSet", "(", "$", "key", ",", "$", "value", ")", ";", "}", "return", "$", "this", ";", "}" ]
Merges values from another Loops\ArrayObject into this one by keys @param Loops\ArrayObject $other Merge values from this array object @param bool $recursive Recursively merge values (i.e. if both values are of type Loops\ArrayObject)
[ "Merges", "values", "from", "another", "Loops", "\\", "ArrayObject", "into", "this", "one", "by", "keys" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/ArrayObject.php#L31-L45
237,233
loopsframework/base
src/Loops/ArrayObject.php
ArrayObject.toArray
public function toArray() { $result = iterator_to_array($this); foreach($result as $key => &$value) { if($value instanceof ArrayObject) { $value = $value->toArray(); } } return $result; }
php
public function toArray() { $result = iterator_to_array($this); foreach($result as $key => &$value) { if($value instanceof ArrayObject) { $value = $value->toArray(); } } return $result; }
[ "public", "function", "toArray", "(", ")", "{", "$", "result", "=", "iterator_to_array", "(", "$", "this", ")", ";", "foreach", "(", "$", "result", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "if", "(", "$", "value", "instanceof", "ArrayObject", ")", "{", "$", "value", "=", "$", "value", "->", "toArray", "(", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns the keys and values of this object as a standard array @return array<mixed> The keys and values as an array
[ "Returns", "the", "keys", "and", "values", "of", "this", "object", "as", "a", "standard", "array" ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/ArrayObject.php#L52-L61
237,234
loopsframework/base
src/Loops/ArrayObject.php
ArrayObject.fromArray
public static function fromArray(array $input) { $input = array_map(function($value) { return is_array($value) ? ArrayObject::fromArray($value) : $value; }, $input); return new ArrayObject($input); }
php
public static function fromArray(array $input) { $input = array_map(function($value) { return is_array($value) ? ArrayObject::fromArray($value) : $value; }, $input); return new ArrayObject($input); }
[ "public", "static", "function", "fromArray", "(", "array", "$", "input", ")", "{", "$", "input", "=", "array_map", "(", "function", "(", "$", "value", ")", "{", "return", "is_array", "(", "$", "value", ")", "?", "ArrayObject", "::", "fromArray", "(", "$", "value", ")", ":", "$", "value", ";", "}", ",", "$", "input", ")", ";", "return", "new", "ArrayObject", "(", "$", "input", ")", ";", "}" ]
Creates an "Loops\ArrayObject" from a normal PHP array. Nested arrays will recursively converted. @param array $input The input array @return Loops\ArrayObject The input array as a "Loops\ArrayObject".
[ "Creates", "an", "Loops", "\\", "ArrayObject", "from", "a", "normal", "PHP", "array", ".", "Nested", "arrays", "will", "recursively", "converted", "." ]
5a15172ed4e543d7d5ecd8bd65e31f26bab3d192
https://github.com/loopsframework/base/blob/5a15172ed4e543d7d5ecd8bd65e31f26bab3d192/src/Loops/ArrayObject.php#L70-L76
237,235
bishopb/vanilla
applications/dashboard/settings/class.hooks.php
DashboardHooks.Gdn_Dispatcher_AppStartup_Handler
public function Gdn_Dispatcher_AppStartup_Handler($Sender) { header('P3P: CP="CAO PSA OUR"', TRUE); if (!Gdn::Session()->IsValid() && $SSO = Gdn::Request()->Get('sso')) { SaveToConfig('Garden.Registration.SendConnectEmail', FALSE, FALSE); $UserID = FALSE; try { $UserID = Gdn::UserModel()->SSO($SSO); } catch (Exception $Ex) { Trace($Ex, TRACE_ERROR); } if ($UserID) { Gdn::Session()->Start($UserID, TRUE, TRUE); Gdn::UserModel()->FireEvent('AfterSignIn'); } else { // There was some sort of error. Let's print that out. Trace(Gdn::UserModel()->Validation->ResultsText(), TRACE_WARNING); } } }
php
public function Gdn_Dispatcher_AppStartup_Handler($Sender) { header('P3P: CP="CAO PSA OUR"', TRUE); if (!Gdn::Session()->IsValid() && $SSO = Gdn::Request()->Get('sso')) { SaveToConfig('Garden.Registration.SendConnectEmail', FALSE, FALSE); $UserID = FALSE; try { $UserID = Gdn::UserModel()->SSO($SSO); } catch (Exception $Ex) { Trace($Ex, TRACE_ERROR); } if ($UserID) { Gdn::Session()->Start($UserID, TRUE, TRUE); Gdn::UserModel()->FireEvent('AfterSignIn'); } else { // There was some sort of error. Let's print that out. Trace(Gdn::UserModel()->Validation->ResultsText(), TRACE_WARNING); } } }
[ "public", "function", "Gdn_Dispatcher_AppStartup_Handler", "(", "$", "Sender", ")", "{", "header", "(", "'P3P: CP=\"CAO PSA OUR\"'", ",", "TRUE", ")", ";", "if", "(", "!", "Gdn", "::", "Session", "(", ")", "->", "IsValid", "(", ")", "&&", "$", "SSO", "=", "Gdn", "::", "Request", "(", ")", "->", "Get", "(", "'sso'", ")", ")", "{", "SaveToConfig", "(", "'Garden.Registration.SendConnectEmail'", ",", "FALSE", ",", "FALSE", ")", ";", "$", "UserID", "=", "FALSE", ";", "try", "{", "$", "UserID", "=", "Gdn", "::", "UserModel", "(", ")", "->", "SSO", "(", "$", "SSO", ")", ";", "}", "catch", "(", "Exception", "$", "Ex", ")", "{", "Trace", "(", "$", "Ex", ",", "TRACE_ERROR", ")", ";", "}", "if", "(", "$", "UserID", ")", "{", "Gdn", "::", "Session", "(", ")", "->", "Start", "(", "$", "UserID", ",", "TRUE", ",", "TRUE", ")", ";", "Gdn", "::", "UserModel", "(", ")", "->", "FireEvent", "(", "'AfterSignIn'", ")", ";", "}", "else", "{", "// There was some sort of error. Let's print that out.", "Trace", "(", "Gdn", "::", "UserModel", "(", ")", "->", "Validation", "->", "ResultsText", "(", ")", ",", "TRACE_WARNING", ")", ";", "}", "}", "}" ]
Set P3P header because IE won't allow cookies thru the iFrame without it. This must be done in the Dispatcher because of PrivateCommunity. That precludes using Controller->SetHeader. This is done so comment & forum embedding can work in old IE.
[ "Set", "P3P", "header", "because", "IE", "won", "t", "allow", "cookies", "thru", "the", "iFrame", "without", "it", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/settings/class.hooks.php#L178-L199
237,236
lciolecki/zf-extensions-library
library/Extlib/Cli/Action.php
Action.console
public function console($message, $eolBefor = false) { $befor = ''; if ($eolBefor) { $befor = PHP_EOL; } echo $befor, $message, PHP_EOL; return $this; }
php
public function console($message, $eolBefor = false) { $befor = ''; if ($eolBefor) { $befor = PHP_EOL; } echo $befor, $message, PHP_EOL; return $this; }
[ "public", "function", "console", "(", "$", "message", ",", "$", "eolBefor", "=", "false", ")", "{", "$", "befor", "=", "''", ";", "if", "(", "$", "eolBefor", ")", "{", "$", "befor", "=", "PHP_EOL", ";", "}", "echo", "$", "befor", ",", "$", "message", ",", "PHP_EOL", ";", "return", "$", "this", ";", "}" ]
Show message in cli @param string $message @param boolean $eolBefor @return \Extlib\Cli\Action
[ "Show", "message", "in", "cli" ]
f479a63188d17f1488b392d4fc14fe47a417ea55
https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Cli/Action.php#L52-L61
237,237
lciolecki/zf-extensions-library
library/Extlib/Cli/Action.php
Action.run
public function run() { if ($this->initialized) { $this->console(sprintf("Start running '%s' method of script '%s'.", $this->opts->action, get_class($this))); $this->{$this->action}(); $this->console(sprintf("End of running '%s' cli script.", get_class($this)), true); } return $this; }
php
public function run() { if ($this->initialized) { $this->console(sprintf("Start running '%s' method of script '%s'.", $this->opts->action, get_class($this))); $this->{$this->action}(); $this->console(sprintf("End of running '%s' cli script.", get_class($this)), true); } return $this; }
[ "public", "function", "run", "(", ")", "{", "if", "(", "$", "this", "->", "initialized", ")", "{", "$", "this", "->", "console", "(", "sprintf", "(", "\"Start running '%s' method of script '%s'.\"", ",", "$", "this", "->", "opts", "->", "action", ",", "get_class", "(", "$", "this", ")", ")", ")", ";", "$", "this", "->", "{", "$", "this", "->", "action", "}", "(", ")", ";", "$", "this", "->", "console", "(", "sprintf", "(", "\"End of running '%s' cli script.\"", ",", "get_class", "(", "$", "this", ")", ")", ",", "true", ")", ";", "}", "return", "$", "this", ";", "}" ]
Run cli script @return \Extlib\Cli\Action
[ "Run", "cli", "script" ]
f479a63188d17f1488b392d4fc14fe47a417ea55
https://github.com/lciolecki/zf-extensions-library/blob/f479a63188d17f1488b392d4fc14fe47a417ea55/library/Extlib/Cli/Action.php#L68-L77
237,238
indigophp-archive/pdf
src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php
WkhtmltopdfAdapter.createTmpFile
protected function createTmpFile($content = null) { $tmpPath = $this->getConfig('tmp', sys_get_temp_dir()); $tmpFile = tempnam($tmpPath,'tmp_WkHtmlToPdf_'); rename($tmpFile, $tmpFile .= '.html'); if (!is_null($content)) { file_put_contents($tmpFile, $content); } $this->tmpFiles[] = $tmpFile; return $tmpFile; }
php
protected function createTmpFile($content = null) { $tmpPath = $this->getConfig('tmp', sys_get_temp_dir()); $tmpFile = tempnam($tmpPath,'tmp_WkHtmlToPdf_'); rename($tmpFile, $tmpFile .= '.html'); if (!is_null($content)) { file_put_contents($tmpFile, $content); } $this->tmpFiles[] = $tmpFile; return $tmpFile; }
[ "protected", "function", "createTmpFile", "(", "$", "content", "=", "null", ")", "{", "$", "tmpPath", "=", "$", "this", "->", "getConfig", "(", "'tmp'", ",", "sys_get_temp_dir", "(", ")", ")", ";", "$", "tmpFile", "=", "tempnam", "(", "$", "tmpPath", ",", "'tmp_WkHtmlToPdf_'", ")", ";", "rename", "(", "$", "tmpFile", ",", "$", "tmpFile", ".=", "'.html'", ")", ";", "if", "(", "!", "is_null", "(", "$", "content", ")", ")", "{", "file_put_contents", "(", "$", "tmpFile", ",", "$", "content", ")", ";", "}", "$", "this", "->", "tmpFiles", "[", "]", "=", "$", "tmpFile", ";", "return", "$", "tmpFile", ";", "}" ]
Create a tmp file, optionally with given content @param mixed $content The file content @return string The path to the created file
[ "Create", "a", "tmp", "file", "optionally", "with", "given", "content" ]
060dcccbcd33066d012bc3d5c8300a5310e87a7a
https://github.com/indigophp-archive/pdf/blob/060dcccbcd33066d012bc3d5c8300a5310e87a7a/src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php#L347-L360
237,239
indigophp-archive/pdf
src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php
WkhtmltopdfAdapter.buildArguments
protected function buildArguments(array $options = array()) { $arguments = array(); foreach ($options as $key => $value) { // Validate value and format it if ($value === false or is_int($key)) { continue; } $arguments[] = "--$key"; if (is_array($value)) { $arguments = array_merge($arguments, $this->buildArrayArguments($value)); } elseif ($value !== true) { $arguments[] = $value; } } return $arguments; }
php
protected function buildArguments(array $options = array()) { $arguments = array(); foreach ($options as $key => $value) { // Validate value and format it if ($value === false or is_int($key)) { continue; } $arguments[] = "--$key"; if (is_array($value)) { $arguments = array_merge($arguments, $this->buildArrayArguments($value)); } elseif ($value !== true) { $arguments[] = $value; } } return $arguments; }
[ "protected", "function", "buildArguments", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "arguments", "=", "array", "(", ")", ";", "foreach", "(", "$", "options", "as", "$", "key", "=>", "$", "value", ")", "{", "// Validate value and format it", "if", "(", "$", "value", "===", "false", "or", "is_int", "(", "$", "key", ")", ")", "{", "continue", ";", "}", "$", "arguments", "[", "]", "=", "\"--$key\"", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "arguments", "=", "array_merge", "(", "$", "arguments", ",", "$", "this", "->", "buildArrayArguments", "(", "$", "value", ")", ")", ";", "}", "elseif", "(", "$", "value", "!==", "true", ")", "{", "$", "arguments", "[", "]", "=", "$", "value", ";", "}", "}", "return", "$", "arguments", ";", "}" ]
Build command line options from array @param array $options Input parameters @param bool $recursive Should NEVER been set manually @return string Argument string
[ "Build", "command", "line", "options", "from", "array" ]
060dcccbcd33066d012bc3d5c8300a5310e87a7a
https://github.com/indigophp-archive/pdf/blob/060dcccbcd33066d012bc3d5c8300a5310e87a7a/src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php#L399-L419
237,240
indigophp-archive/pdf
src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php
WkhtmltopdfAdapter.buildArrayArguments
private function buildArrayArguments($value) { $arguments = array(); foreach ($value as $index => $option) { if (is_string($index)) { $arguments[] = $index; } $arguments[] = $option; } return $arguments; }
php
private function buildArrayArguments($value) { $arguments = array(); foreach ($value as $index => $option) { if (is_string($index)) { $arguments[] = $index; } $arguments[] = $option; } return $arguments; }
[ "private", "function", "buildArrayArguments", "(", "$", "value", ")", "{", "$", "arguments", "=", "array", "(", ")", ";", "foreach", "(", "$", "value", "as", "$", "index", "=>", "$", "option", ")", "{", "if", "(", "is_string", "(", "$", "index", ")", ")", "{", "$", "arguments", "[", "]", "=", "$", "index", ";", "}", "$", "arguments", "[", "]", "=", "$", "option", ";", "}", "return", "$", "arguments", ";", "}" ]
Build array arguments @param array $value @return array
[ "Build", "array", "arguments" ]
060dcccbcd33066d012bc3d5c8300a5310e87a7a
https://github.com/indigophp-archive/pdf/blob/060dcccbcd33066d012bc3d5c8300a5310e87a7a/src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php#L427-L440
237,241
indigophp-archive/pdf
src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php
WkhtmltopdfAdapter.sendHeaders
protected function sendHeaders($tmpFile) { header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Type: application/pdf'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($tmpFile)); }
php
protected function sendHeaders($tmpFile) { header('Pragma: public'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Content-Type: application/pdf'); header('Content-Transfer-Encoding: binary'); header('Content-Length: ' . filesize($tmpFile)); }
[ "protected", "function", "sendHeaders", "(", "$", "tmpFile", ")", "{", "header", "(", "'Pragma: public'", ")", ";", "header", "(", "'Expires: 0'", ")", ";", "header", "(", "'Cache-Control: must-revalidate, post-check=0, pre-check=0'", ")", ";", "header", "(", "'Content-Type: application/pdf'", ")", ";", "header", "(", "'Content-Transfer-Encoding: binary'", ")", ";", "header", "(", "'Content-Length: '", ".", "filesize", "(", "$", "tmpFile", ")", ")", ";", "}" ]
Send PDF file headers @param string $tmpFile Temp file path
[ "Send", "PDF", "file", "headers" ]
060dcccbcd33066d012bc3d5c8300a5310e87a7a
https://github.com/indigophp-archive/pdf/blob/060dcccbcd33066d012bc3d5c8300a5310e87a7a/src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php#L501-L509
237,242
indigophp-archive/pdf
src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php
WkhtmltopdfAdapter.help
public function help() { $builder = new ProcessBuilder(array('--extended-help')); $builder->setPrefix($this->config['bin']); $process = $builder->getProcess(); $process->run(); if ($process->isSuccessful()) { return $process->getOutput(); } }
php
public function help() { $builder = new ProcessBuilder(array('--extended-help')); $builder->setPrefix($this->config['bin']); $process = $builder->getProcess(); $process->run(); if ($process->isSuccessful()) { return $process->getOutput(); } }
[ "public", "function", "help", "(", ")", "{", "$", "builder", "=", "new", "ProcessBuilder", "(", "array", "(", "'--extended-help'", ")", ")", ";", "$", "builder", "->", "setPrefix", "(", "$", "this", "->", "config", "[", "'bin'", "]", ")", ";", "$", "process", "=", "$", "builder", "->", "getProcess", "(", ")", ";", "$", "process", "->", "run", "(", ")", ";", "if", "(", "$", "process", "->", "isSuccessful", "(", ")", ")", "{", "return", "$", "process", "->", "getOutput", "(", ")", ";", "}", "}" ]
Return the extended help of WkHtmlToPdf @return string
[ "Return", "the", "extended", "help", "of", "WkHtmlToPdf" ]
060dcccbcd33066d012bc3d5c8300a5310e87a7a
https://github.com/indigophp-archive/pdf/blob/060dcccbcd33066d012bc3d5c8300a5310e87a7a/src/Indigo/Pdf/Adapter/WkhtmltopdfAdapter.php#L549-L560
237,243
vinala/kernel
src/Http/Router/Routes.php
Routes.setRoot
private static function setRoot($url) { $segements = explode('/', $url); $count = count($segements) - 2; $path = ''; for ($i = 0; $i < $count; $i++) { $path .= '../'; } Application::$path .= $path; return Application::$path; }
php
private static function setRoot($url) { $segements = explode('/', $url); $count = count($segements) - 2; $path = ''; for ($i = 0; $i < $count; $i++) { $path .= '../'; } Application::$path .= $path; return Application::$path; }
[ "private", "static", "function", "setRoot", "(", "$", "url", ")", "{", "$", "segements", "=", "explode", "(", "'/'", ",", "$", "url", ")", ";", "$", "count", "=", "count", "(", "$", "segements", ")", "-", "2", ";", "$", "path", "=", "''", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "count", ";", "$", "i", "++", ")", "{", "$", "path", ".=", "'../'", ";", "}", "Application", "::", "$", "path", ".=", "$", "path", ";", "return", "Application", "::", "$", "path", ";", "}" ]
Set the app root param. @param string $url @return string
[ "Set", "the", "app", "root", "param", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L129-L143
237,244
vinala/kernel
src/Http/Router/Routes.php
Routes.treat
private static function treat(Route $route, $params) { // in case of get request or post request if (($route->getMethod() == 'post' && Request::isPost()) || ($route->getMethod() == 'get') || ($route->getMethod() == 'resource') || ($route->getMethod() == 'call')) { return static::execute($route, $params); } return false; }
php
private static function treat(Route $route, $params) { // in case of get request or post request if (($route->getMethod() == 'post' && Request::isPost()) || ($route->getMethod() == 'get') || ($route->getMethod() == 'resource') || ($route->getMethod() == 'call')) { return static::execute($route, $params); } return false; }
[ "private", "static", "function", "treat", "(", "Route", "$", "route", ",", "$", "params", ")", "{", "// in case of get request or post request", "if", "(", "(", "$", "route", "->", "getMethod", "(", ")", "==", "'post'", "&&", "Request", "::", "isPost", "(", ")", ")", "||", "(", "$", "route", "->", "getMethod", "(", ")", "==", "'get'", ")", "||", "(", "$", "route", "->", "getMethod", "(", ")", "==", "'resource'", ")", "||", "(", "$", "route", "->", "getMethod", "(", ")", "==", "'call'", ")", ")", "{", "return", "static", "::", "execute", "(", "$", "route", ",", "$", "params", ")", ";", "}", "return", "false", ";", "}" ]
Treat the request according to it's method. @param Route $route @param array $params @return bool
[ "Treat", "the", "request", "according", "to", "it", "s", "method", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L212-L220
237,245
vinala/kernel
src/Http/Router/Routes.php
Routes.execute
private static function execute(&$route, $params) { array_shift($params); if (static::runAppMiddleware() && static::runRouteMiddleware($route)) { static::prepare($route, $params); return true; } }
php
private static function execute(&$route, $params) { array_shift($params); if (static::runAppMiddleware() && static::runRouteMiddleware($route)) { static::prepare($route, $params); return true; } }
[ "private", "static", "function", "execute", "(", "&", "$", "route", ",", "$", "params", ")", "{", "array_shift", "(", "$", "params", ")", ";", "if", "(", "static", "::", "runAppMiddleware", "(", ")", "&&", "static", "::", "runRouteMiddleware", "(", "$", "route", ")", ")", "{", "static", "::", "prepare", "(", "$", "route", ",", "$", "params", ")", ";", "return", "true", ";", "}", "}" ]
Execute the route. @param Route $one @param array $params @return bool
[ "Execute", "the", "route", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L230-L239
237,246
vinala/kernel
src/Http/Router/Routes.php
Routes.runAppMiddleware
private static function runAppMiddleware() { $appMiddleware = Filter::$middleware; foreach ($appMiddleware as $middleware) { $middleware = instance($middleware); $middleware->handle(new Request()); } return true; }
php
private static function runAppMiddleware() { $appMiddleware = Filter::$middleware; foreach ($appMiddleware as $middleware) { $middleware = instance($middleware); $middleware->handle(new Request()); } return true; }
[ "private", "static", "function", "runAppMiddleware", "(", ")", "{", "$", "appMiddleware", "=", "Filter", "::", "$", "middleware", ";", "foreach", "(", "$", "appMiddleware", "as", "$", "middleware", ")", "{", "$", "middleware", "=", "instance", "(", "$", "middleware", ")", ";", "$", "middleware", "->", "handle", "(", "new", "Request", "(", ")", ")", ";", "}", "return", "true", ";", "}" ]
Check app middlewares before run the route. @return null
[ "Check", "app", "middlewares", "before", "run", "the", "route", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L246-L257
237,247
vinala/kernel
src/Http/Router/Routes.php
Routes.runRouteMiddleware
private static function runRouteMiddleware($route) { $routeMiddleware = Filter::$routeMiddleware; if (!is_null($route->getMiddleware())) { // if ($route->getMiddleware()['type'] == 'route' && ! is_null($route->getMiddleware()['middlewares'])) { foreach ($route->getMiddleware() as $middleware) { //Check if the routes middlewares are in filter class exception_if(!array_has($routeMiddleware, $middleware), RouteMiddlewareNotFoundException::class, $middleware); $middleware = instance($routeMiddleware[$middleware]); $middleware->handle(new Request()); } } return true; }
php
private static function runRouteMiddleware($route) { $routeMiddleware = Filter::$routeMiddleware; if (!is_null($route->getMiddleware())) { // if ($route->getMiddleware()['type'] == 'route' && ! is_null($route->getMiddleware()['middlewares'])) { foreach ($route->getMiddleware() as $middleware) { //Check if the routes middlewares are in filter class exception_if(!array_has($routeMiddleware, $middleware), RouteMiddlewareNotFoundException::class, $middleware); $middleware = instance($routeMiddleware[$middleware]); $middleware->handle(new Request()); } } return true; }
[ "private", "static", "function", "runRouteMiddleware", "(", "$", "route", ")", "{", "$", "routeMiddleware", "=", "Filter", "::", "$", "routeMiddleware", ";", "if", "(", "!", "is_null", "(", "$", "route", "->", "getMiddleware", "(", ")", ")", ")", "{", "// if ($route->getMiddleware()['type'] == 'route' && ! is_null($route->getMiddleware()['middlewares'])) {", "foreach", "(", "$", "route", "->", "getMiddleware", "(", ")", "as", "$", "middleware", ")", "{", "//Check if the routes middlewares are in filter class", "exception_if", "(", "!", "array_has", "(", "$", "routeMiddleware", ",", "$", "middleware", ")", ",", "RouteMiddlewareNotFoundException", "::", "class", ",", "$", "middleware", ")", ";", "$", "middleware", "=", "instance", "(", "$", "routeMiddleware", "[", "$", "middleware", "]", ")", ";", "$", "middleware", "->", "handle", "(", "new", "Request", "(", ")", ")", ";", "}", "}", "return", "true", ";", "}" ]
Check route middlewares before run the route and check if the requested middleware are realy in filter class. @return null
[ "Check", "route", "middlewares", "before", "run", "the", "route", "and", "check", "if", "the", "requested", "middleware", "are", "realy", "in", "filter", "class", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L265-L282
237,248
vinala/kernel
src/Http/Router/Routes.php
Routes.prepare
private static function prepare(Route $route, $params) { static::$current = $route; if ($route->getMethod() == 'resource') { if ($route->getTarget()['method'] == 'update') { $id = $params[0]; $params[0] = new Request(); $params[] = $id; } elseif ($route->getTarget()['method'] == 'insert') { $params[] = new Request(); } self::treatment(call_user_func_array($route->getClosure(), $params)); } elseif ($route->getMethod() == 'call') { $target = $route->getResource()[$route->name]->getTarget(); self::treatment(call_user_func_array([$target['controller'], $target['method']], $params)); } else { self::treatment(call_user_func_array($route->getClosure(), $params)); } }
php
private static function prepare(Route $route, $params) { static::$current = $route; if ($route->getMethod() == 'resource') { if ($route->getTarget()['method'] == 'update') { $id = $params[0]; $params[0] = new Request(); $params[] = $id; } elseif ($route->getTarget()['method'] == 'insert') { $params[] = new Request(); } self::treatment(call_user_func_array($route->getClosure(), $params)); } elseif ($route->getMethod() == 'call') { $target = $route->getResource()[$route->name]->getTarget(); self::treatment(call_user_func_array([$target['controller'], $target['method']], $params)); } else { self::treatment(call_user_func_array($route->getClosure(), $params)); } }
[ "private", "static", "function", "prepare", "(", "Route", "$", "route", ",", "$", "params", ")", "{", "static", "::", "$", "current", "=", "$", "route", ";", "if", "(", "$", "route", "->", "getMethod", "(", ")", "==", "'resource'", ")", "{", "if", "(", "$", "route", "->", "getTarget", "(", ")", "[", "'method'", "]", "==", "'update'", ")", "{", "$", "id", "=", "$", "params", "[", "0", "]", ";", "$", "params", "[", "0", "]", "=", "new", "Request", "(", ")", ";", "$", "params", "[", "]", "=", "$", "id", ";", "}", "elseif", "(", "$", "route", "->", "getTarget", "(", ")", "[", "'method'", "]", "==", "'insert'", ")", "{", "$", "params", "[", "]", "=", "new", "Request", "(", ")", ";", "}", "self", "::", "treatment", "(", "call_user_func_array", "(", "$", "route", "->", "getClosure", "(", ")", ",", "$", "params", ")", ")", ";", "}", "elseif", "(", "$", "route", "->", "getMethod", "(", ")", "==", "'call'", ")", "{", "$", "target", "=", "$", "route", "->", "getResource", "(", ")", "[", "$", "route", "->", "name", "]", "->", "getTarget", "(", ")", ";", "self", "::", "treatment", "(", "call_user_func_array", "(", "[", "$", "target", "[", "'controller'", "]", ",", "$", "target", "[", "'method'", "]", "]", ",", "$", "params", ")", ")", ";", "}", "else", "{", "self", "::", "treatment", "(", "call_user_func_array", "(", "$", "route", "->", "getClosure", "(", ")", ",", "$", "params", ")", ")", ";", "}", "}" ]
prepare the route to be executed. @param Route $request @param array $params @return null
[ "prepare", "the", "route", "to", "be", "executed", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L292-L312
237,249
vinala/kernel
src/Http/Router/Routes.php
Routes.treatment
private static function treatment($result) { if (is_string($result)) { echo $result; } elseif ($result instanceof Views) { View::show($result); } }
php
private static function treatment($result) { if (is_string($result)) { echo $result; } elseif ($result instanceof Views) { View::show($result); } }
[ "private", "static", "function", "treatment", "(", "$", "result", ")", "{", "if", "(", "is_string", "(", "$", "result", ")", ")", "{", "echo", "$", "result", ";", "}", "elseif", "(", "$", "result", "instanceof", "Views", ")", "{", "View", "::", "show", "(", "$", "result", ")", ";", "}", "}" ]
Treat the result of the route closure. @param mixed $result @return string
[ "Treat", "the", "result", "of", "the", "route", "closure", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L321-L328
237,250
vinala/kernel
src/Http/Router/Routes.php
Routes.add
public static function add(Route $route) { exception_if(self::checkDuplicated($route), RouteDuplicatedException::class, $route); // Create new route for url ended with '/' $routeWithoutSlash = $route; $routeWithSlash = $route->getWithSlash(); self::$register[$routeWithoutSlash->getName()] = $routeWithoutSlash; self::$register[$routeWithSlash->getName()] = $routeWithSlash; }
php
public static function add(Route $route) { exception_if(self::checkDuplicated($route), RouteDuplicatedException::class, $route); // Create new route for url ended with '/' $routeWithoutSlash = $route; $routeWithSlash = $route->getWithSlash(); self::$register[$routeWithoutSlash->getName()] = $routeWithoutSlash; self::$register[$routeWithSlash->getName()] = $routeWithSlash; }
[ "public", "static", "function", "add", "(", "Route", "$", "route", ")", "{", "exception_if", "(", "self", "::", "checkDuplicated", "(", "$", "route", ")", ",", "RouteDuplicatedException", "::", "class", ",", "$", "route", ")", ";", "// Create new route for url ended with '/'", "$", "routeWithoutSlash", "=", "$", "route", ";", "$", "routeWithSlash", "=", "$", "route", "->", "getWithSlash", "(", ")", ";", "self", "::", "$", "register", "[", "$", "routeWithoutSlash", "->", "getName", "(", ")", "]", "=", "$", "routeWithoutSlash", ";", "self", "::", "$", "register", "[", "$", "routeWithSlash", "->", "getName", "(", ")", "]", "=", "$", "routeWithSlash", ";", "}" ]
Add new route to register. @param Route $route @return null
[ "Add", "new", "route", "to", "register", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L337-L347
237,251
vinala/kernel
src/Http/Router/Routes.php
Routes.edit
public static function edit(Route $route) { $routeWithoutSlash = $route; $routeWithSlash = $route->getWithSlash(); self::$register[$routeWithoutSlash->getName()] = $routeWithoutSlash; self::$register[$routeWithSlash->getName()] = $routeWithSlash; }
php
public static function edit(Route $route) { $routeWithoutSlash = $route; $routeWithSlash = $route->getWithSlash(); self::$register[$routeWithoutSlash->getName()] = $routeWithoutSlash; self::$register[$routeWithSlash->getName()] = $routeWithSlash; }
[ "public", "static", "function", "edit", "(", "Route", "$", "route", ")", "{", "$", "routeWithoutSlash", "=", "$", "route", ";", "$", "routeWithSlash", "=", "$", "route", "->", "getWithSlash", "(", ")", ";", "self", "::", "$", "register", "[", "$", "routeWithoutSlash", "->", "getName", "(", ")", "]", "=", "$", "routeWithoutSlash", ";", "self", "::", "$", "register", "[", "$", "routeWithSlash", "->", "getName", "(", ")", "]", "=", "$", "routeWithSlash", ";", "}" ]
Update an existant route in register. @param Route $route @return null
[ "Update", "an", "existant", "route", "in", "register", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L356-L363
237,252
vinala/kernel
src/Http/Router/Routes.php
Routes.delete
public static function delete(Route $route) { $routeWithoutSlash = $route; $routeWithSlash = $route->getWithSlash(); // exception_if(! check(self::$register[$routeWithoutSlash->getName()]), RouteNotFoundInRoutesRegisterException::class , $routeWithoutSlash); // exception_if(! check(self::$register[$routeWithSlash->getName()]), RouteNotFoundInRoutesRegisterException::class , $routeWithSlash); if (check(self::$register[$routeWithoutSlash->getName()])) { unset(self::$register[$routeWithoutSlash->getName()]); } if (check(self::$register[$routeWithSlash->getName()])) { unset(self::$register[$routeWithSlash->getName()]); } }
php
public static function delete(Route $route) { $routeWithoutSlash = $route; $routeWithSlash = $route->getWithSlash(); // exception_if(! check(self::$register[$routeWithoutSlash->getName()]), RouteNotFoundInRoutesRegisterException::class , $routeWithoutSlash); // exception_if(! check(self::$register[$routeWithSlash->getName()]), RouteNotFoundInRoutesRegisterException::class , $routeWithSlash); if (check(self::$register[$routeWithoutSlash->getName()])) { unset(self::$register[$routeWithoutSlash->getName()]); } if (check(self::$register[$routeWithSlash->getName()])) { unset(self::$register[$routeWithSlash->getName()]); } }
[ "public", "static", "function", "delete", "(", "Route", "$", "route", ")", "{", "$", "routeWithoutSlash", "=", "$", "route", ";", "$", "routeWithSlash", "=", "$", "route", "->", "getWithSlash", "(", ")", ";", "// exception_if(! check(self::$register[$routeWithoutSlash->getName()]), RouteNotFoundInRoutesRegisterException::class , $routeWithoutSlash);", "// exception_if(! check(self::$register[$routeWithSlash->getName()]), RouteNotFoundInRoutesRegisterException::class , $routeWithSlash);", "if", "(", "check", "(", "self", "::", "$", "register", "[", "$", "routeWithoutSlash", "->", "getName", "(", ")", "]", ")", ")", "{", "unset", "(", "self", "::", "$", "register", "[", "$", "routeWithoutSlash", "->", "getName", "(", ")", "]", ")", ";", "}", "if", "(", "check", "(", "self", "::", "$", "register", "[", "$", "routeWithSlash", "->", "getName", "(", ")", "]", ")", ")", "{", "unset", "(", "self", "::", "$", "register", "[", "$", "routeWithSlash", "->", "getName", "(", ")", "]", ")", ";", "}", "}" ]
Remove an existant route from register. @param Route $route @return null
[ "Remove", "an", "existant", "route", "from", "register", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L372-L387
237,253
vinala/kernel
src/Http/Router/Routes.php
Routes.checkDuplicated
private static function checkDuplicated(Route $route) { foreach (self::$register as $registeredRoute) { if ($registeredRoute->getName() == $route->getName()) { return true; } } return false; }
php
private static function checkDuplicated(Route $route) { foreach (self::$register as $registeredRoute) { if ($registeredRoute->getName() == $route->getName()) { return true; } } return false; }
[ "private", "static", "function", "checkDuplicated", "(", "Route", "$", "route", ")", "{", "foreach", "(", "self", "::", "$", "register", "as", "$", "registeredRoute", ")", "{", "if", "(", "$", "registeredRoute", "->", "getName", "(", ")", "==", "$", "route", "->", "getName", "(", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Check if route is duplicated. @param Route $route @return bool
[ "Check", "if", "route", "is", "duplicated", "." ]
346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a
https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Routes.php#L396-L405
237,254
kiler129/CherryHttp
src/_legacyCode/HttpResponse.php
HttpResponse.setCode
public function setCode($code) { $code = (int)$code; if (!empty($this->body) && !HttpCode::isBodyAllowed($code)) { //InvalidArgumentException can be thrown here throw new LogicException('HTTP response already contains body - response "' . HttpCode::getName($code) . '" cannot contain body.'); } $this->code = $code; $this->messageCache = null; }
php
public function setCode($code) { $code = (int)$code; if (!empty($this->body) && !HttpCode::isBodyAllowed($code)) { //InvalidArgumentException can be thrown here throw new LogicException('HTTP response already contains body - response "' . HttpCode::getName($code) . '" cannot contain body.'); } $this->code = $code; $this->messageCache = null; }
[ "public", "function", "setCode", "(", "$", "code", ")", "{", "$", "code", "=", "(", "int", ")", "$", "code", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "body", ")", "&&", "!", "HttpCode", "::", "isBodyAllowed", "(", "$", "code", ")", ")", "{", "//InvalidArgumentException can be thrown here", "throw", "new", "LogicException", "(", "'HTTP response already contains body - response \"'", ".", "HttpCode", "::", "getName", "(", "$", "code", ")", ".", "'\" cannot contain body.'", ")", ";", "}", "$", "this", "->", "code", "=", "$", "code", ";", "$", "this", "->", "messageCache", "=", "null", ";", "}" ]
Sets HTTP code for response. @param integer $code Any valid HTTP code @throws InvalidArgumentException Exception is raised if you try to set invalid HTTP code. @throws LogicException Exception is raised if you try to set code which should not contain a body and body is already present.
[ "Sets", "HTTP", "code", "for", "response", "." ]
05927f26183cbd6fd5ccb0853befecdea279308d
https://github.com/kiler129/CherryHttp/blob/05927f26183cbd6fd5ccb0853befecdea279308d/src/_legacyCode/HttpResponse.php#L62-L72
237,255
kiler129/CherryHttp
src/_legacyCode/HttpResponse.php
HttpResponse.setBody
public function setBody($body) { if (!empty($body) && !HttpCode::isBodyAllowed($this->code)) { throw new LogicException('You cannot set non-empty body for currently set code'); } $this->body = (string)$body; $this->setHeader('Content-Length', strlen($this->body)); $this->messageCache = null; }
php
public function setBody($body) { if (!empty($body) && !HttpCode::isBodyAllowed($this->code)) { throw new LogicException('You cannot set non-empty body for currently set code'); } $this->body = (string)$body; $this->setHeader('Content-Length', strlen($this->body)); $this->messageCache = null; }
[ "public", "function", "setBody", "(", "$", "body", ")", "{", "if", "(", "!", "empty", "(", "$", "body", ")", "&&", "!", "HttpCode", "::", "isBodyAllowed", "(", "$", "this", "->", "code", ")", ")", "{", "throw", "new", "LogicException", "(", "'You cannot set non-empty body for currently set code'", ")", ";", "}", "$", "this", "->", "body", "=", "(", "string", ")", "$", "body", ";", "$", "this", "->", "setHeader", "(", "'Content-Length'", ",", "strlen", "(", "$", "this", "->", "body", ")", ")", ";", "$", "this", "->", "messageCache", "=", "null", ";", "}" ]
Sets body for response. It also automatically sets correct Content-Length header. @param string $body @throws LogicException Thrown when you try to set body, but request code (eg. 204) denotes that no body is allowed.
[ "Sets", "body", "for", "response", ".", "It", "also", "automatically", "sets", "correct", "Content", "-", "Length", "header", "." ]
05927f26183cbd6fd5ccb0853befecdea279308d
https://github.com/kiler129/CherryHttp/blob/05927f26183cbd6fd5ccb0853befecdea279308d/src/_legacyCode/HttpResponse.php#L83-L92
237,256
bhavitk/micro-struct
src/Controller.php
Controller.enableSmarty
private function enableSmarty() { if ($this->smarty !== NULL) { return; } $this->smarty = new Smarty; $this->smarty->setTemplateDir(PUBLIC_DIR); $this->smarty->setCompileDir(PUBLIC_DIR . 'smarty' . DSC . 'compile'); $this->smarty->setCacheDir(PUBLIC_DIR . 'smarty' . DSC . 'cache'); }
php
private function enableSmarty() { if ($this->smarty !== NULL) { return; } $this->smarty = new Smarty; $this->smarty->setTemplateDir(PUBLIC_DIR); $this->smarty->setCompileDir(PUBLIC_DIR . 'smarty' . DSC . 'compile'); $this->smarty->setCacheDir(PUBLIC_DIR . 'smarty' . DSC . 'cache'); }
[ "private", "function", "enableSmarty", "(", ")", "{", "if", "(", "$", "this", "->", "smarty", "!==", "NULL", ")", "{", "return", ";", "}", "$", "this", "->", "smarty", "=", "new", "Smarty", ";", "$", "this", "->", "smarty", "->", "setTemplateDir", "(", "PUBLIC_DIR", ")", ";", "$", "this", "->", "smarty", "->", "setCompileDir", "(", "PUBLIC_DIR", ".", "'smarty'", ".", "DSC", ".", "'compile'", ")", ";", "$", "this", "->", "smarty", "->", "setCacheDir", "(", "PUBLIC_DIR", ".", "'smarty'", ".", "DSC", ".", "'cache'", ")", ";", "}" ]
Enables Smarty.
[ "Enables", "Smarty", "." ]
119632405a91658388ef15a327603ac81b838de5
https://github.com/bhavitk/micro-struct/blob/119632405a91658388ef15a327603ac81b838de5/src/Controller.php#L62-L73
237,257
bhavitk/micro-struct
src/Controller.php
Controller.getViewPath
private function getViewPath($name) { $module = $this->module_name !== NULL ? ($this->module_name) . DSC : ''; return $this->getRealPath('views' . DSC . $module . $name); }
php
private function getViewPath($name) { $module = $this->module_name !== NULL ? ($this->module_name) . DSC : ''; return $this->getRealPath('views' . DSC . $module . $name); }
[ "private", "function", "getViewPath", "(", "$", "name", ")", "{", "$", "module", "=", "$", "this", "->", "module_name", "!==", "NULL", "?", "(", "$", "this", "->", "module_name", ")", ".", "DSC", ":", "''", ";", "return", "$", "this", "->", "getRealPath", "(", "'views'", ".", "DSC", ".", "$", "module", ".", "$", "name", ")", ";", "}" ]
Returns path to view file. @param string $name @return string
[ "Returns", "path", "to", "view", "file", "." ]
119632405a91658388ef15a327603ac81b838de5
https://github.com/bhavitk/micro-struct/blob/119632405a91658388ef15a327603ac81b838de5/src/Controller.php#L81-L86
237,258
bhavitk/micro-struct
src/Controller.php
Controller.renderTemplate
public function renderTemplate($name) { $data = array_merge($this->view_data, $this->view); $template = $this->getRealPath('template' . DSC . $name); $this->loadView($template, $data); }
php
public function renderTemplate($name) { $data = array_merge($this->view_data, $this->view); $template = $this->getRealPath('template' . DSC . $name); $this->loadView($template, $data); }
[ "public", "function", "renderTemplate", "(", "$", "name", ")", "{", "$", "data", "=", "array_merge", "(", "$", "this", "->", "view_data", ",", "$", "this", "->", "view", ")", ";", "$", "template", "=", "$", "this", "->", "getRealPath", "(", "'template'", ".", "DSC", ".", "$", "name", ")", ";", "$", "this", "->", "loadView", "(", "$", "template", ",", "$", "data", ")", ";", "}" ]
Render given template with all added view. @param string $name
[ "Render", "given", "template", "with", "all", "added", "view", "." ]
119632405a91658388ef15a327603ac81b838de5
https://github.com/bhavitk/micro-struct/blob/119632405a91658388ef15a327603ac81b838de5/src/Controller.php#L111-L116
237,259
bhavitk/micro-struct
src/Controller.php
Controller.renderView
public function renderView($name, $data = array(), $return = FALSE) { $file = $this->getViewPath($name); return $this->loadView($file, $data, $return); }
php
public function renderView($name, $data = array(), $return = FALSE) { $file = $this->getViewPath($name); return $this->loadView($file, $data, $return); }
[ "public", "function", "renderView", "(", "$", "name", ",", "$", "data", "=", "array", "(", ")", ",", "$", "return", "=", "FALSE", ")", "{", "$", "file", "=", "$", "this", "->", "getViewPath", "(", "$", "name", ")", ";", "return", "$", "this", "->", "loadView", "(", "$", "file", ",", "$", "data", ",", "$", "return", ")", ";", "}" ]
Render View. @param string $name @param array $data @param boolean $return @return string|NULL
[ "Render", "View", "." ]
119632405a91658388ef15a327603ac81b838de5
https://github.com/bhavitk/micro-struct/blob/119632405a91658388ef15a327603ac81b838de5/src/Controller.php#L126-L130
237,260
MINISTRYGmbH/morrow-core
src/Benchmark.php
Benchmark.stop
public function stop() { $temp['section'] = $this->section; // set start value for system + user time if (function_exists('getrusage')) { $use = getrusage(); $user = sprintf('%6d.%06d', $use['ru_utime.tv_sec'], $use['ru_utime.tv_usec']); $system = sprintf('%6d.%06d', $use['ru_stime.tv_sec'], $use['ru_stime.tv_usec']); $proctime_end = $user+$system; $temp['proctime'] = $proctime_end - $this->proctime; } else { $temp['proctime'] = 'n/a'; } $realtime_end = microtime(true); $temp['realtime'] = $realtime_end - $this->realtime; if (function_exists('memory_get_usage')) $temp['mem'] = memory_get_usage(); else $temp['mem'] = 'n/a'; $this->data[] = $temp; $this->active = false; }
php
public function stop() { $temp['section'] = $this->section; // set start value for system + user time if (function_exists('getrusage')) { $use = getrusage(); $user = sprintf('%6d.%06d', $use['ru_utime.tv_sec'], $use['ru_utime.tv_usec']); $system = sprintf('%6d.%06d', $use['ru_stime.tv_sec'], $use['ru_stime.tv_usec']); $proctime_end = $user+$system; $temp['proctime'] = $proctime_end - $this->proctime; } else { $temp['proctime'] = 'n/a'; } $realtime_end = microtime(true); $temp['realtime'] = $realtime_end - $this->realtime; if (function_exists('memory_get_usage')) $temp['mem'] = memory_get_usage(); else $temp['mem'] = 'n/a'; $this->data[] = $temp; $this->active = false; }
[ "public", "function", "stop", "(", ")", "{", "$", "temp", "[", "'section'", "]", "=", "$", "this", "->", "section", ";", "// set start value for system + user time", "if", "(", "function_exists", "(", "'getrusage'", ")", ")", "{", "$", "use", "=", "getrusage", "(", ")", ";", "$", "user", "=", "sprintf", "(", "'%6d.%06d'", ",", "$", "use", "[", "'ru_utime.tv_sec'", "]", ",", "$", "use", "[", "'ru_utime.tv_usec'", "]", ")", ";", "$", "system", "=", "sprintf", "(", "'%6d.%06d'", ",", "$", "use", "[", "'ru_stime.tv_sec'", "]", ",", "$", "use", "[", "'ru_stime.tv_usec'", "]", ")", ";", "$", "proctime_end", "=", "$", "user", "+", "$", "system", ";", "$", "temp", "[", "'proctime'", "]", "=", "$", "proctime_end", "-", "$", "this", "->", "proctime", ";", "}", "else", "{", "$", "temp", "[", "'proctime'", "]", "=", "'n/a'", ";", "}", "$", "realtime_end", "=", "microtime", "(", "true", ")", ";", "$", "temp", "[", "'realtime'", "]", "=", "$", "realtime_end", "-", "$", "this", "->", "realtime", ";", "if", "(", "function_exists", "(", "'memory_get_usage'", ")", ")", "$", "temp", "[", "'mem'", "]", "=", "memory_get_usage", "(", ")", ";", "else", "$", "temp", "[", "'mem'", "]", "=", "'n/a'", ";", "$", "this", "->", "data", "[", "]", "=", "$", "temp", ";", "$", "this", "->", "active", "=", "false", ";", "}" ]
Stops benchmarking of the actual section. @return null
[ "Stops", "benchmarking", "of", "the", "actual", "section", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Benchmark.php#L105-L127
237,261
MINISTRYGmbH/morrow-core
src/Benchmark.php
Benchmark.get
public function get() { if ($this->active) $this->stop(); foreach (array_keys($this->data) as $key) { $row =& $this->data[$key]; $row['realtime_ms'] = $row['realtime']*1000; if (is_numeric($row['proctime'])) { $row['proctime_ms'] = $row['proctime']*1000; } else { $row['proctime_ms'] = 'n/a'; } } $returner = $this->data; unset($this->data); return $returner; }
php
public function get() { if ($this->active) $this->stop(); foreach (array_keys($this->data) as $key) { $row =& $this->data[$key]; $row['realtime_ms'] = $row['realtime']*1000; if (is_numeric($row['proctime'])) { $row['proctime_ms'] = $row['proctime']*1000; } else { $row['proctime_ms'] = 'n/a'; } } $returner = $this->data; unset($this->data); return $returner; }
[ "public", "function", "get", "(", ")", "{", "if", "(", "$", "this", "->", "active", ")", "$", "this", "->", "stop", "(", ")", ";", "foreach", "(", "array_keys", "(", "$", "this", "->", "data", ")", "as", "$", "key", ")", "{", "$", "row", "=", "&", "$", "this", "->", "data", "[", "$", "key", "]", ";", "$", "row", "[", "'realtime_ms'", "]", "=", "$", "row", "[", "'realtime'", "]", "*", "1000", ";", "if", "(", "is_numeric", "(", "$", "row", "[", "'proctime'", "]", ")", ")", "{", "$", "row", "[", "'proctime_ms'", "]", "=", "$", "row", "[", "'proctime'", "]", "*", "1000", ";", "}", "else", "{", "$", "row", "[", "'proctime_ms'", "]", "=", "'n/a'", ";", "}", "}", "$", "returner", "=", "$", "this", "->", "data", ";", "unset", "(", "$", "this", "->", "data", ")", ";", "return", "$", "returner", ";", "}" ]
Returns an array of all so far benchmarked sections with the measured times. @return array Returns an array with the keys `section`, `proctime`, `realtime`, `mem`, `realtime_ms`, `proctime_ms`.
[ "Returns", "an", "array", "of", "all", "so", "far", "benchmarked", "sections", "with", "the", "measured", "times", "." ]
bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e
https://github.com/MINISTRYGmbH/morrow-core/blob/bdc916eedb14b65b06dbc88efbd2b7779f4a9a9e/src/Benchmark.php#L134-L151
237,262
inri13666/AkumaBootswatchBundle
Twig/BootstrapFormExtension.php
BootstrapFormExtension.restoreFormSettings
public function restoreFormSettings() { if (count($this->settingsStack) < 1) { throw new \UnderflowException("No settings on the stack to restore"); } $settings = array_pop($this->settingsStack); $this->style = $settings['style']; $this->colSize = $settings['colSize']; $this->widgetCol = $settings['widgetCol']; $this->labelCol = $settings['labelCol']; $this->simpleCol = $settings['simpleCol']; }
php
public function restoreFormSettings() { if (count($this->settingsStack) < 1) { throw new \UnderflowException("No settings on the stack to restore"); } $settings = array_pop($this->settingsStack); $this->style = $settings['style']; $this->colSize = $settings['colSize']; $this->widgetCol = $settings['widgetCol']; $this->labelCol = $settings['labelCol']; $this->simpleCol = $settings['simpleCol']; }
[ "public", "function", "restoreFormSettings", "(", ")", "{", "if", "(", "count", "(", "$", "this", "->", "settingsStack", ")", "<", "1", ")", "{", "throw", "new", "\\", "UnderflowException", "(", "\"No settings on the stack to restore\"", ")", ";", "}", "$", "settings", "=", "array_pop", "(", "$", "this", "->", "settingsStack", ")", ";", "$", "this", "->", "style", "=", "$", "settings", "[", "'style'", "]", ";", "$", "this", "->", "colSize", "=", "$", "settings", "[", "'colSize'", "]", ";", "$", "this", "->", "widgetCol", "=", "$", "settings", "[", "'widgetCol'", "]", ";", "$", "this", "->", "labelCol", "=", "$", "settings", "[", "'labelCol'", "]", ";", "$", "this", "->", "simpleCol", "=", "$", "settings", "[", "'simpleCol'", "]", ";", "}" ]
Restore the form settings from the stack. @internal Should only be used at the end of form_end. @see backupFormSettings @throws \UnderflowException
[ "Restore", "the", "form", "settings", "from", "the", "stack", "." ]
f18e68933345fd29da712ecfb62b7be6e539191d
https://github.com/inri13666/AkumaBootswatchBundle/blob/f18e68933345fd29da712ecfb62b7be6e539191d/Twig/BootstrapFormExtension.php#L212-L225
237,263
phergie/phergie-irc-plugin-react-eventfilter
src/ChannelFilter.php
ChannelFilter.filter
public function filter(EventInterface $event) { if (!$event instanceof UserEventInterface) { return null; } $channels = $this->getChannels($event); if (empty($channels)) { return null; } $commonChannels = array_intersect($channels, $this->channels); if ($commonChannels) { return true; } return false; }
php
public function filter(EventInterface $event) { if (!$event instanceof UserEventInterface) { return null; } $channels = $this->getChannels($event); if (empty($channels)) { return null; } $commonChannels = array_intersect($channels, $this->channels); if ($commonChannels) { return true; } return false; }
[ "public", "function", "filter", "(", "EventInterface", "$", "event", ")", "{", "if", "(", "!", "$", "event", "instanceof", "UserEventInterface", ")", "{", "return", "null", ";", "}", "$", "channels", "=", "$", "this", "->", "getChannels", "(", "$", "event", ")", ";", "if", "(", "empty", "(", "$", "channels", ")", ")", "{", "return", "null", ";", "}", "$", "commonChannels", "=", "array_intersect", "(", "$", "channels", ",", "$", "this", "->", "channels", ")", ";", "if", "(", "$", "commonChannels", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Filters events that are not channel-specific or originate in specified channels. @param \Phergie\Irc\Event\EventInterface $event @return boolean|null TRUE if the event originated from a matching channel associated with this filter, FALSE if it originated from a non-matching channel, or NULL if it is not associated with a channel.
[ "Filters", "events", "that", "are", "not", "channel", "-", "specific", "or", "originate", "in", "specified", "channels", "." ]
8fdde571a23ab1379d62a48e9de4570845c0e9dd
https://github.com/phergie/phergie-irc-plugin-react-eventfilter/blob/8fdde571a23ab1379d62a48e9de4570845c0e9dd/src/ChannelFilter.php#L95-L112
237,264
phergie/phergie-irc-plugin-react-eventfilter
src/ChannelFilter.php
ChannelFilter.getChannels
protected function getChannels(UserEventInterface $event) { $command = $event->getCommand(); if (isset($this->parameters[$command])) { $params = $event->getParams(); $param = $this->parameters[$command]; return preg_grep('/^[#&]/', explode(',', $params[$param])); } return array(); }
php
protected function getChannels(UserEventInterface $event) { $command = $event->getCommand(); if (isset($this->parameters[$command])) { $params = $event->getParams(); $param = $this->parameters[$command]; return preg_grep('/^[#&]/', explode(',', $params[$param])); } return array(); }
[ "protected", "function", "getChannels", "(", "UserEventInterface", "$", "event", ")", "{", "$", "command", "=", "$", "event", "->", "getCommand", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "parameters", "[", "$", "command", "]", ")", ")", "{", "$", "params", "=", "$", "event", "->", "getParams", "(", ")", ";", "$", "param", "=", "$", "this", "->", "parameters", "[", "$", "command", "]", ";", "return", "preg_grep", "(", "'/^[#&]/'", ",", "explode", "(", "','", ",", "$", "params", "[", "$", "param", "]", ")", ")", ";", "}", "return", "array", "(", ")", ";", "}" ]
Extracts a list of channel names from a user event. @param \Phergie\Irc\Event\UserEventInterface $event @return array
[ "Extracts", "a", "list", "of", "channel", "names", "from", "a", "user", "event", "." ]
8fdde571a23ab1379d62a48e9de4570845c0e9dd
https://github.com/phergie/phergie-irc-plugin-react-eventfilter/blob/8fdde571a23ab1379d62a48e9de4570845c0e9dd/src/ChannelFilter.php#L120-L129
237,265
Jinxes/layton
Layton/Library/Http/Request.php
Request.getMethod
public function getMethod() { if ($this->method === null) { if (is_null($this->method_override)) { $this->method = $this->server->get('request-method'); } else { $this->method = $this->method_override; } $this->method = strtoupper($this->method); } return $this->method; }
php
public function getMethod() { if ($this->method === null) { if (is_null($this->method_override)) { $this->method = $this->server->get('request-method'); } else { $this->method = $this->method_override; } $this->method = strtoupper($this->method); } return $this->method; }
[ "public", "function", "getMethod", "(", ")", "{", "if", "(", "$", "this", "->", "method", "===", "null", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "method_override", ")", ")", "{", "$", "this", "->", "method", "=", "$", "this", "->", "server", "->", "get", "(", "'request-method'", ")", ";", "}", "else", "{", "$", "this", "->", "method", "=", "$", "this", "->", "method_override", ";", "}", "$", "this", "->", "method", "=", "strtoupper", "(", "$", "this", "->", "method", ")", ";", "}", "return", "$", "this", "->", "method", ";", "}" ]
Get Http Method to lower case. @return string
[ "Get", "Http", "Method", "to", "lower", "case", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L62-L73
237,266
Jinxes/layton
Layton/Library/Http/Request.php
Request.getBodyParams
public function getBodyParams() { if (is_array($this->bodyParams)) { return $this->bodyParams; } $content = $this->getBody()->getContents(); $contentType = $this->headers->get('content-type'); if ($contentType === 'application/json') { $bodyParams = json_decode($content, true); $this->bodyParams = $bodyParams ? $bodyParams : []; } else { parse_str($content, $this->bodyParams); } return $this->bodyParams; }
php
public function getBodyParams() { if (is_array($this->bodyParams)) { return $this->bodyParams; } $content = $this->getBody()->getContents(); $contentType = $this->headers->get('content-type'); if ($contentType === 'application/json') { $bodyParams = json_decode($content, true); $this->bodyParams = $bodyParams ? $bodyParams : []; } else { parse_str($content, $this->bodyParams); } return $this->bodyParams; }
[ "public", "function", "getBodyParams", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "bodyParams", ")", ")", "{", "return", "$", "this", "->", "bodyParams", ";", "}", "$", "content", "=", "$", "this", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ";", "$", "contentType", "=", "$", "this", "->", "headers", "->", "get", "(", "'content-type'", ")", ";", "if", "(", "$", "contentType", "===", "'application/json'", ")", "{", "$", "bodyParams", "=", "json_decode", "(", "$", "content", ",", "true", ")", ";", "$", "this", "->", "bodyParams", "=", "$", "bodyParams", "?", "$", "bodyParams", ":", "[", "]", ";", "}", "else", "{", "parse_str", "(", "$", "content", ",", "$", "this", "->", "bodyParams", ")", ";", "}", "return", "$", "this", "->", "bodyParams", ";", "}" ]
Get all params of input body. @return array
[ "Get", "all", "params", "of", "input", "body", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L176-L191
237,267
Jinxes/layton
Layton/Library/Http/Request.php
Request.getBodyParam
public function getBodyParam($key, $default = null) { $params = $this->getBodyParams(); if (array_key_exists($key, $params)) { return $params[$key]; } return $default; }
php
public function getBodyParam($key, $default = null) { $params = $this->getBodyParams(); if (array_key_exists($key, $params)) { return $params[$key]; } return $default; }
[ "public", "function", "getBodyParam", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "$", "params", "=", "$", "this", "->", "getBodyParams", "(", ")", ";", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "params", ")", ")", "{", "return", "$", "params", "[", "$", "key", "]", ";", "}", "return", "$", "default", ";", "}" ]
Get one param of input body. @param string $key @return mixed
[ "Get", "one", "param", "of", "input", "body", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L200-L207
237,268
Jinxes/layton
Layton/Library/Http/Request.php
Request.withBodyParam
public function withBodyParam($key, $value) { $params = $this->getBodyParams(); $params[$key] = $value; $this->bodyParams = $params; }
php
public function withBodyParam($key, $value) { $params = $this->getBodyParams(); $params[$key] = $value; $this->bodyParams = $params; }
[ "public", "function", "withBodyParam", "(", "$", "key", ",", "$", "value", ")", "{", "$", "params", "=", "$", "this", "->", "getBodyParams", "(", ")", ";", "$", "params", "[", "$", "key", "]", "=", "$", "value", ";", "$", "this", "->", "bodyParams", "=", "$", "params", ";", "}" ]
Set a body param. @param string $key @param string $value
[ "Set", "a", "body", "param", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L215-L220
237,269
Jinxes/layton
Layton/Library/Http/Request.php
Request.withBodyParams
public function withBodyParams(array $values) { $params = $this->getBodyParams(); foreach ($values as $key => $value) { $params[$key] = $value; } $this->bodyParams = $params; }
php
public function withBodyParams(array $values) { $params = $this->getBodyParams(); foreach ($values as $key => $value) { $params[$key] = $value; } $this->bodyParams = $params; }
[ "public", "function", "withBodyParams", "(", "array", "$", "values", ")", "{", "$", "params", "=", "$", "this", "->", "getBodyParams", "(", ")", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "params", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "this", "->", "bodyParams", "=", "$", "params", ";", "}" ]
Set many body param. @param array $values
[ "Set", "many", "body", "param", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L227-L234
237,270
Jinxes/layton
Layton/Library/Http/Request.php
Request.getQueryParams
public function getQueryParams() { if (is_array($this->queryParams)) { return $this->queryParams; } if (empty($_SERVER['QUERY_STRING'])) { return []; } parse_str($_SERVER['QUERY_STRING'], $this->queryParams); return $this->queryParams; }
php
public function getQueryParams() { if (is_array($this->queryParams)) { return $this->queryParams; } if (empty($_SERVER['QUERY_STRING'])) { return []; } parse_str($_SERVER['QUERY_STRING'], $this->queryParams); return $this->queryParams; }
[ "public", "function", "getQueryParams", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "queryParams", ")", ")", "{", "return", "$", "this", "->", "queryParams", ";", "}", "if", "(", "empty", "(", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ")", ")", "{", "return", "[", "]", ";", "}", "parse_str", "(", "$", "_SERVER", "[", "'QUERY_STRING'", "]", ",", "$", "this", "->", "queryParams", ")", ";", "return", "$", "this", "->", "queryParams", ";", "}" ]
Get url params. @return array
[ "Get", "url", "params", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L241-L254
237,271
Jinxes/layton
Layton/Library/Http/Request.php
Request.withQueryParams
public function withQueryParams(array $query) { $params = $this->getQueryParams(); foreach ($query as $key => $value) { $params[$key] = $value; } $this->queryParams = $params; }
php
public function withQueryParams(array $query) { $params = $this->getQueryParams(); foreach ($query as $key => $value) { $params[$key] = $value; } $this->queryParams = $params; }
[ "public", "function", "withQueryParams", "(", "array", "$", "query", ")", "{", "$", "params", "=", "$", "this", "->", "getQueryParams", "(", ")", ";", "foreach", "(", "$", "query", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "params", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "this", "->", "queryParams", "=", "$", "params", ";", "}" ]
Set many query param. @param array $values
[ "Set", "many", "query", "param", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L261-L270
237,272
Jinxes/layton
Layton/Library/Http/Request.php
Request.withQueryParam
public function withQueryParam($key, $value) { $params = $this->getQueryParams(); $params[$key] = $value; $this->queryParams = $params; }
php
public function withQueryParam($key, $value) { $params = $this->getQueryParams(); $params[$key] = $value; $this->queryParams = $params; }
[ "public", "function", "withQueryParam", "(", "$", "key", ",", "$", "value", ")", "{", "$", "params", "=", "$", "this", "->", "getQueryParams", "(", ")", ";", "$", "params", "[", "$", "key", "]", "=", "$", "value", ";", "$", "this", "->", "queryParams", "=", "$", "params", ";", "}" ]
Set a query param. @param string $key @param string $value
[ "Set", "a", "query", "param", "." ]
27b8eab2c59b9887eb93e40a533eb77cc5690584
https://github.com/Jinxes/layton/blob/27b8eab2c59b9887eb93e40a533eb77cc5690584/Layton/Library/Http/Request.php#L278-L283
237,273
mostofreddy/resty
src/Api.php
Api.redefineErrorHandlers
protected function redefineErrorHandlers(&$container) { // Redefine - errors $container['errorHandler'] = BuilderJsonErrorResponses::jsonError(); $container['phpErrorHandler'] = BuilderJsonErrorResponses::jsonPhpError(); $container['notFoundHandler'] = BuilderJsonErrorResponses::jsonNotFound(); $container['notAllowedHandler'] = BuilderJsonErrorResponses::jsonNotAllowed(); }
php
protected function redefineErrorHandlers(&$container) { // Redefine - errors $container['errorHandler'] = BuilderJsonErrorResponses::jsonError(); $container['phpErrorHandler'] = BuilderJsonErrorResponses::jsonPhpError(); $container['notFoundHandler'] = BuilderJsonErrorResponses::jsonNotFound(); $container['notAllowedHandler'] = BuilderJsonErrorResponses::jsonNotAllowed(); }
[ "protected", "function", "redefineErrorHandlers", "(", "&", "$", "container", ")", "{", "// Redefine - errors", "$", "container", "[", "'errorHandler'", "]", "=", "BuilderJsonErrorResponses", "::", "jsonError", "(", ")", ";", "$", "container", "[", "'phpErrorHandler'", "]", "=", "BuilderJsonErrorResponses", "::", "jsonPhpError", "(", ")", ";", "$", "container", "[", "'notFoundHandler'", "]", "=", "BuilderJsonErrorResponses", "::", "jsonNotFound", "(", ")", ";", "$", "container", "[", "'notAllowedHandler'", "]", "=", "BuilderJsonErrorResponses", "::", "jsonNotAllowed", "(", ")", ";", "}" ]
Redefine error handlers @param array|ContainerInterface $container Instancia de Container o array de configuración. @return void
[ "Redefine", "error", "handlers" ]
e20d8596bb14ee6db99aded82ed0221cc6d08462
https://github.com/mostofreddy/resty/blob/e20d8596bb14ee6db99aded82ed0221cc6d08462/src/Api.php#L60-L67
237,274
mostofreddy/resty
src/Api.php
Api.redefineResponse
protected function redefineResponse(&$container) { // Redefine - response $container['response'] = function (Container $container) { $headers = new Headers(['Content-Type' => 'application/json;charset=utf-8']); $response = new Response(200, $headers); return $response->withProtocolVersion($container->get('settings')['httpVersion']); }; }
php
protected function redefineResponse(&$container) { // Redefine - response $container['response'] = function (Container $container) { $headers = new Headers(['Content-Type' => 'application/json;charset=utf-8']); $response = new Response(200, $headers); return $response->withProtocolVersion($container->get('settings')['httpVersion']); }; }
[ "protected", "function", "redefineResponse", "(", "&", "$", "container", ")", "{", "// Redefine - response", "$", "container", "[", "'response'", "]", "=", "function", "(", "Container", "$", "container", ")", "{", "$", "headers", "=", "new", "Headers", "(", "[", "'Content-Type'", "=>", "'application/json;charset=utf-8'", "]", ")", ";", "$", "response", "=", "new", "Response", "(", "200", ",", "$", "headers", ")", ";", "return", "$", "response", "->", "withProtocolVersion", "(", "$", "container", "->", "get", "(", "'settings'", ")", "[", "'httpVersion'", "]", ")", ";", "}", ";", "}" ]
Redefine Response object @param array|ContainerInterface $container Instancia de Container o array de configuración. @return void
[ "Redefine", "Response", "object" ]
e20d8596bb14ee6db99aded82ed0221cc6d08462
https://github.com/mostofreddy/resty/blob/e20d8596bb14ee6db99aded82ed0221cc6d08462/src/Api.php#L76-L84
237,275
remote-office/libx
src/External/SimplePay/Authenticator.php
Authenticator.setAuthenticationUrl
public function setAuthenticationUrl($authenticationUrl) { if(!is_string($authenticationUrl) || strlen(trim($authenticationUrl)) == 0) throw new InvalidArgumentException(__METHOD__ . '; Invalid authentication url, must be a non empty string'); $this->authenticationUrl = $authenticationUrl; }
php
public function setAuthenticationUrl($authenticationUrl) { if(!is_string($authenticationUrl) || strlen(trim($authenticationUrl)) == 0) throw new InvalidArgumentException(__METHOD__ . '; Invalid authentication url, must be a non empty string'); $this->authenticationUrl = $authenticationUrl; }
[ "public", "function", "setAuthenticationUrl", "(", "$", "authenticationUrl", ")", "{", "if", "(", "!", "is_string", "(", "$", "authenticationUrl", ")", "||", "strlen", "(", "trim", "(", "$", "authenticationUrl", ")", ")", "==", "0", ")", "throw", "new", "InvalidArgumentException", "(", "__METHOD__", ".", "'; Invalid authentication url, must be a non empty string'", ")", ";", "$", "this", "->", "authenticationUrl", "=", "$", "authenticationUrl", ";", "}" ]
Set authentication url of this Authenticator @param string $authenticationUrl @return void
[ "Set", "authentication", "url", "of", "this", "Authenticator" ]
8baeaae99a6110e7c588bc0388df89a0dc0768b5
https://github.com/remote-office/libx/blob/8baeaae99a6110e7c588bc0388df89a0dc0768b5/src/External/SimplePay/Authenticator.php#L100-L106
237,276
samsonos/cms_input
src/Field.php
Field.save
public function save($value, & $response = null) { /** @var mixed $previousValue Previous instance value for transfer in event handlers */ $previousValue = $this->dbObject[$this->param]; // Set field value $this->dbObject[$this->param] = $this->convert($value); // Create new event on object updating Event::fire('samson.cms.input.change', array(& $this->dbObject, $this->param, $previousValue, & $response)); // Save object $this->dbObject->save(); }
php
public function save($value, & $response = null) { /** @var mixed $previousValue Previous instance value for transfer in event handlers */ $previousValue = $this->dbObject[$this->param]; // Set field value $this->dbObject[$this->param] = $this->convert($value); // Create new event on object updating Event::fire('samson.cms.input.change', array(& $this->dbObject, $this->param, $previousValue, & $response)); // Save object $this->dbObject->save(); }
[ "public", "function", "save", "(", "$", "value", ",", "&", "$", "response", "=", "null", ")", "{", "/** @var mixed $previousValue Previous instance value for transfer in event handlers */", "$", "previousValue", "=", "$", "this", "->", "dbObject", "[", "$", "this", "->", "param", "]", ";", "// Set field value", "$", "this", "->", "dbObject", "[", "$", "this", "->", "param", "]", "=", "$", "this", "->", "convert", "(", "$", "value", ")", ";", "// Create new event on object updating", "Event", "::", "fire", "(", "'samson.cms.input.change'", ",", "array", "(", "&", "$", "this", "->", "dbObject", ",", "$", "this", "->", "param", ",", "$", "previousValue", ",", "&", "$", "response", ")", ")", ";", "// Save object", "$", "this", "->", "dbObject", "->", "save", "(", ")", ";", "}" ]
Save input field value @param mixed $value Field value
[ "Save", "input", "field", "value" ]
88df132aba488e403265ddaa0b1d54f12def8173
https://github.com/samsonos/cms_input/blob/88df132aba488e403265ddaa0b1d54f12def8173/src/Field.php#L102-L115
237,277
samsonos/cms_input
src/Field.php
Field.view
public function view($renderer, $saveHandler = 'save') { // TODO: Context rewriting if in one chain! $fieldView = $this->viewField($renderer); return $renderer->view($this->defaultView) ->set($this->cssClass, 'cssClass') ->set($this->value(), 'value') ->set(url_build(preg_replace('/(_\d+)/', '', $renderer->id()), $saveHandler), 'action') ->set($this->entity, 'entity') ->set($this->param, 'param') ->set($this->dbObject->id, 'objectId') ->set($renderer->id(), 'applicationId') ->set($fieldView, 'fieldView') ->output(); }
php
public function view($renderer, $saveHandler = 'save') { // TODO: Context rewriting if in one chain! $fieldView = $this->viewField($renderer); return $renderer->view($this->defaultView) ->set($this->cssClass, 'cssClass') ->set($this->value(), 'value') ->set(url_build(preg_replace('/(_\d+)/', '', $renderer->id()), $saveHandler), 'action') ->set($this->entity, 'entity') ->set($this->param, 'param') ->set($this->dbObject->id, 'objectId') ->set($renderer->id(), 'applicationId') ->set($fieldView, 'fieldView') ->output(); }
[ "public", "function", "view", "(", "$", "renderer", ",", "$", "saveHandler", "=", "'save'", ")", "{", "// TODO: Context rewriting if in one chain!", "$", "fieldView", "=", "$", "this", "->", "viewField", "(", "$", "renderer", ")", ";", "return", "$", "renderer", "->", "view", "(", "$", "this", "->", "defaultView", ")", "->", "set", "(", "$", "this", "->", "cssClass", ",", "'cssClass'", ")", "->", "set", "(", "$", "this", "->", "value", "(", ")", ",", "'value'", ")", "->", "set", "(", "url_build", "(", "preg_replace", "(", "'/(_\\d+)/'", ",", "''", ",", "$", "renderer", "->", "id", "(", ")", ")", ",", "$", "saveHandler", ")", ",", "'action'", ")", "->", "set", "(", "$", "this", "->", "entity", ",", "'entity'", ")", "->", "set", "(", "$", "this", "->", "param", ",", "'param'", ")", "->", "set", "(", "$", "this", "->", "dbObject", "->", "id", ",", "'objectId'", ")", "->", "set", "(", "$", "renderer", "->", "id", "(", ")", ",", "'applicationId'", ")", "->", "set", "(", "$", "fieldView", ",", "'fieldView'", ")", "->", "output", "(", ")", ";", "}" ]
Function to render class @param Application $renderer Renderer object @param string $saveHandler Save controller name @return string HTML string
[ "Function", "to", "render", "class" ]
88df132aba488e403265ddaa0b1d54f12def8173
https://github.com/samsonos/cms_input/blob/88df132aba488e403265ddaa0b1d54f12def8173/src/Field.php#L138-L152
237,278
Niirrty/Niirrty.IO.VFS
src/VfsHandler.php
VfsHandler.setProtocol
public function setProtocol( string $name, string $separator = '://' ) : VfsHandler { $this->_protocolName = $name ?? ''; $this->_protocolSeparator = $separator ?? ''; return $this; }
php
public function setProtocol( string $name, string $separator = '://' ) : VfsHandler { $this->_protocolName = $name ?? ''; $this->_protocolSeparator = $separator ?? ''; return $this; }
[ "public", "function", "setProtocol", "(", "string", "$", "name", ",", "string", "$", "separator", "=", "'://'", ")", ":", "VfsHandler", "{", "$", "this", "->", "_protocolName", "=", "$", "name", "??", "''", ";", "$", "this", "->", "_protocolSeparator", "=", "$", "separator", "??", "''", ";", "return", "$", "this", ";", "}" ]
Sets the VFS protocol name and separator. @param string $name @param string $separator @return \Niirrty\IO\Vfs\VfsHandler
[ "Sets", "the", "VFS", "protocol", "name", "and", "separator", "." ]
cd5aaea57a27c712a0b6656b5d068aa7a317dbfc
https://github.com/Niirrty/Niirrty.IO.VFS/blob/cd5aaea57a27c712a0b6656b5d068aa7a317dbfc/src/VfsHandler.php#L99-L107
237,279
Niirrty/Niirrty.IO.VFS
src/VfsHandler.php
VfsHandler.addReplacement
public function addReplacement( string $name, ?string $value ) : VfsHandler { if ( null === $value ) { unset( $this->_replacements[ $name ] ); return $this; } $this->_replacements[ $name ] = $value; return $this; }
php
public function addReplacement( string $name, ?string $value ) : VfsHandler { if ( null === $value ) { unset( $this->_replacements[ $name ] ); return $this; } $this->_replacements[ $name ] = $value; return $this; }
[ "public", "function", "addReplacement", "(", "string", "$", "name", ",", "?", "string", "$", "value", ")", ":", "VfsHandler", "{", "if", "(", "null", "===", "$", "value", ")", "{", "unset", "(", "$", "this", "->", "_replacements", "[", "$", "name", "]", ")", ";", "return", "$", "this", ";", "}", "$", "this", "->", "_replacements", "[", "$", "name", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Add or set a replacement. It replaces a part of a path with format ${replacementName} @param string $name The name of the replacement @param string|null $value The replacement string value (or NULL to remove a replacement) @return \Niirrty\IO\Vfs\VfsHandler
[ "Add", "or", "set", "a", "replacement", "." ]
cd5aaea57a27c712a0b6656b5d068aa7a317dbfc
https://github.com/Niirrty/Niirrty.IO.VFS/blob/cd5aaea57a27c712a0b6656b5d068aa7a317dbfc/src/VfsHandler.php#L245-L261
237,280
Niirrty/Niirrty.IO.VFS
src/VfsHandler.php
VfsHandler.addReplacements
public function addReplacements( array $replacements ) : VfsHandler { foreach ( $replacements as $name => $value ) { if ( null === $value ) { unset( $this->_replacements[ $name ] ); continue; } $this->_replacements[ $name ] = $value; } return $this; }
php
public function addReplacements( array $replacements ) : VfsHandler { foreach ( $replacements as $name => $value ) { if ( null === $value ) { unset( $this->_replacements[ $name ] ); continue; } $this->_replacements[ $name ] = $value; } return $this; }
[ "public", "function", "addReplacements", "(", "array", "$", "replacements", ")", ":", "VfsHandler", "{", "foreach", "(", "$", "replacements", "as", "$", "name", "=>", "$", "value", ")", "{", "if", "(", "null", "===", "$", "value", ")", "{", "unset", "(", "$", "this", "->", "_replacements", "[", "$", "name", "]", ")", ";", "continue", ";", "}", "$", "this", "->", "_replacements", "[", "$", "name", "]", "=", "$", "value", ";", "}", "return", "$", "this", ";", "}" ]
Add or set one or more replacements. It replaces a part of a path with format ${replacementName} @param array $replacements Associative array with replacements (keys are the names) @return \Niirrty\IO\Vfs\VfsHandler
[ "Add", "or", "set", "one", "or", "more", "replacements", "." ]
cd5aaea57a27c712a0b6656b5d068aa7a317dbfc
https://github.com/Niirrty/Niirrty.IO.VFS/blob/cd5aaea57a27c712a0b6656b5d068aa7a317dbfc/src/VfsHandler.php#L271-L289
237,281
Niirrty/Niirrty.IO.VFS
src/VfsHandler.php
VfsHandler.tryParse
public function tryParse( string &$pathRef, array $dynamicReplacements = [] ) : bool { $protocol = $this->getProtocol(); if ( '' === $protocol || ! strStartsWith( $pathRef, $protocol ) ) { return false; } if ( \count( $dynamicReplacements ) > 0 ) { $this->addReplacements( $dynamicReplacements ); } $pathRef = $this->_rootFolder . DIRECTORY_SEPARATOR . substring( $pathRef, \mb_strlen( $protocol ) ); $pathRef = \preg_replace_callback( '~\$\{([A-Za-z0-9_.-]+)\}~', function ( $matches ) { if ( ! isset( $this->_replacements[ $matches[ 1 ] ] ) ) { return $matches[ 0 ]; } return $this->_replacements[ $matches[ 1 ] ]; }, $pathRef ); return true; }
php
public function tryParse( string &$pathRef, array $dynamicReplacements = [] ) : bool { $protocol = $this->getProtocol(); if ( '' === $protocol || ! strStartsWith( $pathRef, $protocol ) ) { return false; } if ( \count( $dynamicReplacements ) > 0 ) { $this->addReplacements( $dynamicReplacements ); } $pathRef = $this->_rootFolder . DIRECTORY_SEPARATOR . substring( $pathRef, \mb_strlen( $protocol ) ); $pathRef = \preg_replace_callback( '~\$\{([A-Za-z0-9_.-]+)\}~', function ( $matches ) { if ( ! isset( $this->_replacements[ $matches[ 1 ] ] ) ) { return $matches[ 0 ]; } return $this->_replacements[ $matches[ 1 ] ]; }, $pathRef ); return true; }
[ "public", "function", "tryParse", "(", "string", "&", "$", "pathRef", ",", "array", "$", "dynamicReplacements", "=", "[", "]", ")", ":", "bool", "{", "$", "protocol", "=", "$", "this", "->", "getProtocol", "(", ")", ";", "if", "(", "''", "===", "$", "protocol", "||", "!", "strStartsWith", "(", "$", "pathRef", ",", "$", "protocol", ")", ")", "{", "return", "false", ";", "}", "if", "(", "\\", "count", "(", "$", "dynamicReplacements", ")", ">", "0", ")", "{", "$", "this", "->", "addReplacements", "(", "$", "dynamicReplacements", ")", ";", "}", "$", "pathRef", "=", "$", "this", "->", "_rootFolder", ".", "DIRECTORY_SEPARATOR", ".", "substring", "(", "$", "pathRef", ",", "\\", "mb_strlen", "(", "$", "protocol", ")", ")", ";", "$", "pathRef", "=", "\\", "preg_replace_callback", "(", "'~\\$\\{([A-Za-z0-9_.-]+)\\}~'", ",", "function", "(", "$", "matches", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "_replacements", "[", "$", "matches", "[", "1", "]", "]", ")", ")", "{", "return", "$", "matches", "[", "0", "]", ";", "}", "return", "$", "this", "->", "_replacements", "[", "$", "matches", "[", "1", "]", "]", ";", "}", ",", "$", "pathRef", ")", ";", "return", "true", ";", "}" ]
Tries to parse a path, using a VFS protocol and replaces the protocol with a path @param string $pathRef @param array $dynamicReplacements @return bool Return TRUE on success or false otherwise.
[ "Tries", "to", "parse", "a", "path", "using", "a", "VFS", "protocol", "and", "replaces", "the", "protocol", "with", "a", "path" ]
cd5aaea57a27c712a0b6656b5d068aa7a317dbfc
https://github.com/Niirrty/Niirrty.IO.VFS/blob/cd5aaea57a27c712a0b6656b5d068aa7a317dbfc/src/VfsHandler.php#L311-L345
237,282
alevilar/account
Model/Gasto.php
Gasto._calcularImporteNeto
private function _calcularImporteNeto(){ if (!empty($this->data['Gasto']['Impuesto']) && empty($this->data['Gasto']['importe_neto'])) { if (!empty($this->data['Gasto']['Impuesto'])) { foreach ($this->data['Gasto']['Impuesto'] as $imp){ $this->data['Gasto']['importe_neto'] += $imp['neto']; } } } }
php
private function _calcularImporteNeto(){ if (!empty($this->data['Gasto']['Impuesto']) && empty($this->data['Gasto']['importe_neto'])) { if (!empty($this->data['Gasto']['Impuesto'])) { foreach ($this->data['Gasto']['Impuesto'] as $imp){ $this->data['Gasto']['importe_neto'] += $imp['neto']; } } } }
[ "private", "function", "_calcularImporteNeto", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "data", "[", "'Gasto'", "]", "[", "'Impuesto'", "]", ")", "&&", "empty", "(", "$", "this", "->", "data", "[", "'Gasto'", "]", "[", "'importe_neto'", "]", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "data", "[", "'Gasto'", "]", "[", "'Impuesto'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "data", "[", "'Gasto'", "]", "[", "'Impuesto'", "]", "as", "$", "imp", ")", "{", "$", "this", "->", "data", "[", "'Gasto'", "]", "[", "'importe_neto'", "]", "+=", "$", "imp", "[", "'neto'", "]", ";", "}", "}", "}", "}" ]
Calcula el neto sumando los impuestos y lo setea en el data
[ "Calcula", "el", "neto", "sumando", "los", "impuestos", "y", "lo", "setea", "en", "el", "data" ]
dfb3744d2c5db2875bc49ba39132fec6946d0cca
https://github.com/alevilar/account/blob/dfb3744d2c5db2875bc49ba39132fec6946d0cca/Model/Gasto.php#L278-L286
237,283
alevilar/account
Model/Gasto.php
Gasto._refreshImpuestos
private function _refreshImpuestos($created){ if (!empty($this->data['Gasto']['Impuesto'])) { if (!$created){ $this->Impuesto->deleteAll(array('Impuesto.gasto_id'=>$this->id )); } foreach ($this->data['Gasto']['Impuesto'] as $impId=>$imp){ if (!empty($imp)) { if (!empty($imp['checked']) && (!empty($imp['importe']) || !empty($imp['neto'])) ) { $importe = empty($imp['importe'])?0:$imp['importe']; $neto = empty($imp['neto'])?0:$imp['neto']; $nuevoImp = array( 'gasto_id' => $this->id, 'tipo_impuesto_id' => $impId, 'importe' => $importe, 'neto' => $neto, ); $this->Impuesto->create($nuevoImp); if (!$this->Impuesto->save()){ return false; } } } } } return true; }
php
private function _refreshImpuestos($created){ if (!empty($this->data['Gasto']['Impuesto'])) { if (!$created){ $this->Impuesto->deleteAll(array('Impuesto.gasto_id'=>$this->id )); } foreach ($this->data['Gasto']['Impuesto'] as $impId=>$imp){ if (!empty($imp)) { if (!empty($imp['checked']) && (!empty($imp['importe']) || !empty($imp['neto'])) ) { $importe = empty($imp['importe'])?0:$imp['importe']; $neto = empty($imp['neto'])?0:$imp['neto']; $nuevoImp = array( 'gasto_id' => $this->id, 'tipo_impuesto_id' => $impId, 'importe' => $importe, 'neto' => $neto, ); $this->Impuesto->create($nuevoImp); if (!$this->Impuesto->save()){ return false; } } } } } return true; }
[ "private", "function", "_refreshImpuestos", "(", "$", "created", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "data", "[", "'Gasto'", "]", "[", "'Impuesto'", "]", ")", ")", "{", "if", "(", "!", "$", "created", ")", "{", "$", "this", "->", "Impuesto", "->", "deleteAll", "(", "array", "(", "'Impuesto.gasto_id'", "=>", "$", "this", "->", "id", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "data", "[", "'Gasto'", "]", "[", "'Impuesto'", "]", "as", "$", "impId", "=>", "$", "imp", ")", "{", "if", "(", "!", "empty", "(", "$", "imp", ")", ")", "{", "if", "(", "!", "empty", "(", "$", "imp", "[", "'checked'", "]", ")", "&&", "(", "!", "empty", "(", "$", "imp", "[", "'importe'", "]", ")", "||", "!", "empty", "(", "$", "imp", "[", "'neto'", "]", ")", ")", ")", "{", "$", "importe", "=", "empty", "(", "$", "imp", "[", "'importe'", "]", ")", "?", "0", ":", "$", "imp", "[", "'importe'", "]", ";", "$", "neto", "=", "empty", "(", "$", "imp", "[", "'neto'", "]", ")", "?", "0", ":", "$", "imp", "[", "'neto'", "]", ";", "$", "nuevoImp", "=", "array", "(", "'gasto_id'", "=>", "$", "this", "->", "id", ",", "'tipo_impuesto_id'", "=>", "$", "impId", ",", "'importe'", "=>", "$", "importe", ",", "'neto'", "=>", "$", "neto", ",", ")", ";", "$", "this", "->", "Impuesto", "->", "create", "(", "$", "nuevoImp", ")", ";", "if", "(", "!", "$", "this", "->", "Impuesto", "->", "save", "(", ")", ")", "{", "return", "false", ";", "}", "}", "}", "}", "}", "return", "true", ";", "}" ]
Ante un cambio en e gasto, resetea los valores anteriores @param boolean $created @return boolean
[ "Ante", "un", "cambio", "en", "e", "gasto", "resetea", "los", "valores", "anteriores" ]
dfb3744d2c5db2875bc49ba39132fec6946d0cca
https://github.com/alevilar/account/blob/dfb3744d2c5db2875bc49ba39132fec6946d0cca/Model/Gasto.php#L293-L319
237,284
alevilar/account
Model/Gasto.php
Gasto.enDeuda
public function enDeuda($conditions = array()){ $dbo = $this->getDataSource(); $subQuery = $dbo->buildStatement( array( 'fields' => array('SUM( `Aeg`.`importe` )'), 'table' => 'account_egresos_gastos', 'alias' => 'Aeg', 'limit' => null, 'offset' => null, 'joins' => array(), 'conditions' => array( 'Aeg.gasto_id = `Gasto`.`id`', ), 'order' => null, 'group' => array('Aeg.gasto_id') ), $this ); $conditions[] = "IFNULL(($subQuery), 0) <> `Gasto`.`importe_total`"; $fieldContain['recursive'] = -1; $fieldContain['fields'] = array('Gasto.id','Gasto.id'); $fieldContain['conditions'] = $conditions; $ret = parent::find('list', $fieldContain); $gastos = $this->find('all', array('conditions'=>array('Gasto.id'=>$ret))); return $gastos; }
php
public function enDeuda($conditions = array()){ $dbo = $this->getDataSource(); $subQuery = $dbo->buildStatement( array( 'fields' => array('SUM( `Aeg`.`importe` )'), 'table' => 'account_egresos_gastos', 'alias' => 'Aeg', 'limit' => null, 'offset' => null, 'joins' => array(), 'conditions' => array( 'Aeg.gasto_id = `Gasto`.`id`', ), 'order' => null, 'group' => array('Aeg.gasto_id') ), $this ); $conditions[] = "IFNULL(($subQuery), 0) <> `Gasto`.`importe_total`"; $fieldContain['recursive'] = -1; $fieldContain['fields'] = array('Gasto.id','Gasto.id'); $fieldContain['conditions'] = $conditions; $ret = parent::find('list', $fieldContain); $gastos = $this->find('all', array('conditions'=>array('Gasto.id'=>$ret))); return $gastos; }
[ "public", "function", "enDeuda", "(", "$", "conditions", "=", "array", "(", ")", ")", "{", "$", "dbo", "=", "$", "this", "->", "getDataSource", "(", ")", ";", "$", "subQuery", "=", "$", "dbo", "->", "buildStatement", "(", "array", "(", "'fields'", "=>", "array", "(", "'SUM( `Aeg`.`importe` )'", ")", ",", "'table'", "=>", "'account_egresos_gastos'", ",", "'alias'", "=>", "'Aeg'", ",", "'limit'", "=>", "null", ",", "'offset'", "=>", "null", ",", "'joins'", "=>", "array", "(", ")", ",", "'conditions'", "=>", "array", "(", "'Aeg.gasto_id = `Gasto`.`id`'", ",", ")", ",", "'order'", "=>", "null", ",", "'group'", "=>", "array", "(", "'Aeg.gasto_id'", ")", ")", ",", "$", "this", ")", ";", "$", "conditions", "[", "]", "=", "\"IFNULL(($subQuery), 0) <> `Gasto`.`importe_total`\"", ";", "$", "fieldContain", "[", "'recursive'", "]", "=", "-", "1", ";", "$", "fieldContain", "[", "'fields'", "]", "=", "array", "(", "'Gasto.id'", ",", "'Gasto.id'", ")", ";", "$", "fieldContain", "[", "'conditions'", "]", "=", "$", "conditions", ";", "$", "ret", "=", "parent", "::", "find", "(", "'list'", ",", "$", "fieldContain", ")", ";", "$", "gastos", "=", "$", "this", "->", "find", "(", "'all'", ",", "array", "(", "'conditions'", "=>", "array", "(", "'Gasto.id'", "=>", "$", "ret", ")", ")", ")", ";", "return", "$", "gastos", ";", "}" ]
Devuelve todos los gastos que adeudan pagos o sea, cuyo importe_total no llega a ser cubierto con los pagos realizados @return array de Gastos
[ "Devuelve", "todos", "los", "gastos", "que", "adeudan", "pagos", "o", "sea", "cuyo", "importe_total", "no", "llega", "a", "ser", "cubierto", "con", "los", "pagos", "realizados" ]
dfb3744d2c5db2875bc49ba39132fec6946d0cca
https://github.com/alevilar/account/blob/dfb3744d2c5db2875bc49ba39132fec6946d0cca/Model/Gasto.php#L327-L356
237,285
alevilar/account
Model/Gasto.php
Gasto.importePagado
public function importePagado($id = null){ $importePagado = 0; if (empty($id)) { $id = $this->id; } $fieldContain['recursive'] = -1; $fieldContain['contain'] = 'Egreso'; $fieldContain['conditions'] = array('Gasto.id'=>$id); $coso = parent::find('first', $fieldContain); if (!empty($coso['Egreso'])) { foreach ($coso['Egreso'] as $eg){ if ($eg['AccountEgresosGasto']['gasto_id'] == $id ) { $importePagado += $eg['AccountEgresosGasto']['importe']; } } } return $importePagado; }
php
public function importePagado($id = null){ $importePagado = 0; if (empty($id)) { $id = $this->id; } $fieldContain['recursive'] = -1; $fieldContain['contain'] = 'Egreso'; $fieldContain['conditions'] = array('Gasto.id'=>$id); $coso = parent::find('first', $fieldContain); if (!empty($coso['Egreso'])) { foreach ($coso['Egreso'] as $eg){ if ($eg['AccountEgresosGasto']['gasto_id'] == $id ) { $importePagado += $eg['AccountEgresosGasto']['importe']; } } } return $importePagado; }
[ "public", "function", "importePagado", "(", "$", "id", "=", "null", ")", "{", "$", "importePagado", "=", "0", ";", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "$", "id", "=", "$", "this", "->", "id", ";", "}", "$", "fieldContain", "[", "'recursive'", "]", "=", "-", "1", ";", "$", "fieldContain", "[", "'contain'", "]", "=", "'Egreso'", ";", "$", "fieldContain", "[", "'conditions'", "]", "=", "array", "(", "'Gasto.id'", "=>", "$", "id", ")", ";", "$", "coso", "=", "parent", "::", "find", "(", "'first'", ",", "$", "fieldContain", ")", ";", "if", "(", "!", "empty", "(", "$", "coso", "[", "'Egreso'", "]", ")", ")", "{", "foreach", "(", "$", "coso", "[", "'Egreso'", "]", "as", "$", "eg", ")", "{", "if", "(", "$", "eg", "[", "'AccountEgresosGasto'", "]", "[", "'gasto_id'", "]", "==", "$", "id", ")", "{", "$", "importePagado", "+=", "$", "eg", "[", "'AccountEgresosGasto'", "]", "[", "'importe'", "]", ";", "}", "}", "}", "return", "$", "importePagado", ";", "}" ]
Indica la sumatoria de todos los pagos realizados para ese gasto @param integer $id gasto_id @return $ importe pagado
[ "Indica", "la", "sumatoria", "de", "todos", "los", "pagos", "realizados", "para", "ese", "gasto" ]
dfb3744d2c5db2875bc49ba39132fec6946d0cca
https://github.com/alevilar/account/blob/dfb3744d2c5db2875bc49ba39132fec6946d0cca/Model/Gasto.php#L365-L385
237,286
arnold-almeida/UIKit
src/Almeida/UIKit/Collections/Tables/AbstractTable.php
AbstractTable.extractHeaders
protected function extractHeaders($data) { $headers = array_keys($data[0]); // Remove hidden fields from headers if supplied foreach ($this->options['hiddenFields'] as $hiddenField) { if (in_array($hiddenField, $headers)) { array_splice($headers, array_search($hiddenField, $headers), 1); } } if (!empty($this->options['actions'])) { $headers[] = 'Actions'; } return $headers; }
php
protected function extractHeaders($data) { $headers = array_keys($data[0]); // Remove hidden fields from headers if supplied foreach ($this->options['hiddenFields'] as $hiddenField) { if (in_array($hiddenField, $headers)) { array_splice($headers, array_search($hiddenField, $headers), 1); } } if (!empty($this->options['actions'])) { $headers[] = 'Actions'; } return $headers; }
[ "protected", "function", "extractHeaders", "(", "$", "data", ")", "{", "$", "headers", "=", "array_keys", "(", "$", "data", "[", "0", "]", ")", ";", "// Remove hidden fields from headers if supplied", "foreach", "(", "$", "this", "->", "options", "[", "'hiddenFields'", "]", "as", "$", "hiddenField", ")", "{", "if", "(", "in_array", "(", "$", "hiddenField", ",", "$", "headers", ")", ")", "{", "array_splice", "(", "$", "headers", ",", "array_search", "(", "$", "hiddenField", ",", "$", "headers", ")", ",", "1", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "options", "[", "'actions'", "]", ")", ")", "{", "$", "headers", "[", "]", "=", "'Actions'", ";", "}", "return", "$", "headers", ";", "}" ]
Get Table headers from data
[ "Get", "Table", "headers", "from", "data" ]
cc52f46df011ec2f3676245c90c376da20c40e41
https://github.com/arnold-almeida/UIKit/blob/cc52f46df011ec2f3676245c90c376da20c40e41/src/Almeida/UIKit/Collections/Tables/AbstractTable.php#L195-L211
237,287
hamjoint/mustard-commerce
src/lib/Purchase.php
Purchase.getGrandTotalAttribute
public function getGrandTotalAttribute() { if (!$this->deliveryOption) return $this->total; return (float) round($this->total + $this->deliveryOption->price, 2); }
php
public function getGrandTotalAttribute() { if (!$this->deliveryOption) return $this->total; return (float) round($this->total + $this->deliveryOption->price, 2); }
[ "public", "function", "getGrandTotalAttribute", "(", ")", "{", "if", "(", "!", "$", "this", "->", "deliveryOption", ")", "return", "$", "this", "->", "total", ";", "return", "(", "float", ")", "round", "(", "$", "this", "->", "total", "+", "$", "this", "->", "deliveryOption", "->", "price", ",", "2", ")", ";", "}" ]
Calculate grand total in respect to quantity and delivery. @return float
[ "Calculate", "grand", "total", "in", "respect", "to", "quantity", "and", "delivery", "." ]
886caeb5a88d827c8e9201e90020b64651dd87ad
https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/Purchase.php#L95-L100
237,288
hamjoint/mustard-commerce
src/lib/Purchase.php
Purchase.useAddress
public function useAddress(PostalAddress $postalAddress) { $this->name = $postalAddress->name; $this->street1 = $postalAddress->street1; $this->street2 = $postalAddress->street2; $this->city = $postalAddress->city; $this->county = $postalAddress->county; $this->postcode = $postalAddress->postcode; $this->country = $postalAddress->country; }
php
public function useAddress(PostalAddress $postalAddress) { $this->name = $postalAddress->name; $this->street1 = $postalAddress->street1; $this->street2 = $postalAddress->street2; $this->city = $postalAddress->city; $this->county = $postalAddress->county; $this->postcode = $postalAddress->postcode; $this->country = $postalAddress->country; }
[ "public", "function", "useAddress", "(", "PostalAddress", "$", "postalAddress", ")", "{", "$", "this", "->", "name", "=", "$", "postalAddress", "->", "name", ";", "$", "this", "->", "street1", "=", "$", "postalAddress", "->", "street1", ";", "$", "this", "->", "street2", "=", "$", "postalAddress", "->", "street2", ";", "$", "this", "->", "city", "=", "$", "postalAddress", "->", "city", ";", "$", "this", "->", "county", "=", "$", "postalAddress", "->", "county", ";", "$", "this", "->", "postcode", "=", "$", "postalAddress", "->", "postcode", ";", "$", "this", "->", "country", "=", "$", "postalAddress", "->", "country", ";", "}" ]
Mass-assignment method for using a postal address. @param \Hamjoint\Mustard\Commerce\PostalAddress $postalAddress @return void
[ "Mass", "-", "assignment", "method", "for", "using", "a", "postal", "address", "." ]
886caeb5a88d827c8e9201e90020b64651dd87ad
https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/Purchase.php#L128-L137
237,289
hamjoint/mustard-commerce
src/lib/Purchase.php
Purchase.averageAmount
public static function averageAmount($since = 0, $until = null) { $until = $until ?: time(); return (int) self::where('created', '>=', $since) ->where('created', '<=', $until) ->avg('total'); }
php
public static function averageAmount($since = 0, $until = null) { $until = $until ?: time(); return (int) self::where('created', '>=', $since) ->where('created', '<=', $until) ->avg('total'); }
[ "public", "static", "function", "averageAmount", "(", "$", "since", "=", "0", ",", "$", "until", "=", "null", ")", "{", "$", "until", "=", "$", "until", "?", ":", "time", "(", ")", ";", "return", "(", "int", ")", "self", "::", "where", "(", "'created'", ",", "'>='", ",", "$", "since", ")", "->", "where", "(", "'created'", ",", "'<='", ",", "$", "until", ")", "->", "avg", "(", "'total'", ")", ";", "}" ]
Return the average amount of purchases. @param integer $since UNIX timestamp to optionally specify a lower selection boundary. @param integer $until UNIX timestamp to optionally specify an upper selection boundary. @return integer
[ "Return", "the", "average", "amount", "of", "purchases", "." ]
886caeb5a88d827c8e9201e90020b64651dd87ad
https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/Purchase.php#L202-L209
237,290
integratedfordevelopers/integrated-solr-bundle
Solr/Type/FieldMapperType.php
FieldMapperType.convert
protected function convert($data) { if ($data instanceof DateTime) { $data = clone $data; // don't change to original value return $data->setTimezone($this->timezone)->format('Y-m-d\TG:i:s\Z'); } if (is_object($data) && !method_exists($data, '__toString')) { return null; // can't convert object to a string. } if (is_array($data)) { return null; // can't convert a array to a string. } if (is_bool($data)) { return $data ? '1' : '0'; // would otherwise be empty if converted to a string } return $data !== null ? (string)$data : null; }
php
protected function convert($data) { if ($data instanceof DateTime) { $data = clone $data; // don't change to original value return $data->setTimezone($this->timezone)->format('Y-m-d\TG:i:s\Z'); } if (is_object($data) && !method_exists($data, '__toString')) { return null; // can't convert object to a string. } if (is_array($data)) { return null; // can't convert a array to a string. } if (is_bool($data)) { return $data ? '1' : '0'; // would otherwise be empty if converted to a string } return $data !== null ? (string)$data : null; }
[ "protected", "function", "convert", "(", "$", "data", ")", "{", "if", "(", "$", "data", "instanceof", "DateTime", ")", "{", "$", "data", "=", "clone", "$", "data", ";", "// don't change to original value", "return", "$", "data", "->", "setTimezone", "(", "$", "this", "->", "timezone", ")", "->", "format", "(", "'Y-m-d\\TG:i:s\\Z'", ")", ";", "}", "if", "(", "is_object", "(", "$", "data", ")", "&&", "!", "method_exists", "(", "$", "data", ",", "'__toString'", ")", ")", "{", "return", "null", ";", "// can't convert object to a string.", "}", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "return", "null", ";", "// can't convert a array to a string.", "}", "if", "(", "is_bool", "(", "$", "data", ")", ")", "{", "return", "$", "data", "?", "'1'", ":", "'0'", ";", "// would otherwise be empty if converted to a string", "}", "return", "$", "data", "!==", "null", "?", "(", "string", ")", "$", "data", ":", "null", ";", "}" ]
Convert the data to a string. If the value can not be converted to a string then return null. @param mixed $data @return null | string
[ "Convert", "the", "data", "to", "a", "string", "." ]
9d9bb4071e13ed4686fbc97b6286a475ac5b2162
https://github.com/integratedfordevelopers/integrated-solr-bundle/blob/9d9bb4071e13ed4686fbc97b6286a475ac5b2162/Solr/Type/FieldMapperType.php#L247-L267
237,291
integratedfordevelopers/integrated-solr-bundle
Solr/Type/FieldMapperType.php
FieldMapperType.combine
protected function combine(array $data, $separator) { $results = array_shift($data); $results = is_array($results) ? $results : [$results]; while ($value = array_shift($data)) { if (is_array($value)) { $replacement = []; foreach ($value as $array_value) { foreach ($results as $result_value) { $replacement[] = $result_value . $separator . $array_value; } } $results = $replacement; } else { foreach ($results as $key => $result_value) { $results[$key] = $result_value . $separator . $value; } } } return array_filter($results); }
php
protected function combine(array $data, $separator) { $results = array_shift($data); $results = is_array($results) ? $results : [$results]; while ($value = array_shift($data)) { if (is_array($value)) { $replacement = []; foreach ($value as $array_value) { foreach ($results as $result_value) { $replacement[] = $result_value . $separator . $array_value; } } $results = $replacement; } else { foreach ($results as $key => $result_value) { $results[$key] = $result_value . $separator . $value; } } } return array_filter($results); }
[ "protected", "function", "combine", "(", "array", "$", "data", ",", "$", "separator", ")", "{", "$", "results", "=", "array_shift", "(", "$", "data", ")", ";", "$", "results", "=", "is_array", "(", "$", "results", ")", "?", "$", "results", ":", "[", "$", "results", "]", ";", "while", "(", "$", "value", "=", "array_shift", "(", "$", "data", ")", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "replacement", "=", "[", "]", ";", "foreach", "(", "$", "value", "as", "$", "array_value", ")", "{", "foreach", "(", "$", "results", "as", "$", "result_value", ")", "{", "$", "replacement", "[", "]", "=", "$", "result_value", ".", "$", "separator", ".", "$", "array_value", ";", "}", "}", "$", "results", "=", "$", "replacement", ";", "}", "else", "{", "foreach", "(", "$", "results", "as", "$", "key", "=>", "$", "result_value", ")", "{", "$", "results", "[", "$", "key", "]", "=", "$", "result_value", ".", "$", "separator", ".", "$", "value", ";", "}", "}", "}", "return", "array_filter", "(", "$", "results", ")", ";", "}" ]
Combine all the data into strings. For every array in the data all strings will be multiplied by the number of items in that array to cover every possible string combination. @param array $data @param string $separator @return string[]
[ "Combine", "all", "the", "data", "into", "strings", "." ]
9d9bb4071e13ed4686fbc97b6286a475ac5b2162
https://github.com/integratedfordevelopers/integrated-solr-bundle/blob/9d9bb4071e13ed4686fbc97b6286a475ac5b2162/Solr/Type/FieldMapperType.php#L280-L304
237,292
tekkla/core-security
Core/Security/User/Activation.php
Activation.activateUser
public function activateUser($key) { // Get tokendate from db $tokenhandler = new ActivationToken($this->db); $tokenhandler->setSelectorTokenString($key); // Store the current to extracted from selector:token string ($key) $token_from_key = $tokenhandler->getToken(); // Load the tokendata by using the selector from selector:token string ($key) $tokenhandler->loadTokenData(); // Get user id $id_user = $tokenhandler->getUserId(); // No user id means the activation must fail if (empty($id_user)) { return false; } // Get the token loaded from db via selector from selector:token string ($key) $token_from_db = $tokenhandler->getToken(); // Matching hashes? if (!hash_equals($token_from_key, $token_from_db)) { return false; } // Activate user $this->db->qb([ 'table' => 'core_users', 'method' => 'UPDATE', 'fields' => 'state', 'filter' => 'id_user=:id_user', 'params' => [ ':state' => 0, ':id_user' => $id_user ] ], true); // and delete the token of this user $tokenhandler->deleteActivationTokenByUserId($id_user); // And finally return user id return $id_user; }
php
public function activateUser($key) { // Get tokendate from db $tokenhandler = new ActivationToken($this->db); $tokenhandler->setSelectorTokenString($key); // Store the current to extracted from selector:token string ($key) $token_from_key = $tokenhandler->getToken(); // Load the tokendata by using the selector from selector:token string ($key) $tokenhandler->loadTokenData(); // Get user id $id_user = $tokenhandler->getUserId(); // No user id means the activation must fail if (empty($id_user)) { return false; } // Get the token loaded from db via selector from selector:token string ($key) $token_from_db = $tokenhandler->getToken(); // Matching hashes? if (!hash_equals($token_from_key, $token_from_db)) { return false; } // Activate user $this->db->qb([ 'table' => 'core_users', 'method' => 'UPDATE', 'fields' => 'state', 'filter' => 'id_user=:id_user', 'params' => [ ':state' => 0, ':id_user' => $id_user ] ], true); // and delete the token of this user $tokenhandler->deleteActivationTokenByUserId($id_user); // And finally return user id return $id_user; }
[ "public", "function", "activateUser", "(", "$", "key", ")", "{", "// Get tokendate from db", "$", "tokenhandler", "=", "new", "ActivationToken", "(", "$", "this", "->", "db", ")", ";", "$", "tokenhandler", "->", "setSelectorTokenString", "(", "$", "key", ")", ";", "// Store the current to extracted from selector:token string ($key)", "$", "token_from_key", "=", "$", "tokenhandler", "->", "getToken", "(", ")", ";", "// Load the tokendata by using the selector from selector:token string ($key)", "$", "tokenhandler", "->", "loadTokenData", "(", ")", ";", "// Get user id", "$", "id_user", "=", "$", "tokenhandler", "->", "getUserId", "(", ")", ";", "// No user id means the activation must fail", "if", "(", "empty", "(", "$", "id_user", ")", ")", "{", "return", "false", ";", "}", "// Get the token loaded from db via selector from selector:token string ($key)", "$", "token_from_db", "=", "$", "tokenhandler", "->", "getToken", "(", ")", ";", "// Matching hashes?", "if", "(", "!", "hash_equals", "(", "$", "token_from_key", ",", "$", "token_from_db", ")", ")", "{", "return", "false", ";", "}", "// Activate user", "$", "this", "->", "db", "->", "qb", "(", "[", "'table'", "=>", "'core_users'", ",", "'method'", "=>", "'UPDATE'", ",", "'fields'", "=>", "'state'", ",", "'filter'", "=>", "'id_user=:id_user'", ",", "'params'", "=>", "[", "':state'", "=>", "0", ",", "':id_user'", "=>", "$", "id_user", "]", "]", ",", "true", ")", ";", "// and delete the token of this user", "$", "tokenhandler", "->", "deleteActivationTokenByUserId", "(", "$", "id_user", ")", ";", "// And finally return user id", "return", "$", "id_user", ";", "}" ]
Actives user by using a key @param string $key Key to use for activation
[ "Actives", "user", "by", "using", "a", "key" ]
66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582
https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/User/Activation.php#L75-L121
237,293
dreadlokeur/Midi-ChloriansPHP
src/network/Http.php
Http.redirect
public static function redirect($url, $permanent = false, $timer = 0, $die = true, $noForceJsRedirect = false) { if (headers_sent()) { if ($noForceJsRedirect) { echo '<script language="javascript" type="text/javascript">window.setTimeout("location=(\'' . $url . '\');", ' . $timer . '*1000);</script>'; // if javascript deactived, redirect with meta echo '<noscript><meta http-equiv="refresh" content="' . $timer . ';url=' . $url . '" /></noscript>'; } } else { if ($timer != 0) header('refresh: ' . $timer . ';location=' . $url); else header('location:' . $url); if ($permanent) header('Status: 301 Moved Permanently', false, 301); } if ($die) exit(); }
php
public static function redirect($url, $permanent = false, $timer = 0, $die = true, $noForceJsRedirect = false) { if (headers_sent()) { if ($noForceJsRedirect) { echo '<script language="javascript" type="text/javascript">window.setTimeout("location=(\'' . $url . '\');", ' . $timer . '*1000);</script>'; // if javascript deactived, redirect with meta echo '<noscript><meta http-equiv="refresh" content="' . $timer . ';url=' . $url . '" /></noscript>'; } } else { if ($timer != 0) header('refresh: ' . $timer . ';location=' . $url); else header('location:' . $url); if ($permanent) header('Status: 301 Moved Permanently', false, 301); } if ($die) exit(); }
[ "public", "static", "function", "redirect", "(", "$", "url", ",", "$", "permanent", "=", "false", ",", "$", "timer", "=", "0", ",", "$", "die", "=", "true", ",", "$", "noForceJsRedirect", "=", "false", ")", "{", "if", "(", "headers_sent", "(", ")", ")", "{", "if", "(", "$", "noForceJsRedirect", ")", "{", "echo", "'<script language=\"javascript\" type=\"text/javascript\">window.setTimeout(\"location=(\\''", ".", "$", "url", ".", "'\\');\", '", ".", "$", "timer", ".", "'*1000);</script>'", ";", "// if javascript deactived, redirect with meta\r", "echo", "'<noscript><meta http-equiv=\"refresh\" content=\"'", ".", "$", "timer", ".", "';url='", ".", "$", "url", ".", "'\" /></noscript>'", ";", "}", "}", "else", "{", "if", "(", "$", "timer", "!=", "0", ")", "header", "(", "'refresh: '", ".", "$", "timer", ".", "';location='", ".", "$", "url", ")", ";", "else", "header", "(", "'location:'", ".", "$", "url", ")", ";", "if", "(", "$", "permanent", ")", "header", "(", "'Status: 301 Moved Permanently'", ",", "false", ",", "301", ")", ";", "}", "if", "(", "$", "die", ")", "exit", "(", ")", ";", "}" ]
Redirection to another url. With Javascript if header was alreadry send @access public @static @param String $url Redirection of redirection @param Boolean $permanent Set if this is a permanently redirection or not @param Mixed $timer Redirect time: in seconds (optional: default 0) @param Boolean $die Die script after redirected @return void
[ "Redirection", "to", "another", "url", ".", "With", "Javascript", "if", "header", "was", "alreadry", "send" ]
4842e0a662c8b9448e69c8e5da35f55066f3bd9e
https://github.com/dreadlokeur/Midi-ChloriansPHP/blob/4842e0a662c8b9448e69c8e5da35f55066f3bd9e/src/network/Http.php#L168-L186
237,294
dreadlokeur/Midi-ChloriansPHP
src/network/Http.php
Http._getDataFromArray
protected static function _getDataFromArray(&$array, $key = false, $default = null, $allowHtmlTags = false) { if ($key === null) return !$allowHtmlTags ? self::_secure($array, $allowHtmlTags) : $array; else { if (!array_key_exists($key, $array)) return $default; return !$allowHtmlTags ? self::_secure($array[$key], $allowHtmlTags) : $array[$key]; } }
php
protected static function _getDataFromArray(&$array, $key = false, $default = null, $allowHtmlTags = false) { if ($key === null) return !$allowHtmlTags ? self::_secure($array, $allowHtmlTags) : $array; else { if (!array_key_exists($key, $array)) return $default; return !$allowHtmlTags ? self::_secure($array[$key], $allowHtmlTags) : $array[$key]; } }
[ "protected", "static", "function", "_getDataFromArray", "(", "&", "$", "array", ",", "$", "key", "=", "false", ",", "$", "default", "=", "null", ",", "$", "allowHtmlTags", "=", "false", ")", "{", "if", "(", "$", "key", "===", "null", ")", "return", "!", "$", "allowHtmlTags", "?", "self", "::", "_secure", "(", "$", "array", ",", "$", "allowHtmlTags", ")", ":", "$", "array", ";", "else", "{", "if", "(", "!", "array_key_exists", "(", "$", "key", ",", "$", "array", ")", ")", "return", "$", "default", ";", "return", "!", "$", "allowHtmlTags", "?", "self", "::", "_secure", "(", "$", "array", "[", "$", "key", "]", ",", "$", "allowHtmlTags", ")", ":", "$", "array", "[", "$", "key", "]", ";", "}", "}" ]
Get a data from a reference array @access protected @static @param Array $array @param String $key @param Mixed $default @param Mixed $allowHtmlTags By default false : Remove all HTML tags, can be true : allow all html tags, can be a list of accepted HTML tags (see strip_tags documentation) @return Mixed
[ "Get", "a", "data", "from", "a", "reference", "array" ]
4842e0a662c8b9448e69c8e5da35f55066f3bd9e
https://github.com/dreadlokeur/Midi-ChloriansPHP/blob/4842e0a662c8b9448e69c8e5da35f55066f3bd9e/src/network/Http.php#L266-L275
237,295
dreadlokeur/Midi-ChloriansPHP
src/network/Http.php
Http._secure
protected static function _secure($value, $allowHtmlTags) { if (is_array($value)) { foreach ($value as &$v) $v = self::_secure($v, $allowHtmlTags); } elseif (is_string($value)) $value = htmlspecialchars(strip_tags($value, ((is_string($allowHtmlTags) && !empty($allowHtmlTags)) ? $allowHtmlTags : null)), ENT_QUOTES); return $value; }
php
protected static function _secure($value, $allowHtmlTags) { if (is_array($value)) { foreach ($value as &$v) $v = self::_secure($v, $allowHtmlTags); } elseif (is_string($value)) $value = htmlspecialchars(strip_tags($value, ((is_string($allowHtmlTags) && !empty($allowHtmlTags)) ? $allowHtmlTags : null)), ENT_QUOTES); return $value; }
[ "protected", "static", "function", "_secure", "(", "$", "value", ",", "$", "allowHtmlTags", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "&", "$", "v", ")", "$", "v", "=", "self", "::", "_secure", "(", "$", "v", ",", "$", "allowHtmlTags", ")", ";", "}", "elseif", "(", "is_string", "(", "$", "value", ")", ")", "$", "value", "=", "htmlspecialchars", "(", "strip_tags", "(", "$", "value", ",", "(", "(", "is_string", "(", "$", "allowHtmlTags", ")", "&&", "!", "empty", "(", "$", "allowHtmlTags", ")", ")", "?", "$", "allowHtmlTags", ":", "null", ")", ")", ",", "ENT_QUOTES", ")", ";", "return", "$", "value", ";", "}" ]
Secure a value, remove all, or allow html tags @access protected @static @param Mixed $value Value to secure @param Mixed $allowHtmlTags It can be a string with HTML tags to allow (see strip_tags documentation) @see http://www.php.net/strip_tags @return Mixed
[ "Secure", "a", "value", "remove", "all", "or", "allow", "html", "tags" ]
4842e0a662c8b9448e69c8e5da35f55066f3bd9e
https://github.com/dreadlokeur/Midi-ChloriansPHP/blob/4842e0a662c8b9448e69c8e5da35f55066f3bd9e/src/network/Http.php#L287-L294
237,296
harvestcloud/CoreBundle
Controller/Seller/SellerHubRefController.php
SellerHubRefController.add_pickup_windowAction
public function add_pickup_windowAction(Request $request) { $id = $request->get('id'); $hub = $this->getRepo('Profile')->find($id); $seller = $this->getUser()->getCurrentProfile(); if (!$hub) { throw $this->createNotFoundException('No hub found for id '.$id); } $sellerHubRef = $this->getRepo('SellerHubRef')->findOneBySellerAndHub($seller, $hub); if (!$sellerHubRef) { throw $this->createNotFoundException('No SellerHubRef found for Seller/Hub combination'); } $pickupWindow = new SellerHubPickupWindow(); $pickupWindow->setSellerHubRef($sellerHubRef); $form = $this->createForm(new SellerHubPickupWindowType(), $pickupWindow); if ($request->getMethod() == 'POST') { $form->bindRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getEntityManager(); $em->persist($pickupWindow); $em->flush(); return $this->redirect($this->generateUrl('Seller_hub_show', array( 'id' => $hub->getId(), ))); } } return $this->render('HarvestCloudCoreBundle:Seller/SellerHubRef:add_pickup_window.html.twig', array( 'hub' => $hub, 'form' => $form->createView(), )); }
php
public function add_pickup_windowAction(Request $request) { $id = $request->get('id'); $hub = $this->getRepo('Profile')->find($id); $seller = $this->getUser()->getCurrentProfile(); if (!$hub) { throw $this->createNotFoundException('No hub found for id '.$id); } $sellerHubRef = $this->getRepo('SellerHubRef')->findOneBySellerAndHub($seller, $hub); if (!$sellerHubRef) { throw $this->createNotFoundException('No SellerHubRef found for Seller/Hub combination'); } $pickupWindow = new SellerHubPickupWindow(); $pickupWindow->setSellerHubRef($sellerHubRef); $form = $this->createForm(new SellerHubPickupWindowType(), $pickupWindow); if ($request->getMethod() == 'POST') { $form->bindRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getEntityManager(); $em->persist($pickupWindow); $em->flush(); return $this->redirect($this->generateUrl('Seller_hub_show', array( 'id' => $hub->getId(), ))); } } return $this->render('HarvestCloudCoreBundle:Seller/SellerHubRef:add_pickup_window.html.twig', array( 'hub' => $hub, 'form' => $form->createView(), )); }
[ "public", "function", "add_pickup_windowAction", "(", "Request", "$", "request", ")", "{", "$", "id", "=", "$", "request", "->", "get", "(", "'id'", ")", ";", "$", "hub", "=", "$", "this", "->", "getRepo", "(", "'Profile'", ")", "->", "find", "(", "$", "id", ")", ";", "$", "seller", "=", "$", "this", "->", "getUser", "(", ")", "->", "getCurrentProfile", "(", ")", ";", "if", "(", "!", "$", "hub", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'No hub found for id '", ".", "$", "id", ")", ";", "}", "$", "sellerHubRef", "=", "$", "this", "->", "getRepo", "(", "'SellerHubRef'", ")", "->", "findOneBySellerAndHub", "(", "$", "seller", ",", "$", "hub", ")", ";", "if", "(", "!", "$", "sellerHubRef", ")", "{", "throw", "$", "this", "->", "createNotFoundException", "(", "'No SellerHubRef found for Seller/Hub combination'", ")", ";", "}", "$", "pickupWindow", "=", "new", "SellerHubPickupWindow", "(", ")", ";", "$", "pickupWindow", "->", "setSellerHubRef", "(", "$", "sellerHubRef", ")", ";", "$", "form", "=", "$", "this", "->", "createForm", "(", "new", "SellerHubPickupWindowType", "(", ")", ",", "$", "pickupWindow", ")", ";", "if", "(", "$", "request", "->", "getMethod", "(", ")", "==", "'POST'", ")", "{", "$", "form", "->", "bindRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getEntityManager", "(", ")", ";", "$", "em", "->", "persist", "(", "$", "pickupWindow", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'Seller_hub_show'", ",", "array", "(", "'id'", "=>", "$", "hub", "->", "getId", "(", ")", ",", ")", ")", ")", ";", "}", "}", "return", "$", "this", "->", "render", "(", "'HarvestCloudCoreBundle:Seller/SellerHubRef:add_pickup_window.html.twig'", ",", "array", "(", "'hub'", "=>", "$", "hub", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ")", ";", "}" ]
add pickup window @author Tom Haskins-Vaughan <tom@harvestcloud.com> @since 2012-04-29 @todo Reduce number of queries on this page @todo Make sure we don't create a PickupWindow when the Hub is closed @todo Refcator to model @param Request $request
[ "add", "pickup", "window" ]
f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc
https://github.com/harvestcloud/CoreBundle/blob/f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc/Controller/Seller/SellerHubRefController.php#L36-L80
237,297
bellisq/type-map
src/Base/TypeMapAbstract.php
TypeMapAbstract.get
final public function get(string $type): object { if ($this->supports($type)) { $ret = $this->getObject($type); if ($ret instanceof $type) { return $ret; } throw new TypeError; } throw new UnavailableTypeException; }
php
final public function get(string $type): object { if ($this->supports($type)) { $ret = $this->getObject($type); if ($ret instanceof $type) { return $ret; } throw new TypeError; } throw new UnavailableTypeException; }
[ "final", "public", "function", "get", "(", "string", "$", "type", ")", ":", "object", "{", "if", "(", "$", "this", "->", "supports", "(", "$", "type", ")", ")", "{", "$", "ret", "=", "$", "this", "->", "getObject", "(", "$", "type", ")", ";", "if", "(", "$", "ret", "instanceof", "$", "type", ")", "{", "return", "$", "ret", ";", "}", "throw", "new", "TypeError", ";", "}", "throw", "new", "UnavailableTypeException", ";", "}" ]
Get an object of the type. Check if the type is supported. If the type is supported, call getObject. If not, throw an exception. @param string $type @return object @throws TypeError @throws UnavailableTypeException
[ "Get", "an", "object", "of", "the", "type", "." ]
8a453cc3b0820a85d4f8a6ec2dd967ea800fa6f3
https://github.com/bellisq/type-map/blob/8a453cc3b0820a85d4f8a6ec2dd967ea800fa6f3/src/Base/TypeMapAbstract.php#L47-L58
237,298
neat-php/http
classes/Message.php
Message.headers
public function headers() { $headers = []; foreach ($this->headers as $header) { $headers[$header->name()] = $header->value(); } return $headers; }
php
public function headers() { $headers = []; foreach ($this->headers as $header) { $headers[$header->name()] = $header->value(); } return $headers; }
[ "public", "function", "headers", "(", ")", "{", "$", "headers", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "headers", "as", "$", "header", ")", "{", "$", "headers", "[", "$", "header", "->", "name", "(", ")", "]", "=", "$", "header", "->", "value", "(", ")", ";", "}", "return", "$", "headers", ";", "}" ]
Get header values @return array
[ "Get", "header", "values" ]
5d4781a8481c1f708fd642292e44244435a8369c
https://github.com/neat-php/http/blob/5d4781a8481c1f708fd642292e44244435a8369c/classes/Message.php#L77-L85
237,299
acplo/AcploLog
src/AcploLog/Log/EntityLogger.php
EntityLogger.onFlush
public function onFlush(OnFlushEventArgs $eventArgs) { $em = $eventArgs->getEntityManager(); $uow = $em->getUnitOfWork(); foreach ($uow->getScheduledEntityInsertions() as $entity) { $this->debug('Inserting entity '.get_class($entity).'. Fields: '. json_encode($uow->getEntityChangeSet($entity))); } foreach ($uow->getScheduledEntityUpdates() as $entity) { $add = ''; if (method_exists($entity, '__toString')) { $add = ' '.$entity->__toString(); } elseif (method_exists($entity, 'getId')) { $add = ' with id '.$entity->getId(); } $this->debug('Updating entity '.get_class($entity).$add.'. Data: '. json_encode($uow->getEntityChangeSet($entity))); } foreach ($uow->getScheduledEntityDeletions() as $entity) { $add = ''; if (method_exists($entity, '__toString')) { $add = ' '.$entity->__toString(); } elseif (method_exists($entity, 'getId')) { $add = ' with id '.$entity->getId(); } $this->debug('Deleting entity '.get_class($entity).$add.'.'); } }
php
public function onFlush(OnFlushEventArgs $eventArgs) { $em = $eventArgs->getEntityManager(); $uow = $em->getUnitOfWork(); foreach ($uow->getScheduledEntityInsertions() as $entity) { $this->debug('Inserting entity '.get_class($entity).'. Fields: '. json_encode($uow->getEntityChangeSet($entity))); } foreach ($uow->getScheduledEntityUpdates() as $entity) { $add = ''; if (method_exists($entity, '__toString')) { $add = ' '.$entity->__toString(); } elseif (method_exists($entity, 'getId')) { $add = ' with id '.$entity->getId(); } $this->debug('Updating entity '.get_class($entity).$add.'. Data: '. json_encode($uow->getEntityChangeSet($entity))); } foreach ($uow->getScheduledEntityDeletions() as $entity) { $add = ''; if (method_exists($entity, '__toString')) { $add = ' '.$entity->__toString(); } elseif (method_exists($entity, 'getId')) { $add = ' with id '.$entity->getId(); } $this->debug('Deleting entity '.get_class($entity).$add.'.'); } }
[ "public", "function", "onFlush", "(", "OnFlushEventArgs", "$", "eventArgs", ")", "{", "$", "em", "=", "$", "eventArgs", "->", "getEntityManager", "(", ")", ";", "$", "uow", "=", "$", "em", "->", "getUnitOfWork", "(", ")", ";", "foreach", "(", "$", "uow", "->", "getScheduledEntityInsertions", "(", ")", "as", "$", "entity", ")", "{", "$", "this", "->", "debug", "(", "'Inserting entity '", ".", "get_class", "(", "$", "entity", ")", ".", "'. Fields: '", ".", "json_encode", "(", "$", "uow", "->", "getEntityChangeSet", "(", "$", "entity", ")", ")", ")", ";", "}", "foreach", "(", "$", "uow", "->", "getScheduledEntityUpdates", "(", ")", "as", "$", "entity", ")", "{", "$", "add", "=", "''", ";", "if", "(", "method_exists", "(", "$", "entity", ",", "'__toString'", ")", ")", "{", "$", "add", "=", "' '", ".", "$", "entity", "->", "__toString", "(", ")", ";", "}", "elseif", "(", "method_exists", "(", "$", "entity", ",", "'getId'", ")", ")", "{", "$", "add", "=", "' with id '", ".", "$", "entity", "->", "getId", "(", ")", ";", "}", "$", "this", "->", "debug", "(", "'Updating entity '", ".", "get_class", "(", "$", "entity", ")", ".", "$", "add", ".", "'. Data: '", ".", "json_encode", "(", "$", "uow", "->", "getEntityChangeSet", "(", "$", "entity", ")", ")", ")", ";", "}", "foreach", "(", "$", "uow", "->", "getScheduledEntityDeletions", "(", ")", "as", "$", "entity", ")", "{", "$", "add", "=", "''", ";", "if", "(", "method_exists", "(", "$", "entity", ",", "'__toString'", ")", ")", "{", "$", "add", "=", "' '", ".", "$", "entity", "->", "__toString", "(", ")", ";", "}", "elseif", "(", "method_exists", "(", "$", "entity", ",", "'getId'", ")", ")", "{", "$", "add", "=", "' with id '", ".", "$", "entity", "->", "getId", "(", ")", ";", "}", "$", "this", "->", "debug", "(", "'Deleting entity '", ".", "get_class", "(", "$", "entity", ")", ".", "$", "add", ".", "'.'", ")", ";", "}", "}" ]
Logs the entity changes @param \Doctrine\ORM\Event\OnFlushEventArgs $eventArgs
[ "Logs", "the", "entity", "changes" ]
9cebcd92ccfaf5dcd67f77ecba358ad5d6cee2a2
https://github.com/acplo/AcploLog/blob/9cebcd92ccfaf5dcd67f77ecba358ad5d6cee2a2/src/AcploLog/Log/EntityLogger.php#L45-L77