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
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
9,900
eFrane/Transfugio
src/Http/Method/ShowItemTrait.php
ShowItemTrait.getResolveMethod
protected function getResolveMethod() { if (is_array($this->resolveMethod)) { $method = $this->resolveMethod; } else { if (strpos($this->resolveMethod, 'model:') >= 0) { $method = substr($this->resolveMethod, strpos($this->resolveMethod, ':') + 1); return $method; } else { if (strpos($this->resolveMethod, 'self:') >= 0) { $method = [$this, substr($this->resolveMethod, strpos($this->resolveMethod, ':') + 1)]; } else { throw new LogicException("Unable to determine entity resolve method."); } } } if (!method_exists($method[0], $method[1])) { throw new LogicException("Resolve method does not exist"); } return $method; }
php
protected function getResolveMethod() { if (is_array($this->resolveMethod)) { $method = $this->resolveMethod; } else { if (strpos($this->resolveMethod, 'model:') >= 0) { $method = substr($this->resolveMethod, strpos($this->resolveMethod, ':') + 1); return $method; } else { if (strpos($this->resolveMethod, 'self:') >= 0) { $method = [$this, substr($this->resolveMethod, strpos($this->resolveMethod, ':') + 1)]; } else { throw new LogicException("Unable to determine entity resolve method."); } } } if (!method_exists($method[0], $method[1])) { throw new LogicException("Resolve method does not exist"); } return $method; }
[ "protected", "function", "getResolveMethod", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "resolveMethod", ")", ")", "{", "$", "method", "=", "$", "this", "->", "resolveMethod", ";", "}", "else", "{", "if", "(", "strpos", "(", "$", "this", "->", "resolveMethod", ",", "'model:'", ")", ">=", "0", ")", "{", "$", "method", "=", "substr", "(", "$", "this", "->", "resolveMethod", ",", "strpos", "(", "$", "this", "->", "resolveMethod", ",", "':'", ")", "+", "1", ")", ";", "return", "$", "method", ";", "}", "else", "{", "if", "(", "strpos", "(", "$", "this", "->", "resolveMethod", ",", "'self:'", ")", ">=", "0", ")", "{", "$", "method", "=", "[", "$", "this", ",", "substr", "(", "$", "this", "->", "resolveMethod", ",", "strpos", "(", "$", "this", "->", "resolveMethod", ",", "':'", ")", "+", "1", ")", "]", ";", "}", "else", "{", "throw", "new", "LogicException", "(", "\"Unable to determine entity resolve method.\"", ")", ";", "}", "}", "}", "if", "(", "!", "method_exists", "(", "$", "method", "[", "0", "]", ",", "$", "method", "[", "1", "]", ")", ")", "{", "throw", "new", "LogicException", "(", "\"Resolve method does not exist\"", ")", ";", "}", "return", "$", "method", ";", "}" ]
Get the resolve method for the query. By default, entities are resolved by their id field. It is, however, possible to choose a different resolving method for entities. You may for instance have an API endpoint for stored git commits and it is obviously not in anyway logical to return the id of that commit's database entry. In that case, the following would resolve commits by their sha-hash: <code> class CommitsController extends APIController { use \Transfugio\Http\Method\IndexPaginatedTrait; use \Transfugio\Http\Method\ShowItemTrait; protected $model = 'Git\Commit'; protected $resolveMethod = 'model:whereSha1'; // or 'self:resolveShow' protected function resolveShow($id) { return Git\Commit::whereSha1($id); } } </code> The inclined observer may already have noticed the two core principles for item resolving: 1) You can choose to either implement your own resolver method or to just use an Eloquent way of retrieving a model instance. This is signified by prefixing the method name with model (for Eloquent) or self. 2) It is not necessary to return an actual model instance, the system automatically checks for `\Illuminate\Database\Builder` instances and fetches a model from them by calling `first()`. @return array The resolve method callable
[ "Get", "the", "resolve", "method", "for", "the", "query", "." ]
c213b3c0e3649150d0c6675167e781930fda9125
https://github.com/eFrane/Transfugio/blob/c213b3c0e3649150d0c6675167e781930fda9125/src/Http/Method/ShowItemTrait.php#L85-L107
9,901
tekkla/core-framework
Core/Framework/Error/ErrorHandler.php
ErrorHandler.createErrorHtml
private function createErrorHtml(bool $dismissable = false) { $html = ' <div class="alert alert-danger' . ($dismissable == true ? ' alert-dismissible' : '') . '" role="alert" id="core-error-' . $this->throwable->getCode() . '">'; if ($dismissable) { $html .= '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>'; } switch (true) { case $this->public: $html .= $this->getHeadline(); $html .= $this->getMessage(); $html .= $this->getFileinfo(); $html .= $this->getTrace(); break; default: $html .= ' <h3 class="no-top-margin">Error</h3> <p>Sorry for that! Webmaster has been informed. Please try again later.</p>'; } $html .= ' </div>'; return $html; }
php
private function createErrorHtml(bool $dismissable = false) { $html = ' <div class="alert alert-danger' . ($dismissable == true ? ' alert-dismissible' : '') . '" role="alert" id="core-error-' . $this->throwable->getCode() . '">'; if ($dismissable) { $html .= '<button type="button" class="close" data-dismiss="alert"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>'; } switch (true) { case $this->public: $html .= $this->getHeadline(); $html .= $this->getMessage(); $html .= $this->getFileinfo(); $html .= $this->getTrace(); break; default: $html .= ' <h3 class="no-top-margin">Error</h3> <p>Sorry for that! Webmaster has been informed. Please try again later.</p>'; } $html .= ' </div>'; return $html; }
[ "private", "function", "createErrorHtml", "(", "bool", "$", "dismissable", "=", "false", ")", "{", "$", "html", "=", "'\n <div class=\"alert alert-danger'", ".", "(", "$", "dismissable", "==", "true", "?", "' alert-dismissible'", ":", "''", ")", ".", "'\" role=\"alert\" id=\"core-error-'", ".", "$", "this", "->", "throwable", "->", "getCode", "(", ")", ".", "'\">'", ";", "if", "(", "$", "dismissable", ")", "{", "$", "html", ".=", "'<button type=\"button\" class=\"close\" data-dismiss=\"alert\"><span aria-hidden=\"true\">&times;</span><span class=\"sr-only\">Close</span></button>'", ";", "}", "switch", "(", "true", ")", "{", "case", "$", "this", "->", "public", ":", "$", "html", ".=", "$", "this", "->", "getHeadline", "(", ")", ";", "$", "html", ".=", "$", "this", "->", "getMessage", "(", ")", ";", "$", "html", ".=", "$", "this", "->", "getFileinfo", "(", ")", ";", "$", "html", ".=", "$", "this", "->", "getTrace", "(", ")", ";", "break", ";", "default", ":", "$", "html", ".=", "'\n <h3 class=\"no-top-margin\">Error</h3>\n <p>Sorry for that! Webmaster has been informed. Please try again later.</p>'", ";", "}", "$", "html", ".=", "'\n </div>'", ";", "return", "$", "html", ";", "}" ]
Creates html error message
[ "Creates", "html", "error", "message" ]
ad69e9f15ee3644b6ca376edc30d8f5555399892
https://github.com/tekkla/core-framework/blob/ad69e9f15ee3644b6ca376edc30d8f5555399892/Core/Framework/Error/ErrorHandler.php#L204-L232
9,902
letyii/yii2-diy
models/DiyWidget.php
DiyWidget.generateTemplateWidget
public static function generateTemplateWidget($model){ $templateWidget = Html::beginTag('div', ['data-id' => (string) $model->_id, 'data-category' => $model->category, 'class' => 'let_widget_origin']); $templateWidget .= $model->title; $templateWidget .= Html::endTag('div'); return $templateWidget; }
php
public static function generateTemplateWidget($model){ $templateWidget = Html::beginTag('div', ['data-id' => (string) $model->_id, 'data-category' => $model->category, 'class' => 'let_widget_origin']); $templateWidget .= $model->title; $templateWidget .= Html::endTag('div'); return $templateWidget; }
[ "public", "static", "function", "generateTemplateWidget", "(", "$", "model", ")", "{", "$", "templateWidget", "=", "Html", "::", "beginTag", "(", "'div'", ",", "[", "'data-id'", "=>", "(", "string", ")", "$", "model", "->", "_id", ",", "'data-category'", "=>", "$", "model", "->", "category", ",", "'class'", "=>", "'let_widget_origin'", "]", ")", ";", "$", "templateWidget", ".=", "$", "model", "->", "title", ";", "$", "templateWidget", ".=", "Html", "::", "endTag", "(", "'div'", ")", ";", "return", "$", "templateWidget", ";", "}" ]
Ham hien thi widget khi duoc tao qua namespace @param object $model thong tin cua widget khi duoc tao @return string
[ "Ham", "hien", "thi", "widget", "khi", "duoc", "tao", "qua", "namespace" ]
964f98c52976d7a2429c32864a9a93b635b6a4ef
https://github.com/letyii/yii2-diy/blob/964f98c52976d7a2429c32864a9a93b635b6a4ef/models/DiyWidget.php#L27-L33
9,903
letyii/yii2-diy
models/DiyWidget.php
DiyWidget.getInputByType
private static function getInputByType($type = 'text', $templateSetting = null, $keySetting = null, $value = null, $items = []){ switch ($type) { case 'textarea': $templateSetting = Html::textarea($keySetting, $value, ['class' => 'form-control', 'title' => $keySetting]); break; case 'date': $templateSetting = DateControl::widget([ 'name' => $keySetting, 'value' => $value, 'type'=>DateControl::FORMAT_DATE, 'ajaxConversion'=>false, 'options' => [ 'pluginOptions' => [ 'autoclose' => true ], 'options' => ['title' => $keySetting], ], 'displayFormat' => 'dd-MM-yyyy', 'saveFormat' => 'yyyy-MM-dd', ]); break; case 'datetime': $templateSetting = DateControl::widget([ 'name' => $keySetting, 'value' => $value, 'type'=>DateControl::FORMAT_DATETIME, 'ajaxConversion'=>false, 'options' => [ 'pluginOptions' => [ 'autoclose' => true ], 'options' => ['title' => $keySetting], ], 'saveFormat' => 'yyyy-MM-dd', ]); break; case 'daterange': $templateSetting = DateRangePicker::widget([ 'name' => $keySetting, 'value' => $value, 'presetDropdown'=>true, 'hideInput'=>true, 'options' => ['title' => $keySetting], ]); break; case 'dropdown': $templateSetting = Html::dropDownList($keySetting, $value, $items, ['class' => 'form-control', 'title' => $keySetting]); break; case 'checkbox': $templateSetting = Html::checkboxList($keySetting, $value, $items, ['class' => 'form-control', 'title' => $keySetting]); break; case 'radio': $templateSetting = Html::radioList($keySetting, $value, $items, ['class' => 'form-control', 'title' => $keySetting]); break; default: $templateSetting = Html::textInput($keySetting, $value, ['class' => 'form-control', 'title' => $keySetting]); break; } return $templateSetting; }
php
private static function getInputByType($type = 'text', $templateSetting = null, $keySetting = null, $value = null, $items = []){ switch ($type) { case 'textarea': $templateSetting = Html::textarea($keySetting, $value, ['class' => 'form-control', 'title' => $keySetting]); break; case 'date': $templateSetting = DateControl::widget([ 'name' => $keySetting, 'value' => $value, 'type'=>DateControl::FORMAT_DATE, 'ajaxConversion'=>false, 'options' => [ 'pluginOptions' => [ 'autoclose' => true ], 'options' => ['title' => $keySetting], ], 'displayFormat' => 'dd-MM-yyyy', 'saveFormat' => 'yyyy-MM-dd', ]); break; case 'datetime': $templateSetting = DateControl::widget([ 'name' => $keySetting, 'value' => $value, 'type'=>DateControl::FORMAT_DATETIME, 'ajaxConversion'=>false, 'options' => [ 'pluginOptions' => [ 'autoclose' => true ], 'options' => ['title' => $keySetting], ], 'saveFormat' => 'yyyy-MM-dd', ]); break; case 'daterange': $templateSetting = DateRangePicker::widget([ 'name' => $keySetting, 'value' => $value, 'presetDropdown'=>true, 'hideInput'=>true, 'options' => ['title' => $keySetting], ]); break; case 'dropdown': $templateSetting = Html::dropDownList($keySetting, $value, $items, ['class' => 'form-control', 'title' => $keySetting]); break; case 'checkbox': $templateSetting = Html::checkboxList($keySetting, $value, $items, ['class' => 'form-control', 'title' => $keySetting]); break; case 'radio': $templateSetting = Html::radioList($keySetting, $value, $items, ['class' => 'form-control', 'title' => $keySetting]); break; default: $templateSetting = Html::textInput($keySetting, $value, ['class' => 'form-control', 'title' => $keySetting]); break; } return $templateSetting; }
[ "private", "static", "function", "getInputByType", "(", "$", "type", "=", "'text'", ",", "$", "templateSetting", "=", "null", ",", "$", "keySetting", "=", "null", ",", "$", "value", "=", "null", ",", "$", "items", "=", "[", "]", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'textarea'", ":", "$", "templateSetting", "=", "Html", "::", "textarea", "(", "$", "keySetting", ",", "$", "value", ",", "[", "'class'", "=>", "'form-control'", ",", "'title'", "=>", "$", "keySetting", "]", ")", ";", "break", ";", "case", "'date'", ":", "$", "templateSetting", "=", "DateControl", "::", "widget", "(", "[", "'name'", "=>", "$", "keySetting", ",", "'value'", "=>", "$", "value", ",", "'type'", "=>", "DateControl", "::", "FORMAT_DATE", ",", "'ajaxConversion'", "=>", "false", ",", "'options'", "=>", "[", "'pluginOptions'", "=>", "[", "'autoclose'", "=>", "true", "]", ",", "'options'", "=>", "[", "'title'", "=>", "$", "keySetting", "]", ",", "]", ",", "'displayFormat'", "=>", "'dd-MM-yyyy'", ",", "'saveFormat'", "=>", "'yyyy-MM-dd'", ",", "]", ")", ";", "break", ";", "case", "'datetime'", ":", "$", "templateSetting", "=", "DateControl", "::", "widget", "(", "[", "'name'", "=>", "$", "keySetting", ",", "'value'", "=>", "$", "value", ",", "'type'", "=>", "DateControl", "::", "FORMAT_DATETIME", ",", "'ajaxConversion'", "=>", "false", ",", "'options'", "=>", "[", "'pluginOptions'", "=>", "[", "'autoclose'", "=>", "true", "]", ",", "'options'", "=>", "[", "'title'", "=>", "$", "keySetting", "]", ",", "]", ",", "'saveFormat'", "=>", "'yyyy-MM-dd'", ",", "]", ")", ";", "break", ";", "case", "'daterange'", ":", "$", "templateSetting", "=", "DateRangePicker", "::", "widget", "(", "[", "'name'", "=>", "$", "keySetting", ",", "'value'", "=>", "$", "value", ",", "'presetDropdown'", "=>", "true", ",", "'hideInput'", "=>", "true", ",", "'options'", "=>", "[", "'title'", "=>", "$", "keySetting", "]", ",", "]", ")", ";", "break", ";", "case", "'dropdown'", ":", "$", "templateSetting", "=", "Html", "::", "dropDownList", "(", "$", "keySetting", ",", "$", "value", ",", "$", "items", ",", "[", "'class'", "=>", "'form-control'", ",", "'title'", "=>", "$", "keySetting", "]", ")", ";", "break", ";", "case", "'checkbox'", ":", "$", "templateSetting", "=", "Html", "::", "checkboxList", "(", "$", "keySetting", ",", "$", "value", ",", "$", "items", ",", "[", "'class'", "=>", "'form-control'", ",", "'title'", "=>", "$", "keySetting", "]", ")", ";", "break", ";", "case", "'radio'", ":", "$", "templateSetting", "=", "Html", "::", "radioList", "(", "$", "keySetting", ",", "$", "value", ",", "$", "items", ",", "[", "'class'", "=>", "'form-control'", ",", "'title'", "=>", "$", "keySetting", "]", ")", ";", "break", ";", "default", ":", "$", "templateSetting", "=", "Html", "::", "textInput", "(", "$", "keySetting", ",", "$", "value", ",", "[", "'class'", "=>", "'form-control'", ",", "'title'", "=>", "$", "keySetting", "]", ")", ";", "break", ";", "}", "return", "$", "templateSetting", ";", "}" ]
Ham get html cho input theo type @param string $type input co the la text, textarea, editor, date, datetime, daterange, dropdown, checkbox, radio @param string $templateSetting giao dien input theo type @param string $keySetting ten cua key setting @param string $value gia tri cua key setting @param array $items Mang cac gia tri cua setting neu setting co type la dropdown, checkbox, radio @return string
[ "Ham", "get", "html", "cho", "input", "theo", "type" ]
964f98c52976d7a2429c32864a9a93b635b6a4ef
https://github.com/letyii/yii2-diy/blob/964f98c52976d7a2429c32864a9a93b635b6a4ef/models/DiyWidget.php#L111-L171
9,904
iRAP-software/package-core-libs
src/TimeLib.php
TimeLib.getDaysInMonth
public static function getDaysInMonth($month='', $year='') { $firstOfSpecifiedMonth = self::getFirstOfMonth($month, $year); $numDays = date("t", $firstOfSpecifiedMonth); return $numDays; }
php
public static function getDaysInMonth($month='', $year='') { $firstOfSpecifiedMonth = self::getFirstOfMonth($month, $year); $numDays = date("t", $firstOfSpecifiedMonth); return $numDays; }
[ "public", "static", "function", "getDaysInMonth", "(", "$", "month", "=", "''", ",", "$", "year", "=", "''", ")", "{", "$", "firstOfSpecifiedMonth", "=", "self", "::", "getFirstOfMonth", "(", "$", "month", ",", "$", "year", ")", ";", "$", "numDays", "=", "date", "(", "\"t\"", ",", "$", "firstOfSpecifiedMonth", ")", ";", "return", "$", "numDays", ";", "}" ]
Fetches the number of days in a given month. @param month - optional integer representing which month of the year. e.g. 00 = january if not specified we assume the current month. @param year - optional integer representing which year. e.g. 2013 and not 13 if not specified we assume the current year. @return numDays - the number of days in that month/year.
[ "Fetches", "the", "number", "of", "days", "in", "a", "given", "month", "." ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/TimeLib.php#L25-L30
9,905
iRAP-software/package-core-libs
src/TimeLib.php
TimeLib.roundTimestampToDay
public static function roundTimestampToDay($timestamp) { $day = date('d', $timestamp); $month = date('m', $timestamp); $year = date('Y', $timestamp); $roundedTimestamp = mktime(0, 0, 0, $month, $day, $year); return $roundedTimestamp; }
php
public static function roundTimestampToDay($timestamp) { $day = date('d', $timestamp); $month = date('m', $timestamp); $year = date('Y', $timestamp); $roundedTimestamp = mktime(0, 0, 0, $month, $day, $year); return $roundedTimestamp; }
[ "public", "static", "function", "roundTimestampToDay", "(", "$", "timestamp", ")", "{", "$", "day", "=", "date", "(", "'d'", ",", "$", "timestamp", ")", ";", "$", "month", "=", "date", "(", "'m'", ",", "$", "timestamp", ")", ";", "$", "year", "=", "date", "(", "'Y'", ",", "$", "timestamp", ")", ";", "$", "roundedTimestamp", "=", "mktime", "(", "0", ",", "0", ",", "0", ",", "$", "month", ",", "$", "day", ",", "$", "year", ")", ";", "return", "$", "roundedTimestamp", ";", "}" ]
Rounds a timestamp down to midnight of the day it was taken. @param timestamp - the timestamp to round off. @return roundedTimestamp - the timestamp rounded to midnight of that day.
[ "Rounds", "a", "timestamp", "down", "to", "midnight", "of", "the", "day", "it", "was", "taken", "." ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/TimeLib.php#L145-L154
9,906
iRAP-software/package-core-libs
src/TimeLib.php
TimeLib.roundTimestampToWeek
public static function roundTimestampToWeek($timestamp) { $roundedToDay = self::roundTimestampToDay($timestamp); $weekDay = date('w', $roundedToDay); # 1 = Monday $daysToSubtract = $weekDay - 1; $roundedToWeek = strtotime("-" . $daysToSubtract . " day", $roundedToDay); return $roundedToWeek; }
php
public static function roundTimestampToWeek($timestamp) { $roundedToDay = self::roundTimestampToDay($timestamp); $weekDay = date('w', $roundedToDay); # 1 = Monday $daysToSubtract = $weekDay - 1; $roundedToWeek = strtotime("-" . $daysToSubtract . " day", $roundedToDay); return $roundedToWeek; }
[ "public", "static", "function", "roundTimestampToWeek", "(", "$", "timestamp", ")", "{", "$", "roundedToDay", "=", "self", "::", "roundTimestampToDay", "(", "$", "timestamp", ")", ";", "$", "weekDay", "=", "date", "(", "'w'", ",", "$", "roundedToDay", ")", ";", "# 1 = Monday", "$", "daysToSubtract", "=", "$", "weekDay", "-", "1", ";", "$", "roundedToWeek", "=", "strtotime", "(", "\"-\"", ".", "$", "daysToSubtract", ".", "\" day\"", ",", "$", "roundedToDay", ")", ";", "return", "$", "roundedToWeek", ";", "}" ]
Rounds a timestamp down to midnight on Monday of time it was taken @param timestamp - the timestamp to round off. @return roundedTimestamp - the rounded timestamp
[ "Rounds", "a", "timestamp", "down", "to", "midnight", "on", "Monday", "of", "time", "it", "was", "taken" ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/TimeLib.php#L162-L170
9,907
iRAP-software/package-core-libs
src/TimeLib.php
TimeLib.roundTimestampDownToMonth
public static function roundTimestampDownToMonth($timestamp) { $month = date('n', $timestamp); $year = date('Y', $timestamp); $roundedTimestamp = mktime(0, 0, 0, $month, $day="01", $year); return $roundedTimestamp; }
php
public static function roundTimestampDownToMonth($timestamp) { $month = date('n', $timestamp); $year = date('Y', $timestamp); $roundedTimestamp = mktime(0, 0, 0, $month, $day="01", $year); return $roundedTimestamp; }
[ "public", "static", "function", "roundTimestampDownToMonth", "(", "$", "timestamp", ")", "{", "$", "month", "=", "date", "(", "'n'", ",", "$", "timestamp", ")", ";", "$", "year", "=", "date", "(", "'Y'", ",", "$", "timestamp", ")", ";", "$", "roundedTimestamp", "=", "mktime", "(", "0", ",", "0", ",", "0", ",", "$", "month", ",", "$", "day", "=", "\"01\"", ",", "$", "year", ")", ";", "return", "$", "roundedTimestamp", ";", "}" ]
Rounds a timestamp down to midnight on the first of the month it was taken @param timestamp - the timestamp to round off. @return roundedTimestamp - the rounded timestamp
[ "Rounds", "a", "timestamp", "down", "to", "midnight", "on", "the", "first", "of", "the", "month", "it", "was", "taken" ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/TimeLib.php#L179-L187
9,908
iRAP-software/package-core-libs
src/TimeLib.php
TimeLib.roundTimestampToYear
public static function roundTimestampToYear($timestamp) { $year = date('Y', $timestamp); $roundedTimestamp = mktime(0, 0, 0, $month=1, $day=1, $year); return $roundedTimestamp; }
php
public static function roundTimestampToYear($timestamp) { $year = date('Y', $timestamp); $roundedTimestamp = mktime(0, 0, 0, $month=1, $day=1, $year); return $roundedTimestamp; }
[ "public", "static", "function", "roundTimestampToYear", "(", "$", "timestamp", ")", "{", "$", "year", "=", "date", "(", "'Y'", ",", "$", "timestamp", ")", ";", "$", "roundedTimestamp", "=", "mktime", "(", "0", ",", "0", ",", "0", ",", "$", "month", "=", "1", ",", "$", "day", "=", "1", ",", "$", "year", ")", ";", "return", "$", "roundedTimestamp", ";", "}" ]
Rounds a timestamp down to midnight on the 1st of January of the year it was taken @param timestamp - the timestamp to round off. @return roundedTimestamp - the rounded timestamp
[ "Rounds", "a", "timestamp", "down", "to", "midnight", "on", "the", "1st", "of", "January", "of", "the", "year", "it", "was", "taken" ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/TimeLib.php#L196-L203
9,909
iRAP-software/package-core-libs
src/TimeLib.php
TimeLib.get_human_readble_time_difference
public static function get_human_readble_time_difference(\DateTime $timestamp) { $resultString = ""; $now = new \DateTime(); $diffInSeconds = $now->getTimestamp() - $timestamp->getTimestamp(); if ($diffInSeconds < 60) { $resultString = "$diffInSeconds seconds"; } elseif ($diffInSeconds < 3600) { $diffInMinutes = (int) ($diffInSeconds / 60); $remainder = (int) ($diffInSeconds % 60); $resultString = "$diffInMinutes mins $remainder secs"; } elseif ($diffInSeconds < 86400) { $diffInHours = (int) ($diffInSeconds / 3600); $remainder = (int) ($diffInSeconds % 3600); $minutes = (int)($remainder / 60); $resultString = "$diffInHours hours $minutes mins"; } else { $diffInDays = (int) ($diffInSeconds / 86400); $remainder = (int) ($diffInSeconds % 86400); $hours = (int)($remainder / 3600); $resultString = "$diffInDays days $hours hours"; } return $resultString; }
php
public static function get_human_readble_time_difference(\DateTime $timestamp) { $resultString = ""; $now = new \DateTime(); $diffInSeconds = $now->getTimestamp() - $timestamp->getTimestamp(); if ($diffInSeconds < 60) { $resultString = "$diffInSeconds seconds"; } elseif ($diffInSeconds < 3600) { $diffInMinutes = (int) ($diffInSeconds / 60); $remainder = (int) ($diffInSeconds % 60); $resultString = "$diffInMinutes mins $remainder secs"; } elseif ($diffInSeconds < 86400) { $diffInHours = (int) ($diffInSeconds / 3600); $remainder = (int) ($diffInSeconds % 3600); $minutes = (int)($remainder / 60); $resultString = "$diffInHours hours $minutes mins"; } else { $diffInDays = (int) ($diffInSeconds / 86400); $remainder = (int) ($diffInSeconds % 86400); $hours = (int)($remainder / 3600); $resultString = "$diffInDays days $hours hours"; } return $resultString; }
[ "public", "static", "function", "get_human_readble_time_difference", "(", "\\", "DateTime", "$", "timestamp", ")", "{", "$", "resultString", "=", "\"\"", ";", "$", "now", "=", "new", "\\", "DateTime", "(", ")", ";", "$", "diffInSeconds", "=", "$", "now", "->", "getTimestamp", "(", ")", "-", "$", "timestamp", "->", "getTimestamp", "(", ")", ";", "if", "(", "$", "diffInSeconds", "<", "60", ")", "{", "$", "resultString", "=", "\"$diffInSeconds seconds\"", ";", "}", "elseif", "(", "$", "diffInSeconds", "<", "3600", ")", "{", "$", "diffInMinutes", "=", "(", "int", ")", "(", "$", "diffInSeconds", "/", "60", ")", ";", "$", "remainder", "=", "(", "int", ")", "(", "$", "diffInSeconds", "%", "60", ")", ";", "$", "resultString", "=", "\"$diffInMinutes mins $remainder secs\"", ";", "}", "elseif", "(", "$", "diffInSeconds", "<", "86400", ")", "{", "$", "diffInHours", "=", "(", "int", ")", "(", "$", "diffInSeconds", "/", "3600", ")", ";", "$", "remainder", "=", "(", "int", ")", "(", "$", "diffInSeconds", "%", "3600", ")", ";", "$", "minutes", "=", "(", "int", ")", "(", "$", "remainder", "/", "60", ")", ";", "$", "resultString", "=", "\"$diffInHours hours $minutes mins\"", ";", "}", "else", "{", "$", "diffInDays", "=", "(", "int", ")", "(", "$", "diffInSeconds", "/", "86400", ")", ";", "$", "remainder", "=", "(", "int", ")", "(", "$", "diffInSeconds", "%", "86400", ")", ";", "$", "hours", "=", "(", "int", ")", "(", "$", "remainder", "/", "3600", ")", ";", "$", "resultString", "=", "\"$diffInDays days $hours hours\"", ";", "}", "return", "$", "resultString", ";", "}" ]
Given a timestamp, get how long ago it was in human readable form. E.g. 10 seconds 4 minutes 1 hour 456 days @param \DateTime $timestamp - the timestamp we want the difference to @return String - a human readable string to represent how long ago the timestamp was.
[ "Given", "a", "timestamp", "get", "how", "long", "ago", "it", "was", "in", "human", "readable", "form", ".", "E", ".", "g", ".", "10", "seconds", "4", "minutes", "1", "hour", "456", "days" ]
244871d2fbc2f3fac26ff4b98715224953d9befb
https://github.com/iRAP-software/package-core-libs/blob/244871d2fbc2f3fac26ff4b98715224953d9befb/src/TimeLib.php#L235-L268
9,910
tenside/core
src/Composer/Search/RepositorySearch.php
RepositorySearch.filter
protected function filter($packageNames, $filters) { if (empty($filters)) { return $packageNames; } $packages = []; foreach ($packageNames as $packageName) { if (count($package = $this->repository->findPackages($packageName)) > 0) { foreach ($filters as $filter) { $package = array_filter($package, $filter); } if ($package = current($package)) { $packages[$packageName] = $package; } } } return array_map( function ($package) { /** @var PackageInterface $package */ return $package->getName(); }, $packages ); }
php
protected function filter($packageNames, $filters) { if (empty($filters)) { return $packageNames; } $packages = []; foreach ($packageNames as $packageName) { if (count($package = $this->repository->findPackages($packageName)) > 0) { foreach ($filters as $filter) { $package = array_filter($package, $filter); } if ($package = current($package)) { $packages[$packageName] = $package; } } } return array_map( function ($package) { /** @var PackageInterface $package */ return $package->getName(); }, $packages ); }
[ "protected", "function", "filter", "(", "$", "packageNames", ",", "$", "filters", ")", "{", "if", "(", "empty", "(", "$", "filters", ")", ")", "{", "return", "$", "packageNames", ";", "}", "$", "packages", "=", "[", "]", ";", "foreach", "(", "$", "packageNames", "as", "$", "packageName", ")", "{", "if", "(", "count", "(", "$", "package", "=", "$", "this", "->", "repository", "->", "findPackages", "(", "$", "packageName", ")", ")", ">", "0", ")", "{", "foreach", "(", "$", "filters", "as", "$", "filter", ")", "{", "$", "package", "=", "array_filter", "(", "$", "package", ",", "$", "filter", ")", ";", "}", "if", "(", "$", "package", "=", "current", "(", "$", "package", ")", ")", "{", "$", "packages", "[", "$", "packageName", "]", "=", "$", "package", ";", "}", "}", "}", "return", "array_map", "(", "function", "(", "$", "package", ")", "{", "/** @var PackageInterface $package */", "return", "$", "package", "->", "getName", "(", ")", ";", "}", ",", "$", "packages", ")", ";", "}" ]
Filter the passed list of package names. @param string[] $packageNames The package names. @param \Closure[] $filters The filters to apply. @return string[]
[ "Filter", "the", "passed", "list", "of", "package", "names", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Composer/Search/RepositorySearch.php#L150-L175
9,911
tenside/core
src/Composer/Search/RepositorySearch.php
RepositorySearch.decorate
protected function decorate($packageName) { $results = $this->repository->findPackages($packageName); if (!count($results)) { throw new \InvalidArgumentException('Could not find package with specified name ' . $packageName); } $latest = array_slice($results, 0, 1)[0]; $versions = array_slice($results, 1); $package = new VersionedPackage($latest, $versions); return $this->decorateWithPackagistStats($package); }
php
protected function decorate($packageName) { $results = $this->repository->findPackages($packageName); if (!count($results)) { throw new \InvalidArgumentException('Could not find package with specified name ' . $packageName); } $latest = array_slice($results, 0, 1)[0]; $versions = array_slice($results, 1); $package = new VersionedPackage($latest, $versions); return $this->decorateWithPackagistStats($package); }
[ "protected", "function", "decorate", "(", "$", "packageName", ")", "{", "$", "results", "=", "$", "this", "->", "repository", "->", "findPackages", "(", "$", "packageName", ")", ";", "if", "(", "!", "count", "(", "$", "results", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Could not find package with specified name '", ".", "$", "packageName", ")", ";", "}", "$", "latest", "=", "array_slice", "(", "$", "results", ",", "0", ",", "1", ")", "[", "0", "]", ";", "$", "versions", "=", "array_slice", "(", "$", "results", ",", "1", ")", ";", "$", "package", "=", "new", "VersionedPackage", "(", "$", "latest", ",", "$", "versions", ")", ";", "return", "$", "this", "->", "decorateWithPackagistStats", "(", "$", "package", ")", ";", "}" ]
Decorate a package. @param string $packageName The name of the package to decorate. @return VersionedPackage @throws \InvalidArgumentException When the package could not be found.
[ "Decorate", "a", "package", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Composer/Search/RepositorySearch.php#L186-L199
9,912
tenside/core
src/Composer/Search/RepositorySearch.php
RepositorySearch.decorateWithPackagistStats
protected function decorateWithPackagistStats(VersionedPackage $package) { if (null === $this->decorateBaseUrl) { return $package; } $rfs = new RemoteFilesystem(new BufferIO()); $requestUrl = sprintf($this->decorateBaseUrl, $package->getName()); if (!($jsonData = $rfs->getContents($requestUrl, $requestUrl))) { $this->decorateBaseUrl = null; return $package; } try { $data = new JsonArray($jsonData); } catch (\RuntimeException $exception) { $this->decorateBaseUrl = null; return $package; } $metaPaths = [ 'downloads' => 'package/downloads/total', 'favers' => 'package/favers' ]; foreach ($metaPaths as $metaKey => $metaPath) { $package->addMetaData($metaKey, $data->get($metaPath)); } return $package; }
php
protected function decorateWithPackagistStats(VersionedPackage $package) { if (null === $this->decorateBaseUrl) { return $package; } $rfs = new RemoteFilesystem(new BufferIO()); $requestUrl = sprintf($this->decorateBaseUrl, $package->getName()); if (!($jsonData = $rfs->getContents($requestUrl, $requestUrl))) { $this->decorateBaseUrl = null; return $package; } try { $data = new JsonArray($jsonData); } catch (\RuntimeException $exception) { $this->decorateBaseUrl = null; return $package; } $metaPaths = [ 'downloads' => 'package/downloads/total', 'favers' => 'package/favers' ]; foreach ($metaPaths as $metaKey => $metaPath) { $package->addMetaData($metaKey, $data->get($metaPath)); } return $package; }
[ "protected", "function", "decorateWithPackagistStats", "(", "VersionedPackage", "$", "package", ")", "{", "if", "(", "null", "===", "$", "this", "->", "decorateBaseUrl", ")", "{", "return", "$", "package", ";", "}", "$", "rfs", "=", "new", "RemoteFilesystem", "(", "new", "BufferIO", "(", ")", ")", ";", "$", "requestUrl", "=", "sprintf", "(", "$", "this", "->", "decorateBaseUrl", ",", "$", "package", "->", "getName", "(", ")", ")", ";", "if", "(", "!", "(", "$", "jsonData", "=", "$", "rfs", "->", "getContents", "(", "$", "requestUrl", ",", "$", "requestUrl", ")", ")", ")", "{", "$", "this", "->", "decorateBaseUrl", "=", "null", ";", "return", "$", "package", ";", "}", "try", "{", "$", "data", "=", "new", "JsonArray", "(", "$", "jsonData", ")", ";", "}", "catch", "(", "\\", "RuntimeException", "$", "exception", ")", "{", "$", "this", "->", "decorateBaseUrl", "=", "null", ";", "return", "$", "package", ";", "}", "$", "metaPaths", "=", "[", "'downloads'", "=>", "'package/downloads/total'", ",", "'favers'", "=>", "'package/favers'", "]", ";", "foreach", "(", "$", "metaPaths", "as", "$", "metaKey", "=>", "$", "metaPath", ")", "{", "$", "package", "->", "addMetaData", "(", "$", "metaKey", ",", "$", "data", "->", "get", "(", "$", "metaPath", ")", ")", ";", "}", "return", "$", "package", ";", "}" ]
Decorate the package with stats from packagist. @param VersionedPackage $package The package version. @return VersionedPackage
[ "Decorate", "the", "package", "with", "stats", "from", "packagist", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Composer/Search/RepositorySearch.php#L208-L237
9,913
tenside/core
src/Composer/Search/RepositorySearch.php
RepositorySearch.disableSearchType
public function disableSearchType($searchType) { if (($key = array_search($searchType, $this->enabledSearchTypes)) !== false) { unset($this->enabledSearchTypes[$key]); } return $this; }
php
public function disableSearchType($searchType) { if (($key = array_search($searchType, $this->enabledSearchTypes)) !== false) { unset($this->enabledSearchTypes[$key]); } return $this; }
[ "public", "function", "disableSearchType", "(", "$", "searchType", ")", "{", "if", "(", "(", "$", "key", "=", "array_search", "(", "$", "searchType", ",", "$", "this", "->", "enabledSearchTypes", ")", ")", "!==", "false", ")", "{", "unset", "(", "$", "this", "->", "enabledSearchTypes", "[", "$", "key", "]", ")", ";", "}", "return", "$", "this", ";", "}" ]
Disable a search type. @param int $searchType The search type to disable. @return $this
[ "Disable", "a", "search", "type", "." ]
56422fa8cdecf03cb431bb6654c2942ade39bf7b
https://github.com/tenside/core/blob/56422fa8cdecf03cb431bb6654c2942ade39bf7b/src/Composer/Search/RepositorySearch.php#L301-L308
9,914
phlexible/phlexible
src/Phlexible/Bundle/UserBundle/Controller/StatusController.php
StatusController.indexAction
public function indexAction() { $body = ''; $body .= '<a href="'.$this->generateUrl('phlexible_status_user_context').'">Context</a><br />'; $body .= '<a href="'.$this->generateUrl('phlexible_status_user_session').'">Session</a>'; return new Response($body); }
php
public function indexAction() { $body = ''; $body .= '<a href="'.$this->generateUrl('phlexible_status_user_context').'">Context</a><br />'; $body .= '<a href="'.$this->generateUrl('phlexible_status_user_session').'">Session</a>'; return new Response($body); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "body", "=", "''", ";", "$", "body", ".=", "'<a href=\"'", ".", "$", "this", "->", "generateUrl", "(", "'phlexible_status_user_context'", ")", ".", "'\">Context</a><br />'", ";", "$", "body", ".=", "'<a href=\"'", ".", "$", "this", "->", "generateUrl", "(", "'phlexible_status_user_session'", ")", ".", "'\">Session</a>'", ";", "return", "new", "Response", "(", "$", "body", ")", ";", "}" ]
Show security status. @return Response @Route("", name="phlexible_status_user")
[ "Show", "security", "status", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/UserBundle/Controller/StatusController.php#L35-L42
9,915
phlexible/phlexible
src/Phlexible/Bundle/UserBundle/Controller/StatusController.php
StatusController.contextAction
public function contextAction() { $tokenStorage = $this->get('security.token_storage'); $token = $tokenStorage->getToken(); $user = $token->getUser(); $output = '<pre>'; $output .= 'Token class: '.get_class($token).PHP_EOL; $output .= 'User class: '.(is_object($user) ? get_class($user) : $user).PHP_EOL; $output .= PHP_EOL; $output .= 'Token username: '; $output .= print_r($token->getUsername(), 1).PHP_EOL; $output .= 'Token attributes: '; $output .= print_r($token->getAttributes(), 1).PHP_EOL; $output .= 'Token credentials: '; $output .= print_r($token->getCredentials(), 1).PHP_EOL; $output .= 'Token roles: '; $output .= print_r($token->getRoles(), 1).PHP_EOL; return new Response($output); }
php
public function contextAction() { $tokenStorage = $this->get('security.token_storage'); $token = $tokenStorage->getToken(); $user = $token->getUser(); $output = '<pre>'; $output .= 'Token class: '.get_class($token).PHP_EOL; $output .= 'User class: '.(is_object($user) ? get_class($user) : $user).PHP_EOL; $output .= PHP_EOL; $output .= 'Token username: '; $output .= print_r($token->getUsername(), 1).PHP_EOL; $output .= 'Token attributes: '; $output .= print_r($token->getAttributes(), 1).PHP_EOL; $output .= 'Token credentials: '; $output .= print_r($token->getCredentials(), 1).PHP_EOL; $output .= 'Token roles: '; $output .= print_r($token->getRoles(), 1).PHP_EOL; return new Response($output); }
[ "public", "function", "contextAction", "(", ")", "{", "$", "tokenStorage", "=", "$", "this", "->", "get", "(", "'security.token_storage'", ")", ";", "$", "token", "=", "$", "tokenStorage", "->", "getToken", "(", ")", ";", "$", "user", "=", "$", "token", "->", "getUser", "(", ")", ";", "$", "output", "=", "'<pre>'", ";", "$", "output", ".=", "'Token class: '", ".", "get_class", "(", "$", "token", ")", ".", "PHP_EOL", ";", "$", "output", ".=", "'User class: '", ".", "(", "is_object", "(", "$", "user", ")", "?", "get_class", "(", "$", "user", ")", ":", "$", "user", ")", ".", "PHP_EOL", ";", "$", "output", ".=", "PHP_EOL", ";", "$", "output", ".=", "'Token username: '", ";", "$", "output", ".=", "print_r", "(", "$", "token", "->", "getUsername", "(", ")", ",", "1", ")", ".", "PHP_EOL", ";", "$", "output", ".=", "'Token attributes: '", ";", "$", "output", ".=", "print_r", "(", "$", "token", "->", "getAttributes", "(", ")", ",", "1", ")", ".", "PHP_EOL", ";", "$", "output", ".=", "'Token credentials: '", ";", "$", "output", ".=", "print_r", "(", "$", "token", "->", "getCredentials", "(", ")", ",", "1", ")", ".", "PHP_EOL", ";", "$", "output", ".=", "'Token roles: '", ";", "$", "output", ".=", "print_r", "(", "$", "token", "->", "getRoles", "(", ")", ",", "1", ")", ".", "PHP_EOL", ";", "return", "new", "Response", "(", "$", "output", ")", ";", "}" ]
Show security context. @return Response @Route("/context", name="phlexible_status_user_context")
[ "Show", "security", "context", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/UserBundle/Controller/StatusController.php#L50-L71
9,916
phlexible/phlexible
src/Phlexible/Bundle/UserBundle/Controller/StatusController.php
StatusController.sessionAction
public function sessionAction(Request $request) { $output = '<pre>'; $output .= 'Security session namespace:'.PHP_EOL; $output .= '<ul>'; foreach ($request->getSession()->all() as $key => $value) { if (is_object($value)) { $o = get_class($value); } elseif (is_array($value)) { $o = 'array '.count($value); } else { $o = $value; if (@unserialize($o)) { $o = unserialize($o); } } $output .= '<li>'.$key.': '.$o.'</li>'; } $output .= '</ul>'; return new Response($output); }
php
public function sessionAction(Request $request) { $output = '<pre>'; $output .= 'Security session namespace:'.PHP_EOL; $output .= '<ul>'; foreach ($request->getSession()->all() as $key => $value) { if (is_object($value)) { $o = get_class($value); } elseif (is_array($value)) { $o = 'array '.count($value); } else { $o = $value; if (@unserialize($o)) { $o = unserialize($o); } } $output .= '<li>'.$key.': '.$o.'</li>'; } $output .= '</ul>'; return new Response($output); }
[ "public", "function", "sessionAction", "(", "Request", "$", "request", ")", "{", "$", "output", "=", "'<pre>'", ";", "$", "output", ".=", "'Security session namespace:'", ".", "PHP_EOL", ";", "$", "output", ".=", "'<ul>'", ";", "foreach", "(", "$", "request", "->", "getSession", "(", ")", "->", "all", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "$", "o", "=", "get_class", "(", "$", "value", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "o", "=", "'array '", ".", "count", "(", "$", "value", ")", ";", "}", "else", "{", "$", "o", "=", "$", "value", ";", "if", "(", "@", "unserialize", "(", "$", "o", ")", ")", "{", "$", "o", "=", "unserialize", "(", "$", "o", ")", ";", "}", "}", "$", "output", ".=", "'<li>'", ".", "$", "key", ".", "': '", ".", "$", "o", ".", "'</li>'", ";", "}", "$", "output", ".=", "'</ul>'", ";", "return", "new", "Response", "(", "$", "output", ")", ";", "}" ]
Show session. @param Request $request @return Response @Route("/session", name="phlexible_status_user_session")
[ "Show", "session", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/UserBundle/Controller/StatusController.php#L81-L102
9,917
marando/phpSOFA
src/Marando/IAU/iauLd.php
iauLd.Ld
public static function Ld($bm, array $p, array $q, array $e, $em, $dlim, array &$p1) { $i; $qpe = []; $qdqpe; $w; $eq = []; $peq = []; /* q . (q + e). */ for ($i = 0; $i < 3; $i++) { $qpe[$i] = $q[$i] + $e[$i]; } $qdqpe = IAU::Pdp($q, $qpe); /* 2 x G x bm / ( em x c^2 x ( q . (q + e) ) ). */ $w = $bm * SRS / $em / max($qdqpe, $dlim); /* p x (e x q). */ IAU::Pxp($e, $q, $eq); IAU::Pxp($p, $eq, $peq); /* Apply the deflection. */ for ($i = 0; $i < 3; $i++) { $p1[$i] = $p[$i] + $w * $peq[$i]; } /* Finished. */ }
php
public static function Ld($bm, array $p, array $q, array $e, $em, $dlim, array &$p1) { $i; $qpe = []; $qdqpe; $w; $eq = []; $peq = []; /* q . (q + e). */ for ($i = 0; $i < 3; $i++) { $qpe[$i] = $q[$i] + $e[$i]; } $qdqpe = IAU::Pdp($q, $qpe); /* 2 x G x bm / ( em x c^2 x ( q . (q + e) ) ). */ $w = $bm * SRS / $em / max($qdqpe, $dlim); /* p x (e x q). */ IAU::Pxp($e, $q, $eq); IAU::Pxp($p, $eq, $peq); /* Apply the deflection. */ for ($i = 0; $i < 3; $i++) { $p1[$i] = $p[$i] + $w * $peq[$i]; } /* Finished. */ }
[ "public", "static", "function", "Ld", "(", "$", "bm", ",", "array", "$", "p", ",", "array", "$", "q", ",", "array", "$", "e", ",", "$", "em", ",", "$", "dlim", ",", "array", "&", "$", "p1", ")", "{", "$", "i", ";", "$", "qpe", "=", "[", "]", ";", "$", "qdqpe", ";", "$", "w", ";", "$", "eq", "=", "[", "]", ";", "$", "peq", "=", "[", "]", ";", "/* q . (q + e). */", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "3", ";", "$", "i", "++", ")", "{", "$", "qpe", "[", "$", "i", "]", "=", "$", "q", "[", "$", "i", "]", "+", "$", "e", "[", "$", "i", "]", ";", "}", "$", "qdqpe", "=", "IAU", "::", "Pdp", "(", "$", "q", ",", "$", "qpe", ")", ";", "/* 2 x G x bm / ( em x c^2 x ( q . (q + e) ) ). */", "$", "w", "=", "$", "bm", "*", "SRS", "/", "$", "em", "/", "max", "(", "$", "qdqpe", ",", "$", "dlim", ")", ";", "/* p x (e x q). */", "IAU", "::", "Pxp", "(", "$", "e", ",", "$", "q", ",", "$", "eq", ")", ";", "IAU", "::", "Pxp", "(", "$", "p", ",", "$", "eq", ",", "$", "peq", ")", ";", "/* Apply the deflection. */", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "3", ";", "$", "i", "++", ")", "{", "$", "p1", "[", "$", "i", "]", "=", "$", "p", "[", "$", "i", "]", "+", "$", "w", "*", "$", "peq", "[", "$", "i", "]", ";", "}", "/* Finished. */", "}" ]
- - - - - - i a u L d - - - - - - Apply light deflection by a solar-system body, as part of transforming coordinate direction into natural direction. This function is part of the International Astronomical Union's SOFA (Standards of Fundamental Astronomy) software collection. Status: support function. Given: bm double mass of the gravitating body (solar masses) p double[3] direction from observer to source (unit vector) q double[3] direction from body to source (unit vector) e double[3] direction from body to observer (unit vector) em double distance from body to observer (au) dlim double deflection limiter (Note 4) Returned: p1 double[3] observer to deflected source (unit vector) Notes: 1) The algorithm is based on Expr. (70) in Klioner (2003) and Expr. (7.63) in the Explanatory Supplement (Urban & Seidelmann 2013), with some rearrangement to minimize the effects of machine precision. 2) The mass parameter bm can, as required, be adjusted in order to allow for such effects as quadrupole field. 3) The barycentric position of the deflecting body should ideally correspond to the time of closest approach of the light ray to the body. 4) The deflection limiter parameter dlim is phi^2/2, where phi is the angular separation (in radians) between source and body at which limiting is applied. As phi shrinks below the chosen threshold, the deflection is artificially reduced, reaching zero for phi = 0. 5) The returned vector p1 is not normalized, but the consequential departure from unit magnitude is always negligible. 6) The arguments p and p1 can be the same array. 7) To accumulate total light deflection taking into account the contributions from several bodies, call the present function for each body in succession, in decreasing order of distance from the observer. 8) For efficiency, validation is omitted. The supplied vectors must be of unit magnitude, and the deflection limiter non-zero and positive. References: Urban, S. & Seidelmann, P. K. (eds), Explanatory Supplement to the Astronomical Almanac, 3rd ed., University Science Books (2013). Klioner, Sergei A., "A practical relativistic model for micro- arcsecond astrometry in space", Astr. J. 125, 1580-1597 (2003). Called: iauPdp scalar product of two p-vectors iauPxp vector product of two p-vectors This revision: 2013 October 9 SOFA release 2015-02-09 Copyright (C) 2015 IAU SOFA Board. See notes at end.
[ "-", "-", "-", "-", "-", "-", "i", "a", "u", "L", "d", "-", "-", "-", "-", "-", "-" ]
757fa49fe335ae1210eaa7735473fd4388b13f07
https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauLd.php#L84-L113
9,918
synapsestudios/synapse-base
src/Synapse/CliCommand/CliCommandExecutor.php
CliCommandExecutor.execute
public function execute($command = '', $cwd = null, array $env = null) { $fd = proc_open( $command, $this->descriptors, $pipes, $cwd, $env ); // Close the proc's stdin right away fclose($pipes[0]); // Read stdout $output = $this->parseOutput(stream_get_contents($pipes[1])); fclose($pipes[1]); $returnCode = (int) trim(proc_close($fd)); return new CliCommandResponse([ 'output' => $output, 'return_code' => $returnCode, ]); }
php
public function execute($command = '', $cwd = null, array $env = null) { $fd = proc_open( $command, $this->descriptors, $pipes, $cwd, $env ); // Close the proc's stdin right away fclose($pipes[0]); // Read stdout $output = $this->parseOutput(stream_get_contents($pipes[1])); fclose($pipes[1]); $returnCode = (int) trim(proc_close($fd)); return new CliCommandResponse([ 'output' => $output, 'return_code' => $returnCode, ]); }
[ "public", "function", "execute", "(", "$", "command", "=", "''", ",", "$", "cwd", "=", "null", ",", "array", "$", "env", "=", "null", ")", "{", "$", "fd", "=", "proc_open", "(", "$", "command", ",", "$", "this", "->", "descriptors", ",", "$", "pipes", ",", "$", "cwd", ",", "$", "env", ")", ";", "// Close the proc's stdin right away", "fclose", "(", "$", "pipes", "[", "0", "]", ")", ";", "// Read stdout", "$", "output", "=", "$", "this", "->", "parseOutput", "(", "stream_get_contents", "(", "$", "pipes", "[", "1", "]", ")", ")", ";", "fclose", "(", "$", "pipes", "[", "1", "]", ")", ";", "$", "returnCode", "=", "(", "int", ")", "trim", "(", "proc_close", "(", "$", "fd", ")", ")", ";", "return", "new", "CliCommandResponse", "(", "[", "'output'", "=>", "$", "output", ",", "'return_code'", "=>", "$", "returnCode", ",", "]", ")", ";", "}" ]
Executes a cli command using proc_open @param string $command the command to be executed @param mixed $cwd the directory to execute in or null to use current @param mixed $env an array of environment variables or null to use current @return CliCommandResponse a DataObject with output and return_code set
[ "Executes", "a", "cli", "command", "using", "proc_open" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/CliCommand/CliCommandExecutor.php#L25-L48
9,919
synapsestudios/synapse-base
src/Synapse/CliCommand/CliCommandExecutor.php
CliCommandExecutor.parseOutput
protected function parseOutput($output) { $lines = explode("\n", $output); // This is the escape sequence that kills the stuff on the line, then // adds new text to it. The fake lines are separated by CRs instead of // NLs. You can thank whoever invented Bash for that $escapeStr = "\x1b\x5b\x4b"; $actualLines = array(); foreach ($lines as $line) { if (stripos($line, $escapeStr) !== false) { // Explode on the CR and take the last item, as that is the // actual line we want to show $parts = explode("\r", $line); $actualLine = array_pop($parts); // Remove the escape sequence $actualLines[] = str_replace($escapeStr, '', $actualLine); } else { $actualLines[] = $line; } } return trim(implode("\n", $actualLines)); }
php
protected function parseOutput($output) { $lines = explode("\n", $output); // This is the escape sequence that kills the stuff on the line, then // adds new text to it. The fake lines are separated by CRs instead of // NLs. You can thank whoever invented Bash for that $escapeStr = "\x1b\x5b\x4b"; $actualLines = array(); foreach ($lines as $line) { if (stripos($line, $escapeStr) !== false) { // Explode on the CR and take the last item, as that is the // actual line we want to show $parts = explode("\r", $line); $actualLine = array_pop($parts); // Remove the escape sequence $actualLines[] = str_replace($escapeStr, '', $actualLine); } else { $actualLines[] = $line; } } return trim(implode("\n", $actualLines)); }
[ "protected", "function", "parseOutput", "(", "$", "output", ")", "{", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "output", ")", ";", "// This is the escape sequence that kills the stuff on the line, then", "// adds new text to it. The fake lines are separated by CRs instead of", "// NLs. You can thank whoever invented Bash for that", "$", "escapeStr", "=", "\"\\x1b\\x5b\\x4b\"", ";", "$", "actualLines", "=", "array", "(", ")", ";", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "if", "(", "stripos", "(", "$", "line", ",", "$", "escapeStr", ")", "!==", "false", ")", "{", "// Explode on the CR and take the last item, as that is the", "// actual line we want to show", "$", "parts", "=", "explode", "(", "\"\\r\"", ",", "$", "line", ")", ";", "$", "actualLine", "=", "array_pop", "(", "$", "parts", ")", ";", "// Remove the escape sequence", "$", "actualLines", "[", "]", "=", "str_replace", "(", "$", "escapeStr", ",", "''", ",", "$", "actualLine", ")", ";", "}", "else", "{", "$", "actualLines", "[", "]", "=", "$", "line", ";", "}", "}", "return", "trim", "(", "implode", "(", "\"\\n\"", ",", "$", "actualLines", ")", ")", ";", "}" ]
Parses output from shell into usable string @param string $output the output from a shell commmand @return string the actual lines of output
[ "Parses", "output", "from", "shell", "into", "usable", "string" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/CliCommand/CliCommandExecutor.php#L56-L82
9,920
konservs/brilliant.framework
libraries/Users/BUsers.php
BUsers.getLoggedUser
public function getLoggedUser() { $session = BUsersSession::getInstanceAndStart(); if (empty($session)) { return NULL; } return $this->itemGet($session->userid); }
php
public function getLoggedUser() { $session = BUsersSession::getInstanceAndStart(); if (empty($session)) { return NULL; } return $this->itemGet($session->userid); }
[ "public", "function", "getLoggedUser", "(", ")", "{", "$", "session", "=", "BUsersSession", "::", "getInstanceAndStart", "(", ")", ";", "if", "(", "empty", "(", "$", "session", ")", ")", "{", "return", "NULL", ";", "}", "return", "$", "this", "->", "itemGet", "(", "$", "session", "->", "userid", ")", ";", "}" ]
Get logged user class @return BUser|null
[ "Get", "logged", "user", "class" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Users/BUsers.php#L69-L75
9,921
konservs/brilliant.framework
libraries/Users/BUsers.php
BUsers.login
public function login($email, $password, $longsession = false) { $user = $this->getUserByEmail($email); if ($user == false) { BLog::addToLog('[Users]: login() wrong email!', LL_ERROR); return USERS_ERROR_NOSUCHEMAIL; } if ($user->active == USER_STATUS_NOTACTIVATED) { BLog::addToLog('[Users]: Not Activated', LL_ERROR); return USERS_ERROR_NOACTIVATED; } if ($user->active == USER_STATUS_BANNED) { BLog::addToLog('[Users]: Banned user', LL_ERROR); return USERS_ERROR_BANNED; } $hash = $this->makepass($email, $password); if ($user->password != $hash) { BLog::addToLog('[Users]: password hashes not equal! user hash=' . $user->password . '; post hash=' . $hash, LL_ERROR); return USERS_ERROR_PASS; } $options = array('interval' => $longsession ? 2592000 : 10800, 'updatestep' => 60,); $sess = BUsersSession::getInstance(); $sess->newSession($user->id, $options); return USERS_ERROR_OK; }
php
public function login($email, $password, $longsession = false) { $user = $this->getUserByEmail($email); if ($user == false) { BLog::addToLog('[Users]: login() wrong email!', LL_ERROR); return USERS_ERROR_NOSUCHEMAIL; } if ($user->active == USER_STATUS_NOTACTIVATED) { BLog::addToLog('[Users]: Not Activated', LL_ERROR); return USERS_ERROR_NOACTIVATED; } if ($user->active == USER_STATUS_BANNED) { BLog::addToLog('[Users]: Banned user', LL_ERROR); return USERS_ERROR_BANNED; } $hash = $this->makepass($email, $password); if ($user->password != $hash) { BLog::addToLog('[Users]: password hashes not equal! user hash=' . $user->password . '; post hash=' . $hash, LL_ERROR); return USERS_ERROR_PASS; } $options = array('interval' => $longsession ? 2592000 : 10800, 'updatestep' => 60,); $sess = BUsersSession::getInstance(); $sess->newSession($user->id, $options); return USERS_ERROR_OK; }
[ "public", "function", "login", "(", "$", "email", ",", "$", "password", ",", "$", "longsession", "=", "false", ")", "{", "$", "user", "=", "$", "this", "->", "getUserByEmail", "(", "$", "email", ")", ";", "if", "(", "$", "user", "==", "false", ")", "{", "BLog", "::", "addToLog", "(", "'[Users]: login() wrong email!'", ",", "LL_ERROR", ")", ";", "return", "USERS_ERROR_NOSUCHEMAIL", ";", "}", "if", "(", "$", "user", "->", "active", "==", "USER_STATUS_NOTACTIVATED", ")", "{", "BLog", "::", "addToLog", "(", "'[Users]: Not Activated'", ",", "LL_ERROR", ")", ";", "return", "USERS_ERROR_NOACTIVATED", ";", "}", "if", "(", "$", "user", "->", "active", "==", "USER_STATUS_BANNED", ")", "{", "BLog", "::", "addToLog", "(", "'[Users]: Banned user'", ",", "LL_ERROR", ")", ";", "return", "USERS_ERROR_BANNED", ";", "}", "$", "hash", "=", "$", "this", "->", "makepass", "(", "$", "email", ",", "$", "password", ")", ";", "if", "(", "$", "user", "->", "password", "!=", "$", "hash", ")", "{", "BLog", "::", "addToLog", "(", "'[Users]: password hashes not equal! user hash='", ".", "$", "user", "->", "password", ".", "'; post hash='", ".", "$", "hash", ",", "LL_ERROR", ")", ";", "return", "USERS_ERROR_PASS", ";", "}", "$", "options", "=", "array", "(", "'interval'", "=>", "$", "longsession", "?", "2592000", ":", "10800", ",", "'updatestep'", "=>", "60", ",", ")", ";", "$", "sess", "=", "BUsersSession", "::", "getInstance", "(", ")", ";", "$", "sess", "->", "newSession", "(", "$", "user", "->", "id", ",", "$", "options", ")", ";", "return", "USERS_ERROR_OK", ";", "}" ]
Login. Returns user object @param $email @param $password @param bool|false $longsession @return BUser|int|null
[ "Login", ".", "Returns", "user", "object" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Users/BUsers.php#L85-L108
9,922
konservs/brilliant.framework
libraries/Users/BUsers.php
BUsers.itemsFilterSql
public function itemsFilterSql($params, &$wh, &$jn) { parent::itemsFilterSql($params, $wh, $jn); $db = BFactory::getDBO(); //Filter users by Email if (isset($params['email'])) { $wh[] = '(`email`=' . $db->escapeString($params['email']) . ')'; } return true; }
php
public function itemsFilterSql($params, &$wh, &$jn) { parent::itemsFilterSql($params, $wh, $jn); $db = BFactory::getDBO(); //Filter users by Email if (isset($params['email'])) { $wh[] = '(`email`=' . $db->escapeString($params['email']) . ')'; } return true; }
[ "public", "function", "itemsFilterSql", "(", "$", "params", ",", "&", "$", "wh", ",", "&", "$", "jn", ")", "{", "parent", "::", "itemsFilterSql", "(", "$", "params", ",", "$", "wh", ",", "$", "jn", ")", ";", "$", "db", "=", "BFactory", "::", "getDBO", "(", ")", ";", "//Filter users by Email", "if", "(", "isset", "(", "$", "params", "[", "'email'", "]", ")", ")", "{", "$", "wh", "[", "]", "=", "'(`email`='", ".", "$", "db", "->", "escapeString", "(", "$", "params", "[", "'email'", "]", ")", ".", "')'", ";", "}", "return", "true", ";", "}" ]
Items Filter SQL @param $params @param $wh @param $jn @return bool
[ "Items", "Filter", "SQL" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Users/BUsers.php#L118-L126
9,923
konservs/brilliant.framework
libraries/Users/BUsers.php
BUsers.itemsFilterHash
public function itemsFilterHash($params) { $itemsHash = parent::itemsFilterHash($params); //Filter users by email if (isset($params['email'])) { $itemsHash .= ':email=' . $params['email']; } return $itemsHash; }
php
public function itemsFilterHash($params) { $itemsHash = parent::itemsFilterHash($params); //Filter users by email if (isset($params['email'])) { $itemsHash .= ':email=' . $params['email']; } return $itemsHash; }
[ "public", "function", "itemsFilterHash", "(", "$", "params", ")", "{", "$", "itemsHash", "=", "parent", "::", "itemsFilterHash", "(", "$", "params", ")", ";", "//Filter users by email", "if", "(", "isset", "(", "$", "params", "[", "'email'", "]", ")", ")", "{", "$", "itemsHash", ".=", "':email='", ".", "$", "params", "[", "'email'", "]", ";", "}", "return", "$", "itemsHash", ";", "}" ]
Return items hash @param array $params @return string
[ "Return", "items", "hash" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Users/BUsers.php#L133-L140
9,924
konservs/brilliant.framework
libraries/Users/BUsers.php
BUsers.getUserByEmail
public function getUserByEmail($email) { $list = $this->itemsFilter(['email' => $email, 'limit' => 1]); if (empty($list)) { return NULL; } $user = reset($list); return $user; }
php
public function getUserByEmail($email) { $list = $this->itemsFilter(['email' => $email, 'limit' => 1]); if (empty($list)) { return NULL; } $user = reset($list); return $user; }
[ "public", "function", "getUserByEmail", "(", "$", "email", ")", "{", "$", "list", "=", "$", "this", "->", "itemsFilter", "(", "[", "'email'", "=>", "$", "email", ",", "'limit'", "=>", "1", "]", ")", ";", "if", "(", "empty", "(", "$", "list", ")", ")", "{", "return", "NULL", ";", "}", "$", "user", "=", "reset", "(", "$", "list", ")", ";", "return", "$", "user", ";", "}" ]
Get user By email @param $email @return BUser|null
[ "Get", "user", "By", "email" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/Users/BUsers.php#L147-L154
9,925
mooti/framework
src/Util/FileSystem.php
FileSystem.filePutContents
public function filePutContents($filePath, $data) { $bytesWritten = @file_put_contents($filePath, $data); if ($bytesWritten === false) { throw new FileSystemException('File '.$filePath.' could not be written'); } return true; }
php
public function filePutContents($filePath, $data) { $bytesWritten = @file_put_contents($filePath, $data); if ($bytesWritten === false) { throw new FileSystemException('File '.$filePath.' could not be written'); } return true; }
[ "public", "function", "filePutContents", "(", "$", "filePath", ",", "$", "data", ")", "{", "$", "bytesWritten", "=", "@", "file_put_contents", "(", "$", "filePath", ",", "$", "data", ")", ";", "if", "(", "$", "bytesWritten", "===", "false", ")", "{", "throw", "new", "FileSystemException", "(", "'File '", ".", "$", "filePath", ".", "' could not be written'", ")", ";", "}", "return", "true", ";", "}" ]
write to a file @param string $filePath The path of the file @param string $data The contents of the file @return string The contents of the file
[ "write", "to", "a", "file" ]
078da6699c5c6c7ac4e5a3d36751d645ad8aa93e
https://github.com/mooti/framework/blob/078da6699c5c6c7ac4e5a3d36751d645ad8aa93e/src/Util/FileSystem.php#L73-L80
9,926
belgattitude/soluble-schema
src/Soluble/Schema/Source/AbstractSchemaSource.php
AbstractSchemaSource.validateTable
protected function validateTable($table) { $this->checkTableArgument($table); if (!$this->hasTable($table)) { throw new Exception\TableNotFoundException(__METHOD__ . ": Table '$table' does not exists in database '{$this->schema}'"); } return $this; }
php
protected function validateTable($table) { $this->checkTableArgument($table); if (!$this->hasTable($table)) { throw new Exception\TableNotFoundException(__METHOD__ . ": Table '$table' does not exists in database '{$this->schema}'"); } return $this; }
[ "protected", "function", "validateTable", "(", "$", "table", ")", "{", "$", "this", "->", "checkTableArgument", "(", "$", "table", ")", ";", "if", "(", "!", "$", "this", "->", "hasTable", "(", "$", "table", ")", ")", "{", "throw", "new", "Exception", "\\", "TableNotFoundException", "(", "__METHOD__", ".", "\": Table '$table' does not exists in database '{$this->schema}'\"", ")", ";", "}", "return", "$", "this", ";", "}" ]
Check whether a table parameter is valid and exists. @throws Exception\InvalidArgumentException @throws Exception\ErrorException @throws Exception\ExceptionInterface @throws Exception\TableNotFoundException @param string $table @return self
[ "Check", "whether", "a", "table", "parameter", "is", "valid", "and", "exists", "." ]
7c6959740f7392ef22c12c2118ddf53294a01955
https://github.com/belgattitude/soluble-schema/blob/7c6959740f7392ef22c12c2118ddf53294a01955/src/Soluble/Schema/Source/AbstractSchemaSource.php#L100-L108
9,927
belgattitude/soluble-schema
src/Soluble/Schema/Source/AbstractSchemaSource.php
AbstractSchemaSource.validateSchema
protected function validateSchema($schema) { if (!is_string($schema) || trim($schema) == '') { throw new Exception\InvalidArgumentException(__METHOD__ . ': Schema name must be a valid string or an empty string detected'); } return $this; }
php
protected function validateSchema($schema) { if (!is_string($schema) || trim($schema) == '') { throw new Exception\InvalidArgumentException(__METHOD__ . ': Schema name must be a valid string or an empty string detected'); } return $this; }
[ "protected", "function", "validateSchema", "(", "$", "schema", ")", "{", "if", "(", "!", "is_string", "(", "$", "schema", ")", "||", "trim", "(", "$", "schema", ")", "==", "''", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "__METHOD__", ".", "': Schema name must be a valid string or an empty string detected'", ")", ";", "}", "return", "$", "this", ";", "}" ]
Check whether a schema parameter is valid. @throws Exception\InvalidArgumentException @param string $schema @return self
[ "Check", "whether", "a", "schema", "parameter", "is", "valid", "." ]
7c6959740f7392ef22c12c2118ddf53294a01955
https://github.com/belgattitude/soluble-schema/blob/7c6959740f7392ef22c12c2118ddf53294a01955/src/Soluble/Schema/Source/AbstractSchemaSource.php#L119-L126
9,928
belgattitude/soluble-schema
src/Soluble/Schema/Source/AbstractSchemaSource.php
AbstractSchemaSource.setSchemaSignature
protected function setSchemaSignature() { $host = $this->adapter->getConnection()->getHost(); $schema = $this->schema; $this->schemaSignature = "$host:$schema"; }
php
protected function setSchemaSignature() { $host = $this->adapter->getConnection()->getHost(); $schema = $this->schema; $this->schemaSignature = "$host:$schema"; }
[ "protected", "function", "setSchemaSignature", "(", ")", "{", "$", "host", "=", "$", "this", "->", "adapter", "->", "getConnection", "(", ")", "->", "getHost", "(", ")", ";", "$", "schema", "=", "$", "this", "->", "schema", ";", "$", "this", "->", "schemaSignature", "=", "\"$host:$schema\"", ";", "}" ]
Return current schema signature for caching.
[ "Return", "current", "schema", "signature", "for", "caching", "." ]
7c6959740f7392ef22c12c2118ddf53294a01955
https://github.com/belgattitude/soluble-schema/blob/7c6959740f7392ef22c12c2118ddf53294a01955/src/Soluble/Schema/Source/AbstractSchemaSource.php#L162-L167
9,929
rollun-com/rollun-permission
src/Permission/src/OAuth/GoogleClient.php
GoogleClient.authenticateWithAuthCode
public function authenticateWithAuthCode($authCode) { $accessToken = $this->fetchAccessTokenWithAuthCode($authCode); $this->getLogger()->debug('Access token with auth code: ' . json_encode($accessToken)); return !array_key_exists('error', $accessToken); }
php
public function authenticateWithAuthCode($authCode) { $accessToken = $this->fetchAccessTokenWithAuthCode($authCode); $this->getLogger()->debug('Access token with auth code: ' . json_encode($accessToken)); return !array_key_exists('error', $accessToken); }
[ "public", "function", "authenticateWithAuthCode", "(", "$", "authCode", ")", "{", "$", "accessToken", "=", "$", "this", "->", "fetchAccessTokenWithAuthCode", "(", "$", "authCode", ")", ";", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "'Access token with auth code: '", ".", "json_encode", "(", "$", "accessToken", ")", ")", ";", "return", "!", "array_key_exists", "(", "'error'", ",", "$", "accessToken", ")", ";", "}" ]
Authentication passed if access token can be fetch using authorization code @param $authCode @return bool @throws Exception
[ "Authentication", "passed", "if", "access", "token", "can", "be", "fetch", "using", "authorization", "code" ]
9f58c814337fcfd1e52ecfbf496f95d276d8217e
https://github.com/rollun-com/rollun-permission/blob/9f58c814337fcfd1e52ecfbf496f95d276d8217e/src/Permission/src/OAuth/GoogleClient.php#L39-L45
9,930
rollun-com/rollun-permission
src/Permission/src/OAuth/GoogleClient.php
GoogleClient.getAccessToken
public function getAccessToken() { $this->getLogger()->debug('Get access token. If expired try to update'); if ($this->isAccessTokenExpired() && $this->getRefreshToken()) { $this->fetchAccessTokenWithRefreshToken($this->getRefreshToken()); } return parent::getAccessToken(); }
php
public function getAccessToken() { $this->getLogger()->debug('Get access token. If expired try to update'); if ($this->isAccessTokenExpired() && $this->getRefreshToken()) { $this->fetchAccessTokenWithRefreshToken($this->getRefreshToken()); } return parent::getAccessToken(); }
[ "public", "function", "getAccessToken", "(", ")", "{", "$", "this", "->", "getLogger", "(", ")", "->", "debug", "(", "'Get access token. If expired try to update'", ")", ";", "if", "(", "$", "this", "->", "isAccessTokenExpired", "(", ")", "&&", "$", "this", "->", "getRefreshToken", "(", ")", ")", "{", "$", "this", "->", "fetchAccessTokenWithRefreshToken", "(", "$", "this", "->", "getRefreshToken", "(", ")", ")", ";", "}", "return", "parent", "::", "getAccessToken", "(", ")", ";", "}" ]
Proxy for parent method Get new access token if it expired using refresh token @return array
[ "Proxy", "for", "parent", "method", "Get", "new", "access", "token", "if", "it", "expired", "using", "refresh", "token" ]
9f58c814337fcfd1e52ecfbf496f95d276d8217e
https://github.com/rollun-com/rollun-permission/blob/9f58c814337fcfd1e52ecfbf496f95d276d8217e/src/Permission/src/OAuth/GoogleClient.php#L53-L62
9,931
bishopb/vanilla
applications/dashboard/models/class.rolemodel.php
RoleModel.FilterPersonalInfo
public static function FilterPersonalInfo($Role) { if (is_string($Role)) { $Role = array_shift(self::GetByName($Role)); } return (GetValue('PersonalInfo', $Role)) ? FALSE : TRUE; }
php
public static function FilterPersonalInfo($Role) { if (is_string($Role)) { $Role = array_shift(self::GetByName($Role)); } return (GetValue('PersonalInfo', $Role)) ? FALSE : TRUE; }
[ "public", "static", "function", "FilterPersonalInfo", "(", "$", "Role", ")", "{", "if", "(", "is_string", "(", "$", "Role", ")", ")", "{", "$", "Role", "=", "array_shift", "(", "self", "::", "GetByName", "(", "$", "Role", ")", ")", ";", "}", "return", "(", "GetValue", "(", "'PersonalInfo'", ",", "$", "Role", ")", ")", "?", "FALSE", ":", "TRUE", ";", "}" ]
Use with array_filter to remove PersonalInfo roles. @var mixed $Roles Role name (string) or $Role data (array or object). @return bool Whether role is NOT personal info (FALSE = remove it, it's personal).
[ "Use", "with", "array_filter", "to", "remove", "PersonalInfo", "roles", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.rolemodel.php#L58-L64
9,932
bishopb/vanilla
applications/dashboard/models/class.rolemodel.php
RoleModel.GetArray
public function GetArray() { // $RoleData = $this->GetEditablePermissions(); $RoleData = $this->Get(); $RoleIDs = ConsolidateArrayValuesByKey($RoleData->ResultArray(), 'RoleID'); $RoleNames = ConsolidateArrayValuesByKey($RoleData->ResultArray(), 'Name'); return ArrayCombine($RoleIDs, $RoleNames); }
php
public function GetArray() { // $RoleData = $this->GetEditablePermissions(); $RoleData = $this->Get(); $RoleIDs = ConsolidateArrayValuesByKey($RoleData->ResultArray(), 'RoleID'); $RoleNames = ConsolidateArrayValuesByKey($RoleData->ResultArray(), 'Name'); return ArrayCombine($RoleIDs, $RoleNames); }
[ "public", "function", "GetArray", "(", ")", "{", "// $RoleData = $this->GetEditablePermissions();", "$", "RoleData", "=", "$", "this", "->", "Get", "(", ")", ";", "$", "RoleIDs", "=", "ConsolidateArrayValuesByKey", "(", "$", "RoleData", "->", "ResultArray", "(", ")", ",", "'RoleID'", ")", ";", "$", "RoleNames", "=", "ConsolidateArrayValuesByKey", "(", "$", "RoleData", "->", "ResultArray", "(", ")", ",", "'Name'", ")", ";", "return", "ArrayCombine", "(", "$", "RoleIDs", ",", "$", "RoleNames", ")", ";", "}" ]
Returns an array of RoleID => RoleName pairs. @return array
[ "Returns", "an", "array", "of", "RoleID", "=", ">", "RoleName", "pairs", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.rolemodel.php#L82-L88
9,933
bishopb/vanilla
applications/dashboard/models/class.rolemodel.php
RoleModel.GetByUserID
public function GetByUserID($UserID) { return $this->SQL->Select() ->From('Role') ->Join('UserRole', 'Role.RoleID = UserRole.RoleID') ->Where('UserRole.UserID', $UserID) ->Get(); }
php
public function GetByUserID($UserID) { return $this->SQL->Select() ->From('Role') ->Join('UserRole', 'Role.RoleID = UserRole.RoleID') ->Where('UserRole.UserID', $UserID) ->Get(); }
[ "public", "function", "GetByUserID", "(", "$", "UserID", ")", "{", "return", "$", "this", "->", "SQL", "->", "Select", "(", ")", "->", "From", "(", "'Role'", ")", "->", "Join", "(", "'UserRole'", ",", "'Role.RoleID = UserRole.RoleID'", ")", "->", "Where", "(", "'UserRole.UserID'", ",", "$", "UserID", ")", "->", "Get", "(", ")", ";", "}" ]
Returns a resultset of role data related to the specified UserID. @param int The UserID to filter to. @return Gdn_DataSet
[ "Returns", "a", "resultset", "of", "role", "data", "related", "to", "the", "specified", "UserID", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.rolemodel.php#L118-L124
9,934
bd808/moar-log
src/Moar/Log/Monolog/HierarchialLogger.php
HierarchialLogger.setParent
public function setParent (Logger $parent) { $this->handlers = $parent->handlers; $this->processors = $parent->processors; $this->level = $parent->level; }
php
public function setParent (Logger $parent) { $this->handlers = $parent->handlers; $this->processors = $parent->processors; $this->level = $parent->level; }
[ "public", "function", "setParent", "(", "Logger", "$", "parent", ")", "{", "$", "this", "->", "handlers", "=", "$", "parent", "->", "handlers", ";", "$", "this", "->", "processors", "=", "$", "parent", "->", "processors", ";", "$", "this", "->", "level", "=", "$", "parent", "->", "level", ";", "}" ]
Set this logger's parent logger. @param HierarchialLogger $parent Parent logger @return void
[ "Set", "this", "logger", "s", "parent", "logger", "." ]
01f44c46fef9a612cef6209c3bd69c97f3475064
https://github.com/bd808/moar-log/blob/01f44c46fef9a612cef6209c3bd69c97f3475064/src/Moar/Log/Monolog/HierarchialLogger.php#L33-L37
9,935
novuso/common
src/Domain/Value/DateTime/Date.php
Date.create
public static function create(int $year, int $month, int $day): Date { return new static($year, $month, $day); }
php
public static function create(int $year, int $month, int $day): Date { return new static($year, $month, $day); }
[ "public", "static", "function", "create", "(", "int", "$", "year", ",", "int", "$", "month", ",", "int", "$", "day", ")", ":", "Date", "{", "return", "new", "static", "(", "$", "year", ",", "$", "month", ",", "$", "day", ")", ";", "}" ]
Creates instance from date values @param int $year The year @param int $month The month @param int $day The day @return Date @throws DomainException When the date is not valid
[ "Creates", "instance", "from", "date", "values" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/Date.php#L71-L74
9,936
novuso/common
src/Domain/Value/DateTime/Date.php
Date.now
public static function now(?string $timezone = null): Date { $timezone = $timezone ?: date_default_timezone_get(); assert(Validate::isTimezone($timezone), sprintf('Invalid timezone: %s', $timezone)); $dateTime = new DateTimeImmutable('now', new DateTimeZone($timezone)); $year = (int) $dateTime->format('Y'); $month = (int) $dateTime->format('n'); $day = (int) $dateTime->format('j'); return new static($year, $month, $day); }
php
public static function now(?string $timezone = null): Date { $timezone = $timezone ?: date_default_timezone_get(); assert(Validate::isTimezone($timezone), sprintf('Invalid timezone: %s', $timezone)); $dateTime = new DateTimeImmutable('now', new DateTimeZone($timezone)); $year = (int) $dateTime->format('Y'); $month = (int) $dateTime->format('n'); $day = (int) $dateTime->format('j'); return new static($year, $month, $day); }
[ "public", "static", "function", "now", "(", "?", "string", "$", "timezone", "=", "null", ")", ":", "Date", "{", "$", "timezone", "=", "$", "timezone", "?", ":", "date_default_timezone_get", "(", ")", ";", "assert", "(", "Validate", "::", "isTimezone", "(", "$", "timezone", ")", ",", "sprintf", "(", "'Invalid timezone: %s'", ",", "$", "timezone", ")", ")", ";", "$", "dateTime", "=", "new", "DateTimeImmutable", "(", "'now'", ",", "new", "DateTimeZone", "(", "$", "timezone", ")", ")", ";", "$", "year", "=", "(", "int", ")", "$", "dateTime", "->", "format", "(", "'Y'", ")", ";", "$", "month", "=", "(", "int", ")", "$", "dateTime", "->", "format", "(", "'n'", ")", ";", "$", "day", "=", "(", "int", ")", "$", "dateTime", "->", "format", "(", "'j'", ")", ";", "return", "new", "static", "(", "$", "year", ",", "$", "month", ",", "$", "day", ")", ";", "}" ]
Creates instance for the current date @param string|null $timezone The timezone string or null for default @return Date
[ "Creates", "instance", "for", "the", "current", "date" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/Date.php#L83-L94
9,937
novuso/common
src/Domain/Value/DateTime/Date.php
Date.guardDate
protected function guardDate(int $year, int $month, int $day): void { if (!checkdate($month, $day, $year)) { $message = sprintf('Invalid date: %04d-%02d-%02d', $year, $month, $day); throw new DomainException($message); } }
php
protected function guardDate(int $year, int $month, int $day): void { if (!checkdate($month, $day, $year)) { $message = sprintf('Invalid date: %04d-%02d-%02d', $year, $month, $day); throw new DomainException($message); } }
[ "protected", "function", "guardDate", "(", "int", "$", "year", ",", "int", "$", "month", ",", "int", "$", "day", ")", ":", "void", "{", "if", "(", "!", "checkdate", "(", "$", "month", ",", "$", "day", ",", "$", "year", ")", ")", "{", "$", "message", "=", "sprintf", "(", "'Invalid date: %04d-%02d-%02d'", ",", "$", "year", ",", "$", "month", ",", "$", "day", ")", ";", "throw", "new", "DomainException", "(", "$", "message", ")", ";", "}", "}" ]
Validates the date @param int $year The year @param int $month The month @param int $day The day @return void @throws DomainException When the date is not valid
[ "Validates", "the", "date" ]
7d0e5a4f4c79c9622e068efc8b7c70815c460863
https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/Date.php#L240-L246
9,938
oroinc/OroChainProcessorComponent
ChainProcessorFactory.php
ChainProcessorFactory.addFactory
public function addFactory(ProcessorFactoryInterface $factory, $priority = 0) { $this->factories[$priority][] = $factory; // sort by priority and flatten // we do it here due to performance reasons (it is expected that it will be only several factories, // but the getProcessor method will be called a lot of times) \krsort($this->factories); $this->sortedFactories = \array_merge(...$this->factories); }
php
public function addFactory(ProcessorFactoryInterface $factory, $priority = 0) { $this->factories[$priority][] = $factory; // sort by priority and flatten // we do it here due to performance reasons (it is expected that it will be only several factories, // but the getProcessor method will be called a lot of times) \krsort($this->factories); $this->sortedFactories = \array_merge(...$this->factories); }
[ "public", "function", "addFactory", "(", "ProcessorFactoryInterface", "$", "factory", ",", "$", "priority", "=", "0", ")", "{", "$", "this", "->", "factories", "[", "$", "priority", "]", "[", "]", "=", "$", "factory", ";", "// sort by priority and flatten", "// we do it here due to performance reasons (it is expected that it will be only several factories,", "// but the getProcessor method will be called a lot of times)", "\\", "krsort", "(", "$", "this", "->", "factories", ")", ";", "$", "this", "->", "sortedFactories", "=", "\\", "array_merge", "(", "...", "$", "this", "->", "factories", ")", ";", "}" ]
Registers a factory in the chain @param ProcessorFactoryInterface $factory @param int $priority
[ "Registers", "a", "factory", "in", "the", "chain" ]
89c9bc60140292c9367a0c3178f760ecbcec6bd2
https://github.com/oroinc/OroChainProcessorComponent/blob/89c9bc60140292c9367a0c3178f760ecbcec6bd2/ChainProcessorFactory.php#L22-L30
9,939
themichaelhall/datatypes
src/UrlPath.php
UrlPath.equals
public function equals(UrlPathInterface $urlPath): bool { return $this->isAbsolute() === $urlPath->isAbsolute() && $this->getDirectoryParts() === $urlPath->getDirectoryParts() && $this->getFilename() === $urlPath->getFilename(); }
php
public function equals(UrlPathInterface $urlPath): bool { return $this->isAbsolute() === $urlPath->isAbsolute() && $this->getDirectoryParts() === $urlPath->getDirectoryParts() && $this->getFilename() === $urlPath->getFilename(); }
[ "public", "function", "equals", "(", "UrlPathInterface", "$", "urlPath", ")", ":", "bool", "{", "return", "$", "this", "->", "isAbsolute", "(", ")", "===", "$", "urlPath", "->", "isAbsolute", "(", ")", "&&", "$", "this", "->", "getDirectoryParts", "(", ")", "===", "$", "urlPath", "->", "getDirectoryParts", "(", ")", "&&", "$", "this", "->", "getFilename", "(", ")", "===", "$", "urlPath", "->", "getFilename", "(", ")", ";", "}" ]
Returns true if the url path equals other url path, false otherwise. @since 1.2.0 @param UrlPathInterface $urlPath The other url path. @return bool True if the url path equals other url path, false otherwise.
[ "Returns", "true", "if", "the", "url", "path", "equals", "other", "url", "path", "false", "otherwise", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/UrlPath.php#L34-L37
9,940
themichaelhall/datatypes
src/UrlPath.php
UrlPath.getDirectory
public function getDirectory(): UrlPathInterface { return new self($this->myIsAbsolute, $this->myAboveBaseLevel, $this->myDirectoryParts, null); }
php
public function getDirectory(): UrlPathInterface { return new self($this->myIsAbsolute, $this->myAboveBaseLevel, $this->myDirectoryParts, null); }
[ "public", "function", "getDirectory", "(", ")", ":", "UrlPathInterface", "{", "return", "new", "self", "(", "$", "this", "->", "myIsAbsolute", ",", "$", "this", "->", "myAboveBaseLevel", ",", "$", "this", "->", "myDirectoryParts", ",", "null", ")", ";", "}" ]
Returns the directory of the url path. @since 1.0.0 @return UrlPathInterface The directory of the url path.
[ "Returns", "the", "directory", "of", "the", "url", "path", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/UrlPath.php#L46-L49
9,941
themichaelhall/datatypes
src/UrlPath.php
UrlPath.getParentDirectory
public function getParentDirectory(): ?UrlPathInterface { if ($this->myParentDirectory($aboveBaseLevel, $directoryParts)) { return new self($this->myIsAbsolute, $aboveBaseLevel, $directoryParts, null); } return null; }
php
public function getParentDirectory(): ?UrlPathInterface { if ($this->myParentDirectory($aboveBaseLevel, $directoryParts)) { return new self($this->myIsAbsolute, $aboveBaseLevel, $directoryParts, null); } return null; }
[ "public", "function", "getParentDirectory", "(", ")", ":", "?", "UrlPathInterface", "{", "if", "(", "$", "this", "->", "myParentDirectory", "(", "$", "aboveBaseLevel", ",", "$", "directoryParts", ")", ")", "{", "return", "new", "self", "(", "$", "this", "->", "myIsAbsolute", ",", "$", "aboveBaseLevel", ",", "$", "directoryParts", ",", "null", ")", ";", "}", "return", "null", ";", "}" ]
Returns the parent directory of the url path or null if url path does not have a parent directory. @since 1.0.0 @return UrlPathInterface|null The parent directory of the url path or null if url path does not have a parent directory.
[ "Returns", "the", "parent", "directory", "of", "the", "url", "path", "or", "null", "if", "url", "path", "does", "not", "have", "a", "parent", "directory", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/UrlPath.php#L58-L65
9,942
themichaelhall/datatypes
src/UrlPath.php
UrlPath.toAbsolute
public function toAbsolute(): UrlPathInterface { if ($this->myAboveBaseLevel > 0) { throw new UrlPathLogicException('Url path "' . $this->__toString() . '" can not be made absolute: Relative path is above base level.'); } return new self(true, $this->myAboveBaseLevel, $this->myDirectoryParts, $this->myFilename); }
php
public function toAbsolute(): UrlPathInterface { if ($this->myAboveBaseLevel > 0) { throw new UrlPathLogicException('Url path "' . $this->__toString() . '" can not be made absolute: Relative path is above base level.'); } return new self(true, $this->myAboveBaseLevel, $this->myDirectoryParts, $this->myFilename); }
[ "public", "function", "toAbsolute", "(", ")", ":", "UrlPathInterface", "{", "if", "(", "$", "this", "->", "myAboveBaseLevel", ">", "0", ")", "{", "throw", "new", "UrlPathLogicException", "(", "'Url path \"'", ".", "$", "this", "->", "__toString", "(", ")", ".", "'\" can not be made absolute: Relative path is above base level.'", ")", ";", "}", "return", "new", "self", "(", "true", ",", "$", "this", "->", "myAboveBaseLevel", ",", "$", "this", "->", "myDirectoryParts", ",", "$", "this", "->", "myFilename", ")", ";", "}" ]
Returns The url path as an absolute path. @since 1.0.0 @throws UrlPathLogicException if the url path could not be made absolute. @return UrlPathInterface The url path as an absolute path.
[ "Returns", "The", "url", "path", "as", "an", "absolute", "path", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/UrlPath.php#L76-L83
9,943
themichaelhall/datatypes
src/UrlPath.php
UrlPath.toRelative
public function toRelative(): UrlPathInterface { return new self(false, $this->myAboveBaseLevel, $this->myDirectoryParts, $this->myFilename); }
php
public function toRelative(): UrlPathInterface { return new self(false, $this->myAboveBaseLevel, $this->myDirectoryParts, $this->myFilename); }
[ "public", "function", "toRelative", "(", ")", ":", "UrlPathInterface", "{", "return", "new", "self", "(", "false", ",", "$", "this", "->", "myAboveBaseLevel", ",", "$", "this", "->", "myDirectoryParts", ",", "$", "this", "->", "myFilename", ")", ";", "}" ]
Returns the url path as a relative path. @since 1.0.0 @return UrlPathInterface The url path as a relative path.
[ "Returns", "the", "url", "path", "as", "a", "relative", "path", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/UrlPath.php#L92-L95
9,944
themichaelhall/datatypes
src/UrlPath.php
UrlPath.withUrlPath
public function withUrlPath(UrlPathInterface $urlPath): UrlPathInterface { if (!$this->myCombine($urlPath, $isAbsolute, $aboveBaseLevel, $directoryParts, $filename, $error)) { throw new UrlPathLogicException('Url path "' . $this->__toString() . '" can not be combined with url path "' . $urlPath->__toString() . '": ' . $error); } return new self($isAbsolute, $aboveBaseLevel, $directoryParts, $filename); }
php
public function withUrlPath(UrlPathInterface $urlPath): UrlPathInterface { if (!$this->myCombine($urlPath, $isAbsolute, $aboveBaseLevel, $directoryParts, $filename, $error)) { throw new UrlPathLogicException('Url path "' . $this->__toString() . '" can not be combined with url path "' . $urlPath->__toString() . '": ' . $error); } return new self($isAbsolute, $aboveBaseLevel, $directoryParts, $filename); }
[ "public", "function", "withUrlPath", "(", "UrlPathInterface", "$", "urlPath", ")", ":", "UrlPathInterface", "{", "if", "(", "!", "$", "this", "->", "myCombine", "(", "$", "urlPath", ",", "$", "isAbsolute", ",", "$", "aboveBaseLevel", ",", "$", "directoryParts", ",", "$", "filename", ",", "$", "error", ")", ")", "{", "throw", "new", "UrlPathLogicException", "(", "'Url path \"'", ".", "$", "this", "->", "__toString", "(", ")", ".", "'\" can not be combined with url path \"'", ".", "$", "urlPath", "->", "__toString", "(", ")", ".", "'\": '", ".", "$", "error", ")", ";", "}", "return", "new", "self", "(", "$", "isAbsolute", ",", "$", "aboveBaseLevel", ",", "$", "directoryParts", ",", "$", "filename", ")", ";", "}" ]
Returns a copy of the url path combined with another url path. @since 1.0.0 @param UrlPathInterface $urlPath The other url path. @throws UrlPathLogicException if the url paths could not be combined. @return UrlPathInterface The combined url path.
[ "Returns", "a", "copy", "of", "the", "url", "path", "combined", "with", "another", "url", "path", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/UrlPath.php#L108-L115
9,945
themichaelhall/datatypes
src/UrlPath.php
UrlPath.isValid
public static function isValid(string $urlPath): bool { return self::myParse( '/', $urlPath, function ($p, $d, &$e) { return self::myPartValidator($p, $d, $e); }); }
php
public static function isValid(string $urlPath): bool { return self::myParse( '/', $urlPath, function ($p, $d, &$e) { return self::myPartValidator($p, $d, $e); }); }
[ "public", "static", "function", "isValid", "(", "string", "$", "urlPath", ")", ":", "bool", "{", "return", "self", "::", "myParse", "(", "'/'", ",", "$", "urlPath", ",", "function", "(", "$", "p", ",", "$", "d", ",", "&", "$", "e", ")", "{", "return", "self", "::", "myPartValidator", "(", "$", "p", ",", "$", "d", ",", "$", "e", ")", ";", "}", ")", ";", "}" ]
Checks if a url path is valid. @since 1.0.0 @param string $urlPath The url path. @return bool True if the $urlPath parameter is a valid url path, false otherwise.
[ "Checks", "if", "a", "url", "path", "is", "valid", "." ]
c738fdf4ffca2e613badcb3011dbd5268e4309d8
https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/UrlPath.php#L140-L148
9,946
mszewcz/php-json-schema-validator
src/Validators/StringValidators/FormatValidator.php
FormatValidator.validateFormatUri
private function validateFormatUri(string $subject): bool { return \filter_var($subject, \FILTER_VALIDATE_URL, \FILTER_FLAG_SCHEME_REQUIRED | \FILTER_FLAG_HOST_REQUIRED) !== false; }
php
private function validateFormatUri(string $subject): bool { return \filter_var($subject, \FILTER_VALIDATE_URL, \FILTER_FLAG_SCHEME_REQUIRED | \FILTER_FLAG_HOST_REQUIRED) !== false; }
[ "private", "function", "validateFormatUri", "(", "string", "$", "subject", ")", ":", "bool", "{", "return", "\\", "filter_var", "(", "$", "subject", ",", "\\", "FILTER_VALIDATE_URL", ",", "\\", "FILTER_FLAG_SCHEME_REQUIRED", "|", "\\", "FILTER_FLAG_HOST_REQUIRED", ")", "!==", "false", ";", "}" ]
'uri' format validation @param string $subject @return bool
[ "uri", "format", "validation" ]
f7768bfe07ce6508bb1ff36163560a5e5791de7d
https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/StringValidators/FormatValidator.php#L117-L121
9,947
oal/babble
src/Babble.php
Babble.serve
public function serve() { $request = Request::createFromGlobals(); $response = $this->handleRequest($request); if ($this->liveReload) $this->injectLiveReload($response); $response->send(); }
php
public function serve() { $request = Request::createFromGlobals(); $response = $this->handleRequest($request); if ($this->liveReload) $this->injectLiveReload($response); $response->send(); }
[ "public", "function", "serve", "(", ")", "{", "$", "request", "=", "Request", "::", "createFromGlobals", "(", ")", ";", "$", "response", "=", "$", "this", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "this", "->", "liveReload", ")", "$", "this", "->", "injectLiveReload", "(", "$", "response", ")", ";", "$", "response", "->", "send", "(", ")", ";", "}" ]
Serves a response based on the request received from the client.
[ "Serves", "a", "response", "based", "on", "the", "request", "received", "from", "the", "client", "." ]
5a352d12ead6341294747831b0dfce097a0215e7
https://github.com/oal/babble/blob/5a352d12ead6341294747831b0dfce097a0215e7/src/Babble.php#L37-L45
9,948
oal/babble
src/Babble.php
Babble.injectLiveReload
private function injectLiveReload(Response $response) { $content = $response->getContent(); $content = str_replace('</body>', ' <script> document.write(\'<script src="http://\' + (location.host || \'localhost\').split(\':\')[0] + \':35729/livereload.js?snipver=1"></\' + \'script>\') </script></body>', $content); $response->setContent($content); }
php
private function injectLiveReload(Response $response) { $content = $response->getContent(); $content = str_replace('</body>', ' <script> document.write(\'<script src="http://\' + (location.host || \'localhost\').split(\':\')[0] + \':35729/livereload.js?snipver=1"></\' + \'script>\') </script></body>', $content); $response->setContent($content); }
[ "private", "function", "injectLiveReload", "(", "Response", "$", "response", ")", "{", "$", "content", "=", "$", "response", "->", "getContent", "(", ")", ";", "$", "content", "=", "str_replace", "(", "'</body>'", ",", "'\n <script>\n document.write(\\'<script src=\"http://\\' + (location.host || \\'localhost\\').split(\\':\\')[0] + \\':35729/livereload.js?snipver=1\"></\\' + \\'script>\\')\n </script></body>'", ",", "$", "content", ")", ";", "$", "response", "->", "setContent", "(", "$", "content", ")", ";", "}" ]
Injects script tag that loads livereload.js to the response. @param Response $response
[ "Injects", "script", "tag", "that", "loads", "livereload", ".", "js", "to", "the", "response", "." ]
5a352d12ead6341294747831b0dfce097a0215e7
https://github.com/oal/babble/blob/5a352d12ead6341294747831b0dfce097a0215e7/src/Babble.php#L113-L121
9,949
mirko-pagliai/cakephp-tokens
src/Model/Table/TokensTable.php
TokensTable.beforeSave
public function beforeSave(Event $event, Entity $entity, ArrayObject $options) { if (empty($entity->expiry)) { $entity->expiry = Configure::read('Tokens.expiryDefaultValue'); } if (!empty($entity->extra)) { $entity->extra = serialize($entity->extra); } //Deletes all expired tokens and tokens with the same token value // and/or the same user. $this->deleteExpired($entity); return true; }
php
public function beforeSave(Event $event, Entity $entity, ArrayObject $options) { if (empty($entity->expiry)) { $entity->expiry = Configure::read('Tokens.expiryDefaultValue'); } if (!empty($entity->extra)) { $entity->extra = serialize($entity->extra); } //Deletes all expired tokens and tokens with the same token value // and/or the same user. $this->deleteExpired($entity); return true; }
[ "public", "function", "beforeSave", "(", "Event", "$", "event", ",", "Entity", "$", "entity", ",", "ArrayObject", "$", "options", ")", "{", "if", "(", "empty", "(", "$", "entity", "->", "expiry", ")", ")", "{", "$", "entity", "->", "expiry", "=", "Configure", "::", "read", "(", "'Tokens.expiryDefaultValue'", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "entity", "->", "extra", ")", ")", "{", "$", "entity", "->", "extra", "=", "serialize", "(", "$", "entity", "->", "extra", ")", ";", "}", "//Deletes all expired tokens and tokens with the same token value", "// and/or the same user.", "$", "this", "->", "deleteExpired", "(", "$", "entity", ")", ";", "return", "true", ";", "}" ]
Called before each entity is saved. Stopping this event will abort the save operation. @param \Cake\Event\Event $event Event @param \Cake\ORM\Entity $entity Entity @param \ArrayObject $options Options @return bool @uses deleteExpired()
[ "Called", "before", "each", "entity", "is", "saved", ".", "Stopping", "this", "event", "will", "abort", "the", "save", "operation", "." ]
1e6e2fb4bdabc1e3801c428775813d2a2f022ae7
https://github.com/mirko-pagliai/cakephp-tokens/blob/1e6e2fb4bdabc1e3801c428775813d2a2f022ae7/src/Model/Table/TokensTable.php#L49-L64
9,950
mirko-pagliai/cakephp-tokens
src/Model/Table/TokensTable.php
TokensTable.deleteExpired
public function deleteExpired(Token $entity = null) { $conditions[] = ['expiry <' => new Time]; if (!empty($entity->token)) { $conditions[] = ['token' => $entity->token]; } if (!empty($entity->user_id)) { $conditions[] = ['user_id' => $entity->user_id]; } return $this->deleteAll(['OR' => $conditions]); }
php
public function deleteExpired(Token $entity = null) { $conditions[] = ['expiry <' => new Time]; if (!empty($entity->token)) { $conditions[] = ['token' => $entity->token]; } if (!empty($entity->user_id)) { $conditions[] = ['user_id' => $entity->user_id]; } return $this->deleteAll(['OR' => $conditions]); }
[ "public", "function", "deleteExpired", "(", "Token", "$", "entity", "=", "null", ")", "{", "$", "conditions", "[", "]", "=", "[", "'expiry <'", "=>", "new", "Time", "]", ";", "if", "(", "!", "empty", "(", "$", "entity", "->", "token", ")", ")", "{", "$", "conditions", "[", "]", "=", "[", "'token'", "=>", "$", "entity", "->", "token", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "entity", "->", "user_id", ")", ")", "{", "$", "conditions", "[", "]", "=", "[", "'user_id'", "=>", "$", "entity", "->", "user_id", "]", ";", "}", "return", "$", "this", "->", "deleteAll", "(", "[", "'OR'", "=>", "$", "conditions", "]", ")", ";", "}" ]
Deletes all expired tokens. If a `$token` entity is passed, it also clears tokens with the same token value and/or the same user. This method should be called before creating a new token. In fact, it prevents a user from having more than token or a token is created with the same token value. @param \Tokens\Model\Entity\Token|null $entity Token entity @return int Affected rows
[ "Deletes", "all", "expired", "tokens", "." ]
1e6e2fb4bdabc1e3801c428775813d2a2f022ae7
https://github.com/mirko-pagliai/cakephp-tokens/blob/1e6e2fb4bdabc1e3801c428775813d2a2f022ae7/src/Model/Table/TokensTable.php#L78-L91
9,951
mirko-pagliai/cakephp-tokens
src/Model/Table/TokensTable.php
TokensTable.buildRules
public function buildRules(RulesChecker $rules) { //Uses validation rules as application rules $rules->add(function (Token $entity) { $errors = $this->getValidator('default')->errors( $entity->extract($this->getSchema()->columns(), true), $entity->isNew() ); $entity->setErrors($errors); return empty($errors); }); $rules->add($rules->existsIn(['user_id'], 'Users')); return $rules; }
php
public function buildRules(RulesChecker $rules) { //Uses validation rules as application rules $rules->add(function (Token $entity) { $errors = $this->getValidator('default')->errors( $entity->extract($this->getSchema()->columns(), true), $entity->isNew() ); $entity->setErrors($errors); return empty($errors); }); $rules->add($rules->existsIn(['user_id'], 'Users')); return $rules; }
[ "public", "function", "buildRules", "(", "RulesChecker", "$", "rules", ")", "{", "//Uses validation rules as application rules", "$", "rules", "->", "add", "(", "function", "(", "Token", "$", "entity", ")", "{", "$", "errors", "=", "$", "this", "->", "getValidator", "(", "'default'", ")", "->", "errors", "(", "$", "entity", "->", "extract", "(", "$", "this", "->", "getSchema", "(", ")", "->", "columns", "(", ")", ",", "true", ")", ",", "$", "entity", "->", "isNew", "(", ")", ")", ";", "$", "entity", "->", "setErrors", "(", "$", "errors", ")", ";", "return", "empty", "(", "$", "errors", ")", ";", "}", ")", ";", "$", "rules", "->", "add", "(", "$", "rules", "->", "existsIn", "(", "[", "'user_id'", "]", ",", "'Users'", ")", ")", ";", "return", "$", "rules", ";", "}" ]
Build rules. It uses validation rules as application rules. @param Cake\ORM\RulesChecker $rules The rules object to be modified @return Cake\ORM\RulesChecker
[ "Build", "rules", "." ]
1e6e2fb4bdabc1e3801c428775813d2a2f022ae7
https://github.com/mirko-pagliai/cakephp-tokens/blob/1e6e2fb4bdabc1e3801c428775813d2a2f022ae7/src/Model/Table/TokensTable.php#L174-L190
9,952
ARCANESOFT/Core
src/Helpers/UI/Label.php
Label.activeIcon
public static function activeIcon($active, array $options = [], $withTooltip = true) { // TODO: Refactor the options to a dedicated config file. $classes = Arr::get($options, 'classes', [ 'enabled' => 'label label-success', 'disabled' => 'label label-default', ]); $translations = Arr::get($options, 'trans', [ 'enabled' => 'core::statuses.enabled', 'disabled' => 'core::statuses.disabled', ]); $icons = Arr::get($options, 'icons', [ 'enabled' => 'fa fa-fw fa-check', 'disabled' => 'fa fa-fw fa-ban', ]); $key = $active ? 'enabled' : 'disabled'; $attributes = ['class' => $classes[$key]]; $value = static::generateIcon($icons[$key]); return $withTooltip ? static::generateWithTooltip($value, ucfirst(trans($translations[$key])), $attributes) : static::generate($value, $attributes); }
php
public static function activeIcon($active, array $options = [], $withTooltip = true) { // TODO: Refactor the options to a dedicated config file. $classes = Arr::get($options, 'classes', [ 'enabled' => 'label label-success', 'disabled' => 'label label-default', ]); $translations = Arr::get($options, 'trans', [ 'enabled' => 'core::statuses.enabled', 'disabled' => 'core::statuses.disabled', ]); $icons = Arr::get($options, 'icons', [ 'enabled' => 'fa fa-fw fa-check', 'disabled' => 'fa fa-fw fa-ban', ]); $key = $active ? 'enabled' : 'disabled'; $attributes = ['class' => $classes[$key]]; $value = static::generateIcon($icons[$key]); return $withTooltip ? static::generateWithTooltip($value, ucfirst(trans($translations[$key])), $attributes) : static::generate($value, $attributes); }
[ "public", "static", "function", "activeIcon", "(", "$", "active", ",", "array", "$", "options", "=", "[", "]", ",", "$", "withTooltip", "=", "true", ")", "{", "// TODO: Refactor the options to a dedicated config file.", "$", "classes", "=", "Arr", "::", "get", "(", "$", "options", ",", "'classes'", ",", "[", "'enabled'", "=>", "'label label-success'", ",", "'disabled'", "=>", "'label label-default'", ",", "]", ")", ";", "$", "translations", "=", "Arr", "::", "get", "(", "$", "options", ",", "'trans'", ",", "[", "'enabled'", "=>", "'core::statuses.enabled'", ",", "'disabled'", "=>", "'core::statuses.disabled'", ",", "]", ")", ";", "$", "icons", "=", "Arr", "::", "get", "(", "$", "options", ",", "'icons'", ",", "[", "'enabled'", "=>", "'fa fa-fw fa-check'", ",", "'disabled'", "=>", "'fa fa-fw fa-ban'", ",", "]", ")", ";", "$", "key", "=", "$", "active", "?", "'enabled'", ":", "'disabled'", ";", "$", "attributes", "=", "[", "'class'", "=>", "$", "classes", "[", "$", "key", "]", "]", ";", "$", "value", "=", "static", "::", "generateIcon", "(", "$", "icons", "[", "$", "key", "]", ")", ";", "return", "$", "withTooltip", "?", "static", "::", "generateWithTooltip", "(", "$", "value", ",", "ucfirst", "(", "trans", "(", "$", "translations", "[", "$", "key", "]", ")", ")", ",", "$", "attributes", ")", ":", "static", "::", "generate", "(", "$", "value", ",", "$", "attributes", ")", ";", "}" ]
Generate active icon label. @param bool $active @param array $options @param bool $withTooltip @return \Illuminate\Support\HtmlString
[ "Generate", "active", "icon", "label", "." ]
d0798074d47785cf0a768f51d82c0315363213be
https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/Label.php#L30-L53
9,953
ARCANESOFT/Core
src/Helpers/UI/Label.php
Label.activeStatus
public static function activeStatus($active, array $options = [], $withIcon = true) { // TODO: Refactor the options to a dedicated config file. $classes = Arr::get($options, 'classes', [ 'enabled' => 'label label-success', 'disabled' => 'label label-default', ]); $translations = Arr::get($options, 'trans', [ 'enabled' => 'core::statuses.enabled', 'disabled' => 'core::statuses.disabled', ]); $icons = Arr::get($options, 'icons', [ 'enabled' => 'fa fa-fw fa-check', 'disabled' => 'fa fa-fw fa-ban', ]); $key = $active ? 'enabled' : 'disabled'; $attributes = ['class' => $classes[$key]]; return $withIcon ? static::generateWithIcon(ucfirst(trans($translations[$key])), $icons[$key], $attributes) : static::generate(ucfirst(trans($translations[$key])), $attributes); }
php
public static function activeStatus($active, array $options = [], $withIcon = true) { // TODO: Refactor the options to a dedicated config file. $classes = Arr::get($options, 'classes', [ 'enabled' => 'label label-success', 'disabled' => 'label label-default', ]); $translations = Arr::get($options, 'trans', [ 'enabled' => 'core::statuses.enabled', 'disabled' => 'core::statuses.disabled', ]); $icons = Arr::get($options, 'icons', [ 'enabled' => 'fa fa-fw fa-check', 'disabled' => 'fa fa-fw fa-ban', ]); $key = $active ? 'enabled' : 'disabled'; $attributes = ['class' => $classes[$key]]; return $withIcon ? static::generateWithIcon(ucfirst(trans($translations[$key])), $icons[$key], $attributes) : static::generate(ucfirst(trans($translations[$key])), $attributes); }
[ "public", "static", "function", "activeStatus", "(", "$", "active", ",", "array", "$", "options", "=", "[", "]", ",", "$", "withIcon", "=", "true", ")", "{", "// TODO: Refactor the options to a dedicated config file.", "$", "classes", "=", "Arr", "::", "get", "(", "$", "options", ",", "'classes'", ",", "[", "'enabled'", "=>", "'label label-success'", ",", "'disabled'", "=>", "'label label-default'", ",", "]", ")", ";", "$", "translations", "=", "Arr", "::", "get", "(", "$", "options", ",", "'trans'", ",", "[", "'enabled'", "=>", "'core::statuses.enabled'", ",", "'disabled'", "=>", "'core::statuses.disabled'", ",", "]", ")", ";", "$", "icons", "=", "Arr", "::", "get", "(", "$", "options", ",", "'icons'", ",", "[", "'enabled'", "=>", "'fa fa-fw fa-check'", ",", "'disabled'", "=>", "'fa fa-fw fa-ban'", ",", "]", ")", ";", "$", "key", "=", "$", "active", "?", "'enabled'", ":", "'disabled'", ";", "$", "attributes", "=", "[", "'class'", "=>", "$", "classes", "[", "$", "key", "]", "]", ";", "return", "$", "withIcon", "?", "static", "::", "generateWithIcon", "(", "ucfirst", "(", "trans", "(", "$", "translations", "[", "$", "key", "]", ")", ")", ",", "$", "icons", "[", "$", "key", "]", ",", "$", "attributes", ")", ":", "static", "::", "generate", "(", "ucfirst", "(", "trans", "(", "$", "translations", "[", "$", "key", "]", ")", ")", ",", "$", "attributes", ")", ";", "}" ]
Generate active status label. @param bool $active @param array $options @param bool $withIcon @return \Illuminate\Support\HtmlString
[ "Generate", "active", "status", "label", "." ]
d0798074d47785cf0a768f51d82c0315363213be
https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/Label.php#L64-L86
9,954
ARCANESOFT/Core
src/Helpers/UI/Label.php
Label.checkStatus
public static function checkStatus($checked, array $options = [], $withIcon = true) { // TODO: Refactor the options to a dedicated config file. $classes = Arr::get($options, 'classes', [ 'checked' => 'label label-success', 'unchecked' => 'label label-default', ]); $translations = Arr::get($options, 'trans', [ 'checked' => 'core::statuses.checked', 'unchecked' => 'core::statuses.unchecked', ]); $icons = Arr::get($options, 'icons', [ 'checked' => 'fa fa-fw fa-check', 'unchecked' => 'fa fa-fw fa-ban', ]); $key = $checked ? 'checked' : 'unchecked'; $attributes = ['class' => $classes[$key]]; return $withIcon ? static::generateWithIcon(ucfirst(trans($translations[$key])), $icons[$key], $attributes) : static::generate(ucfirst(trans($translations[$key])), $attributes); }
php
public static function checkStatus($checked, array $options = [], $withIcon = true) { // TODO: Refactor the options to a dedicated config file. $classes = Arr::get($options, 'classes', [ 'checked' => 'label label-success', 'unchecked' => 'label label-default', ]); $translations = Arr::get($options, 'trans', [ 'checked' => 'core::statuses.checked', 'unchecked' => 'core::statuses.unchecked', ]); $icons = Arr::get($options, 'icons', [ 'checked' => 'fa fa-fw fa-check', 'unchecked' => 'fa fa-fw fa-ban', ]); $key = $checked ? 'checked' : 'unchecked'; $attributes = ['class' => $classes[$key]]; return $withIcon ? static::generateWithIcon(ucfirst(trans($translations[$key])), $icons[$key], $attributes) : static::generate(ucfirst(trans($translations[$key])), $attributes); }
[ "public", "static", "function", "checkStatus", "(", "$", "checked", ",", "array", "$", "options", "=", "[", "]", ",", "$", "withIcon", "=", "true", ")", "{", "// TODO: Refactor the options to a dedicated config file.", "$", "classes", "=", "Arr", "::", "get", "(", "$", "options", ",", "'classes'", ",", "[", "'checked'", "=>", "'label label-success'", ",", "'unchecked'", "=>", "'label label-default'", ",", "]", ")", ";", "$", "translations", "=", "Arr", "::", "get", "(", "$", "options", ",", "'trans'", ",", "[", "'checked'", "=>", "'core::statuses.checked'", ",", "'unchecked'", "=>", "'core::statuses.unchecked'", ",", "]", ")", ";", "$", "icons", "=", "Arr", "::", "get", "(", "$", "options", ",", "'icons'", ",", "[", "'checked'", "=>", "'fa fa-fw fa-check'", ",", "'unchecked'", "=>", "'fa fa-fw fa-ban'", ",", "]", ")", ";", "$", "key", "=", "$", "checked", "?", "'checked'", ":", "'unchecked'", ";", "$", "attributes", "=", "[", "'class'", "=>", "$", "classes", "[", "$", "key", "]", "]", ";", "return", "$", "withIcon", "?", "static", "::", "generateWithIcon", "(", "ucfirst", "(", "trans", "(", "$", "translations", "[", "$", "key", "]", ")", ")", ",", "$", "icons", "[", "$", "key", "]", ",", "$", "attributes", ")", ":", "static", "::", "generate", "(", "ucfirst", "(", "trans", "(", "$", "translations", "[", "$", "key", "]", ")", ")", ",", "$", "attributes", ")", ";", "}" ]
Generate check status label. @param bool $checked @param array $options @param bool $withIcon @return \Illuminate\Support\HtmlString
[ "Generate", "check", "status", "label", "." ]
d0798074d47785cf0a768f51d82c0315363213be
https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/Label.php#L132-L154
9,955
ARCANESOFT/Core
src/Helpers/UI/Label.php
Label.count
public static function count($count, array $options = []) { // TODO: Refactor the options to a dedicated config file. $classes = Arr::get($options, 'classes', [ 'positive' => 'label label-info', 'zero' => 'label label-default', 'negative' => 'label label-danger', ]); return static::generate($count, [ 'class' => $count > 0 ? $classes['positive'] : ($count < 0 ? $classes['negative'] : $classes['zero']) ]); }
php
public static function count($count, array $options = []) { // TODO: Refactor the options to a dedicated config file. $classes = Arr::get($options, 'classes', [ 'positive' => 'label label-info', 'zero' => 'label label-default', 'negative' => 'label label-danger', ]); return static::generate($count, [ 'class' => $count > 0 ? $classes['positive'] : ($count < 0 ? $classes['negative'] : $classes['zero']) ]); }
[ "public", "static", "function", "count", "(", "$", "count", ",", "array", "$", "options", "=", "[", "]", ")", "{", "// TODO: Refactor the options to a dedicated config file.", "$", "classes", "=", "Arr", "::", "get", "(", "$", "options", ",", "'classes'", ",", "[", "'positive'", "=>", "'label label-info'", ",", "'zero'", "=>", "'label label-default'", ",", "'negative'", "=>", "'label label-danger'", ",", "]", ")", ";", "return", "static", "::", "generate", "(", "$", "count", ",", "[", "'class'", "=>", "$", "count", ">", "0", "?", "$", "classes", "[", "'positive'", "]", ":", "(", "$", "count", "<", "0", "?", "$", "classes", "[", "'negative'", "]", ":", "$", "classes", "[", "'zero'", "]", ")", "]", ")", ";", "}" ]
Generate count label. @param int|float $count @param array $options @return \Illuminate\Support\HtmlString
[ "Generate", "count", "label", "." ]
d0798074d47785cf0a768f51d82c0315363213be
https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/Label.php#L164-L176
9,956
ARCANESOFT/Core
src/Helpers/UI/Label.php
Label.lockedStatus
public static function lockedStatus($locked, array $options = [], $withIcon = true) { // TODO: Refactor the options to a dedicated config file. $classes = Arr::get($options, 'classes', [ 'locked' => 'label label-danger', 'unlocked' => 'label label-success', ]); $translations = Arr::get($options, 'trans', [ 'locked' => 'core::statuses.locked', 'unlocked' => 'core::statuses.unlocked', ]); $icons = Arr::get($options, 'icons', [ 'locked' => 'fa fa-fw fa-lock', 'unlocked' => 'fa fa-fw fa-unlock', ]); $key = $locked ? 'locked' : 'unlocked'; $value = ucfirst(trans($translations[$key])); $attributes = ['class' => $classes[$key]]; return $withIcon ? static::generateWithIcon($value, $icons[$key], $attributes) : static::generate($value, $attributes); }
php
public static function lockedStatus($locked, array $options = [], $withIcon = true) { // TODO: Refactor the options to a dedicated config file. $classes = Arr::get($options, 'classes', [ 'locked' => 'label label-danger', 'unlocked' => 'label label-success', ]); $translations = Arr::get($options, 'trans', [ 'locked' => 'core::statuses.locked', 'unlocked' => 'core::statuses.unlocked', ]); $icons = Arr::get($options, 'icons', [ 'locked' => 'fa fa-fw fa-lock', 'unlocked' => 'fa fa-fw fa-unlock', ]); $key = $locked ? 'locked' : 'unlocked'; $value = ucfirst(trans($translations[$key])); $attributes = ['class' => $classes[$key]]; return $withIcon ? static::generateWithIcon($value, $icons[$key], $attributes) : static::generate($value, $attributes); }
[ "public", "static", "function", "lockedStatus", "(", "$", "locked", ",", "array", "$", "options", "=", "[", "]", ",", "$", "withIcon", "=", "true", ")", "{", "// TODO: Refactor the options to a dedicated config file.", "$", "classes", "=", "Arr", "::", "get", "(", "$", "options", ",", "'classes'", ",", "[", "'locked'", "=>", "'label label-danger'", ",", "'unlocked'", "=>", "'label label-success'", ",", "]", ")", ";", "$", "translations", "=", "Arr", "::", "get", "(", "$", "options", ",", "'trans'", ",", "[", "'locked'", "=>", "'core::statuses.locked'", ",", "'unlocked'", "=>", "'core::statuses.unlocked'", ",", "]", ")", ";", "$", "icons", "=", "Arr", "::", "get", "(", "$", "options", ",", "'icons'", ",", "[", "'locked'", "=>", "'fa fa-fw fa-lock'", ",", "'unlocked'", "=>", "'fa fa-fw fa-unlock'", ",", "]", ")", ";", "$", "key", "=", "$", "locked", "?", "'locked'", ":", "'unlocked'", ";", "$", "value", "=", "ucfirst", "(", "trans", "(", "$", "translations", "[", "$", "key", "]", ")", ")", ";", "$", "attributes", "=", "[", "'class'", "=>", "$", "classes", "[", "$", "key", "]", "]", ";", "return", "$", "withIcon", "?", "static", "::", "generateWithIcon", "(", "$", "value", ",", "$", "icons", "[", "$", "key", "]", ",", "$", "attributes", ")", ":", "static", "::", "generate", "(", "$", "value", ",", "$", "attributes", ")", ";", "}" ]
Generate locked status label. @param bool $locked @param array $options @param bool $withIcon @return \Illuminate\Support\HtmlString
[ "Generate", "locked", "status", "label", "." ]
d0798074d47785cf0a768f51d82c0315363213be
https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/Label.php#L221-L244
9,957
ARCANESOFT/Core
src/Helpers/UI/Label.php
Label.trashedStatus
public static function trashedStatus(array $options = [], $withIcon = true) { $trans = Arr::get($options, 'trans', 'core::statuses.trashed'); $icon = Arr::get($options, 'icon', 'fa fa-fw fa-trash-o'); $attributes = [ 'class' => Arr::get($options, 'class', 'label label-danger') ]; return $withIcon ? static::generateWithIcon(ucfirst(trans($trans)), $icon, $attributes) : static::generate(ucfirst(trans($trans)), $attributes); }
php
public static function trashedStatus(array $options = [], $withIcon = true) { $trans = Arr::get($options, 'trans', 'core::statuses.trashed'); $icon = Arr::get($options, 'icon', 'fa fa-fw fa-trash-o'); $attributes = [ 'class' => Arr::get($options, 'class', 'label label-danger') ]; return $withIcon ? static::generateWithIcon(ucfirst(trans($trans)), $icon, $attributes) : static::generate(ucfirst(trans($trans)), $attributes); }
[ "public", "static", "function", "trashedStatus", "(", "array", "$", "options", "=", "[", "]", ",", "$", "withIcon", "=", "true", ")", "{", "$", "trans", "=", "Arr", "::", "get", "(", "$", "options", ",", "'trans'", ",", "'core::statuses.trashed'", ")", ";", "$", "icon", "=", "Arr", "::", "get", "(", "$", "options", ",", "'icon'", ",", "'fa fa-fw fa-trash-o'", ")", ";", "$", "attributes", "=", "[", "'class'", "=>", "Arr", "::", "get", "(", "$", "options", ",", "'class'", ",", "'label label-danger'", ")", "]", ";", "return", "$", "withIcon", "?", "static", "::", "generateWithIcon", "(", "ucfirst", "(", "trans", "(", "$", "trans", ")", ")", ",", "$", "icon", ",", "$", "attributes", ")", ":", "static", "::", "generate", "(", "ucfirst", "(", "trans", "(", "$", "trans", ")", ")", ",", "$", "attributes", ")", ";", "}" ]
Generate trashed icon label. @param array $options @return \Illuminate\Support\HtmlString
[ "Generate", "trashed", "icon", "label", "." ]
d0798074d47785cf0a768f51d82c0315363213be
https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/Label.php#L252-L263
9,958
ARCANESOFT/Core
src/Helpers/UI/Label.php
Label.generateWithTooltip
protected static function generateWithTooltip($value, $title, array $attributes = []) { $attributes['data-toggle'] = 'tooltip'; $attributes['data-original-title'] = $title; return static::generate($value, $attributes); }
php
protected static function generateWithTooltip($value, $title, array $attributes = []) { $attributes['data-toggle'] = 'tooltip'; $attributes['data-original-title'] = $title; return static::generate($value, $attributes); }
[ "protected", "static", "function", "generateWithTooltip", "(", "$", "value", ",", "$", "title", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "attributes", "[", "'data-toggle'", "]", "=", "'tooltip'", ";", "$", "attributes", "[", "'data-original-title'", "]", "=", "$", "title", ";", "return", "static", "::", "generate", "(", "$", "value", ",", "$", "attributes", ")", ";", "}" ]
Generate the label with tooltip. @param string $value @param string $title @param array $attributes @return \Illuminate\Support\HtmlString
[ "Generate", "the", "label", "with", "tooltip", "." ]
d0798074d47785cf0a768f51d82c0315363213be
https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/Label.php#L294-L300
9,959
RhubarbPHP/Module.CsrfProtection
src/CsrfProtection.php
CsrfProtection.validateHeaders
public function validateHeaders(WebRequest $request) { $settings = CsrfSettings::singleton(); $headersValid = false; $referrerDomain = $this->getHost($request->header("Referer", "")); if ($referrerDomain != "") { if ($referrerDomain == $settings->domain){ $headersValid = true; } } else { if ($this->getHost($request->header("Origin")) == $settings->domain) { $headersValid = true; } } if (!$headersValid){ throw new CsrfViolationException(); } }
php
public function validateHeaders(WebRequest $request) { $settings = CsrfSettings::singleton(); $headersValid = false; $referrerDomain = $this->getHost($request->header("Referer", "")); if ($referrerDomain != "") { if ($referrerDomain == $settings->domain){ $headersValid = true; } } else { if ($this->getHost($request->header("Origin")) == $settings->domain) { $headersValid = true; } } if (!$headersValid){ throw new CsrfViolationException(); } }
[ "public", "function", "validateHeaders", "(", "WebRequest", "$", "request", ")", "{", "$", "settings", "=", "CsrfSettings", "::", "singleton", "(", ")", ";", "$", "headersValid", "=", "false", ";", "$", "referrerDomain", "=", "$", "this", "->", "getHost", "(", "$", "request", "->", "header", "(", "\"Referer\"", ",", "\"\"", ")", ")", ";", "if", "(", "$", "referrerDomain", "!=", "\"\"", ")", "{", "if", "(", "$", "referrerDomain", "==", "$", "settings", "->", "domain", ")", "{", "$", "headersValid", "=", "true", ";", "}", "}", "else", "{", "if", "(", "$", "this", "->", "getHost", "(", "$", "request", "->", "header", "(", "\"Origin\"", ")", ")", "==", "$", "settings", "->", "domain", ")", "{", "$", "headersValid", "=", "true", ";", "}", "}", "if", "(", "!", "$", "headersValid", ")", "{", "throw", "new", "CsrfViolationException", "(", ")", ";", "}", "}" ]
Validates that a request headers meets CSRF requirements. @param WebRequest $request @throws CsrfViolationException Thrown if the request does not validate on headers.
[ "Validates", "that", "a", "request", "headers", "meets", "CSRF", "requirements", "." ]
3472b0cce4137b33e205183c19530b07f5a17a0d
https://github.com/RhubarbPHP/Module.CsrfProtection/blob/3472b0cce4137b33e205183c19530b07f5a17a0d/src/CsrfProtection.php#L28-L49
9,960
RhubarbPHP/Module.CsrfProtection
src/CsrfProtection.php
CsrfProtection.validateCookie
public function validateCookie(WebRequest $request) { if ($request->cookie(self::TOKEN_COOKIE_NAME) != $request->post(self::TOKEN_COOKIE_NAME)) { throw new CsrfViolationException(); } }
php
public function validateCookie(WebRequest $request) { if ($request->cookie(self::TOKEN_COOKIE_NAME) != $request->post(self::TOKEN_COOKIE_NAME)) { throw new CsrfViolationException(); } }
[ "public", "function", "validateCookie", "(", "WebRequest", "$", "request", ")", "{", "if", "(", "$", "request", "->", "cookie", "(", "self", "::", "TOKEN_COOKIE_NAME", ")", "!=", "$", "request", "->", "post", "(", "self", "::", "TOKEN_COOKIE_NAME", ")", ")", "{", "throw", "new", "CsrfViolationException", "(", ")", ";", "}", "}" ]
Validates if the csrf_tk cookie matches the posted value.
[ "Validates", "if", "the", "csrf_tk", "cookie", "matches", "the", "posted", "value", "." ]
3472b0cce4137b33e205183c19530b07f5a17a0d
https://github.com/RhubarbPHP/Module.CsrfProtection/blob/3472b0cce4137b33e205183c19530b07f5a17a0d/src/CsrfProtection.php#L54-L59
9,961
RhubarbPHP/Module.CsrfProtection
src/CsrfProtection.php
CsrfProtection.getCookie
public function getCookie() { $request = Request::current(); $settings = CsrfSettings::singleton(); if ($request instanceof WebRequest){ $existingCookie = $request->cookie(self::TOKEN_COOKIE_NAME, false); if ($existingCookie){ $this->currentCookie = $existingCookie; } } if (!$this->currentCookie) { $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345689.;,!$%^&*()-=+"; $cookie = ""; for ($x = 0; $x < self::TOKEN_COOKIE_LENGTH; $x++) { $rand = rand(0, strlen($chars) - 1); $char = $chars[$rand]; if (rand(0, 1) == 1) { $char = strtolower($char); } $cookie .= $char; } $this->currentCookie = $cookie; HttpResponse::setCookie(self::TOKEN_COOKIE_NAME, $cookie, 0, '/', parse_url($settings->domain, PHP_URL_HOST), false, true); } return $this->currentCookie; }
php
public function getCookie() { $request = Request::current(); $settings = CsrfSettings::singleton(); if ($request instanceof WebRequest){ $existingCookie = $request->cookie(self::TOKEN_COOKIE_NAME, false); if ($existingCookie){ $this->currentCookie = $existingCookie; } } if (!$this->currentCookie) { $chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ012345689.;,!$%^&*()-=+"; $cookie = ""; for ($x = 0; $x < self::TOKEN_COOKIE_LENGTH; $x++) { $rand = rand(0, strlen($chars) - 1); $char = $chars[$rand]; if (rand(0, 1) == 1) { $char = strtolower($char); } $cookie .= $char; } $this->currentCookie = $cookie; HttpResponse::setCookie(self::TOKEN_COOKIE_NAME, $cookie, 0, '/', parse_url($settings->domain, PHP_URL_HOST), false, true); } return $this->currentCookie; }
[ "public", "function", "getCookie", "(", ")", "{", "$", "request", "=", "Request", "::", "current", "(", ")", ";", "$", "settings", "=", "CsrfSettings", "::", "singleton", "(", ")", ";", "if", "(", "$", "request", "instanceof", "WebRequest", ")", "{", "$", "existingCookie", "=", "$", "request", "->", "cookie", "(", "self", "::", "TOKEN_COOKIE_NAME", ",", "false", ")", ";", "if", "(", "$", "existingCookie", ")", "{", "$", "this", "->", "currentCookie", "=", "$", "existingCookie", ";", "}", "}", "if", "(", "!", "$", "this", "->", "currentCookie", ")", "{", "$", "chars", "=", "\"ABCDEFGHIJKLMNOPQRSTUVWXYZ012345689.;,!$%^&*()-=+\"", ";", "$", "cookie", "=", "\"\"", ";", "for", "(", "$", "x", "=", "0", ";", "$", "x", "<", "self", "::", "TOKEN_COOKIE_LENGTH", ";", "$", "x", "++", ")", "{", "$", "rand", "=", "rand", "(", "0", ",", "strlen", "(", "$", "chars", ")", "-", "1", ")", ";", "$", "char", "=", "$", "chars", "[", "$", "rand", "]", ";", "if", "(", "rand", "(", "0", ",", "1", ")", "==", "1", ")", "{", "$", "char", "=", "strtolower", "(", "$", "char", ")", ";", "}", "$", "cookie", ".=", "$", "char", ";", "}", "$", "this", "->", "currentCookie", "=", "$", "cookie", ";", "HttpResponse", "::", "setCookie", "(", "self", "::", "TOKEN_COOKIE_NAME", ",", "$", "cookie", ",", "0", ",", "'/'", ",", "parse_url", "(", "$", "settings", "->", "domain", ",", "PHP_URL_HOST", ")", ",", "false", ",", "true", ")", ";", "}", "return", "$", "this", "->", "currentCookie", ";", "}" ]
Returns the current cookie being used for CSRF or generates one if one doesn't exist.
[ "Returns", "the", "current", "cookie", "being", "used", "for", "CSRF", "or", "generates", "one", "if", "one", "doesn", "t", "exist", "." ]
3472b0cce4137b33e205183c19530b07f5a17a0d
https://github.com/RhubarbPHP/Module.CsrfProtection/blob/3472b0cce4137b33e205183c19530b07f5a17a0d/src/CsrfProtection.php#L66-L99
9,962
jinraynor1/threading
src/Pcntl/Thread.php
Thread.setRunnable
public function setRunnable($runnable) { if (self::isRunnableOk($runnable)) { $this->runnable = $runnable; } else { $this->fatalError(Thread::FUNCTION_NOT_CALLABLE); } }
php
public function setRunnable($runnable) { if (self::isRunnableOk($runnable)) { $this->runnable = $runnable; } else { $this->fatalError(Thread::FUNCTION_NOT_CALLABLE); } }
[ "public", "function", "setRunnable", "(", "$", "runnable", ")", "{", "if", "(", "self", "::", "isRunnableOk", "(", "$", "runnable", ")", ")", "{", "$", "this", "->", "runnable", "=", "$", "runnable", ";", "}", "else", "{", "$", "this", "->", "fatalError", "(", "Thread", "::", "FUNCTION_NOT_CALLABLE", ")", ";", "}", "}" ]
Sets the callback @param callback $runnable Callback reference @return callback
[ "Sets", "the", "callback" ]
8b63c75fe4fcc2523d26f060a75af1694dd020d4
https://github.com/jinraynor1/threading/blob/8b63c75fe4fcc2523d26f060a75af1694dd020d4/src/Pcntl/Thread.php#L114-L121
9,963
jinraynor1/threading
src/Pcntl/Thread.php
Thread.isAlive
public function isAlive() { $pid = pcntl_waitpid($this->_pid, $status, WNOHANG); $this->result = unserialize(trim(socket_read($this->sockets[1], $this->message_length))); socket_close($this->sockets[1]); return ($pid === 0); }
php
public function isAlive() { $pid = pcntl_waitpid($this->_pid, $status, WNOHANG); $this->result = unserialize(trim(socket_read($this->sockets[1], $this->message_length))); socket_close($this->sockets[1]); return ($pid === 0); }
[ "public", "function", "isAlive", "(", ")", "{", "$", "pid", "=", "pcntl_waitpid", "(", "$", "this", "->", "_pid", ",", "$", "status", ",", "WNOHANG", ")", ";", "$", "this", "->", "result", "=", "unserialize", "(", "trim", "(", "socket_read", "(", "$", "this", "->", "sockets", "[", "1", "]", ",", "$", "this", "->", "message_length", ")", ")", ")", ";", "socket_close", "(", "$", "this", "->", "sockets", "[", "1", "]", ")", ";", "return", "(", "$", "pid", "===", "0", ")", ";", "}" ]
Checks if the child thread is alive @return boolean
[ "Checks", "if", "the", "child", "thread", "is", "alive" ]
8b63c75fe4fcc2523d26f060a75af1694dd020d4
https://github.com/jinraynor1/threading/blob/8b63c75fe4fcc2523d26f060a75af1694dd020d4/src/Pcntl/Thread.php#L163-L170
9,964
jinraynor1/threading
src/Pcntl/Thread.php
Thread.start
public function start($arguments) { if (socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $this->sockets) === false) { throw new \Exception(socket_strerror(socket_last_error())); } $pid = @pcntl_fork(); if ($pid == -1) { $this->fatalError(Thread::COULD_NOT_FORK); } if ($pid) { // parent $this->_pid = $pid; } else { // child pcntl_signal(SIGTERM, array($this, 'handleSignal')); if (!empty($arguments)) { $results = call_user_func_array($this->runnable, $arguments); } else { $results = call_user_func($this->runnable); } $data = serialize($results); socket_write($this->sockets[0], str_pad($data, $this->message_length), $this->message_length); socket_close($this->sockets[0]); exit(0); } }
php
public function start($arguments) { if (socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $this->sockets) === false) { throw new \Exception(socket_strerror(socket_last_error())); } $pid = @pcntl_fork(); if ($pid == -1) { $this->fatalError(Thread::COULD_NOT_FORK); } if ($pid) { // parent $this->_pid = $pid; } else { // child pcntl_signal(SIGTERM, array($this, 'handleSignal')); if (!empty($arguments)) { $results = call_user_func_array($this->runnable, $arguments); } else { $results = call_user_func($this->runnable); } $data = serialize($results); socket_write($this->sockets[0], str_pad($data, $this->message_length), $this->message_length); socket_close($this->sockets[0]); exit(0); } }
[ "public", "function", "start", "(", "$", "arguments", ")", "{", "if", "(", "socket_create_pair", "(", "AF_UNIX", ",", "SOCK_STREAM", ",", "0", ",", "$", "this", "->", "sockets", ")", "===", "false", ")", "{", "throw", "new", "\\", "Exception", "(", "socket_strerror", "(", "socket_last_error", "(", ")", ")", ")", ";", "}", "$", "pid", "=", "@", "pcntl_fork", "(", ")", ";", "if", "(", "$", "pid", "==", "-", "1", ")", "{", "$", "this", "->", "fatalError", "(", "Thread", "::", "COULD_NOT_FORK", ")", ";", "}", "if", "(", "$", "pid", ")", "{", "// parent", "$", "this", "->", "_pid", "=", "$", "pid", ";", "}", "else", "{", "// child", "pcntl_signal", "(", "SIGTERM", ",", "array", "(", "$", "this", ",", "'handleSignal'", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "arguments", ")", ")", "{", "$", "results", "=", "call_user_func_array", "(", "$", "this", "->", "runnable", ",", "$", "arguments", ")", ";", "}", "else", "{", "$", "results", "=", "call_user_func", "(", "$", "this", "->", "runnable", ")", ";", "}", "$", "data", "=", "serialize", "(", "$", "results", ")", ";", "socket_write", "(", "$", "this", "->", "sockets", "[", "0", "]", ",", "str_pad", "(", "$", "data", ",", "$", "this", "->", "message_length", ")", ",", "$", "this", "->", "message_length", ")", ";", "socket_close", "(", "$", "this", "->", "sockets", "[", "0", "]", ")", ";", "exit", "(", "0", ")", ";", "}", "}" ]
Starts the thread, all the parameters are passed to the callback function @return void
[ "Starts", "the", "thread", "all", "the", "parameters", "are", "passed", "to", "the", "callback", "function" ]
8b63c75fe4fcc2523d26f060a75af1694dd020d4
https://github.com/jinraynor1/threading/blob/8b63c75fe4fcc2523d26f060a75af1694dd020d4/src/Pcntl/Thread.php#L178-L208
9,965
jinraynor1/threading
src/Pcntl/Thread.php
Thread.stop
public function stop($signal = SIGKILL, $wait = false) { if ($this->isAlive()) { posix_kill($this->_pid, $signal); if ($wait) { pcntl_waitpid($this->_pid, $status = 0); } } }
php
public function stop($signal = SIGKILL, $wait = false) { if ($this->isAlive()) { posix_kill($this->_pid, $signal); if ($wait) { pcntl_waitpid($this->_pid, $status = 0); } } }
[ "public", "function", "stop", "(", "$", "signal", "=", "SIGKILL", ",", "$", "wait", "=", "false", ")", "{", "if", "(", "$", "this", "->", "isAlive", "(", ")", ")", "{", "posix_kill", "(", "$", "this", "->", "_pid", ",", "$", "signal", ")", ";", "if", "(", "$", "wait", ")", "{", "pcntl_waitpid", "(", "$", "this", "->", "_pid", ",", "$", "status", "=", "0", ")", ";", "}", "}", "}" ]
Attempts to stop the thread returns true on success and false otherwise @param integer $signal SIGKILL or SIGTERM @param boolean $wait Wait until child has exited @return void
[ "Attempts", "to", "stop", "the", "thread", "returns", "true", "on", "success", "and", "false", "otherwise" ]
8b63c75fe4fcc2523d26f060a75af1694dd020d4
https://github.com/jinraynor1/threading/blob/8b63c75fe4fcc2523d26f060a75af1694dd020d4/src/Pcntl/Thread.php#L219-L227
9,966
CakeCMS/Community
src/Controller/UsersController.php
UsersController.profile
public function profile() { $userId = $this->Auth->user('id'); if (!$userId) { $this->Flash->error(__d('community', 'You are not logged in')); $this->redirect($this->Auth->getConfig('loginAction')); } $this ->set('user', $this->Users->get($userId, ['contain' => 'Groups'])) ->set('page_title', __d('community', 'Edit profile')); }
php
public function profile() { $userId = $this->Auth->user('id'); if (!$userId) { $this->Flash->error(__d('community', 'You are not logged in')); $this->redirect($this->Auth->getConfig('loginAction')); } $this ->set('user', $this->Users->get($userId, ['contain' => 'Groups'])) ->set('page_title', __d('community', 'Edit profile')); }
[ "public", "function", "profile", "(", ")", "{", "$", "userId", "=", "$", "this", "->", "Auth", "->", "user", "(", "'id'", ")", ";", "if", "(", "!", "$", "userId", ")", "{", "$", "this", "->", "Flash", "->", "error", "(", "__d", "(", "'community'", ",", "'You are not logged in'", ")", ")", ";", "$", "this", "->", "redirect", "(", "$", "this", "->", "Auth", "->", "getConfig", "(", "'loginAction'", ")", ")", ";", "}", "$", "this", "->", "set", "(", "'user'", ",", "$", "this", "->", "Users", "->", "get", "(", "$", "userId", ",", "[", "'contain'", "=>", "'Groups'", "]", ")", ")", "->", "set", "(", "'page_title'", ",", "__d", "(", "'community'", ",", "'Edit profile'", ")", ")", ";", "}" ]
Default profile page action. @return void @throws \Aura\Intl\Exception
[ "Default", "profile", "page", "action", "." ]
cc2bdb596dd9617d42fd81f59e981024caa062e8
https://github.com/CakeCMS/Community/blob/cc2bdb596dd9617d42fd81f59e981024caa062e8/src/Controller/UsersController.php#L38-L49
9,967
CakeCMS/Community
src/Controller/UsersController.php
UsersController._getUser
private function _getUser($id, $token) { return $this->Users->find() ->where([ 'id' => $id, 'token' => $token ]) ->first(); }
php
private function _getUser($id, $token) { return $this->Users->find() ->where([ 'id' => $id, 'token' => $token ]) ->first(); }
[ "private", "function", "_getUser", "(", "$", "id", ",", "$", "token", ")", "{", "return", "$", "this", "->", "Users", "->", "find", "(", ")", "->", "where", "(", "[", "'id'", "=>", "$", "id", ",", "'token'", "=>", "$", "token", "]", ")", "->", "first", "(", ")", ";", "}" ]
Get user by id and activation token. @param int $id User id. @param string $token User activation token. @return array|User|null
[ "Get", "user", "by", "id", "and", "activation", "token", "." ]
cc2bdb596dd9617d42fd81f59e981024caa062e8
https://github.com/CakeCMS/Community/blob/cc2bdb596dd9617d42fd81f59e981024caa062e8/src/Controller/UsersController.php#L191-L199
9,968
meliorframework/melior
Classes/Helper/LinkHelper.php
LinkHelper.buildLink
public function buildLink( string $protocol = null, string $host = null, $path = null, array $query = null, string $fragment = null ): string { if (empty($protocol)) { $protocol = (array_key_exists('HTTPS', $_SERVER) && !empty($_SERVER['HTTPS']) ? 'https' : 'http'); } if (empty($host)) { $host = $_SERVER['HTTP_HOST']; } $link = "$protocol://$host/"; if (!empty($path)) { if (is_string($path)) { $link .= $path; } elseif (is_array($path)) { $path = $this->pathHelper->joinArray($path); $link .= $path; } else { $type = gettype($path); throw new InvalidArgumentException( "Expected a the path argument to be of type string or array, $type given!", 1530398563 ); } } if (!empty($query)) { $link .= '?'.array_keys($query)[0].'='.array_shift($query); foreach ($query as $key => $value) { $link .= "&$key=$value"; } } if (!empty($fragment)) { $link .= "#$fragment"; } return $link; }
php
public function buildLink( string $protocol = null, string $host = null, $path = null, array $query = null, string $fragment = null ): string { if (empty($protocol)) { $protocol = (array_key_exists('HTTPS', $_SERVER) && !empty($_SERVER['HTTPS']) ? 'https' : 'http'); } if (empty($host)) { $host = $_SERVER['HTTP_HOST']; } $link = "$protocol://$host/"; if (!empty($path)) { if (is_string($path)) { $link .= $path; } elseif (is_array($path)) { $path = $this->pathHelper->joinArray($path); $link .= $path; } else { $type = gettype($path); throw new InvalidArgumentException( "Expected a the path argument to be of type string or array, $type given!", 1530398563 ); } } if (!empty($query)) { $link .= '?'.array_keys($query)[0].'='.array_shift($query); foreach ($query as $key => $value) { $link .= "&$key=$value"; } } if (!empty($fragment)) { $link .= "#$fragment"; } return $link; }
[ "public", "function", "buildLink", "(", "string", "$", "protocol", "=", "null", ",", "string", "$", "host", "=", "null", ",", "$", "path", "=", "null", ",", "array", "$", "query", "=", "null", ",", "string", "$", "fragment", "=", "null", ")", ":", "string", "{", "if", "(", "empty", "(", "$", "protocol", ")", ")", "{", "$", "protocol", "=", "(", "array_key_exists", "(", "'HTTPS'", ",", "$", "_SERVER", ")", "&&", "!", "empty", "(", "$", "_SERVER", "[", "'HTTPS'", "]", ")", "?", "'https'", ":", "'http'", ")", ";", "}", "if", "(", "empty", "(", "$", "host", ")", ")", "{", "$", "host", "=", "$", "_SERVER", "[", "'HTTP_HOST'", "]", ";", "}", "$", "link", "=", "\"$protocol://$host/\"", ";", "if", "(", "!", "empty", "(", "$", "path", ")", ")", "{", "if", "(", "is_string", "(", "$", "path", ")", ")", "{", "$", "link", ".=", "$", "path", ";", "}", "elseif", "(", "is_array", "(", "$", "path", ")", ")", "{", "$", "path", "=", "$", "this", "->", "pathHelper", "->", "joinArray", "(", "$", "path", ")", ";", "$", "link", ".=", "$", "path", ";", "}", "else", "{", "$", "type", "=", "gettype", "(", "$", "path", ")", ";", "throw", "new", "InvalidArgumentException", "(", "\"Expected a the path argument to be of type string or array, $type given!\"", ",", "1530398563", ")", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "query", ")", ")", "{", "$", "link", ".=", "'?'", ".", "array_keys", "(", "$", "query", ")", "[", "0", "]", ".", "'='", ".", "array_shift", "(", "$", "query", ")", ";", "foreach", "(", "$", "query", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "link", ".=", "\"&$key=$value\"", ";", "}", "}", "if", "(", "!", "empty", "(", "$", "fragment", ")", ")", "{", "$", "link", ".=", "\"#$fragment\"", ";", "}", "return", "$", "link", ";", "}" ]
Build an URL by the given arguments. @param string $protocol The link protocol (defaults to the current request protocol) @param string $host The link host (defaults to the current http host) @param string|array|null $path The link path (optional) @param array|null $query Additional query parameters (optional) @param string|null $fragment The link fragment (optional) @return string
[ "Build", "an", "URL", "by", "the", "given", "arguments", "." ]
f6469fa6e85f66a0507ae13603d19d78f2774e0b
https://github.com/meliorframework/melior/blob/f6469fa6e85f66a0507ae13603d19d78f2774e0b/Classes/Helper/LinkHelper.php#L52-L97
9,969
rawphp/RawSupport
src/RawPHP/RawSupport/Collection/Collection.php
Collection.getGroupByKey
protected function getGroupByKey( $group, $key, $value ) { if ( !is_string( $group ) && is_callable( $group ) ) { return $group( $value, $key ); } return Util::dataGet( $value, $group ); }
php
protected function getGroupByKey( $group, $key, $value ) { if ( !is_string( $group ) && is_callable( $group ) ) { return $group( $value, $key ); } return Util::dataGet( $value, $group ); }
[ "protected", "function", "getGroupByKey", "(", "$", "group", ",", "$", "key", ",", "$", "value", ")", "{", "if", "(", "!", "is_string", "(", "$", "group", ")", "&&", "is_callable", "(", "$", "group", ")", ")", "{", "return", "$", "group", "(", "$", "value", ",", "$", "key", ")", ";", "}", "return", "Util", "::", "dataGet", "(", "$", "value", ",", "$", "group", ")", ";", "}" ]
Get the 'group by' key value. @param Closure|string $group @param string $key @param mixed $value @return string
[ "Get", "the", "group", "by", "key", "value", "." ]
0eb1601fa6b14bc0e40d30dc8d53126b2409ab37
https://github.com/rawphp/RawSupport/blob/0eb1601fa6b14bc0e40d30dc8d53126b2409ab37/src/RawPHP/RawSupport/Collection/Collection.php#L210-L218
9,970
rootworkit/phpunit-helpers
src/PHPUnit/Helper/Accessor.php
Accessor.getPropertyValue
public function getPropertyValue($object, $name) { $property = new ReflectionProperty($object, $name); $property->setAccessible(true); return $property->getValue($object); }
php
public function getPropertyValue($object, $name) { $property = new ReflectionProperty($object, $name); $property->setAccessible(true); return $property->getValue($object); }
[ "public", "function", "getPropertyValue", "(", "$", "object", ",", "$", "name", ")", "{", "$", "property", "=", "new", "ReflectionProperty", "(", "$", "object", ",", "$", "name", ")", ";", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "return", "$", "property", "->", "getValue", "(", "$", "object", ")", ";", "}" ]
Get the value of a non-public property. @param object $object @param string $name @return mixed
[ "Get", "the", "value", "of", "a", "non", "-", "public", "property", "." ]
8578e6d7a477f8d97982d52c5a28236aecb8b10f
https://github.com/rootworkit/phpunit-helpers/blob/8578e6d7a477f8d97982d52c5a28236aecb8b10f/src/PHPUnit/Helper/Accessor.php#L40-L45
9,971
rootworkit/phpunit-helpers
src/PHPUnit/Helper/Accessor.php
Accessor.invokeMethod
public function invokeMethod($object, $name, array $args = []) { $method = new ReflectionMethod($object, $name); $method->setAccessible(true); if (empty($args)) { return $method->invoke($object); } return $method->invokeArgs($object, $args); }
php
public function invokeMethod($object, $name, array $args = []) { $method = new ReflectionMethod($object, $name); $method->setAccessible(true); if (empty($args)) { return $method->invoke($object); } return $method->invokeArgs($object, $args); }
[ "public", "function", "invokeMethod", "(", "$", "object", ",", "$", "name", ",", "array", "$", "args", "=", "[", "]", ")", "{", "$", "method", "=", "new", "ReflectionMethod", "(", "$", "object", ",", "$", "name", ")", ";", "$", "method", "->", "setAccessible", "(", "true", ")", ";", "if", "(", "empty", "(", "$", "args", ")", ")", "{", "return", "$", "method", "->", "invoke", "(", "$", "object", ")", ";", "}", "return", "$", "method", "->", "invokeArgs", "(", "$", "object", ",", "$", "args", ")", ";", "}" ]
Invoke a non-public method @param object $object @param string $name @param array $args @return mixed
[ "Invoke", "a", "non", "-", "public", "method" ]
8578e6d7a477f8d97982d52c5a28236aecb8b10f
https://github.com/rootworkit/phpunit-helpers/blob/8578e6d7a477f8d97982d52c5a28236aecb8b10f/src/PHPUnit/Helper/Accessor.php#L55-L65
9,972
rootworkit/phpunit-helpers
src/PHPUnit/Helper/Accessor.php
Accessor.invokeStaticMethod
public function invokeStaticMethod($class, $name, array $args = []) { $method = new ReflectionMethod($class, $name); $method->setAccessible(true); if (empty($args)) { return $method->invoke(null); } return $method->invokeArgs(null, $args); }
php
public function invokeStaticMethod($class, $name, array $args = []) { $method = new ReflectionMethod($class, $name); $method->setAccessible(true); if (empty($args)) { return $method->invoke(null); } return $method->invokeArgs(null, $args); }
[ "public", "function", "invokeStaticMethod", "(", "$", "class", ",", "$", "name", ",", "array", "$", "args", "=", "[", "]", ")", "{", "$", "method", "=", "new", "ReflectionMethod", "(", "$", "class", ",", "$", "name", ")", ";", "$", "method", "->", "setAccessible", "(", "true", ")", ";", "if", "(", "empty", "(", "$", "args", ")", ")", "{", "return", "$", "method", "->", "invoke", "(", "null", ")", ";", "}", "return", "$", "method", "->", "invokeArgs", "(", "null", ",", "$", "args", ")", ";", "}" ]
Invoke a non-public static method @param string $class @param string $name @param array $args @return mixed
[ "Invoke", "a", "non", "-", "public", "static", "method" ]
8578e6d7a477f8d97982d52c5a28236aecb8b10f
https://github.com/rootworkit/phpunit-helpers/blob/8578e6d7a477f8d97982d52c5a28236aecb8b10f/src/PHPUnit/Helper/Accessor.php#L103-L113
9,973
chilimatic/datastructure-component
src/Graph/TreeNode.php
TreeNode.createTree
protected function createTree(&$keyParts, TreeNode $rootNode) : TreeNode { if (!count($keyParts)) { return $rootNode; } $newKey = array_shift($keyParts); $newNode = new self($rootNode, $newKey, null, $rootNode->getKeyDelimiter()); $rootNode->addChild($newNode); return $this->createTree($keyParts, $newNode); }
php
protected function createTree(&$keyParts, TreeNode $rootNode) : TreeNode { if (!count($keyParts)) { return $rootNode; } $newKey = array_shift($keyParts); $newNode = new self($rootNode, $newKey, null, $rootNode->getKeyDelimiter()); $rootNode->addChild($newNode); return $this->createTree($keyParts, $newNode); }
[ "protected", "function", "createTree", "(", "&", "$", "keyParts", ",", "TreeNode", "$", "rootNode", ")", ":", "TreeNode", "{", "if", "(", "!", "count", "(", "$", "keyParts", ")", ")", "{", "return", "$", "rootNode", ";", "}", "$", "newKey", "=", "array_shift", "(", "$", "keyParts", ")", ";", "$", "newNode", "=", "new", "self", "(", "$", "rootNode", ",", "$", "newKey", ",", "null", ",", "$", "rootNode", "->", "getKeyDelimiter", "(", ")", ")", ";", "$", "rootNode", "->", "addChild", "(", "$", "newNode", ")", ";", "return", "$", "this", "->", "createTree", "(", "$", "keyParts", ",", "$", "newNode", ")", ";", "}" ]
recursive way to build tree structure @param array $keyParts @param TreeNode $rootNode @return TreeNode
[ "recursive", "way", "to", "build", "tree", "structure" ]
37832e5fab2a9520f9b025160b31a34c06bd71cd
https://github.com/chilimatic/datastructure-component/blob/37832e5fab2a9520f9b025160b31a34c06bd71cd/src/Graph/TreeNode.php#L121-L132
9,974
unyx/utils
traits/StaticallyExtendable.php
StaticallyExtendable.extend
public static function extend($name, callable $callable = null) { if (!is_array($name)) { if (null === $callable) { throw new \InvalidArgumentException("A callable must be given as second parameter if the first is not an array."); } self::$extensions[$name] = $callable; return; } foreach ($name as $method => $callable) { if (!is_callable($callable)) { throw new \InvalidArgumentException("The values of an array passed to the extend() method must be callables."); } self::$extensions[$method] = $callable; } }
php
public static function extend($name, callable $callable = null) { if (!is_array($name)) { if (null === $callable) { throw new \InvalidArgumentException("A callable must be given as second parameter if the first is not an array."); } self::$extensions[$name] = $callable; return; } foreach ($name as $method => $callable) { if (!is_callable($callable)) { throw new \InvalidArgumentException("The values of an array passed to the extend() method must be callables."); } self::$extensions[$method] = $callable; } }
[ "public", "static", "function", "extend", "(", "$", "name", ",", "callable", "$", "callable", "=", "null", ")", "{", "if", "(", "!", "is_array", "(", "$", "name", ")", ")", "{", "if", "(", "null", "===", "$", "callable", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"A callable must be given as second parameter if the first is not an array.\"", ")", ";", "}", "self", "::", "$", "extensions", "[", "$", "name", "]", "=", "$", "callable", ";", "return", ";", "}", "foreach", "(", "$", "name", "as", "$", "method", "=>", "$", "callable", ")", "{", "if", "(", "!", "is_callable", "(", "$", "callable", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"The values of an array passed to the extend() method must be callables.\"", ")", ";", "}", "self", "::", "$", "extensions", "[", "$", "method", "]", "=", "$", "callable", ";", "}", "}" ]
Registers an additional static method. @param string|array $name The name the callable should be made available as or an array of name => callable pairs. @param callable $callable The actual code that should be called. @throws \InvalidArgumentException When the first parameter is not an array and the second is not given or when an array is given and its values are not callables.
[ "Registers", "an", "additional", "static", "method", "." ]
503a3dd46fd2216024ab771b6e830be16d36b358
https://github.com/unyx/utils/blob/503a3dd46fd2216024ab771b6e830be16d36b358/traits/StaticallyExtendable.php#L35-L53
9,975
nubs/sensible
src/Browser.php
Browser.viewURI
public function viewURI(ProcessBuilder $processBuilder, $uri) { $proc = $processBuilder->setPrefix($this->_browserCommand)->setArguments([$uri])->getProcess(); $proc->setTty(true)->run(); return $proc; }
php
public function viewURI(ProcessBuilder $processBuilder, $uri) { $proc = $processBuilder->setPrefix($this->_browserCommand)->setArguments([$uri])->getProcess(); $proc->setTty(true)->run(); return $proc; }
[ "public", "function", "viewURI", "(", "ProcessBuilder", "$", "processBuilder", ",", "$", "uri", ")", "{", "$", "proc", "=", "$", "processBuilder", "->", "setPrefix", "(", "$", "this", "->", "_browserCommand", ")", "->", "setArguments", "(", "[", "$", "uri", "]", ")", "->", "getProcess", "(", ")", ";", "$", "proc", "->", "setTty", "(", "true", ")", "->", "run", "(", ")", ";", "return", "$", "proc", ";", "}" ]
View the given URI using the symfony process builder to build the symfony process to execute. @api @param \Symfony\Component\Process\ProcessBuilder $processBuilder The process builder. @param string $uri The URI to view. @return \Symfony\Component\Process\Process The already-executed process.
[ "View", "the", "given", "URI", "using", "the", "symfony", "process", "builder", "to", "build", "the", "symfony", "process", "to", "execute", "." ]
d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7
https://github.com/nubs/sensible/blob/d0ba8d66a93d42ac0a9fb813093e8c0c3559bac7/src/Browser.php#L35-L41
9,976
traq/installer
src/Controllers/Install.php
Install.installAction
public function installAction() { // Create database connection and load migrations $connection = ConnectionManager::create($_SESSION['db']); $this->loadMigrations(); // Migrate the database. $m = new Migrator; $m->migrate('up'); // Create admin account $admin = new User($_SESSION['admin'] + [ 'name' => $_SESSION['admin']['username'], 'group_id' => 1 ]); $admin->save(); // Set config file contents $this->set("config", $this->makeConfig()); // Insert defaults $seeder = new Seeder; $seeder->seed(); // Remove database and account details from the session. unset($_SESSION['db'], $_SESSION['admin']); $this->title("Complete"); return $this->render("complete.phtml"); }
php
public function installAction() { // Create database connection and load migrations $connection = ConnectionManager::create($_SESSION['db']); $this->loadMigrations(); // Migrate the database. $m = new Migrator; $m->migrate('up'); // Create admin account $admin = new User($_SESSION['admin'] + [ 'name' => $_SESSION['admin']['username'], 'group_id' => 1 ]); $admin->save(); // Set config file contents $this->set("config", $this->makeConfig()); // Insert defaults $seeder = new Seeder; $seeder->seed(); // Remove database and account details from the session. unset($_SESSION['db'], $_SESSION['admin']); $this->title("Complete"); return $this->render("complete.phtml"); }
[ "public", "function", "installAction", "(", ")", "{", "// Create database connection and load migrations", "$", "connection", "=", "ConnectionManager", "::", "create", "(", "$", "_SESSION", "[", "'db'", "]", ")", ";", "$", "this", "->", "loadMigrations", "(", ")", ";", "// Migrate the database.", "$", "m", "=", "new", "Migrator", ";", "$", "m", "->", "migrate", "(", "'up'", ")", ";", "// Create admin account", "$", "admin", "=", "new", "User", "(", "$", "_SESSION", "[", "'admin'", "]", "+", "[", "'name'", "=>", "$", "_SESSION", "[", "'admin'", "]", "[", "'username'", "]", ",", "'group_id'", "=>", "1", "]", ")", ";", "$", "admin", "->", "save", "(", ")", ";", "// Set config file contents", "$", "this", "->", "set", "(", "\"config\"", ",", "$", "this", "->", "makeConfig", "(", ")", ")", ";", "// Insert defaults", "$", "seeder", "=", "new", "Seeder", ";", "$", "seeder", "->", "seed", "(", ")", ";", "// Remove database and account details from the session.", "unset", "(", "$", "_SESSION", "[", "'db'", "]", ",", "$", "_SESSION", "[", "'admin'", "]", ")", ";", "$", "this", "->", "title", "(", "\"Complete\"", ")", ";", "return", "$", "this", "->", "render", "(", "\"complete.phtml\"", ")", ";", "}" ]
Migrate database and create admin account.
[ "Migrate", "database", "and", "create", "admin", "account", "." ]
7d82ee13d11c59cb63bcb7739962c85a994271ef
https://github.com/traq/installer/blob/7d82ee13d11c59cb63bcb7739962c85a994271ef/src/Controllers/Install.php#L47-L76
9,977
traq/installer
src/Controllers/Install.php
Install.makeConfig
protected function makeConfig() { $config = [ "<?php", "return [", " 'environment' => \"production\",", " 'db' => [", " 'production' => [" ]; if ($_SESSION['db']['driver'] == "pdo_pgsql" || $_SESSION['db']['driver'] == "pdo_mysql") { $config[] = " 'driver' => \"{$_SESSION['db']['driver']}\","; $config[] = " 'host' => \"{$_SESSION['db']['host']}\","; $config[] = " 'user' => \"{$_SESSION['db']['user']}\","; $config[] = " 'password' => \"{$_SESSION['db']['password']}\","; $config[] = " 'dbname' => \"{$_SESSION['db']['dbname']}\","; $config[] = " 'prefix' => ''"; } elseif ($_SESSION['db']['driver'] == "pdo_sqlite") { $config[] = " 'path' => \"{$_SESSION['db']['path']}\""; } $config[] = " ]"; $config[] = " ]"; $config[] = "];"; return htmlentities(implode(PHP_EOL, $config)); }
php
protected function makeConfig() { $config = [ "<?php", "return [", " 'environment' => \"production\",", " 'db' => [", " 'production' => [" ]; if ($_SESSION['db']['driver'] == "pdo_pgsql" || $_SESSION['db']['driver'] == "pdo_mysql") { $config[] = " 'driver' => \"{$_SESSION['db']['driver']}\","; $config[] = " 'host' => \"{$_SESSION['db']['host']}\","; $config[] = " 'user' => \"{$_SESSION['db']['user']}\","; $config[] = " 'password' => \"{$_SESSION['db']['password']}\","; $config[] = " 'dbname' => \"{$_SESSION['db']['dbname']}\","; $config[] = " 'prefix' => ''"; } elseif ($_SESSION['db']['driver'] == "pdo_sqlite") { $config[] = " 'path' => \"{$_SESSION['db']['path']}\""; } $config[] = " ]"; $config[] = " ]"; $config[] = "];"; return htmlentities(implode(PHP_EOL, $config)); }
[ "protected", "function", "makeConfig", "(", ")", "{", "$", "config", "=", "[", "\"<?php\"", ",", "\"return [\"", ",", "\" 'environment' => \\\"production\\\",\"", ",", "\" 'db' => [\"", ",", "\" 'production' => [\"", "]", ";", "if", "(", "$", "_SESSION", "[", "'db'", "]", "[", "'driver'", "]", "==", "\"pdo_pgsql\"", "||", "$", "_SESSION", "[", "'db'", "]", "[", "'driver'", "]", "==", "\"pdo_mysql\"", ")", "{", "$", "config", "[", "]", "=", "\" 'driver' => \\\"{$_SESSION['db']['driver']}\\\",\"", ";", "$", "config", "[", "]", "=", "\" 'host' => \\\"{$_SESSION['db']['host']}\\\",\"", ";", "$", "config", "[", "]", "=", "\" 'user' => \\\"{$_SESSION['db']['user']}\\\",\"", ";", "$", "config", "[", "]", "=", "\" 'password' => \\\"{$_SESSION['db']['password']}\\\",\"", ";", "$", "config", "[", "]", "=", "\" 'dbname' => \\\"{$_SESSION['db']['dbname']}\\\",\"", ";", "$", "config", "[", "]", "=", "\" 'prefix' => ''\"", ";", "}", "elseif", "(", "$", "_SESSION", "[", "'db'", "]", "[", "'driver'", "]", "==", "\"pdo_sqlite\"", ")", "{", "$", "config", "[", "]", "=", "\" 'path' => \\\"{$_SESSION['db']['path']}\\\"\"", ";", "}", "$", "config", "[", "]", "=", "\" ]\"", ";", "$", "config", "[", "]", "=", "\" ]\"", ";", "$", "config", "[", "]", "=", "\"];\"", ";", "return", "htmlentities", "(", "implode", "(", "PHP_EOL", ",", "$", "config", ")", ")", ";", "}" ]
Create the configuration file contents.
[ "Create", "the", "configuration", "file", "contents", "." ]
7d82ee13d11c59cb63bcb7739962c85a994271ef
https://github.com/traq/installer/blob/7d82ee13d11c59cb63bcb7739962c85a994271ef/src/Controllers/Install.php#L81-L107
9,978
FiveLab/Query
src/Model/Join.php
Join.inner
public static function inner(string $fromAlias, string $to, string $toAlias, string $condition): Join { return new self(self::MODE_INNER, $fromAlias, $to, $toAlias, $condition); }
php
public static function inner(string $fromAlias, string $to, string $toAlias, string $condition): Join { return new self(self::MODE_INNER, $fromAlias, $to, $toAlias, $condition); }
[ "public", "static", "function", "inner", "(", "string", "$", "fromAlias", ",", "string", "$", "to", ",", "string", "$", "toAlias", ",", "string", "$", "condition", ")", ":", "Join", "{", "return", "new", "self", "(", "self", "::", "MODE_INNER", ",", "$", "fromAlias", ",", "$", "to", ",", "$", "toAlias", ",", "$", "condition", ")", ";", "}" ]
Create inner mode @param string $fromAlias @param string $to @param string $toAlias @param string $condition @return Join
[ "Create", "inner", "mode" ]
9a677ae5fd680173feae08cd1c78b0ce92937af0
https://github.com/FiveLab/Query/blob/9a677ae5fd680173feae08cd1c78b0ce92937af0/src/Model/Join.php#L79-L82
9,979
FiveLab/Query
src/Model/Join.php
Join.left
public static function left(string $fromAlias, string $to, string $toAlias, string $condition): Join { return new self(self::MODE_LEFT, $fromAlias, $to, $toAlias, $condition); }
php
public static function left(string $fromAlias, string $to, string $toAlias, string $condition): Join { return new self(self::MODE_LEFT, $fromAlias, $to, $toAlias, $condition); }
[ "public", "static", "function", "left", "(", "string", "$", "fromAlias", ",", "string", "$", "to", ",", "string", "$", "toAlias", ",", "string", "$", "condition", ")", ":", "Join", "{", "return", "new", "self", "(", "self", "::", "MODE_LEFT", ",", "$", "fromAlias", ",", "$", "to", ",", "$", "toAlias", ",", "$", "condition", ")", ";", "}" ]
Create left mode @param string $fromAlias @param string $to @param string $toAlias @param string $condition @return Join
[ "Create", "left", "mode" ]
9a677ae5fd680173feae08cd1c78b0ce92937af0
https://github.com/FiveLab/Query/blob/9a677ae5fd680173feae08cd1c78b0ce92937af0/src/Model/Join.php#L94-L97
9,980
gplcart/gapi
models/Credential.php
Credential.getList
public function getList(array $options = array()) { $sql = 'SELECT *'; if (!empty($options['count'])) { $sql = 'SELECT COUNT(credential_id)'; } $sql .= ' FROM module_gapi_credential WHERE credential_id IS NOT NULL'; $conditions = array(); if (isset($options['type'])) { $sql .= ' AND type=?'; $conditions[] = $options['type']; } $allowed_order = array('asc', 'desc'); $allowed_sort = array('name', 'credential_id', 'created', 'modified', 'type'); if (isset($options['sort']) && in_array($options['sort'], $allowed_sort) && isset($options['order']) && in_array($options['order'], $allowed_order)) { $sql .= " ORDER BY {$options['sort']} {$options['order']}"; } else { $sql .= ' ORDER BY created DESC'; } if (!empty($options['limit'])) { $sql .= ' LIMIT ' . implode(',', array_map('intval', $options['limit'])); } if (empty($options['count'])) { $fetch_options = array('index' => 'credential_id', 'unserialize' => 'data'); $result = $this->db->fetchAll($sql, $conditions, $fetch_options); } else { $result = (int) $this->db->fetchColumn($sql, $conditions); } return $result; }
php
public function getList(array $options = array()) { $sql = 'SELECT *'; if (!empty($options['count'])) { $sql = 'SELECT COUNT(credential_id)'; } $sql .= ' FROM module_gapi_credential WHERE credential_id IS NOT NULL'; $conditions = array(); if (isset($options['type'])) { $sql .= ' AND type=?'; $conditions[] = $options['type']; } $allowed_order = array('asc', 'desc'); $allowed_sort = array('name', 'credential_id', 'created', 'modified', 'type'); if (isset($options['sort']) && in_array($options['sort'], $allowed_sort) && isset($options['order']) && in_array($options['order'], $allowed_order)) { $sql .= " ORDER BY {$options['sort']} {$options['order']}"; } else { $sql .= ' ORDER BY created DESC'; } if (!empty($options['limit'])) { $sql .= ' LIMIT ' . implode(',', array_map('intval', $options['limit'])); } if (empty($options['count'])) { $fetch_options = array('index' => 'credential_id', 'unserialize' => 'data'); $result = $this->db->fetchAll($sql, $conditions, $fetch_options); } else { $result = (int) $this->db->fetchColumn($sql, $conditions); } return $result; }
[ "public", "function", "getList", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "sql", "=", "'SELECT *'", ";", "if", "(", "!", "empty", "(", "$", "options", "[", "'count'", "]", ")", ")", "{", "$", "sql", "=", "'SELECT COUNT(credential_id)'", ";", "}", "$", "sql", ".=", "' FROM module_gapi_credential WHERE credential_id IS NOT NULL'", ";", "$", "conditions", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'type'", "]", ")", ")", "{", "$", "sql", ".=", "' AND type=?'", ";", "$", "conditions", "[", "]", "=", "$", "options", "[", "'type'", "]", ";", "}", "$", "allowed_order", "=", "array", "(", "'asc'", ",", "'desc'", ")", ";", "$", "allowed_sort", "=", "array", "(", "'name'", ",", "'credential_id'", ",", "'created'", ",", "'modified'", ",", "'type'", ")", ";", "if", "(", "isset", "(", "$", "options", "[", "'sort'", "]", ")", "&&", "in_array", "(", "$", "options", "[", "'sort'", "]", ",", "$", "allowed_sort", ")", "&&", "isset", "(", "$", "options", "[", "'order'", "]", ")", "&&", "in_array", "(", "$", "options", "[", "'order'", "]", ",", "$", "allowed_order", ")", ")", "{", "$", "sql", ".=", "\" ORDER BY {$options['sort']} {$options['order']}\"", ";", "}", "else", "{", "$", "sql", ".=", "' ORDER BY created DESC'", ";", "}", "if", "(", "!", "empty", "(", "$", "options", "[", "'limit'", "]", ")", ")", "{", "$", "sql", ".=", "' LIMIT '", ".", "implode", "(", "','", ",", "array_map", "(", "'intval'", ",", "$", "options", "[", "'limit'", "]", ")", ")", ";", "}", "if", "(", "empty", "(", "$", "options", "[", "'count'", "]", ")", ")", "{", "$", "fetch_options", "=", "array", "(", "'index'", "=>", "'credential_id'", ",", "'unserialize'", "=>", "'data'", ")", ";", "$", "result", "=", "$", "this", "->", "db", "->", "fetchAll", "(", "$", "sql", ",", "$", "conditions", ",", "$", "fetch_options", ")", ";", "}", "else", "{", "$", "result", "=", "(", "int", ")", "$", "this", "->", "db", "->", "fetchColumn", "(", "$", "sql", ",", "$", "conditions", ")", ";", "}", "return", "$", "result", ";", "}" ]
Returns an array of credentials or counts them @param array $options @return array|integer
[ "Returns", "an", "array", "of", "credentials", "or", "counts", "them" ]
b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8
https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/models/Credential.php#L69-L110
9,981
gplcart/gapi
models/Credential.php
Credential.deleteService
public function deleteService($id) { $data = $this->get($id); if (empty($data)) { return false; } if (!$this->delete($id)) { return false; } $file = gplcart_file_absolute($data['data']['file']); if (file_exists($file)) { unlink($file); } return true; }
php
public function deleteService($id) { $data = $this->get($id); if (empty($data)) { return false; } if (!$this->delete($id)) { return false; } $file = gplcart_file_absolute($data['data']['file']); if (file_exists($file)) { unlink($file); } return true; }
[ "public", "function", "deleteService", "(", "$", "id", ")", "{", "$", "data", "=", "$", "this", "->", "get", "(", "$", "id", ")", ";", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "$", "this", "->", "delete", "(", "$", "id", ")", ")", "{", "return", "false", ";", "}", "$", "file", "=", "gplcart_file_absolute", "(", "$", "data", "[", "'data'", "]", "[", "'file'", "]", ")", ";", "if", "(", "file_exists", "(", "$", "file", ")", ")", "{", "unlink", "(", "$", "file", ")", ";", "}", "return", "true", ";", "}" ]
Delete "Service" credential @param int @return bool
[ "Delete", "Service", "credential" ]
b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8
https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/models/Credential.php#L138-L157
9,982
gplcart/gapi
models/Credential.php
Credential.update
public function update($id, array $data) { $data['modified'] = GC_TIME; return (bool) $this->db->update('module_gapi_credential', $data, array('credential_id' => $id)); }
php
public function update($id, array $data) { $data['modified'] = GC_TIME; return (bool) $this->db->update('module_gapi_credential', $data, array('credential_id' => $id)); }
[ "public", "function", "update", "(", "$", "id", ",", "array", "$", "data", ")", "{", "$", "data", "[", "'modified'", "]", "=", "GC_TIME", ";", "return", "(", "bool", ")", "$", "this", "->", "db", "->", "update", "(", "'module_gapi_credential'", ",", "$", "data", ",", "array", "(", "'credential_id'", "=>", "$", "id", ")", ")", ";", "}" ]
Updates a credential @param integer $id @param array $data @return boolean
[ "Updates", "a", "credential" ]
b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8
https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/models/Credential.php#L165-L169
9,983
gplcart/gapi
models/Credential.php
Credential.getHandlers
public function getHandlers() { $handlers = array( 'key' => array( 'name' => $this->translation->text('API key'), 'handlers' => array( 'delete' => array(__CLASS__, 'delete'), 'edit' => array('gplcart\\modules\\gapi\\controllers\\Credential', 'editKeyCredential') ) ), 'oauth' => array( 'name' => $this->translation->text('OAuth client ID'), 'handlers' => array( 'delete' => array(__CLASS__, 'delete'), 'edit' => array('gplcart\\modules\\gapi\\controllers\\Credential', 'editOauthCredential') ) ), 'service' => array( 'name' => $this->translation->text('Service account key'), 'handlers' => array( 'delete' => array(__CLASS__, 'deleteService'), 'edit' => array('gplcart\\modules\\gapi\\controllers\\Credential', 'editServiceCredential') ) ) ); $this->hook->attach('module.gapi.credential.handlers', $handlers); return $handlers; }
php
public function getHandlers() { $handlers = array( 'key' => array( 'name' => $this->translation->text('API key'), 'handlers' => array( 'delete' => array(__CLASS__, 'delete'), 'edit' => array('gplcart\\modules\\gapi\\controllers\\Credential', 'editKeyCredential') ) ), 'oauth' => array( 'name' => $this->translation->text('OAuth client ID'), 'handlers' => array( 'delete' => array(__CLASS__, 'delete'), 'edit' => array('gplcart\\modules\\gapi\\controllers\\Credential', 'editOauthCredential') ) ), 'service' => array( 'name' => $this->translation->text('Service account key'), 'handlers' => array( 'delete' => array(__CLASS__, 'deleteService'), 'edit' => array('gplcart\\modules\\gapi\\controllers\\Credential', 'editServiceCredential') ) ) ); $this->hook->attach('module.gapi.credential.handlers', $handlers); return $handlers; }
[ "public", "function", "getHandlers", "(", ")", "{", "$", "handlers", "=", "array", "(", "'key'", "=>", "array", "(", "'name'", "=>", "$", "this", "->", "translation", "->", "text", "(", "'API key'", ")", ",", "'handlers'", "=>", "array", "(", "'delete'", "=>", "array", "(", "__CLASS__", ",", "'delete'", ")", ",", "'edit'", "=>", "array", "(", "'gplcart\\\\modules\\\\gapi\\\\controllers\\\\Credential'", ",", "'editKeyCredential'", ")", ")", ")", ",", "'oauth'", "=>", "array", "(", "'name'", "=>", "$", "this", "->", "translation", "->", "text", "(", "'OAuth client ID'", ")", ",", "'handlers'", "=>", "array", "(", "'delete'", "=>", "array", "(", "__CLASS__", ",", "'delete'", ")", ",", "'edit'", "=>", "array", "(", "'gplcart\\\\modules\\\\gapi\\\\controllers\\\\Credential'", ",", "'editOauthCredential'", ")", ")", ")", ",", "'service'", "=>", "array", "(", "'name'", "=>", "$", "this", "->", "translation", "->", "text", "(", "'Service account key'", ")", ",", "'handlers'", "=>", "array", "(", "'delete'", "=>", "array", "(", "__CLASS__", ",", "'deleteService'", ")", ",", "'edit'", "=>", "array", "(", "'gplcart\\\\modules\\\\gapi\\\\controllers\\\\Credential'", ",", "'editServiceCredential'", ")", ")", ")", ")", ";", "$", "this", "->", "hook", "->", "attach", "(", "'module.gapi.credential.handlers'", ",", "$", "handlers", ")", ";", "return", "$", "handlers", ";", "}" ]
Returns an array of credential handlers @return array
[ "Returns", "an", "array", "of", "credential", "handlers" ]
b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8
https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/models/Credential.php#L175-L203
9,984
gplcart/gapi
models/Credential.php
Credential.callHandler
public function callHandler($handler_id, $name, array $arguments = array()) { return Handler::call($this->getHandlers(), $handler_id, $name, $arguments); }
php
public function callHandler($handler_id, $name, array $arguments = array()) { return Handler::call($this->getHandlers(), $handler_id, $name, $arguments); }
[ "public", "function", "callHandler", "(", "$", "handler_id", ",", "$", "name", ",", "array", "$", "arguments", "=", "array", "(", ")", ")", "{", "return", "Handler", "::", "call", "(", "$", "this", "->", "getHandlers", "(", ")", ",", "$", "handler_id", ",", "$", "name", ",", "$", "arguments", ")", ";", "}" ]
Call a credential handler @param string $handler_id @param string $name @param array $arguments @return mixed
[ "Call", "a", "credential", "handler" ]
b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8
https://github.com/gplcart/gapi/blob/b1f8a737d8ff3b6a3e54f44d19af3295ce732fa8/models/Credential.php#L212-L215
9,985
mszewcz/php-json-schema-validator
src/Validators/ArrayValidators/ItemsValidator.php
ItemsValidator.validate
public function validate($subject): bool { if (\is_array($this->schema['items'])) { $schemaFirstKey = \array_keys($this->schema['items'])[0]; $schemaType = \is_int($schemaFirstKey) ? 'array' : 'object'; if (($schemaType === 'object') && !$this->validateItemsSchemaObject($subject, $this->schema)) { return false; } if ($schemaType === 'array' && !$this->validateItemsSchemaArray($subject, $this->schema)) { return false; } } return true; }
php
public function validate($subject): bool { if (\is_array($this->schema['items'])) { $schemaFirstKey = \array_keys($this->schema['items'])[0]; $schemaType = \is_int($schemaFirstKey) ? 'array' : 'object'; if (($schemaType === 'object') && !$this->validateItemsSchemaObject($subject, $this->schema)) { return false; } if ($schemaType === 'array' && !$this->validateItemsSchemaArray($subject, $this->schema)) { return false; } } return true; }
[ "public", "function", "validate", "(", "$", "subject", ")", ":", "bool", "{", "if", "(", "\\", "is_array", "(", "$", "this", "->", "schema", "[", "'items'", "]", ")", ")", "{", "$", "schemaFirstKey", "=", "\\", "array_keys", "(", "$", "this", "->", "schema", "[", "'items'", "]", ")", "[", "0", "]", ";", "$", "schemaType", "=", "\\", "is_int", "(", "$", "schemaFirstKey", ")", "?", "'array'", ":", "'object'", ";", "if", "(", "(", "$", "schemaType", "===", "'object'", ")", "&&", "!", "$", "this", "->", "validateItemsSchemaObject", "(", "$", "subject", ",", "$", "this", "->", "schema", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "schemaType", "===", "'array'", "&&", "!", "$", "this", "->", "validateItemsSchemaArray", "(", "$", "subject", ",", "$", "this", "->", "schema", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Validates subject against items @param $subject @return bool
[ "Validates", "subject", "against", "items" ]
f7768bfe07ce6508bb1ff36163560a5e5791de7d
https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/ArrayValidators/ItemsValidator.php#L48-L62
9,986
tenside/core-bundle
src/Command/SelfUpdateCommand.php
SelfUpdateCommand.cleanupOldBackups
protected function cleanupOldBackups($rollbackDir) { $finder = $this->getOldInstallationFinder($rollbackDir); $fileSystem = new Filesystem; foreach ($finder as $file) { $file = (string) $file; $this->getIO()->writeError('<info>Removing: ' . $file . '</info>'); $fileSystem->remove($file); } }
php
protected function cleanupOldBackups($rollbackDir) { $finder = $this->getOldInstallationFinder($rollbackDir); $fileSystem = new Filesystem; foreach ($finder as $file) { $file = (string) $file; $this->getIO()->writeError('<info>Removing: ' . $file . '</info>'); $fileSystem->remove($file); } }
[ "protected", "function", "cleanupOldBackups", "(", "$", "rollbackDir", ")", "{", "$", "finder", "=", "$", "this", "->", "getOldInstallationFinder", "(", "$", "rollbackDir", ")", ";", "$", "fileSystem", "=", "new", "Filesystem", ";", "foreach", "(", "$", "finder", "as", "$", "file", ")", "{", "$", "file", "=", "(", "string", ")", "$", "file", ";", "$", "this", "->", "getIO", "(", ")", "->", "writeError", "(", "'<info>Removing: '", ".", "$", "file", ".", "'</info>'", ")", ";", "$", "fileSystem", "->", "remove", "(", "$", "file", ")", ";", "}", "}" ]
Clean the backup directory. @param string $rollbackDir The backup directory. @return void
[ "Clean", "the", "backup", "directory", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Command/SelfUpdateCommand.php#L372-L382
9,987
tenside/core-bundle
src/Command/SelfUpdateCommand.php
SelfUpdateCommand.getBaseUrl
protected function getBaseUrl() { if (isset($this->baseUrl)) { return $this->baseUrl; } $this->baseUrl = $this->container->getParameter('tenside.self_update.base_url'); if (false === strpos($this->baseUrl, '://')) { $this->baseUrl = (extension_loaded('openssl') ? 'https' : 'http') . '://' . $this->baseUrl; } return $this->baseUrl; }
php
protected function getBaseUrl() { if (isset($this->baseUrl)) { return $this->baseUrl; } $this->baseUrl = $this->container->getParameter('tenside.self_update.base_url'); if (false === strpos($this->baseUrl, '://')) { $this->baseUrl = (extension_loaded('openssl') ? 'https' : 'http') . '://' . $this->baseUrl; } return $this->baseUrl; }
[ "protected", "function", "getBaseUrl", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "baseUrl", ")", ")", "{", "return", "$", "this", "->", "baseUrl", ";", "}", "$", "this", "->", "baseUrl", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'tenside.self_update.base_url'", ")", ";", "if", "(", "false", "===", "strpos", "(", "$", "this", "->", "baseUrl", ",", "'://'", ")", ")", "{", "$", "this", "->", "baseUrl", "=", "(", "extension_loaded", "(", "'openssl'", ")", "?", "'https'", ":", "'http'", ")", ".", "'://'", ".", "$", "this", "->", "baseUrl", ";", "}", "return", "$", "this", "->", "baseUrl", ";", "}" ]
Retrieve the base url for obtaining the latest version and phar files. @return string
[ "Retrieve", "the", "base", "url", "for", "obtaining", "the", "latest", "version", "and", "phar", "files", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Command/SelfUpdateCommand.php#L411-L424
9,988
tenside/core-bundle
src/Command/SelfUpdateCommand.php
SelfUpdateCommand.determineRemoteFilename
protected function determineRemoteFilename($updateVersion) { // If sha, download from root. if (preg_match('{^[0-9a-f]{40}$}', $updateVersion)) { return $this->getBaseUrl() . '/' . $this->getPharName(); } // Download from sub directory otherwise. return sprintf( '%s/download/%s/%s', $this->getBaseUrl(), $updateVersion, $this->getPharName() ); }
php
protected function determineRemoteFilename($updateVersion) { // If sha, download from root. if (preg_match('{^[0-9a-f]{40}$}', $updateVersion)) { return $this->getBaseUrl() . '/' . $this->getPharName(); } // Download from sub directory otherwise. return sprintf( '%s/download/%s/%s', $this->getBaseUrl(), $updateVersion, $this->getPharName() ); }
[ "protected", "function", "determineRemoteFilename", "(", "$", "updateVersion", ")", "{", "// If sha, download from root.", "if", "(", "preg_match", "(", "'{^[0-9a-f]{40}$}'", ",", "$", "updateVersion", ")", ")", "{", "return", "$", "this", "->", "getBaseUrl", "(", ")", ".", "'/'", ".", "$", "this", "->", "getPharName", "(", ")", ";", "}", "// Download from sub directory otherwise.", "return", "sprintf", "(", "'%s/download/%s/%s'", ",", "$", "this", "->", "getBaseUrl", "(", ")", ",", "$", "updateVersion", ",", "$", "this", "->", "getPharName", "(", ")", ")", ";", "}" ]
Calculate the remote filename from a version. @param string $updateVersion The version to update to either an sha or a semver version. @return string
[ "Calculate", "the", "remote", "filename", "from", "a", "version", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Command/SelfUpdateCommand.php#L443-L457
9,989
tenside/core-bundle
src/Command/SelfUpdateCommand.php
SelfUpdateCommand.determineLocalFileName
protected function determineLocalFileName() { // First: try to convert server argv 0 to a real path first (absolute path to a phar). if (false !== ($localFilename = realpath($_SERVER['argv'][0]))) { return $localFilename; } // Second: try the currently running phar file now. if ($localFilename = \Phar::running(false)) { return $localFilename; } // Fall back to server argv 0 (retaining relative path) and hope best. return $_SERVER['argv'][0]; }
php
protected function determineLocalFileName() { // First: try to convert server argv 0 to a real path first (absolute path to a phar). if (false !== ($localFilename = realpath($_SERVER['argv'][0]))) { return $localFilename; } // Second: try the currently running phar file now. if ($localFilename = \Phar::running(false)) { return $localFilename; } // Fall back to server argv 0 (retaining relative path) and hope best. return $_SERVER['argv'][0]; }
[ "protected", "function", "determineLocalFileName", "(", ")", "{", "// First: try to convert server argv 0 to a real path first (absolute path to a phar).", "if", "(", "false", "!==", "(", "$", "localFilename", "=", "realpath", "(", "$", "_SERVER", "[", "'argv'", "]", "[", "0", "]", ")", ")", ")", "{", "return", "$", "localFilename", ";", "}", "// Second: try the currently running phar file now.", "if", "(", "$", "localFilename", "=", "\\", "Phar", "::", "running", "(", "false", ")", ")", "{", "return", "$", "localFilename", ";", "}", "// Fall back to server argv 0 (retaining relative path) and hope best.", "return", "$", "_SERVER", "[", "'argv'", "]", "[", "0", "]", ";", "}" ]
Determine the local file name of the current running phar. @return string @SuppressWarnings(PHPMD.Superglobals) @SuppressWarnings(PHPMD.CamelCaseVariableName)
[ "Determine", "the", "local", "file", "name", "of", "the", "current", "running", "phar", "." ]
a7ffad3649cddac1e5594b4f8b65a5504363fccd
https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Command/SelfUpdateCommand.php#L467-L481
9,990
staccatocode/listable
src/Repository/AbstractRepository.php
AbstractRepository.filterBy
public function filterBy(string $name, $value): AbstractRepository { $this->filters[$name] = $value; return $this; }
php
public function filterBy(string $name, $value): AbstractRepository { $this->filters[$name] = $value; return $this; }
[ "public", "function", "filterBy", "(", "string", "$", "name", ",", "$", "value", ")", ":", "AbstractRepository", "{", "$", "this", "->", "filters", "[", "$", "name", "]", "=", "$", "value", ";", "return", "$", "this", ";", "}" ]
Set new list filter. @param string $name @param mixed $value @return AbstractRepository self
[ "Set", "new", "list", "filter", "." ]
9e97ff44e7d2af59f5a46c8e0faa29880545a40b
https://github.com/staccatocode/listable/blob/9e97ff44e7d2af59f5a46c8e0faa29880545a40b/src/Repository/AbstractRepository.php#L61-L66
9,991
staccatocode/listable
src/Repository/AbstractRepository.php
AbstractRepository.setFilters
public function setFilters(array $filters): AbstractRepository { foreach ($filters as $f => $v) { $this->filterBy($f, $v); } return $this; }
php
public function setFilters(array $filters): AbstractRepository { foreach ($filters as $f => $v) { $this->filterBy($f, $v); } return $this; }
[ "public", "function", "setFilters", "(", "array", "$", "filters", ")", ":", "AbstractRepository", "{", "foreach", "(", "$", "filters", "as", "$", "f", "=>", "$", "v", ")", "{", "$", "this", "->", "filterBy", "(", "$", "f", ",", "$", "v", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set list filters. @param array $filters @return AbstractRepository self
[ "Set", "list", "filters", "." ]
9e97ff44e7d2af59f5a46c8e0faa29880545a40b
https://github.com/staccatocode/listable/blob/9e97ff44e7d2af59f5a46c8e0faa29880545a40b/src/Repository/AbstractRepository.php#L75-L82
9,992
staccatocode/listable
src/Repository/AbstractRepository.php
AbstractRepository.orderBy
public function orderBy(?string $name, string $type = self::ORDER_ASC): AbstractRepository { $this->sorter['name'] = $name; $this->sorter['type'] = $type; return $this; }
php
public function orderBy(?string $name, string $type = self::ORDER_ASC): AbstractRepository { $this->sorter['name'] = $name; $this->sorter['type'] = $type; return $this; }
[ "public", "function", "orderBy", "(", "?", "string", "$", "name", ",", "string", "$", "type", "=", "self", "::", "ORDER_ASC", ")", ":", "AbstractRepository", "{", "$", "this", "->", "sorter", "[", "'name'", "]", "=", "$", "name", ";", "$", "this", "->", "sorter", "[", "'type'", "]", "=", "$", "type", ";", "return", "$", "this", ";", "}" ]
Set list ordering. @param string|null $name sorter name or null to disable @param string $type `asc` or `desc` @return AbstractRepository self
[ "Set", "list", "ordering", "." ]
9e97ff44e7d2af59f5a46c8e0faa29880545a40b
https://github.com/staccatocode/listable/blob/9e97ff44e7d2af59f5a46c8e0faa29880545a40b/src/Repository/AbstractRepository.php#L92-L98
9,993
flowcode/AmulenNewsBundle
src/Flowcode/NewsBundle/Controller/AdminPostController.php
AdminPostController.createAction
public function createAction(Request $request) { $entity = new Post(); $form = $this->createCreateForm($entity); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $this->processVideo($entity); $em->persist($entity); $em->flush(); return $this->redirect($this->generateUrl('admin_post_show', array('id' => $entity->getId()))); } else { $this->get('session')->getFlashBag()->add( 'warning', $this->get('translator')->trans('save_fail') ); } return array( 'entity' => $entity, 'form' => $form->createView(), ); }
php
public function createAction(Request $request) { $entity = new Post(); $form = $this->createCreateForm($entity); $form->handleRequest($request); if ($form->isValid()) { $em = $this->getDoctrine()->getManager(); $this->processVideo($entity); $em->persist($entity); $em->flush(); return $this->redirect($this->generateUrl('admin_post_show', array('id' => $entity->getId()))); } else { $this->get('session')->getFlashBag()->add( 'warning', $this->get('translator')->trans('save_fail') ); } return array( 'entity' => $entity, 'form' => $form->createView(), ); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "entity", "=", "new", "Post", "(", ")", ";", "$", "form", "=", "$", "this", "->", "createCreateForm", "(", "$", "entity", ")", ";", "$", "form", "->", "handleRequest", "(", "$", "request", ")", ";", "if", "(", "$", "form", "->", "isValid", "(", ")", ")", "{", "$", "em", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getManager", "(", ")", ";", "$", "this", "->", "processVideo", "(", "$", "entity", ")", ";", "$", "em", "->", "persist", "(", "$", "entity", ")", ";", "$", "em", "->", "flush", "(", ")", ";", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "generateUrl", "(", "'admin_post_show'", ",", "array", "(", "'id'", "=>", "$", "entity", "->", "getId", "(", ")", ")", ")", ")", ";", "}", "else", "{", "$", "this", "->", "get", "(", "'session'", ")", "->", "getFlashBag", "(", ")", "->", "add", "(", "'warning'", ",", "$", "this", "->", "get", "(", "'translator'", ")", "->", "trans", "(", "'save_fail'", ")", ")", ";", "}", "return", "array", "(", "'entity'", "=>", "$", "entity", ",", "'form'", "=>", "$", "form", "->", "createView", "(", ")", ",", ")", ";", "}" ]
Creates a new Post entity. @Route("/", name="admin_post_create") @Method("POST") @Template("FlowcodeNewsBundle:AdminPost:new.html.twig")
[ "Creates", "a", "new", "Post", "entity", "." ]
e870d2f09b629affeddf9a53ed43205300b66933
https://github.com/flowcode/AmulenNewsBundle/blob/e870d2f09b629affeddf9a53ed43205300b66933/src/Flowcode/NewsBundle/Controller/AdminPostController.php#L48-L70
9,994
leedave/resource-mysql
src/Mysql.php
Mysql.connect
public function connect() { $arrParams = [ 'mysql:host='.$this->host, 'dbname='.$this->database, 'charset='.$this->charset, ]; $this->db = PdoSingleton::getInstance()->getConnection($arrParams, $this->username, $this->password); }
php
public function connect() { $arrParams = [ 'mysql:host='.$this->host, 'dbname='.$this->database, 'charset='.$this->charset, ]; $this->db = PdoSingleton::getInstance()->getConnection($arrParams, $this->username, $this->password); }
[ "public", "function", "connect", "(", ")", "{", "$", "arrParams", "=", "[", "'mysql:host='", ".", "$", "this", "->", "host", ",", "'dbname='", ".", "$", "this", "->", "database", ",", "'charset='", ".", "$", "this", "->", "charset", ",", "]", ";", "$", "this", "->", "db", "=", "PdoSingleton", "::", "getInstance", "(", ")", "->", "getConnection", "(", "$", "arrParams", ",", "$", "this", "->", "username", ",", "$", "this", "->", "password", ")", ";", "}" ]
Connect to MySql DB using constant params
[ "Connect", "to", "MySql", "DB", "using", "constant", "params" ]
68305dac50b1b956f08f41267d0b2912850d8232
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Mysql.php#L110-L119
9,995
leedave/resource-mysql
src/Mysql.php
Mysql.getTableColumns
public function getTableColumns() : array { if (!$this->isTableNameSet()) { return []; } $sql = "SHOW COLUMNS FROM `".$this->tableName."`"; $stmt = $this->db->query($sql); $arrResult = $stmt->fetchAll(PDO::FETCH_ASSOC); return $arrResult; }
php
public function getTableColumns() : array { if (!$this->isTableNameSet()) { return []; } $sql = "SHOW COLUMNS FROM `".$this->tableName."`"; $stmt = $this->db->query($sql); $arrResult = $stmt->fetchAll(PDO::FETCH_ASSOC); return $arrResult; }
[ "public", "function", "getTableColumns", "(", ")", ":", "array", "{", "if", "(", "!", "$", "this", "->", "isTableNameSet", "(", ")", ")", "{", "return", "[", "]", ";", "}", "$", "sql", "=", "\"SHOW COLUMNS FROM `\"", ".", "$", "this", "->", "tableName", ".", "\"`\"", ";", "$", "stmt", "=", "$", "this", "->", "db", "->", "query", "(", "$", "sql", ")", ";", "$", "arrResult", "=", "$", "stmt", "->", "fetchAll", "(", "PDO", "::", "FETCH_ASSOC", ")", ";", "return", "$", "arrResult", ";", "}" ]
Returns Columns in table @return array
[ "Returns", "Columns", "in", "table" ]
68305dac50b1b956f08f41267d0b2912850d8232
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Mysql.php#L137-L147
9,996
leedave/resource-mysql
src/Mysql.php
Mysql.save
public function save() : bool { if (!$this->isTableNameSet()) { return false; } $pkName = $this->primaryKey; if ((int) $this->$pkName > 0) { $this->updateEntry(); } else { $this->createEntry(); } return true; }
php
public function save() : bool { if (!$this->isTableNameSet()) { return false; } $pkName = $this->primaryKey; if ((int) $this->$pkName > 0) { $this->updateEntry(); } else { $this->createEntry(); } return true; }
[ "public", "function", "save", "(", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "isTableNameSet", "(", ")", ")", "{", "return", "false", ";", "}", "$", "pkName", "=", "$", "this", "->", "primaryKey", ";", "if", "(", "(", "int", ")", "$", "this", "->", "$", "pkName", ">", "0", ")", "{", "$", "this", "->", "updateEntry", "(", ")", ";", "}", "else", "{", "$", "this", "->", "createEntry", "(", ")", ";", "}", "return", "true", ";", "}" ]
Save if new, update if primary key isset @return bool
[ "Save", "if", "new", "update", "if", "primary", "key", "isset" ]
68305dac50b1b956f08f41267d0b2912850d8232
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Mysql.php#L153-L165
9,997
leedave/resource-mysql
src/Mysql.php
Mysql.delete
public function delete() : int { $sql = "DELETE FROM `".$this->tableName."` " . "WHERE `".$this->primaryKey."` = '".$this->id."';"; return $this->db->exec($sql); }
php
public function delete() : int { $sql = "DELETE FROM `".$this->tableName."` " . "WHERE `".$this->primaryKey."` = '".$this->id."';"; return $this->db->exec($sql); }
[ "public", "function", "delete", "(", ")", ":", "int", "{", "$", "sql", "=", "\"DELETE FROM `\"", ".", "$", "this", "->", "tableName", ".", "\"` \"", ".", "\"WHERE `\"", ".", "$", "this", "->", "primaryKey", ".", "\"` = '\"", ".", "$", "this", "->", "id", ".", "\"';\"", ";", "return", "$", "this", "->", "db", "->", "exec", "(", "$", "sql", ")", ";", "}" ]
Delete Row from DB Table @return int
[ "Delete", "Row", "from", "DB", "Table" ]
68305dac50b1b956f08f41267d0b2912850d8232
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Mysql.php#L171-L176
9,998
leedave/resource-mysql
src/Mysql.php
Mysql.createEntry
protected function createEntry() { $arrColumns = $this->getTableColumns(); $arrColumnNames = []; $arrColumnTypes = []; foreach ($arrColumns as $column) { $arrColumnNames[] = $column['Field']; $arrColumnTypes[] = $column['Type']; } $sql = 'INSERT INTO `'.$this->tableName.'` ' . '(`'.implode('`, `', $arrColumnNames).'`) ' . 'VALUES ' . '(:'.implode(', :', $arrColumnNames).')'; $arrInsert = []; for ($i = 0; $i < count($arrColumnNames); $i++) { $name = $arrColumnNames[$i]; $value = isset($this->$name)?$this->$name:""; if (substr($arrColumnTypes[$i], 0, 3) == 'int') { $value = (int) $value; } elseif ($arrColumnTypes[$i] == 'datetime') { $value = strftime("%Y-%m-%d %H:%M:%S", strtotime($value)); } $arrInsert[':'.$name] = $value; } $this->db->beginTransaction(); $stmt = $this->db->prepare($sql); try { $stmt->execute($arrInsert); $this->db->commit(); } catch (PDOException $ex) { $this->db->rollBack(); $this->log->critical( "Could not save to mysql".PHP_EOL .$sql.PHP_EOL .print_r($arrInsert, true).PHP_EOL .$ex->getMessage() ); } }
php
protected function createEntry() { $arrColumns = $this->getTableColumns(); $arrColumnNames = []; $arrColumnTypes = []; foreach ($arrColumns as $column) { $arrColumnNames[] = $column['Field']; $arrColumnTypes[] = $column['Type']; } $sql = 'INSERT INTO `'.$this->tableName.'` ' . '(`'.implode('`, `', $arrColumnNames).'`) ' . 'VALUES ' . '(:'.implode(', :', $arrColumnNames).')'; $arrInsert = []; for ($i = 0; $i < count($arrColumnNames); $i++) { $name = $arrColumnNames[$i]; $value = isset($this->$name)?$this->$name:""; if (substr($arrColumnTypes[$i], 0, 3) == 'int') { $value = (int) $value; } elseif ($arrColumnTypes[$i] == 'datetime') { $value = strftime("%Y-%m-%d %H:%M:%S", strtotime($value)); } $arrInsert[':'.$name] = $value; } $this->db->beginTransaction(); $stmt = $this->db->prepare($sql); try { $stmt->execute($arrInsert); $this->db->commit(); } catch (PDOException $ex) { $this->db->rollBack(); $this->log->critical( "Could not save to mysql".PHP_EOL .$sql.PHP_EOL .print_r($arrInsert, true).PHP_EOL .$ex->getMessage() ); } }
[ "protected", "function", "createEntry", "(", ")", "{", "$", "arrColumns", "=", "$", "this", "->", "getTableColumns", "(", ")", ";", "$", "arrColumnNames", "=", "[", "]", ";", "$", "arrColumnTypes", "=", "[", "]", ";", "foreach", "(", "$", "arrColumns", "as", "$", "column", ")", "{", "$", "arrColumnNames", "[", "]", "=", "$", "column", "[", "'Field'", "]", ";", "$", "arrColumnTypes", "[", "]", "=", "$", "column", "[", "'Type'", "]", ";", "}", "$", "sql", "=", "'INSERT INTO `'", ".", "$", "this", "->", "tableName", ".", "'` '", ".", "'(`'", ".", "implode", "(", "'`, `'", ",", "$", "arrColumnNames", ")", ".", "'`) '", ".", "'VALUES '", ".", "'(:'", ".", "implode", "(", "', :'", ",", "$", "arrColumnNames", ")", ".", "')'", ";", "$", "arrInsert", "=", "[", "]", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "arrColumnNames", ")", ";", "$", "i", "++", ")", "{", "$", "name", "=", "$", "arrColumnNames", "[", "$", "i", "]", ";", "$", "value", "=", "isset", "(", "$", "this", "->", "$", "name", ")", "?", "$", "this", "->", "$", "name", ":", "\"\"", ";", "if", "(", "substr", "(", "$", "arrColumnTypes", "[", "$", "i", "]", ",", "0", ",", "3", ")", "==", "'int'", ")", "{", "$", "value", "=", "(", "int", ")", "$", "value", ";", "}", "elseif", "(", "$", "arrColumnTypes", "[", "$", "i", "]", "==", "'datetime'", ")", "{", "$", "value", "=", "strftime", "(", "\"%Y-%m-%d %H:%M:%S\"", ",", "strtotime", "(", "$", "value", ")", ")", ";", "}", "$", "arrInsert", "[", "':'", ".", "$", "name", "]", "=", "$", "value", ";", "}", "$", "this", "->", "db", "->", "beginTransaction", "(", ")", ";", "$", "stmt", "=", "$", "this", "->", "db", "->", "prepare", "(", "$", "sql", ")", ";", "try", "{", "$", "stmt", "->", "execute", "(", "$", "arrInsert", ")", ";", "$", "this", "->", "db", "->", "commit", "(", ")", ";", "}", "catch", "(", "PDOException", "$", "ex", ")", "{", "$", "this", "->", "db", "->", "rollBack", "(", ")", ";", "$", "this", "->", "log", "->", "critical", "(", "\"Could not save to mysql\"", ".", "PHP_EOL", ".", "$", "sql", ".", "PHP_EOL", ".", "print_r", "(", "$", "arrInsert", ",", "true", ")", ".", "PHP_EOL", ".", "$", "ex", "->", "getMessage", "(", ")", ")", ";", "}", "}" ]
Inset a new Row into DB Table
[ "Inset", "a", "new", "Row", "into", "DB", "Table" ]
68305dac50b1b956f08f41267d0b2912850d8232
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Mysql.php#L181-L225
9,999
leedave/resource-mysql
src/Mysql.php
Mysql.getAllRows
public function getAllRows( array $arrWhat = ['*'], array $arrWhere = [], array $arrOrder = ['`id` ASC'], array $arrLimit = [] ) : array { if (count($arrWhat) < 1) { throw new Exception('Missing MySQL Select Params'); } $strWhere = ""; $strOrder = ""; $strLimit = ""; if (count($arrWhere) > 0) { $strWhere = "WHERE ".implode(" AND ", $arrWhere)." "; } if (count($arrOrder) > 0) { $strOrder = "ORDER BY ".implode(", ", $arrOrder)." "; } if (count($arrLimit) > 0) { $strLimit = "LIMIT ".implode(",", $arrLimit)." "; } $what = "`".implode($arrWhat, "`,`")."`"; $sql = "SELECT ".$what." " . "FROM `".$this->tableName."` " . $strWhere . $strOrder . $strLimit ; //echo $sql; $stmt = $this->db->query($sql); $arrRows = $stmt->fetchAll(PDO::FETCH_ASSOC); if ($arrRows === false) { throw new Exception('failed to execute '.$sql); } return $arrRows; }
php
public function getAllRows( array $arrWhat = ['*'], array $arrWhere = [], array $arrOrder = ['`id` ASC'], array $arrLimit = [] ) : array { if (count($arrWhat) < 1) { throw new Exception('Missing MySQL Select Params'); } $strWhere = ""; $strOrder = ""; $strLimit = ""; if (count($arrWhere) > 0) { $strWhere = "WHERE ".implode(" AND ", $arrWhere)." "; } if (count($arrOrder) > 0) { $strOrder = "ORDER BY ".implode(", ", $arrOrder)." "; } if (count($arrLimit) > 0) { $strLimit = "LIMIT ".implode(",", $arrLimit)." "; } $what = "`".implode($arrWhat, "`,`")."`"; $sql = "SELECT ".$what." " . "FROM `".$this->tableName."` " . $strWhere . $strOrder . $strLimit ; //echo $sql; $stmt = $this->db->query($sql); $arrRows = $stmt->fetchAll(PDO::FETCH_ASSOC); if ($arrRows === false) { throw new Exception('failed to execute '.$sql); } return $arrRows; }
[ "public", "function", "getAllRows", "(", "array", "$", "arrWhat", "=", "[", "'*'", "]", ",", "array", "$", "arrWhere", "=", "[", "]", ",", "array", "$", "arrOrder", "=", "[", "'`id` ASC'", "]", ",", "array", "$", "arrLimit", "=", "[", "]", ")", ":", "array", "{", "if", "(", "count", "(", "$", "arrWhat", ")", "<", "1", ")", "{", "throw", "new", "Exception", "(", "'Missing MySQL Select Params'", ")", ";", "}", "$", "strWhere", "=", "\"\"", ";", "$", "strOrder", "=", "\"\"", ";", "$", "strLimit", "=", "\"\"", ";", "if", "(", "count", "(", "$", "arrWhere", ")", ">", "0", ")", "{", "$", "strWhere", "=", "\"WHERE \"", ".", "implode", "(", "\" AND \"", ",", "$", "arrWhere", ")", ".", "\" \"", ";", "}", "if", "(", "count", "(", "$", "arrOrder", ")", ">", "0", ")", "{", "$", "strOrder", "=", "\"ORDER BY \"", ".", "implode", "(", "\", \"", ",", "$", "arrOrder", ")", ".", "\" \"", ";", "}", "if", "(", "count", "(", "$", "arrLimit", ")", ">", "0", ")", "{", "$", "strLimit", "=", "\"LIMIT \"", ".", "implode", "(", "\",\"", ",", "$", "arrLimit", ")", ".", "\" \"", ";", "}", "$", "what", "=", "\"`\"", ".", "implode", "(", "$", "arrWhat", ",", "\"`,`\"", ")", ".", "\"`\"", ";", "$", "sql", "=", "\"SELECT \"", ".", "$", "what", ".", "\" \"", ".", "\"FROM `\"", ".", "$", "this", "->", "tableName", ".", "\"` \"", ".", "$", "strWhere", ".", "$", "strOrder", ".", "$", "strLimit", ";", "//echo $sql;", "$", "stmt", "=", "$", "this", "->", "db", "->", "query", "(", "$", "sql", ")", ";", "$", "arrRows", "=", "$", "stmt", "->", "fetchAll", "(", "PDO", "::", "FETCH_ASSOC", ")", ";", "if", "(", "$", "arrRows", "===", "false", ")", "{", "throw", "new", "Exception", "(", "'failed to execute '", ".", "$", "sql", ")", ";", "}", "return", "$", "arrRows", ";", "}" ]
Simple SELECT Query, no transactions, fetch multiple entries @param array $arrWhat @param array $arrWhere array of strings Example: "`name` LIKE 'Dave'" @param array $arrOrder @param array $arrLimit @return array @throws Exception
[ "Simple", "SELECT", "Query", "no", "transactions", "fetch", "multiple", "entries" ]
68305dac50b1b956f08f41267d0b2912850d8232
https://github.com/leedave/resource-mysql/blob/68305dac50b1b956f08f41267d0b2912850d8232/src/Mysql.php#L345-L385