id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
21,300 |
eghojansu/moe
|
src/tools/Markdown.php
|
Markdown._code
|
protected function _code($str) {
$self=$this;
return preg_replace_callback(
'/`` (.+?) ``|(?<!\\\\)`(.+?)(?!\\\\)`/',
function($expr) use($self) {
return '<code>'.
$self->esc(empty($expr[1])?$expr[2]:$expr[1]).'</code>';
},
$str
);
}
|
php
|
protected function _code($str) {
$self=$this;
return preg_replace_callback(
'/`` (.+?) ``|(?<!\\\\)`(.+?)(?!\\\\)`/',
function($expr) use($self) {
return '<code>'.
$self->esc(empty($expr[1])?$expr[2]:$expr[1]).'</code>';
},
$str
);
}
|
[
"protected",
"function",
"_code",
"(",
"$",
"str",
")",
"{",
"$",
"self",
"=",
"$",
"this",
";",
"return",
"preg_replace_callback",
"(",
"'/`` (.+?) ``|(?<!\\\\\\\\)`(.+?)(?!\\\\\\\\)`/'",
",",
"function",
"(",
"$",
"expr",
")",
"use",
"(",
"$",
"self",
")",
"{",
"return",
"'<code>'",
".",
"$",
"self",
"->",
"esc",
"(",
"empty",
"(",
"$",
"expr",
"[",
"1",
"]",
")",
"?",
"$",
"expr",
"[",
"2",
"]",
":",
"$",
"expr",
"[",
"1",
"]",
")",
".",
"'</code>'",
";",
"}",
",",
"$",
"str",
")",
";",
"}"
] |
Process code span
@return string
@param $str string
|
[
"Process",
"code",
"span"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Markdown.php#L396-L406
|
21,301 |
eghojansu/moe
|
src/tools/Markdown.php
|
Markdown.esc
|
function esc($str) {
if (!$this->special)
$this->special=array(
'...'=>'…',
'(tm)'=>'™',
'(r)'=>'®',
'(c)'=>'©'
);
foreach ($this->special as $key=>$val)
$str=preg_replace('/'.preg_quote($key,'/').'/i',$val,$str);
return htmlspecialchars($str,ENT_COMPAT,
Base::instance()->get('ENCODING'),FALSE);
}
|
php
|
function esc($str) {
if (!$this->special)
$this->special=array(
'...'=>'…',
'(tm)'=>'™',
'(r)'=>'®',
'(c)'=>'©'
);
foreach ($this->special as $key=>$val)
$str=preg_replace('/'.preg_quote($key,'/').'/i',$val,$str);
return htmlspecialchars($str,ENT_COMPAT,
Base::instance()->get('ENCODING'),FALSE);
}
|
[
"function",
"esc",
"(",
"$",
"str",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"special",
")",
"$",
"this",
"->",
"special",
"=",
"array",
"(",
"'...'",
"=>",
"'…'",
",",
"'(tm)'",
"=>",
"'™'",
",",
"'(r)'",
"=>",
"'®'",
",",
"'(c)'",
"=>",
"'©'",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"special",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"$",
"str",
"=",
"preg_replace",
"(",
"'/'",
".",
"preg_quote",
"(",
"$",
"key",
",",
"'/'",
")",
".",
"'/i'",
",",
"$",
"val",
",",
"$",
"str",
")",
";",
"return",
"htmlspecialchars",
"(",
"$",
"str",
",",
"ENT_COMPAT",
",",
"Base",
"::",
"instance",
"(",
")",
"->",
"get",
"(",
"'ENCODING'",
")",
",",
"FALSE",
")",
";",
"}"
] |
Convert characters to HTML entities
@return string
@param $str string
|
[
"Convert",
"characters",
"to",
"HTML",
"entities"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/tools/Markdown.php#L413-L425
|
21,302 |
old-town/workflow-designer-server
|
src/View/ApiProblemInjectResponse.php
|
ApiProblemInjectResponse.getStatusCodeFromApiProblem
|
protected function getStatusCodeFromApiProblem(ApiProblem $problem)
{
$problemData = $problem->toArray();
$status = array_key_exists('status', $problemData) ? $problemData['status'] : 0;
if ($status < 100 || $status >= 600) {
return 500;
}
return $status;
}
|
php
|
protected function getStatusCodeFromApiProblem(ApiProblem $problem)
{
$problemData = $problem->toArray();
$status = array_key_exists('status', $problemData) ? $problemData['status'] : 0;
if ($status < 100 || $status >= 600) {
return 500;
}
return $status;
}
|
[
"protected",
"function",
"getStatusCodeFromApiProblem",
"(",
"ApiProblem",
"$",
"problem",
")",
"{",
"$",
"problemData",
"=",
"$",
"problem",
"->",
"toArray",
"(",
")",
";",
"$",
"status",
"=",
"array_key_exists",
"(",
"'status'",
",",
"$",
"problemData",
")",
"?",
"$",
"problemData",
"[",
"'status'",
"]",
":",
"0",
";",
"if",
"(",
"$",
"status",
"<",
"100",
"||",
"$",
"status",
">=",
"600",
")",
"{",
"return",
"500",
";",
"}",
"return",
"$",
"status",
";",
"}"
] |
Retrieve the HTTP status from an ApiProblem object
Ensures that the status falls within the acceptable range (100 - 599).
@param ApiProblem $problem
@return int
|
[
"Retrieve",
"the",
"HTTP",
"status",
"from",
"an",
"ApiProblem",
"object"
] |
6389c5a515861cc8e0b769f1ca7be12c6b78c611
|
https://github.com/old-town/workflow-designer-server/blob/6389c5a515861cc8e0b769f1ca7be12c6b78c611/src/View/ApiProblemInjectResponse.php#L87-L97
|
21,303 |
arndtteunissen/column-layout
|
Classes/Utility/ColumnLayoutUtility.php
|
ColumnLayoutUtility.getSizesFor
|
public static function getSizesFor(string $size, string $type, int $pageUid): array
{
$settings = ColumnLayoutUtility::getColumnLayoutSettings($pageUid);
if (!array_key_exists($size . '.', $settings['sizes.'])) {
throw new Exception(sprintf('The given size "%s" is not defined in the gridsystem', $size), 1520324173);
}
if (!array_key_exists($type, $settings['sizes.'][$size . '.'])) {
throw new Exception(sprintf('The given type "%s" does not exist for size "%s"', $type, $size), 1520324252);
}
return ColumnLayoutUtility::processColumnSizes($settings['sizes.'][$size . '.'][$type], $settings['columnsCount']);
}
|
php
|
public static function getSizesFor(string $size, string $type, int $pageUid): array
{
$settings = ColumnLayoutUtility::getColumnLayoutSettings($pageUid);
if (!array_key_exists($size . '.', $settings['sizes.'])) {
throw new Exception(sprintf('The given size "%s" is not defined in the gridsystem', $size), 1520324173);
}
if (!array_key_exists($type, $settings['sizes.'][$size . '.'])) {
throw new Exception(sprintf('The given type "%s" does not exist for size "%s"', $type, $size), 1520324252);
}
return ColumnLayoutUtility::processColumnSizes($settings['sizes.'][$size . '.'][$type], $settings['columnsCount']);
}
|
[
"public",
"static",
"function",
"getSizesFor",
"(",
"string",
"$",
"size",
",",
"string",
"$",
"type",
",",
"int",
"$",
"pageUid",
")",
":",
"array",
"{",
"$",
"settings",
"=",
"ColumnLayoutUtility",
"::",
"getColumnLayoutSettings",
"(",
"$",
"pageUid",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"size",
".",
"'.'",
",",
"$",
"settings",
"[",
"'sizes.'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'The given size \"%s\" is not defined in the gridsystem'",
",",
"$",
"size",
")",
",",
"1520324173",
")",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"type",
",",
"$",
"settings",
"[",
"'sizes.'",
"]",
"[",
"$",
"size",
".",
"'.'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'The given type \"%s\" does not exist for size \"%s\"'",
",",
"$",
"type",
",",
"$",
"size",
")",
",",
"1520324252",
")",
";",
"}",
"return",
"ColumnLayoutUtility",
"::",
"processColumnSizes",
"(",
"$",
"settings",
"[",
"'sizes.'",
"]",
"[",
"$",
"size",
".",
"'.'",
"]",
"[",
"$",
"type",
"]",
",",
"$",
"settings",
"[",
"'columnsCount'",
"]",
")",
";",
"}"
] |
Calculates the column sizes for the given size and the given size type
@param string $size name of the sizes identifier (e.g. large, medium)
@param string $type size type (e.g. columns, offset, order)
@param int $pageUid the page which's TSConfig should be used
@return array of column sizes
@throws Exception when the given size or type is not defined
|
[
"Calculates",
"the",
"column",
"sizes",
"for",
"the",
"given",
"size",
"and",
"the",
"given",
"size",
"type"
] |
ad737068eef3b084d4d0e3a48e6a3d8277af9560
|
https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/Utility/ColumnLayoutUtility.php#L31-L44
|
21,304 |
arndtteunissen/column-layout
|
Classes/Utility/ColumnLayoutUtility.php
|
ColumnLayoutUtility.getColumnLayoutSettings
|
public static function getColumnLayoutSettings(int $page): array
{
$pageTSConfig = BackendUtility::getPagesTSconfig($page);
if (!array_key_exists('column_layout.', $pageTSConfig['mod.'])) {
throw new Exception(sprintf('No column layout found for page "%d". Please define the column_layout settings in your page TSConfig.', $page), 1520323245);
}
return $pageTSConfig['mod.']['column_layout.'];
}
|
php
|
public static function getColumnLayoutSettings(int $page): array
{
$pageTSConfig = BackendUtility::getPagesTSconfig($page);
if (!array_key_exists('column_layout.', $pageTSConfig['mod.'])) {
throw new Exception(sprintf('No column layout found for page "%d". Please define the column_layout settings in your page TSConfig.', $page), 1520323245);
}
return $pageTSConfig['mod.']['column_layout.'];
}
|
[
"public",
"static",
"function",
"getColumnLayoutSettings",
"(",
"int",
"$",
"page",
")",
":",
"array",
"{",
"$",
"pageTSConfig",
"=",
"BackendUtility",
"::",
"getPagesTSconfig",
"(",
"$",
"page",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"'column_layout.'",
",",
"$",
"pageTSConfig",
"[",
"'mod.'",
"]",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"'No column layout found for page \"%d\". Please define the column_layout settings in your page TSConfig.'",
",",
"$",
"page",
")",
",",
"1520323245",
")",
";",
"}",
"return",
"$",
"pageTSConfig",
"[",
"'mod.'",
"]",
"[",
"'column_layout.'",
"]",
";",
"}"
] |
Returns the column layout configuration from page TSConfig.
@param int $page uid of the page
@return array column layout settings
@throws Exception when the column_layout setting hasn't been defined
|
[
"Returns",
"the",
"column",
"layout",
"configuration",
"from",
"page",
"TSConfig",
"."
] |
ad737068eef3b084d4d0e3a48e6a3d8277af9560
|
https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/Utility/ColumnLayoutUtility.php#L81-L90
|
21,305 |
arndtteunissen/column-layout
|
Classes/Utility/ColumnLayoutUtility.php
|
ColumnLayoutUtility.hydrateLayoutConfigFlexFormData
|
public static function hydrateLayoutConfigFlexFormData($flexFormData): array
{
$dataStructure = $flexFormData;
if (is_string($flexFormData)) {
$dataStructure = GeneralUtility::xml2array($flexFormData);
}
// Level: FlexForm Sheets
return array_map(function ($sheet) {
// Level: FlexForm Sheet Fields
return array_map(function ($field) {
// Level: FlexForm Field
return $field['vDEF'];
}, $sheet['lDEF']);
}, $dataStructure['data']);
}
|
php
|
public static function hydrateLayoutConfigFlexFormData($flexFormData): array
{
$dataStructure = $flexFormData;
if (is_string($flexFormData)) {
$dataStructure = GeneralUtility::xml2array($flexFormData);
}
// Level: FlexForm Sheets
return array_map(function ($sheet) {
// Level: FlexForm Sheet Fields
return array_map(function ($field) {
// Level: FlexForm Field
return $field['vDEF'];
}, $sheet['lDEF']);
}, $dataStructure['data']);
}
|
[
"public",
"static",
"function",
"hydrateLayoutConfigFlexFormData",
"(",
"$",
"flexFormData",
")",
":",
"array",
"{",
"$",
"dataStructure",
"=",
"$",
"flexFormData",
";",
"if",
"(",
"is_string",
"(",
"$",
"flexFormData",
")",
")",
"{",
"$",
"dataStructure",
"=",
"GeneralUtility",
"::",
"xml2array",
"(",
"$",
"flexFormData",
")",
";",
"}",
"// Level: FlexForm Sheets",
"return",
"array_map",
"(",
"function",
"(",
"$",
"sheet",
")",
"{",
"// Level: FlexForm Sheet Fields",
"return",
"array_map",
"(",
"function",
"(",
"$",
"field",
")",
"{",
"// Level: FlexForm Field",
"return",
"$",
"field",
"[",
"'vDEF'",
"]",
";",
"}",
",",
"$",
"sheet",
"[",
"'lDEF'",
"]",
")",
";",
"}",
",",
"$",
"dataStructure",
"[",
"'data'",
"]",
")",
";",
"}"
] |
Simplify a FlexForm DataStructure array.
Removes all unnecessary sheet, field or value identifiers.
@param string|array $flexFormData either a converted FlexForm array or the raw FlexForm string
@return array simplified FlexForm data structure
|
[
"Simplify",
"a",
"FlexForm",
"DataStructure",
"array",
".",
"Removes",
"all",
"unnecessary",
"sheet",
"field",
"or",
"value",
"identifiers",
"."
] |
ad737068eef3b084d4d0e3a48e6a3d8277af9560
|
https://github.com/arndtteunissen/column-layout/blob/ad737068eef3b084d4d0e3a48e6a3d8277af9560/Classes/Utility/ColumnLayoutUtility.php#L99-L114
|
21,306 |
thelia-modules/CustomerGroup
|
Model/Base/CustomerGroupI18n.php
|
CustomerGroupI18n.getCustomerGroup
|
public function getCustomerGroup(ConnectionInterface $con = null)
{
if ($this->aCustomerGroup === null && ($this->id !== null)) {
$this->aCustomerGroup = ChildCustomerGroupQuery::create()->findPk($this->id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aCustomerGroup->addCustomerGroupI18ns($this);
*/
}
return $this->aCustomerGroup;
}
|
php
|
public function getCustomerGroup(ConnectionInterface $con = null)
{
if ($this->aCustomerGroup === null && ($this->id !== null)) {
$this->aCustomerGroup = ChildCustomerGroupQuery::create()->findPk($this->id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aCustomerGroup->addCustomerGroupI18ns($this);
*/
}
return $this->aCustomerGroup;
}
|
[
"public",
"function",
"getCustomerGroup",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aCustomerGroup",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"id",
"!==",
"null",
")",
")",
"{",
"$",
"this",
"->",
"aCustomerGroup",
"=",
"ChildCustomerGroupQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"id",
",",
"$",
"con",
")",
";",
"/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aCustomerGroup->addCustomerGroupI18ns($this);\n */",
"}",
"return",
"$",
"this",
"->",
"aCustomerGroup",
";",
"}"
] |
Get the associated ChildCustomerGroup object
@param ConnectionInterface $con Optional Connection object.
@return ChildCustomerGroup The associated ChildCustomerGroup object.
@throws PropelException
|
[
"Get",
"the",
"associated",
"ChildCustomerGroup",
"object"
] |
672cc64c686812f6a95cf0d702111f93d8c0e850
|
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Base/CustomerGroupI18n.php#L1148-L1162
|
21,307 |
99designs/ergo-http
|
src/Url.php
|
Url.getHostWithPort
|
public function getHostWithPort()
{
if ($this->hasPort() && (!$this->hasDefaultPort() || !$this->isPortDefault())) {
return $this->getHost() . ':' . $this->getPort();
} else {
return $this->getHost();
}
}
|
php
|
public function getHostWithPort()
{
if ($this->hasPort() && (!$this->hasDefaultPort() || !$this->isPortDefault())) {
return $this->getHost() . ':' . $this->getPort();
} else {
return $this->getHost();
}
}
|
[
"public",
"function",
"getHostWithPort",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasPort",
"(",
")",
"&&",
"(",
"!",
"$",
"this",
"->",
"hasDefaultPort",
"(",
")",
"||",
"!",
"$",
"this",
"->",
"isPortDefault",
"(",
")",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getHost",
"(",
")",
".",
"':'",
".",
"$",
"this",
"->",
"getPort",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"getHost",
"(",
")",
";",
"}",
"}"
] |
Host, including port unless it is the default port for the scheme.
@return string
|
[
"Host",
"including",
"port",
"unless",
"it",
"is",
"the",
"default",
"port",
"for",
"the",
"scheme",
"."
] |
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
|
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L89-L96
|
21,308 |
99designs/ergo-http
|
src/Url.php
|
Url.getDefaultPort
|
public function getDefaultPort()
{
if (!$this->hasDefaultPort()) throw new UrlException(sprintf(
"No default port for URL '%s'",
$this->_inputString
));
$scheme = $this->getScheme();
if ($scheme == 'http') return 80;
elseif ($scheme == 'https') return 443;
else throw new UrlException("No default port for scheme '$scheme'");
}
|
php
|
public function getDefaultPort()
{
if (!$this->hasDefaultPort()) throw new UrlException(sprintf(
"No default port for URL '%s'",
$this->_inputString
));
$scheme = $this->getScheme();
if ($scheme == 'http') return 80;
elseif ($scheme == 'https') return 443;
else throw new UrlException("No default port for scheme '$scheme'");
}
|
[
"public",
"function",
"getDefaultPort",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasDefaultPort",
"(",
")",
")",
"throw",
"new",
"UrlException",
"(",
"sprintf",
"(",
"\"No default port for URL '%s'\"",
",",
"$",
"this",
"->",
"_inputString",
")",
")",
";",
"$",
"scheme",
"=",
"$",
"this",
"->",
"getScheme",
"(",
")",
";",
"if",
"(",
"$",
"scheme",
"==",
"'http'",
")",
"return",
"80",
";",
"elseif",
"(",
"$",
"scheme",
"==",
"'https'",
")",
"return",
"443",
";",
"else",
"throw",
"new",
"UrlException",
"(",
"\"No default port for scheme '$scheme'\"",
")",
";",
"}"
] |
The default TCP port for the scheme of the URL
@return int or null
|
[
"The",
"default",
"TCP",
"port",
"for",
"the",
"scheme",
"of",
"the",
"URL"
] |
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
|
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L176-L187
|
21,309 |
99designs/ergo-http
|
src/Url.php
|
Url.getHostRelativeUrl
|
public function getHostRelativeUrl()
{
$url = $this->getPath();
if ($this->hasQueryString()) $url .= '?' . $this->getQueryString();
if ($this->hasFragmentString()) $url .= '#' . $this->getFragmentString();
return $url;
}
|
php
|
public function getHostRelativeUrl()
{
$url = $this->getPath();
if ($this->hasQueryString()) $url .= '?' . $this->getQueryString();
if ($this->hasFragmentString()) $url .= '#' . $this->getFragmentString();
return $url;
}
|
[
"public",
"function",
"getHostRelativeUrl",
"(",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasQueryString",
"(",
")",
")",
"$",
"url",
".=",
"'?'",
".",
"$",
"this",
"->",
"getQueryString",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasFragmentString",
"(",
")",
")",
"$",
"url",
".=",
"'#'",
".",
"$",
"this",
"->",
"getFragmentString",
"(",
")",
";",
"return",
"$",
"url",
";",
"}"
] |
The URL components after the host.
@return string
|
[
"The",
"URL",
"components",
"after",
"the",
"host",
"."
] |
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
|
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L210-L216
|
21,310 |
99designs/ergo-http
|
src/Url.php
|
Url.getUrlForPath
|
public function getUrlForPath($path)
{
$fragments = parse_url($path);
if (!isset($fragments['path']))
throw new UrlException("URL is not a valid path: '$path'");
$newUrl = clone $this;
$newUrl->_fragments['path'] = $fragments['path'];
// overwrite RHS components
foreach (array('query', 'fragment') as $component) {
if (isset($fragments[$component]))
$newUrl->_fragments[$component] = $fragments[$component];
elseif (isset($newUrl->_fragments[$component]))
unset($newUrl->_fragments[$component]);
}
// store the new URL internally
$newUrl->_inputString = $newUrl->__toString();
return $newUrl;
}
|
php
|
public function getUrlForPath($path)
{
$fragments = parse_url($path);
if (!isset($fragments['path']))
throw new UrlException("URL is not a valid path: '$path'");
$newUrl = clone $this;
$newUrl->_fragments['path'] = $fragments['path'];
// overwrite RHS components
foreach (array('query', 'fragment') as $component) {
if (isset($fragments[$component]))
$newUrl->_fragments[$component] = $fragments[$component];
elseif (isset($newUrl->_fragments[$component]))
unset($newUrl->_fragments[$component]);
}
// store the new URL internally
$newUrl->_inputString = $newUrl->__toString();
return $newUrl;
}
|
[
"public",
"function",
"getUrlForPath",
"(",
"$",
"path",
")",
"{",
"$",
"fragments",
"=",
"parse_url",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"fragments",
"[",
"'path'",
"]",
")",
")",
"throw",
"new",
"UrlException",
"(",
"\"URL is not a valid path: '$path'\"",
")",
";",
"$",
"newUrl",
"=",
"clone",
"$",
"this",
";",
"$",
"newUrl",
"->",
"_fragments",
"[",
"'path'",
"]",
"=",
"$",
"fragments",
"[",
"'path'",
"]",
";",
"// overwrite RHS components",
"foreach",
"(",
"array",
"(",
"'query'",
",",
"'fragment'",
")",
"as",
"$",
"component",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"fragments",
"[",
"$",
"component",
"]",
")",
")",
"$",
"newUrl",
"->",
"_fragments",
"[",
"$",
"component",
"]",
"=",
"$",
"fragments",
"[",
"$",
"component",
"]",
";",
"elseif",
"(",
"isset",
"(",
"$",
"newUrl",
"->",
"_fragments",
"[",
"$",
"component",
"]",
")",
")",
"unset",
"(",
"$",
"newUrl",
"->",
"_fragments",
"[",
"$",
"component",
"]",
")",
";",
"}",
"// store the new URL internally",
"$",
"newUrl",
"->",
"_inputString",
"=",
"$",
"newUrl",
"->",
"__toString",
"(",
")",
";",
"return",
"$",
"newUrl",
";",
"}"
] |
Builds a URL with a different path component
@return Url
|
[
"Builds",
"a",
"URL",
"with",
"a",
"different",
"path",
"component"
] |
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
|
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L235-L257
|
21,311 |
99designs/ergo-http
|
src/Url.php
|
Url.getUrlForHost
|
public function getUrlForHost($host)
{
$newUrl = clone $this;
$newUrl->_fragments['host'] = $host;
$newUrl->_inputString = $newUrl->__toString();
return $newUrl;
}
|
php
|
public function getUrlForHost($host)
{
$newUrl = clone $this;
$newUrl->_fragments['host'] = $host;
$newUrl->_inputString = $newUrl->__toString();
return $newUrl;
}
|
[
"public",
"function",
"getUrlForHost",
"(",
"$",
"host",
")",
"{",
"$",
"newUrl",
"=",
"clone",
"$",
"this",
";",
"$",
"newUrl",
"->",
"_fragments",
"[",
"'host'",
"]",
"=",
"$",
"host",
";",
"$",
"newUrl",
"->",
"_inputString",
"=",
"$",
"newUrl",
"->",
"__toString",
"(",
")",
";",
"return",
"$",
"newUrl",
";",
"}"
] |
Builds a URL with a different host
@return Url
|
[
"Builds",
"a",
"URL",
"with",
"a",
"different",
"host"
] |
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
|
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L263-L270
|
21,312 |
99designs/ergo-http
|
src/Url.php
|
Url.getUrlForScheme
|
public function getUrlForScheme($scheme)
{
$newUrl = clone $this;
$wasDefaultPort = ($newUrl->hasScheme() && $newUrl->isPortDefault());
$newUrl->_fragments['scheme'] = $scheme;
if ($wasDefaultPort) {
$newUrl->_fragments['port'] = $newUrl->getDefaultPort();
}
$newUrl->_inputString = $newUrl->__toString();
return $newUrl;
}
|
php
|
public function getUrlForScheme($scheme)
{
$newUrl = clone $this;
$wasDefaultPort = ($newUrl->hasScheme() && $newUrl->isPortDefault());
$newUrl->_fragments['scheme'] = $scheme;
if ($wasDefaultPort) {
$newUrl->_fragments['port'] = $newUrl->getDefaultPort();
}
$newUrl->_inputString = $newUrl->__toString();
return $newUrl;
}
|
[
"public",
"function",
"getUrlForScheme",
"(",
"$",
"scheme",
")",
"{",
"$",
"newUrl",
"=",
"clone",
"$",
"this",
";",
"$",
"wasDefaultPort",
"=",
"(",
"$",
"newUrl",
"->",
"hasScheme",
"(",
")",
"&&",
"$",
"newUrl",
"->",
"isPortDefault",
"(",
")",
")",
";",
"$",
"newUrl",
"->",
"_fragments",
"[",
"'scheme'",
"]",
"=",
"$",
"scheme",
";",
"if",
"(",
"$",
"wasDefaultPort",
")",
"{",
"$",
"newUrl",
"->",
"_fragments",
"[",
"'port'",
"]",
"=",
"$",
"newUrl",
"->",
"getDefaultPort",
"(",
")",
";",
"}",
"$",
"newUrl",
"->",
"_inputString",
"=",
"$",
"newUrl",
"->",
"__toString",
"(",
")",
";",
"return",
"$",
"newUrl",
";",
"}"
] |
Builds a URL with a different scheme
@return Url
|
[
"Builds",
"a",
"URL",
"with",
"a",
"different",
"scheme"
] |
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
|
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L276-L290
|
21,313 |
99designs/ergo-http
|
src/Url.php
|
Url.getUrlForRelativePath
|
public function getUrlForRelativePath($path)
{
return $this->getUrlForPath(
$this->_joinPathComponents($this->getPath(), ltrim($path, '/')));
}
|
php
|
public function getUrlForRelativePath($path)
{
return $this->getUrlForPath(
$this->_joinPathComponents($this->getPath(), ltrim($path, '/')));
}
|
[
"public",
"function",
"getUrlForRelativePath",
"(",
"$",
"path",
")",
"{",
"return",
"$",
"this",
"->",
"getUrlForPath",
"(",
"$",
"this",
"->",
"_joinPathComponents",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"ltrim",
"(",
"$",
"path",
",",
"'/'",
")",
")",
")",
";",
"}"
] |
Builds a URL with a path component that is relative to the current one
@return Url
|
[
"Builds",
"a",
"URL",
"with",
"a",
"path",
"component",
"that",
"is",
"relative",
"to",
"the",
"current",
"one"
] |
979b789f2e011a1cb70a00161e6b7bcd0d2e9c71
|
https://github.com/99designs/ergo-http/blob/979b789f2e011a1cb70a00161e6b7bcd0d2e9c71/src/Url.php#L327-L331
|
21,314 |
DotZecker/Larafeed
|
src/Larafeed.php
|
Larafeed.addAuthor
|
public function addAuthor($author)
{
if (!is_array($author)) {
$author = ['name' => $author];
}
$this->authors->add((object) $author);
}
|
php
|
public function addAuthor($author)
{
if (!is_array($author)) {
$author = ['name' => $author];
}
$this->authors->add((object) $author);
}
|
[
"public",
"function",
"addAuthor",
"(",
"$",
"author",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"author",
")",
")",
"{",
"$",
"author",
"=",
"[",
"'name'",
"=>",
"$",
"author",
"]",
";",
"}",
"$",
"this",
"->",
"authors",
"->",
"add",
"(",
"(",
"object",
")",
"$",
"author",
")",
";",
"}"
] |
Add an Author to the feed
@param mixed $author It can be an array with name, email and uri,
or just and string with the name.
|
[
"Add",
"an",
"Author",
"to",
"the",
"feed"
] |
d696e2f97b584ed690fe7ba4ac5d739e266c75dd
|
https://github.com/DotZecker/Larafeed/blob/d696e2f97b584ed690fe7ba4ac5d739e266c75dd/src/Larafeed.php#L108-L115
|
21,315 |
DotZecker/Larafeed
|
src/Larafeed.php
|
Larafeed.render
|
public function render()
{
$this->prepare();
$view = $this->twig->render(sprintf('%s.twig.html', $this->format), ['feed' => $this]);
return Response::create(
$view,
200,
[
'Content-Type' => "{$this->getContentType()}; charset={$this->charset}",
]
);
}
|
php
|
public function render()
{
$this->prepare();
$view = $this->twig->render(sprintf('%s.twig.html', $this->format), ['feed' => $this]);
return Response::create(
$view,
200,
[
'Content-Type' => "{$this->getContentType()}; charset={$this->charset}",
]
);
}
|
[
"public",
"function",
"render",
"(",
")",
"{",
"$",
"this",
"->",
"prepare",
"(",
")",
";",
"$",
"view",
"=",
"$",
"this",
"->",
"twig",
"->",
"render",
"(",
"sprintf",
"(",
"'%s.twig.html'",
",",
"$",
"this",
"->",
"format",
")",
",",
"[",
"'feed'",
"=>",
"$",
"this",
"]",
")",
";",
"return",
"Response",
"::",
"create",
"(",
"$",
"view",
",",
"200",
",",
"[",
"'Content-Type'",
"=>",
"\"{$this->getContentType()}; charset={$this->charset}\"",
",",
"]",
")",
";",
"}"
] |
Prepare the feed and if it's valid, renders it
@return Response
|
[
"Prepare",
"the",
"feed",
"and",
"if",
"it",
"s",
"valid",
"renders",
"it"
] |
d696e2f97b584ed690fe7ba4ac5d739e266c75dd
|
https://github.com/DotZecker/Larafeed/blob/d696e2f97b584ed690fe7ba4ac5d739e266c75dd/src/Larafeed.php#L122-L135
|
21,316 |
surebert/surebert-framework
|
src/sb/Excel/Writer.php
|
Writer.setCell
|
public function setCell($cell, $value, $type = "auto")
{
if ($type == "auto") {
$type = \gettype($value);
}
if (\is_array($cell)) {
$parts["row"] = $cell[0];
$parts["col"] = $cell[1];
} else {
$parts = $this->refToArray($cell);
}
if (!\is_array($parts)) {
\trigger_error("Cell reference should be in the format A1 or array(0,0).", E_USER_ERROR);
return false;
}
$row = $parts["row"];
$col = $parts["col"];
switch ($type) {
case "string" :
/**
* @todo it would be nice if we were able to keep that
* characters UTF-8 or unicode
*/
$value = \mb_convert_encoding($value, "Windows-1252", "UTF-8");
$length = \mb_strlen($value, "Windows-1252");
if ($length > 255) {
\trigger_error("String '$value' is too long. "
."Please keep to a max of 255 characters.",
E_USER_ERROR);
return false;
}
$this->contents .= \pack("s*", 0x0204, 8 + $length, $row, $col, 0x00, $length);
$this->contents .= $value;
break;
case "integer" :
$this->contents .= \pack("s*", 0x0203, 14, $row, $col, 0x00);
$this->contents .= \pack("d", $value);
break;
}
return true;
}
|
php
|
public function setCell($cell, $value, $type = "auto")
{
if ($type == "auto") {
$type = \gettype($value);
}
if (\is_array($cell)) {
$parts["row"] = $cell[0];
$parts["col"] = $cell[1];
} else {
$parts = $this->refToArray($cell);
}
if (!\is_array($parts)) {
\trigger_error("Cell reference should be in the format A1 or array(0,0).", E_USER_ERROR);
return false;
}
$row = $parts["row"];
$col = $parts["col"];
switch ($type) {
case "string" :
/**
* @todo it would be nice if we were able to keep that
* characters UTF-8 or unicode
*/
$value = \mb_convert_encoding($value, "Windows-1252", "UTF-8");
$length = \mb_strlen($value, "Windows-1252");
if ($length > 255) {
\trigger_error("String '$value' is too long. "
."Please keep to a max of 255 characters.",
E_USER_ERROR);
return false;
}
$this->contents .= \pack("s*", 0x0204, 8 + $length, $row, $col, 0x00, $length);
$this->contents .= $value;
break;
case "integer" :
$this->contents .= \pack("s*", 0x0203, 14, $row, $col, 0x00);
$this->contents .= \pack("d", $value);
break;
}
return true;
}
|
[
"public",
"function",
"setCell",
"(",
"$",
"cell",
",",
"$",
"value",
",",
"$",
"type",
"=",
"\"auto\"",
")",
"{",
"if",
"(",
"$",
"type",
"==",
"\"auto\"",
")",
"{",
"$",
"type",
"=",
"\\",
"gettype",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"cell",
")",
")",
"{",
"$",
"parts",
"[",
"\"row\"",
"]",
"=",
"$",
"cell",
"[",
"0",
"]",
";",
"$",
"parts",
"[",
"\"col\"",
"]",
"=",
"$",
"cell",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"parts",
"=",
"$",
"this",
"->",
"refToArray",
"(",
"$",
"cell",
")",
";",
"}",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"parts",
")",
")",
"{",
"\\",
"trigger_error",
"(",
"\"Cell reference should be in the format A1 or array(0,0).\"",
",",
"E_USER_ERROR",
")",
";",
"return",
"false",
";",
"}",
"$",
"row",
"=",
"$",
"parts",
"[",
"\"row\"",
"]",
";",
"$",
"col",
"=",
"$",
"parts",
"[",
"\"col\"",
"]",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"\"string\"",
":",
"/**\n * @todo it would be nice if we were able to keep that\n * characters UTF-8 or unicode\n */",
"$",
"value",
"=",
"\\",
"mb_convert_encoding",
"(",
"$",
"value",
",",
"\"Windows-1252\"",
",",
"\"UTF-8\"",
")",
";",
"$",
"length",
"=",
"\\",
"mb_strlen",
"(",
"$",
"value",
",",
"\"Windows-1252\"",
")",
";",
"if",
"(",
"$",
"length",
">",
"255",
")",
"{",
"\\",
"trigger_error",
"(",
"\"String '$value' is too long. \"",
".",
"\"Please keep to a max of 255 characters.\"",
",",
"E_USER_ERROR",
")",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"contents",
".=",
"\\",
"pack",
"(",
"\"s*\"",
",",
"0x0204",
",",
"8",
"+",
"$",
"length",
",",
"$",
"row",
",",
"$",
"col",
",",
"0x00",
",",
"$",
"length",
")",
";",
"$",
"this",
"->",
"contents",
".=",
"$",
"value",
";",
"break",
";",
"case",
"\"integer\"",
":",
"$",
"this",
"->",
"contents",
".=",
"\\",
"pack",
"(",
"\"s*\"",
",",
"0x0203",
",",
"14",
",",
"$",
"row",
",",
"$",
"col",
",",
"0x00",
")",
";",
"$",
"this",
"->",
"contents",
".=",
"\\",
"pack",
"(",
"\"d\"",
",",
"$",
"value",
")",
";",
"break",
";",
"}",
"return",
"true",
";",
"}"
] |
Set the value of an individual cell
@param mixed An excel cell reference such as A1, or an array in the
format of ($row, $col) usign zero-based integers
@param mixed the value to put in this cell
@param the type of value (string|integer). Autodetects by default
@return boolean Success
|
[
"Set",
"the",
"value",
"of",
"an",
"individual",
"cell"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Writer.php#L60-L111
|
21,317 |
surebert/surebert-framework
|
src/sb/Excel/Writer.php
|
Writer.setRow
|
public function setRow($row, $values)
{
if (!\is_array($values)) {
\trigger_error("Values must be an array.", E_USER_ERROR);
return false;
}
if (intval($row) < 1) {
\trigger_error("Row number must be an integer greater than 1.", E_USER_ERROR);
return false;
}
$i = 0;
foreach ($values as $value) {
$this->setCell(array($row - 1, $i), $value);
$i++;
}
return true;
}
|
php
|
public function setRow($row, $values)
{
if (!\is_array($values)) {
\trigger_error("Values must be an array.", E_USER_ERROR);
return false;
}
if (intval($row) < 1) {
\trigger_error("Row number must be an integer greater than 1.", E_USER_ERROR);
return false;
}
$i = 0;
foreach ($values as $value) {
$this->setCell(array($row - 1, $i), $value);
$i++;
}
return true;
}
|
[
"public",
"function",
"setRow",
"(",
"$",
"row",
",",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"values",
")",
")",
"{",
"\\",
"trigger_error",
"(",
"\"Values must be an array.\"",
",",
"E_USER_ERROR",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"intval",
"(",
"$",
"row",
")",
"<",
"1",
")",
"{",
"\\",
"trigger_error",
"(",
"\"Row number must be an integer greater than 1.\"",
",",
"E_USER_ERROR",
")",
";",
"return",
"false",
";",
"}",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"setCell",
"(",
"array",
"(",
"$",
"row",
"-",
"1",
",",
"$",
"i",
")",
",",
"$",
"value",
")",
";",
"$",
"i",
"++",
";",
"}",
"return",
"true",
";",
"}"
] |
Set the values for a row
@param integer The Excel row number to place these values
@param array An array of values
@return boolean Success
|
[
"Set",
"the",
"values",
"for",
"a",
"row"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Writer.php#L120-L139
|
21,318 |
surebert/surebert-framework
|
src/sb/Excel/Writer.php
|
Writer.outputWithHeaders
|
public function outputWithHeaders($filename = 'output.xls')
{
\header("Expires: " . date("r", 0));
\header("Last-Modified: " . gmdate("r") . " GMT");
\header("Content-Type: application/x-msexcel");
\header("Content-Disposition: attachment; filename=" . $filename);
echo $this->__toString();
}
|
php
|
public function outputWithHeaders($filename = 'output.xls')
{
\header("Expires: " . date("r", 0));
\header("Last-Modified: " . gmdate("r") . " GMT");
\header("Content-Type: application/x-msexcel");
\header("Content-Disposition: attachment; filename=" . $filename);
echo $this->__toString();
}
|
[
"public",
"function",
"outputWithHeaders",
"(",
"$",
"filename",
"=",
"'output.xls'",
")",
"{",
"\\",
"header",
"(",
"\"Expires: \"",
".",
"date",
"(",
"\"r\"",
",",
"0",
")",
")",
";",
"\\",
"header",
"(",
"\"Last-Modified: \"",
".",
"gmdate",
"(",
"\"r\"",
")",
".",
"\" GMT\"",
")",
";",
"\\",
"header",
"(",
"\"Content-Type: application/x-msexcel\"",
")",
";",
"\\",
"header",
"(",
"\"Content-Disposition: attachment; filename=\"",
".",
"$",
"filename",
")",
";",
"echo",
"$",
"this",
"->",
"__toString",
"(",
")",
";",
"}"
] |
Stream this file over HTTP
@return void
|
[
"Stream",
"this",
"file",
"over",
"HTTP"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Excel/Writer.php#L174-L181
|
21,319 |
romainbessugesmeusy/php-datagrid
|
library/RBM/Datagrid/Data/Processor/ArrayProcessor.php
|
ArrayProcessor._sort
|
protected function _sort()
{
if (!isset($this->_sorts) || count($this->_sorts) === 0) {
return;
}
$columns = $this->_dataGrid->getActiveColumnsOrdered();
$sorts = $this->_sorts;
$sortPosition = $this->_sortPositions;
usort($this->_output, function ($a, $b) use ($columns, $sortPosition, $sorts) {
foreach ($sortPosition as $colIndex) {
$sort = $sorts[$colIndex];
/** @var $sort\RBM\Datagrid\Data\Sort */
/** @var $column\RBM\Datagrid\Column */
$column = $columns[$colIndex];
$valueA = $column->getSortData($a);
$valueB = $column->getSortData($b);
if ($valueA == $valueB) {
continue;
}
$arr = array($valueA, $valueB);
$args = array_merge(array(&$arr), array($sort->getDirection(), $sort->getType()));
call_user_func_array('array_multisort', $args);
return ($arr[0] == $valueA) ? -1 : 1;
}
return 0;
});
}
|
php
|
protected function _sort()
{
if (!isset($this->_sorts) || count($this->_sorts) === 0) {
return;
}
$columns = $this->_dataGrid->getActiveColumnsOrdered();
$sorts = $this->_sorts;
$sortPosition = $this->_sortPositions;
usort($this->_output, function ($a, $b) use ($columns, $sortPosition, $sorts) {
foreach ($sortPosition as $colIndex) {
$sort = $sorts[$colIndex];
/** @var $sort\RBM\Datagrid\Data\Sort */
/** @var $column\RBM\Datagrid\Column */
$column = $columns[$colIndex];
$valueA = $column->getSortData($a);
$valueB = $column->getSortData($b);
if ($valueA == $valueB) {
continue;
}
$arr = array($valueA, $valueB);
$args = array_merge(array(&$arr), array($sort->getDirection(), $sort->getType()));
call_user_func_array('array_multisort', $args);
return ($arr[0] == $valueA) ? -1 : 1;
}
return 0;
});
}
|
[
"protected",
"function",
"_sort",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_sorts",
")",
"||",
"count",
"(",
"$",
"this",
"->",
"_sorts",
")",
"===",
"0",
")",
"{",
"return",
";",
"}",
"$",
"columns",
"=",
"$",
"this",
"->",
"_dataGrid",
"->",
"getActiveColumnsOrdered",
"(",
")",
";",
"$",
"sorts",
"=",
"$",
"this",
"->",
"_sorts",
";",
"$",
"sortPosition",
"=",
"$",
"this",
"->",
"_sortPositions",
";",
"usort",
"(",
"$",
"this",
"->",
"_output",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"use",
"(",
"$",
"columns",
",",
"$",
"sortPosition",
",",
"$",
"sorts",
")",
"{",
"foreach",
"(",
"$",
"sortPosition",
"as",
"$",
"colIndex",
")",
"{",
"$",
"sort",
"=",
"$",
"sorts",
"[",
"$",
"colIndex",
"]",
";",
"/** @var $sort\\RBM\\Datagrid\\Data\\Sort */",
"/** @var $column\\RBM\\Datagrid\\Column */",
"$",
"column",
"=",
"$",
"columns",
"[",
"$",
"colIndex",
"]",
";",
"$",
"valueA",
"=",
"$",
"column",
"->",
"getSortData",
"(",
"$",
"a",
")",
";",
"$",
"valueB",
"=",
"$",
"column",
"->",
"getSortData",
"(",
"$",
"b",
")",
";",
"if",
"(",
"$",
"valueA",
"==",
"$",
"valueB",
")",
"{",
"continue",
";",
"}",
"$",
"arr",
"=",
"array",
"(",
"$",
"valueA",
",",
"$",
"valueB",
")",
";",
"$",
"args",
"=",
"array_merge",
"(",
"array",
"(",
"&",
"$",
"arr",
")",
",",
"array",
"(",
"$",
"sort",
"->",
"getDirection",
"(",
")",
",",
"$",
"sort",
"->",
"getType",
"(",
")",
")",
")",
";",
"call_user_func_array",
"(",
"'array_multisort'",
",",
"$",
"args",
")",
";",
"return",
"(",
"$",
"arr",
"[",
"0",
"]",
"==",
"$",
"valueA",
")",
"?",
"-",
"1",
":",
"1",
";",
"}",
"return",
"0",
";",
"}",
")",
";",
"}"
] |
Performs an array_multisort, based on the sorts defined
|
[
"Performs",
"an",
"array_multisort",
"based",
"on",
"the",
"sorts",
"defined"
] |
18f7ae15845fcf61520bbfc946771242bf1091c9
|
https://github.com/romainbessugesmeusy/php-datagrid/blob/18f7ae15845fcf61520bbfc946771242bf1091c9/library/RBM/Datagrid/Data/Processor/ArrayProcessor.php#L72-L104
|
21,320 |
romainbessugesmeusy/php-datagrid
|
library/RBM/Datagrid/Data/Processor/ArrayProcessor.php
|
ArrayProcessor._truncate
|
protected function _truncate()
{
if (!$this->getLimit()->isNull()) {
if (is_null($this->getLimit()->getCount())) {
$this->_output = array_splice($this->_output, $this->getLimit()->getStart());
} else {
$this->_output = array_splice($this->_output, $this->getLimit()->getStart(), $this->getLimit()->getCount());
}
}
}
|
php
|
protected function _truncate()
{
if (!$this->getLimit()->isNull()) {
if (is_null($this->getLimit()->getCount())) {
$this->_output = array_splice($this->_output, $this->getLimit()->getStart());
} else {
$this->_output = array_splice($this->_output, $this->getLimit()->getStart(), $this->getLimit()->getCount());
}
}
}
|
[
"protected",
"function",
"_truncate",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getLimit",
"(",
")",
"->",
"isNull",
"(",
")",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"getLimit",
"(",
")",
"->",
"getCount",
"(",
")",
")",
")",
"{",
"$",
"this",
"->",
"_output",
"=",
"array_splice",
"(",
"$",
"this",
"->",
"_output",
",",
"$",
"this",
"->",
"getLimit",
"(",
")",
"->",
"getStart",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_output",
"=",
"array_splice",
"(",
"$",
"this",
"->",
"_output",
",",
"$",
"this",
"->",
"getLimit",
"(",
")",
"->",
"getStart",
"(",
")",
",",
"$",
"this",
"->",
"getLimit",
"(",
")",
"->",
"getCount",
"(",
")",
")",
";",
"}",
"}",
"}"
] |
Simply splice the array
|
[
"Simply",
"splice",
"the",
"array"
] |
18f7ae15845fcf61520bbfc946771242bf1091c9
|
https://github.com/romainbessugesmeusy/php-datagrid/blob/18f7ae15845fcf61520bbfc946771242bf1091c9/library/RBM/Datagrid/Data/Processor/ArrayProcessor.php#L109-L118
|
21,321 |
ekuiter/feature-php
|
FeaturePhp/Model/ConstraintSolver.php
|
ConstraintSolver.mandatory
|
private static function mandatory($feature) {
if ($feature->getParent() && $feature->getMandatory())
return Logic::equiv(Logic::is($feature), Logic::is($feature->getParent()));
}
|
php
|
private static function mandatory($feature) {
if ($feature->getParent() && $feature->getMandatory())
return Logic::equiv(Logic::is($feature), Logic::is($feature->getParent()));
}
|
[
"private",
"static",
"function",
"mandatory",
"(",
"$",
"feature",
")",
"{",
"if",
"(",
"$",
"feature",
"->",
"getParent",
"(",
")",
"&&",
"$",
"feature",
"->",
"getMandatory",
"(",
")",
")",
"return",
"Logic",
"::",
"equiv",
"(",
"Logic",
"::",
"is",
"(",
"$",
"feature",
")",
",",
"Logic",
"::",
"is",
"(",
"$",
"feature",
"->",
"getParent",
"(",
")",
")",
")",
";",
"}"
] |
Semantics for a mandatory feature.
A mandatory feature is selected iff its parent is selected.
@param Feature $feature
@return callable
|
[
"Semantics",
"for",
"a",
"mandatory",
"feature",
".",
"A",
"mandatory",
"feature",
"is",
"selected",
"iff",
"its",
"parent",
"is",
"selected",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/ConstraintSolver.php#L117-L120
|
21,322 |
ekuiter/feature-php
|
FeaturePhp/Model/ConstraintSolver.php
|
ConstraintSolver.optional
|
private static function optional($feature) {
if ($feature->getParent())
return Logic::implies(Logic::is($feature), Logic::is($feature->getParent()));
}
|
php
|
private static function optional($feature) {
if ($feature->getParent())
return Logic::implies(Logic::is($feature), Logic::is($feature->getParent()));
}
|
[
"private",
"static",
"function",
"optional",
"(",
"$",
"feature",
")",
"{",
"if",
"(",
"$",
"feature",
"->",
"getParent",
"(",
")",
")",
"return",
"Logic",
"::",
"implies",
"(",
"Logic",
"::",
"is",
"(",
"$",
"feature",
")",
",",
"Logic",
"::",
"is",
"(",
"$",
"feature",
"->",
"getParent",
"(",
")",
")",
")",
";",
"}"
] |
Semantics for an optional feature.
If an optional feature is selected, its parent is selected.
@param Feature $feature
@return callable
|
[
"Semantics",
"for",
"an",
"optional",
"feature",
".",
"If",
"an",
"optional",
"feature",
"is",
"selected",
"its",
"parent",
"is",
"selected",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/ConstraintSolver.php#L128-L131
|
21,323 |
ekuiter/feature-php
|
FeaturePhp/Model/ConstraintSolver.php
|
ConstraintSolver.alternative
|
private static function alternative($feature) {
if ($feature->getAlternative()) {
$children = array();
foreach ($feature->getChildren() as $child)
$children[] = Logic::is($child);
$alternativeConstraints = array();
for ($i = 0; $i < count($children); $i++)
for ($j = 0; $j < $i; $j++)
$alternativeConstraints[] = Logic::not(Logic::_and($children[$i], $children[$j]));
return Logic::_and(Logic::equiv(Logic::is($feature),
call_user_func_array("\FeaturePhp\Helper\Logic::_or", $children)),
call_user_func_array("\FeaturePhp\Helper\Logic::_and", $alternativeConstraints));
}
}
|
php
|
private static function alternative($feature) {
if ($feature->getAlternative()) {
$children = array();
foreach ($feature->getChildren() as $child)
$children[] = Logic::is($child);
$alternativeConstraints = array();
for ($i = 0; $i < count($children); $i++)
for ($j = 0; $j < $i; $j++)
$alternativeConstraints[] = Logic::not(Logic::_and($children[$i], $children[$j]));
return Logic::_and(Logic::equiv(Logic::is($feature),
call_user_func_array("\FeaturePhp\Helper\Logic::_or", $children)),
call_user_func_array("\FeaturePhp\Helper\Logic::_and", $alternativeConstraints));
}
}
|
[
"private",
"static",
"function",
"alternative",
"(",
"$",
"feature",
")",
"{",
"if",
"(",
"$",
"feature",
"->",
"getAlternative",
"(",
")",
")",
"{",
"$",
"children",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"feature",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"$",
"children",
"[",
"]",
"=",
"Logic",
"::",
"is",
"(",
"$",
"child",
")",
";",
"$",
"alternativeConstraints",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"children",
")",
";",
"$",
"i",
"++",
")",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"$",
"i",
";",
"$",
"j",
"++",
")",
"$",
"alternativeConstraints",
"[",
"]",
"=",
"Logic",
"::",
"not",
"(",
"Logic",
"::",
"_and",
"(",
"$",
"children",
"[",
"$",
"i",
"]",
",",
"$",
"children",
"[",
"$",
"j",
"]",
")",
")",
";",
"return",
"Logic",
"::",
"_and",
"(",
"Logic",
"::",
"equiv",
"(",
"Logic",
"::",
"is",
"(",
"$",
"feature",
")",
",",
"call_user_func_array",
"(",
"\"\\FeaturePhp\\Helper\\Logic::_or\"",
",",
"$",
"children",
")",
")",
",",
"call_user_func_array",
"(",
"\"\\FeaturePhp\\Helper\\Logic::_and\"",
",",
"$",
"alternativeConstraints",
")",
")",
";",
"}",
"}"
] |
Semantics for a feature that provides an alternative choice.
Exactly one child of such a feature is selected.
@param Feature $feature
@return callable
|
[
"Semantics",
"for",
"a",
"feature",
"that",
"provides",
"an",
"alternative",
"choice",
".",
"Exactly",
"one",
"child",
"of",
"such",
"a",
"feature",
"is",
"selected",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/ConstraintSolver.php#L139-L154
|
21,324 |
ekuiter/feature-php
|
FeaturePhp/Model/ConstraintSolver.php
|
ConstraintSolver._or
|
private static function _or($feature) {
if ($feature->getOr()) {
$children = array();
foreach ($feature->getChildren() as $child)
$children[] = Logic::is($child);
return Logic::equiv(Logic::is($feature),
call_user_func_array("\FeaturePhp\Helper\Logic::_or", $children));
}
}
|
php
|
private static function _or($feature) {
if ($feature->getOr()) {
$children = array();
foreach ($feature->getChildren() as $child)
$children[] = Logic::is($child);
return Logic::equiv(Logic::is($feature),
call_user_func_array("\FeaturePhp\Helper\Logic::_or", $children));
}
}
|
[
"private",
"static",
"function",
"_or",
"(",
"$",
"feature",
")",
"{",
"if",
"(",
"$",
"feature",
"->",
"getOr",
"(",
")",
")",
"{",
"$",
"children",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"feature",
"->",
"getChildren",
"(",
")",
"as",
"$",
"child",
")",
"$",
"children",
"[",
"]",
"=",
"Logic",
"::",
"is",
"(",
"$",
"child",
")",
";",
"return",
"Logic",
"::",
"equiv",
"(",
"Logic",
"::",
"is",
"(",
"$",
"feature",
")",
",",
"call_user_func_array",
"(",
"\"\\FeaturePhp\\Helper\\Logic::_or\"",
",",
"$",
"children",
")",
")",
";",
"}",
"}"
] |
Semantics for a feature that provides a choice using an inclusive or.
At least one child of such a feature is selected.
@param Feature $feature
@return callable
|
[
"Semantics",
"for",
"a",
"feature",
"that",
"provides",
"a",
"choice",
"using",
"an",
"inclusive",
"or",
".",
"At",
"least",
"one",
"child",
"of",
"such",
"a",
"feature",
"is",
"selected",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/ConstraintSolver.php#L162-L170
|
21,325 |
ekuiter/feature-php
|
FeaturePhp/Model/ConstraintSolver.php
|
ConstraintSolver.crossTreeConstraint
|
private function crossTreeConstraint($rule) {
$op = $rule->getName();
$num = $rule->count();
if ($op === "eq" && $num === 2)
return Logic::equiv($this->crossTreeConstraint($rule->children()[0]),
$this->crossTreeConstraint($rule->children()[1]));
if ($op === "imp" && $num === 2)
return Logic::implies($this->crossTreeConstraint($rule->children()[0]),
$this->crossTreeConstraint($rule->children()[1]));
if ($op === "conj" && $num === 2)
return Logic::_and($this->crossTreeConstraint($rule->children()[0]),
$this->crossTreeConstraint($rule->children()[1]));
if ($op === "disj" && $num === 2)
return Logic::_or($this->crossTreeConstraint($rule->children()[0]),
$this->crossTreeConstraint($rule->children()[1]));
if ($op === "not" && $num === 1)
return Logic::not($this->crossTreeConstraint($rule->children()[0]));
if ($op === "var" && $num === 0)
return Logic::is($this->model->getFeature((string) $rule));
throw new ConstraintSolverException("unknown operation $op with $num arguments encountered");
}
|
php
|
private function crossTreeConstraint($rule) {
$op = $rule->getName();
$num = $rule->count();
if ($op === "eq" && $num === 2)
return Logic::equiv($this->crossTreeConstraint($rule->children()[0]),
$this->crossTreeConstraint($rule->children()[1]));
if ($op === "imp" && $num === 2)
return Logic::implies($this->crossTreeConstraint($rule->children()[0]),
$this->crossTreeConstraint($rule->children()[1]));
if ($op === "conj" && $num === 2)
return Logic::_and($this->crossTreeConstraint($rule->children()[0]),
$this->crossTreeConstraint($rule->children()[1]));
if ($op === "disj" && $num === 2)
return Logic::_or($this->crossTreeConstraint($rule->children()[0]),
$this->crossTreeConstraint($rule->children()[1]));
if ($op === "not" && $num === 1)
return Logic::not($this->crossTreeConstraint($rule->children()[0]));
if ($op === "var" && $num === 0)
return Logic::is($this->model->getFeature((string) $rule));
throw new ConstraintSolverException("unknown operation $op with $num arguments encountered");
}
|
[
"private",
"function",
"crossTreeConstraint",
"(",
"$",
"rule",
")",
"{",
"$",
"op",
"=",
"$",
"rule",
"->",
"getName",
"(",
")",
";",
"$",
"num",
"=",
"$",
"rule",
"->",
"count",
"(",
")",
";",
"if",
"(",
"$",
"op",
"===",
"\"eq\"",
"&&",
"$",
"num",
"===",
"2",
")",
"return",
"Logic",
"::",
"equiv",
"(",
"$",
"this",
"->",
"crossTreeConstraint",
"(",
"$",
"rule",
"->",
"children",
"(",
")",
"[",
"0",
"]",
")",
",",
"$",
"this",
"->",
"crossTreeConstraint",
"(",
"$",
"rule",
"->",
"children",
"(",
")",
"[",
"1",
"]",
")",
")",
";",
"if",
"(",
"$",
"op",
"===",
"\"imp\"",
"&&",
"$",
"num",
"===",
"2",
")",
"return",
"Logic",
"::",
"implies",
"(",
"$",
"this",
"->",
"crossTreeConstraint",
"(",
"$",
"rule",
"->",
"children",
"(",
")",
"[",
"0",
"]",
")",
",",
"$",
"this",
"->",
"crossTreeConstraint",
"(",
"$",
"rule",
"->",
"children",
"(",
")",
"[",
"1",
"]",
")",
")",
";",
"if",
"(",
"$",
"op",
"===",
"\"conj\"",
"&&",
"$",
"num",
"===",
"2",
")",
"return",
"Logic",
"::",
"_and",
"(",
"$",
"this",
"->",
"crossTreeConstraint",
"(",
"$",
"rule",
"->",
"children",
"(",
")",
"[",
"0",
"]",
")",
",",
"$",
"this",
"->",
"crossTreeConstraint",
"(",
"$",
"rule",
"->",
"children",
"(",
")",
"[",
"1",
"]",
")",
")",
";",
"if",
"(",
"$",
"op",
"===",
"\"disj\"",
"&&",
"$",
"num",
"===",
"2",
")",
"return",
"Logic",
"::",
"_or",
"(",
"$",
"this",
"->",
"crossTreeConstraint",
"(",
"$",
"rule",
"->",
"children",
"(",
")",
"[",
"0",
"]",
")",
",",
"$",
"this",
"->",
"crossTreeConstraint",
"(",
"$",
"rule",
"->",
"children",
"(",
")",
"[",
"1",
"]",
")",
")",
";",
"if",
"(",
"$",
"op",
"===",
"\"not\"",
"&&",
"$",
"num",
"===",
"1",
")",
"return",
"Logic",
"::",
"not",
"(",
"$",
"this",
"->",
"crossTreeConstraint",
"(",
"$",
"rule",
"->",
"children",
"(",
")",
"[",
"0",
"]",
")",
")",
";",
"if",
"(",
"$",
"op",
"===",
"\"var\"",
"&&",
"$",
"num",
"===",
"0",
")",
"return",
"Logic",
"::",
"is",
"(",
"$",
"this",
"->",
"model",
"->",
"getFeature",
"(",
"(",
"string",
")",
"$",
"rule",
")",
")",
";",
"throw",
"new",
"ConstraintSolverException",
"(",
"\"unknown operation $op with $num arguments encountered\"",
")",
";",
"}"
] |
Transforms a cross-tree constraint from an XML rule to a formula.
@param \SimpleXMLElement $rule
@return callable
|
[
"Transforms",
"a",
"cross",
"-",
"tree",
"constraint",
"from",
"an",
"XML",
"rule",
"to",
"a",
"formula",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Model/ConstraintSolver.php#L177-L199
|
21,326 |
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Descriptor/Validator/ValidatorAbstract.php
|
ValidatorAbstract.dispatch
|
public function dispatch($name, $event)
{
if (!$this->event_dispatcher) {
return null;
}
if (!$this->event_dispatcher instanceof Dispatcher) {
throw new \Exception(
'Expected the event dispatcher to be an instance of phpDocumentor\Event\Dispatcher'
);
}
$this->event_dispatcher->dispatch($name, $event);
}
|
php
|
public function dispatch($name, $event)
{
if (!$this->event_dispatcher) {
return null;
}
if (!$this->event_dispatcher instanceof Dispatcher) {
throw new \Exception(
'Expected the event dispatcher to be an instance of phpDocumentor\Event\Dispatcher'
);
}
$this->event_dispatcher->dispatch($name, $event);
}
|
[
"public",
"function",
"dispatch",
"(",
"$",
"name",
",",
"$",
"event",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"event_dispatcher",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"event_dispatcher",
"instanceof",
"Dispatcher",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Expected the event dispatcher to be an instance of phpDocumentor\\Event\\Dispatcher'",
")",
";",
"}",
"$",
"this",
"->",
"event_dispatcher",
"->",
"dispatch",
"(",
"$",
"name",
",",
"$",
"event",
")",
";",
"}"
] |
Dispatches an event to the Event Dispatcher.
This method tries to dispatch an event; if no Event Dispatcher has been
set than this method will explicitly not fail and return null.
By not failing we make the Event Dispatcher optional and is it easier
for people to re-use this component in their own application.
@param string $name Name of the event to dispatch.
@param EventAbstract $event Arguments for this event.
@throws \Exception if there is a dispatcher but it is not of type EventDispatcher
@return void
|
[
"Dispatches",
"an",
"event",
"to",
"the",
"Event",
"Dispatcher",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Descriptor/Validator/ValidatorAbstract.php#L115-L128
|
21,327 |
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Descriptor/Validator/ValidatorAbstract.php
|
ValidatorAbstract.logParserError
|
public function logParserError($type, $code, $line, $variables = array())
{
$message = $this->__($code, $variables);
$this->log($message, LogLevel::ERROR);
$this->dispatch(
'parser.log',
LogEvent::createInstance($this)
->setMessage($message)
->setType($type)
->setCode($code)
->setLine($line)
);
}
|
php
|
public function logParserError($type, $code, $line, $variables = array())
{
$message = $this->__($code, $variables);
$this->log($message, LogLevel::ERROR);
$this->dispatch(
'parser.log',
LogEvent::createInstance($this)
->setMessage($message)
->setType($type)
->setCode($code)
->setLine($line)
);
}
|
[
"public",
"function",
"logParserError",
"(",
"$",
"type",
",",
"$",
"code",
",",
"$",
"line",
",",
"$",
"variables",
"=",
"array",
"(",
")",
")",
"{",
"$",
"message",
"=",
"$",
"this",
"->",
"__",
"(",
"$",
"code",
",",
"$",
"variables",
")",
";",
"$",
"this",
"->",
"log",
"(",
"$",
"message",
",",
"LogLevel",
"::",
"ERROR",
")",
";",
"$",
"this",
"->",
"dispatch",
"(",
"'parser.log'",
",",
"LogEvent",
"::",
"createInstance",
"(",
"$",
"this",
")",
"->",
"setMessage",
"(",
"$",
"message",
")",
"->",
"setType",
"(",
"$",
"type",
")",
"->",
"setCode",
"(",
"$",
"code",
")",
"->",
"setLine",
"(",
"$",
"line",
")",
")",
";",
"}"
] |
Dispatches a parser error to be logged.
@param string $type The logging priority as string
@param string $code The message to log.
@param string $line The line number where the error occurred..
@param string[] $variables an array with message substitution variables.
@return void
|
[
"Dispatches",
"a",
"parser",
"error",
"to",
"be",
"logged",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Descriptor/Validator/ValidatorAbstract.php#L158-L170
|
21,328 |
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Descriptor/Validator/ValidatorAbstract.php
|
ValidatorAbstract.__
|
public function __($message, $variables = array())
{
if (!$this->translate) {
return vsprintf($message, $variables);
}
$translator = $this->translate;
return vsprintf($translator->translate($message), $variables);
}
|
php
|
public function __($message, $variables = array())
{
if (!$this->translate) {
return vsprintf($message, $variables);
}
$translator = $this->translate;
return vsprintf($translator->translate($message), $variables);
}
|
[
"public",
"function",
"__",
"(",
"$",
"message",
",",
"$",
"variables",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"translate",
")",
"{",
"return",
"vsprintf",
"(",
"$",
"message",
",",
"$",
"variables",
")",
";",
"}",
"$",
"translator",
"=",
"$",
"this",
"->",
"translate",
";",
"return",
"vsprintf",
"(",
"$",
"translator",
"->",
"translate",
"(",
"$",
"message",
")",
",",
"$",
"variables",
")",
";",
"}"
] |
Translates the ID or message in the given language.
Translation messages may contain any formatting as used by the php
vsprintf function.
@param string $message ID or message to translate.
@param array $variables Variables to use for substitution.
@codingStandardsIgnoreStart
@return string
|
[
"Translates",
"the",
"ID",
"or",
"message",
"in",
"the",
"given",
"language",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Descriptor/Validator/ValidatorAbstract.php#L196-L205
|
21,329 |
MASNathan/Parser
|
src/Data/Content.php
|
Content.from
|
public function from($type)
{
switch ($type) {
case 'ini':
$this->data = Ini::decode($this->string);
break;
case 'json':
$this->data = Json::decode($this->string);
break;
case 'php':
$this->data = Php::decode($this->string);
break;
case 'xml':
$this->data = Xml::decode($this->string);
break;
case 'yml':
case 'yaml':
$this->data = Yaml::decode($this->string);
break;
default:
throw new \Exception("Format not supported: " . $type);
}
return $this;
}
|
php
|
public function from($type)
{
switch ($type) {
case 'ini':
$this->data = Ini::decode($this->string);
break;
case 'json':
$this->data = Json::decode($this->string);
break;
case 'php':
$this->data = Php::decode($this->string);
break;
case 'xml':
$this->data = Xml::decode($this->string);
break;
case 'yml':
case 'yaml':
$this->data = Yaml::decode($this->string);
break;
default:
throw new \Exception("Format not supported: " . $type);
}
return $this;
}
|
[
"public",
"function",
"from",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'ini'",
":",
"$",
"this",
"->",
"data",
"=",
"Ini",
"::",
"decode",
"(",
"$",
"this",
"->",
"string",
")",
";",
"break",
";",
"case",
"'json'",
":",
"$",
"this",
"->",
"data",
"=",
"Json",
"::",
"decode",
"(",
"$",
"this",
"->",
"string",
")",
";",
"break",
";",
"case",
"'php'",
":",
"$",
"this",
"->",
"data",
"=",
"Php",
"::",
"decode",
"(",
"$",
"this",
"->",
"string",
")",
";",
"break",
";",
"case",
"'xml'",
":",
"$",
"this",
"->",
"data",
"=",
"Xml",
"::",
"decode",
"(",
"$",
"this",
"->",
"string",
")",
";",
"break",
";",
"case",
"'yml'",
":",
"case",
"'yaml'",
":",
"$",
"this",
"->",
"data",
"=",
"Yaml",
"::",
"decode",
"(",
"$",
"this",
"->",
"string",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Format not supported: \"",
".",
"$",
"type",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Specifies the structure type which the content will be parsed from
@param string $type Type [ini, json, php, xml or yaml]
@return Content
|
[
"Specifies",
"the",
"structure",
"type",
"which",
"the",
"content",
"will",
"be",
"parsed",
"from"
] |
0f55402b99b1e071bdcd6277b9268f783ca25e34
|
https://github.com/MASNathan/Parser/blob/0f55402b99b1e071bdcd6277b9268f783ca25e34/src/Data/Content.php#L82-L111
|
21,330 |
MASNathan/Parser
|
src/Data/Content.php
|
Content.to
|
public function to($type)
{
switch ($type) {
case 'ini':
$this->string = Ini::encode($this->data);
break;
case 'json':
$this->string = Json::encode($this->data, $this->prettyOutput);
break;
case 'php':
$this->string = Php::encode($this->data);
break;
case 'xml':
$this->string = Xml::encode($this->data, $this->prettyOutput);
break;
case 'yml':
case 'yaml':
$this->string = Yaml::encode($this->data);
break;
default:
throw new \Exception("Format not supported: " . $type);
}
return $this->string;
}
|
php
|
public function to($type)
{
switch ($type) {
case 'ini':
$this->string = Ini::encode($this->data);
break;
case 'json':
$this->string = Json::encode($this->data, $this->prettyOutput);
break;
case 'php':
$this->string = Php::encode($this->data);
break;
case 'xml':
$this->string = Xml::encode($this->data, $this->prettyOutput);
break;
case 'yml':
case 'yaml':
$this->string = Yaml::encode($this->data);
break;
default:
throw new \Exception("Format not supported: " . $type);
}
return $this->string;
}
|
[
"public",
"function",
"to",
"(",
"$",
"type",
")",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'ini'",
":",
"$",
"this",
"->",
"string",
"=",
"Ini",
"::",
"encode",
"(",
"$",
"this",
"->",
"data",
")",
";",
"break",
";",
"case",
"'json'",
":",
"$",
"this",
"->",
"string",
"=",
"Json",
"::",
"encode",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"this",
"->",
"prettyOutput",
")",
";",
"break",
";",
"case",
"'php'",
":",
"$",
"this",
"->",
"string",
"=",
"Php",
"::",
"encode",
"(",
"$",
"this",
"->",
"data",
")",
";",
"break",
";",
"case",
"'xml'",
":",
"$",
"this",
"->",
"string",
"=",
"Xml",
"::",
"encode",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"this",
"->",
"prettyOutput",
")",
";",
"break",
";",
"case",
"'yml'",
":",
"case",
"'yaml'",
":",
"$",
"this",
"->",
"string",
"=",
"Yaml",
"::",
"encode",
"(",
"$",
"this",
"->",
"data",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Format not supported: \"",
".",
"$",
"type",
")",
";",
"}",
"return",
"$",
"this",
"->",
"string",
";",
"}"
] |
Specifies the format you want to encode the data to
@param string $type Type [ini, json, php, xml or yaml]
@return string
|
[
"Specifies",
"the",
"format",
"you",
"want",
"to",
"encode",
"the",
"data",
"to"
] |
0f55402b99b1e071bdcd6277b9268f783ca25e34
|
https://github.com/MASNathan/Parser/blob/0f55402b99b1e071bdcd6277b9268f783ca25e34/src/Data/Content.php#L118-L147
|
21,331 |
kouks/laravel-filters
|
src/Filters/Filter.php
|
Filter.apply
|
public function apply(Builder $builder)
{
$this->builder = $builder;
// We need to select all columns from the original
// table, since many joins can mess up the selected fields
$this->builder->select("{$this->getTableName()}.*");
foreach ($this->filters() as $name => $value) {
$this->callFilterMethod($name, $value);
}
return $this->builder;
}
|
php
|
public function apply(Builder $builder)
{
$this->builder = $builder;
// We need to select all columns from the original
// table, since many joins can mess up the selected fields
$this->builder->select("{$this->getTableName()}.*");
foreach ($this->filters() as $name => $value) {
$this->callFilterMethod($name, $value);
}
return $this->builder;
}
|
[
"public",
"function",
"apply",
"(",
"Builder",
"$",
"builder",
")",
"{",
"$",
"this",
"->",
"builder",
"=",
"$",
"builder",
";",
"// We need to select all columns from the original",
"// table, since many joins can mess up the selected fields",
"$",
"this",
"->",
"builder",
"->",
"select",
"(",
"\"{$this->getTableName()}.*\"",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"callFilterMethod",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
"->",
"builder",
";",
"}"
] |
Applies all available filters.
@param \Illuminate\Database\Eloquent\Builder $builder
@return \Illuminate\Database\Eloquent\Builder
|
[
"Applies",
"all",
"available",
"filters",
"."
] |
c1a594fd40173dcbb454ea7ec59818a919fff6bd
|
https://github.com/kouks/laravel-filters/blob/c1a594fd40173dcbb454ea7ec59818a919fff6bd/src/Filters/Filter.php#L66-L79
|
21,332 |
kouks/laravel-filters
|
src/Filters/Filter.php
|
Filter.resolve
|
protected function resolve($column, $key, $last, callable $callback)
{
if (! strpos($column, '.')) {
return $callback("{$last}.{$column}", $key);
}
$scope = strstr($column, '.', true);
$singular = str_singular($scope);
$next = substr(strstr($column, '.'), 1);
if (! in_array($scope, $this->loaded)) {
$this->loaded[] = $scope;
$this->builder->join($scope, "{$last}.{$singular}_id", "{$scope}.id");
}
return $this->resolve($next, $key, $scope, $callback);
}
|
php
|
protected function resolve($column, $key, $last, callable $callback)
{
if (! strpos($column, '.')) {
return $callback("{$last}.{$column}", $key);
}
$scope = strstr($column, '.', true);
$singular = str_singular($scope);
$next = substr(strstr($column, '.'), 1);
if (! in_array($scope, $this->loaded)) {
$this->loaded[] = $scope;
$this->builder->join($scope, "{$last}.{$singular}_id", "{$scope}.id");
}
return $this->resolve($next, $key, $scope, $callback);
}
|
[
"protected",
"function",
"resolve",
"(",
"$",
"column",
",",
"$",
"key",
",",
"$",
"last",
",",
"callable",
"$",
"callback",
")",
"{",
"if",
"(",
"!",
"strpos",
"(",
"$",
"column",
",",
"'.'",
")",
")",
"{",
"return",
"$",
"callback",
"(",
"\"{$last}.{$column}\"",
",",
"$",
"key",
")",
";",
"}",
"$",
"scope",
"=",
"strstr",
"(",
"$",
"column",
",",
"'.'",
",",
"true",
")",
";",
"$",
"singular",
"=",
"str_singular",
"(",
"$",
"scope",
")",
";",
"$",
"next",
"=",
"substr",
"(",
"strstr",
"(",
"$",
"column",
",",
"'.'",
")",
",",
"1",
")",
";",
"if",
"(",
"!",
"in_array",
"(",
"$",
"scope",
",",
"$",
"this",
"->",
"loaded",
")",
")",
"{",
"$",
"this",
"->",
"loaded",
"[",
"]",
"=",
"$",
"scope",
";",
"$",
"this",
"->",
"builder",
"->",
"join",
"(",
"$",
"scope",
",",
"\"{$last}.{$singular}_id\"",
",",
"\"{$scope}.id\"",
")",
";",
"}",
"return",
"$",
"this",
"->",
"resolve",
"(",
"$",
"next",
",",
"$",
"key",
",",
"$",
"scope",
",",
"$",
"callback",
")",
";",
"}"
] |
Recursively build up the query.
@param string $column
@param string $key
@param string $last
@param callable $callback
@return void
|
[
"Recursively",
"build",
"up",
"the",
"query",
"."
] |
c1a594fd40173dcbb454ea7ec59818a919fff6bd
|
https://github.com/kouks/laravel-filters/blob/c1a594fd40173dcbb454ea7ec59818a919fff6bd/src/Filters/Filter.php#L121-L138
|
21,333 |
ekuiter/feature-php
|
FeaturePhp/ProductLine/ProductRenderer.php
|
ProductRenderer._render
|
public function _render($textOnly) {
$featureNum = count($this->product->getConfiguration()->getSelectedFeatures());
$fileNum = count($this->files);
$str = "";
$maxLen = fphp\Helper\_String::getMaxLength($this->files, "getTarget");
if ($textOnly)
$str .= "\nProduct Analysis\n================\n" .
"For the given product, $featureNum features were selected and the following $fileNum files were generated:\n\n";
else {
$str .= "<h2>Product Analysis</h2>";
$str .= "<div>";
$str .= "<p>For the given product, $featureNum features were selected and the following $fileNum files were generated:</p>";
$str .= "<ul>";
}
foreach ($this->files as $file) {
$summary = $file->getContent()->getSummary();
if ($textOnly) {
$str .= sprintf("$this->accentColor%-{$maxLen}s$this->defaultColor %s\n", $file->getTarget(),
fphp\Helper\_String::truncate($summary));
} else
$str .= "<li><span class='fileName' onclick='var style = this.parentElement.children[1].style;
style.display = style.display === \"block\" ? \"none\" : \"block\";'>"
. $file->getTarget()
. "</span><pre style='font-size: 0.8em; display: none'>"
. str_replace("\n", "<br />", htmlspecialchars($summary)) . "</pre>"
. "</li>";
}
if (!$textOnly) {
$str .= "</ul>";
$str .= "</div>";
}
$str .= (new fphp\Artifact\TracingLinkRenderer($this->tracingLinks))->render($textOnly);
return $str;
}
|
php
|
public function _render($textOnly) {
$featureNum = count($this->product->getConfiguration()->getSelectedFeatures());
$fileNum = count($this->files);
$str = "";
$maxLen = fphp\Helper\_String::getMaxLength($this->files, "getTarget");
if ($textOnly)
$str .= "\nProduct Analysis\n================\n" .
"For the given product, $featureNum features were selected and the following $fileNum files were generated:\n\n";
else {
$str .= "<h2>Product Analysis</h2>";
$str .= "<div>";
$str .= "<p>For the given product, $featureNum features were selected and the following $fileNum files were generated:</p>";
$str .= "<ul>";
}
foreach ($this->files as $file) {
$summary = $file->getContent()->getSummary();
if ($textOnly) {
$str .= sprintf("$this->accentColor%-{$maxLen}s$this->defaultColor %s\n", $file->getTarget(),
fphp\Helper\_String::truncate($summary));
} else
$str .= "<li><span class='fileName' onclick='var style = this.parentElement.children[1].style;
style.display = style.display === \"block\" ? \"none\" : \"block\";'>"
. $file->getTarget()
. "</span><pre style='font-size: 0.8em; display: none'>"
. str_replace("\n", "<br />", htmlspecialchars($summary)) . "</pre>"
. "</li>";
}
if (!$textOnly) {
$str .= "</ul>";
$str .= "</div>";
}
$str .= (new fphp\Artifact\TracingLinkRenderer($this->tracingLinks))->render($textOnly);
return $str;
}
|
[
"public",
"function",
"_render",
"(",
"$",
"textOnly",
")",
"{",
"$",
"featureNum",
"=",
"count",
"(",
"$",
"this",
"->",
"product",
"->",
"getConfiguration",
"(",
")",
"->",
"getSelectedFeatures",
"(",
")",
")",
";",
"$",
"fileNum",
"=",
"count",
"(",
"$",
"this",
"->",
"files",
")",
";",
"$",
"str",
"=",
"\"\"",
";",
"$",
"maxLen",
"=",
"fphp",
"\\",
"Helper",
"\\",
"_String",
"::",
"getMaxLength",
"(",
"$",
"this",
"->",
"files",
",",
"\"getTarget\"",
")",
";",
"if",
"(",
"$",
"textOnly",
")",
"$",
"str",
".=",
"\"\\nProduct Analysis\\n================\\n\"",
".",
"\"For the given product, $featureNum features were selected and the following $fileNum files were generated:\\n\\n\"",
";",
"else",
"{",
"$",
"str",
".=",
"\"<h2>Product Analysis</h2>\"",
";",
"$",
"str",
".=",
"\"<div>\"",
";",
"$",
"str",
".=",
"\"<p>For the given product, $featureNum features were selected and the following $fileNum files were generated:</p>\"",
";",
"$",
"str",
".=",
"\"<ul>\"",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"summary",
"=",
"$",
"file",
"->",
"getContent",
"(",
")",
"->",
"getSummary",
"(",
")",
";",
"if",
"(",
"$",
"textOnly",
")",
"{",
"$",
"str",
".=",
"sprintf",
"(",
"\"$this->accentColor%-{$maxLen}s$this->defaultColor %s\\n\"",
",",
"$",
"file",
"->",
"getTarget",
"(",
")",
",",
"fphp",
"\\",
"Helper",
"\\",
"_String",
"::",
"truncate",
"(",
"$",
"summary",
")",
")",
";",
"}",
"else",
"$",
"str",
".=",
"\"<li><span class='fileName' onclick='var style = this.parentElement.children[1].style;\n style.display = style.display === \\\"block\\\" ? \\\"none\\\" : \\\"block\\\";'>\"",
".",
"$",
"file",
"->",
"getTarget",
"(",
")",
".",
"\"</span><pre style='font-size: 0.8em; display: none'>\"",
".",
"str_replace",
"(",
"\"\\n\"",
",",
"\"<br />\"",
",",
"htmlspecialchars",
"(",
"$",
"summary",
")",
")",
".",
"\"</pre>\"",
".",
"\"</li>\"",
";",
"}",
"if",
"(",
"!",
"$",
"textOnly",
")",
"{",
"$",
"str",
".=",
"\"</ul>\"",
";",
"$",
"str",
".=",
"\"</div>\"",
";",
"}",
"$",
"str",
".=",
"(",
"new",
"fphp",
"\\",
"Artifact",
"\\",
"TracingLinkRenderer",
"(",
"$",
"this",
"->",
"tracingLinks",
")",
")",
"->",
"render",
"(",
"$",
"textOnly",
")",
";",
"return",
"$",
"str",
";",
"}"
] |
Returns the product analysis.
@param bool $textOnly whether to render text or HTML
@return string
|
[
"Returns",
"the",
"product",
"analysis",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/ProductLine/ProductRenderer.php#L47-L85
|
21,334 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.table
|
public function table()
{
if (!$this->_properties['table_name']) {
$class = explode('\\', get_called_class());
$this->_properties['table_name'] = Instance::snakecase(lcfirst(end($class)));
}
return $this->_properties['table_name'];
}
|
php
|
public function table()
{
if (!$this->_properties['table_name']) {
$class = explode('\\', get_called_class());
$this->_properties['table_name'] = Instance::snakecase(lcfirst(end($class)));
}
return $this->_properties['table_name'];
}
|
[
"public",
"function",
"table",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_properties",
"[",
"'table_name'",
"]",
")",
"{",
"$",
"class",
"=",
"explode",
"(",
"'\\\\'",
",",
"get_called_class",
"(",
")",
")",
";",
"$",
"this",
"->",
"_properties",
"[",
"'table_name'",
"]",
"=",
"Instance",
"::",
"snakecase",
"(",
"lcfirst",
"(",
"end",
"(",
"$",
"class",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"_properties",
"[",
"'table_name'",
"]",
";",
"}"
] |
Return table name
|
[
"Return",
"table",
"name"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L160-L168
|
21,335 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.field
|
public function field($name)
{
return isset($this->_properties['fields'][$name])?
$this->_properties['fields'][$name]:null;
}
|
php
|
public function field($name)
{
return isset($this->_properties['fields'][$name])?
$this->_properties['fields'][$name]:null;
}
|
[
"public",
"function",
"field",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_properties",
"[",
"'fields'",
"]",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"_properties",
"[",
"'fields'",
"]",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] |
return field alias
|
[
"return",
"field",
"alias"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L278-L282
|
21,336 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.get
|
public function get($var)
{
return isset($this->_schema['values'][$var])?
$this->_schema['values'][$var]:(
isset($this->_schema['others'][$var])?
$this->_schema['others'][$var]:null);
}
|
php
|
public function get($var)
{
return isset($this->_schema['values'][$var])?
$this->_schema['values'][$var]:(
isset($this->_schema['others'][$var])?
$this->_schema['others'][$var]:null);
}
|
[
"public",
"function",
"get",
"(",
"$",
"var",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"_schema",
"[",
"'values'",
"]",
"[",
"$",
"var",
"]",
")",
"?",
"$",
"this",
"->",
"_schema",
"[",
"'values'",
"]",
"[",
"$",
"var",
"]",
":",
"(",
"isset",
"(",
"$",
"this",
"->",
"_schema",
"[",
"'others'",
"]",
"[",
"$",
"var",
"]",
")",
"?",
"$",
"this",
"->",
"_schema",
"[",
"'others'",
"]",
"[",
"$",
"var",
"]",
":",
"null",
")",
";",
"}"
] |
Get fields value
|
[
"Get",
"fields",
"value"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L351-L357
|
21,337 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.findByPK
|
public function findByPK()
{
$pk = func_get_args();
if (!$this->_properties['primary_key'] || !$pk)
throw new Exception(sprintf(self::E_PrimaryKey, get_called_class()), 1);
!is_array(reset($pk)) || $pk = array_shift($pk);
$criteria = $values = array();
foreach ($this->_properties['primary_key'] as $field) {
$token = ':pk_'.$field;
$criteria[] = '{table}.'.$field.'='.$token;
$values[$token] = isset($pk[$field])?$pk[$field]:array_shift($pk);
}
return $this->limit(1)->find(implode(' and ', $criteria), $values);
}
|
php
|
public function findByPK()
{
$pk = func_get_args();
if (!$this->_properties['primary_key'] || !$pk)
throw new Exception(sprintf(self::E_PrimaryKey, get_called_class()), 1);
!is_array(reset($pk)) || $pk = array_shift($pk);
$criteria = $values = array();
foreach ($this->_properties['primary_key'] as $field) {
$token = ':pk_'.$field;
$criteria[] = '{table}.'.$field.'='.$token;
$values[$token] = isset($pk[$field])?$pk[$field]:array_shift($pk);
}
return $this->limit(1)->find(implode(' and ', $criteria), $values);
}
|
[
"public",
"function",
"findByPK",
"(",
")",
"{",
"$",
"pk",
"=",
"func_get_args",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"_properties",
"[",
"'primary_key'",
"]",
"||",
"!",
"$",
"pk",
")",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"self",
"::",
"E_PrimaryKey",
",",
"get_called_class",
"(",
")",
")",
",",
"1",
")",
";",
"!",
"is_array",
"(",
"reset",
"(",
"$",
"pk",
")",
")",
"||",
"$",
"pk",
"=",
"array_shift",
"(",
"$",
"pk",
")",
";",
"$",
"criteria",
"=",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_properties",
"[",
"'primary_key'",
"]",
"as",
"$",
"field",
")",
"{",
"$",
"token",
"=",
"':pk_'",
".",
"$",
"field",
";",
"$",
"criteria",
"[",
"]",
"=",
"'{table}.'",
".",
"$",
"field",
".",
"'='",
".",
"$",
"token",
";",
"$",
"values",
"[",
"$",
"token",
"]",
"=",
"isset",
"(",
"$",
"pk",
"[",
"$",
"field",
"]",
")",
"?",
"$",
"pk",
"[",
"$",
"field",
"]",
":",
"array_shift",
"(",
"$",
"pk",
")",
";",
"}",
"return",
"$",
"this",
"->",
"limit",
"(",
"1",
")",
"->",
"find",
"(",
"implode",
"(",
"' and '",
",",
"$",
"criteria",
")",
",",
"$",
"values",
")",
";",
"}"
] |
Find by PK
|
[
"Find",
"by",
"PK"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L476-L491
|
21,338 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.pkValue
|
public function pkValue()
{
if ($args = func_get_args()) {
!is_array($args[0]) || $args = array_shift($args);
$args = array_values($args);
foreach ($args as $key=>$arg)
$this->{$this->_properties['primary_key'][$key]} = $arg;
return $this;
}
$pk = array_intersect_key($this->_schema['values'],
array_fill_keys($this->_properties['primary_key'], null));
return count($pk)==0?null:(count($pk)==1?array_shift($pk):$pk);
}
|
php
|
public function pkValue()
{
if ($args = func_get_args()) {
!is_array($args[0]) || $args = array_shift($args);
$args = array_values($args);
foreach ($args as $key=>$arg)
$this->{$this->_properties['primary_key'][$key]} = $arg;
return $this;
}
$pk = array_intersect_key($this->_schema['values'],
array_fill_keys($this->_properties['primary_key'], null));
return count($pk)==0?null:(count($pk)==1?array_shift($pk):$pk);
}
|
[
"public",
"function",
"pkValue",
"(",
")",
"{",
"if",
"(",
"$",
"args",
"=",
"func_get_args",
"(",
")",
")",
"{",
"!",
"is_array",
"(",
"$",
"args",
"[",
"0",
"]",
")",
"||",
"$",
"args",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"args",
"=",
"array_values",
"(",
"$",
"args",
")",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"key",
"=>",
"$",
"arg",
")",
"$",
"this",
"->",
"{",
"$",
"this",
"->",
"_properties",
"[",
"'primary_key'",
"]",
"[",
"$",
"key",
"]",
"}",
"=",
"$",
"arg",
";",
"return",
"$",
"this",
";",
"}",
"$",
"pk",
"=",
"array_intersect_key",
"(",
"$",
"this",
"->",
"_schema",
"[",
"'values'",
"]",
",",
"array_fill_keys",
"(",
"$",
"this",
"->",
"_properties",
"[",
"'primary_key'",
"]",
",",
"null",
")",
")",
";",
"return",
"count",
"(",
"$",
"pk",
")",
"==",
"0",
"?",
"null",
":",
"(",
"count",
"(",
"$",
"pk",
")",
"==",
"1",
"?",
"array_shift",
"(",
"$",
"pk",
")",
":",
"$",
"pk",
")",
";",
"}"
] |
Get PK Value
@return mixed pk value
|
[
"Get",
"PK",
"Value"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L497-L512
|
21,339 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.generatePK
|
public function generatePK()
{
$format = $this->pkFormat;
$pk = $this->_properties['primary_key'];
if (isset($pk[1]))
throw new Exception(sprintf(self::E_Composit, get_called_class(), __FUNCTION__), 1);
$pk = array_shift($pk);
if (!$pk)
throw new Exception(sprintf(self::E_PrimaryKey, get_called_class()), 1);
$last = (int) $this
->select(($format['serial']?
'right('.$pk.', '.$format['serial'].')':
$pk).' as last')
->order($pk.' desc')
->read(1)
->last;
// compile prefix format
if (preg_match('/\{(?<date>.+)\}/', $format['prefix'], $match))
$newPK = preg_replace('/\{.+\}/', date($match['date']), $format['prefix']);
else
$newPK = $format['prefix'];
$newPK .= trim(str_pad($last+1, $format['serial'], $format['prefix']?'0':' ', STR_PAD_LEFT));
return $newPK;
}
|
php
|
public function generatePK()
{
$format = $this->pkFormat;
$pk = $this->_properties['primary_key'];
if (isset($pk[1]))
throw new Exception(sprintf(self::E_Composit, get_called_class(), __FUNCTION__), 1);
$pk = array_shift($pk);
if (!$pk)
throw new Exception(sprintf(self::E_PrimaryKey, get_called_class()), 1);
$last = (int) $this
->select(($format['serial']?
'right('.$pk.', '.$format['serial'].')':
$pk).' as last')
->order($pk.' desc')
->read(1)
->last;
// compile prefix format
if (preg_match('/\{(?<date>.+)\}/', $format['prefix'], $match))
$newPK = preg_replace('/\{.+\}/', date($match['date']), $format['prefix']);
else
$newPK = $format['prefix'];
$newPK .= trim(str_pad($last+1, $format['serial'], $format['prefix']?'0':' ', STR_PAD_LEFT));
return $newPK;
}
|
[
"public",
"function",
"generatePK",
"(",
")",
"{",
"$",
"format",
"=",
"$",
"this",
"->",
"pkFormat",
";",
"$",
"pk",
"=",
"$",
"this",
"->",
"_properties",
"[",
"'primary_key'",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"pk",
"[",
"1",
"]",
")",
")",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"self",
"::",
"E_Composit",
",",
"get_called_class",
"(",
")",
",",
"__FUNCTION__",
")",
",",
"1",
")",
";",
"$",
"pk",
"=",
"array_shift",
"(",
"$",
"pk",
")",
";",
"if",
"(",
"!",
"$",
"pk",
")",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"self",
"::",
"E_PrimaryKey",
",",
"get_called_class",
"(",
")",
")",
",",
"1",
")",
";",
"$",
"last",
"=",
"(",
"int",
")",
"$",
"this",
"->",
"select",
"(",
"(",
"$",
"format",
"[",
"'serial'",
"]",
"?",
"'right('",
".",
"$",
"pk",
".",
"', '",
".",
"$",
"format",
"[",
"'serial'",
"]",
".",
"')'",
":",
"$",
"pk",
")",
".",
"' as last'",
")",
"->",
"order",
"(",
"$",
"pk",
".",
"' desc'",
")",
"->",
"read",
"(",
"1",
")",
"->",
"last",
";",
"// compile prefix format",
"if",
"(",
"preg_match",
"(",
"'/\\{(?<date>.+)\\}/'",
",",
"$",
"format",
"[",
"'prefix'",
"]",
",",
"$",
"match",
")",
")",
"$",
"newPK",
"=",
"preg_replace",
"(",
"'/\\{.+\\}/'",
",",
"date",
"(",
"$",
"match",
"[",
"'date'",
"]",
")",
",",
"$",
"format",
"[",
"'prefix'",
"]",
")",
";",
"else",
"$",
"newPK",
"=",
"$",
"format",
"[",
"'prefix'",
"]",
";",
"$",
"newPK",
".=",
"trim",
"(",
"str_pad",
"(",
"$",
"last",
"+",
"1",
",",
"$",
"format",
"[",
"'serial'",
"]",
",",
"$",
"format",
"[",
"'prefix'",
"]",
"?",
"'0'",
":",
"' '",
",",
"STR_PAD_LEFT",
")",
")",
";",
"return",
"$",
"newPK",
";",
"}"
] |
Generate PK only if pk count = 1
@return string Next PK
|
[
"Generate",
"PK",
"only",
"if",
"pk",
"count",
"=",
"1"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L548-L576
|
21,340 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.unique
|
public function unique($criteria = null, array $values = array())
{
if (!$this->_properties['primary_key'] || (!$values && !$criteria))
throw new Exception(sprintf(self::E_PrimaryKey, get_called_class()), 1);
$that = clone $this;
$values ? $that->find($criteria, $values) : $that->findByPK($criteria);
return ($that->dry() || $this->pkCompare($that->pkValue()));
}
|
php
|
public function unique($criteria = null, array $values = array())
{
if (!$this->_properties['primary_key'] || (!$values && !$criteria))
throw new Exception(sprintf(self::E_PrimaryKey, get_called_class()), 1);
$that = clone $this;
$values ? $that->find($criteria, $values) : $that->findByPK($criteria);
return ($that->dry() || $this->pkCompare($that->pkValue()));
}
|
[
"public",
"function",
"unique",
"(",
"$",
"criteria",
"=",
"null",
",",
"array",
"$",
"values",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_properties",
"[",
"'primary_key'",
"]",
"||",
"(",
"!",
"$",
"values",
"&&",
"!",
"$",
"criteria",
")",
")",
"throw",
"new",
"Exception",
"(",
"sprintf",
"(",
"self",
"::",
"E_PrimaryKey",
",",
"get_called_class",
"(",
")",
")",
",",
"1",
")",
";",
"$",
"that",
"=",
"clone",
"$",
"this",
";",
"$",
"values",
"?",
"$",
"that",
"->",
"find",
"(",
"$",
"criteria",
",",
"$",
"values",
")",
":",
"$",
"that",
"->",
"findByPK",
"(",
"$",
"criteria",
")",
";",
"return",
"(",
"$",
"that",
"->",
"dry",
"(",
")",
"||",
"$",
"this",
"->",
"pkCompare",
"(",
"$",
"that",
"->",
"pkValue",
"(",
")",
")",
")",
";",
"}"
] |
Check not existance
|
[
"Check",
"not",
"existance"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L595-L604
|
21,341 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.next
|
public function next()
{
if (!$this->hasError()) {
$row = $this->_stmt->fetch($this->_schema['fetch']);
$this->assign($row?:array_fill_keys(array_keys(
$this->_properties['fields']), null));
}
return $this;
}
|
php
|
public function next()
{
if (!$this->hasError()) {
$row = $this->_stmt->fetch($this->_schema['fetch']);
$this->assign($row?:array_fill_keys(array_keys(
$this->_properties['fields']), null));
}
return $this;
}
|
[
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasError",
"(",
")",
")",
"{",
"$",
"row",
"=",
"$",
"this",
"->",
"_stmt",
"->",
"fetch",
"(",
"$",
"this",
"->",
"_schema",
"[",
"'fetch'",
"]",
")",
";",
"$",
"this",
"->",
"assign",
"(",
"$",
"row",
"?",
":",
"array_fill_keys",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"_properties",
"[",
"'fields'",
"]",
")",
",",
"null",
")",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
get next row and assign row to schema values
|
[
"get",
"next",
"row",
"and",
"assign",
"row",
"to",
"schema",
"values"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L655-L664
|
21,342 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.read
|
public function read($limit = 0)
{
$this->limit($limit);
$query = $this->buildSelect();
$this->run($query['query'], $query['param']);
return $this->next();
}
|
php
|
public function read($limit = 0)
{
$this->limit($limit);
$query = $this->buildSelect();
$this->run($query['query'], $query['param']);
return $this->next();
}
|
[
"public",
"function",
"read",
"(",
"$",
"limit",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"limit",
"(",
"$",
"limit",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"buildSelect",
"(",
")",
";",
"$",
"this",
"->",
"run",
"(",
"$",
"query",
"[",
"'query'",
"]",
",",
"$",
"query",
"[",
"'param'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"next",
"(",
")",
";",
"}"
] |
perform select query
|
[
"perform",
"select",
"query"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L669-L676
|
21,343 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.insert
|
public function insert(array $data = array(), $update = false)
{
$this->viewCheck(__FUNCTION__);
$data = array_merge($this->_schema['init'],
array_filter($this->_schema['values'], array($this, 'filterRule')),
array_filter($this->_schema['others'], array($this, 'filterRule')),
$data);
$params = array();
foreach ($data as $key => $value)
if (in_array($key, $this->_properties['primary_key']) && !$value)
continue;
elseif (is_array($value))
return false;
elseif (isset($this->_properties['fields'][$key]))
$params[':'.$key] = $value;
if (empty($params) || ($update && !$this->_properties['primary_key']))
return false;
$query = $this->buildInsert($params, $update);
if (!($query && $this->validate($params)))
return false;
$old = clone $this;
if (!$this->beforeInsert($params))
return false;
if ($result = $this->run($query, $params))
$this->assign($params);
if (!$this->afterInsert($old))
return false;
return $result;
}
|
php
|
public function insert(array $data = array(), $update = false)
{
$this->viewCheck(__FUNCTION__);
$data = array_merge($this->_schema['init'],
array_filter($this->_schema['values'], array($this, 'filterRule')),
array_filter($this->_schema['others'], array($this, 'filterRule')),
$data);
$params = array();
foreach ($data as $key => $value)
if (in_array($key, $this->_properties['primary_key']) && !$value)
continue;
elseif (is_array($value))
return false;
elseif (isset($this->_properties['fields'][$key]))
$params[':'.$key] = $value;
if (empty($params) || ($update && !$this->_properties['primary_key']))
return false;
$query = $this->buildInsert($params, $update);
if (!($query && $this->validate($params)))
return false;
$old = clone $this;
if (!$this->beforeInsert($params))
return false;
if ($result = $this->run($query, $params))
$this->assign($params);
if (!$this->afterInsert($old))
return false;
return $result;
}
|
[
"public",
"function",
"insert",
"(",
"array",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"update",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"viewCheck",
"(",
"__FUNCTION__",
")",
";",
"$",
"data",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"_schema",
"[",
"'init'",
"]",
",",
"array_filter",
"(",
"$",
"this",
"->",
"_schema",
"[",
"'values'",
"]",
",",
"array",
"(",
"$",
"this",
",",
"'filterRule'",
")",
")",
",",
"array_filter",
"(",
"$",
"this",
"->",
"_schema",
"[",
"'others'",
"]",
",",
"array",
"(",
"$",
"this",
",",
"'filterRule'",
")",
")",
",",
"$",
"data",
")",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"_properties",
"[",
"'primary_key'",
"]",
")",
"&&",
"!",
"$",
"value",
")",
"continue",
";",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"return",
"false",
";",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"_properties",
"[",
"'fields'",
"]",
"[",
"$",
"key",
"]",
")",
")",
"$",
"params",
"[",
"':'",
".",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"if",
"(",
"empty",
"(",
"$",
"params",
")",
"||",
"(",
"$",
"update",
"&&",
"!",
"$",
"this",
"->",
"_properties",
"[",
"'primary_key'",
"]",
")",
")",
"return",
"false",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"buildInsert",
"(",
"$",
"params",
",",
"$",
"update",
")",
";",
"if",
"(",
"!",
"(",
"$",
"query",
"&&",
"$",
"this",
"->",
"validate",
"(",
"$",
"params",
")",
")",
")",
"return",
"false",
";",
"$",
"old",
"=",
"clone",
"$",
"this",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"beforeInsert",
"(",
"$",
"params",
")",
")",
"return",
"false",
";",
"if",
"(",
"$",
"result",
"=",
"$",
"this",
"->",
"run",
"(",
"$",
"query",
",",
"$",
"params",
")",
")",
"$",
"this",
"->",
"assign",
"(",
"$",
"params",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"afterInsert",
"(",
"$",
"old",
")",
")",
"return",
"false",
";",
"return",
"$",
"result",
";",
"}"
] |
Insert, on duplicate key update
|
[
"Insert",
"on",
"duplicate",
"key",
"update"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L716-L753
|
21,344 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.update
|
public function update(array $data = array(), array $criteria = array())
{
$this->viewCheck(__FUNCTION__);
$data = array_merge(
array_filter($this->_schema['others'], array($this, 'filterRule')),
$data);
$params = array();
$values = array_filter($this->_schema['values']);
$others = array_filter($this->_schema['others']);
foreach ($data as $key => $value)
if (is_array($value))
return false;
elseif (isset($this->_properties['fields'][$key]))
if (isset($values[$key]) && isset($others[$key])
&& $values[$key]==$others[$key]
)
continue;
else
$params[':'.$key] = $value;
if (empty($params))
return true;
$query = $this->buildUpdate($params, $criteria);
if (!($query && $this->validate($params)))
return false;
$old = clone $this;
if (!$this->beforeUpdate($params))
return false;
if ($result = $this->run($query, $params))
$this->assign($params);
if (!$this->afterUpdate($old))
return false;
return $result;
}
|
php
|
public function update(array $data = array(), array $criteria = array())
{
$this->viewCheck(__FUNCTION__);
$data = array_merge(
array_filter($this->_schema['others'], array($this, 'filterRule')),
$data);
$params = array();
$values = array_filter($this->_schema['values']);
$others = array_filter($this->_schema['others']);
foreach ($data as $key => $value)
if (is_array($value))
return false;
elseif (isset($this->_properties['fields'][$key]))
if (isset($values[$key]) && isset($others[$key])
&& $values[$key]==$others[$key]
)
continue;
else
$params[':'.$key] = $value;
if (empty($params))
return true;
$query = $this->buildUpdate($params, $criteria);
if (!($query && $this->validate($params)))
return false;
$old = clone $this;
if (!$this->beforeUpdate($params))
return false;
if ($result = $this->run($query, $params))
$this->assign($params);
if (!$this->afterUpdate($old))
return false;
return $result;
}
|
[
"public",
"function",
"update",
"(",
"array",
"$",
"data",
"=",
"array",
"(",
")",
",",
"array",
"$",
"criteria",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"viewCheck",
"(",
"__FUNCTION__",
")",
";",
"$",
"data",
"=",
"array_merge",
"(",
"array_filter",
"(",
"$",
"this",
"->",
"_schema",
"[",
"'others'",
"]",
",",
"array",
"(",
"$",
"this",
",",
"'filterRule'",
")",
")",
",",
"$",
"data",
")",
";",
"$",
"params",
"=",
"array",
"(",
")",
";",
"$",
"values",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"_schema",
"[",
"'values'",
"]",
")",
";",
"$",
"others",
"=",
"array_filter",
"(",
"$",
"this",
"->",
"_schema",
"[",
"'others'",
"]",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"return",
"false",
";",
"elseif",
"(",
"isset",
"(",
"$",
"this",
"->",
"_properties",
"[",
"'fields'",
"]",
"[",
"$",
"key",
"]",
")",
")",
"if",
"(",
"isset",
"(",
"$",
"values",
"[",
"$",
"key",
"]",
")",
"&&",
"isset",
"(",
"$",
"others",
"[",
"$",
"key",
"]",
")",
"&&",
"$",
"values",
"[",
"$",
"key",
"]",
"==",
"$",
"others",
"[",
"$",
"key",
"]",
")",
"continue",
";",
"else",
"$",
"params",
"[",
"':'",
".",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"if",
"(",
"empty",
"(",
"$",
"params",
")",
")",
"return",
"true",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"buildUpdate",
"(",
"$",
"params",
",",
"$",
"criteria",
")",
";",
"if",
"(",
"!",
"(",
"$",
"query",
"&&",
"$",
"this",
"->",
"validate",
"(",
"$",
"params",
")",
")",
")",
"return",
"false",
";",
"$",
"old",
"=",
"clone",
"$",
"this",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"beforeUpdate",
"(",
"$",
"params",
")",
")",
"return",
"false",
";",
"if",
"(",
"$",
"result",
"=",
"$",
"this",
"->",
"run",
"(",
"$",
"query",
",",
"$",
"params",
")",
")",
"$",
"this",
"->",
"assign",
"(",
"$",
"params",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"afterUpdate",
"(",
"$",
"old",
")",
")",
"return",
"false",
";",
"return",
"$",
"result",
";",
"}"
] |
Update, only when there is primary key
|
[
"Update",
"only",
"when",
"there",
"is",
"primary",
"key"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L758-L799
|
21,345 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.delete
|
public function delete(array $criteria = [])
{
$this->viewCheck(__FUNCTION__);
$query = $this->buildDelete($criteria);
$old = clone $this;
if (!$this->beforeDelete($criteria))
return false;
if ($result = $this->run($query, $criteria))
$this->next();
if (!$this->afterDelete($old))
return false;
return $result;
}
|
php
|
public function delete(array $criteria = [])
{
$this->viewCheck(__FUNCTION__);
$query = $this->buildDelete($criteria);
$old = clone $this;
if (!$this->beforeDelete($criteria))
return false;
if ($result = $this->run($query, $criteria))
$this->next();
if (!$this->afterDelete($old))
return false;
return $result;
}
|
[
"public",
"function",
"delete",
"(",
"array",
"$",
"criteria",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"viewCheck",
"(",
"__FUNCTION__",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"buildDelete",
"(",
"$",
"criteria",
")",
";",
"$",
"old",
"=",
"clone",
"$",
"this",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"beforeDelete",
"(",
"$",
"criteria",
")",
")",
"return",
"false",
";",
"if",
"(",
"$",
"result",
"=",
"$",
"this",
"->",
"run",
"(",
"$",
"query",
",",
"$",
"criteria",
")",
")",
"$",
"this",
"->",
"next",
"(",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"afterDelete",
"(",
"$",
"old",
")",
")",
"return",
"false",
";",
"return",
"$",
"result",
";",
"}"
] |
delete, only when there is primary key
|
[
"delete",
"only",
"when",
"there",
"is",
"primary",
"key"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L804-L821
|
21,346 |
eghojansu/moe
|
src/AbstractModel.php
|
AbstractModel.performValidate
|
protected function performValidate($key, &$value)
{
if (!$filter = $this->_schema['filter'][$key])
return true;
$validation = Validation::instance();
$moe = Base::instance();
$field = $this->_properties['fields'][$key];
foreach ($filter as $func => $param) {
if (is_numeric($func)) {
$func = $param;
$args = array();
} else
$args = [$param];
$function = $func;
if (method_exists($validation, $func))
$func = array($validation, $func);
elseif (method_exists($this, $func) ||
preg_match('/^('.self::Magic.')/', $func))
$func = array($this, $func);
elseif (method_exists($moe, $func))
$func = array($moe, $func);
array_unshift($args, $value);
if (false === $result = $moe->call($func, $args)) {
$this->_messages[] = $validation->message($function, $field, $value, $param);
return false;
} else
is_bool($result) || $value = $result;
}
return true;
}
|
php
|
protected function performValidate($key, &$value)
{
if (!$filter = $this->_schema['filter'][$key])
return true;
$validation = Validation::instance();
$moe = Base::instance();
$field = $this->_properties['fields'][$key];
foreach ($filter as $func => $param) {
if (is_numeric($func)) {
$func = $param;
$args = array();
} else
$args = [$param];
$function = $func;
if (method_exists($validation, $func))
$func = array($validation, $func);
elseif (method_exists($this, $func) ||
preg_match('/^('.self::Magic.')/', $func))
$func = array($this, $func);
elseif (method_exists($moe, $func))
$func = array($moe, $func);
array_unshift($args, $value);
if (false === $result = $moe->call($func, $args)) {
$this->_messages[] = $validation->message($function, $field, $value, $param);
return false;
} else
is_bool($result) || $value = $result;
}
return true;
}
|
[
"protected",
"function",
"performValidate",
"(",
"$",
"key",
",",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"filter",
"=",
"$",
"this",
"->",
"_schema",
"[",
"'filter'",
"]",
"[",
"$",
"key",
"]",
")",
"return",
"true",
";",
"$",
"validation",
"=",
"Validation",
"::",
"instance",
"(",
")",
";",
"$",
"moe",
"=",
"Base",
"::",
"instance",
"(",
")",
";",
"$",
"field",
"=",
"$",
"this",
"->",
"_properties",
"[",
"'fields'",
"]",
"[",
"$",
"key",
"]",
";",
"foreach",
"(",
"$",
"filter",
"as",
"$",
"func",
"=>",
"$",
"param",
")",
"{",
"if",
"(",
"is_numeric",
"(",
"$",
"func",
")",
")",
"{",
"$",
"func",
"=",
"$",
"param",
";",
"$",
"args",
"=",
"array",
"(",
")",
";",
"}",
"else",
"$",
"args",
"=",
"[",
"$",
"param",
"]",
";",
"$",
"function",
"=",
"$",
"func",
";",
"if",
"(",
"method_exists",
"(",
"$",
"validation",
",",
"$",
"func",
")",
")",
"$",
"func",
"=",
"array",
"(",
"$",
"validation",
",",
"$",
"func",
")",
";",
"elseif",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"func",
")",
"||",
"preg_match",
"(",
"'/^('",
".",
"self",
"::",
"Magic",
".",
"')/'",
",",
"$",
"func",
")",
")",
"$",
"func",
"=",
"array",
"(",
"$",
"this",
",",
"$",
"func",
")",
";",
"elseif",
"(",
"method_exists",
"(",
"$",
"moe",
",",
"$",
"func",
")",
")",
"$",
"func",
"=",
"array",
"(",
"$",
"moe",
",",
"$",
"func",
")",
";",
"array_unshift",
"(",
"$",
"args",
",",
"$",
"value",
")",
";",
"if",
"(",
"false",
"===",
"$",
"result",
"=",
"$",
"moe",
"->",
"call",
"(",
"$",
"func",
",",
"$",
"args",
")",
")",
"{",
"$",
"this",
"->",
"_messages",
"[",
"]",
"=",
"$",
"validation",
"->",
"message",
"(",
"$",
"function",
",",
"$",
"field",
",",
"$",
"value",
",",
"$",
"param",
")",
";",
"return",
"false",
";",
"}",
"else",
"is_bool",
"(",
"$",
"result",
")",
"||",
"$",
"value",
"=",
"$",
"result",
";",
"}",
"return",
"true",
";",
"}"
] |
Perform validation
We can use method in Base class or any method with full name call but
you need to define a message to override default message
Be aware when use a method
|
[
"Perform",
"validation",
"We",
"can",
"use",
"method",
"in",
"Base",
"class",
"or",
"any",
"method",
"with",
"full",
"name",
"call",
"but",
"you",
"need",
"to",
"define",
"a",
"message",
"to",
"override",
"default",
"message",
"Be",
"aware",
"when",
"use",
"a",
"method"
] |
f58ec75a3116d1a572782256e2b38bb9aab95e3c
|
https://github.com/eghojansu/moe/blob/f58ec75a3116d1a572782256e2b38bb9aab95e3c/src/AbstractModel.php#L972-L1005
|
21,347 |
chippyash/Assembly-Builder
|
src/chippyash/Assembler/Traits/ParameterGrabable.php
|
ParameterGrabable.grabFunctionParameters
|
static function grabFunctionParameters($class, $function, array $paramValues)
{
$declaredParams = (new \ReflectionMethod($class, $function))->getParameters();
$paramNames = array_map(function(\ReflectionParameter $v) {
return $v->getName();
},
$declaredParams
);
$paramDefaults = array_map(function(\ReflectionParameter $v) {
return $v->isOptional() ? $v->getDefaultValue() : null;
},
$declaredParams
);
return array_combine($paramNames, array_replace($paramDefaults, $paramValues));
}
|
php
|
static function grabFunctionParameters($class, $function, array $paramValues)
{
$declaredParams = (new \ReflectionMethod($class, $function))->getParameters();
$paramNames = array_map(function(\ReflectionParameter $v) {
return $v->getName();
},
$declaredParams
);
$paramDefaults = array_map(function(\ReflectionParameter $v) {
return $v->isOptional() ? $v->getDefaultValue() : null;
},
$declaredParams
);
return array_combine($paramNames, array_replace($paramDefaults, $paramValues));
}
|
[
"static",
"function",
"grabFunctionParameters",
"(",
"$",
"class",
",",
"$",
"function",
",",
"array",
"$",
"paramValues",
")",
"{",
"$",
"declaredParams",
"=",
"(",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"class",
",",
"$",
"function",
")",
")",
"->",
"getParameters",
"(",
")",
";",
"$",
"paramNames",
"=",
"array_map",
"(",
"function",
"(",
"\\",
"ReflectionParameter",
"$",
"v",
")",
"{",
"return",
"$",
"v",
"->",
"getName",
"(",
")",
";",
"}",
",",
"$",
"declaredParams",
")",
";",
"$",
"paramDefaults",
"=",
"array_map",
"(",
"function",
"(",
"\\",
"ReflectionParameter",
"$",
"v",
")",
"{",
"return",
"$",
"v",
"->",
"isOptional",
"(",
")",
"?",
"$",
"v",
"->",
"getDefaultValue",
"(",
")",
":",
"null",
";",
"}",
",",
"$",
"declaredParams",
")",
";",
"return",
"array_combine",
"(",
"$",
"paramNames",
",",
"array_replace",
"(",
"$",
"paramDefaults",
",",
"$",
"paramValues",
")",
")",
";",
"}"
] |
Return array keyed by parameter name of values passed into a class static function
@param string $class Name of class that has the method usually via __CLASS__
@param string $function Name of function to inspect usually via __FUNCTION__
@param array $paramValues array of actual values usually via func_get_args
@return array
|
[
"Return",
"array",
"keyed",
"by",
"parameter",
"name",
"of",
"values",
"passed",
"into",
"a",
"class",
"static",
"function"
] |
be477306b7a1c09b48ce9e100f9f6680035d0df3
|
https://github.com/chippyash/Assembly-Builder/blob/be477306b7a1c09b48ce9e100f9f6680035d0df3/src/chippyash/Assembler/Traits/ParameterGrabable.php#L45-L60
|
21,348 |
glynnforrest/blockade
|
src/Blockade/EventListener/FirewallListener.php
|
FirewallListener.onKernelRequest
|
public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
foreach ($this->firewalls as $firewall) {
//firewalls returns true for an exemption, so skip others
if (true === $firewall->check($request)) {
return;
}
}
}
|
php
|
public function onKernelRequest(GetResponseEvent $event)
{
$request = $event->getRequest();
foreach ($this->firewalls as $firewall) {
//firewalls returns true for an exemption, so skip others
if (true === $firewall->check($request)) {
return;
}
}
}
|
[
"public",
"function",
"onKernelRequest",
"(",
"GetResponseEvent",
"$",
"event",
")",
"{",
"$",
"request",
"=",
"$",
"event",
"->",
"getRequest",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"firewalls",
"as",
"$",
"firewall",
")",
"{",
"//firewalls returns true for an exemption, so skip others",
"if",
"(",
"true",
"===",
"$",
"firewall",
"->",
"check",
"(",
"$",
"request",
")",
")",
"{",
"return",
";",
"}",
"}",
"}"
] |
Respond to a REQUEST KernelEvent by validating the request
against the registered firewalls.
|
[
"Respond",
"to",
"a",
"REQUEST",
"KernelEvent",
"by",
"validating",
"the",
"request",
"against",
"the",
"registered",
"firewalls",
"."
] |
5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b
|
https://github.com/glynnforrest/blockade/blob/5dfc8b2fa7b9f7029a1bdaa7c50e32ee8665ab3b/src/Blockade/EventListener/FirewallListener.php#L61-L70
|
21,349 |
ekuiter/feature-php
|
FeaturePhp/Aspect/Aspect.php
|
Aspect.getRelativeFileTarget
|
public function getRelativeFileTarget($aspectKernelTarget) {
return fphp\Helper\Path::join(fphp\Helper\Path::rootPath(dirname($aspectKernelTarget)),
$this->fileSpecification->getTarget());
}
|
php
|
public function getRelativeFileTarget($aspectKernelTarget) {
return fphp\Helper\Path::join(fphp\Helper\Path::rootPath(dirname($aspectKernelTarget)),
$this->fileSpecification->getTarget());
}
|
[
"public",
"function",
"getRelativeFileTarget",
"(",
"$",
"aspectKernelTarget",
")",
"{",
"return",
"fphp",
"\\",
"Helper",
"\\",
"Path",
"::",
"join",
"(",
"fphp",
"\\",
"Helper",
"\\",
"Path",
"::",
"rootPath",
"(",
"dirname",
"(",
"$",
"aspectKernelTarget",
")",
")",
",",
"$",
"this",
"->",
"fileSpecification",
"->",
"getTarget",
"(",
")",
")",
";",
"}"
] |
Returns the path of the aspect's target file relative to the aspect kernel's target file.
@param string $aspectKernelTarget
@return string
|
[
"Returns",
"the",
"path",
"of",
"the",
"aspect",
"s",
"target",
"file",
"relative",
"to",
"the",
"aspect",
"kernel",
"s",
"target",
"file",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Aspect/Aspect.php#L68-L71
|
21,350 |
ekuiter/feature-php
|
FeaturePhp/Aspect/Aspect.php
|
Aspect.getClassName
|
public function getClassName() {
$fileSource = $this->fileSpecification->getSource();
return (new fphp\Helper\PhpParser())->parseFile($fileSource)->getExactlyOneClass($fileSource)->name;
}
|
php
|
public function getClassName() {
$fileSource = $this->fileSpecification->getSource();
return (new fphp\Helper\PhpParser())->parseFile($fileSource)->getExactlyOneClass($fileSource)->name;
}
|
[
"public",
"function",
"getClassName",
"(",
")",
"{",
"$",
"fileSource",
"=",
"$",
"this",
"->",
"fileSpecification",
"->",
"getSource",
"(",
")",
";",
"return",
"(",
"new",
"fphp",
"\\",
"Helper",
"\\",
"PhpParser",
"(",
")",
")",
"->",
"parseFile",
"(",
"$",
"fileSource",
")",
"->",
"getExactlyOneClass",
"(",
"$",
"fileSource",
")",
"->",
"name",
";",
"}"
] |
Returns the aspect's class name.
For this, the aspect's file has to be parsed.
@return string
|
[
"Returns",
"the",
"aspect",
"s",
"class",
"name",
".",
"For",
"this",
"the",
"aspect",
"s",
"file",
"has",
"to",
"be",
"parsed",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Aspect/Aspect.php#L78-L81
|
21,351 |
technote-space/wordpress-plugin-base
|
src/classes/models/lib/loader/controller/api.php
|
Api.register_ajax_script
|
private function register_ajax_script() {
return $this->register_script_common( function () {
return [
'endpoint' => $this->apply_filters( 'admin_ajax', admin_url( 'admin-ajax.php' ) ),
'nonce_key' => $this->get_nonce_key(),
'nonce_value' => $this->create_nonce(),
'is_admin_ajax' => true,
];
} );
}
|
php
|
private function register_ajax_script() {
return $this->register_script_common( function () {
return [
'endpoint' => $this->apply_filters( 'admin_ajax', admin_url( 'admin-ajax.php' ) ),
'nonce_key' => $this->get_nonce_key(),
'nonce_value' => $this->create_nonce(),
'is_admin_ajax' => true,
];
} );
}
|
[
"private",
"function",
"register_ajax_script",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"register_script_common",
"(",
"function",
"(",
")",
"{",
"return",
"[",
"'endpoint'",
"=>",
"$",
"this",
"->",
"apply_filters",
"(",
"'admin_ajax'",
",",
"admin_url",
"(",
"'admin-ajax.php'",
")",
")",
",",
"'nonce_key'",
"=>",
"$",
"this",
"->",
"get_nonce_key",
"(",
")",
",",
"'nonce_value'",
"=>",
"$",
"this",
"->",
"create_nonce",
"(",
")",
",",
"'is_admin_ajax'",
"=>",
"true",
",",
"]",
";",
"}",
")",
";",
"}"
] |
register script for admin-ajax.php
|
[
"register",
"script",
"for",
"admin",
"-",
"ajax",
".",
"php"
] |
02cfcba358432a2539af07a69d9db00ff7c14eac
|
https://github.com/technote-space/wordpress-plugin-base/blob/02cfcba358432a2539af07a69d9db00ff7c14eac/src/classes/models/lib/loader/controller/api.php#L177-L186
|
21,352 |
Eresus/EresusCMS
|
src/core/framework/core/Template/Template.php
|
TemplateSettings.getGlobalValue
|
public static function getGlobalValue($name)
{
return array_key_exists($name, self::$globalValues) ? self::$globalValues[$name] : null;
}
|
php
|
public static function getGlobalValue($name)
{
return array_key_exists($name, self::$globalValues) ? self::$globalValues[$name] : null;
}
|
[
"public",
"static",
"function",
"getGlobalValue",
"(",
"$",
"name",
")",
"{",
"return",
"array_key_exists",
"(",
"$",
"name",
",",
"self",
"::",
"$",
"globalValues",
")",
"?",
"self",
"::",
"$",
"globalValues",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}"
] |
Get global substitution value
@param string $name
@return null|mixed Null will be returned if value not set
|
[
"Get",
"global",
"substitution",
"value"
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/Template/Template.php#L61-L64
|
21,353 |
hametuha/wpametu
|
src/WPametu/API/RewriteParser.php
|
RewriteParser.invoke
|
protected function invoke($method_name, $request_method, array $arguments = []){
$method_name = strtolower($request_method).'_'.$this->str->to_snake_case($method_name);
// Check if method exists
if( !is_callable([$this, $method_name]) ){
return false;
}
// Check accessibility
$reflection = new \ReflectionMethod($this, $method_name);
if( !$reflection->isPublic() || $reflection->isStatic() ){
return false;
}
// Check required arguments length
if( $reflection->getNumberOfRequiredParameters() > count($arguments) ){
return false;
}
// O.K. It's public method. Call it.
$this->handle_result(call_user_func_array([$this, $method_name], $arguments));
return true;
}
|
php
|
protected function invoke($method_name, $request_method, array $arguments = []){
$method_name = strtolower($request_method).'_'.$this->str->to_snake_case($method_name);
// Check if method exists
if( !is_callable([$this, $method_name]) ){
return false;
}
// Check accessibility
$reflection = new \ReflectionMethod($this, $method_name);
if( !$reflection->isPublic() || $reflection->isStatic() ){
return false;
}
// Check required arguments length
if( $reflection->getNumberOfRequiredParameters() > count($arguments) ){
return false;
}
// O.K. It's public method. Call it.
$this->handle_result(call_user_func_array([$this, $method_name], $arguments));
return true;
}
|
[
"protected",
"function",
"invoke",
"(",
"$",
"method_name",
",",
"$",
"request_method",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"method_name",
"=",
"strtolower",
"(",
"$",
"request_method",
")",
".",
"'_'",
".",
"$",
"this",
"->",
"str",
"->",
"to_snake_case",
"(",
"$",
"method_name",
")",
";",
"// Check if method exists",
"if",
"(",
"!",
"is_callable",
"(",
"[",
"$",
"this",
",",
"$",
"method_name",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Check accessibility",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"$",
"this",
",",
"$",
"method_name",
")",
";",
"if",
"(",
"!",
"$",
"reflection",
"->",
"isPublic",
"(",
")",
"||",
"$",
"reflection",
"->",
"isStatic",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Check required arguments length",
"if",
"(",
"$",
"reflection",
"->",
"getNumberOfRequiredParameters",
"(",
")",
">",
"count",
"(",
"$",
"arguments",
")",
")",
"{",
"return",
"false",
";",
"}",
"// O.K. It's public method. Call it.",
"$",
"this",
"->",
"handle_result",
"(",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"$",
"method_name",
"]",
",",
"$",
"arguments",
")",
")",
";",
"return",
"true",
";",
"}"
] |
Search method and execute if exists.
@param string $method_name
@param string $request_method
@param array $arguments
@return bool
|
[
"Search",
"method",
"and",
"execute",
"if",
"exists",
"."
] |
0939373800815a8396291143d2a57967340da5aa
|
https://github.com/hametuha/wpametu/blob/0939373800815a8396291143d2a57967340da5aa/src/WPametu/API/RewriteParser.php#L61-L79
|
21,354 |
OpenBuildings/monetary
|
src/OpenBuildings/Monetary/Source/ECB.php
|
Source_ECB.convert_to_array
|
public function convert_to_array($raw_data)
{
$xml = new \SimpleXMLElement($raw_data);
$xml->registerXPathNamespace(
self::XML_NAMESPACE,
self::XML_NAMESPACE_URL
);
$data = $xml->xpath(self::XPATH_CURRENCY);
$currencies = array();
foreach ($data as $currency)
{
$currencies[ (string) $currency->attributes()->currency] = (string) $currency->attributes()->rate;
}
return $currencies;
}
|
php
|
public function convert_to_array($raw_data)
{
$xml = new \SimpleXMLElement($raw_data);
$xml->registerXPathNamespace(
self::XML_NAMESPACE,
self::XML_NAMESPACE_URL
);
$data = $xml->xpath(self::XPATH_CURRENCY);
$currencies = array();
foreach ($data as $currency)
{
$currencies[ (string) $currency->attributes()->currency] = (string) $currency->attributes()->rate;
}
return $currencies;
}
|
[
"public",
"function",
"convert_to_array",
"(",
"$",
"raw_data",
")",
"{",
"$",
"xml",
"=",
"new",
"\\",
"SimpleXMLElement",
"(",
"$",
"raw_data",
")",
";",
"$",
"xml",
"->",
"registerXPathNamespace",
"(",
"self",
"::",
"XML_NAMESPACE",
",",
"self",
"::",
"XML_NAMESPACE_URL",
")",
";",
"$",
"data",
"=",
"$",
"xml",
"->",
"xpath",
"(",
"self",
"::",
"XPATH_CURRENCY",
")",
";",
"$",
"currencies",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"currency",
")",
"{",
"$",
"currencies",
"[",
"(",
"string",
")",
"$",
"currency",
"->",
"attributes",
"(",
")",
"->",
"currency",
"]",
"=",
"(",
"string",
")",
"$",
"currency",
"->",
"attributes",
"(",
")",
"->",
"rate",
";",
"}",
"return",
"$",
"currencies",
";",
"}"
] |
Convert raw currency data to array of currencies
@param string $raw_data currency data in XML format
@return array currencies
|
[
"Convert",
"raw",
"currency",
"data",
"to",
"array",
"of",
"currencies"
] |
f7831ab055eaba7105f3f3530506b96de7fedd29
|
https://github.com/OpenBuildings/monetary/blob/f7831ab055eaba7105f3f3530506b96de7fedd29/src/OpenBuildings/Monetary/Source/ECB.php#L30-L47
|
21,355 |
FriendsOfApi/phraseapp
|
src/Api/Translation.php
|
Translation.indexLocale
|
public function indexLocale(string $projectKey, string $localeId, array $params = [])
{
if (isset($params['tags'])) {
$params['q'] = 'tags:'.$params['tags'];
unset($params['tags']);
}
$response = $this->httpGet(sprintf('/api/v2/projects/%s/locales/%s/translations', $projectKey, $localeId), $params);
if (!$this->hydrator) {
return $response;
}
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, Index::class);
}
|
php
|
public function indexLocale(string $projectKey, string $localeId, array $params = [])
{
if (isset($params['tags'])) {
$params['q'] = 'tags:'.$params['tags'];
unset($params['tags']);
}
$response = $this->httpGet(sprintf('/api/v2/projects/%s/locales/%s/translations', $projectKey, $localeId), $params);
if (!$this->hydrator) {
return $response;
}
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, Index::class);
}
|
[
"public",
"function",
"indexLocale",
"(",
"string",
"$",
"projectKey",
",",
"string",
"$",
"localeId",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'tags'",
"]",
")",
")",
"{",
"$",
"params",
"[",
"'q'",
"]",
"=",
"'tags:'",
".",
"$",
"params",
"[",
"'tags'",
"]",
";",
"unset",
"(",
"$",
"params",
"[",
"'tags'",
"]",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"httpGet",
"(",
"sprintf",
"(",
"'/api/v2/projects/%s/locales/%s/translations'",
",",
"$",
"projectKey",
",",
"$",
"localeId",
")",
",",
"$",
"params",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hydrator",
")",
"{",
"return",
"$",
"response",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"200",
"&&",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"201",
")",
"{",
"$",
"this",
"->",
"handleErrors",
"(",
"$",
"response",
")",
";",
"}",
"return",
"$",
"this",
"->",
"hydrator",
"->",
"hydrate",
"(",
"$",
"response",
",",
"Index",
"::",
"class",
")",
";",
"}"
] |
Index a locale.
@param string $projectKey
@param string $localeId
@param array $params
@return Index|ResponseInterface
|
[
"Index",
"a",
"locale",
"."
] |
1553bf857eb0858f9a7eb905b085864d24f80886
|
https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Api/Translation.php#L31-L49
|
21,356 |
FriendsOfApi/phraseapp
|
src/Api/Translation.php
|
Translation.create
|
public function create(string $projectKey, string $localeId, string $keyId, string $content, array $params = [])
{
$params['locale_id'] = $localeId;
$params['key_id'] = $keyId;
$params['content'] = $content;
$response = $this->httpPost(sprintf('/api/v2/projects/%s/translations', $projectKey), $params);
if (!$this->hydrator) {
return $response;
}
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, TranslationCreated::class);
}
|
php
|
public function create(string $projectKey, string $localeId, string $keyId, string $content, array $params = [])
{
$params['locale_id'] = $localeId;
$params['key_id'] = $keyId;
$params['content'] = $content;
$response = $this->httpPost(sprintf('/api/v2/projects/%s/translations', $projectKey), $params);
if (!$this->hydrator) {
return $response;
}
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, TranslationCreated::class);
}
|
[
"public",
"function",
"create",
"(",
"string",
"$",
"projectKey",
",",
"string",
"$",
"localeId",
",",
"string",
"$",
"keyId",
",",
"string",
"$",
"content",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"[",
"'locale_id'",
"]",
"=",
"$",
"localeId",
";",
"$",
"params",
"[",
"'key_id'",
"]",
"=",
"$",
"keyId",
";",
"$",
"params",
"[",
"'content'",
"]",
"=",
"$",
"content",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"httpPost",
"(",
"sprintf",
"(",
"'/api/v2/projects/%s/translations'",
",",
"$",
"projectKey",
")",
",",
"$",
"params",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hydrator",
")",
"{",
"return",
"$",
"response",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"200",
"&&",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"201",
")",
"{",
"$",
"this",
"->",
"handleErrors",
"(",
"$",
"response",
")",
";",
"}",
"return",
"$",
"this",
"->",
"hydrator",
"->",
"hydrate",
"(",
"$",
"response",
",",
"TranslationCreated",
"::",
"class",
")",
";",
"}"
] |
Create a translation.
@param string $projectKey
@param string $keyId
@param string $content
@param array $params
@return TranslationCreated|ResponseInterface
|
[
"Create",
"a",
"translation",
"."
] |
1553bf857eb0858f9a7eb905b085864d24f80886
|
https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Api/Translation.php#L61-L78
|
21,357 |
FriendsOfApi/phraseapp
|
src/Api/Translation.php
|
Translation.update
|
public function update(string $projectKey, string $translationId, string $content, array $params = [])
{
$params['content'] = $content;
$response = $this->httpPatch(sprintf('/api/v2/projects/%s/translations/%s', $projectKey, $translationId), $params);
if (!$this->hydrator) {
return $response;
}
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, TranslationUpdated::class);
}
|
php
|
public function update(string $projectKey, string $translationId, string $content, array $params = [])
{
$params['content'] = $content;
$response = $this->httpPatch(sprintf('/api/v2/projects/%s/translations/%s', $projectKey, $translationId), $params);
if (!$this->hydrator) {
return $response;
}
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, TranslationUpdated::class);
}
|
[
"public",
"function",
"update",
"(",
"string",
"$",
"projectKey",
",",
"string",
"$",
"translationId",
",",
"string",
"$",
"content",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"[",
"'content'",
"]",
"=",
"$",
"content",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"httpPatch",
"(",
"sprintf",
"(",
"'/api/v2/projects/%s/translations/%s'",
",",
"$",
"projectKey",
",",
"$",
"translationId",
")",
",",
"$",
"params",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hydrator",
")",
"{",
"return",
"$",
"response",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"200",
"&&",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"201",
")",
"{",
"$",
"this",
"->",
"handleErrors",
"(",
"$",
"response",
")",
";",
"}",
"return",
"$",
"this",
"->",
"hydrator",
"->",
"hydrate",
"(",
"$",
"response",
",",
"TranslationUpdated",
"::",
"class",
")",
";",
"}"
] |
Update a translation.
@param string $projectKey
@param string $translationId
@param string $content
@param array $params
@return TranslationUpdated|ResponseInterface
|
[
"Update",
"a",
"translation",
"."
] |
1553bf857eb0858f9a7eb905b085864d24f80886
|
https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Api/Translation.php#L90-L105
|
21,358 |
FriendsOfApi/phraseapp
|
src/Api/Translation.php
|
Translation.indexKey
|
public function indexKey(string $projectKey, string $keyId, array $params = [])
{
if (isset($params['tags'])) {
$params['q'] = 'tags:'.$params['tags'];
unset($params['tags']);
}
$response = $this->httpGet(sprintf('/api/v2/projects/%s/keys/%s/translations', $projectKey, $keyId), $params);
if (!$this->hydrator) {
return $response;
}
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, Index::class);
}
|
php
|
public function indexKey(string $projectKey, string $keyId, array $params = [])
{
if (isset($params['tags'])) {
$params['q'] = 'tags:'.$params['tags'];
unset($params['tags']);
}
$response = $this->httpGet(sprintf('/api/v2/projects/%s/keys/%s/translations', $projectKey, $keyId), $params);
if (!$this->hydrator) {
return $response;
}
if ($response->getStatusCode() !== 200 && $response->getStatusCode() !== 201) {
$this->handleErrors($response);
}
return $this->hydrator->hydrate($response, Index::class);
}
|
[
"public",
"function",
"indexKey",
"(",
"string",
"$",
"projectKey",
",",
"string",
"$",
"keyId",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'tags'",
"]",
")",
")",
"{",
"$",
"params",
"[",
"'q'",
"]",
"=",
"'tags:'",
".",
"$",
"params",
"[",
"'tags'",
"]",
";",
"unset",
"(",
"$",
"params",
"[",
"'tags'",
"]",
")",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"httpGet",
"(",
"sprintf",
"(",
"'/api/v2/projects/%s/keys/%s/translations'",
",",
"$",
"projectKey",
",",
"$",
"keyId",
")",
",",
"$",
"params",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hydrator",
")",
"{",
"return",
"$",
"response",
";",
"}",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"200",
"&&",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"!==",
"201",
")",
"{",
"$",
"this",
"->",
"handleErrors",
"(",
"$",
"response",
")",
";",
"}",
"return",
"$",
"this",
"->",
"hydrator",
"->",
"hydrate",
"(",
"$",
"response",
",",
"Index",
"::",
"class",
")",
";",
"}"
] |
List translations for a specific key.
@param string $projectKey
@param string $keyId
@param array $params
@return Index|ResponseInterface
|
[
"List",
"translations",
"for",
"a",
"specific",
"key",
"."
] |
1553bf857eb0858f9a7eb905b085864d24f80886
|
https://github.com/FriendsOfApi/phraseapp/blob/1553bf857eb0858f9a7eb905b085864d24f80886/src/Api/Translation.php#L116-L134
|
21,359 |
WellCommerce/AppBundle
|
Form/DataTransformer/TranslationTransformer.php
|
TranslationTransformer.transformTranslation
|
protected function transformTranslation(LocaleAwareInterface $translation, $fields, &$values)
{
foreach ($fields as $field) {
$values[$translation->getLocale()][$field] = $this->propertyAccessor->getValue($translation, $field);
}
}
|
php
|
protected function transformTranslation(LocaleAwareInterface $translation, $fields, &$values)
{
foreach ($fields as $field) {
$values[$translation->getLocale()][$field] = $this->propertyAccessor->getValue($translation, $field);
}
}
|
[
"protected",
"function",
"transformTranslation",
"(",
"LocaleAwareInterface",
"$",
"translation",
",",
"$",
"fields",
",",
"&",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"values",
"[",
"$",
"translation",
"->",
"getLocale",
"(",
")",
"]",
"[",
"$",
"field",
"]",
"=",
"$",
"this",
"->",
"propertyAccessor",
"->",
"getValue",
"(",
"$",
"translation",
",",
"$",
"field",
")",
";",
"}",
"}"
] |
Transforms single translation
@param LocaleAwareInterface $translation
@param array $fields
@param array $values
|
[
"Transforms",
"single",
"translation"
] |
2add687d1c898dd0b24afd611d896e3811a0eac3
|
https://github.com/WellCommerce/AppBundle/blob/2add687d1c898dd0b24afd611d896e3811a0eac3/Form/DataTransformer/TranslationTransformer.php#L55-L60
|
21,360 |
platformsh/platformsh-oauth2-php
|
src/GuzzleMiddleware.php
|
GuzzleMiddleware.isOAuth2
|
private function isOAuth2(RequestInterface $request, array $options)
{
// The 'auth' option must be set to 'oauth2'.
if (!isset($options['auth']) || $options['auth'] !== 'oauth2') {
return false;
}
// The request must be not for an access token endpoint.
if ($this->provider->getBaseAccessTokenUrl([]) === $request->getUri()) {
return false;
}
return true;
}
|
php
|
private function isOAuth2(RequestInterface $request, array $options)
{
// The 'auth' option must be set to 'oauth2'.
if (!isset($options['auth']) || $options['auth'] !== 'oauth2') {
return false;
}
// The request must be not for an access token endpoint.
if ($this->provider->getBaseAccessTokenUrl([]) === $request->getUri()) {
return false;
}
return true;
}
|
[
"private",
"function",
"isOAuth2",
"(",
"RequestInterface",
"$",
"request",
",",
"array",
"$",
"options",
")",
"{",
"// The 'auth' option must be set to 'oauth2'.",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'auth'",
"]",
")",
"||",
"$",
"options",
"[",
"'auth'",
"]",
"!==",
"'oauth2'",
")",
"{",
"return",
"false",
";",
"}",
"// The request must be not for an access token endpoint.",
"if",
"(",
"$",
"this",
"->",
"provider",
"->",
"getBaseAccessTokenUrl",
"(",
"[",
"]",
")",
"===",
"$",
"request",
"->",
"getUri",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Check if a request is configured to use OAuth2.
@param RequestInterface $request
@param array $options
@return bool
|
[
"Check",
"if",
"a",
"request",
"is",
"configured",
"to",
"use",
"OAuth2",
"."
] |
c5056b818f326e8ee358521224ac7f803d1e9d6b
|
https://github.com/platformsh/platformsh-oauth2-php/blob/c5056b818f326e8ee358521224ac7f803d1e9d6b/src/GuzzleMiddleware.php#L101-L114
|
21,361 |
platformsh/platformsh-oauth2-php
|
src/GuzzleMiddleware.php
|
GuzzleMiddleware.authenticateRequest
|
private function authenticateRequest(RequestInterface $request, AccessToken $token)
{
foreach ($this->provider->getHeaders($token->getToken()) as $name => $value) {
$request = $request->withHeader($name, $value);
}
return $request;
}
|
php
|
private function authenticateRequest(RequestInterface $request, AccessToken $token)
{
foreach ($this->provider->getHeaders($token->getToken()) as $name => $value) {
$request = $request->withHeader($name, $value);
}
return $request;
}
|
[
"private",
"function",
"authenticateRequest",
"(",
"RequestInterface",
"$",
"request",
",",
"AccessToken",
"$",
"token",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"provider",
"->",
"getHeaders",
"(",
"$",
"token",
"->",
"getToken",
"(",
")",
")",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"request",
"=",
"$",
"request",
"->",
"withHeader",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"request",
";",
"}"
] |
Add authentication to an HTTP request.
@param \Psr\Http\Message\RequestInterface $request
@param \League\OAuth2\Client\Token\AccessToken $token
@return \Psr\Http\Message\RequestInterface
|
[
"Add",
"authentication",
"to",
"an",
"HTTP",
"request",
"."
] |
c5056b818f326e8ee358521224ac7f803d1e9d6b
|
https://github.com/platformsh/platformsh-oauth2-php/blob/c5056b818f326e8ee358521224ac7f803d1e9d6b/src/GuzzleMiddleware.php#L124-L131
|
21,362 |
platformsh/platformsh-oauth2-php
|
src/GuzzleMiddleware.php
|
GuzzleMiddleware.getAccessToken
|
private function getAccessToken(AccessToken $invalid = null)
{
if (!isset($this->accessToken) || $this->accessToken->hasExpired() || ($invalid && $this->accessToken === $invalid)) {
$this->accessToken = $this->acquireAccessToken();
if (is_callable($this->tokenSave)) {
call_user_func($this->tokenSave, $this->accessToken);
}
}
return $this->accessToken;
}
|
php
|
private function getAccessToken(AccessToken $invalid = null)
{
if (!isset($this->accessToken) || $this->accessToken->hasExpired() || ($invalid && $this->accessToken === $invalid)) {
$this->accessToken = $this->acquireAccessToken();
if (is_callable($this->tokenSave)) {
call_user_func($this->tokenSave, $this->accessToken);
}
}
return $this->accessToken;
}
|
[
"private",
"function",
"getAccessToken",
"(",
"AccessToken",
"$",
"invalid",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"accessToken",
")",
"||",
"$",
"this",
"->",
"accessToken",
"->",
"hasExpired",
"(",
")",
"||",
"(",
"$",
"invalid",
"&&",
"$",
"this",
"->",
"accessToken",
"===",
"$",
"invalid",
")",
")",
"{",
"$",
"this",
"->",
"accessToken",
"=",
"$",
"this",
"->",
"acquireAccessToken",
"(",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"tokenSave",
")",
")",
"{",
"call_user_func",
"(",
"$",
"this",
"->",
"tokenSave",
",",
"$",
"this",
"->",
"accessToken",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"accessToken",
";",
"}"
] |
Get the current access token.
@param AccessToken|null $invalid
A token to consider invalid.
@return \League\OAuth2\Client\Token\AccessToken
The OAuth2 access token.
|
[
"Get",
"the",
"current",
"access",
"token",
"."
] |
c5056b818f326e8ee358521224ac7f803d1e9d6b
|
https://github.com/platformsh/platformsh-oauth2-php/blob/c5056b818f326e8ee358521224ac7f803d1e9d6b/src/GuzzleMiddleware.php#L142-L152
|
21,363 |
platformsh/platformsh-oauth2-php
|
src/GuzzleMiddleware.php
|
GuzzleMiddleware.acquireAccessToken
|
private function acquireAccessToken()
{
if (isset($this->accessToken) && $this->accessToken->getRefreshToken()) {
return $this->provider->getAccessToken(new RefreshToken(), ['refresh_token' => $this->accessToken->getRefreshToken()]);
}
return $this->provider->getAccessToken($this->grant, $this->grantOptions);
}
|
php
|
private function acquireAccessToken()
{
if (isset($this->accessToken) && $this->accessToken->getRefreshToken()) {
return $this->provider->getAccessToken(new RefreshToken(), ['refresh_token' => $this->accessToken->getRefreshToken()]);
}
return $this->provider->getAccessToken($this->grant, $this->grantOptions);
}
|
[
"private",
"function",
"acquireAccessToken",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"accessToken",
")",
"&&",
"$",
"this",
"->",
"accessToken",
"->",
"getRefreshToken",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"provider",
"->",
"getAccessToken",
"(",
"new",
"RefreshToken",
"(",
")",
",",
"[",
"'refresh_token'",
"=>",
"$",
"this",
"->",
"accessToken",
"->",
"getRefreshToken",
"(",
")",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"provider",
"->",
"getAccessToken",
"(",
"$",
"this",
"->",
"grant",
",",
"$",
"this",
"->",
"grantOptions",
")",
";",
"}"
] |
Acquire a new access token using a refresh token or the configured grant.
@return AccessToken
|
[
"Acquire",
"a",
"new",
"access",
"token",
"using",
"a",
"refresh",
"token",
"or",
"the",
"configured",
"grant",
"."
] |
c5056b818f326e8ee358521224ac7f803d1e9d6b
|
https://github.com/platformsh/platformsh-oauth2-php/blob/c5056b818f326e8ee358521224ac7f803d1e9d6b/src/GuzzleMiddleware.php#L159-L166
|
21,364 |
Innmind/neo4j-dbal
|
src/Query/Cypher.php
|
Cypher.withParameters
|
public function withParameters(array $parameters): self
{
$query = $this;
foreach ($parameters as $key => $parameter) {
$query = $query->withParameter($key, $parameter);
}
return $query;
}
|
php
|
public function withParameters(array $parameters): self
{
$query = $this;
foreach ($parameters as $key => $parameter) {
$query = $query->withParameter($key, $parameter);
}
return $query;
}
|
[
"public",
"function",
"withParameters",
"(",
"array",
"$",
"parameters",
")",
":",
"self",
"{",
"$",
"query",
"=",
"$",
"this",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"key",
"=>",
"$",
"parameter",
")",
"{",
"$",
"query",
"=",
"$",
"query",
"->",
"withParameter",
"(",
"$",
"key",
",",
"$",
"parameter",
")",
";",
"}",
"return",
"$",
"query",
";",
"}"
] |
Attach parameters to this query
@param array $parameters
@throws NonParametrableClause
@return self
|
[
"Attach",
"parameters",
"to",
"this",
"query"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Cypher.php#L72-L81
|
21,365 |
Innmind/neo4j-dbal
|
src/Query/Cypher.php
|
Cypher.withParameter
|
public function withParameter(string $key, $parameter): self
{
if (Str::of($key)->empty()) {
throw new DomainException;
}
$query = new self($this->cypher);
$query->parameters = $this->parameters->put(
$key,
new Parameter($key, $parameter)
);
return $query;
}
|
php
|
public function withParameter(string $key, $parameter): self
{
if (Str::of($key)->empty()) {
throw new DomainException;
}
$query = new self($this->cypher);
$query->parameters = $this->parameters->put(
$key,
new Parameter($key, $parameter)
);
return $query;
}
|
[
"public",
"function",
"withParameter",
"(",
"string",
"$",
"key",
",",
"$",
"parameter",
")",
":",
"self",
"{",
"if",
"(",
"Str",
"::",
"of",
"(",
"$",
"key",
")",
"->",
"empty",
"(",
")",
")",
"{",
"throw",
"new",
"DomainException",
";",
"}",
"$",
"query",
"=",
"new",
"self",
"(",
"$",
"this",
"->",
"cypher",
")",
";",
"$",
"query",
"->",
"parameters",
"=",
"$",
"this",
"->",
"parameters",
"->",
"put",
"(",
"$",
"key",
",",
"new",
"Parameter",
"(",
"$",
"key",
",",
"$",
"parameter",
")",
")",
";",
"return",
"$",
"query",
";",
"}"
] |
Attach the given parameter to this query
@param string $key
@param mixed $parameter
@throws NonParametrableClause
@return self
|
[
"Attach",
"the",
"given",
"parameter",
"to",
"this",
"query"
] |
12cb71e698cc0f4d55b7f2eb40f7b353c778a20b
|
https://github.com/Innmind/neo4j-dbal/blob/12cb71e698cc0f4d55b7f2eb40f7b353c778a20b/src/Query/Cypher.php#L93-L106
|
21,366 |
inhere/php-librarys
|
src/Files/FileFinder.php
|
FileFinder.filterResult
|
public function filterResult(callable $filter)
{
$result = [];
foreach ($this->files as $file) {
if ($filter($file)) {
$result[] = $file;
}
}
return $result;
}
|
php
|
public function filterResult(callable $filter)
{
$result = [];
foreach ($this->files as $file) {
if ($filter($file)) {
$result[] = $file;
}
}
return $result;
}
|
[
"public",
"function",
"filterResult",
"(",
"callable",
"$",
"filter",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"files",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"filter",
"(",
"$",
"file",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"file",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] |
Further filtering the find result set
@param callable $filter
e.g:
$filter = function($file) {
if (false !== strpos($file, 'jqu') ) {
return true;
}
return false;
};
@return array
|
[
"Further",
"filtering",
"the",
"find",
"result",
"set"
] |
e6ca598685469794f310e3ab0e2bc19519cd0ae6
|
https://github.com/inhere/php-librarys/blob/e6ca598685469794f310e3ab0e2bc19519cd0ae6/src/Files/FileFinder.php#L207-L218
|
21,367 |
Eresus/EresusCMS
|
src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/file.php
|
ezcMailFilePart.setHeaderContentType
|
private function setHeaderContentType()
{
$fileName = basename( $this->fileName );
if ( $this->contentDisposition !== null && $this->contentDisposition->fileName !== null )
{
$fileName = $this->contentDisposition->fileName;
}
$this->setHeader( 'Content-Type',
$this->contentType . '/' . $this->mimeType . '; ' . 'name="' . $fileName . '"' );
}
|
php
|
private function setHeaderContentType()
{
$fileName = basename( $this->fileName );
if ( $this->contentDisposition !== null && $this->contentDisposition->fileName !== null )
{
$fileName = $this->contentDisposition->fileName;
}
$this->setHeader( 'Content-Type',
$this->contentType . '/' . $this->mimeType . '; ' . 'name="' . $fileName . '"' );
}
|
[
"private",
"function",
"setHeaderContentType",
"(",
")",
"{",
"$",
"fileName",
"=",
"basename",
"(",
"$",
"this",
"->",
"fileName",
")",
";",
"if",
"(",
"$",
"this",
"->",
"contentDisposition",
"!==",
"null",
"&&",
"$",
"this",
"->",
"contentDisposition",
"->",
"fileName",
"!==",
"null",
")",
"{",
"$",
"fileName",
"=",
"$",
"this",
"->",
"contentDisposition",
"->",
"fileName",
";",
"}",
"$",
"this",
"->",
"setHeader",
"(",
"'Content-Type'",
",",
"$",
"this",
"->",
"contentType",
".",
"'/'",
".",
"$",
"this",
"->",
"mimeType",
".",
"'; '",
".",
"'name=\"'",
".",
"$",
"fileName",
".",
"'\"'",
")",
";",
"}"
] |
Sets the Content-Type header.
Based on the contentType, mimeType and fileName.
|
[
"Sets",
"the",
"Content",
"-",
"Type",
"header",
"."
] |
b0afc661105f0a2f65d49abac13956cc93c5188d
|
https://github.com/Eresus/EresusCMS/blob/b0afc661105f0a2f65d49abac13956cc93c5188d/src/core/framework/core/3rdparty/ezcomponents/Mail/src/parts/file.php#L184-L194
|
21,368 |
robbertkl/simplepdf
|
classes/SimplePdf/Page.php
|
Page.setMargins
|
public function setMargins($marginLeft, $marginRight, $marginTop, $marginBottom)
{
$this->setLeftMargin($marginLeft);
$this->setRightMargin($marginRight);
$this->setTopMargin($marginTop);
$this->setBottomMargin($marginBottom);
return $this;
}
|
php
|
public function setMargins($marginLeft, $marginRight, $marginTop, $marginBottom)
{
$this->setLeftMargin($marginLeft);
$this->setRightMargin($marginRight);
$this->setTopMargin($marginTop);
$this->setBottomMargin($marginBottom);
return $this;
}
|
[
"public",
"function",
"setMargins",
"(",
"$",
"marginLeft",
",",
"$",
"marginRight",
",",
"$",
"marginTop",
",",
"$",
"marginBottom",
")",
"{",
"$",
"this",
"->",
"setLeftMargin",
"(",
"$",
"marginLeft",
")",
";",
"$",
"this",
"->",
"setRightMargin",
"(",
"$",
"marginRight",
")",
";",
"$",
"this",
"->",
"setTopMargin",
"(",
"$",
"marginTop",
")",
";",
"$",
"this",
"->",
"setBottomMargin",
"(",
"$",
"marginBottom",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Set new margin, in the given units
@param float $marginLeft new left margin, in the given units
@param float $marginRight new right margin, in the given units
@param float $marginTop new top margin, in the given units
@param float $marginBottom new bottom margin, in the given units
@return \SimplePdf\Page this page
|
[
"Set",
"new",
"margin",
"in",
"the",
"given",
"units"
] |
f19cea8d4e52fe76d4fa447b411514dee688adbc
|
https://github.com/robbertkl/simplepdf/blob/f19cea8d4e52fe76d4fa447b411514dee688adbc/classes/SimplePdf/Page.php#L326-L333
|
21,369 |
robbertkl/simplepdf
|
classes/SimplePdf/Page.php
|
Page.setFont
|
public function setFont(\ZendPdf\Resource\Font\AbstractFont $font, $fontSize = null)
{
if (is_null($fontSize)) {
$fontSize = $this->getFontSize();
}
return parent::setFont($font, $fontSize);
}
|
php
|
public function setFont(\ZendPdf\Resource\Font\AbstractFont $font, $fontSize = null)
{
if (is_null($fontSize)) {
$fontSize = $this->getFontSize();
}
return parent::setFont($font, $fontSize);
}
|
[
"public",
"function",
"setFont",
"(",
"\\",
"ZendPdf",
"\\",
"Resource",
"\\",
"Font",
"\\",
"AbstractFont",
"$",
"font",
",",
"$",
"fontSize",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"fontSize",
")",
")",
"{",
"$",
"fontSize",
"=",
"$",
"this",
"->",
"getFontSize",
"(",
")",
";",
"}",
"return",
"parent",
"::",
"setFont",
"(",
"$",
"font",
",",
"$",
"fontSize",
")",
";",
"}"
] |
Sets a new font family and, optionally, a new font size as well
@param \ZendPdf\Resource\Font\AbstractFont $font font object to use
@param float $fontSize new font size, leave it out to keep the current font size
|
[
"Sets",
"a",
"new",
"font",
"family",
"and",
"optionally",
"a",
"new",
"font",
"size",
"as",
"well"
] |
f19cea8d4e52fe76d4fa447b411514dee688adbc
|
https://github.com/robbertkl/simplepdf/blob/f19cea8d4e52fe76d4fa447b411514dee688adbc/classes/SimplePdf/Page.php#L373-L380
|
21,370 |
robbertkl/simplepdf
|
classes/SimplePdf/Page.php
|
Page.wordWrapText
|
public function wordWrapText($text, $wrapWidth)
{
$wrappedText = '';
foreach (explode(PHP_EOL, $text) as $line) {
$words = explode(' ', $line);
$currentLine = array_shift($words);
while (count($words) > 0) {
$word = array_shift($words);
if ($this->getTextWidth($currentLine . ' ' . $word) > $wrapWidth) {
$wrappedText .= PHP_EOL . $currentLine;
$currentLine = $word;
} else {
$currentLine .= ' ' . $word;
}
}
$wrappedText .= PHP_EOL . $currentLine;
}
return ltrim($wrappedText, PHP_EOL);
}
|
php
|
public function wordWrapText($text, $wrapWidth)
{
$wrappedText = '';
foreach (explode(PHP_EOL, $text) as $line) {
$words = explode(' ', $line);
$currentLine = array_shift($words);
while (count($words) > 0) {
$word = array_shift($words);
if ($this->getTextWidth($currentLine . ' ' . $word) > $wrapWidth) {
$wrappedText .= PHP_EOL . $currentLine;
$currentLine = $word;
} else {
$currentLine .= ' ' . $word;
}
}
$wrappedText .= PHP_EOL . $currentLine;
}
return ltrim($wrappedText, PHP_EOL);
}
|
[
"public",
"function",
"wordWrapText",
"(",
"$",
"text",
",",
"$",
"wrapWidth",
")",
"{",
"$",
"wrappedText",
"=",
"''",
";",
"foreach",
"(",
"explode",
"(",
"PHP_EOL",
",",
"$",
"text",
")",
"as",
"$",
"line",
")",
"{",
"$",
"words",
"=",
"explode",
"(",
"' '",
",",
"$",
"line",
")",
";",
"$",
"currentLine",
"=",
"array_shift",
"(",
"$",
"words",
")",
";",
"while",
"(",
"count",
"(",
"$",
"words",
")",
">",
"0",
")",
"{",
"$",
"word",
"=",
"array_shift",
"(",
"$",
"words",
")",
";",
"if",
"(",
"$",
"this",
"->",
"getTextWidth",
"(",
"$",
"currentLine",
".",
"' '",
".",
"$",
"word",
")",
">",
"$",
"wrapWidth",
")",
"{",
"$",
"wrappedText",
".=",
"PHP_EOL",
".",
"$",
"currentLine",
";",
"$",
"currentLine",
"=",
"$",
"word",
";",
"}",
"else",
"{",
"$",
"currentLine",
".=",
"' '",
".",
"$",
"word",
";",
"}",
"}",
"$",
"wrappedText",
".=",
"PHP_EOL",
".",
"$",
"currentLine",
";",
"}",
"return",
"ltrim",
"(",
"$",
"wrappedText",
",",
"PHP_EOL",
")",
";",
"}"
] |
Word-wrap a text to a certain width, using the current font properties
@param string $text text to wrap (can already contain some newlines)
@param string $wrapWidth width (in the given units) to wrap the text to
@return string the same text but with newlines inserted at the specified $wrapWidth
|
[
"Word",
"-",
"wrap",
"a",
"text",
"to",
"a",
"certain",
"width",
"using",
"the",
"current",
"font",
"properties"
] |
f19cea8d4e52fe76d4fa447b411514dee688adbc
|
https://github.com/robbertkl/simplepdf/blob/f19cea8d4e52fe76d4fa447b411514dee688adbc/classes/SimplePdf/Page.php#L433-L451
|
21,371 |
heidelpay/PhpDoc
|
src/phpDocumentor/Plugin/Core/Transformer/Writer/Sourcecode.php
|
Sourcecode.transform
|
public function transform(ProjectDescriptor $project, Transformation $transformation)
{
$artifact = $transformation->getTransformer()->getTarget()
. DIRECTORY_SEPARATOR
. ($transformation->getArtifact()
? $transformation->getArtifact()
: 'source');
/** @var FileDescriptor $file */
foreach ($project->getFiles() as $file) {
$filename = $file->getPath();
$source = $file->getSource();
$root = str_repeat('../', count(explode(DIRECTORY_SEPARATOR, $filename)));
$path = $artifact . DIRECTORY_SEPARATOR . $filename;
if (!file_exists(dirname($path))) {
mkdir(dirname($path), 0755, true);
}
$source = htmlentities($source);
file_put_contents(
$path.'.html',
<<<HTML
<html>
<head>
<script
type="text/javascript"
src="{$root}js/jquery-1.4.2.min.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shCore.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shBrushJScript.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shBrushPhp.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shBrushXml.js">
</script>
<link
href="{$root}syntax_highlighter/styles/shCore.css" rel="stylesheet"
type="text/css"
/>
<link
href="{$root}syntax_highlighter/styles/shCoreEclipse.css"
rel="stylesheet" type="text/css"
/>
<link
href="{$root}syntax_highlighter/styles/shThemeWordpress.css"
rel="stylesheet" type="text/css"
/>
</head>
<body>
<pre class="brush: php">$source</pre>
<script type="text/javascript">
SyntaxHighlighter.all();
jQuery('.gutter div').each(function(key, data){
jQuery(data).prepend('<a name="L'+jQuery(data).text()+'"/>');
});
</script>
</body>
</html>
HTML
);
}
}
|
php
|
public function transform(ProjectDescriptor $project, Transformation $transformation)
{
$artifact = $transformation->getTransformer()->getTarget()
. DIRECTORY_SEPARATOR
. ($transformation->getArtifact()
? $transformation->getArtifact()
: 'source');
/** @var FileDescriptor $file */
foreach ($project->getFiles() as $file) {
$filename = $file->getPath();
$source = $file->getSource();
$root = str_repeat('../', count(explode(DIRECTORY_SEPARATOR, $filename)));
$path = $artifact . DIRECTORY_SEPARATOR . $filename;
if (!file_exists(dirname($path))) {
mkdir(dirname($path), 0755, true);
}
$source = htmlentities($source);
file_put_contents(
$path.'.html',
<<<HTML
<html>
<head>
<script
type="text/javascript"
src="{$root}js/jquery-1.4.2.min.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shCore.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shBrushJScript.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shBrushPhp.js">
</script>
<script
type="text/javascript"
src="{$root}syntax_highlighter/scripts/shBrushXml.js">
</script>
<link
href="{$root}syntax_highlighter/styles/shCore.css" rel="stylesheet"
type="text/css"
/>
<link
href="{$root}syntax_highlighter/styles/shCoreEclipse.css"
rel="stylesheet" type="text/css"
/>
<link
href="{$root}syntax_highlighter/styles/shThemeWordpress.css"
rel="stylesheet" type="text/css"
/>
</head>
<body>
<pre class="brush: php">$source</pre>
<script type="text/javascript">
SyntaxHighlighter.all();
jQuery('.gutter div').each(function(key, data){
jQuery(data).prepend('<a name="L'+jQuery(data).text()+'"/>');
});
</script>
</body>
</html>
HTML
);
}
}
|
[
"public",
"function",
"transform",
"(",
"ProjectDescriptor",
"$",
"project",
",",
"Transformation",
"$",
"transformation",
")",
"{",
"$",
"artifact",
"=",
"$",
"transformation",
"->",
"getTransformer",
"(",
")",
"->",
"getTarget",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"(",
"$",
"transformation",
"->",
"getArtifact",
"(",
")",
"?",
"$",
"transformation",
"->",
"getArtifact",
"(",
")",
":",
"'source'",
")",
";",
"/** @var FileDescriptor $file */",
"foreach",
"(",
"$",
"project",
"->",
"getFiles",
"(",
")",
"as",
"$",
"file",
")",
"{",
"$",
"filename",
"=",
"$",
"file",
"->",
"getPath",
"(",
")",
";",
"$",
"source",
"=",
"$",
"file",
"->",
"getSource",
"(",
")",
";",
"$",
"root",
"=",
"str_repeat",
"(",
"'../'",
",",
"count",
"(",
"explode",
"(",
"DIRECTORY_SEPARATOR",
",",
"$",
"filename",
")",
")",
")",
";",
"$",
"path",
"=",
"$",
"artifact",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"filename",
";",
"if",
"(",
"!",
"file_exists",
"(",
"dirname",
"(",
"$",
"path",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"path",
")",
",",
"0755",
",",
"true",
")",
";",
"}",
"$",
"source",
"=",
"htmlentities",
"(",
"$",
"source",
")",
";",
"file_put_contents",
"(",
"$",
"path",
".",
"'.html'",
",",
"\n <<<HTML\n<html>\n <head>\n <script\n type=\"text/javascript\"\n src=\"{$root}js/jquery-1.4.2.min.js\">\n </script>\n <script\n type=\"text/javascript\"\n src=\"{$root}syntax_highlighter/scripts/shCore.js\">\n </script>\n <script\n type=\"text/javascript\"\n src=\"{$root}syntax_highlighter/scripts/shBrushJScript.js\">\n </script>\n <script\n type=\"text/javascript\"\n src=\"{$root}syntax_highlighter/scripts/shBrushPhp.js\">\n </script>\n <script\n type=\"text/javascript\"\n src=\"{$root}syntax_highlighter/scripts/shBrushXml.js\">\n </script>\n <link\n href=\"{$root}syntax_highlighter/styles/shCore.css\" rel=\"stylesheet\"\n type=\"text/css\"\n />\n <link\n href=\"{$root}syntax_highlighter/styles/shCoreEclipse.css\"\n rel=\"stylesheet\" type=\"text/css\"\n />\n <link\n href=\"{$root}syntax_highlighter/styles/shThemeWordpress.css\"\n rel=\"stylesheet\" type=\"text/css\"\n />\n </head>\n <body>\n <pre class=\"brush: php\">$source</pre>\n <script type=\"text/javascript\">\n SyntaxHighlighter.all();\n jQuery('.gutter div').each(function(key, data){\n jQuery(data).prepend('<a name=\"L'+jQuery(data).text()+'\"/>');\n });\n </script>\n </body>\n</html>\nHTML",
")",
";",
"}",
"}"
] |
This method writes every source code entry in the structure file to a highlighted file.
@param ProjectDescriptor $project Document containing the structure.
@param Transformation $transformation Transformation to execute.
@return void
|
[
"This",
"method",
"writes",
"every",
"source",
"code",
"entry",
"in",
"the",
"structure",
"file",
"to",
"a",
"highlighted",
"file",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Plugin/Core/Transformer/Writer/Sourcecode.php#L32-L103
|
21,372 |
david-mk/mail-map
|
src/MailMap/Mail.php
|
Mail.setHeaderAttributes
|
private function setHeaderAttributes(array $mailHeader)
{
$mailHeader = array_filter($mailHeader, function ($property) {
return property_exists($this, $property);
}, ARRAY_FILTER_USE_KEY);
foreach ($mailHeader as $property => $header) {
$this->{$property} = $header;
}
}
|
php
|
private function setHeaderAttributes(array $mailHeader)
{
$mailHeader = array_filter($mailHeader, function ($property) {
return property_exists($this, $property);
}, ARRAY_FILTER_USE_KEY);
foreach ($mailHeader as $property => $header) {
$this->{$property} = $header;
}
}
|
[
"private",
"function",
"setHeaderAttributes",
"(",
"array",
"$",
"mailHeader",
")",
"{",
"$",
"mailHeader",
"=",
"array_filter",
"(",
"$",
"mailHeader",
",",
"function",
"(",
"$",
"property",
")",
"{",
"return",
"property_exists",
"(",
"$",
"this",
",",
"$",
"property",
")",
";",
"}",
",",
"ARRAY_FILTER_USE_KEY",
")",
";",
"foreach",
"(",
"$",
"mailHeader",
"as",
"$",
"property",
"=>",
"$",
"header",
")",
"{",
"$",
"this",
"->",
"{",
"$",
"property",
"}",
"=",
"$",
"header",
";",
"}",
"}"
] |
Set attributes on email from header
@param array $mailHeader
@return void
|
[
"Set",
"attributes",
"on",
"email",
"from",
"header"
] |
4eea346ece9fa35c0d309b5a909f657ad83e1e6a
|
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/Mail.php#L173-L182
|
21,373 |
david-mk/mail-map
|
src/MailMap/Mail.php
|
Mail.header
|
public function header($key, $default = null)
{
if (array_key_exists($key, $this->headers)) {
return $this->headers[$key];
}
return $default;
}
|
php
|
public function header($key, $default = null)
{
if (array_key_exists($key, $this->headers)) {
return $this->headers[$key];
}
return $default;
}
|
[
"public",
"function",
"header",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"headers",
")",
")",
"{",
"return",
"$",
"this",
"->",
"headers",
"[",
"$",
"key",
"]",
";",
"}",
"return",
"$",
"default",
";",
"}"
] |
Get a header value. Return given default if none found
@param string $key
@param mixed $default
@return mixed
|
[
"Get",
"a",
"header",
"value",
".",
"Return",
"given",
"default",
"if",
"none",
"found"
] |
4eea346ece9fa35c0d309b5a909f657ad83e1e6a
|
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/Mail.php#L201-L208
|
21,374 |
david-mk/mail-map
|
src/MailMap/Mail.php
|
Mail.body
|
public function body($mimeType = 'html')
{
$body = [];
foreach ($this->body as $part) {
if ($part->mime_type === $mimeType) {
$body[] = $part->body;
}
}
return implode(static::partSeparator($mimeType), $body);
}
|
php
|
public function body($mimeType = 'html')
{
$body = [];
foreach ($this->body as $part) {
if ($part->mime_type === $mimeType) {
$body[] = $part->body;
}
}
return implode(static::partSeparator($mimeType), $body);
}
|
[
"public",
"function",
"body",
"(",
"$",
"mimeType",
"=",
"'html'",
")",
"{",
"$",
"body",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"body",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"$",
"part",
"->",
"mime_type",
"===",
"$",
"mimeType",
")",
"{",
"$",
"body",
"[",
"]",
"=",
"$",
"part",
"->",
"body",
";",
"}",
"}",
"return",
"implode",
"(",
"static",
"::",
"partSeparator",
"(",
"$",
"mimeType",
")",
",",
"$",
"body",
")",
";",
"}"
] |
Render the email body as the given mime-type
@param string $mimeType
@return string
|
[
"Render",
"the",
"email",
"body",
"as",
"the",
"given",
"mime",
"-",
"type"
] |
4eea346ece9fa35c0d309b5a909f657ad83e1e6a
|
https://github.com/david-mk/mail-map/blob/4eea346ece9fa35c0d309b5a909f657ad83e1e6a/src/MailMap/Mail.php#L216-L227
|
21,375 |
ekuiter/feature-php
|
FeaturePhp/Artifact/TracingLinkRenderer.php
|
TracingLinkRenderer._render
|
public function _render($textOnly) {
$tracingLinkNum = count($this->tracingLinks);
$str = "";
if ($textOnly) {
$str .= "\nFeature Traceability\n====================\n" .
"The following $tracingLinkNum tracing links were found:\n\n";
$maxLen = fphp\Helper\_String::getMaxLength($this->tracingLinks, "getFeatureName")
+ fphp\Helper\_String::getMaxLength($this->tracingLinks, "getType");
foreach ($this->tracingLinks as $tracingLink)
$str .= $this->analyzeTracingLink($tracingLink, true, $maxLen);
} else {
$str .= "<h2>Feature Traceability</h2>";
$str .= "<p>The following $tracingLinkNum tracing links were found:</p>";
$str .= "<table cellpadding='2'>";
$str .= "<tr align='left'><th>Feature</th><th>Type</th><th>Source</th><th>Target</th></tr>";
foreach ($this->tracingLinks as $tracingLink)
$str .= $this->analyzeTracingLink($tracingLink);
$str .= "</table>";
}
return $str;
}
|
php
|
public function _render($textOnly) {
$tracingLinkNum = count($this->tracingLinks);
$str = "";
if ($textOnly) {
$str .= "\nFeature Traceability\n====================\n" .
"The following $tracingLinkNum tracing links were found:\n\n";
$maxLen = fphp\Helper\_String::getMaxLength($this->tracingLinks, "getFeatureName")
+ fphp\Helper\_String::getMaxLength($this->tracingLinks, "getType");
foreach ($this->tracingLinks as $tracingLink)
$str .= $this->analyzeTracingLink($tracingLink, true, $maxLen);
} else {
$str .= "<h2>Feature Traceability</h2>";
$str .= "<p>The following $tracingLinkNum tracing links were found:</p>";
$str .= "<table cellpadding='2'>";
$str .= "<tr align='left'><th>Feature</th><th>Type</th><th>Source</th><th>Target</th></tr>";
foreach ($this->tracingLinks as $tracingLink)
$str .= $this->analyzeTracingLink($tracingLink);
$str .= "</table>";
}
return $str;
}
|
[
"public",
"function",
"_render",
"(",
"$",
"textOnly",
")",
"{",
"$",
"tracingLinkNum",
"=",
"count",
"(",
"$",
"this",
"->",
"tracingLinks",
")",
";",
"$",
"str",
"=",
"\"\"",
";",
"if",
"(",
"$",
"textOnly",
")",
"{",
"$",
"str",
".=",
"\"\\nFeature Traceability\\n====================\\n\"",
".",
"\"The following $tracingLinkNum tracing links were found:\\n\\n\"",
";",
"$",
"maxLen",
"=",
"fphp",
"\\",
"Helper",
"\\",
"_String",
"::",
"getMaxLength",
"(",
"$",
"this",
"->",
"tracingLinks",
",",
"\"getFeatureName\"",
")",
"+",
"fphp",
"\\",
"Helper",
"\\",
"_String",
"::",
"getMaxLength",
"(",
"$",
"this",
"->",
"tracingLinks",
",",
"\"getType\"",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"tracingLinks",
"as",
"$",
"tracingLink",
")",
"$",
"str",
".=",
"$",
"this",
"->",
"analyzeTracingLink",
"(",
"$",
"tracingLink",
",",
"true",
",",
"$",
"maxLen",
")",
";",
"}",
"else",
"{",
"$",
"str",
".=",
"\"<h2>Feature Traceability</h2>\"",
";",
"$",
"str",
".=",
"\"<p>The following $tracingLinkNum tracing links were found:</p>\"",
";",
"$",
"str",
".=",
"\"<table cellpadding='2'>\"",
";",
"$",
"str",
".=",
"\"<tr align='left'><th>Feature</th><th>Type</th><th>Source</th><th>Target</th></tr>\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"tracingLinks",
"as",
"$",
"tracingLink",
")",
"$",
"str",
".=",
"$",
"this",
"->",
"analyzeTracingLink",
"(",
"$",
"tracingLink",
")",
";",
"$",
"str",
".=",
"\"</table>\"",
";",
"}",
"return",
"$",
"str",
";",
"}"
] |
Returns the tracing link analysis.
@param bool $textOnly whether to render text or HTML
@return string
|
[
"Returns",
"the",
"tracing",
"link",
"analysis",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Artifact/TracingLinkRenderer.php#L33-L55
|
21,376 |
ekuiter/feature-php
|
FeaturePhp/Artifact/TracingLinkRenderer.php
|
TracingLinkRenderer.analyzeTracingLink
|
private function analyzeTracingLink($tracingLink, $textOnly = false, $maxLen = 0) {
$maxLen += strlen($this->defaultColor);
if ($textOnly)
return sprintf("$this->accentColor%-{$maxLen}s %s\n%{$maxLen}s %s\n",
$tracingLink->getFeatureName() . "$this->defaultColor " . $tracingLink->getType(),
$tracingLink->getSourcePlace()->getSummary(),
$this->defaultColor, $tracingLink->getTargetPlace()->getSummary());
else
return "<tr><td><span class='feature'>"
. $tracingLink->getFeatureName()
. "</span></td><td>" . $tracingLink->getType()
. "</td><td>" . $tracingLink->getSourcePlace()->getSummary()
. "</td><td>" . $tracingLink->getTargetPlace()->getSummary() . "</td></tr>";
}
|
php
|
private function analyzeTracingLink($tracingLink, $textOnly = false, $maxLen = 0) {
$maxLen += strlen($this->defaultColor);
if ($textOnly)
return sprintf("$this->accentColor%-{$maxLen}s %s\n%{$maxLen}s %s\n",
$tracingLink->getFeatureName() . "$this->defaultColor " . $tracingLink->getType(),
$tracingLink->getSourcePlace()->getSummary(),
$this->defaultColor, $tracingLink->getTargetPlace()->getSummary());
else
return "<tr><td><span class='feature'>"
. $tracingLink->getFeatureName()
. "</span></td><td>" . $tracingLink->getType()
. "</td><td>" . $tracingLink->getSourcePlace()->getSummary()
. "</td><td>" . $tracingLink->getTargetPlace()->getSummary() . "</td></tr>";
}
|
[
"private",
"function",
"analyzeTracingLink",
"(",
"$",
"tracingLink",
",",
"$",
"textOnly",
"=",
"false",
",",
"$",
"maxLen",
"=",
"0",
")",
"{",
"$",
"maxLen",
"+=",
"strlen",
"(",
"$",
"this",
"->",
"defaultColor",
")",
";",
"if",
"(",
"$",
"textOnly",
")",
"return",
"sprintf",
"(",
"\"$this->accentColor%-{$maxLen}s %s\\n%{$maxLen}s %s\\n\"",
",",
"$",
"tracingLink",
"->",
"getFeatureName",
"(",
")",
".",
"\"$this->defaultColor \"",
".",
"$",
"tracingLink",
"->",
"getType",
"(",
")",
",",
"$",
"tracingLink",
"->",
"getSourcePlace",
"(",
")",
"->",
"getSummary",
"(",
")",
",",
"$",
"this",
"->",
"defaultColor",
",",
"$",
"tracingLink",
"->",
"getTargetPlace",
"(",
")",
"->",
"getSummary",
"(",
")",
")",
";",
"else",
"return",
"\"<tr><td><span class='feature'>\"",
".",
"$",
"tracingLink",
"->",
"getFeatureName",
"(",
")",
".",
"\"</span></td><td>\"",
".",
"$",
"tracingLink",
"->",
"getType",
"(",
")",
".",
"\"</td><td>\"",
".",
"$",
"tracingLink",
"->",
"getSourcePlace",
"(",
")",
"->",
"getSummary",
"(",
")",
".",
"\"</td><td>\"",
".",
"$",
"tracingLink",
"->",
"getTargetPlace",
"(",
")",
"->",
"getSummary",
"(",
")",
".",
"\"</td></tr>\"",
";",
"}"
] |
Analyzes a single tracing link.
@param TracingLink $tracingLink
@param bool $textOnly whether to render text or HTML
@param int $maxLen
@return string
|
[
"Analyzes",
"a",
"single",
"tracing",
"link",
"."
] |
daf4a59098802fedcfd1f1a1d07847fcf2fea7bf
|
https://github.com/ekuiter/feature-php/blob/daf4a59098802fedcfd1f1a1d07847fcf2fea7bf/FeaturePhp/Artifact/TracingLinkRenderer.php#L64-L78
|
21,377 |
shabbyrobe/amiss
|
bin/commands/migrate-notes.php
|
LegacyParser.parse
|
public function parse($string)
{
global $matchedNotes;
$keyPrefixLen = $this->keyPrefix ? strlen($this->keyPrefix) : 0;
$data = array();
$toDelete = [];
$lines = preg_split('@\n@', $string, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
foreach ($lines as list($l, $offset)) {
$len = strlen($l);
$l = trim($l);
$offset += $len - strlen($l);
if ($l && $l[0] == '@') {
$curDelete = trim($l);
$l = substr($l, 1);
$d = preg_split('/\s+/', $l, 2, PREG_SPLIT_OFFSET_CAPTURE);
$key = $d[0][0];
if ($this->keyPrefix) {
if (strpos($key, $this->keyPrefix)!==0)
continue;
$key = substr($key, $keyPrefixLen);
}
$key = preg_split(
"/(
\]\[
| \[
| \]\. # when php style abuts dot notation (foo[a].b)
| \]
| \.)
/x",
rtrim($key, ']')
);
if (isset($d[1])) {
$value = $d[1][0];
}
else {
$value = $this->defaultValue;
}
$current = &$data;
$found = array();
foreach ($key as $part) {
if ($current && !is_array($current)) {
throw new RewriteException("Key at path ".implode('.', $found)." already had non-array value, tried to set key $part");
}
if (!$found) {
if (in_array($part, $matchedNotes)) {
$toDelete[] = $curDelete;
}
}
$found[] = $part;
// if the last segment is empty, it means "@key[] value" or "@key. value" was used,
// so we should just assign the next key
if ($part !== "")
$current = &$current[$part];
else
$current = &$current[];
}
if ($current === null)
$current = $value;
elseif (!is_array($current))
$current = array($current, $value);
else
$current[] = $value;
unset($current);
}
}
return [$data, $toDelete];
}
|
php
|
public function parse($string)
{
global $matchedNotes;
$keyPrefixLen = $this->keyPrefix ? strlen($this->keyPrefix) : 0;
$data = array();
$toDelete = [];
$lines = preg_split('@\n@', $string, null, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_OFFSET_CAPTURE);
foreach ($lines as list($l, $offset)) {
$len = strlen($l);
$l = trim($l);
$offset += $len - strlen($l);
if ($l && $l[0] == '@') {
$curDelete = trim($l);
$l = substr($l, 1);
$d = preg_split('/\s+/', $l, 2, PREG_SPLIT_OFFSET_CAPTURE);
$key = $d[0][0];
if ($this->keyPrefix) {
if (strpos($key, $this->keyPrefix)!==0)
continue;
$key = substr($key, $keyPrefixLen);
}
$key = preg_split(
"/(
\]\[
| \[
| \]\. # when php style abuts dot notation (foo[a].b)
| \]
| \.)
/x",
rtrim($key, ']')
);
if (isset($d[1])) {
$value = $d[1][0];
}
else {
$value = $this->defaultValue;
}
$current = &$data;
$found = array();
foreach ($key as $part) {
if ($current && !is_array($current)) {
throw new RewriteException("Key at path ".implode('.', $found)." already had non-array value, tried to set key $part");
}
if (!$found) {
if (in_array($part, $matchedNotes)) {
$toDelete[] = $curDelete;
}
}
$found[] = $part;
// if the last segment is empty, it means "@key[] value" or "@key. value" was used,
// so we should just assign the next key
if ($part !== "")
$current = &$current[$part];
else
$current = &$current[];
}
if ($current === null)
$current = $value;
elseif (!is_array($current))
$current = array($current, $value);
else
$current[] = $value;
unset($current);
}
}
return [$data, $toDelete];
}
|
[
"public",
"function",
"parse",
"(",
"$",
"string",
")",
"{",
"global",
"$",
"matchedNotes",
";",
"$",
"keyPrefixLen",
"=",
"$",
"this",
"->",
"keyPrefix",
"?",
"strlen",
"(",
"$",
"this",
"->",
"keyPrefix",
")",
":",
"0",
";",
"$",
"data",
"=",
"array",
"(",
")",
";",
"$",
"toDelete",
"=",
"[",
"]",
";",
"$",
"lines",
"=",
"preg_split",
"(",
"'@\\n@'",
",",
"$",
"string",
",",
"null",
",",
"PREG_SPLIT_NO_EMPTY",
"|",
"PREG_SPLIT_OFFSET_CAPTURE",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"list",
"(",
"$",
"l",
",",
"$",
"offset",
")",
")",
"{",
"$",
"len",
"=",
"strlen",
"(",
"$",
"l",
")",
";",
"$",
"l",
"=",
"trim",
"(",
"$",
"l",
")",
";",
"$",
"offset",
"+=",
"$",
"len",
"-",
"strlen",
"(",
"$",
"l",
")",
";",
"if",
"(",
"$",
"l",
"&&",
"$",
"l",
"[",
"0",
"]",
"==",
"'@'",
")",
"{",
"$",
"curDelete",
"=",
"trim",
"(",
"$",
"l",
")",
";",
"$",
"l",
"=",
"substr",
"(",
"$",
"l",
",",
"1",
")",
";",
"$",
"d",
"=",
"preg_split",
"(",
"'/\\s+/'",
",",
"$",
"l",
",",
"2",
",",
"PREG_SPLIT_OFFSET_CAPTURE",
")",
";",
"$",
"key",
"=",
"$",
"d",
"[",
"0",
"]",
"[",
"0",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"keyPrefix",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"keyPrefix",
")",
"!==",
"0",
")",
"continue",
";",
"$",
"key",
"=",
"substr",
"(",
"$",
"key",
",",
"$",
"keyPrefixLen",
")",
";",
"}",
"$",
"key",
"=",
"preg_split",
"(",
"\"/(\n \\]\\[\n | \\[\n | \\]\\. # when php style abuts dot notation (foo[a].b)\n | \\]\n | \\.)\n /x\"",
",",
"rtrim",
"(",
"$",
"key",
",",
"']'",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"d",
"[",
"1",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"d",
"[",
"1",
"]",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"defaultValue",
";",
"}",
"$",
"current",
"=",
"&",
"$",
"data",
";",
"$",
"found",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"key",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"$",
"current",
"&&",
"!",
"is_array",
"(",
"$",
"current",
")",
")",
"{",
"throw",
"new",
"RewriteException",
"(",
"\"Key at path \"",
".",
"implode",
"(",
"'.'",
",",
"$",
"found",
")",
".",
"\" already had non-array value, tried to set key $part\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"found",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"part",
",",
"$",
"matchedNotes",
")",
")",
"{",
"$",
"toDelete",
"[",
"]",
"=",
"$",
"curDelete",
";",
"}",
"}",
"$",
"found",
"[",
"]",
"=",
"$",
"part",
";",
"// if the last segment is empty, it means \"@key[] value\" or \"@key. value\" was used,",
"// so we should just assign the next key",
"if",
"(",
"$",
"part",
"!==",
"\"\"",
")",
"$",
"current",
"=",
"&",
"$",
"current",
"[",
"$",
"part",
"]",
";",
"else",
"$",
"current",
"=",
"&",
"$",
"current",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"current",
"===",
"null",
")",
"$",
"current",
"=",
"$",
"value",
";",
"elseif",
"(",
"!",
"is_array",
"(",
"$",
"current",
")",
")",
"$",
"current",
"=",
"array",
"(",
"$",
"current",
",",
"$",
"value",
")",
";",
"else",
"$",
"current",
"[",
"]",
"=",
"$",
"value",
";",
"unset",
"(",
"$",
"current",
")",
";",
"}",
"}",
"return",
"[",
"$",
"data",
",",
"$",
"toDelete",
"]",
";",
"}"
] |
will do for now, but it's definitely one to revisit.
|
[
"will",
"do",
"for",
"now",
"but",
"it",
"s",
"definitely",
"one",
"to",
"revisit",
"."
] |
ba261f0d1f985ed36e9fd2903ac0df86c5b9498d
|
https://github.com/shabbyrobe/amiss/blob/ba261f0d1f985ed36e9fd2903ac0df86c5b9498d/bin/commands/migrate-notes.php#L504-L583
|
21,378 |
NuclearCMS/Hierarchy
|
src/NodeType.php
|
NodeType.addField
|
public function addField(array $attributes)
{
$field = $this->fields()->create($attributes);
$this->save();
return $field;
}
|
php
|
public function addField(array $attributes)
{
$field = $this->fields()->create($attributes);
$this->save();
return $field;
}
|
[
"public",
"function",
"addField",
"(",
"array",
"$",
"attributes",
")",
"{",
"$",
"field",
"=",
"$",
"this",
"->",
"fields",
"(",
")",
"->",
"create",
"(",
"$",
"attributes",
")",
";",
"$",
"this",
"->",
"save",
"(",
")",
";",
"return",
"$",
"field",
";",
"}"
] |
Add a field to the node type
@param array $attributes
@return Eloquent
|
[
"Add",
"a",
"field",
"to",
"the",
"node",
"type"
] |
535171c5e2db72265313fd2110aec8456e46f459
|
https://github.com/NuclearCMS/Hierarchy/blob/535171c5e2db72265313fd2110aec8456e46f459/src/NodeType.php#L120-L127
|
21,379 |
wplibs/rules
|
src/Builder.php
|
Builder.offsetGet
|
public function offsetGet( $name ) {
if ( ! array_key_exists( $name, $this->variables ) ) {
$this->variables[ $name ] = new Variable( $name );
}
return $this->variables[ $name ];
}
|
php
|
public function offsetGet( $name ) {
if ( ! array_key_exists( $name, $this->variables ) ) {
$this->variables[ $name ] = new Variable( $name );
}
return $this->variables[ $name ];
}
|
[
"public",
"function",
"offsetGet",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"variables",
")",
")",
"{",
"$",
"this",
"->",
"variables",
"[",
"$",
"name",
"]",
"=",
"new",
"Variable",
"(",
"$",
"name",
")",
";",
"}",
"return",
"$",
"this",
"->",
"variables",
"[",
"$",
"name",
"]",
";",
"}"
] |
Retrieve a variable by name.
@param string $name
@return Variable
|
[
"Retrieve",
"a",
"variable",
"by",
"name",
"."
] |
29b4495e2ae87349fd64fcd844f3ba96cc268e3d
|
https://github.com/wplibs/rules/blob/29b4495e2ae87349fd64fcd844f3ba96cc268e3d/src/Builder.php#L72-L78
|
21,380 |
heidelpay/PhpDoc
|
src/phpDocumentor/Descriptor/Cache/ProjectDescriptorMapper.php
|
ProjectDescriptorMapper.garbageCollect
|
public function garbageCollect(Collection $collection)
{
$projectRoot = $collection->getProjectRoot();
$filenames = $collection->getFilenames();
foreach ($filenames as &$name) {
// the cache key contains a path relative to the project root; here we expect absolute paths.
$name = self::FILE_PREFIX . md5(substr($name, strlen($projectRoot)));
}
/** @var IteratorInterface $iteratorInterface */
$iteratorInterface = $this->getCache()->getIterator();
// FIXME: Workaround for: https://github.com/zendframework/zf2/pull/4154
if ($iteratorInterface->valid()) {
foreach ($this->getCache() as $item) {
if (substr($item, 0, strlen(self::FILE_PREFIX)) === self::FILE_PREFIX && !in_array($item, $filenames)) {
$this->getCache()->removeItem($item);
}
}
}
}
|
php
|
public function garbageCollect(Collection $collection)
{
$projectRoot = $collection->getProjectRoot();
$filenames = $collection->getFilenames();
foreach ($filenames as &$name) {
// the cache key contains a path relative to the project root; here we expect absolute paths.
$name = self::FILE_PREFIX . md5(substr($name, strlen($projectRoot)));
}
/** @var IteratorInterface $iteratorInterface */
$iteratorInterface = $this->getCache()->getIterator();
// FIXME: Workaround for: https://github.com/zendframework/zf2/pull/4154
if ($iteratorInterface->valid()) {
foreach ($this->getCache() as $item) {
if (substr($item, 0, strlen(self::FILE_PREFIX)) === self::FILE_PREFIX && !in_array($item, $filenames)) {
$this->getCache()->removeItem($item);
}
}
}
}
|
[
"public",
"function",
"garbageCollect",
"(",
"Collection",
"$",
"collection",
")",
"{",
"$",
"projectRoot",
"=",
"$",
"collection",
"->",
"getProjectRoot",
"(",
")",
";",
"$",
"filenames",
"=",
"$",
"collection",
"->",
"getFilenames",
"(",
")",
";",
"foreach",
"(",
"$",
"filenames",
"as",
"&",
"$",
"name",
")",
"{",
"// the cache key contains a path relative to the project root; here we expect absolute paths.",
"$",
"name",
"=",
"self",
"::",
"FILE_PREFIX",
".",
"md5",
"(",
"substr",
"(",
"$",
"name",
",",
"strlen",
"(",
"$",
"projectRoot",
")",
")",
")",
";",
"}",
"/** @var IteratorInterface $iteratorInterface */",
"$",
"iteratorInterface",
"=",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"getIterator",
"(",
")",
";",
"// FIXME: Workaround for: https://github.com/zendframework/zf2/pull/4154",
"if",
"(",
"$",
"iteratorInterface",
"->",
"valid",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getCache",
"(",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"item",
",",
"0",
",",
"strlen",
"(",
"self",
"::",
"FILE_PREFIX",
")",
")",
"===",
"self",
"::",
"FILE_PREFIX",
"&&",
"!",
"in_array",
"(",
"$",
"item",
",",
"$",
"filenames",
")",
")",
"{",
"$",
"this",
"->",
"getCache",
"(",
")",
"->",
"removeItem",
"(",
"$",
"item",
")",
";",
"}",
"}",
"}",
"}"
] |
Removes all files in cache that do not occur in the given FileSet Collection.
@param Collection $collection
@return void
|
[
"Removes",
"all",
"files",
"in",
"cache",
"that",
"do",
"not",
"occur",
"in",
"the",
"given",
"FileSet",
"Collection",
"."
] |
5ac9e842cbd4cbb70900533b240c131f3515ee02
|
https://github.com/heidelpay/PhpDoc/blob/5ac9e842cbd4cbb70900533b240c131f3515ee02/src/phpDocumentor/Descriptor/Cache/ProjectDescriptorMapper.php#L163-L184
|
21,381 |
qlake/framework
|
src/Qlake/Routing/Router.php
|
Router.addRoute
|
protected function addRoute($methods, $uri, $action)
{
$route = $this->createRoute($methods, $uri, $action);
$route->setPrefixUri($this->processGroupsUri());
$this->routes->addRoute($route);
return $route;
}
|
php
|
protected function addRoute($methods, $uri, $action)
{
$route = $this->createRoute($methods, $uri, $action);
$route->setPrefixUri($this->processGroupsUri());
$this->routes->addRoute($route);
return $route;
}
|
[
"protected",
"function",
"addRoute",
"(",
"$",
"methods",
",",
"$",
"uri",
",",
"$",
"action",
")",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"createRoute",
"(",
"$",
"methods",
",",
"$",
"uri",
",",
"$",
"action",
")",
";",
"$",
"route",
"->",
"setPrefixUri",
"(",
"$",
"this",
"->",
"processGroupsUri",
"(",
")",
")",
";",
"$",
"this",
"->",
"routes",
"->",
"addRoute",
"(",
"$",
"route",
")",
";",
"return",
"$",
"route",
";",
"}"
] |
Create and register a route
@param array $methods
@param string $uri
@param Closure|string $action
@return Qlake\Routing\Route
|
[
"Create",
"and",
"register",
"a",
"route"
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Routing/Router.php#L231-L240
|
21,382 |
qlake/framework
|
src/Qlake/Routing/Router.php
|
Router.match
|
public function match(Request $request)
{
foreach ($this->routes->filterByMethod($request->getMethod()) as $route)
{
if ($route->isMatch($request->getPathInfo()))
{
return $route;
}
}
return null;
}
|
php
|
public function match(Request $request)
{
foreach ($this->routes->filterByMethod($request->getMethod()) as $route)
{
if ($route->isMatch($request->getPathInfo()))
{
return $route;
}
}
return null;
}
|
[
"public",
"function",
"match",
"(",
"Request",
"$",
"request",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"routes",
"->",
"filterByMethod",
"(",
"$",
"request",
"->",
"getMethod",
"(",
")",
")",
"as",
"$",
"route",
")",
"{",
"if",
"(",
"$",
"route",
"->",
"isMatch",
"(",
"$",
"request",
"->",
"getPathInfo",
"(",
")",
")",
")",
"{",
"return",
"$",
"route",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Chack matching requested uri by registered routes.
@param Qlake\Http\Request $request
@return Qlake\Routing\Route|null
|
[
"Chack",
"matching",
"requested",
"uri",
"by",
"registered",
"routes",
"."
] |
0b7bad459ae0721bc5cdd141344f9dfc1acee28a
|
https://github.com/qlake/framework/blob/0b7bad459ae0721bc5cdd141344f9dfc1acee28a/src/Qlake/Routing/Router.php#L287-L298
|
21,383 |
thelia-modules/CustomerGroup
|
Model/Map/CustomerGroupI18nTableMap.php
|
CustomerGroupI18nTableMap.doDelete
|
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupI18nTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CustomerGroup\Model\CustomerGroupI18n) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CustomerGroupI18nTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(CustomerGroupI18nTableMap::ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(CustomerGroupI18nTableMap::LOCALE, $value[1]));
$criteria->addOr($criterion);
}
}
$query = CustomerGroupI18nQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CustomerGroupI18nTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CustomerGroupI18nTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
|
php
|
public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(CustomerGroupI18nTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \CustomerGroup\Model\CustomerGroupI18n) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(CustomerGroupI18nTableMap::DATABASE_NAME);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey values
if (count($values) == count($values, COUNT_RECURSIVE)) {
// array is not multi-dimensional
$values = array($values);
}
foreach ($values as $value) {
$criterion = $criteria->getNewCriterion(CustomerGroupI18nTableMap::ID, $value[0]);
$criterion->addAnd($criteria->getNewCriterion(CustomerGroupI18nTableMap::LOCALE, $value[1]));
$criteria->addOr($criterion);
}
}
$query = CustomerGroupI18nQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) { CustomerGroupI18nTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) { CustomerGroupI18nTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
}
|
[
"public",
"static",
"function",
"doDelete",
"(",
"$",
"values",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getWriteConnection",
"(",
"CustomerGroupI18nTableMap",
"::",
"DATABASE_NAME",
")",
";",
"}",
"if",
"(",
"$",
"values",
"instanceof",
"Criteria",
")",
"{",
"// rename for clarity",
"$",
"criteria",
"=",
"$",
"values",
";",
"}",
"elseif",
"(",
"$",
"values",
"instanceof",
"\\",
"CustomerGroup",
"\\",
"Model",
"\\",
"CustomerGroupI18n",
")",
"{",
"// it's a model object",
"// create criteria based on pk values",
"$",
"criteria",
"=",
"$",
"values",
"->",
"buildPkeyCriteria",
"(",
")",
";",
"}",
"else",
"{",
"// it's a primary key, or an array of pks",
"$",
"criteria",
"=",
"new",
"Criteria",
"(",
"CustomerGroupI18nTableMap",
"::",
"DATABASE_NAME",
")",
";",
"// primary key is composite; we therefore, expect",
"// the primary key passed to be an array of pkey values",
"if",
"(",
"count",
"(",
"$",
"values",
")",
"==",
"count",
"(",
"$",
"values",
",",
"COUNT_RECURSIVE",
")",
")",
"{",
"// array is not multi-dimensional",
"$",
"values",
"=",
"array",
"(",
"$",
"values",
")",
";",
"}",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"$",
"criterion",
"=",
"$",
"criteria",
"->",
"getNewCriterion",
"(",
"CustomerGroupI18nTableMap",
"::",
"ID",
",",
"$",
"value",
"[",
"0",
"]",
")",
";",
"$",
"criterion",
"->",
"addAnd",
"(",
"$",
"criteria",
"->",
"getNewCriterion",
"(",
"CustomerGroupI18nTableMap",
"::",
"LOCALE",
",",
"$",
"value",
"[",
"1",
"]",
")",
")",
";",
"$",
"criteria",
"->",
"addOr",
"(",
"$",
"criterion",
")",
";",
"}",
"}",
"$",
"query",
"=",
"CustomerGroupI18nQuery",
"::",
"create",
"(",
")",
"->",
"mergeWith",
"(",
"$",
"criteria",
")",
";",
"if",
"(",
"$",
"values",
"instanceof",
"Criteria",
")",
"{",
"CustomerGroupI18nTableMap",
"::",
"clearInstancePool",
"(",
")",
";",
"}",
"elseif",
"(",
"!",
"is_object",
"(",
"$",
"values",
")",
")",
"{",
"// it's a primary key, or an array of pks",
"foreach",
"(",
"(",
"array",
")",
"$",
"values",
"as",
"$",
"singleval",
")",
"{",
"CustomerGroupI18nTableMap",
"::",
"removeInstanceFromPool",
"(",
"$",
"singleval",
")",
";",
"}",
"}",
"return",
"$",
"query",
"->",
"delete",
"(",
"$",
"con",
")",
";",
"}"
] |
Performs a DELETE on the database, given a CustomerGroupI18n or Criteria object OR a primary key value.
@param mixed $values Criteria or CustomerGroupI18n object or primary key or array of primary keys
which is used to create the DELETE statement
@param ConnectionInterface $con the connection to use
@return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
if supported by native driver or if emulated using Propel.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException.
|
[
"Performs",
"a",
"DELETE",
"on",
"the",
"database",
"given",
"a",
"CustomerGroupI18n",
"or",
"Criteria",
"object",
"OR",
"a",
"primary",
"key",
"value",
"."
] |
672cc64c686812f6a95cf0d702111f93d8c0e850
|
https://github.com/thelia-modules/CustomerGroup/blob/672cc64c686812f6a95cf0d702111f93d8c0e850/Model/Map/CustomerGroupI18nTableMap.php#L391-L427
|
21,384 |
mustardandrew/muan-laravel-acl
|
src/Models/UserObserver.php
|
UserObserver.created
|
public function created($user)
{
if (! $baseName = $user->baseRole) {
return;
}
// Attach base role
if (method_exists($user, 'attachRole')) {
$user->attachRole($baseName);
}
}
|
php
|
public function created($user)
{
if (! $baseName = $user->baseRole) {
return;
}
// Attach base role
if (method_exists($user, 'attachRole')) {
$user->attachRole($baseName);
}
}
|
[
"public",
"function",
"created",
"(",
"$",
"user",
")",
"{",
"if",
"(",
"!",
"$",
"baseName",
"=",
"$",
"user",
"->",
"baseRole",
")",
"{",
"return",
";",
"}",
"// Attach base role",
"if",
"(",
"method_exists",
"(",
"$",
"user",
",",
"'attachRole'",
")",
")",
"{",
"$",
"user",
"->",
"attachRole",
"(",
"$",
"baseName",
")",
";",
"}",
"}"
] |
Listen to the User created event.
@param object $user
@return void
|
[
"Listen",
"to",
"the",
"User",
"created",
"event",
"."
] |
b5f23340b5536babb98d9fd0d727a7a3371c97d5
|
https://github.com/mustardandrew/muan-laravel-acl/blob/b5f23340b5536babb98d9fd0d727a7a3371c97d5/src/Models/UserObserver.php#L19-L29
|
21,385 |
Rxnet/rabbitmq
|
Queue.php
|
Queue.get
|
public function get($queue, $noAck = false): Observable
{
$promise = $this->channel->get($queue, $noAck);
return Observable::fromPromise($promise)
->map(function (BaseMessage $message) {
return new Message($this->channel, $message);
});
}
|
php
|
public function get($queue, $noAck = false): Observable
{
$promise = $this->channel->get($queue, $noAck);
return Observable::fromPromise($promise)
->map(function (BaseMessage $message) {
return new Message($this->channel, $message);
});
}
|
[
"public",
"function",
"get",
"(",
"$",
"queue",
",",
"$",
"noAck",
"=",
"false",
")",
":",
"Observable",
"{",
"$",
"promise",
"=",
"$",
"this",
"->",
"channel",
"->",
"get",
"(",
"$",
"queue",
",",
"$",
"noAck",
")",
";",
"return",
"Observable",
"::",
"fromPromise",
"(",
"$",
"promise",
")",
"->",
"map",
"(",
"function",
"(",
"BaseMessage",
"$",
"message",
")",
"{",
"return",
"new",
"Message",
"(",
"$",
"this",
"->",
"channel",
",",
"$",
"message",
")",
";",
"}",
")",
";",
"}"
] |
Pop one element from the queue.
|
[
"Pop",
"one",
"element",
"from",
"the",
"queue",
"."
] |
16e2fa39daddb6cca70716b8895470c4691a6f9e
|
https://github.com/Rxnet/rabbitmq/blob/16e2fa39daddb6cca70716b8895470c4691a6f9e/Queue.php#L118-L126
|
21,386 |
oroinc/OroLayoutComponent
|
Loader/Driver/AbstractDriver.php
|
AbstractDriver.getCacheFilename
|
protected function getCacheFilename($name)
{
$class = substr($this->generateClassName($name), strlen(static::CLASS_PREFIX));
return str_replace(
'/',
DIRECTORY_SEPARATOR,
sprintf(
'%s/%s/%s/%s.php',
$this->getCacheDir(),
substr($class, 0, 2),
substr($class, 2, 2),
substr($class, 4)
)
);
}
|
php
|
protected function getCacheFilename($name)
{
$class = substr($this->generateClassName($name), strlen(static::CLASS_PREFIX));
return str_replace(
'/',
DIRECTORY_SEPARATOR,
sprintf(
'%s/%s/%s/%s.php',
$this->getCacheDir(),
substr($class, 0, 2),
substr($class, 2, 2),
substr($class, 4)
)
);
}
|
[
"protected",
"function",
"getCacheFilename",
"(",
"$",
"name",
")",
"{",
"$",
"class",
"=",
"substr",
"(",
"$",
"this",
"->",
"generateClassName",
"(",
"$",
"name",
")",
",",
"strlen",
"(",
"static",
"::",
"CLASS_PREFIX",
")",
")",
";",
"return",
"str_replace",
"(",
"'/'",
",",
"DIRECTORY_SEPARATOR",
",",
"sprintf",
"(",
"'%s/%s/%s/%s.php'",
",",
"$",
"this",
"->",
"getCacheDir",
"(",
")",
",",
"substr",
"(",
"$",
"class",
",",
"0",
",",
"2",
")",
",",
"substr",
"(",
"$",
"class",
",",
"2",
",",
"2",
")",
",",
"substr",
"(",
"$",
"class",
",",
"4",
")",
")",
")",
";",
"}"
] |
Generates PHP filename based on given resource name
@param string $name Resource filename
@return bool|string Returns FALSE if cache dir isn't configured or generated PHP absolute filename otherwise
|
[
"Generates",
"PHP",
"filename",
"based",
"on",
"given",
"resource",
"name"
] |
682a96672393d81c63728e47c4a4c3618c515be0
|
https://github.com/oroinc/OroLayoutComponent/blob/682a96672393d81c63728e47c4a4c3618c515be0/Loader/Driver/AbstractDriver.php#L174-L189
|
21,387 |
GrupaZero/api
|
src/Gzero/Api/Controller/Admin/UserController.php
|
UserController.index
|
public function index()
{
$this->authorize('readList', User::class);
$input = $this->validator->validate('list');
$params = $this->processor->process($input)->getProcessedFields();
$results = $this->userRepo->getUsers(
$params['filter'],
$params['orderBy'],
$params['page'],
$params['perPage']
);
return $this->respondWithSuccess($results, new UserTransformer);
}
|
php
|
public function index()
{
$this->authorize('readList', User::class);
$input = $this->validator->validate('list');
$params = $this->processor->process($input)->getProcessedFields();
$results = $this->userRepo->getUsers(
$params['filter'],
$params['orderBy'],
$params['page'],
$params['perPage']
);
return $this->respondWithSuccess($results, new UserTransformer);
}
|
[
"public",
"function",
"index",
"(",
")",
"{",
"$",
"this",
"->",
"authorize",
"(",
"'readList'",
",",
"User",
"::",
"class",
")",
";",
"$",
"input",
"=",
"$",
"this",
"->",
"validator",
"->",
"validate",
"(",
"'list'",
")",
";",
"$",
"params",
"=",
"$",
"this",
"->",
"processor",
"->",
"process",
"(",
"$",
"input",
")",
"->",
"getProcessedFields",
"(",
")",
";",
"$",
"results",
"=",
"$",
"this",
"->",
"userRepo",
"->",
"getUsers",
"(",
"$",
"params",
"[",
"'filter'",
"]",
",",
"$",
"params",
"[",
"'orderBy'",
"]",
",",
"$",
"params",
"[",
"'page'",
"]",
",",
"$",
"params",
"[",
"'perPage'",
"]",
")",
";",
"return",
"$",
"this",
"->",
"respondWithSuccess",
"(",
"$",
"results",
",",
"new",
"UserTransformer",
")",
";",
"}"
] |
Display list of users
@return \Illuminate\Http\JsonResponse
|
[
"Display",
"list",
"of",
"users"
] |
fc544bb6057274e9d5e7b617346c3f854ea5effd
|
https://github.com/GrupaZero/api/blob/fc544bb6057274e9d5e7b617346c3f854ea5effd/src/Gzero/Api/Controller/Admin/UserController.php#L54-L66
|
21,388 |
Baachi/CouchDB
|
src/CouchDB/Database.php
|
Database.find
|
public function find($id)
{
$response = $this->client->request('GET', sprintf('/%s/%s', $this->name, $id));
$json = (string) $response->getBody();
if (404 === $response->getStatusCode()) {
throw new Exception('Document does not exist');
}
return JSONEncoder::decode($json);
}
|
php
|
public function find($id)
{
$response = $this->client->request('GET', sprintf('/%s/%s', $this->name, $id));
$json = (string) $response->getBody();
if (404 === $response->getStatusCode()) {
throw new Exception('Document does not exist');
}
return JSONEncoder::decode($json);
}
|
[
"public",
"function",
"find",
"(",
"$",
"id",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'GET'",
",",
"sprintf",
"(",
"'/%s/%s'",
",",
"$",
"this",
"->",
"name",
",",
"$",
"id",
")",
")",
";",
"$",
"json",
"=",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
";",
"if",
"(",
"404",
"===",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Document does not exist'",
")",
";",
"}",
"return",
"JSONEncoder",
"::",
"decode",
"(",
"$",
"json",
")",
";",
"}"
] |
Find a document by a id.
@param string $id
@throws Exception If the document doesn't exists.
@return mixed
|
[
"Find",
"a",
"document",
"by",
"a",
"id",
"."
] |
6be364c2f3d9c7b1288b1c11115469c91819ff5c
|
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L60-L70
|
21,389 |
Baachi/CouchDB
|
src/CouchDB/Database.php
|
Database.findAll
|
public function findAll($limit = null, $startKey = null)
{
$path = "/{$this->name}/_all_docs?include_docs=true";
if (null !== $limit) {
$path .= '&limit='.(integer) $limit;
}
if (null !== $startKey) {
$path .= '&startkey='.(string) $startKey;
}
$json = (string) $this->client->request('GET', $path)->getBody();
$docs = JSONEncoder::decode($json);
return $docs;
}
|
php
|
public function findAll($limit = null, $startKey = null)
{
$path = "/{$this->name}/_all_docs?include_docs=true";
if (null !== $limit) {
$path .= '&limit='.(integer) $limit;
}
if (null !== $startKey) {
$path .= '&startkey='.(string) $startKey;
}
$json = (string) $this->client->request('GET', $path)->getBody();
$docs = JSONEncoder::decode($json);
return $docs;
}
|
[
"public",
"function",
"findAll",
"(",
"$",
"limit",
"=",
"null",
",",
"$",
"startKey",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"\"/{$this->name}/_all_docs?include_docs=true\"",
";",
"if",
"(",
"null",
"!==",
"$",
"limit",
")",
"{",
"$",
"path",
".=",
"'&limit='",
".",
"(",
"integer",
")",
"$",
"limit",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"startKey",
")",
"{",
"$",
"path",
".=",
"'&startkey='",
".",
"(",
"string",
")",
"$",
"startKey",
";",
"}",
"$",
"json",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'GET'",
",",
"$",
"path",
")",
"->",
"getBody",
"(",
")",
";",
"$",
"docs",
"=",
"JSONEncoder",
"::",
"decode",
"(",
"$",
"json",
")",
";",
"return",
"$",
"docs",
";",
"}"
] |
Find all documents from the database.
@param int|null $limit
@param string|null $startKey
@return mixed
|
[
"Find",
"all",
"documents",
"from",
"the",
"database",
"."
] |
6be364c2f3d9c7b1288b1c11115469c91819ff5c
|
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L80-L95
|
21,390 |
Baachi/CouchDB
|
src/CouchDB/Database.php
|
Database.findDocuments
|
public function findDocuments(array $ids, $limit = null, $offset = null)
{
$path = "/{$this->name}/_all_docs?include_docs=true";
if (null !== $limit) {
$path .= '&limit='.(integer) $limit;
}
if (null !== $offset) {
$path .= '&skip='.(integer) $offset;
}
$response = $this->client->request('POST', $path, [
'body' => JSONEncoder::encode(['keys' => $ids]),
'headers' => ['Content-Type' => 'application/json'],
]);
return JSONEncoder::decode((string) $response->getBody());
}
|
php
|
public function findDocuments(array $ids, $limit = null, $offset = null)
{
$path = "/{$this->name}/_all_docs?include_docs=true";
if (null !== $limit) {
$path .= '&limit='.(integer) $limit;
}
if (null !== $offset) {
$path .= '&skip='.(integer) $offset;
}
$response = $this->client->request('POST', $path, [
'body' => JSONEncoder::encode(['keys' => $ids]),
'headers' => ['Content-Type' => 'application/json'],
]);
return JSONEncoder::decode((string) $response->getBody());
}
|
[
"public",
"function",
"findDocuments",
"(",
"array",
"$",
"ids",
",",
"$",
"limit",
"=",
"null",
",",
"$",
"offset",
"=",
"null",
")",
"{",
"$",
"path",
"=",
"\"/{$this->name}/_all_docs?include_docs=true\"",
";",
"if",
"(",
"null",
"!==",
"$",
"limit",
")",
"{",
"$",
"path",
".=",
"'&limit='",
".",
"(",
"integer",
")",
"$",
"limit",
";",
"}",
"if",
"(",
"null",
"!==",
"$",
"offset",
")",
"{",
"$",
"path",
".=",
"'&skip='",
".",
"(",
"integer",
")",
"$",
"offset",
";",
"}",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'POST'",
",",
"$",
"path",
",",
"[",
"'body'",
"=>",
"JSONEncoder",
"::",
"encode",
"(",
"[",
"'keys'",
"=>",
"$",
"ids",
"]",
")",
",",
"'headers'",
"=>",
"[",
"'Content-Type'",
"=>",
"'application/json'",
"]",
",",
"]",
")",
";",
"return",
"JSONEncoder",
"::",
"decode",
"(",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"}"
] |
Find a documents by a id.
@param array $ids
@param null|int $limit
@param null|int $offset
@return array|null
|
[
"Find",
"a",
"documents",
"by",
"a",
"id",
"."
] |
6be364c2f3d9c7b1288b1c11115469c91819ff5c
|
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L106-L123
|
21,391 |
Baachi/CouchDB
|
src/CouchDB/Database.php
|
Database.insert
|
public function insert(array &$doc)
{
if (isset($doc['_id'])) {
$clone = $doc;
unset($clone['_id']);
$response = $this->client->request('PUT', "/{$this->name}/{$doc['_id']}", [
'body' => JSONEncoder::encode($clone),
'headers' => ['Content-Type' => 'application/json'],
]);
} else {
$response = $this->client->request('POST', "/{$this->name}/", [
'body' => JSONEncoder::encode($doc),
'headers' => ['Content-Type' => 'application/json'],
]);
}
if (201 !== $response->getStatusCode()) {
throw new Exception('Unable to save document');
}
$value = JSONEncoder::decode((string) $response->getBody());
$doc['_id'] = $value['id'];
$doc['_rev'] = $value['rev'];
}
|
php
|
public function insert(array &$doc)
{
if (isset($doc['_id'])) {
$clone = $doc;
unset($clone['_id']);
$response = $this->client->request('PUT', "/{$this->name}/{$doc['_id']}", [
'body' => JSONEncoder::encode($clone),
'headers' => ['Content-Type' => 'application/json'],
]);
} else {
$response = $this->client->request('POST', "/{$this->name}/", [
'body' => JSONEncoder::encode($doc),
'headers' => ['Content-Type' => 'application/json'],
]);
}
if (201 !== $response->getStatusCode()) {
throw new Exception('Unable to save document');
}
$value = JSONEncoder::decode((string) $response->getBody());
$doc['_id'] = $value['id'];
$doc['_rev'] = $value['rev'];
}
|
[
"public",
"function",
"insert",
"(",
"array",
"&",
"$",
"doc",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"doc",
"[",
"'_id'",
"]",
")",
")",
"{",
"$",
"clone",
"=",
"$",
"doc",
";",
"unset",
"(",
"$",
"clone",
"[",
"'_id'",
"]",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'PUT'",
",",
"\"/{$this->name}/{$doc['_id']}\"",
",",
"[",
"'body'",
"=>",
"JSONEncoder",
"::",
"encode",
"(",
"$",
"clone",
")",
",",
"'headers'",
"=>",
"[",
"'Content-Type'",
"=>",
"'application/json'",
"]",
",",
"]",
")",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'POST'",
",",
"\"/{$this->name}/\"",
",",
"[",
"'body'",
"=>",
"JSONEncoder",
"::",
"encode",
"(",
"$",
"doc",
")",
",",
"'headers'",
"=>",
"[",
"'Content-Type'",
"=>",
"'application/json'",
"]",
",",
"]",
")",
";",
"}",
"if",
"(",
"201",
"!==",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Unable to save document'",
")",
";",
"}",
"$",
"value",
"=",
"JSONEncoder",
"::",
"decode",
"(",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"$",
"doc",
"[",
"'_id'",
"]",
"=",
"$",
"value",
"[",
"'id'",
"]",
";",
"$",
"doc",
"[",
"'_rev'",
"]",
"=",
"$",
"value",
"[",
"'rev'",
"]",
";",
"}"
] |
Insert a new document.
@param array $doc
@deprecated To update a document use Database::update, it will be removed in version 2
@throws Exception
|
[
"Insert",
"a",
"new",
"document",
"."
] |
6be364c2f3d9c7b1288b1c11115469c91819ff5c
|
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L134-L159
|
21,392 |
Baachi/CouchDB
|
src/CouchDB/Database.php
|
Database.update
|
public function update($id, array &$doc)
{
$json = JSONEncoder::encode($doc);
$response = $this->client->request('PUT', "/{$this->name}/{$id}", [
'body' => $json,
'headers' => ['Content-Type' => 'application/json'],
]);
if (201 !== $response->getStatusCode()) {
throw new Exception('Unable to save document');
}
$value = JSONEncoder::decode((string) $response->getBody());
$doc['_id'] = $value['id'];
$doc['_rev'] = $value['rev'];
}
|
php
|
public function update($id, array &$doc)
{
$json = JSONEncoder::encode($doc);
$response = $this->client->request('PUT', "/{$this->name}/{$id}", [
'body' => $json,
'headers' => ['Content-Type' => 'application/json'],
]);
if (201 !== $response->getStatusCode()) {
throw new Exception('Unable to save document');
}
$value = JSONEncoder::decode((string) $response->getBody());
$doc['_id'] = $value['id'];
$doc['_rev'] = $value['rev'];
}
|
[
"public",
"function",
"update",
"(",
"$",
"id",
",",
"array",
"&",
"$",
"doc",
")",
"{",
"$",
"json",
"=",
"JSONEncoder",
"::",
"encode",
"(",
"$",
"doc",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'PUT'",
",",
"\"/{$this->name}/{$id}\"",
",",
"[",
"'body'",
"=>",
"$",
"json",
",",
"'headers'",
"=>",
"[",
"'Content-Type'",
"=>",
"'application/json'",
"]",
",",
"]",
")",
";",
"if",
"(",
"201",
"!==",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Unable to save document'",
")",
";",
"}",
"$",
"value",
"=",
"JSONEncoder",
"::",
"decode",
"(",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"$",
"doc",
"[",
"'_id'",
"]",
"=",
"$",
"value",
"[",
"'id'",
"]",
";",
"$",
"doc",
"[",
"'_rev'",
"]",
"=",
"$",
"value",
"[",
"'rev'",
"]",
";",
"}"
] |
Updates a document.
@param string $id The id from the document
@param array $doc A reference from the document
@throws Exception
|
[
"Updates",
"a",
"document",
"."
] |
6be364c2f3d9c7b1288b1c11115469c91819ff5c
|
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L169-L186
|
21,393 |
Baachi/CouchDB
|
src/CouchDB/Database.php
|
Database.getInfo
|
public function getInfo()
{
$json = (string) $this->client->request('GET', "/{$this->name}/")->getBody();
return JSONEncoder::decode($json);
}
|
php
|
public function getInfo()
{
$json = (string) $this->client->request('GET', "/{$this->name}/")->getBody();
return JSONEncoder::decode($json);
}
|
[
"public",
"function",
"getInfo",
"(",
")",
"{",
"$",
"json",
"=",
"(",
"string",
")",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'GET'",
",",
"\"/{$this->name}/\"",
")",
"->",
"getBody",
"(",
")",
";",
"return",
"JSONEncoder",
"::",
"decode",
"(",
"$",
"json",
")",
";",
"}"
] |
Return the database informations.
@return array
|
[
"Return",
"the",
"database",
"informations",
"."
] |
6be364c2f3d9c7b1288b1c11115469c91819ff5c
|
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L224-L229
|
21,394 |
Baachi/CouchDB
|
src/CouchDB/Database.php
|
Database.getChanges
|
public function getChanges()
{
$response = $this->client->request('GET', "/{$this->name}/_changes");
if (200 !== $response->getStatusCode()) {
throw new Exception('Request wasn\'t successfull');
}
return JSONEncoder::decode((string) $response->getBody());
}
|
php
|
public function getChanges()
{
$response = $this->client->request('GET', "/{$this->name}/_changes");
if (200 !== $response->getStatusCode()) {
throw new Exception('Request wasn\'t successfull');
}
return JSONEncoder::decode((string) $response->getBody());
}
|
[
"public",
"function",
"getChanges",
"(",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"client",
"->",
"request",
"(",
"'GET'",
",",
"\"/{$this->name}/_changes\"",
")",
";",
"if",
"(",
"200",
"!==",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Request wasn\\'t successfull'",
")",
";",
"}",
"return",
"JSONEncoder",
"::",
"decode",
"(",
"(",
"string",
")",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"}"
] |
Return informations about the last changes from the database.
@throws \RuntimeException If the request was not successfull
@return array
|
[
"Return",
"informations",
"about",
"the",
"last",
"changes",
"from",
"the",
"database",
"."
] |
6be364c2f3d9c7b1288b1c11115469c91819ff5c
|
https://github.com/Baachi/CouchDB/blob/6be364c2f3d9c7b1288b1c11115469c91819ff5c/src/CouchDB/Database.php#L238-L247
|
21,395 |
canax/database-query-builder
|
src/DatabaseQueryBuilder/DatabaseQueryBuilder.php
|
DatabaseQueryBuilder.setDefaultsFromConfiguration
|
public function setDefaultsFromConfiguration()
{
if ($this->options['dsn']) {
$dsn = explode(':', $this->options['dsn']);
$this->setSQLDialect($dsn[0]);
}
$this->setTablePrefix($this->options['table_prefix']);
}
|
php
|
public function setDefaultsFromConfiguration()
{
if ($this->options['dsn']) {
$dsn = explode(':', $this->options['dsn']);
$this->setSQLDialect($dsn[0]);
}
$this->setTablePrefix($this->options['table_prefix']);
}
|
[
"public",
"function",
"setDefaultsFromConfiguration",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'dsn'",
"]",
")",
"{",
"$",
"dsn",
"=",
"explode",
"(",
"':'",
",",
"$",
"this",
"->",
"options",
"[",
"'dsn'",
"]",
")",
";",
"$",
"this",
"->",
"setSQLDialect",
"(",
"$",
"dsn",
"[",
"0",
"]",
")",
";",
"}",
"$",
"this",
"->",
"setTablePrefix",
"(",
"$",
"this",
"->",
"options",
"[",
"'table_prefix'",
"]",
")",
";",
"}"
] |
Update builder settings from active configuration.
@return void
|
[
"Update",
"builder",
"settings",
"from",
"active",
"configuration",
"."
] |
c26a8a1537a8d8c2dcee305167980a57384b4e77
|
https://github.com/canax/database-query-builder/blob/c26a8a1537a8d8c2dcee305167980a57384b4e77/src/DatabaseQueryBuilder/DatabaseQueryBuilder.php#L22-L30
|
21,396 |
canax/database-query-builder
|
src/DatabaseQueryBuilder/DatabaseQueryBuilder.php
|
DatabaseQueryBuilder.execute
|
public function execute($query = null, array $params = []) : object
{
// When using one argument and its array, assume its $params
if (is_array($query)) {
$params = $query;
$query = null;
}
if (!$query) {
$query = $this->getSQL();
}
return parent::execute($query, $params);
}
|
php
|
public function execute($query = null, array $params = []) : object
{
// When using one argument and its array, assume its $params
if (is_array($query)) {
$params = $query;
$query = null;
}
if (!$query) {
$query = $this->getSQL();
}
return parent::execute($query, $params);
}
|
[
"public",
"function",
"execute",
"(",
"$",
"query",
"=",
"null",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
":",
"object",
"{",
"// When using one argument and its array, assume its $params",
"if",
"(",
"is_array",
"(",
"$",
"query",
")",
")",
"{",
"$",
"params",
"=",
"$",
"query",
";",
"$",
"query",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"query",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"getSQL",
"(",
")",
";",
"}",
"return",
"parent",
"::",
"execute",
"(",
"$",
"query",
",",
"$",
"params",
")",
";",
"}"
] |
Execute a SQL-query.
@param string|null|array $query the SQL statement (or $params)
@param array $params the params array
@return self
|
[
"Execute",
"a",
"SQL",
"-",
"query",
"."
] |
c26a8a1537a8d8c2dcee305167980a57384b4e77
|
https://github.com/canax/database-query-builder/blob/c26a8a1537a8d8c2dcee305167980a57384b4e77/src/DatabaseQueryBuilder/DatabaseQueryBuilder.php#L42-L55
|
21,397 |
tigron/skeleton-file
|
migration/20160503_215547_restruct_datastore.php
|
Migration_20160503_215547_Restruct_datastore.get_old_path
|
private function get_old_path(File $file) {
if (Config::$store_dir === null AND Config::$file_dir === null) {
throw new \Exception('Set a path first in "Config::$file_dir"');
}
$subpath = substr(base_convert($file->md5sum, 16, 10), 0, 3);
$subpath = implode('/', str_split($subpath)) . '/';
if (\Skeleton\File\Config::$file_dir !== null) {
$path = \Skeleton\File\Config::$file_dir . '/' . $subpath . $file->id . '-' . \Skeleton\File\Util::sanitize_filename($file->name);
} else {
$path = \Skeleton\File\Config::$store_dir . '/file/' . $subpath . $file->id . '-' . \Skeleton\File\Util::sanitize_filename($file->name);
}
return $path;
}
|
php
|
private function get_old_path(File $file) {
if (Config::$store_dir === null AND Config::$file_dir === null) {
throw new \Exception('Set a path first in "Config::$file_dir"');
}
$subpath = substr(base_convert($file->md5sum, 16, 10), 0, 3);
$subpath = implode('/', str_split($subpath)) . '/';
if (\Skeleton\File\Config::$file_dir !== null) {
$path = \Skeleton\File\Config::$file_dir . '/' . $subpath . $file->id . '-' . \Skeleton\File\Util::sanitize_filename($file->name);
} else {
$path = \Skeleton\File\Config::$store_dir . '/file/' . $subpath . $file->id . '-' . \Skeleton\File\Util::sanitize_filename($file->name);
}
return $path;
}
|
[
"private",
"function",
"get_old_path",
"(",
"File",
"$",
"file",
")",
"{",
"if",
"(",
"Config",
"::",
"$",
"store_dir",
"===",
"null",
"AND",
"Config",
"::",
"$",
"file_dir",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Set a path first in \"Config::$file_dir\"'",
")",
";",
"}",
"$",
"subpath",
"=",
"substr",
"(",
"base_convert",
"(",
"$",
"file",
"->",
"md5sum",
",",
"16",
",",
"10",
")",
",",
"0",
",",
"3",
")",
";",
"$",
"subpath",
"=",
"implode",
"(",
"'/'",
",",
"str_split",
"(",
"$",
"subpath",
")",
")",
".",
"'/'",
";",
"if",
"(",
"\\",
"Skeleton",
"\\",
"File",
"\\",
"Config",
"::",
"$",
"file_dir",
"!==",
"null",
")",
"{",
"$",
"path",
"=",
"\\",
"Skeleton",
"\\",
"File",
"\\",
"Config",
"::",
"$",
"file_dir",
".",
"'/'",
".",
"$",
"subpath",
".",
"$",
"file",
"->",
"id",
".",
"'-'",
".",
"\\",
"Skeleton",
"\\",
"File",
"\\",
"Util",
"::",
"sanitize_filename",
"(",
"$",
"file",
"->",
"name",
")",
";",
"}",
"else",
"{",
"$",
"path",
"=",
"\\",
"Skeleton",
"\\",
"File",
"\\",
"Config",
"::",
"$",
"store_dir",
".",
"'/file/'",
".",
"$",
"subpath",
".",
"$",
"file",
"->",
"id",
".",
"'-'",
".",
"\\",
"Skeleton",
"\\",
"File",
"\\",
"Util",
"::",
"sanitize_filename",
"(",
"$",
"file",
"->",
"name",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] |
Get the old path
@access private
@param string $md5sum
@return string $path
|
[
"Get",
"the",
"old",
"path"
] |
97978d49f179f07c76380ddc8919b8a7d56dee61
|
https://github.com/tigron/skeleton-file/blob/97978d49f179f07c76380ddc8919b8a7d56dee61/migration/20160503_215547_restruct_datastore.php#L55-L69
|
21,398 |
surebert/surebert-framework
|
src/sb/Password/Random.php
|
Random.generate
|
protected function generate()
{
$this->password = '';
$chars = range('a', 'z');
$symbols = Array('*', '&', '^', '%', '$', '#', '@', '!');
$chars = array_merge($chars, $symbols);
//get rid of l and o as they can be confused with 1 and 0
unset($chars[11]);
unset($chars[14]);
$chars = array_values($chars);
$chars_length = count($chars);
foreach (range(1, $this->length) as $char) {
$char = '';
$integer = rand(2, 9).'';
$new_char = $chars[rand(0, $chars_length - 1)];
if (strstr($this->password, $new_char)) {
$char = $new_char;
} elseif (strstr($this->password, $integer)) {
$char = $integer;
} else {
$char = rand(0, 1) ? $new_char : $integer;
}
$this->password .= $char;
}
$this->password = substr_replace($this->password, array_rand($symbols), rand(0, strlen($this->password)), 1);
}
|
php
|
protected function generate()
{
$this->password = '';
$chars = range('a', 'z');
$symbols = Array('*', '&', '^', '%', '$', '#', '@', '!');
$chars = array_merge($chars, $symbols);
//get rid of l and o as they can be confused with 1 and 0
unset($chars[11]);
unset($chars[14]);
$chars = array_values($chars);
$chars_length = count($chars);
foreach (range(1, $this->length) as $char) {
$char = '';
$integer = rand(2, 9).'';
$new_char = $chars[rand(0, $chars_length - 1)];
if (strstr($this->password, $new_char)) {
$char = $new_char;
} elseif (strstr($this->password, $integer)) {
$char = $integer;
} else {
$char = rand(0, 1) ? $new_char : $integer;
}
$this->password .= $char;
}
$this->password = substr_replace($this->password, array_rand($symbols), rand(0, strlen($this->password)), 1);
}
|
[
"protected",
"function",
"generate",
"(",
")",
"{",
"$",
"this",
"->",
"password",
"=",
"''",
";",
"$",
"chars",
"=",
"range",
"(",
"'a'",
",",
"'z'",
")",
";",
"$",
"symbols",
"=",
"Array",
"(",
"'*'",
",",
"'&'",
",",
"'^'",
",",
"'%'",
",",
"'$'",
",",
"'#'",
",",
"'@'",
",",
"'!'",
")",
";",
"$",
"chars",
"=",
"array_merge",
"(",
"$",
"chars",
",",
"$",
"symbols",
")",
";",
"//get rid of l and o as they can be confused with 1 and 0",
"unset",
"(",
"$",
"chars",
"[",
"11",
"]",
")",
";",
"unset",
"(",
"$",
"chars",
"[",
"14",
"]",
")",
";",
"$",
"chars",
"=",
"array_values",
"(",
"$",
"chars",
")",
";",
"$",
"chars_length",
"=",
"count",
"(",
"$",
"chars",
")",
";",
"foreach",
"(",
"range",
"(",
"1",
",",
"$",
"this",
"->",
"length",
")",
"as",
"$",
"char",
")",
"{",
"$",
"char",
"=",
"''",
";",
"$",
"integer",
"=",
"rand",
"(",
"2",
",",
"9",
")",
".",
"''",
";",
"$",
"new_char",
"=",
"$",
"chars",
"[",
"rand",
"(",
"0",
",",
"$",
"chars_length",
"-",
"1",
")",
"]",
";",
"if",
"(",
"strstr",
"(",
"$",
"this",
"->",
"password",
",",
"$",
"new_char",
")",
")",
"{",
"$",
"char",
"=",
"$",
"new_char",
";",
"}",
"elseif",
"(",
"strstr",
"(",
"$",
"this",
"->",
"password",
",",
"$",
"integer",
")",
")",
"{",
"$",
"char",
"=",
"$",
"integer",
";",
"}",
"else",
"{",
"$",
"char",
"=",
"rand",
"(",
"0",
",",
"1",
")",
"?",
"$",
"new_char",
":",
"$",
"integer",
";",
"}",
"$",
"this",
"->",
"password",
".=",
"$",
"char",
";",
"}",
"$",
"this",
"->",
"password",
"=",
"substr_replace",
"(",
"$",
"this",
"->",
"password",
",",
"array_rand",
"(",
"$",
"symbols",
")",
",",
"rand",
"(",
"0",
",",
"strlen",
"(",
"$",
"this",
"->",
"password",
")",
")",
",",
"1",
")",
";",
"}"
] |
Generates the password randomly
|
[
"Generates",
"the",
"password",
"randomly"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Password/Random.php#L58-L95
|
21,399 |
surebert/surebert-framework
|
src/sb/Password/Random.php
|
Random.randomlyCapitalize
|
protected function randomlyCapitalize()
{
$chars = str_split($this->password);
$letter_positions = Array();
foreach ($chars as $key => $char) {
if (!is_numeric($char)) {
$letter_positions[] = $key;
}
}
$random_letter = $letter_positions[array_rand($letter_positions)];
$chars[$random_letter] = ucwords($chars[$random_letter]);
$this->password = implode('', $chars);
}
|
php
|
protected function randomlyCapitalize()
{
$chars = str_split($this->password);
$letter_positions = Array();
foreach ($chars as $key => $char) {
if (!is_numeric($char)) {
$letter_positions[] = $key;
}
}
$random_letter = $letter_positions[array_rand($letter_positions)];
$chars[$random_letter] = ucwords($chars[$random_letter]);
$this->password = implode('', $chars);
}
|
[
"protected",
"function",
"randomlyCapitalize",
"(",
")",
"{",
"$",
"chars",
"=",
"str_split",
"(",
"$",
"this",
"->",
"password",
")",
";",
"$",
"letter_positions",
"=",
"Array",
"(",
")",
";",
"foreach",
"(",
"$",
"chars",
"as",
"$",
"key",
"=>",
"$",
"char",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"char",
")",
")",
"{",
"$",
"letter_positions",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"}",
"$",
"random_letter",
"=",
"$",
"letter_positions",
"[",
"array_rand",
"(",
"$",
"letter_positions",
")",
"]",
";",
"$",
"chars",
"[",
"$",
"random_letter",
"]",
"=",
"ucwords",
"(",
"$",
"chars",
"[",
"$",
"random_letter",
"]",
")",
";",
"$",
"this",
"->",
"password",
"=",
"implode",
"(",
"''",
",",
"$",
"chars",
")",
";",
"}"
] |
Randomly capitalize one of the letters in the password
|
[
"Randomly",
"capitalize",
"one",
"of",
"the",
"letters",
"in",
"the",
"password"
] |
f2f32eb693bd39385ceb93355efb5b2a429f27ce
|
https://github.com/surebert/surebert-framework/blob/f2f32eb693bd39385ceb93355efb5b2a429f27ce/src/sb/Password/Random.php#L100-L116
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.