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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
225,300
|
stubbles/stubbles-input
|
src/main/php/ValueReader.php
|
ValueReader.asText
|
public function asText(StringLength $length = null, array $allowedTags = [])
{
return $this->handleFilter(
function() use($length, $allowedTags)
{
$textFilter = new filter\TextFilter();
return filter\RangeFilter::wrap(
$textFilter->allowTags($allowedTags),
$length
);
}
);
}
|
php
|
public function asText(StringLength $length = null, array $allowedTags = [])
{
return $this->handleFilter(
function() use($length, $allowedTags)
{
$textFilter = new filter\TextFilter();
return filter\RangeFilter::wrap(
$textFilter->allowTags($allowedTags),
$length
);
}
);
}
|
[
"public",
"function",
"asText",
"(",
"StringLength",
"$",
"length",
"=",
"null",
",",
"array",
"$",
"allowedTags",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"handleFilter",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"length",
",",
"$",
"allowedTags",
")",
"{",
"$",
"textFilter",
"=",
"new",
"filter",
"\\",
"TextFilter",
"(",
")",
";",
"return",
"filter",
"\\",
"RangeFilter",
"::",
"wrap",
"(",
"$",
"textFilter",
"->",
"allowTags",
"(",
"$",
"allowedTags",
")",
",",
"$",
"length",
")",
";",
"}",
")",
";",
"}"
] |
read as text value
@api
@param \stubbles\input\filter\range\StringLength $length optional allowed length of text
@param string[] $allowedTags optional list of allowed tags
@return string
|
[
"read",
"as",
"text",
"value"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L264-L276
|
225,301
|
stubbles/stubbles-input
|
src/main/php/ValueReader.php
|
ValueReader.asJson
|
public function asJson(int $maxLength = filter\JsonFilter::DEFAULT_MAX_LENGTH)
{
return $this->withFilter(new filter\JsonFilter($maxLength));
}
|
php
|
public function asJson(int $maxLength = filter\JsonFilter::DEFAULT_MAX_LENGTH)
{
return $this->withFilter(new filter\JsonFilter($maxLength));
}
|
[
"public",
"function",
"asJson",
"(",
"int",
"$",
"maxLength",
"=",
"filter",
"\\",
"JsonFilter",
"::",
"DEFAULT_MAX_LENGTH",
")",
"{",
"return",
"$",
"this",
"->",
"withFilter",
"(",
"new",
"filter",
"\\",
"JsonFilter",
"(",
"$",
"maxLength",
")",
")",
";",
"}"
] |
read as json value
@api
@param int $maxLength maximum allowed length of incoming JSON document in bytes optional
@return \stdClass|array
|
[
"read",
"as",
"json",
"value"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L285-L288
|
225,302
|
stubbles/stubbles-input
|
src/main/php/ValueReader.php
|
ValueReader.asHttpUri
|
public function asHttpUri()
{
if ($this->value->isEmpty()) {
return null;
}
if ($this->value->isHttpUri()) {
return HttpUri::fromString($this->value->value());
}
$this->paramErrors->append($this->paramName, 'HTTP_URI_INCORRECT');
return null;
}
|
php
|
public function asHttpUri()
{
if ($this->value->isEmpty()) {
return null;
}
if ($this->value->isHttpUri()) {
return HttpUri::fromString($this->value->value());
}
$this->paramErrors->append($this->paramName, 'HTTP_URI_INCORRECT');
return null;
}
|
[
"public",
"function",
"asHttpUri",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"value",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"value",
"->",
"isHttpUri",
"(",
")",
")",
"{",
"return",
"HttpUri",
"::",
"fromString",
"(",
"$",
"this",
"->",
"value",
"->",
"value",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"paramErrors",
"->",
"append",
"(",
"$",
"this",
"->",
"paramName",
",",
"'HTTP_URI_INCORRECT'",
")",
";",
"return",
"null",
";",
"}"
] |
read as http uri
Return value is null in the following cases:
- Given param value is null or empty string.
- Given param value contains an invalid http uri.
In all other cases an instance of stubbles\peer\http\HttpUri is returned.
@api
@return \stubbles\peer\http\HttpUri
|
[
"read",
"as",
"http",
"uri"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L313-L325
|
225,303
|
stubbles/stubbles-input
|
src/main/php/ValueReader.php
|
ValueReader.asExistingHttpUri
|
public function asExistingHttpUri(callable $checkdnsrr = null)
{
$httpUri = $this->asHttpUri();
if (null === $httpUri) {
return null;
}
if ($httpUri->hasDnsRecord($checkdnsrr)) {
return $httpUri;
}
$this->paramErrors->append($this->paramName, 'HTTP_URI_NOT_AVAILABLE');
return null;
}
|
php
|
public function asExistingHttpUri(callable $checkdnsrr = null)
{
$httpUri = $this->asHttpUri();
if (null === $httpUri) {
return null;
}
if ($httpUri->hasDnsRecord($checkdnsrr)) {
return $httpUri;
}
$this->paramErrors->append($this->paramName, 'HTTP_URI_NOT_AVAILABLE');
return null;
}
|
[
"public",
"function",
"asExistingHttpUri",
"(",
"callable",
"$",
"checkdnsrr",
"=",
"null",
")",
"{",
"$",
"httpUri",
"=",
"$",
"this",
"->",
"asHttpUri",
"(",
")",
";",
"if",
"(",
"null",
"===",
"$",
"httpUri",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"httpUri",
"->",
"hasDnsRecord",
"(",
"$",
"checkdnsrr",
")",
")",
"{",
"return",
"$",
"httpUri",
";",
"}",
"$",
"this",
"->",
"paramErrors",
"->",
"append",
"(",
"$",
"this",
"->",
"paramName",
",",
"'HTTP_URI_NOT_AVAILABLE'",
")",
";",
"return",
"null",
";",
"}"
] |
read as http uri if it does exist
Return value is null in the following cases:
- Given param value is null or empty string.
- Given param value contains an invalid http uri.
- Given http uri doesn't have a DNS record but DNS record is enforced.
In all other cases an instance of stubbles\peer\http\HttpUri is returned.
@api
@param callable $checkdnsrr optional function with which to check DNS record, defaults to checkdnsrr()
@return \stubbles\peer\http\HttpUri
|
[
"read",
"as",
"http",
"uri",
"if",
"it",
"does",
"exist"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L340-L353
|
225,304
|
stubbles/stubbles-input
|
src/main/php/ValueReader.php
|
ValueReader.ifIsIpAddress
|
public function ifIsIpAddress()
{
if ($this->value->isIpAddress()) {
return $this->value->value();
}
$this->paramErrors->append($this->paramName, 'INVALID_IP_ADDRESS');
return null;
}
|
php
|
public function ifIsIpAddress()
{
if ($this->value->isIpAddress()) {
return $this->value->value();
}
$this->paramErrors->append($this->paramName, 'INVALID_IP_ADDRESS');
return null;
}
|
[
"public",
"function",
"ifIsIpAddress",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"value",
"->",
"isIpAddress",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"value",
"->",
"value",
"(",
")",
";",
"}",
"$",
"this",
"->",
"paramErrors",
"->",
"append",
"(",
"$",
"this",
"->",
"paramName",
",",
"'INVALID_IP_ADDRESS'",
")",
";",
"return",
"null",
";",
"}"
] |
returns value if it is an ip address, and null otherwise
@api
@return string
|
[
"returns",
"value",
"if",
"it",
"is",
"an",
"ip",
"address",
"and",
"null",
"otherwise"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L475-L483
|
225,305
|
stubbles/stubbles-input
|
src/main/php/ValueReader.php
|
ValueReader.ifIsOneOf
|
public function ifIsOneOf(array $allowedValues)
{
if ($this->value->isOneOf($allowedValues)) {
return $this->value->value();
}
$this->paramErrors->append(
$this->paramName,
'FIELD_NO_SELECT',
['ALLOWED' => join('|', $allowedValues)]
);
return null;
}
|
php
|
public function ifIsOneOf(array $allowedValues)
{
if ($this->value->isOneOf($allowedValues)) {
return $this->value->value();
}
$this->paramErrors->append(
$this->paramName,
'FIELD_NO_SELECT',
['ALLOWED' => join('|', $allowedValues)]
);
return null;
}
|
[
"public",
"function",
"ifIsOneOf",
"(",
"array",
"$",
"allowedValues",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"value",
"->",
"isOneOf",
"(",
"$",
"allowedValues",
")",
")",
"{",
"return",
"$",
"this",
"->",
"value",
"->",
"value",
"(",
")",
";",
"}",
"$",
"this",
"->",
"paramErrors",
"->",
"append",
"(",
"$",
"this",
"->",
"paramName",
",",
"'FIELD_NO_SELECT'",
",",
"[",
"'ALLOWED'",
"=>",
"join",
"(",
"'|'",
",",
"$",
"allowedValues",
")",
"]",
")",
";",
"return",
"null",
";",
"}"
] |
returns value if it is an allowed value according to list of allowed values, and null otherwise
@api
@param string[] $allowedValues list of allowed values
@return string
|
[
"returns",
"value",
"if",
"it",
"is",
"an",
"allowed",
"value",
"according",
"to",
"list",
"of",
"allowed",
"values",
"and",
"null",
"otherwise"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L492-L504
|
225,306
|
stubbles/stubbles-input
|
src/main/php/ValueReader.php
|
ValueReader.ifMatches
|
public function ifMatches(string $regex)
{
if ($this->value->isMatchedBy($regex)) {
return $this->value->value();
}
$this->paramErrors->append($this->paramName, 'FIELD_WRONG_VALUE');
return null;
}
|
php
|
public function ifMatches(string $regex)
{
if ($this->value->isMatchedBy($regex)) {
return $this->value->value();
}
$this->paramErrors->append($this->paramName, 'FIELD_WRONG_VALUE');
return null;
}
|
[
"public",
"function",
"ifMatches",
"(",
"string",
"$",
"regex",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"value",
"->",
"isMatchedBy",
"(",
"$",
"regex",
")",
")",
"{",
"return",
"$",
"this",
"->",
"value",
"->",
"value",
"(",
")",
";",
"}",
"$",
"this",
"->",
"paramErrors",
"->",
"append",
"(",
"$",
"this",
"->",
"paramName",
",",
"'FIELD_WRONG_VALUE'",
")",
";",
"return",
"null",
";",
"}"
] |
returns value if it is matched by given regular expression
@api
@param string $regex regular expression to apply
@return string
@since 6.0.0
|
[
"returns",
"value",
"if",
"it",
"is",
"matched",
"by",
"given",
"regular",
"expression"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L514-L522
|
225,307
|
stubbles/stubbles-input
|
src/main/php/ValueReader.php
|
ValueReader.when
|
public function when(callable $predicate, string $errorId, array $details = [])
{
return $this->handleFilter(
function() use($predicate, $errorId, $details)
{
return new filter\PredicateFilter($predicate, $errorId, $details);
}
);
}
|
php
|
public function when(callable $predicate, string $errorId, array $details = [])
{
return $this->handleFilter(
function() use($predicate, $errorId, $details)
{
return new filter\PredicateFilter($predicate, $errorId, $details);
}
);
}
|
[
"public",
"function",
"when",
"(",
"callable",
"$",
"predicate",
",",
"string",
"$",
"errorId",
",",
"array",
"$",
"details",
"=",
"[",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"handleFilter",
"(",
"function",
"(",
")",
"use",
"(",
"$",
"predicate",
",",
"$",
"errorId",
",",
"$",
"details",
")",
"{",
"return",
"new",
"filter",
"\\",
"PredicateFilter",
"(",
"$",
"predicate",
",",
"$",
"errorId",
",",
"$",
"details",
")",
";",
"}",
")",
";",
"}"
] |
returns param value when given predicate evaluates to true
If value does not satisfy the predicate return value will be null.
@api
@param callable $predicate predicate to use
@param string $errorId error id to be used in case validation fails
@param array $details optional details for param error in case validation fails
@return string
@since 3.0.0
|
[
"returns",
"param",
"value",
"when",
"given",
"predicate",
"evaluates",
"to",
"true"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L536-L544
|
225,308
|
stubbles/stubbles-input
|
src/main/php/ValueReader.php
|
ValueReader.handleFilter
|
private function handleFilter(\Closure $createFilter)
{
if ($this->value->isNull()) {
return null;
}
return $this->applyFilter($createFilter());
}
|
php
|
private function handleFilter(\Closure $createFilter)
{
if ($this->value->isNull()) {
return null;
}
return $this->applyFilter($createFilter());
}
|
[
"private",
"function",
"handleFilter",
"(",
"\\",
"Closure",
"$",
"createFilter",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"value",
"->",
"isNull",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"applyFilter",
"(",
"$",
"createFilter",
"(",
")",
")",
";",
"}"
] |
handles a filter
@param \Closure $createFilter
@return mixed
|
[
"handles",
"a",
"filter"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L570-L577
|
225,309
|
stubbles/stubbles-input
|
src/main/php/ValueReader.php
|
ValueReader.withCallable
|
public function withCallable(callable $filter)
{
if ($this->value->isNull()) {
return null;
}
return $this->applyFilter(new filter\WrapCallableFilter($filter));
}
|
php
|
public function withCallable(callable $filter)
{
if ($this->value->isNull()) {
return null;
}
return $this->applyFilter(new filter\WrapCallableFilter($filter));
}
|
[
"public",
"function",
"withCallable",
"(",
"callable",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"value",
"->",
"isNull",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"applyFilter",
"(",
"new",
"filter",
"\\",
"WrapCallableFilter",
"(",
"$",
"filter",
")",
")",
";",
"}"
] |
checks value with given callable
The callable must accept an instance of stubbles\input\Param and
return the filtered value. It can add errors to the provided param when
the param value is not satisfying.
<code>
$result = $request->readParam('name')->withCallable(
function(Value $value, array &$errors)
{
if ($value->equals(303)) {
return 'Roland TB-303';
}
$errors['INVALID_303'] = [];
return null;
}
);
</code>
@api
@param callable $filter function to apply for reading the value
@return mixed
@since 3.0.0
|
[
"checks",
"value",
"with",
"given",
"callable"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/ValueReader.php#L626-L633
|
225,310
|
n2n/n2n-log4php
|
src/app/n2n/log4php/appender/AppenderPDO.php
|
AppenderPDO.activateOptions
|
public function activateOptions() {
try {
$this->establishConnection();
} catch (\PDOException $e) {
$this->warn("Failed connecting to database. Closing appender. Error: " . $e->getMessage());
$this->close();
return;
}
// Parse the insert patterns; pattern parts are comma delimited
$pieces = explode(',', $this->insertPattern);
$converterMap = \n2n\log4php\layout\LayoutPattern::getDefaultConverterMap();
foreach($pieces as $pattern) {
$parser = new \n2n\log4php\pattern\PatternParser($pattern, $converterMap);
$this->converters[] = $parser->parse();
}
$this->closed = false;
}
|
php
|
public function activateOptions() {
try {
$this->establishConnection();
} catch (\PDOException $e) {
$this->warn("Failed connecting to database. Closing appender. Error: " . $e->getMessage());
$this->close();
return;
}
// Parse the insert patterns; pattern parts are comma delimited
$pieces = explode(',', $this->insertPattern);
$converterMap = \n2n\log4php\layout\LayoutPattern::getDefaultConverterMap();
foreach($pieces as $pattern) {
$parser = new \n2n\log4php\pattern\PatternParser($pattern, $converterMap);
$this->converters[] = $parser->parse();
}
$this->closed = false;
}
|
[
"public",
"function",
"activateOptions",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"establishConnection",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Failed connecting to database. Closing appender. Error: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"$",
"this",
"->",
"close",
"(",
")",
";",
"return",
";",
"}",
"// Parse the insert patterns; pattern parts are comma delimited\r",
"$",
"pieces",
"=",
"explode",
"(",
"','",
",",
"$",
"this",
"->",
"insertPattern",
")",
";",
"$",
"converterMap",
"=",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"layout",
"\\",
"LayoutPattern",
"::",
"getDefaultConverterMap",
"(",
")",
";",
"foreach",
"(",
"$",
"pieces",
"as",
"$",
"pattern",
")",
"{",
"$",
"parser",
"=",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"pattern",
"\\",
"PatternParser",
"(",
"$",
"pattern",
",",
"$",
"converterMap",
")",
";",
"$",
"this",
"->",
"converters",
"[",
"]",
"=",
"$",
"parser",
"->",
"parse",
"(",
")",
";",
"}",
"$",
"this",
"->",
"closed",
"=",
"false",
";",
"}"
] |
Acquires a database connection based on parameters.
Parses the insert pattern to create a chain of converters which will be
used in forming query parameters from logging events.
|
[
"Acquires",
"a",
"database",
"connection",
"based",
"on",
"parameters",
".",
"Parses",
"the",
"insert",
"pattern",
"to",
"create",
"a",
"chain",
"of",
"converters",
"which",
"will",
"be",
"used",
"in",
"forming",
"query",
"parameters",
"from",
"logging",
"events",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/AppenderPDO.php#L119-L137
|
225,311
|
n2n/n2n-log4php
|
src/app/n2n/log4php/appender/AppenderPDO.php
|
AppenderPDO.establishConnection
|
protected function establishConnection() {
// Acquire database connection
$this->db = new \PDO($this->dsn, $this->user, $this->password);
$this->db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
// Prepare the insert statement
$insertSQL = str_replace('__TABLE__', $this->table, $this->insertSQL);
$this->preparedInsert = $this->db->prepare($insertSQL);
}
|
php
|
protected function establishConnection() {
// Acquire database connection
$this->db = new \PDO($this->dsn, $this->user, $this->password);
$this->db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
// Prepare the insert statement
$insertSQL = str_replace('__TABLE__', $this->table, $this->insertSQL);
$this->preparedInsert = $this->db->prepare($insertSQL);
}
|
[
"protected",
"function",
"establishConnection",
"(",
")",
"{",
"// Acquire database connection\r",
"$",
"this",
"->",
"db",
"=",
"new",
"\\",
"PDO",
"(",
"$",
"this",
"->",
"dsn",
",",
"$",
"this",
"->",
"user",
",",
"$",
"this",
"->",
"password",
")",
";",
"$",
"this",
"->",
"db",
"->",
"setAttribute",
"(",
"\\",
"PDO",
"::",
"ATTR_ERRMODE",
",",
"\\",
"PDO",
"::",
"ERRMODE_EXCEPTION",
")",
";",
"// Prepare the insert statement\r",
"$",
"insertSQL",
"=",
"str_replace",
"(",
"'__TABLE__'",
",",
"$",
"this",
"->",
"table",
",",
"$",
"this",
"->",
"insertSQL",
")",
";",
"$",
"this",
"->",
"preparedInsert",
"=",
"$",
"this",
"->",
"db",
"->",
"prepare",
"(",
"$",
"insertSQL",
")",
";",
"}"
] |
Connects to the database, and prepares the insert query.
@throws PDOException If connect or prepare fails.
|
[
"Connects",
"to",
"the",
"database",
"and",
"prepares",
"the",
"insert",
"query",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/AppenderPDO.php#L143-L151
|
225,312
|
n2n/n2n-log4php
|
src/app/n2n/log4php/appender/AppenderPDO.php
|
AppenderPDO.append
|
public function append(\n2n\log4php\logging\LoggingEvent $event) {
for ($attempt = 1; $attempt <= $this->reconnectAttempts + 1; $attempt++) {
try {
// Attempt to write to database
$this->preparedInsert->execute($this->format($event));
$this->preparedInsert->closeCursor();
break;
} catch (\PDOException $e) {
$this->warn("Failed writing to database: ". $e->getMessage());
// Close the appender if it's the last attempt
if ($attempt > $this->reconnectAttempts) {
$this->warn("Failed writing to database after {$this->reconnectAttempts} reconnect attempts. Closing appender.");
$this->close();
// Otherwise reconnect and try to write again
} else {
$this->warn("Attempting a reconnect (attempt $attempt of {$this->reconnectAttempts}).");
$this->establishConnection();
}
}
}
}
|
php
|
public function append(\n2n\log4php\logging\LoggingEvent $event) {
for ($attempt = 1; $attempt <= $this->reconnectAttempts + 1; $attempt++) {
try {
// Attempt to write to database
$this->preparedInsert->execute($this->format($event));
$this->preparedInsert->closeCursor();
break;
} catch (\PDOException $e) {
$this->warn("Failed writing to database: ". $e->getMessage());
// Close the appender if it's the last attempt
if ($attempt > $this->reconnectAttempts) {
$this->warn("Failed writing to database after {$this->reconnectAttempts} reconnect attempts. Closing appender.");
$this->close();
// Otherwise reconnect and try to write again
} else {
$this->warn("Attempting a reconnect (attempt $attempt of {$this->reconnectAttempts}).");
$this->establishConnection();
}
}
}
}
|
[
"public",
"function",
"append",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"logging",
"\\",
"LoggingEvent",
"$",
"event",
")",
"{",
"for",
"(",
"$",
"attempt",
"=",
"1",
";",
"$",
"attempt",
"<=",
"$",
"this",
"->",
"reconnectAttempts",
"+",
"1",
";",
"$",
"attempt",
"++",
")",
"{",
"try",
"{",
"// Attempt to write to database\r",
"$",
"this",
"->",
"preparedInsert",
"->",
"execute",
"(",
"$",
"this",
"->",
"format",
"(",
"$",
"event",
")",
")",
";",
"$",
"this",
"->",
"preparedInsert",
"->",
"closeCursor",
"(",
")",
";",
"break",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Failed writing to database: \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
")",
";",
"// Close the appender if it's the last attempt\r",
"if",
"(",
"$",
"attempt",
">",
"$",
"this",
"->",
"reconnectAttempts",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Failed writing to database after {$this->reconnectAttempts} reconnect attempts. Closing appender.\"",
")",
";",
"$",
"this",
"->",
"close",
"(",
")",
";",
"// Otherwise reconnect and try to write again\r",
"}",
"else",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Attempting a reconnect (attempt $attempt of {$this->reconnectAttempts}).\"",
")",
";",
"$",
"this",
"->",
"establishConnection",
"(",
")",
";",
"}",
"}",
"}",
"}"
] |
Appends a new event to the database.
If writing to database fails, it will retry by re-establishing the
connection up to $reconnectAttempts times. If writing still fails,
the appender will close.
|
[
"Appends",
"a",
"new",
"event",
"to",
"the",
"database",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/AppenderPDO.php#L160-L182
|
225,313
|
n2n/n2n-log4php
|
src/app/n2n/log4php/appender/AppenderPDO.php
|
AppenderPDO.format
|
protected function format(\n2n\log4php\logging\LoggingEvent $event) {
$params = array();
foreach($this->converters as $converter) {
$buffer = '';
while ($converter !== null) {
$converter->format($buffer, $event);
$converter = $converter->next;
}
$params[] = $buffer;
}
return $params;
}
|
php
|
protected function format(\n2n\log4php\logging\LoggingEvent $event) {
$params = array();
foreach($this->converters as $converter) {
$buffer = '';
while ($converter !== null) {
$converter->format($buffer, $event);
$converter = $converter->next;
}
$params[] = $buffer;
}
return $params;
}
|
[
"protected",
"function",
"format",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"logging",
"\\",
"LoggingEvent",
"$",
"event",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"converters",
"as",
"$",
"converter",
")",
"{",
"$",
"buffer",
"=",
"''",
";",
"while",
"(",
"$",
"converter",
"!==",
"null",
")",
"{",
"$",
"converter",
"->",
"format",
"(",
"$",
"buffer",
",",
"$",
"event",
")",
";",
"$",
"converter",
"=",
"$",
"converter",
"->",
"next",
";",
"}",
"$",
"params",
"[",
"]",
"=",
"$",
"buffer",
";",
"}",
"return",
"$",
"params",
";",
"}"
] |
Converts the logging event to a series of database parameters by using
the converter chain which was set up on activation.
|
[
"Converts",
"the",
"logging",
"event",
"to",
"a",
"series",
"of",
"database",
"parameters",
"by",
"using",
"the",
"converter",
"chain",
"which",
"was",
"set",
"up",
"on",
"activation",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/appender/AppenderPDO.php#L188-L199
|
225,314
|
UCSLabs/Pagination
|
src/EfficientPaginator.php
|
EfficientPaginator.setOrderBy
|
public function setOrderBy($sort, $direction = 'ASC')
{
$this->sort = $sort;
$this->direction = $direction;
return $this;
}
|
php
|
public function setOrderBy($sort, $direction = 'ASC')
{
$this->sort = $sort;
$this->direction = $direction;
return $this;
}
|
[
"public",
"function",
"setOrderBy",
"(",
"$",
"sort",
",",
"$",
"direction",
"=",
"'ASC'",
")",
"{",
"$",
"this",
"->",
"sort",
"=",
"$",
"sort",
";",
"$",
"this",
"->",
"direction",
"=",
"$",
"direction",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets th order by
@param string $sort the sorting property
@param string $direction the direciton ordering property
@return EfficientPaginator This query object.
|
[
"Sets",
"th",
"order",
"by"
] |
0e26d054f53ecb20960c409322acb565ce30b675
|
https://github.com/UCSLabs/Pagination/blob/0e26d054f53ecb20960c409322acb565ce30b675/src/EfficientPaginator.php#L209-L214
|
225,315
|
Finesse/MiniDB
|
src/Parts/SelectTrait.php
|
SelectTrait.get
|
public function get(): array
{
try {
$query = $this->apply($this->database->getTablePrefixer());
$compiled = $this->database->getGrammar()->compileSelect($query);
return $this->database->select($compiled->getSQL(), $compiled->getBindings());
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
php
|
public function get(): array
{
try {
$query = $this->apply($this->database->getTablePrefixer());
$compiled = $this->database->getGrammar()->compileSelect($query);
return $this->database->select($compiled->getSQL(), $compiled->getBindings());
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
[
"public",
"function",
"get",
"(",
")",
":",
"array",
"{",
"try",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"apply",
"(",
"$",
"this",
"->",
"database",
"->",
"getTablePrefixer",
"(",
")",
")",
";",
"$",
"compiled",
"=",
"$",
"this",
"->",
"database",
"->",
"getGrammar",
"(",
")",
"->",
"compileSelect",
"(",
"$",
"query",
")",
";",
"return",
"$",
"this",
"->",
"database",
"->",
"select",
"(",
"$",
"compiled",
"->",
"getSQL",
"(",
")",
",",
"$",
"compiled",
"->",
"getBindings",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"exception",
")",
"{",
"return",
"$",
"this",
"->",
"handleException",
"(",
"$",
"exception",
")",
";",
"}",
"}"
] |
Performs a select query and returns the selected rows. Doesn't modify itself.
@return array[] Array of the result rows. Result row is an array indexed by columns.
@throws DatabaseException
@throws IncorrectQueryException
|
[
"Performs",
"a",
"select",
"query",
"and",
"returns",
"the",
"selected",
"rows",
".",
"Doesn",
"t",
"modify",
"itself",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/SelectTrait.php#L34-L43
|
225,316
|
Finesse/MiniDB
|
src/Parts/SelectTrait.php
|
SelectTrait.first
|
public function first()
{
try {
$query = (clone $this)->limit(1)->apply($this->database->getTablePrefixer());
$compiled = $this->database->getGrammar()->compileSelect($query);
return $this->database->selectFirst($compiled->getSQL(), $compiled->getBindings());
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
php
|
public function first()
{
try {
$query = (clone $this)->limit(1)->apply($this->database->getTablePrefixer());
$compiled = $this->database->getGrammar()->compileSelect($query);
return $this->database->selectFirst($compiled->getSQL(), $compiled->getBindings());
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
[
"public",
"function",
"first",
"(",
")",
"{",
"try",
"{",
"$",
"query",
"=",
"(",
"clone",
"$",
"this",
")",
"->",
"limit",
"(",
"1",
")",
"->",
"apply",
"(",
"$",
"this",
"->",
"database",
"->",
"getTablePrefixer",
"(",
")",
")",
";",
"$",
"compiled",
"=",
"$",
"this",
"->",
"database",
"->",
"getGrammar",
"(",
")",
"->",
"compileSelect",
"(",
"$",
"query",
")",
";",
"return",
"$",
"this",
"->",
"database",
"->",
"selectFirst",
"(",
"$",
"compiled",
"->",
"getSQL",
"(",
")",
",",
"$",
"compiled",
"->",
"getBindings",
"(",
")",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"exception",
")",
"{",
"return",
"$",
"this",
"->",
"handleException",
"(",
"$",
"exception",
")",
";",
"}",
"}"
] |
Performs a select query and returns the first selected row. Doesn't modify itself.
@return array|null An array indexed by columns. Null if nothing is found.
@throws DatabaseException
@throws IncorrectQueryException
|
[
"Performs",
"a",
"select",
"query",
"and",
"returns",
"the",
"first",
"selected",
"row",
".",
"Doesn",
"t",
"modify",
"itself",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/SelectTrait.php#L52-L61
|
225,317
|
Finesse/MiniDB
|
src/Parts/SelectTrait.php
|
SelectTrait.count
|
public function count($column = '*'): int
{
try {
return $this->getAggregate(function (Query $query) use ($column) {
$query->addCount($column);
});
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
php
|
public function count($column = '*'): int
{
try {
return $this->getAggregate(function (Query $query) use ($column) {
$query->addCount($column);
});
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
[
"public",
"function",
"count",
"(",
"$",
"column",
"=",
"'*'",
")",
":",
"int",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"getAggregate",
"(",
"function",
"(",
"Query",
"$",
"query",
")",
"use",
"(",
"$",
"column",
")",
"{",
"$",
"query",
"->",
"addCount",
"(",
"$",
"column",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"exception",
")",
"{",
"return",
"$",
"this",
"->",
"handleException",
"(",
"$",
"exception",
")",
";",
"}",
"}"
] |
Gets the count of the target rows. Doesn't modify itself.
@param string|\Closure|self|StatementInterface $column Column to count
@return int
@throws DatabaseException
@throws IncorrectQueryException
@throws InvalidArgumentException
@throws InvalidReturnValueException
|
[
"Gets",
"the",
"count",
"of",
"the",
"target",
"rows",
".",
"Doesn",
"t",
"modify",
"itself",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/SelectTrait.php#L73-L82
|
225,318
|
Finesse/MiniDB
|
src/Parts/SelectTrait.php
|
SelectTrait.avg
|
public function avg($column)
{
try {
return $this->getAggregate(function (Query $query) use ($column) {
$query->addAvg($column);
});
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
php
|
public function avg($column)
{
try {
return $this->getAggregate(function (Query $query) use ($column) {
$query->addAvg($column);
});
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
[
"public",
"function",
"avg",
"(",
"$",
"column",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"getAggregate",
"(",
"function",
"(",
"Query",
"$",
"query",
")",
"use",
"(",
"$",
"column",
")",
"{",
"$",
"query",
"->",
"addAvg",
"(",
"$",
"column",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"exception",
")",
"{",
"return",
"$",
"this",
"->",
"handleException",
"(",
"$",
"exception",
")",
";",
"}",
"}"
] |
Gets the average value of the target rows. Doesn't modify itself.
@param string|\Closure|self|StatementInterface $column Column to get average
@return float|null Null is returned when no target row has a value
@throws DatabaseException
@throws IncorrectQueryException
@throws InvalidArgumentException
@throws InvalidReturnValueException
|
[
"Gets",
"the",
"average",
"value",
"of",
"the",
"target",
"rows",
".",
"Doesn",
"t",
"modify",
"itself",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/SelectTrait.php#L94-L103
|
225,319
|
Finesse/MiniDB
|
src/Parts/SelectTrait.php
|
SelectTrait.sum
|
public function sum($column)
{
try {
return $this->getAggregate(function (Query $query) use ($column) {
$query->addSum($column);
});
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
php
|
public function sum($column)
{
try {
return $this->getAggregate(function (Query $query) use ($column) {
$query->addSum($column);
});
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
[
"public",
"function",
"sum",
"(",
"$",
"column",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"getAggregate",
"(",
"function",
"(",
"Query",
"$",
"query",
")",
"use",
"(",
"$",
"column",
")",
"{",
"$",
"query",
"->",
"addSum",
"(",
"$",
"column",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"exception",
")",
"{",
"return",
"$",
"this",
"->",
"handleException",
"(",
"$",
"exception",
")",
";",
"}",
"}"
] |
Gets the sum of the target rows. Doesn't modify itself.
@param string|\Closure|self|StatementInterface $column Column to get sum
@return float|null Null is returned when no target row has a value
@throws DatabaseException
@throws IncorrectQueryException
@throws InvalidArgumentException
@throws InvalidReturnValueException
|
[
"Gets",
"the",
"sum",
"of",
"the",
"target",
"rows",
".",
"Doesn",
"t",
"modify",
"itself",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/SelectTrait.php#L115-L124
|
225,320
|
Finesse/MiniDB
|
src/Parts/SelectTrait.php
|
SelectTrait.min
|
public function min($column)
{
try {
return $this->getAggregate(function (Query $query) use ($column) {
$query->addMin($column);
});
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
php
|
public function min($column)
{
try {
return $this->getAggregate(function (Query $query) use ($column) {
$query->addMin($column);
});
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
[
"public",
"function",
"min",
"(",
"$",
"column",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"getAggregate",
"(",
"function",
"(",
"Query",
"$",
"query",
")",
"use",
"(",
"$",
"column",
")",
"{",
"$",
"query",
"->",
"addMin",
"(",
"$",
"column",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"exception",
")",
"{",
"return",
"$",
"this",
"->",
"handleException",
"(",
"$",
"exception",
")",
";",
"}",
"}"
] |
Gets the minimum value of the target rows. Doesn't modify itself.
@param string|\Closure|self|StatementInterface $column Column to get minimum
@return float|null Null is returned when no target row has a value
@throws DatabaseException
@throws IncorrectQueryException
@throws InvalidArgumentException
@throws InvalidReturnValueException
|
[
"Gets",
"the",
"minimum",
"value",
"of",
"the",
"target",
"rows",
".",
"Doesn",
"t",
"modify",
"itself",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/SelectTrait.php#L136-L145
|
225,321
|
Finesse/MiniDB
|
src/Parts/SelectTrait.php
|
SelectTrait.max
|
public function max($column)
{
try {
return $this->getAggregate(function (Query $query) use ($column) {
$query->addMax($column);
});
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
php
|
public function max($column)
{
try {
return $this->getAggregate(function (Query $query) use ($column) {
$query->addMax($column);
});
} catch (\Throwable $exception) {
return $this->handleException($exception);
}
}
|
[
"public",
"function",
"max",
"(",
"$",
"column",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"getAggregate",
"(",
"function",
"(",
"Query",
"$",
"query",
")",
"use",
"(",
"$",
"column",
")",
"{",
"$",
"query",
"->",
"addMax",
"(",
"$",
"column",
")",
";",
"}",
")",
";",
"}",
"catch",
"(",
"\\",
"Throwable",
"$",
"exception",
")",
"{",
"return",
"$",
"this",
"->",
"handleException",
"(",
"$",
"exception",
")",
";",
"}",
"}"
] |
Gets the maximum value of the target rows. Doesn't modify itself.
@param string|\Closure|self|StatementInterface $column Column to get maximum
@return float|null Null is returned when no target row has a value
@throws DatabaseException
@throws IncorrectQueryException
@throws InvalidArgumentException
@throws InvalidReturnValueException
|
[
"Gets",
"the",
"maximum",
"value",
"of",
"the",
"target",
"rows",
".",
"Doesn",
"t",
"modify",
"itself",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/SelectTrait.php#L157-L166
|
225,322
|
Finesse/MiniDB
|
src/Parts/SelectTrait.php
|
SelectTrait.chunk
|
public function chunk(int $size, callable $callback)
{
if ($size <= 0) {
$this->handleException(new InvalidArgumentException('Chunk size must be greater than zero'));
}
// A copy is made not to mutate this query
$query = clone $this;
for ($offset = 0;; $offset += $size) {
$rows = $query->offset($offset)->limit($size)->get();
if (empty($rows)) {
break;
}
$callback($rows);
if (count($rows) < $size) {
break;
}
}
}
|
php
|
public function chunk(int $size, callable $callback)
{
if ($size <= 0) {
$this->handleException(new InvalidArgumentException('Chunk size must be greater than zero'));
}
// A copy is made not to mutate this query
$query = clone $this;
for ($offset = 0;; $offset += $size) {
$rows = $query->offset($offset)->limit($size)->get();
if (empty($rows)) {
break;
}
$callback($rows);
if (count($rows) < $size) {
break;
}
}
}
|
[
"public",
"function",
"chunk",
"(",
"int",
"$",
"size",
",",
"callable",
"$",
"callback",
")",
"{",
"if",
"(",
"$",
"size",
"<=",
"0",
")",
"{",
"$",
"this",
"->",
"handleException",
"(",
"new",
"InvalidArgumentException",
"(",
"'Chunk size must be greater than zero'",
")",
")",
";",
"}",
"// A copy is made not to mutate this query",
"$",
"query",
"=",
"clone",
"$",
"this",
";",
"for",
"(",
"$",
"offset",
"=",
"0",
";",
";",
"$",
"offset",
"+=",
"$",
"size",
")",
"{",
"$",
"rows",
"=",
"$",
"query",
"->",
"offset",
"(",
"$",
"offset",
")",
"->",
"limit",
"(",
"$",
"size",
")",
"->",
"get",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"rows",
")",
")",
"{",
"break",
";",
"}",
"$",
"callback",
"(",
"$",
"rows",
")",
";",
"if",
"(",
"count",
"(",
"$",
"rows",
")",
"<",
"$",
"size",
")",
"{",
"break",
";",
"}",
"}",
"}"
] |
Walks large amount of rows calling a callback on small portions of rows. Doesn't modify itself.
@param int $size Number of rows per callback call
@param callable $callback The callback. Receives an array of rows as the first argument.
@throws DatabaseException
@throws IncorrectQueryException
@throws InvalidArgumentException
|
[
"Walks",
"large",
"amount",
"of",
"rows",
"calling",
"a",
"callback",
"on",
"small",
"portions",
"of",
"rows",
".",
"Doesn",
"t",
"modify",
"itself",
"."
] |
d70e27cae91f975e9f5bfd506a6e5d6fee0ada65
|
https://github.com/Finesse/MiniDB/blob/d70e27cae91f975e9f5bfd506a6e5d6fee0ada65/src/Parts/SelectTrait.php#L177-L198
|
225,323
|
yawik/behat
|
src/UserContext.php
|
UserContext.tearDown
|
public static function tearDown()
{
$dm = static::$dm;
if (is_null($dm)) {
return;
}
$documents = [
'Applications\Entity\Application',
'Cv\Entity\Cv',
'Jobs\Entity\Job',
'Organizations\Entity\Organization',
'Auth\Entity\User',
'Jobs\Entity\Category',
'Auth\Entity\UserImage',
'Organizations\Entity\OrganizationName',
];
foreach ($documents as $document) {
try {
$dm->createQueryBuilder($document)
->remove()
->getQuery()
->execute()
;
} catch (\Exception $e) {
}
}
}
|
php
|
public static function tearDown()
{
$dm = static::$dm;
if (is_null($dm)) {
return;
}
$documents = [
'Applications\Entity\Application',
'Cv\Entity\Cv',
'Jobs\Entity\Job',
'Organizations\Entity\Organization',
'Auth\Entity\User',
'Jobs\Entity\Category',
'Auth\Entity\UserImage',
'Organizations\Entity\OrganizationName',
];
foreach ($documents as $document) {
try {
$dm->createQueryBuilder($document)
->remove()
->getQuery()
->execute()
;
} catch (\Exception $e) {
}
}
}
|
[
"public",
"static",
"function",
"tearDown",
"(",
")",
"{",
"$",
"dm",
"=",
"static",
"::",
"$",
"dm",
";",
"if",
"(",
"is_null",
"(",
"$",
"dm",
")",
")",
"{",
"return",
";",
"}",
"$",
"documents",
"=",
"[",
"'Applications\\Entity\\Application'",
",",
"'Cv\\Entity\\Cv'",
",",
"'Jobs\\Entity\\Job'",
",",
"'Organizations\\Entity\\Organization'",
",",
"'Auth\\Entity\\User'",
",",
"'Jobs\\Entity\\Category'",
",",
"'Auth\\Entity\\UserImage'",
",",
"'Organizations\\Entity\\OrganizationName'",
",",
"]",
";",
"foreach",
"(",
"$",
"documents",
"as",
"$",
"document",
")",
"{",
"try",
"{",
"$",
"dm",
"->",
"createQueryBuilder",
"(",
"$",
"document",
")",
"->",
"remove",
"(",
")",
"->",
"getQuery",
"(",
")",
"->",
"execute",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"}",
"}",
"}"
] |
Empty all data every each tests
@AfterSuite
|
[
"Empty",
"all",
"data",
"every",
"each",
"tests"
] |
9e776b8aa8a069da13e35d717f7bb35c2f96b277
|
https://github.com/yawik/behat/blob/9e776b8aa8a069da13e35d717f7bb35c2f96b277/src/UserContext.php#L87-L115
|
225,324
|
stubbles/stubbles-input
|
src/main/php/filter/PasswordFilter.php
|
PasswordFilter.parse
|
private function parse($value): array
{
if (is_array($value)) {
if ($value[0] !== $value[1]) {
return $this->error('PASSWORDS_NOT_EQUAL');
}
$value = $value[0];
}
if (empty($value) === 0) {
return [null, []];
}
return [Secret::create($value), []];
}
|
php
|
private function parse($value): array
{
if (is_array($value)) {
if ($value[0] !== $value[1]) {
return $this->error('PASSWORDS_NOT_EQUAL');
}
$value = $value[0];
}
if (empty($value) === 0) {
return [null, []];
}
return [Secret::create($value), []];
}
|
[
"private",
"function",
"parse",
"(",
"$",
"value",
")",
":",
"array",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"$",
"value",
"[",
"0",
"]",
"!==",
"$",
"value",
"[",
"1",
"]",
")",
"{",
"return",
"$",
"this",
"->",
"error",
"(",
"'PASSWORDS_NOT_EQUAL'",
")",
";",
"}",
"$",
"value",
"=",
"$",
"value",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
"===",
"0",
")",
"{",
"return",
"[",
"null",
",",
"[",
"]",
"]",
";",
"}",
"return",
"[",
"Secret",
"::",
"create",
"(",
"$",
"value",
")",
",",
"[",
"]",
"]",
";",
"}"
] |
parses password from given param value
@param string|array $value
@return array
|
[
"parses",
"password",
"from",
"given",
"param",
"value"
] |
1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e
|
https://github.com/stubbles/stubbles-input/blob/1ce0ebe5ba392faf3cc369a95e3fe0fa38912b1e/src/main/php/filter/PasswordFilter.php#L78-L93
|
225,325
|
SetBased/php-abc-form
|
src/Cleaner/UrlCleaner.php
|
UrlCleaner.clean
|
public function clean($value)
{
// First prune whitespace.
$cleaner = PruneWhitespaceCleaner::get();
$value = $cleaner->clean($value);
// If the value is empty return immediately,
if ($value==='' || $value===null || $value===false)
{
return null;
}
// Split the URL in parts.
$parts = parse_url($value);
if (!is_array($parts))
{
return $value;
}
return Url::unParseUrl($parts, 'http');
}
|
php
|
public function clean($value)
{
// First prune whitespace.
$cleaner = PruneWhitespaceCleaner::get();
$value = $cleaner->clean($value);
// If the value is empty return immediately,
if ($value==='' || $value===null || $value===false)
{
return null;
}
// Split the URL in parts.
$parts = parse_url($value);
if (!is_array($parts))
{
return $value;
}
return Url::unParseUrl($parts, 'http');
}
|
[
"public",
"function",
"clean",
"(",
"$",
"value",
")",
"{",
"// First prune whitespace.",
"$",
"cleaner",
"=",
"PruneWhitespaceCleaner",
"::",
"get",
"(",
")",
";",
"$",
"value",
"=",
"$",
"cleaner",
"->",
"clean",
"(",
"$",
"value",
")",
";",
"// If the value is empty return immediately,",
"if",
"(",
"$",
"value",
"===",
"''",
"||",
"$",
"value",
"===",
"null",
"||",
"$",
"value",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"// Split the URL in parts.",
"$",
"parts",
"=",
"parse_url",
"(",
"$",
"value",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"parts",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"return",
"Url",
"::",
"unParseUrl",
"(",
"$",
"parts",
",",
"'http'",
")",
";",
"}"
] |
Returns a normalized URL if the submitted value is a URL. Otherwise returns the submitted value.
@param string|null $value The submitted URL.
@return string|null
@since 1.0.0
@api
|
[
"Returns",
"a",
"normalized",
"URL",
"if",
"the",
"submitted",
"value",
"is",
"a",
"URL",
".",
"Otherwise",
"returns",
"the",
"submitted",
"value",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Cleaner/UrlCleaner.php#L45-L65
|
225,326
|
railken/amethyst-exporter
|
src/Managers/ExporterManager.php
|
ExporterManager.generate
|
public function generate(Exporter $exporter, array $data = [])
{
$result = (new DataBuilderManager())->validateRaw($exporter->data_builder, $data);
if (!$result->ok()) {
return $result;
}
// We assume this class exists.
$className = $exporter->class_name;
if (!class_exists($className)) {
throw new \Exception();
}
dispatch(new $className($exporter, $data, $this->getAgent()));
return $result;
}
|
php
|
public function generate(Exporter $exporter, array $data = [])
{
$result = (new DataBuilderManager())->validateRaw($exporter->data_builder, $data);
if (!$result->ok()) {
return $result;
}
// We assume this class exists.
$className = $exporter->class_name;
if (!class_exists($className)) {
throw new \Exception();
}
dispatch(new $className($exporter, $data, $this->getAgent()));
return $result;
}
|
[
"public",
"function",
"generate",
"(",
"Exporter",
"$",
"exporter",
",",
"array",
"$",
"data",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"(",
"new",
"DataBuilderManager",
"(",
")",
")",
"->",
"validateRaw",
"(",
"$",
"exporter",
"->",
"data_builder",
",",
"$",
"data",
")",
";",
"if",
"(",
"!",
"$",
"result",
"->",
"ok",
"(",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"// We assume this class exists.",
"$",
"className",
"=",
"$",
"exporter",
"->",
"class_name",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
")",
";",
"}",
"dispatch",
"(",
"new",
"$",
"className",
"(",
"$",
"exporter",
",",
"$",
"data",
",",
"$",
"this",
"->",
"getAgent",
"(",
")",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Request a exporter.
@param Exporter $exporter
@param array $data
@return \Railken\Lem\Contracts\ResultContract
|
[
"Request",
"a",
"exporter",
"."
] |
ee3ef85f2364d52a76e2e08b6344960892515b94
|
https://github.com/railken/amethyst-exporter/blob/ee3ef85f2364d52a76e2e08b6344960892515b94/src/Managers/ExporterManager.php#L26-L44
|
225,327
|
SetBased/php-abc-form
|
src/Formatter/DateFormatter.php
|
DateFormatter.format
|
public function format($value)
{
if ($value===null) return null;
$match = preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $value, $parts);
$valid = ($match && checkdate((int)$parts[2], (int)$parts[3], (int)$parts[1]));
if ($valid)
{
if ($value===$this->openDate) return '';
$date = new \DateTime($value);
return $date->format($this->format);
}
return $value;
}
|
php
|
public function format($value)
{
if ($value===null) return null;
$match = preg_match('/^(\d{4})-(\d{1,2})-(\d{1,2})$/', $value, $parts);
$valid = ($match && checkdate((int)$parts[2], (int)$parts[3], (int)$parts[1]));
if ($valid)
{
if ($value===$this->openDate) return '';
$date = new \DateTime($value);
return $date->format($this->format);
}
return $value;
}
|
[
"public",
"function",
"format",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"return",
"null",
";",
"$",
"match",
"=",
"preg_match",
"(",
"'/^(\\d{4})-(\\d{1,2})-(\\d{1,2})$/'",
",",
"$",
"value",
",",
"$",
"parts",
")",
";",
"$",
"valid",
"=",
"(",
"$",
"match",
"&&",
"checkdate",
"(",
"(",
"int",
")",
"$",
"parts",
"[",
"2",
"]",
",",
"(",
"int",
")",
"$",
"parts",
"[",
"3",
"]",
",",
"(",
"int",
")",
"$",
"parts",
"[",
"1",
"]",
")",
")",
";",
"if",
"(",
"$",
"valid",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"$",
"this",
"->",
"openDate",
")",
"return",
"''",
";",
"$",
"date",
"=",
"new",
"\\",
"DateTime",
"(",
"$",
"value",
")",
";",
"return",
"$",
"date",
"->",
"format",
"(",
"$",
"this",
"->",
"format",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
If the machine value is a valid date returns the date formatted according the format specifier. Otherwise,
returns the machine value unchanged.
@param string|null $value The machine value.
@return string|null
@since 1.0.0
@api
|
[
"If",
"the",
"machine",
"value",
"is",
"a",
"valid",
"date",
"returns",
"the",
"date",
"formatted",
"according",
"the",
"format",
"specifier",
".",
"Otherwise",
"returns",
"the",
"machine",
"value",
"unchanged",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Formatter/DateFormatter.php#L52-L68
|
225,328
|
n2n/n2n-log4php
|
src/app/n2n/log4php/configurator/ConfiguratorDefault.php
|
ConfiguratorDefault.parse
|
public function parse($input) {
// No input - use default configuration
if (!isset($input)) {
$config = self::$defaultConfiguration;
}
// Array input - contains configuration within the array
else if (is_array($input)) {
$config = $input;
}
// String input - contains path to configuration file
else if (is_string($input)) {
try {
$config = $this->parseFile($input);
} catch (\n2n\log4php\LoggerException $e) {
$this->warn("Configuration failed. " . $e->getMessage() . " Using default configuration.");
$config = self::$defaultConfiguration;
}
}
// Anything else is an error
else {
$this->warn("Invalid configuration param given. Reverting to default configuration.");
$config = self::$defaultConfiguration;
}
return $config;
}
|
php
|
public function parse($input) {
// No input - use default configuration
if (!isset($input)) {
$config = self::$defaultConfiguration;
}
// Array input - contains configuration within the array
else if (is_array($input)) {
$config = $input;
}
// String input - contains path to configuration file
else if (is_string($input)) {
try {
$config = $this->parseFile($input);
} catch (\n2n\log4php\LoggerException $e) {
$this->warn("Configuration failed. " . $e->getMessage() . " Using default configuration.");
$config = self::$defaultConfiguration;
}
}
// Anything else is an error
else {
$this->warn("Invalid configuration param given. Reverting to default configuration.");
$config = self::$defaultConfiguration;
}
return $config;
}
|
[
"public",
"function",
"parse",
"(",
"$",
"input",
")",
"{",
"// No input - use default configuration\r",
"if",
"(",
"!",
"isset",
"(",
"$",
"input",
")",
")",
"{",
"$",
"config",
"=",
"self",
"::",
"$",
"defaultConfiguration",
";",
"}",
"// Array input - contains configuration within the array\r",
"else",
"if",
"(",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
"$",
"config",
"=",
"$",
"input",
";",
"}",
"// String input - contains path to configuration file\r",
"else",
"if",
"(",
"is_string",
"(",
"$",
"input",
")",
")",
"{",
"try",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"parseFile",
"(",
"$",
"input",
")",
";",
"}",
"catch",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Configuration failed. \"",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
".",
"\" Using default configuration.\"",
")",
";",
"$",
"config",
"=",
"self",
"::",
"$",
"defaultConfiguration",
";",
"}",
"}",
"// Anything else is an error\r",
"else",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Invalid configuration param given. Reverting to default configuration.\"",
")",
";",
"$",
"config",
"=",
"self",
"::",
"$",
"defaultConfiguration",
";",
"}",
"return",
"$",
"config",
";",
"}"
] |
Parses the given configuration and returns the parsed configuration
as a PHP array. Does not perform any configuration.
If no configuration is given, or if the given configuration cannot be
parsed for whatever reason, a warning will be issued, and the default
configuration will be returned ({@link $defaultConfiguration}).
@param string|array $input Either path to the config file or the
configuration as an array. If not set, default configuration
will be used.
@return array The parsed configuration.
|
[
"Parses",
"the",
"given",
"configuration",
"and",
"returns",
"the",
"parsed",
"configuration",
"as",
"a",
"PHP",
"array",
".",
"Does",
"not",
"perform",
"any",
"configuration",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/configurator/ConfiguratorDefault.php#L101-L129
|
225,329
|
n2n/n2n-log4php
|
src/app/n2n/log4php/configurator/ConfiguratorDefault.php
|
ConfiguratorDefault.parseFile
|
private function parseFile($url) {
if (!file_exists($url)) {
throw new \n2n\log4php\LoggerException("File not found at [$url].");
}
$type = $this->getConfigType($url);
$adapterClass = $this->adapters[$type];
$adapter = new $adapterClass();
return $adapter->convert($url);
}
|
php
|
private function parseFile($url) {
if (!file_exists($url)) {
throw new \n2n\log4php\LoggerException("File not found at [$url].");
}
$type = $this->getConfigType($url);
$adapterClass = $this->adapters[$type];
$adapter = new $adapterClass();
return $adapter->convert($url);
}
|
[
"private",
"function",
"parseFile",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"url",
")",
")",
"{",
"throw",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"(",
"\"File not found at [$url].\"",
")",
";",
"}",
"$",
"type",
"=",
"$",
"this",
"->",
"getConfigType",
"(",
"$",
"url",
")",
";",
"$",
"adapterClass",
"=",
"$",
"this",
"->",
"adapters",
"[",
"$",
"type",
"]",
";",
"$",
"adapter",
"=",
"new",
"$",
"adapterClass",
"(",
")",
";",
"return",
"$",
"adapter",
"->",
"convert",
"(",
"$",
"url",
")",
";",
"}"
] |
Loads the configuration file from the given URL, determines which
adapter to use, converts the configuration to a PHP array and
returns it.
@param string $url Path to the config file.
@return The configuration from the config file, as a PHP array.
@throws \n2n\log4php\LoggerException If the configuration file cannot be loaded, or
if the parsing fails.
|
[
"Loads",
"the",
"configuration",
"file",
"from",
"the",
"given",
"URL",
"determines",
"which",
"adapter",
"to",
"use",
"converts",
"the",
"configuration",
"to",
"a",
"PHP",
"array",
"and",
"returns",
"it",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/configurator/ConfiguratorDefault.php#L149-L160
|
225,330
|
n2n/n2n-log4php
|
src/app/n2n/log4php/configurator/ConfiguratorDefault.php
|
ConfiguratorDefault.getConfigType
|
private function getConfigType($url) {
$info = pathinfo($url);
$ext = strtolower($info['extension']);
switch($ext) {
case 'xml':
return self::FORMAT_XML;
case 'ini':
case 'properties':
return self::FORMAT_INI;
case 'php':
return self::FORMAT_PHP;
default:
throw new \n2n\log4php\LoggerException("Unsupported configuration file extension: $ext");
}
}
|
php
|
private function getConfigType($url) {
$info = pathinfo($url);
$ext = strtolower($info['extension']);
switch($ext) {
case 'xml':
return self::FORMAT_XML;
case 'ini':
case 'properties':
return self::FORMAT_INI;
case 'php':
return self::FORMAT_PHP;
default:
throw new \n2n\log4php\LoggerException("Unsupported configuration file extension: $ext");
}
}
|
[
"private",
"function",
"getConfigType",
"(",
"$",
"url",
")",
"{",
"$",
"info",
"=",
"pathinfo",
"(",
"$",
"url",
")",
";",
"$",
"ext",
"=",
"strtolower",
"(",
"$",
"info",
"[",
"'extension'",
"]",
")",
";",
"switch",
"(",
"$",
"ext",
")",
"{",
"case",
"'xml'",
":",
"return",
"self",
"::",
"FORMAT_XML",
";",
"case",
"'ini'",
":",
"case",
"'properties'",
":",
"return",
"self",
"::",
"FORMAT_INI",
";",
"case",
"'php'",
":",
"return",
"self",
"::",
"FORMAT_PHP",
";",
"default",
":",
"throw",
"new",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerException",
"(",
"\"Unsupported configuration file extension: $ext\"",
")",
";",
"}",
"}"
] |
Determines configuration file type based on the file extension.
|
[
"Determines",
"configuration",
"file",
"type",
"based",
"on",
"the",
"file",
"extension",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/configurator/ConfiguratorDefault.php#L163-L181
|
225,331
|
n2n/n2n-log4php
|
src/app/n2n/log4php/configurator/ConfiguratorDefault.php
|
ConfiguratorDefault.doConfigure
|
private function doConfigure(\n2n\log4php\LoggerHierarchy $hierarchy, $config) {
if (isset($config['threshold'])) {
$threshold = \n2n\log4php\LoggerLevel::toLevel($config['threshold']);
if (isset($threshold)) {
$hierarchy->setThreshold($threshold);
} else {
$this->warn("Invalid threshold value [{$config['threshold']}] specified. Ignoring threshold definition.");
}
}
// Configure appenders and add them to the appender pool
if (isset($config['appenders']) && is_array($config['appenders'])) {
foreach($config['appenders'] as $name => $appenderConfig) {
$this->configureAppender($name, $appenderConfig);
}
}
// Configure root logger
if (isset($config['rootLogger'])) {
$this->configureRootLogger($hierarchy, $config['rootLogger']);
}
// Configure loggers
if (isset($config['loggers']) && is_array($config['loggers'])) {
foreach($config['loggers'] as $loggerName => $loggerConfig) {
$this->configureOtherLogger($hierarchy, $loggerName, $loggerConfig);
}
}
// Configure renderers
if (isset($config['renderers']) && is_array($config['renderers'])) {
foreach($config['renderers'] as $rendererConfig) {
$this->configureRenderer($hierarchy, $rendererConfig);
}
}
if (isset($config['defaultRenderer'])) {
$this->configureDefaultRenderer($hierarchy, $config['defaultRenderer']);
}
}
|
php
|
private function doConfigure(\n2n\log4php\LoggerHierarchy $hierarchy, $config) {
if (isset($config['threshold'])) {
$threshold = \n2n\log4php\LoggerLevel::toLevel($config['threshold']);
if (isset($threshold)) {
$hierarchy->setThreshold($threshold);
} else {
$this->warn("Invalid threshold value [{$config['threshold']}] specified. Ignoring threshold definition.");
}
}
// Configure appenders and add them to the appender pool
if (isset($config['appenders']) && is_array($config['appenders'])) {
foreach($config['appenders'] as $name => $appenderConfig) {
$this->configureAppender($name, $appenderConfig);
}
}
// Configure root logger
if (isset($config['rootLogger'])) {
$this->configureRootLogger($hierarchy, $config['rootLogger']);
}
// Configure loggers
if (isset($config['loggers']) && is_array($config['loggers'])) {
foreach($config['loggers'] as $loggerName => $loggerConfig) {
$this->configureOtherLogger($hierarchy, $loggerName, $loggerConfig);
}
}
// Configure renderers
if (isset($config['renderers']) && is_array($config['renderers'])) {
foreach($config['renderers'] as $rendererConfig) {
$this->configureRenderer($hierarchy, $rendererConfig);
}
}
if (isset($config['defaultRenderer'])) {
$this->configureDefaultRenderer($hierarchy, $config['defaultRenderer']);
}
}
|
[
"private",
"function",
"doConfigure",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerHierarchy",
"$",
"hierarchy",
",",
"$",
"config",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'threshold'",
"]",
")",
")",
"{",
"$",
"threshold",
"=",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerLevel",
"::",
"toLevel",
"(",
"$",
"config",
"[",
"'threshold'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"threshold",
")",
")",
"{",
"$",
"hierarchy",
"->",
"setThreshold",
"(",
"$",
"threshold",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Invalid threshold value [{$config['threshold']}] specified. Ignoring threshold definition.\"",
")",
";",
"}",
"}",
"// Configure appenders and add them to the appender pool\r",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'appenders'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'appenders'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"config",
"[",
"'appenders'",
"]",
"as",
"$",
"name",
"=>",
"$",
"appenderConfig",
")",
"{",
"$",
"this",
"->",
"configureAppender",
"(",
"$",
"name",
",",
"$",
"appenderConfig",
")",
";",
"}",
"}",
"// Configure root logger \r",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'rootLogger'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"configureRootLogger",
"(",
"$",
"hierarchy",
",",
"$",
"config",
"[",
"'rootLogger'",
"]",
")",
";",
"}",
"// Configure loggers\r",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'loggers'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'loggers'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"config",
"[",
"'loggers'",
"]",
"as",
"$",
"loggerName",
"=>",
"$",
"loggerConfig",
")",
"{",
"$",
"this",
"->",
"configureOtherLogger",
"(",
"$",
"hierarchy",
",",
"$",
"loggerName",
",",
"$",
"loggerConfig",
")",
";",
"}",
"}",
"// Configure renderers\r",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'renderers'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"config",
"[",
"'renderers'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"config",
"[",
"'renderers'",
"]",
"as",
"$",
"rendererConfig",
")",
"{",
"$",
"this",
"->",
"configureRenderer",
"(",
"$",
"hierarchy",
",",
"$",
"rendererConfig",
")",
";",
"}",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'defaultRenderer'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"configureDefaultRenderer",
"(",
"$",
"hierarchy",
",",
"$",
"config",
"[",
"'defaultRenderer'",
"]",
")",
";",
"}",
"}"
] |
Constructs the logger hierarchy based on configuration.
@param \n2n\log4php\LoggerHierarchy $hierarchy
@param array $config
|
[
"Constructs",
"the",
"logger",
"hierarchy",
"based",
"on",
"configuration",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/configurator/ConfiguratorDefault.php#L189-L228
|
225,332
|
n2n/n2n-log4php
|
src/app/n2n/log4php/configurator/ConfiguratorDefault.php
|
ConfiguratorDefault.createAppenderFilter
|
private function createAppenderFilter(\n2n\log4php\LoggerAppender $appender, $config) {
$name = $appender->getName();
$class = $config['class'];
if (!class_exists($class)) {
$this->warn("Nonexistant filter class [$class] specified on appender [$name]. Skipping filter definition.");
return;
}
$filter = new $class();
if (!($filter instanceof \n2n\log4php\LoggerFilter)) {
$this->warn("Invalid filter class [$class] sepcified on appender [$name]. Skipping filter definition.");
return;
}
if (isset($config['params'])) {
$this->setOptions($filter, $config['params']);
}
$filter->activateOptions();
$appender->addFilter($filter);
}
|
php
|
private function createAppenderFilter(\n2n\log4php\LoggerAppender $appender, $config) {
$name = $appender->getName();
$class = $config['class'];
if (!class_exists($class)) {
$this->warn("Nonexistant filter class [$class] specified on appender [$name]. Skipping filter definition.");
return;
}
$filter = new $class();
if (!($filter instanceof \n2n\log4php\LoggerFilter)) {
$this->warn("Invalid filter class [$class] sepcified on appender [$name]. Skipping filter definition.");
return;
}
if (isset($config['params'])) {
$this->setOptions($filter, $config['params']);
}
$filter->activateOptions();
$appender->addFilter($filter);
}
|
[
"private",
"function",
"createAppenderFilter",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerAppender",
"$",
"appender",
",",
"$",
"config",
")",
"{",
"$",
"name",
"=",
"$",
"appender",
"->",
"getName",
"(",
")",
";",
"$",
"class",
"=",
"$",
"config",
"[",
"'class'",
"]",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Nonexistant filter class [$class] specified on appender [$name]. Skipping filter definition.\"",
")",
";",
"return",
";",
"}",
"$",
"filter",
"=",
"new",
"$",
"class",
"(",
")",
";",
"if",
"(",
"!",
"(",
"$",
"filter",
"instanceof",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerFilter",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Invalid filter class [$class] sepcified on appender [$name]. Skipping filter definition.\"",
")",
";",
"return",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'params'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"setOptions",
"(",
"$",
"filter",
",",
"$",
"config",
"[",
"'params'",
"]",
")",
";",
"}",
"$",
"filter",
"->",
"activateOptions",
"(",
")",
";",
"$",
"appender",
"->",
"addFilter",
"(",
"$",
"filter",
")",
";",
"}"
] |
Parses filter config, creates the filter and adds it to the appender's
filter chain.
@param \n2n\log4php\LoggerAppender $appender
@param array $config Filter configuration.
|
[
"Parses",
"filter",
"config",
"creates",
"the",
"filter",
"and",
"adds",
"it",
"to",
"the",
"appender",
"s",
"filter",
"chain",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/configurator/ConfiguratorDefault.php#L357-L377
|
225,333
|
n2n/n2n-log4php
|
src/app/n2n/log4php/configurator/ConfiguratorDefault.php
|
ConfiguratorDefault.configureRootLogger
|
private function configureRootLogger(\n2n\log4php\LoggerHierarchy $hierarchy, $config) {
$logger = $hierarchy->getRootLogger();
$this->configureLogger($logger, $config);
}
|
php
|
private function configureRootLogger(\n2n\log4php\LoggerHierarchy $hierarchy, $config) {
$logger = $hierarchy->getRootLogger();
$this->configureLogger($logger, $config);
}
|
[
"private",
"function",
"configureRootLogger",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerHierarchy",
"$",
"hierarchy",
",",
"$",
"config",
")",
"{",
"$",
"logger",
"=",
"$",
"hierarchy",
"->",
"getRootLogger",
"(",
")",
";",
"$",
"this",
"->",
"configureLogger",
"(",
"$",
"logger",
",",
"$",
"config",
")",
";",
"}"
] |
Configures the root logger
@see configureLogger()
|
[
"Configures",
"the",
"root",
"logger"
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/configurator/ConfiguratorDefault.php#L383-L386
|
225,334
|
n2n/n2n-log4php
|
src/app/n2n/log4php/configurator/ConfiguratorDefault.php
|
ConfiguratorDefault.configureOtherLogger
|
private function configureOtherLogger(\n2n\log4php\LoggerHierarchy $hierarchy, $name, $config) {
// Get logger from hierarchy (this creates it if it doesn't already exist)
$logger = $hierarchy->getLogger($name);
$this->configureLogger($logger, $config);
}
|
php
|
private function configureOtherLogger(\n2n\log4php\LoggerHierarchy $hierarchy, $name, $config) {
// Get logger from hierarchy (this creates it if it doesn't already exist)
$logger = $hierarchy->getLogger($name);
$this->configureLogger($logger, $config);
}
|
[
"private",
"function",
"configureOtherLogger",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerHierarchy",
"$",
"hierarchy",
",",
"$",
"name",
",",
"$",
"config",
")",
"{",
"// Get logger from hierarchy (this creates it if it doesn't already exist)\r",
"$",
"logger",
"=",
"$",
"hierarchy",
"->",
"getLogger",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"configureLogger",
"(",
"$",
"logger",
",",
"$",
"config",
")",
";",
"}"
] |
Configures a logger which is not root.
@see configureLogger()
|
[
"Configures",
"a",
"logger",
"which",
"is",
"not",
"root",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/configurator/ConfiguratorDefault.php#L392-L396
|
225,335
|
n2n/n2n-log4php
|
src/app/n2n/log4php/configurator/ConfiguratorDefault.php
|
ConfiguratorDefault.configureLogger
|
private function configureLogger(\n2n\log4php\Logger $logger, $config) {
$loggerName = $logger->getName();
// Set logger level
if (isset($config['level'])) {
$level = \n2n\log4php\LoggerLevel::toLevel($config['level']);
if (isset($level)) {
$logger->setLevel($level);
} else {
$this->warn("Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.");
}
}
// Link appenders to logger
if (isset($config['appenders'])) {
foreach($config['appenders'] as $appenderName) {
if (isset($this->appenders[$appenderName])) {
$logger->addAppender($this->appenders[$appenderName]);
} else {
$this->warn("Nonexistnant appender [$appenderName] linked to logger [$loggerName].");
}
}
}
// Set logger additivity
if (isset($config['additivity'])) {
try {
$additivity = \n2n\log4php\option\OptionConverter::toBooleanEx($config['additivity'], null);
$logger->setAdditivity($additivity);
} catch (Exception $ex) {
$this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.");
}
}
}
|
php
|
private function configureLogger(\n2n\log4php\Logger $logger, $config) {
$loggerName = $logger->getName();
// Set logger level
if (isset($config['level'])) {
$level = \n2n\log4php\LoggerLevel::toLevel($config['level']);
if (isset($level)) {
$logger->setLevel($level);
} else {
$this->warn("Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.");
}
}
// Link appenders to logger
if (isset($config['appenders'])) {
foreach($config['appenders'] as $appenderName) {
if (isset($this->appenders[$appenderName])) {
$logger->addAppender($this->appenders[$appenderName]);
} else {
$this->warn("Nonexistnant appender [$appenderName] linked to logger [$loggerName].");
}
}
}
// Set logger additivity
if (isset($config['additivity'])) {
try {
$additivity = \n2n\log4php\option\OptionConverter::toBooleanEx($config['additivity'], null);
$logger->setAdditivity($additivity);
} catch (Exception $ex) {
$this->warn("Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.");
}
}
}
|
[
"private",
"function",
"configureLogger",
"(",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"Logger",
"$",
"logger",
",",
"$",
"config",
")",
"{",
"$",
"loggerName",
"=",
"$",
"logger",
"->",
"getName",
"(",
")",
";",
"// Set logger level\r",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'level'",
"]",
")",
")",
"{",
"$",
"level",
"=",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"LoggerLevel",
"::",
"toLevel",
"(",
"$",
"config",
"[",
"'level'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"level",
")",
")",
"{",
"$",
"logger",
"->",
"setLevel",
"(",
"$",
"level",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Invalid level value [{$config['level']}] specified for logger [$loggerName]. Ignoring level definition.\"",
")",
";",
"}",
"}",
"// Link appenders to logger\r",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'appenders'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"config",
"[",
"'appenders'",
"]",
"as",
"$",
"appenderName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"appenders",
"[",
"$",
"appenderName",
"]",
")",
")",
"{",
"$",
"logger",
"->",
"addAppender",
"(",
"$",
"this",
"->",
"appenders",
"[",
"$",
"appenderName",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Nonexistnant appender [$appenderName] linked to logger [$loggerName].\"",
")",
";",
"}",
"}",
"}",
"// Set logger additivity\r",
"if",
"(",
"isset",
"(",
"$",
"config",
"[",
"'additivity'",
"]",
")",
")",
"{",
"try",
"{",
"$",
"additivity",
"=",
"\\",
"n2n",
"\\",
"log4php",
"\\",
"option",
"\\",
"OptionConverter",
"::",
"toBooleanEx",
"(",
"$",
"config",
"[",
"'additivity'",
"]",
",",
"null",
")",
";",
"$",
"logger",
"->",
"setAdditivity",
"(",
"$",
"additivity",
")",
";",
"}",
"catch",
"(",
"Exception",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Invalid additivity value [{$config['additivity']}] specified for logger [$loggerName]. Ignoring additivity setting.\"",
")",
";",
"}",
"}",
"}"
] |
Configures a logger.
@param \n2n\log4php\Logger $logger The logger to configure
@param array $config \n2n\log4php\Logger configuration options.
|
[
"Configures",
"a",
"logger",
"."
] |
1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2
|
https://github.com/n2n/n2n-log4php/blob/1e6fff4c2785acdb8c2e0c3d5451cbb7e1b51fc2/src/app/n2n/log4php/configurator/ConfiguratorDefault.php#L404-L437
|
225,336
|
froq/froq-service
|
src/Service.php
|
Service.setMethodArguments
|
public final function setMethodArguments(string $method, array $methodArguments): self
{
$this->methodArguments[$method] = $methodArguments;
return $this;
}
|
php
|
public final function setMethodArguments(string $method, array $methodArguments): self
{
$this->methodArguments[$method] = $methodArguments;
return $this;
}
|
[
"public",
"final",
"function",
"setMethodArguments",
"(",
"string",
"$",
"method",
",",
"array",
"$",
"methodArguments",
")",
":",
"self",
"{",
"$",
"this",
"->",
"methodArguments",
"[",
"$",
"method",
"]",
"=",
"$",
"methodArguments",
";",
"return",
"$",
"this",
";",
"}"
] |
Set method arguments.
@param string $method
@param array $methodArguments
@return self
|
[
"Set",
"method",
"arguments",
"."
] |
c8fb2009100b27b6a0bd1ff8f8d81e102faadebc
|
https://github.com/froq/froq-service/blob/c8fb2009100b27b6a0bd1ff8f8d81e102faadebc/src/Service.php#L294-L299
|
225,337
|
froq/froq-service
|
src/Service.php
|
Service.getMethodArguments
|
public final function getMethodArguments(string $method = null): ?array
{
return $method ? $this->methodArguments[$method] ?? null : $this->methodArguments;
}
|
php
|
public final function getMethodArguments(string $method = null): ?array
{
return $method ? $this->methodArguments[$method] ?? null : $this->methodArguments;
}
|
[
"public",
"final",
"function",
"getMethodArguments",
"(",
"string",
"$",
"method",
"=",
"null",
")",
":",
"?",
"array",
"{",
"return",
"$",
"method",
"?",
"$",
"this",
"->",
"methodArguments",
"[",
"$",
"method",
"]",
"??",
"null",
":",
"$",
"this",
"->",
"methodArguments",
";",
"}"
] |
Get method arguments.
@param string|null $method
@return ?array
|
[
"Get",
"method",
"arguments",
"."
] |
c8fb2009100b27b6a0bd1ff8f8d81e102faadebc
|
https://github.com/froq/froq-service/blob/c8fb2009100b27b6a0bd1ff8f8d81e102faadebc/src/Service.php#L306-L309
|
225,338
|
froq/froq-service
|
src/Service.php
|
Service.isAllowedRequestMethod
|
public final function isAllowedRequestMethod(string $method): bool
{
return $this->allowedRequestMethods == null || in_array($method, (array) $this->allowedRequestMethods);
}
|
php
|
public final function isAllowedRequestMethod(string $method): bool
{
return $this->allowedRequestMethods == null || in_array($method, (array) $this->allowedRequestMethods);
}
|
[
"public",
"final",
"function",
"isAllowedRequestMethod",
"(",
"string",
"$",
"method",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"allowedRequestMethods",
"==",
"null",
"||",
"in_array",
"(",
"$",
"method",
",",
"(",
"array",
")",
"$",
"this",
"->",
"allowedRequestMethods",
")",
";",
"}"
] |
Is allowed request method.
@param string $method
@return bool
|
[
"Is",
"allowed",
"request",
"method",
"."
] |
c8fb2009100b27b6a0bd1ff8f8d81e102faadebc
|
https://github.com/froq/froq-service/blob/c8fb2009100b27b6a0bd1ff8f8d81e102faadebc/src/Service.php#L337-L340
|
225,339
|
froq/froq-service
|
src/Service.php
|
Service.getShortName
|
public final function getShortName(): ?string
{
return ($this->name != null) ? substr($this->name, 0, -strlen(self::SERVICE_NAME_SUFFIX)) : null;
}
|
php
|
public final function getShortName(): ?string
{
return ($this->name != null) ? substr($this->name, 0, -strlen(self::SERVICE_NAME_SUFFIX)) : null;
}
|
[
"public",
"final",
"function",
"getShortName",
"(",
")",
":",
"?",
"string",
"{",
"return",
"(",
"$",
"this",
"->",
"name",
"!=",
"null",
")",
"?",
"substr",
"(",
"$",
"this",
"->",
"name",
",",
"0",
",",
"-",
"strlen",
"(",
"self",
"::",
"SERVICE_NAME_SUFFIX",
")",
")",
":",
"null",
";",
"}"
] |
Get short name.
@return ?string
|
[
"Get",
"short",
"name",
"."
] |
c8fb2009100b27b6a0bd1ff8f8d81e102faadebc
|
https://github.com/froq/froq-service/blob/c8fb2009100b27b6a0bd1ff8f8d81e102faadebc/src/Service.php#L346-L349
|
225,340
|
froq/froq-service
|
src/Service.php
|
Service.loadAcl
|
private final function loadAcl(): void
{
$this->acl = new Acl($this);
$rules = $this->config->get('acl.rules');
if ($rules != null) {
$this->acl->setRules($rules);
}
}
|
php
|
private final function loadAcl(): void
{
$this->acl = new Acl($this);
$rules = $this->config->get('acl.rules');
if ($rules != null) {
$this->acl->setRules($rules);
}
}
|
[
"private",
"final",
"function",
"loadAcl",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"acl",
"=",
"new",
"Acl",
"(",
"$",
"this",
")",
";",
"$",
"rules",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'acl.rules'",
")",
";",
"if",
"(",
"$",
"rules",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"acl",
"->",
"setRules",
"(",
"$",
"rules",
")",
";",
"}",
"}"
] |
Load acl.
@return void
|
[
"Load",
"acl",
"."
] |
c8fb2009100b27b6a0bd1ff8f8d81e102faadebc
|
https://github.com/froq/froq-service/blob/c8fb2009100b27b6a0bd1ff8f8d81e102faadebc/src/Service.php#L677-L685
|
225,341
|
froq/froq-service
|
src/Service.php
|
Service.loadValidation
|
private final function loadValidation(): void
{
$this->validation = new Validation();
$rules = $this->config->get('validation.rules');
if ($rules != null) {
$this->validation->setRules($rules);
}
}
|
php
|
private final function loadValidation(): void
{
$this->validation = new Validation();
$rules = $this->config->get('validation.rules');
if ($rules != null) {
$this->validation->setRules($rules);
}
}
|
[
"private",
"final",
"function",
"loadValidation",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"validation",
"=",
"new",
"Validation",
"(",
")",
";",
"$",
"rules",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'validation.rules'",
")",
";",
"if",
"(",
"$",
"rules",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"validation",
"->",
"setRules",
"(",
"$",
"rules",
")",
";",
"}",
"}"
] |
Load validation.
@return void
|
[
"Load",
"validation",
"."
] |
c8fb2009100b27b6a0bd1ff8f8d81e102faadebc
|
https://github.com/froq/froq-service/blob/c8fb2009100b27b6a0bd1ff8f8d81e102faadebc/src/Service.php#L691-L699
|
225,342
|
php-toolkit/obj-utils
|
src/Traits/StdObjectTrait.php
|
StdObjectTrait.spaceName
|
final public static function spaceName(string $fullName = null): string
{
$fullName = $fullName ?: self::fullName();
$fullName = \str_replace('\\', '/', $fullName);
return \strpos($fullName, '/') ? \dirname($fullName) : null;
}
|
php
|
final public static function spaceName(string $fullName = null): string
{
$fullName = $fullName ?: self::fullName();
$fullName = \str_replace('\\', '/', $fullName);
return \strpos($fullName, '/') ? \dirname($fullName) : null;
}
|
[
"final",
"public",
"static",
"function",
"spaceName",
"(",
"string",
"$",
"fullName",
"=",
"null",
")",
":",
"string",
"{",
"$",
"fullName",
"=",
"$",
"fullName",
"?",
":",
"self",
"::",
"fullName",
"(",
")",
";",
"$",
"fullName",
"=",
"\\",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"fullName",
")",
";",
"return",
"\\",
"strpos",
"(",
"$",
"fullName",
",",
"'/'",
")",
"?",
"\\",
"dirname",
"(",
"$",
"fullName",
")",
":",
"null",
";",
"}"
] |
get called class namespace
@param null|string $fullName
@return string
|
[
"get",
"called",
"class",
"namespace"
] |
69f860762cd0feb0fb23f9005b0df9ce2732de4a
|
https://github.com/php-toolkit/obj-utils/blob/69f860762cd0feb0fb23f9005b0df9ce2732de4a/src/Traits/StdObjectTrait.php#L33-L39
|
225,343
|
Eve-PHP/Framework
|
src/Job/Base.php
|
Base.prepare
|
public function prepare($item)
{
$prepared = array();
foreach($item as $key => $value) {
//if it's null
if($value === null) {
//set it and continue
$prepared[$key] = null;
continue;
}
//if is array
if(is_array($value)) {
//recursive
$prepared[$key] = $this->prepare($value);
continue;
}
//if it can be converted
if(is_scalar($value)) {
$prepared[$key] = (string) $value;
continue;
}
//we tried our best ...
$prepared[$key] = $value;
}
return $prepared;
}
|
php
|
public function prepare($item)
{
$prepared = array();
foreach($item as $key => $value) {
//if it's null
if($value === null) {
//set it and continue
$prepared[$key] = null;
continue;
}
//if is array
if(is_array($value)) {
//recursive
$prepared[$key] = $this->prepare($value);
continue;
}
//if it can be converted
if(is_scalar($value)) {
$prepared[$key] = (string) $value;
continue;
}
//we tried our best ...
$prepared[$key] = $value;
}
return $prepared;
}
|
[
"public",
"function",
"prepare",
"(",
"$",
"item",
")",
"{",
"$",
"prepared",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"item",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"//if it's null",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"//set it and continue",
"$",
"prepared",
"[",
"$",
"key",
"]",
"=",
"null",
";",
"continue",
";",
"}",
"//if is array",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"//recursive",
"$",
"prepared",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"prepare",
"(",
"$",
"value",
")",
";",
"continue",
";",
"}",
"//if it can be converted",
"if",
"(",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"$",
"prepared",
"[",
"$",
"key",
"]",
"=",
"(",
"string",
")",
"$",
"value",
";",
"continue",
";",
"}",
"//we tried our best ...",
"$",
"prepared",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"prepared",
";",
"}"
] |
Make everything into a string
remove empty strings
@param array $item The item to prepare
@return array
|
[
"Make",
"everything",
"into",
"a",
"string",
"remove",
"empty",
"strings"
] |
cd4ca9472c6c46034bde402bf20bf2f86657c608
|
https://github.com/Eve-PHP/Framework/blob/cd4ca9472c6c46034bde402bf20bf2f86657c608/src/Job/Base.php#L55-L85
|
225,344
|
DrNixx/yii2-onix
|
src/data/ActiveRecordEx.php
|
ActiveRecordEx.insert
|
public function insert($runValidation = true, $attributes = null)
{
try {
return parent::insert($runValidation, $attributes);
} catch (\Exception $ex) {
throw new Exception($ex->getMessage(), $ex->getCode(), $ex);
} /** @noinspection PhpUndefinedClassInspection */ catch (\Throwable $ex) {
throw new Exception($ex->getMessage(), $ex->getCode(), $ex);
}
}
|
php
|
public function insert($runValidation = true, $attributes = null)
{
try {
return parent::insert($runValidation, $attributes);
} catch (\Exception $ex) {
throw new Exception($ex->getMessage(), $ex->getCode(), $ex);
} /** @noinspection PhpUndefinedClassInspection */ catch (\Throwable $ex) {
throw new Exception($ex->getMessage(), $ex->getCode(), $ex);
}
}
|
[
"public",
"function",
"insert",
"(",
"$",
"runValidation",
"=",
"true",
",",
"$",
"attributes",
"=",
"null",
")",
"{",
"try",
"{",
"return",
"parent",
"::",
"insert",
"(",
"$",
"runValidation",
",",
"$",
"attributes",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
",",
"$",
"ex",
"->",
"getCode",
"(",
")",
",",
"$",
"ex",
")",
";",
"}",
"/** @noinspection PhpUndefinedClassInspection */",
"catch",
"(",
"\\",
"Throwable",
"$",
"ex",
")",
"{",
"throw",
"new",
"Exception",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
",",
"$",
"ex",
"->",
"getCode",
"(",
")",
",",
"$",
"ex",
")",
";",
"}",
"}"
] |
Inserts a row into the associated database table using the attribute values of this record.
This method performs the following steps in order:
1. call [[beforeValidate()]] when `$runValidation` is `true`. If [[beforeValidate()]]
returns `false`, the rest of the steps will be skipped;
2. call [[afterValidate()]] when `$runValidation` is `true`. If validation
failed, the rest of the steps will be skipped;
3. call [[beforeSave()]]. If [[beforeSave()]] returns `false`,
the rest of the steps will be skipped;
4. insert the record into database. If this fails, it will skip the rest of the steps;
5. call [[afterSave()]];
In the above step 1, 2, 3 and 5, events [[EVENT_BEFORE_VALIDATE]],
[[EVENT_AFTER_VALIDATE]], [[EVENT_BEFORE_INSERT]], and [[EVENT_AFTER_INSERT]]
will be raised by the corresponding methods.
Only the [[dirtyAttributes|changed attribute values]] will be inserted into database.
If the table's primary key is auto-incremental and is `null` during insertion,
it will be populated with the actual value after insertion.
For example, to insert a customer record:
```php
$customer = new Customer;
$customer->name = $name;
$customer->email = $email;
$customer->insert();
```
@param bool $runValidation whether to perform validation (calling [[validate()]])
before saving the record. Defaults to `true`. If the validation fails, the record
will not be saved to the database and this method will return `false`.
@param array $attributes list of attributes that need to be saved. Defaults to `null`,
meaning all attributes that are loaded from DB will be saved.
@return bool whether the attributes are valid and the record is inserted successfully.
@throws Exception
|
[
"Inserts",
"a",
"row",
"into",
"the",
"associated",
"database",
"table",
"using",
"the",
"attribute",
"values",
"of",
"this",
"record",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/data/ActiveRecordEx.php#L95-L104
|
225,345
|
DrNixx/yii2-onix
|
src/data/ActiveRecordEx.php
|
ActiveRecordEx.invalidateCache
|
public function invalidateCache()
{
if (!$this->isNewRecord) {
$cache = Yii::$app->cache;
if ($cache !== null) {
$key = $this->getCacheKey();
if ($key != null) {
Yii::debug(sprintf("Clear cache key %s", $key));
$cache->delete($key);
}
$tags = $this->getCacheTag();
if ($tags !== null) {
TagDependency::invalidate($cache, $tags);
}
}
}
}
|
php
|
public function invalidateCache()
{
if (!$this->isNewRecord) {
$cache = Yii::$app->cache;
if ($cache !== null) {
$key = $this->getCacheKey();
if ($key != null) {
Yii::debug(sprintf("Clear cache key %s", $key));
$cache->delete($key);
}
$tags = $this->getCacheTag();
if ($tags !== null) {
TagDependency::invalidate($cache, $tags);
}
}
}
}
|
[
"public",
"function",
"invalidateCache",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isNewRecord",
")",
"{",
"$",
"cache",
"=",
"Yii",
"::",
"$",
"app",
"->",
"cache",
";",
"if",
"(",
"$",
"cache",
"!==",
"null",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"getCacheKey",
"(",
")",
";",
"if",
"(",
"$",
"key",
"!=",
"null",
")",
"{",
"Yii",
"::",
"debug",
"(",
"sprintf",
"(",
"\"Clear cache key %s\"",
",",
"$",
"key",
")",
")",
";",
"$",
"cache",
"->",
"delete",
"(",
"$",
"key",
")",
";",
"}",
"$",
"tags",
"=",
"$",
"this",
"->",
"getCacheTag",
"(",
")",
";",
"if",
"(",
"$",
"tags",
"!==",
"null",
")",
"{",
"TagDependency",
"::",
"invalidate",
"(",
"$",
"cache",
",",
"$",
"tags",
")",
";",
"}",
"}",
"}",
"}"
] |
Invalidate cache related for object
|
[
"Invalidate",
"cache",
"related",
"for",
"object"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/data/ActiveRecordEx.php#L308-L325
|
225,346
|
ricardopedias/report-collection
|
src/Libs/Styler.php
|
Styler.applyStyles
|
protected function applyStyles($row, $col, array $styles) : bool
{
$buffer = $this->getBuffer();
if (!isset($buffer[$row])) {
return false;
}
if (!isset($buffer[$row][$col])) {
return false;
}
$current_styles = $this->buffer[$row][$col]['styles'];
$results = [];
foreach ($styles as $param => $value) {
if (!isset($this->getDefaultStyles()[$param])) {
// Apenas estilos válidos são permitidos
throw new \InvalidArgumentException("Invalid style {$param}");
} else {
$border_styles = [
'border-top-color',
'border-right-color',
'border-bottom-color',
'border-left-color',
'border-top-style',
'border-right-style',
'border-bottom-style',
'border-left-style',
];
// As bordas são aplicadas de forma mais complexa
if (in_array($param, $border_styles) == true) {
$results[$param] = $this->applyBorderStyle($row, $col, $param, $value);
}
if ($value == 'none' && isset($current_styles[$param])) {
unset($current_styles[$param]);
}
if ($value != 'none') {
$current_styles[$param] = $value;
}
}
}
$this->buffer[$row][$col]['styles'] = $current_styles;
$results = array_unique($results);
return (count($results) == 0 || current($results) === true) ? true : false;
}
|
php
|
protected function applyStyles($row, $col, array $styles) : bool
{
$buffer = $this->getBuffer();
if (!isset($buffer[$row])) {
return false;
}
if (!isset($buffer[$row][$col])) {
return false;
}
$current_styles = $this->buffer[$row][$col]['styles'];
$results = [];
foreach ($styles as $param => $value) {
if (!isset($this->getDefaultStyles()[$param])) {
// Apenas estilos válidos são permitidos
throw new \InvalidArgumentException("Invalid style {$param}");
} else {
$border_styles = [
'border-top-color',
'border-right-color',
'border-bottom-color',
'border-left-color',
'border-top-style',
'border-right-style',
'border-bottom-style',
'border-left-style',
];
// As bordas são aplicadas de forma mais complexa
if (in_array($param, $border_styles) == true) {
$results[$param] = $this->applyBorderStyle($row, $col, $param, $value);
}
if ($value == 'none' && isset($current_styles[$param])) {
unset($current_styles[$param]);
}
if ($value != 'none') {
$current_styles[$param] = $value;
}
}
}
$this->buffer[$row][$col]['styles'] = $current_styles;
$results = array_unique($results);
return (count($results) == 0 || current($results) === true) ? true : false;
}
|
[
"protected",
"function",
"applyStyles",
"(",
"$",
"row",
",",
"$",
"col",
",",
"array",
"$",
"styles",
")",
":",
"bool",
"{",
"$",
"buffer",
"=",
"$",
"this",
"->",
"getBuffer",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"buffer",
"[",
"$",
"row",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"buffer",
"[",
"$",
"row",
"]",
"[",
"$",
"col",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"current_styles",
"=",
"$",
"this",
"->",
"buffer",
"[",
"$",
"row",
"]",
"[",
"$",
"col",
"]",
"[",
"'styles'",
"]",
";",
"$",
"results",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"styles",
"as",
"$",
"param",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"getDefaultStyles",
"(",
")",
"[",
"$",
"param",
"]",
")",
")",
"{",
"// Apenas estilos válidos são permitidos",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid style {$param}\"",
")",
";",
"}",
"else",
"{",
"$",
"border_styles",
"=",
"[",
"'border-top-color'",
",",
"'border-right-color'",
",",
"'border-bottom-color'",
",",
"'border-left-color'",
",",
"'border-top-style'",
",",
"'border-right-style'",
",",
"'border-bottom-style'",
",",
"'border-left-style'",
",",
"]",
";",
"// As bordas são aplicadas de forma mais complexa",
"if",
"(",
"in_array",
"(",
"$",
"param",
",",
"$",
"border_styles",
")",
"==",
"true",
")",
"{",
"$",
"results",
"[",
"$",
"param",
"]",
"=",
"$",
"this",
"->",
"applyBorderStyle",
"(",
"$",
"row",
",",
"$",
"col",
",",
"$",
"param",
",",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"value",
"==",
"'none'",
"&&",
"isset",
"(",
"$",
"current_styles",
"[",
"$",
"param",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"current_styles",
"[",
"$",
"param",
"]",
")",
";",
"}",
"if",
"(",
"$",
"value",
"!=",
"'none'",
")",
"{",
"$",
"current_styles",
"[",
"$",
"param",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"}",
"$",
"this",
"->",
"buffer",
"[",
"$",
"row",
"]",
"[",
"$",
"col",
"]",
"[",
"'styles'",
"]",
"=",
"$",
"current_styles",
";",
"$",
"results",
"=",
"array_unique",
"(",
"$",
"results",
")",
";",
"return",
"(",
"count",
"(",
"$",
"results",
")",
"==",
"0",
"||",
"current",
"(",
"$",
"results",
")",
"===",
"true",
")",
"?",
"true",
":",
"false",
";",
"}"
] |
Aplica os estilos com base nos indices PHP.
@param int $row
@param int $col
@param array $styles
@return bool
|
[
"Aplica",
"os",
"estilos",
"com",
"base",
"nos",
"indices",
"PHP",
"."
] |
8536e2c48f83fa12b5cea20737d50da20945b71d
|
https://github.com/ricardopedias/report-collection/blob/8536e2c48f83fa12b5cea20737d50da20945b71d/src/Libs/Styler.php#L210-L261
|
225,347
|
ricardopedias/report-collection
|
src/Libs/Styler.php
|
Styler.applyBorderStyle
|
protected function applyBorderStyle($row, $col, string $param, $value) : bool
{
$buffer = $this->getBuffer();
if (!isset($buffer[$row])) {
return false;
}
if (!isset($buffer[$row][$col])) {
return false;
}
// Os estilos de borda são aplicados apenas no topo e na esquerda
// Isso diminui a carga na estilização da planilha e corrige possiveis
// bugs no objeto Spreadsheet
$names = explode('-', $param);
$direction = $names[1]; // top, right, bottom, left
switch($direction) {
case 'top':
$this->applyBorderTop($row, $col, $param, $value);
break;
case 'left':
$this->applyBorderLeft($row, $col, $param, $value);
break;
case 'right':
$this->applyBorderRight($row, $col, $param, $value);
break;
case 'bottom':
$this->applyBorderBottom($row, $col, $param, $value);
break;
}
return true;
}
|
php
|
protected function applyBorderStyle($row, $col, string $param, $value) : bool
{
$buffer = $this->getBuffer();
if (!isset($buffer[$row])) {
return false;
}
if (!isset($buffer[$row][$col])) {
return false;
}
// Os estilos de borda são aplicados apenas no topo e na esquerda
// Isso diminui a carga na estilização da planilha e corrige possiveis
// bugs no objeto Spreadsheet
$names = explode('-', $param);
$direction = $names[1]; // top, right, bottom, left
switch($direction) {
case 'top':
$this->applyBorderTop($row, $col, $param, $value);
break;
case 'left':
$this->applyBorderLeft($row, $col, $param, $value);
break;
case 'right':
$this->applyBorderRight($row, $col, $param, $value);
break;
case 'bottom':
$this->applyBorderBottom($row, $col, $param, $value);
break;
}
return true;
}
|
[
"protected",
"function",
"applyBorderStyle",
"(",
"$",
"row",
",",
"$",
"col",
",",
"string",
"$",
"param",
",",
"$",
"value",
")",
":",
"bool",
"{",
"$",
"buffer",
"=",
"$",
"this",
"->",
"getBuffer",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"buffer",
"[",
"$",
"row",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"buffer",
"[",
"$",
"row",
"]",
"[",
"$",
"col",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Os estilos de borda são aplicados apenas no topo e na esquerda",
"// Isso diminui a carga na estilização da planilha e corrige possiveis",
"// bugs no objeto Spreadsheet",
"$",
"names",
"=",
"explode",
"(",
"'-'",
",",
"$",
"param",
")",
";",
"$",
"direction",
"=",
"$",
"names",
"[",
"1",
"]",
";",
"// top, right, bottom, left",
"switch",
"(",
"$",
"direction",
")",
"{",
"case",
"'top'",
":",
"$",
"this",
"->",
"applyBorderTop",
"(",
"$",
"row",
",",
"$",
"col",
",",
"$",
"param",
",",
"$",
"value",
")",
";",
"break",
";",
"case",
"'left'",
":",
"$",
"this",
"->",
"applyBorderLeft",
"(",
"$",
"row",
",",
"$",
"col",
",",
"$",
"param",
",",
"$",
"value",
")",
";",
"break",
";",
"case",
"'right'",
":",
"$",
"this",
"->",
"applyBorderRight",
"(",
"$",
"row",
",",
"$",
"col",
",",
"$",
"param",
",",
"$",
"value",
")",
";",
"break",
";",
"case",
"'bottom'",
":",
"$",
"this",
"->",
"applyBorderBottom",
"(",
"$",
"row",
",",
"$",
"col",
",",
"$",
"param",
",",
"$",
"value",
")",
";",
"break",
";",
"}",
"return",
"true",
";",
"}"
] |
Aplica os estilos para bordas com base nos indices PHP.
@param int $row
@param int $col
@param string $param
@param string $value
@return bool
|
[
"Aplica",
"os",
"estilos",
"para",
"bordas",
"com",
"base",
"nos",
"indices",
"PHP",
"."
] |
8536e2c48f83fa12b5cea20737d50da20945b71d
|
https://github.com/ricardopedias/report-collection/blob/8536e2c48f83fa12b5cea20737d50da20945b71d/src/Libs/Styler.php#L272-L310
|
225,348
|
SetBased/php-abc-form
|
src/Control/SelectControl.php
|
SelectControl.setOptions
|
public function setOptions(?array &$options, string $keyKey, string $labelKey)
{
$this->options = $options;
$this->keyKey = $keyKey;
$this->labelKey = $labelKey;
}
|
php
|
public function setOptions(?array &$options, string $keyKey, string $labelKey)
{
$this->options = $options;
$this->keyKey = $keyKey;
$this->labelKey = $labelKey;
}
|
[
"public",
"function",
"setOptions",
"(",
"?",
"array",
"&",
"$",
"options",
",",
"string",
"$",
"keyKey",
",",
"string",
"$",
"labelKey",
")",
"{",
"$",
"this",
"->",
"options",
"=",
"$",
"options",
";",
"$",
"this",
"->",
"keyKey",
"=",
"$",
"keyKey",
";",
"$",
"this",
"->",
"labelKey",
"=",
"$",
"labelKey",
";",
"}"
] |
Sets the options for this select box.
@param array[]|null $options The options of this select box.
@param string $keyKey The key holding the keys of the options.
@param string $labelKey The key holding the labels for the options.
@since 1.0.0
@api
|
[
"Sets",
"the",
"options",
"for",
"this",
"select",
"box",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/SelectControl.php#L168-L173
|
225,349
|
SetBased/php-abc-form
|
src/Control/SelectControl.php
|
SelectControl.optionAttributes
|
private function optionAttributes(array $option): array
{
$attributes = [];
if (is_array($this->optionAttributesMap))
{
foreach ($this->optionAttributesMap as $key => $name)
{
if (isset($option[$key])) $attributes[$name] = $option[$key];
}
}
return $attributes;
}
|
php
|
private function optionAttributes(array $option): array
{
$attributes = [];
if (is_array($this->optionAttributesMap))
{
foreach ($this->optionAttributesMap as $key => $name)
{
if (isset($option[$key])) $attributes[$name] = $option[$key];
}
}
return $attributes;
}
|
[
"private",
"function",
"optionAttributes",
"(",
"array",
"$",
"option",
")",
":",
"array",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"optionAttributesMap",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"optionAttributesMap",
"as",
"$",
"key",
"=>",
"$",
"name",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"option",
"[",
"$",
"key",
"]",
")",
")",
"$",
"attributes",
"[",
"$",
"name",
"]",
"=",
"$",
"option",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"return",
"$",
"attributes",
";",
"}"
] |
Returns the attributes for the option element.
@param array $option The option.
@return array
|
[
"Returns",
"the",
"attributes",
"for",
"the",
"option",
"element",
"."
] |
a7343e2b7dda411f5f0fc7d64324bc9d021aa73e
|
https://github.com/SetBased/php-abc-form/blob/a7343e2b7dda411f5f0fc7d64324bc9d021aa73e/src/Control/SelectControl.php#L268-L281
|
225,350
|
spiral/translator
|
src/Config/TranslatorConfig.php
|
TranslatorConfig.resolveDomain
|
public function resolveDomain(string $bundle): string
{
$bundle = strtolower(str_replace(['/', '\\'], '-', $bundle));
foreach ($this->config['domains'] as $domain => $patterns) {
foreach ($patterns as $pattern) {
if ($this->matcher->matches($bundle, $pattern)) {
return $domain;
}
}
}
//We can use bundle itself as domain
return $bundle;
}
|
php
|
public function resolveDomain(string $bundle): string
{
$bundle = strtolower(str_replace(['/', '\\'], '-', $bundle));
foreach ($this->config['domains'] as $domain => $patterns) {
foreach ($patterns as $pattern) {
if ($this->matcher->matches($bundle, $pattern)) {
return $domain;
}
}
}
//We can use bundle itself as domain
return $bundle;
}
|
[
"public",
"function",
"resolveDomain",
"(",
"string",
"$",
"bundle",
")",
":",
"string",
"{",
"$",
"bundle",
"=",
"strtolower",
"(",
"str_replace",
"(",
"[",
"'/'",
",",
"'\\\\'",
"]",
",",
"'-'",
",",
"$",
"bundle",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"config",
"[",
"'domains'",
"]",
"as",
"$",
"domain",
"=>",
"$",
"patterns",
")",
"{",
"foreach",
"(",
"$",
"patterns",
"as",
"$",
"pattern",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"matcher",
"->",
"matches",
"(",
"$",
"bundle",
",",
"$",
"pattern",
")",
")",
"{",
"return",
"$",
"domain",
";",
"}",
"}",
"}",
"//We can use bundle itself as domain",
"return",
"$",
"bundle",
";",
"}"
] |
Get domain name associated with given bundle.
@param string $bundle
@return string
|
[
"Get",
"domain",
"name",
"associated",
"with",
"given",
"bundle",
"."
] |
dde0f3d3db7960c22a36b9e781fe30ab51656424
|
https://github.com/spiral/translator/blob/dde0f3d3db7960c22a36b9e781fe30ab51656424/src/Config/TranslatorConfig.php#L104-L118
|
225,351
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/Folder.php
|
Folder.find
|
public function find(string $pattern, int $flags = 0): Collection
{
$files = glob($this->path.'/'.$pattern, $flags);
foreach ($files as $index => $file) {
if (is_dir($file)) {
$files[$index] = new self($file);
} else {
$files[$index] = new File($file);
}
}
return new Collection($files);
}
|
php
|
public function find(string $pattern, int $flags = 0): Collection
{
$files = glob($this->path.'/'.$pattern, $flags);
foreach ($files as $index => $file) {
if (is_dir($file)) {
$files[$index] = new self($file);
} else {
$files[$index] = new File($file);
}
}
return new Collection($files);
}
|
[
"public",
"function",
"find",
"(",
"string",
"$",
"pattern",
",",
"int",
"$",
"flags",
"=",
"0",
")",
":",
"Collection",
"{",
"$",
"files",
"=",
"glob",
"(",
"$",
"this",
"->",
"path",
".",
"'/'",
".",
"$",
"pattern",
",",
"$",
"flags",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"index",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"file",
")",
")",
"{",
"$",
"files",
"[",
"$",
"index",
"]",
"=",
"new",
"self",
"(",
"$",
"file",
")",
";",
"}",
"else",
"{",
"$",
"files",
"[",
"$",
"index",
"]",
"=",
"new",
"File",
"(",
"$",
"file",
")",
";",
"}",
"}",
"return",
"new",
"Collection",
"(",
"$",
"files",
")",
";",
"}"
] |
Find sub files and folders matching a pattern.
@param string $pattern the pattern
@param int $flags Glob flags
@return Collection
@throws FileException
@throws FolderException
|
[
"Find",
"sub",
"files",
"and",
"folders",
"matching",
"a",
"pattern",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/Folder.php#L53-L65
|
225,352
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/Folder.php
|
Folder.findFiles
|
public function findFiles(string $pattern, int $flags = 0): FileCollection
{
$files = glob($this->path.'/'.$pattern, $flags);
foreach ($files as $index => $file) {
if (is_file($file)) {
$files[$index] = new File($file);
} else {
unset($files[$index]);
}
}
return new FileCollection($files);
}
|
php
|
public function findFiles(string $pattern, int $flags = 0): FileCollection
{
$files = glob($this->path.'/'.$pattern, $flags);
foreach ($files as $index => $file) {
if (is_file($file)) {
$files[$index] = new File($file);
} else {
unset($files[$index]);
}
}
return new FileCollection($files);
}
|
[
"public",
"function",
"findFiles",
"(",
"string",
"$",
"pattern",
",",
"int",
"$",
"flags",
"=",
"0",
")",
":",
"FileCollection",
"{",
"$",
"files",
"=",
"glob",
"(",
"$",
"this",
"->",
"path",
".",
"'/'",
".",
"$",
"pattern",
",",
"$",
"flags",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"index",
"=>",
"$",
"file",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"$",
"files",
"[",
"$",
"index",
"]",
"=",
"new",
"File",
"(",
"$",
"file",
")",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"files",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}",
"return",
"new",
"FileCollection",
"(",
"$",
"files",
")",
";",
"}"
] |
Find sub files matching a pattern.
@param string $pattern glob pattern
@param int $flags Glob flags
@return FileCollection
@throws FileException
|
[
"Find",
"sub",
"files",
"matching",
"a",
"pattern",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/Folder.php#L77-L89
|
225,353
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/Folder.php
|
Folder.findFolders
|
public function findFolders(string $pattern, int $flags = 0): FolderCollection
{
$folders = glob($this->path.'/'.$pattern, $flags);
foreach ($folders as $index => $folder) {
if (is_dir($folder)) {
$folders[$index] = new self($folder);
} else {
unset($folders[$index]);
}
}
return new FolderCollection($folders);
}
|
php
|
public function findFolders(string $pattern, int $flags = 0): FolderCollection
{
$folders = glob($this->path.'/'.$pattern, $flags);
foreach ($folders as $index => $folder) {
if (is_dir($folder)) {
$folders[$index] = new self($folder);
} else {
unset($folders[$index]);
}
}
return new FolderCollection($folders);
}
|
[
"public",
"function",
"findFolders",
"(",
"string",
"$",
"pattern",
",",
"int",
"$",
"flags",
"=",
"0",
")",
":",
"FolderCollection",
"{",
"$",
"folders",
"=",
"glob",
"(",
"$",
"this",
"->",
"path",
".",
"'/'",
".",
"$",
"pattern",
",",
"$",
"flags",
")",
";",
"foreach",
"(",
"$",
"folders",
"as",
"$",
"index",
"=>",
"$",
"folder",
")",
"{",
"if",
"(",
"is_dir",
"(",
"$",
"folder",
")",
")",
"{",
"$",
"folders",
"[",
"$",
"index",
"]",
"=",
"new",
"self",
"(",
"$",
"folder",
")",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"folders",
"[",
"$",
"index",
"]",
")",
";",
"}",
"}",
"return",
"new",
"FolderCollection",
"(",
"$",
"folders",
")",
";",
"}"
] |
Find sub folders matching a pattern.
@param string $pattern glob pattern
@param int $flags Glob flags
@return FolderCollection
@throws FolderException
|
[
"Find",
"sub",
"folders",
"matching",
"a",
"pattern",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/Folder.php#L101-L113
|
225,354
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/Folder.php
|
Folder.addFile
|
public function addFile(File $file): self
{
$directory = $this->getPath();
$file->moveToDirectory($directory);
return $this;
}
|
php
|
public function addFile(File $file): self
{
$directory = $this->getPath();
$file->moveToDirectory($directory);
return $this;
}
|
[
"public",
"function",
"addFile",
"(",
"File",
"$",
"file",
")",
":",
"self",
"{",
"$",
"directory",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"$",
"file",
"->",
"moveToDirectory",
"(",
"$",
"directory",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Add file to the folder.
@param File $file
@return static
@throws FileException
@throws FolderException
|
[
"Add",
"file",
"to",
"the",
"folder",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/Folder.php#L125-L131
|
225,355
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/Folder.php
|
Folder.addFiles
|
public function addFiles(Collection $files): self
{
foreach ($files as $file) {
$this->addFile($file);
}
return $this;
}
|
php
|
public function addFiles(Collection $files): self
{
foreach ($files as $file) {
$this->addFile($file);
}
return $this;
}
|
[
"public",
"function",
"addFiles",
"(",
"Collection",
"$",
"files",
")",
":",
"self",
"{",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"this",
"->",
"addFile",
"(",
"$",
"file",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add files to the folder.
@param Collection $files
@return static
@throws FileException
@throws FolderException
|
[
"Add",
"files",
"to",
"the",
"folder",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/Folder.php#L143-L150
|
225,356
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/Folder.php
|
Folder.rename
|
public function rename(string $newFolderName): self
{
$newFolderPath = normalize_path($this->getDirectory().DIRECTORY_SEPARATOR.$newFolderName);
if ($newFolderPath === $this->getPath() || (!is_dir($newFolderPath) && $this->move($newFolderPath))) {
return self::load($newFolderPath);
}
throw new FolderException('Cannot rename the folder, because the new folder path ('.$newFolderPath.') already exists',
FolderException::ALREADY_EXIST);
}
|
php
|
public function rename(string $newFolderName): self
{
$newFolderPath = normalize_path($this->getDirectory().DIRECTORY_SEPARATOR.$newFolderName);
if ($newFolderPath === $this->getPath() || (!is_dir($newFolderPath) && $this->move($newFolderPath))) {
return self::load($newFolderPath);
}
throw new FolderException('Cannot rename the folder, because the new folder path ('.$newFolderPath.') already exists',
FolderException::ALREADY_EXIST);
}
|
[
"public",
"function",
"rename",
"(",
"string",
"$",
"newFolderName",
")",
":",
"self",
"{",
"$",
"newFolderPath",
"=",
"normalize_path",
"(",
"$",
"this",
"->",
"getDirectory",
"(",
")",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"newFolderName",
")",
";",
"if",
"(",
"$",
"newFolderPath",
"===",
"$",
"this",
"->",
"getPath",
"(",
")",
"||",
"(",
"!",
"is_dir",
"(",
"$",
"newFolderPath",
")",
"&&",
"$",
"this",
"->",
"move",
"(",
"$",
"newFolderPath",
")",
")",
")",
"{",
"return",
"self",
"::",
"load",
"(",
"$",
"newFolderPath",
")",
";",
"}",
"throw",
"new",
"FolderException",
"(",
"'Cannot rename the folder, because the new folder path ('",
".",
"$",
"newFolderPath",
".",
"') already exists'",
",",
"FolderException",
"::",
"ALREADY_EXIST",
")",
";",
"}"
] |
Rename folder with new folder name.
@param string $newFolderName New folder name
@return static
@throws FolderException
|
[
"Rename",
"folder",
"with",
"new",
"folder",
"name",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/Folder.php#L249-L257
|
225,357
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/Folder.php
|
Folder.move
|
public function move(string $newFolderPath): self
{
$newFolderPath = normalize_path($newFolderPath);
if (!is_dir($newFolderPath)) {
if (rename($this->path, $newFolderPath)) {
return new self($newFolderPath);
}
throw new FolderException('Cannot move folder to the new folder path ('.$newFolderPath.') for unknown reasons');
}
throw new FolderException('Cannot move the folder, because the new folder path ('.$newFolderPath.') already exists',
FolderException::ALREADY_EXIST);
}
|
php
|
public function move(string $newFolderPath): self
{
$newFolderPath = normalize_path($newFolderPath);
if (!is_dir($newFolderPath)) {
if (rename($this->path, $newFolderPath)) {
return new self($newFolderPath);
}
throw new FolderException('Cannot move folder to the new folder path ('.$newFolderPath.') for unknown reasons');
}
throw new FolderException('Cannot move the folder, because the new folder path ('.$newFolderPath.') already exists',
FolderException::ALREADY_EXIST);
}
|
[
"public",
"function",
"move",
"(",
"string",
"$",
"newFolderPath",
")",
":",
"self",
"{",
"$",
"newFolderPath",
"=",
"normalize_path",
"(",
"$",
"newFolderPath",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"newFolderPath",
")",
")",
"{",
"if",
"(",
"rename",
"(",
"$",
"this",
"->",
"path",
",",
"$",
"newFolderPath",
")",
")",
"{",
"return",
"new",
"self",
"(",
"$",
"newFolderPath",
")",
";",
"}",
"throw",
"new",
"FolderException",
"(",
"'Cannot move folder to the new folder path ('",
".",
"$",
"newFolderPath",
".",
"') for unknown reasons'",
")",
";",
"}",
"throw",
"new",
"FolderException",
"(",
"'Cannot move the folder, because the new folder path ('",
".",
"$",
"newFolderPath",
".",
"') already exists'",
",",
"FolderException",
"::",
"ALREADY_EXIST",
")",
";",
"}"
] |
Move folder to directory and rename it.
@param string $newFolderPath New folder path
@return static
@throws FolderException
|
[
"Move",
"folder",
"to",
"directory",
"and",
"rename",
"it",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/Folder.php#L268-L280
|
225,358
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/Folder.php
|
Folder.moveToDirectory
|
public function moveToDirectory(string $newDirectoryPath): self
{
$newDirectoryPath = normalize_path($newDirectoryPath);
if (is_dir($newDirectoryPath)) {
if (is_writeable($newDirectoryPath)) {
$newFolderPath = $newDirectoryPath.DIRECTORY_SEPARATOR.$this->getName();
return $this->move($newFolderPath);
}
throw new FolderException('Cannot move the folder, because the directory ('.$newDirectoryPath.') is not writable',
FolderException::NOT_WRITEABLE);
}
throw new FolderException('Cannot move the folder, because the directory (('.$newDirectoryPath.')) does not exist',
FolderException::DONT_EXIST);
}
|
php
|
public function moveToDirectory(string $newDirectoryPath): self
{
$newDirectoryPath = normalize_path($newDirectoryPath);
if (is_dir($newDirectoryPath)) {
if (is_writeable($newDirectoryPath)) {
$newFolderPath = $newDirectoryPath.DIRECTORY_SEPARATOR.$this->getName();
return $this->move($newFolderPath);
}
throw new FolderException('Cannot move the folder, because the directory ('.$newDirectoryPath.') is not writable',
FolderException::NOT_WRITEABLE);
}
throw new FolderException('Cannot move the folder, because the directory (('.$newDirectoryPath.')) does not exist',
FolderException::DONT_EXIST);
}
|
[
"public",
"function",
"moveToDirectory",
"(",
"string",
"$",
"newDirectoryPath",
")",
":",
"self",
"{",
"$",
"newDirectoryPath",
"=",
"normalize_path",
"(",
"$",
"newDirectoryPath",
")",
";",
"if",
"(",
"is_dir",
"(",
"$",
"newDirectoryPath",
")",
")",
"{",
"if",
"(",
"is_writeable",
"(",
"$",
"newDirectoryPath",
")",
")",
"{",
"$",
"newFolderPath",
"=",
"$",
"newDirectoryPath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"return",
"$",
"this",
"->",
"move",
"(",
"$",
"newFolderPath",
")",
";",
"}",
"throw",
"new",
"FolderException",
"(",
"'Cannot move the folder, because the directory ('",
".",
"$",
"newDirectoryPath",
".",
"') is not writable'",
",",
"FolderException",
"::",
"NOT_WRITEABLE",
")",
";",
"}",
"throw",
"new",
"FolderException",
"(",
"'Cannot move the folder, because the directory (('",
".",
"$",
"newDirectoryPath",
".",
"')) does not exist'",
",",
"FolderException",
"::",
"DONT_EXIST",
")",
";",
"}"
] |
Move folder to new directory.
@param string $newDirectoryPath New directory path
@return static
@throws FolderException
|
[
"Move",
"folder",
"to",
"new",
"directory",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/Folder.php#L291-L306
|
225,359
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/Folder.php
|
Folder.copy
|
public function copy(string $newFolderPath): self
{
$newFolderPath = normalize_path($newFolderPath);
if (!is_dir($newFolderPath)) {
$newFolder = self::create($newFolderPath);
if ($this->copyContent($newFolder->getPath())) {
return $newFolder;
}
throw new FolderException('Cannot copy folder to the new folder path ('.$newFolderPath.') for unknown reasons');
}
throw new FolderException('Cannot copy the folder, because a folder with the same name and path ('.$newFolderPath.') already exists',
FolderException::ALREADY_EXIST);
}
|
php
|
public function copy(string $newFolderPath): self
{
$newFolderPath = normalize_path($newFolderPath);
if (!is_dir($newFolderPath)) {
$newFolder = self::create($newFolderPath);
if ($this->copyContent($newFolder->getPath())) {
return $newFolder;
}
throw new FolderException('Cannot copy folder to the new folder path ('.$newFolderPath.') for unknown reasons');
}
throw new FolderException('Cannot copy the folder, because a folder with the same name and path ('.$newFolderPath.') already exists',
FolderException::ALREADY_EXIST);
}
|
[
"public",
"function",
"copy",
"(",
"string",
"$",
"newFolderPath",
")",
":",
"self",
"{",
"$",
"newFolderPath",
"=",
"normalize_path",
"(",
"$",
"newFolderPath",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"newFolderPath",
")",
")",
"{",
"$",
"newFolder",
"=",
"self",
"::",
"create",
"(",
"$",
"newFolderPath",
")",
";",
"if",
"(",
"$",
"this",
"->",
"copyContent",
"(",
"$",
"newFolder",
"->",
"getPath",
"(",
")",
")",
")",
"{",
"return",
"$",
"newFolder",
";",
"}",
"throw",
"new",
"FolderException",
"(",
"'Cannot copy folder to the new folder path ('",
".",
"$",
"newFolderPath",
".",
"') for unknown reasons'",
")",
";",
"}",
"throw",
"new",
"FolderException",
"(",
"'Cannot copy the folder, because a folder with the same name and path ('",
".",
"$",
"newFolderPath",
".",
"') already exists'",
",",
"FolderException",
"::",
"ALREADY_EXIST",
")",
";",
"}"
] |
Copy folder to new directory and rename it.
@param string $newFolderPath New folder path
@return Folder
@throws FolderException
|
[
"Copy",
"folder",
"to",
"new",
"directory",
"and",
"rename",
"it",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/Folder.php#L317-L330
|
225,360
|
Everest/Everest-Filesystem
|
src/classes/Everest/Filesystem/Folder.php
|
Folder.copyToDirectory
|
public function copyToDirectory(string $newDirectoryPath): self
{
$newDirectoryPath = normalize_path($newDirectoryPath);
if (is_dir($newDirectoryPath)) {
if (is_writeable($newDirectoryPath)) {
$newFolderPath = $newDirectoryPath.DIRECTORY_SEPARATOR.$this->getName();
$this->copy($newFolderPath);
}
throw new FolderException('Cannot copy the folder, because the new directory path ('.$newDirectoryPath.') is not writable',
FolderException::NOT_WRITEABLE);
}
throw new FolderException('Cannot copy the folder, because the new directory path ('.$newDirectoryPath.') does not exist',
FolderException::DONT_EXIST);
}
|
php
|
public function copyToDirectory(string $newDirectoryPath): self
{
$newDirectoryPath = normalize_path($newDirectoryPath);
if (is_dir($newDirectoryPath)) {
if (is_writeable($newDirectoryPath)) {
$newFolderPath = $newDirectoryPath.DIRECTORY_SEPARATOR.$this->getName();
$this->copy($newFolderPath);
}
throw new FolderException('Cannot copy the folder, because the new directory path ('.$newDirectoryPath.') is not writable',
FolderException::NOT_WRITEABLE);
}
throw new FolderException('Cannot copy the folder, because the new directory path ('.$newDirectoryPath.') does not exist',
FolderException::DONT_EXIST);
}
|
[
"public",
"function",
"copyToDirectory",
"(",
"string",
"$",
"newDirectoryPath",
")",
":",
"self",
"{",
"$",
"newDirectoryPath",
"=",
"normalize_path",
"(",
"$",
"newDirectoryPath",
")",
";",
"if",
"(",
"is_dir",
"(",
"$",
"newDirectoryPath",
")",
")",
"{",
"if",
"(",
"is_writeable",
"(",
"$",
"newDirectoryPath",
")",
")",
"{",
"$",
"newFolderPath",
"=",
"$",
"newDirectoryPath",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"$",
"this",
"->",
"copy",
"(",
"$",
"newFolderPath",
")",
";",
"}",
"throw",
"new",
"FolderException",
"(",
"'Cannot copy the folder, because the new directory path ('",
".",
"$",
"newDirectoryPath",
".",
"') is not writable'",
",",
"FolderException",
"::",
"NOT_WRITEABLE",
")",
";",
"}",
"throw",
"new",
"FolderException",
"(",
"'Cannot copy the folder, because the new directory path ('",
".",
"$",
"newDirectoryPath",
".",
"') does not exist'",
",",
"FolderException",
"::",
"DONT_EXIST",
")",
";",
"}"
] |
Copy folder to new directory path.
@param string $newDirectoryPath New directory path
@return Folder
@throws FolderException
|
[
"Copy",
"folder",
"to",
"new",
"directory",
"path",
"."
] |
67782256e4b09adc7f761944b88ea317a194d677
|
https://github.com/Everest/Everest-Filesystem/blob/67782256e4b09adc7f761944b88ea317a194d677/src/classes/Everest/Filesystem/Folder.php#L341-L355
|
225,361
|
OleMchls/PHP-Metrics-Client
|
src/Metrics/Client.php
|
Client.request
|
protected function request($path, $method, array $data = array()) {
$request = new Request();
$response = new Response();
$transport = $this->getTransport();
$request->setMethod($method);
$request->setResource($this->buildPath($path));
$request->setHost(self::URI);
$request->addHeader('Authorization: Basic ' . base64_encode($this->getAuthCredentials()));
$request->addHeader('User-Agent: ' . $this->getUserAgent());
if (count($data)) {
$request->addHeader('Content-Type: application/json');
$request->setContent(json_encode($data));
}
$transport->send($request, $response);
return json_decode($response->getContent());
}
|
php
|
protected function request($path, $method, array $data = array()) {
$request = new Request();
$response = new Response();
$transport = $this->getTransport();
$request->setMethod($method);
$request->setResource($this->buildPath($path));
$request->setHost(self::URI);
$request->addHeader('Authorization: Basic ' . base64_encode($this->getAuthCredentials()));
$request->addHeader('User-Agent: ' . $this->getUserAgent());
if (count($data)) {
$request->addHeader('Content-Type: application/json');
$request->setContent(json_encode($data));
}
$transport->send($request, $response);
return json_decode($response->getContent());
}
|
[
"protected",
"function",
"request",
"(",
"$",
"path",
",",
"$",
"method",
",",
"array",
"$",
"data",
"=",
"array",
"(",
")",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
")",
";",
"$",
"response",
"=",
"new",
"Response",
"(",
")",
";",
"$",
"transport",
"=",
"$",
"this",
"->",
"getTransport",
"(",
")",
";",
"$",
"request",
"->",
"setMethod",
"(",
"$",
"method",
")",
";",
"$",
"request",
"->",
"setResource",
"(",
"$",
"this",
"->",
"buildPath",
"(",
"$",
"path",
")",
")",
";",
"$",
"request",
"->",
"setHost",
"(",
"self",
"::",
"URI",
")",
";",
"$",
"request",
"->",
"addHeader",
"(",
"'Authorization: Basic '",
".",
"base64_encode",
"(",
"$",
"this",
"->",
"getAuthCredentials",
"(",
")",
")",
")",
";",
"$",
"request",
"->",
"addHeader",
"(",
"'User-Agent: '",
".",
"$",
"this",
"->",
"getUserAgent",
"(",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"data",
")",
")",
"{",
"$",
"request",
"->",
"addHeader",
"(",
"'Content-Type: application/json'",
")",
";",
"$",
"request",
"->",
"setContent",
"(",
"json_encode",
"(",
"$",
"data",
")",
")",
";",
"}",
"$",
"transport",
"->",
"send",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"return",
"json_decode",
"(",
"$",
"response",
"->",
"getContent",
"(",
")",
")",
";",
"}"
] |
Helper to send requests to Metrics API.
@param string $path Path after metrics api version.
@param string $method HTTP Mthod, 'GET' or 'POST'.
@param array<string,array> $data Metrics data.
@return stdClass
|
[
"Helper",
"to",
"send",
"requests",
"to",
"Metrics",
"API",
"."
] |
173e31ee3da814e66976e4c0a73f6660544077cd
|
https://github.com/OleMchls/PHP-Metrics-Client/blob/173e31ee3da814e66976e4c0a73f6660544077cd/src/Metrics/Client.php#L60-L79
|
225,362
|
php-toolkit/file-utils
|
src/ReadTrait.php
|
ReadTrait.loadPhp
|
public static function loadPhp($file, $throwError = true): array
{
$ary = [];
if (is_file($file)) {
$ary = require $file;
if (!\is_array($ary)) {
$ary = [];
}
} elseif ($throwError) {
throw new FileNotFoundException("php file [$file] not exists.");
}
return $ary;
}
|
php
|
public static function loadPhp($file, $throwError = true): array
{
$ary = [];
if (is_file($file)) {
$ary = require $file;
if (!\is_array($ary)) {
$ary = [];
}
} elseif ($throwError) {
throw new FileNotFoundException("php file [$file] not exists.");
}
return $ary;
}
|
[
"public",
"static",
"function",
"loadPhp",
"(",
"$",
"file",
",",
"$",
"throwError",
"=",
"true",
")",
":",
"array",
"{",
"$",
"ary",
"=",
"[",
"]",
";",
"if",
"(",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"$",
"ary",
"=",
"require",
"$",
"file",
";",
"if",
"(",
"!",
"\\",
"is_array",
"(",
"$",
"ary",
")",
")",
"{",
"$",
"ary",
"=",
"[",
"]",
";",
"}",
"}",
"elseif",
"(",
"$",
"throwError",
")",
"{",
"throw",
"new",
"FileNotFoundException",
"(",
"\"php file [$file] not exists.\"",
")",
";",
"}",
"return",
"$",
"ary",
";",
"}"
] |
load array data form file.
@param string $file
@param bool $throwError
@return array
@throws FileNotFoundException
|
[
"load",
"array",
"data",
"form",
"file",
"."
] |
cf55fa8ce34000731460e8dc705d7006632119a8
|
https://github.com/php-toolkit/file-utils/blob/cf55fa8ce34000731460e8dc705d7006632119a8/src/ReadTrait.php#L64-L79
|
225,363
|
railken/amethyst-file
|
src/Managers/FileManager.php
|
FileManager.uploadFileByContent
|
public function uploadFileByContent(File $file, string $content)
{
$dir = sys_get_temp_dir();
$tmp = $dir.'/'.Uuid::uuid4()->toString();
file_put_contents($tmp, $content);
$filename = $file->name;
if (!$filename) {
$filename = Uuid::uuid4()->toString().'.'.$this->guessExtension($tmp);
}
$filename = $dir.'/'.$filename;
rename($tmp, $filename);
return $this->uploadFileFromFilesystem($file, $filename);
}
|
php
|
public function uploadFileByContent(File $file, string $content)
{
$dir = sys_get_temp_dir();
$tmp = $dir.'/'.Uuid::uuid4()->toString();
file_put_contents($tmp, $content);
$filename = $file->name;
if (!$filename) {
$filename = Uuid::uuid4()->toString().'.'.$this->guessExtension($tmp);
}
$filename = $dir.'/'.$filename;
rename($tmp, $filename);
return $this->uploadFileFromFilesystem($file, $filename);
}
|
[
"public",
"function",
"uploadFileByContent",
"(",
"File",
"$",
"file",
",",
"string",
"$",
"content",
")",
"{",
"$",
"dir",
"=",
"sys_get_temp_dir",
"(",
")",
";",
"$",
"tmp",
"=",
"$",
"dir",
".",
"'/'",
".",
"Uuid",
"::",
"uuid4",
"(",
")",
"->",
"toString",
"(",
")",
";",
"file_put_contents",
"(",
"$",
"tmp",
",",
"$",
"content",
")",
";",
"$",
"filename",
"=",
"$",
"file",
"->",
"name",
";",
"if",
"(",
"!",
"$",
"filename",
")",
"{",
"$",
"filename",
"=",
"Uuid",
"::",
"uuid4",
"(",
")",
"->",
"toString",
"(",
")",
".",
"'.'",
".",
"$",
"this",
"->",
"guessExtension",
"(",
"$",
"tmp",
")",
";",
"}",
"$",
"filename",
"=",
"$",
"dir",
".",
"'/'",
".",
"$",
"filename",
";",
"rename",
"(",
"$",
"tmp",
",",
"$",
"filename",
")",
";",
"return",
"$",
"this",
"->",
"uploadFileFromFilesystem",
"(",
"$",
"file",
",",
"$",
"filename",
")",
";",
"}"
] |
Upload file By content.
@param File $file
@param string $content
@return \Railken\Lem\Contracts\ResultContract
|
[
"Upload",
"file",
"By",
"content",
"."
] |
732916420373fd2ad1a80393d86f8a4d26e47768
|
https://github.com/railken/amethyst-file/blob/732916420373fd2ad1a80393d86f8a4d26e47768/src/Managers/FileManager.php#L52-L71
|
225,364
|
railken/amethyst-file
|
src/Managers/FileManager.php
|
FileManager.uploadFileFromFilesystem
|
public function uploadFileFromFilesystem(File $file, string $path)
{
$dir = sys_get_temp_dir();
$filename = $dir.'/'.Uuid::uuid4()->toString().'.'.$this->guessExtension($path);
rename($path, $filename);
$file->path = $filename;
$file->save();
$file->addMedia($file->path)->toMediaCollection('default');
$result = new Result();
$result->setResources(Collection::make([$file]));
return $result;
}
|
php
|
public function uploadFileFromFilesystem(File $file, string $path)
{
$dir = sys_get_temp_dir();
$filename = $dir.'/'.Uuid::uuid4()->toString().'.'.$this->guessExtension($path);
rename($path, $filename);
$file->path = $filename;
$file->save();
$file->addMedia($file->path)->toMediaCollection('default');
$result = new Result();
$result->setResources(Collection::make([$file]));
return $result;
}
|
[
"public",
"function",
"uploadFileFromFilesystem",
"(",
"File",
"$",
"file",
",",
"string",
"$",
"path",
")",
"{",
"$",
"dir",
"=",
"sys_get_temp_dir",
"(",
")",
";",
"$",
"filename",
"=",
"$",
"dir",
".",
"'/'",
".",
"Uuid",
"::",
"uuid4",
"(",
")",
"->",
"toString",
"(",
")",
".",
"'.'",
".",
"$",
"this",
"->",
"guessExtension",
"(",
"$",
"path",
")",
";",
"rename",
"(",
"$",
"path",
",",
"$",
"filename",
")",
";",
"$",
"file",
"->",
"path",
"=",
"$",
"filename",
";",
"$",
"file",
"->",
"save",
"(",
")",
";",
"$",
"file",
"->",
"addMedia",
"(",
"$",
"file",
"->",
"path",
")",
"->",
"toMediaCollection",
"(",
"'default'",
")",
";",
"$",
"result",
"=",
"new",
"Result",
"(",
")",
";",
"$",
"result",
"->",
"setResources",
"(",
"Collection",
"::",
"make",
"(",
"[",
"$",
"file",
"]",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Upload a file from filesystem.
@param File $file
@param string $path
@return \Railken\Lem\Contracts\ResultContract
|
[
"Upload",
"a",
"file",
"from",
"filesystem",
"."
] |
732916420373fd2ad1a80393d86f8a4d26e47768
|
https://github.com/railken/amethyst-file/blob/732916420373fd2ad1a80393d86f8a4d26e47768/src/Managers/FileManager.php#L81-L98
|
225,365
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.getBase
|
public function getBase() {
$orderTable = CartTables::getTableName( CartTables::TABLE_ORDER );
return $this->hasOne( Order::class, [ 'id' => 'baseId' ] )->from( "$orderTable as base" );
}
|
php
|
public function getBase() {
$orderTable = CartTables::getTableName( CartTables::TABLE_ORDER );
return $this->hasOne( Order::class, [ 'id' => 'baseId' ] )->from( "$orderTable as base" );
}
|
[
"public",
"function",
"getBase",
"(",
")",
"{",
"$",
"orderTable",
"=",
"CartTables",
"::",
"getTableName",
"(",
"CartTables",
"::",
"TABLE_ORDER",
")",
";",
"return",
"$",
"this",
"->",
"hasOne",
"(",
"Order",
"::",
"class",
",",
"[",
"'id'",
"=>",
"'baseId'",
"]",
")",
"->",
"from",
"(",
"\"$orderTable as base\"",
")",
";",
"}"
] |
Returns the parent order.
@return Order
|
[
"Returns",
"the",
"parent",
"order",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L273-L278
|
225,366
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.getTransaction
|
public function getTransaction() {
$transactionTable = PaymentTables::getTableName( PaymentTables::TABLE_TRANSACTION );
$transactionSuccess = Transaction::STATUS_SUCCESS;
return $this->hasOne( Transaction::class, [ 'orderId' => 'id' ] )->where( "$transactionTable.status=$transactionSuccess" );
}
|
php
|
public function getTransaction() {
$transactionTable = PaymentTables::getTableName( PaymentTables::TABLE_TRANSACTION );
$transactionSuccess = Transaction::STATUS_SUCCESS;
return $this->hasOne( Transaction::class, [ 'orderId' => 'id' ] )->where( "$transactionTable.status=$transactionSuccess" );
}
|
[
"public",
"function",
"getTransaction",
"(",
")",
"{",
"$",
"transactionTable",
"=",
"PaymentTables",
"::",
"getTableName",
"(",
"PaymentTables",
"::",
"TABLE_TRANSACTION",
")",
";",
"$",
"transactionSuccess",
"=",
"Transaction",
"::",
"STATUS_SUCCESS",
";",
"return",
"$",
"this",
"->",
"hasOne",
"(",
"Transaction",
"::",
"class",
",",
"[",
"'orderId'",
"=>",
"'id'",
"]",
")",
"->",
"where",
"(",
"\"$transactionTable.status=$transactionSuccess\"",
")",
";",
"}"
] |
Returns the successful transaction associated with the order.
It's useful in the cases where only one transaction is required for an order.
@return Transaction
|
[
"Returns",
"the",
"successful",
"transaction",
"associated",
"with",
"the",
"order",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L307-L313
|
225,367
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isApproved
|
public function isApproved( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_APPROVED;
}
return $this->status >= self::STATUS_APPROVED;
}
|
php
|
public function isApproved( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_APPROVED;
}
return $this->status >= self::STATUS_APPROVED;
}
|
[
"public",
"function",
"isApproved",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_APPROVED",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"self",
"::",
"STATUS_APPROVED",
";",
"}"
] |
Check whether order is approved.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"approved",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L371-L379
|
225,368
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isPlaced
|
public function isPlaced( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_PLACED;
}
return $this->status >= self::STATUS_PLACED;
}
|
php
|
public function isPlaced( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_PLACED;
}
return $this->status >= self::STATUS_PLACED;
}
|
[
"public",
"function",
"isPlaced",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_PLACED",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"self",
"::",
"STATUS_PLACED",
";",
"}"
] |
Check whether order is placed.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"placed",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L387-L395
|
225,369
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isCancelled
|
public function isCancelled( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_CANCELLED;
}
return $this->status >= self::STATUS_CANCELLED;
}
|
php
|
public function isCancelled( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_CANCELLED;
}
return $this->status >= self::STATUS_CANCELLED;
}
|
[
"public",
"function",
"isCancelled",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_CANCELLED",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"self",
"::",
"STATUS_CANCELLED",
";",
"}"
] |
Check whether order is cancelled.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"cancelled",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L403-L411
|
225,370
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isPaid
|
public function isPaid( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_PAID;
}
return $this->status >= self::STATUS_PAID;
}
|
php
|
public function isPaid( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_PAID;
}
return $this->status >= self::STATUS_PAID;
}
|
[
"public",
"function",
"isPaid",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_PAID",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"self",
"::",
"STATUS_PAID",
";",
"}"
] |
Check whether order is paid.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"paid",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L419-L427
|
225,371
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isRefunded
|
public function isRefunded( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_REFUNDED;
}
return $this->status >= self::STATUS_REFUNDED;
}
|
php
|
public function isRefunded( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_REFUNDED;
}
return $this->status >= self::STATUS_REFUNDED;
}
|
[
"public",
"function",
"isRefunded",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_REFUNDED",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"self",
"::",
"STATUS_REFUNDED",
";",
"}"
] |
Check whether order is refunded.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"refunded",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L435-L443
|
225,372
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isConfirmed
|
public function isConfirmed( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_CONFIRMED;
}
return $this->status >= self::STATUS_CONFIRMED;
}
|
php
|
public function isConfirmed( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_CONFIRMED;
}
return $this->status >= self::STATUS_CONFIRMED;
}
|
[
"public",
"function",
"isConfirmed",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_CONFIRMED",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"self",
"::",
"STATUS_CONFIRMED",
";",
"}"
] |
Check whether order is confirmed.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"confirmed",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L451-L459
|
225,373
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isProcessed
|
public function isProcessed( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_PROCESSED;
}
return $this->status >= self::STATUS_PROCESSED;
}
|
php
|
public function isProcessed( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_PROCESSED;
}
return $this->status >= self::STATUS_PROCESSED;
}
|
[
"public",
"function",
"isProcessed",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_PROCESSED",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"self",
"::",
"STATUS_PROCESSED",
";",
"}"
] |
Check whether order is processed.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"processed",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L467-L475
|
225,374
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isShipped
|
public function isShipped( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_SHIPPED;
}
return $this->status >= self::STATUS_SHIPPED;
}
|
php
|
public function isShipped( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_SHIPPED;
}
return $this->status >= self::STATUS_SHIPPED;
}
|
[
"public",
"function",
"isShipped",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_SHIPPED",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"self",
"::",
"STATUS_SHIPPED",
";",
"}"
] |
Check whether order is shipped.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"shipped",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L483-L491
|
225,375
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isDelivered
|
public function isDelivered( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_DELIVERED;
}
return $this->status >= self::STATUS_DELIVERED;
}
|
php
|
public function isDelivered( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_DELIVERED;
}
return $this->status >= self::STATUS_DELIVERED;
}
|
[
"public",
"function",
"isDelivered",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_DELIVERED",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"self",
"::",
"STATUS_DELIVERED",
";",
"}"
] |
Check whether order is delivered.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"delivered",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L499-L507
|
225,376
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isReturned
|
public function isReturned( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_RETURNED;
}
return $this->status >= self::STATUS_RETURNED;
}
|
php
|
public function isReturned( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_RETURNED;
}
return $this->status >= self::STATUS_RETURNED;
}
|
[
"public",
"function",
"isReturned",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_RETURNED",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"self",
"::",
"STATUS_RETURNED",
";",
"}"
] |
Check whether order is returned.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"returned",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L515-L523
|
225,377
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isDispute
|
public function isDispute( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_DISPUTE;
}
return $this->status >= self::STATUS_DISPUTE;
}
|
php
|
public function isDispute( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_DISPUTE;
}
return $this->status >= self::STATUS_DISPUTE;
}
|
[
"public",
"function",
"isDispute",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_DISPUTE",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"self",
"::",
"STATUS_DISPUTE",
";",
"}"
] |
Check whether order is under dispute.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"under",
"dispute",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L531-L539
|
225,378
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isCompleted
|
public function isCompleted( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_COMPLETED;
}
return $this->status >= self::STATUS_COMPLETED;
}
|
php
|
public function isCompleted( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_COMPLETED;
}
return $this->status >= self::STATUS_COMPLETED;
}
|
[
"public",
"function",
"isCompleted",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_COMPLETED",
";",
"}",
"return",
"$",
"this",
"->",
"status",
">=",
"self",
"::",
"STATUS_COMPLETED",
";",
"}"
] |
Check whether order is completed.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"completed",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L547-L555
|
225,379
|
cmsgears/module-cart
|
common/models/resources/Order.php
|
Order.isPrintable
|
public function isPrintable( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_COMPLETED;
}
return in_array( $this->status, [ self::STATUS_PAID, self::STATUS_DELIVERED, self::STATUS_COMPLETED ] );
}
|
php
|
public function isPrintable( $strict = true ) {
if( $strict ) {
return $this->status == self::STATUS_COMPLETED;
}
return in_array( $this->status, [ self::STATUS_PAID, self::STATUS_DELIVERED, self::STATUS_COMPLETED ] );
}
|
[
"public",
"function",
"isPrintable",
"(",
"$",
"strict",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"strict",
")",
"{",
"return",
"$",
"this",
"->",
"status",
"==",
"self",
"::",
"STATUS_COMPLETED",
";",
"}",
"return",
"in_array",
"(",
"$",
"this",
"->",
"status",
",",
"[",
"self",
"::",
"STATUS_PAID",
",",
"self",
"::",
"STATUS_DELIVERED",
",",
"self",
"::",
"STATUS_COMPLETED",
"]",
")",
";",
"}"
] |
Check whether order is printable.
$param boolean $strict
@return boolean
|
[
"Check",
"whether",
"order",
"is",
"printable",
"."
] |
7c44fe1f652783e3baa58b07f2eb840f53dc5d95
|
https://github.com/cmsgears/module-cart/blob/7c44fe1f652783e3baa58b07f2eb840f53dc5d95/common/models/resources/Order.php#L563-L571
|
225,380
|
cloudcreativity/utils-object
|
src/ObjectProxyTrait.php
|
ObjectProxyTrait.getMany
|
public function getMany(...$keys)
{
$ret = [];
foreach ($this->normalizeKeys($keys) as $key) {
if ($this->has($key)) {
$ret[$key] = $this->proxy->{$key};
}
}
return $ret;
}
|
php
|
public function getMany(...$keys)
{
$ret = [];
foreach ($this->normalizeKeys($keys) as $key) {
if ($this->has($key)) {
$ret[$key] = $this->proxy->{$key};
}
}
return $ret;
}
|
[
"public",
"function",
"getMany",
"(",
"...",
"$",
"keys",
")",
"{",
"$",
"ret",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"normalizeKeys",
"(",
"$",
"keys",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"$",
"ret",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"proxy",
"->",
"{",
"$",
"key",
"}",
";",
"}",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Get properties if they exist.
@param array ...$keys
@return array
|
[
"Get",
"properties",
"if",
"they",
"exist",
"."
] |
4b12016a0a6e5412d26472b2ffcdeadc5dd43ec2
|
https://github.com/cloudcreativity/utils-object/blob/4b12016a0a6e5412d26472b2ffcdeadc5dd43ec2/src/ObjectProxyTrait.php#L65-L76
|
225,381
|
cloudcreativity/utils-object
|
src/ObjectProxyTrait.php
|
ObjectProxyTrait.addProperties
|
public function addProperties(array $values)
{
foreach ($values as $key => $value) {
$this->add($key, $value);
}
return $this;
}
|
php
|
public function addProperties(array $values)
{
foreach ($values as $key => $value) {
$this->add($key, $value);
}
return $this;
}
|
[
"public",
"function",
"addProperties",
"(",
"array",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"add",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Add many properties.
@param array $values
@return $this
|
[
"Add",
"many",
"properties",
"."
] |
4b12016a0a6e5412d26472b2ffcdeadc5dd43ec2
|
https://github.com/cloudcreativity/utils-object/blob/4b12016a0a6e5412d26472b2ffcdeadc5dd43ec2/src/ObjectProxyTrait.php#L125-L132
|
225,382
|
cloudcreativity/utils-object
|
src/ObjectProxyTrait.php
|
ObjectProxyTrait.reduce
|
public function reduce(...$keys)
{
$keys = $this->normalizeKeys($keys);
foreach ($this->keys() as $key) {
if (!in_array($key, $keys, true)) {
$this->remove($key);
}
}
return $this;
}
|
php
|
public function reduce(...$keys)
{
$keys = $this->normalizeKeys($keys);
foreach ($this->keys() as $key) {
if (!in_array($key, $keys, true)) {
$this->remove($key);
}
}
return $this;
}
|
[
"public",
"function",
"reduce",
"(",
"...",
"$",
"keys",
")",
"{",
"$",
"keys",
"=",
"$",
"this",
"->",
"normalizeKeys",
"(",
"$",
"keys",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"keys",
"(",
")",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"keys",
",",
"true",
")",
")",
"{",
"$",
"this",
"->",
"remove",
"(",
"$",
"key",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Reduce this object so that it only has the supplied allowed keys.
@param array ...$keys
@return $this
|
[
"Reduce",
"this",
"object",
"so",
"that",
"it",
"only",
"has",
"the",
"supplied",
"allowed",
"keys",
"."
] |
4b12016a0a6e5412d26472b2ffcdeadc5dd43ec2
|
https://github.com/cloudcreativity/utils-object/blob/4b12016a0a6e5412d26472b2ffcdeadc5dd43ec2/src/ObjectProxyTrait.php#L183-L194
|
225,383
|
cloudcreativity/utils-object
|
src/ObjectProxyTrait.php
|
ObjectProxyTrait.rename
|
public function rename($currentKey, $newKey)
{
if ($this->has($currentKey)) {
$this->set($newKey, $this->proxy->{$currentKey})->remove($currentKey);
}
return $this;
}
|
php
|
public function rename($currentKey, $newKey)
{
if ($this->has($currentKey)) {
$this->set($newKey, $this->proxy->{$currentKey})->remove($currentKey);
}
return $this;
}
|
[
"public",
"function",
"rename",
"(",
"$",
"currentKey",
",",
"$",
"newKey",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"currentKey",
")",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"newKey",
",",
"$",
"this",
"->",
"proxy",
"->",
"{",
"$",
"currentKey",
"}",
")",
"->",
"remove",
"(",
"$",
"currentKey",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
If the object has the current key, rename it to the new key name.
@param $currentKey
@param $newKey
@return $this
|
[
"If",
"the",
"object",
"has",
"the",
"current",
"key",
"rename",
"it",
"to",
"the",
"new",
"key",
"name",
"."
] |
4b12016a0a6e5412d26472b2ffcdeadc5dd43ec2
|
https://github.com/cloudcreativity/utils-object/blob/4b12016a0a6e5412d26472b2ffcdeadc5dd43ec2/src/ObjectProxyTrait.php#L211-L218
|
225,384
|
cloudcreativity/utils-object
|
src/ObjectProxyTrait.php
|
ObjectProxyTrait.renameKeys
|
public function renameKeys(array $mapping)
{
foreach ($mapping as $currentKey => $newKey) {
$this->rename($currentKey, $newKey);
}
return $this;
}
|
php
|
public function renameKeys(array $mapping)
{
foreach ($mapping as $currentKey => $newKey) {
$this->rename($currentKey, $newKey);
}
return $this;
}
|
[
"public",
"function",
"renameKeys",
"(",
"array",
"$",
"mapping",
")",
"{",
"foreach",
"(",
"$",
"mapping",
"as",
"$",
"currentKey",
"=>",
"$",
"newKey",
")",
"{",
"$",
"this",
"->",
"rename",
"(",
"$",
"currentKey",
",",
"$",
"newKey",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Rename many current keys to new keys.
@param array $mapping
@return $this
|
[
"Rename",
"many",
"current",
"keys",
"to",
"new",
"keys",
"."
] |
4b12016a0a6e5412d26472b2ffcdeadc5dd43ec2
|
https://github.com/cloudcreativity/utils-object/blob/4b12016a0a6e5412d26472b2ffcdeadc5dd43ec2/src/ObjectProxyTrait.php#L226-L233
|
225,385
|
SetBased/php-abc-table-detail
|
src/TableRow/TextTableRow.php
|
TextTableRow.addRow
|
public static function addRow(DetailTable $table, $header, ?string $text): void
{
if ($text!==null && $text!=='')
{
$table->addRow($header, ['class' => 'text'], $text);
}
else
{
$table->addRow($header);
}
}
|
php
|
public static function addRow(DetailTable $table, $header, ?string $text): void
{
if ($text!==null && $text!=='')
{
$table->addRow($header, ['class' => 'text'], $text);
}
else
{
$table->addRow($header);
}
}
|
[
"public",
"static",
"function",
"addRow",
"(",
"DetailTable",
"$",
"table",
",",
"$",
"header",
",",
"?",
"string",
"$",
"text",
")",
":",
"void",
"{",
"if",
"(",
"$",
"text",
"!==",
"null",
"&&",
"$",
"text",
"!==",
"''",
")",
"{",
"$",
"table",
"->",
"addRow",
"(",
"$",
"header",
",",
"[",
"'class'",
"=>",
"'text'",
"]",
",",
"$",
"text",
")",
";",
"}",
"else",
"{",
"$",
"table",
"->",
"addRow",
"(",
"$",
"header",
")",
";",
"}",
"}"
] |
Adds a row with a text value to a detail table.
@param DetailTable $table The detail table.
@param string|int|null $header The header text of this table row.
@param string|null $text The text.
|
[
"Adds",
"a",
"row",
"with",
"a",
"text",
"value",
"to",
"a",
"detail",
"table",
"."
] |
1f786174ccb10800f9c07bfd497b0ab35940a8ea
|
https://github.com/SetBased/php-abc-table-detail/blob/1f786174ccb10800f9c07bfd497b0ab35940a8ea/src/TableRow/TextTableRow.php#L20-L30
|
225,386
|
DrNixx/yii2-onix
|
src/Env.php
|
Env.getCurrentDir
|
public static function getCurrentDir($object)
{
if (empty($object)) {
return '';
}
$child = new \ReflectionClass($object);
return dirname($child->getFileName());
}
|
php
|
public static function getCurrentDir($object)
{
if (empty($object)) {
return '';
}
$child = new \ReflectionClass($object);
return dirname($child->getFileName());
}
|
[
"public",
"static",
"function",
"getCurrentDir",
"(",
"$",
"object",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"object",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"child",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"object",
")",
";",
"return",
"dirname",
"(",
"$",
"child",
"->",
"getFileName",
"(",
")",
")",
";",
"}"
] |
Get the current directory of the extended class object
@param object $object the called object instance
@return string
|
[
"Get",
"the",
"current",
"directory",
"of",
"the",
"extended",
"class",
"object"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/Env.php#L33-L41
|
225,387
|
DrNixx/yii2-onix
|
src/collections/TreeMap.php
|
TreeMap.lower
|
public function lower($key)
{
if ($this->root) {
$lower = $this->root->find($key, $this->comparator, -2);
} else {
$lower = null;
}
if ($lower) {
return $lower;
} else {
throw new \OutOfBoundsException('Lower element unexisting');
}
}
|
php
|
public function lower($key)
{
if ($this->root) {
$lower = $this->root->find($key, $this->comparator, -2);
} else {
$lower = null;
}
if ($lower) {
return $lower;
} else {
throw new \OutOfBoundsException('Lower element unexisting');
}
}
|
[
"public",
"function",
"lower",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"root",
")",
"{",
"$",
"lower",
"=",
"$",
"this",
"->",
"root",
"->",
"find",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"comparator",
",",
"-",
"2",
")",
";",
"}",
"else",
"{",
"$",
"lower",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"lower",
")",
"{",
"return",
"$",
"lower",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'Lower element unexisting'",
")",
";",
"}",
"}"
] |
Returns the element whose key is the greatest key lesser than the given key or
throw an exception if there is no such element
@param mixed $key The searched key
@return mixed The found element
@throws \OutOfBoundsException If there is no lower element
|
[
"Returns",
"the",
"element",
"whose",
"key",
"is",
"the",
"greatest",
"key",
"lesser",
"than",
"the",
"given",
"key",
"or",
"throw",
"an",
"exception",
"if",
"there",
"is",
"no",
"such",
"element"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeMap.php#L132-L145
|
225,388
|
DrNixx/yii2-onix
|
src/collections/TreeMap.php
|
TreeMap.floor
|
public function floor($key)
{
if ($this->root) {
$floor = $this->root->find($key, $this->comparator, -1);
} else {
$floor = null;
}
if ($floor) {
return $floor;
} else {
throw new \OutOfBoundsException('Floor element unexisting');
}
}
|
php
|
public function floor($key)
{
if ($this->root) {
$floor = $this->root->find($key, $this->comparator, -1);
} else {
$floor = null;
}
if ($floor) {
return $floor;
} else {
throw new \OutOfBoundsException('Floor element unexisting');
}
}
|
[
"public",
"function",
"floor",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"root",
")",
"{",
"$",
"floor",
"=",
"$",
"this",
"->",
"root",
"->",
"find",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"comparator",
",",
"-",
"1",
")",
";",
"}",
"else",
"{",
"$",
"floor",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"floor",
")",
"{",
"return",
"$",
"floor",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'Floor element unexisting'",
")",
";",
"}",
"}"
] |
Returns the element whose key is the greatest key lesser than or equal to the given key or throw
an exception if there is no such element
@param mixed $key The searched key
@return mixed The found element
@throws \OutOfBoundsException If there is no floor element
|
[
"Returns",
"the",
"element",
"whose",
"key",
"is",
"the",
"greatest",
"key",
"lesser",
"than",
"or",
"equal",
"to",
"the",
"given",
"key",
"or",
"throw",
"an",
"exception",
"if",
"there",
"is",
"no",
"such",
"element"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeMap.php#L155-L168
|
225,389
|
DrNixx/yii2-onix
|
src/collections/TreeMap.php
|
TreeMap.find
|
public function find($key)
{
if ($this->root) {
$find = $this->root->find($key, $this->comparator, 0);
} else {
$find = null;
}
if ($find) {
return $find;
} else {
throw new \OutOfBoundsException('Element unexisting');
}
}
|
php
|
public function find($key)
{
if ($this->root) {
$find = $this->root->find($key, $this->comparator, 0);
} else {
$find = null;
}
if ($find) {
return $find;
} else {
throw new \OutOfBoundsException('Element unexisting');
}
}
|
[
"public",
"function",
"find",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"root",
")",
"{",
"$",
"find",
"=",
"$",
"this",
"->",
"root",
"->",
"find",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"comparator",
",",
"0",
")",
";",
"}",
"else",
"{",
"$",
"find",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"find",
")",
"{",
"return",
"$",
"find",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'Element unexisting'",
")",
";",
"}",
"}"
] |
Returns the element whose key is equal to the given key or throw an exception if there is no such element
@param mixed $key The searched key
@return TreeNode|null The found element
@throws \OutOfBoundsException If there is no such element
|
[
"Returns",
"the",
"element",
"whose",
"key",
"is",
"equal",
"to",
"the",
"given",
"key",
"or",
"throw",
"an",
"exception",
"if",
"there",
"is",
"no",
"such",
"element"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeMap.php#L176-L189
|
225,390
|
DrNixx/yii2-onix
|
src/collections/TreeMap.php
|
TreeMap.ceiling
|
public function ceiling($key)
{
if ($this->root) {
$ceiling = $this->root->find($key, $this->comparator, 1);
} else {
$ceiling = null;
}
if ($ceiling) {
return $ceiling;
} else {
throw new \OutOfBoundsException('Ceiling element unexisting');
}
}
|
php
|
public function ceiling($key)
{
if ($this->root) {
$ceiling = $this->root->find($key, $this->comparator, 1);
} else {
$ceiling = null;
}
if ($ceiling) {
return $ceiling;
} else {
throw new \OutOfBoundsException('Ceiling element unexisting');
}
}
|
[
"public",
"function",
"ceiling",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"root",
")",
"{",
"$",
"ceiling",
"=",
"$",
"this",
"->",
"root",
"->",
"find",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"comparator",
",",
"1",
")",
";",
"}",
"else",
"{",
"$",
"ceiling",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"ceiling",
")",
"{",
"return",
"$",
"ceiling",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'Ceiling element unexisting'",
")",
";",
"}",
"}"
] |
Returns the element whose key is the lowest key greater than or equal to the given key or
throw an exception if there is no such element
@param mixed $key The searched key
@return mixed The found element
@throws \OutOfBoundsException If there is no ceiling element
|
[
"Returns",
"the",
"element",
"whose",
"key",
"is",
"the",
"lowest",
"key",
"greater",
"than",
"or",
"equal",
"to",
"the",
"given",
"key",
"or",
"throw",
"an",
"exception",
"if",
"there",
"is",
"no",
"such",
"element"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeMap.php#L199-L212
|
225,391
|
DrNixx/yii2-onix
|
src/collections/TreeMap.php
|
TreeMap.higher
|
public function higher($key)
{
if ($this->root) {
$higher = $this->root->find($key, $this->comparator, 2);
} else {
$higher = null;
}
if ($higher) {
return $higher;
} else {
throw new \OutOfBoundsException('Higher element unexisting');
}
}
|
php
|
public function higher($key)
{
if ($this->root) {
$higher = $this->root->find($key, $this->comparator, 2);
} else {
$higher = null;
}
if ($higher) {
return $higher;
} else {
throw new \OutOfBoundsException('Higher element unexisting');
}
}
|
[
"public",
"function",
"higher",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"root",
")",
"{",
"$",
"higher",
"=",
"$",
"this",
"->",
"root",
"->",
"find",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"comparator",
",",
"2",
")",
";",
"}",
"else",
"{",
"$",
"higher",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"higher",
")",
"{",
"return",
"$",
"higher",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'Higher element unexisting'",
")",
";",
"}",
"}"
] |
Returns the element whose key is the lowest key greater than to the given key or
throw an exception if there is no such element
@param mixed $key The searched key
@return mixed The found element
@throws \OutOfBoundsException If there is no higher element
|
[
"Returns",
"the",
"element",
"whose",
"key",
"is",
"the",
"lowest",
"key",
"greater",
"than",
"to",
"the",
"given",
"key",
"or",
"throw",
"an",
"exception",
"if",
"there",
"is",
"no",
"such",
"element"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeMap.php#L222-L235
|
225,392
|
DrNixx/yii2-onix
|
src/collections/TreeMap.php
|
TreeMap.putAll
|
public function putAll($map)
{
foreach ($map as $key => $val) {
$this->put($key, $val);
}
return $this;
}
|
php
|
public function putAll($map)
{
foreach ($map as $key => $val) {
$this->put($key, $val);
}
return $this;
}
|
[
"public",
"function",
"putAll",
"(",
"$",
"map",
")",
"{",
"foreach",
"(",
"$",
"map",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"this",
"->",
"put",
"(",
"$",
"key",
",",
"$",
"val",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Initialise the map
@param MapInterface|array $map Values to initialise the map
@return TreeMap $this for chaining
|
[
"Initialise",
"the",
"map"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeMap.php#L255-L262
|
225,393
|
DrNixx/yii2-onix
|
src/collections/TreeMap.php
|
TreeMap.offsetSet
|
public function offsetSet($key, $value)
{
if ($this->root) {
$this->root = $this->root->insert($key, $value, $this->comparator);
} else {
$this->root = TreeNode::create($key, $value);
}
}
|
php
|
public function offsetSet($key, $value)
{
if ($this->root) {
$this->root = $this->root->insert($key, $value, $this->comparator);
} else {
$this->root = TreeNode::create($key, $value);
}
}
|
[
"public",
"function",
"offsetSet",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"root",
")",
"{",
"$",
"this",
"->",
"root",
"=",
"$",
"this",
"->",
"root",
"->",
"insert",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"this",
"->",
"comparator",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"root",
"=",
"TreeNode",
"::",
"create",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}"
] |
Set the value for a key
@param mixed $key The key
@param mixed $value The value
@return void
|
[
"Set",
"the",
"value",
"for",
"a",
"key"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeMap.php#L313-L320
|
225,394
|
DrNixx/yii2-onix
|
src/collections/TreeMap.php
|
TreeMap.offsetUnset
|
public function offsetUnset($key)
{
if ($this->root) {
$this->root = $this->root->remove($key, $this->comparator);
}
}
|
php
|
public function offsetUnset($key)
{
if ($this->root) {
$this->root = $this->root->remove($key, $this->comparator);
}
}
|
[
"public",
"function",
"offsetUnset",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"root",
")",
"{",
"$",
"this",
"->",
"root",
"=",
"$",
"this",
"->",
"root",
"->",
"remove",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"comparator",
")",
";",
"}",
"}"
] |
Unset the existence of a key
@param mixed $key The key
@return void
|
[
"Unset",
"the",
"existence",
"of",
"a",
"key"
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeMap.php#L327-L332
|
225,395
|
DrNixx/yii2-onix
|
src/collections/TreeMap.php
|
TreeMap.containsValue
|
public function containsValue($value)
{
foreach ($this->values() as $v) {
if ($v === $value) {
return true;
}
}
return false;
}
|
php
|
public function containsValue($value)
{
foreach ($this->values() as $v) {
if ($v === $value) {
return true;
}
}
return false;
}
|
[
"public",
"function",
"containsValue",
"(",
"$",
"value",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"values",
"(",
")",
"as",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"$",
"value",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] |
Returns `true` if this map maps one or more keys to the specified value.
@param mixed $value Value whose presence in this map is to be tested.
@return bool `true` if this map maps one or more keys to the value, otherwise `false`.
@throws NullPointerException If the value is null and this map does not permit null values (optional).
@throws UnexpectedValueException If the value is incompatible with this map (optional).
|
[
"Returns",
"true",
"if",
"this",
"map",
"maps",
"one",
"or",
"more",
"keys",
"to",
"the",
"specified",
"value",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeMap.php#L461-L470
|
225,396
|
DrNixx/yii2-onix
|
src/collections/TreeMap.php
|
TreeMap.keySet
|
public function keySet()
{
$result = [];
$keys = $this->keys();
foreach ($keys as $key) {
$result[] = $key;
}
return $result;
}
|
php
|
public function keySet()
{
$result = [];
$keys = $this->keys();
foreach ($keys as $key) {
$result[] = $key;
}
return $result;
}
|
[
"public",
"function",
"keySet",
"(",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"keys",
"=",
"$",
"this",
"->",
"keys",
"(",
")",
";",
"foreach",
"(",
"$",
"keys",
"as",
"$",
"key",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"return",
"$",
"result",
";",
"}"
] |
Returns a set view of the keys contained in this map.
@return array Set view of the keys contained in this map.
|
[
"Returns",
"a",
"set",
"view",
"of",
"the",
"keys",
"contained",
"in",
"this",
"map",
"."
] |
0a621ed301dc94971ff71af062b24d6bc0858dd7
|
https://github.com/DrNixx/yii2-onix/blob/0a621ed301dc94971ff71af062b24d6bc0858dd7/src/collections/TreeMap.php#L499-L508
|
225,397
|
SetBased/php-abc-html
|
src/HtmlElement.php
|
HtmlElement.addClass
|
public function addClass(?string $class): void
{
// If class is empty return immediately.
if ($class===null || $class==='') return;
if (isset($this->attributes['class']))
{
$this->attributes['class'] .= ' ';
$this->attributes['class'] .= $class;
}
else
{
$this->attributes['class'] = $class;
}
}
|
php
|
public function addClass(?string $class): void
{
// If class is empty return immediately.
if ($class===null || $class==='') return;
if (isset($this->attributes['class']))
{
$this->attributes['class'] .= ' ';
$this->attributes['class'] .= $class;
}
else
{
$this->attributes['class'] = $class;
}
}
|
[
"public",
"function",
"addClass",
"(",
"?",
"string",
"$",
"class",
")",
":",
"void",
"{",
"// If class is empty return immediately.",
"if",
"(",
"$",
"class",
"===",
"null",
"||",
"$",
"class",
"===",
"''",
")",
"return",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
".=",
"' '",
";",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
".=",
"$",
"class",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"$",
"class",
";",
"}",
"}"
] |
Adds a class to the list of classes.
@param string|null $class The class.
@since 1.0.0
@api
|
[
"Adds",
"a",
"class",
"to",
"the",
"list",
"of",
"classes",
"."
] |
4e123c3b477bcd76ed82239711653b85ad5f4b26
|
https://github.com/SetBased/php-abc-html/blob/4e123c3b477bcd76ed82239711653b85ad5f4b26/src/HtmlElement.php#L45-L59
|
225,398
|
SetBased/php-abc-html
|
src/HtmlElement.php
|
HtmlElement.removeClass
|
public function removeClass(?string $class): void
{
// If class is empty or no classes are set return immediately.
if ($class===null || $class==='' || !isset($this->attributes['class'])) return;
// Remove the class from the list of classes.
$this->attributes['class'] = implode(' ', array_diff(explode(' ', $this->attributes['class']), [$class]));
}
|
php
|
public function removeClass(?string $class): void
{
// If class is empty or no classes are set return immediately.
if ($class===null || $class==='' || !isset($this->attributes['class'])) return;
// Remove the class from the list of classes.
$this->attributes['class'] = implode(' ', array_diff(explode(' ', $this->attributes['class']), [$class]));
}
|
[
"public",
"function",
"removeClass",
"(",
"?",
"string",
"$",
"class",
")",
":",
"void",
"{",
"// If class is empty or no classes are set return immediately.",
"if",
"(",
"$",
"class",
"===",
"null",
"||",
"$",
"class",
"===",
"''",
"||",
"!",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
")",
")",
"return",
";",
"// Remove the class from the list of classes.",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"implode",
"(",
"' '",
",",
"array_diff",
"(",
"explode",
"(",
"' '",
",",
"$",
"this",
"->",
"attributes",
"[",
"'class'",
"]",
")",
",",
"[",
"$",
"class",
"]",
")",
")",
";",
"}"
] |
Removes a class from the list of classes.
@param string|null $class The class to be removed.
@since 1.0.0
@api
|
[
"Removes",
"a",
"class",
"from",
"the",
"list",
"of",
"classes",
"."
] |
4e123c3b477bcd76ed82239711653b85ad5f4b26
|
https://github.com/SetBased/php-abc-html/blob/4e123c3b477bcd76ed82239711653b85ad5f4b26/src/HtmlElement.php#L86-L93
|
225,399
|
SetBased/php-abc-html
|
src/HtmlElement.php
|
HtmlElement.setFakeAttribute
|
public function setFakeAttribute(string $name, $value): void
{
if (strpos($name, '_')!==0)
{
throw new LogicException("Attribute '%s' is not a valid fake attribute.", $name);
}
$this->attributes[$name] = $value;
}
|
php
|
public function setFakeAttribute(string $name, $value): void
{
if (strpos($name, '_')!==0)
{
throw new LogicException("Attribute '%s' is not a valid fake attribute.", $name);
}
$this->attributes[$name] = $value;
}
|
[
"public",
"function",
"setFakeAttribute",
"(",
"string",
"$",
"name",
",",
"$",
"value",
")",
":",
"void",
"{",
"if",
"(",
"strpos",
"(",
"$",
"name",
",",
"'_'",
")",
"!==",
"0",
")",
"{",
"throw",
"new",
"LogicException",
"(",
"\"Attribute '%s' is not a valid fake attribute.\"",
",",
"$",
"name",
")",
";",
"}",
"$",
"this",
"->",
"attributes",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}"
] |
Sets a fake attribute. A fake attribute has a name that starts with an underscore. Fake attributes will not be
included in the generated HTML code.
@param string $name The name of the fake attribute.
@param mixed $value The value of the fake attribute.
@since 1.0.0
@api
|
[
"Sets",
"a",
"fake",
"attribute",
".",
"A",
"fake",
"attribute",
"has",
"a",
"name",
"that",
"starts",
"with",
"an",
"underscore",
".",
"Fake",
"attributes",
"will",
"not",
"be",
"included",
"in",
"the",
"generated",
"HTML",
"code",
"."
] |
4e123c3b477bcd76ed82239711653b85ad5f4b26
|
https://github.com/SetBased/php-abc-html/blob/4e123c3b477bcd76ed82239711653b85ad5f4b26/src/HtmlElement.php#L387-L395
|
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.