id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
8,000 | konservs/brilliant.framework | libraries/MVC/BControllerField.php | BControllerField.useFramework | public function useFramework($alias){
if(!isset($this->controller)){
return false;
}
$this->controller->frameworks[$alias]=$alias;
return true;
} | php | public function useFramework($alias){
if(!isset($this->controller)){
return false;
}
$this->controller->frameworks[$alias]=$alias;
return true;
} | [
"public",
"function",
"useFramework",
"(",
"$",
"alias",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"controller",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"controller",
"->",
"frameworks",
"[",
"$",
"alias",
"]",
"=",
"$",
"alias",
";",
"return",
"true",
";",
"}"
] | Add frameform declaration
@param string $alias the framework alias
@return boolean true if ok | [
"Add",
"frameform",
"declaration"
] | 95f03f1917f746fee98bea8a906ba0588c87762d | https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/MVC/BControllerField.php#L96-L102 |
8,001 | qlcorp/VextFramework | src/Qlcorp/VextFramework/CrudModel.php | CrudModel.validate | public function validate()
{
$validator = Validator::make($this->toArray(), $this->rules,
$this->messages);
if ($validator->fails()) {
$this->errors = $validator->messages();
return false;
} else return true;
} | php | public function validate()
{
$validator = Validator::make($this->toArray(), $this->rules,
$this->messages);
if ($validator->fails()) {
$this->errors = $validator->messages();
return false;
} else return true;
} | [
"public",
"function",
"validate",
"(",
")",
"{",
"$",
"validator",
"=",
"Validator",
"::",
"make",
"(",
"$",
"this",
"->",
"toArray",
"(",
")",
",",
"$",
"this",
"->",
"rules",
",",
"$",
"this",
"->",
"messages",
")",
";",
"if",
"(",
"$",
"validator",
"->",
"fails",
"(",
")",
")",
"{",
"$",
"this",
"->",
"errors",
"=",
"$",
"validator",
"->",
"messages",
"(",
")",
";",
"return",
"false",
";",
"}",
"else",
"return",
"true",
";",
"}"
] | Validates generation input
@return bool | [
"Validates",
"generation",
"input"
] | 674e59d27ffe573866b14b931b8dd027f50cb740 | https://github.com/qlcorp/VextFramework/blob/674e59d27ffe573866b14b931b8dd027f50cb740/src/Qlcorp/VextFramework/CrudModel.php#L45-L54 |
8,002 | easy-system/es-http | src/Uploading/StrategiesQueue.php | StrategiesQueue.attach | public function attach(UploadStrategyInterface $strategy, $priority)
{
if ($this->started) {
throw new RuntimeException('Unable during invoking.');
}
if (isset($this->queue[$priority])) {
throw new InvalidArgumentException(sprintf(
'The strategy with priority "%s" already exists.',
$priority
));
}
$this->queue[$priority] = $strategy;
$this->sortedQueue = null;
if ($this->options && ! $strategy->getOptions()) {
$strategy->setOptions($this->options);
}
return $this;
} | php | public function attach(UploadStrategyInterface $strategy, $priority)
{
if ($this->started) {
throw new RuntimeException('Unable during invoking.');
}
if (isset($this->queue[$priority])) {
throw new InvalidArgumentException(sprintf(
'The strategy with priority "%s" already exists.',
$priority
));
}
$this->queue[$priority] = $strategy;
$this->sortedQueue = null;
if ($this->options && ! $strategy->getOptions()) {
$strategy->setOptions($this->options);
}
return $this;
} | [
"public",
"function",
"attach",
"(",
"UploadStrategyInterface",
"$",
"strategy",
",",
"$",
"priority",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Unable during invoking.'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"queue",
"[",
"$",
"priority",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'The strategy with priority \"%s\" already exists.'",
",",
"$",
"priority",
")",
")",
";",
"}",
"$",
"this",
"->",
"queue",
"[",
"$",
"priority",
"]",
"=",
"$",
"strategy",
";",
"$",
"this",
"->",
"sortedQueue",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"&&",
"!",
"$",
"strategy",
"->",
"getOptions",
"(",
")",
")",
"{",
"$",
"strategy",
"->",
"setOptions",
"(",
"$",
"this",
"->",
"options",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Attaches the upload strategy to specific priority.
@param UploadStrategyInterface $strategy The upload strategy
@param int $priority The priority
@throws \RuntimeException If try to attach during invoking
@throws \InvalidArgumentException If the specified priority have already
some strategy
@return self | [
"Attaches",
"the",
"upload",
"strategy",
"to",
"specific",
"priority",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uploading/StrategiesQueue.php#L61-L80 |
8,003 | easy-system/es-http | src/Uploading/StrategiesQueue.php | StrategiesQueue.detach | public function detach($priority)
{
if ($this->started) {
throw new RuntimeException('Unable during invoking.');
}
if (isset($this->queue[$priority])) {
unset($this->queue[$priority]);
$this->sortedQueue = null;
}
return $this;
} | php | public function detach($priority)
{
if ($this->started) {
throw new RuntimeException('Unable during invoking.');
}
if (isset($this->queue[$priority])) {
unset($this->queue[$priority]);
$this->sortedQueue = null;
}
return $this;
} | [
"public",
"function",
"detach",
"(",
"$",
"priority",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"started",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Unable during invoking.'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"queue",
"[",
"$",
"priority",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"this",
"->",
"queue",
"[",
"$",
"priority",
"]",
")",
";",
"$",
"this",
"->",
"sortedQueue",
"=",
"null",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Detaches of the upload strategy with the specific priority.
@param int $priority The priority
@throws \RuntimeException If try to detach during invoking
@return self | [
"Detaches",
"of",
"the",
"upload",
"strategy",
"with",
"the",
"specific",
"priority",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uploading/StrategiesQueue.php#L91-L102 |
8,004 | easy-system/es-http | src/Uploading/StrategiesQueue.php | StrategiesQueue.getState | public function getState()
{
if (empty($this->sortedQueue)) {
return;
}
$current = current($this->sortedQueue)
? current($this->sortedQueue)
: end($this->sortedQueue);
return $current->getState();
} | php | public function getState()
{
if (empty($this->sortedQueue)) {
return;
}
$current = current($this->sortedQueue)
? current($this->sortedQueue)
: end($this->sortedQueue);
return $current->getState();
} | [
"public",
"function",
"getState",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
")",
"{",
"return",
";",
"}",
"$",
"current",
"=",
"current",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
"?",
"current",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
":",
"end",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
";",
"return",
"$",
"current",
"->",
"getState",
"(",
")",
";",
"}"
] | Gets the state of strategy.
@return null|int The state of strategy | [
"Gets",
"the",
"state",
"of",
"strategy",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uploading/StrategiesQueue.php#L144-L154 |
8,005 | easy-system/es-http | src/Uploading/StrategiesQueue.php | StrategiesQueue.hasOperationError | public function hasOperationError()
{
if (empty($this->sortedQueue)) {
return false;
}
$current = current($this->sortedQueue)
? current($this->sortedQueue)
: end($this->sortedQueue);
return (bool) ($current::STATE_FAILURE & $current->getState());
} | php | public function hasOperationError()
{
if (empty($this->sortedQueue)) {
return false;
}
$current = current($this->sortedQueue)
? current($this->sortedQueue)
: end($this->sortedQueue);
return (bool) ($current::STATE_FAILURE & $current->getState());
} | [
"public",
"function",
"hasOperationError",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"current",
"=",
"current",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
"?",
"current",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
":",
"end",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
";",
"return",
"(",
"bool",
")",
"(",
"$",
"current",
"::",
"STATE_FAILURE",
"&",
"$",
"current",
"->",
"getState",
"(",
")",
")",
";",
"}"
] | An easy way to check the state to the presence of failure.
Any of strategies can decides on failure without break the execution.
The queue of strategies returns result of last executed strategy, if any.
@return bool Returns true, if the state contains the failure flag,
false otherwise | [
"An",
"easy",
"way",
"to",
"check",
"the",
"state",
"to",
"the",
"presence",
"of",
"failure",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uploading/StrategiesQueue.php#L165-L175 |
8,006 | easy-system/es-http | src/Uploading/StrategiesQueue.php | StrategiesQueue.getOperationError | public function getOperationError()
{
if (empty($this->sortedQueue)) {
return;
}
$current = current($this->sortedQueue)
? current($this->sortedQueue)
: end($this->sortedQueue);
return $current->getOperationError();
} | php | public function getOperationError()
{
if (empty($this->sortedQueue)) {
return;
}
$current = current($this->sortedQueue)
? current($this->sortedQueue)
: end($this->sortedQueue);
return $current->getOperationError();
} | [
"public",
"function",
"getOperationError",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
")",
"{",
"return",
";",
"}",
"$",
"current",
"=",
"current",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
"?",
"current",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
":",
"end",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
";",
"return",
"$",
"current",
"->",
"getOperationError",
"(",
")",
";",
"}"
] | Gets the error of last operation.
@return null|string The error of last operation, if any | [
"Gets",
"the",
"error",
"of",
"last",
"operation",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uploading/StrategiesQueue.php#L182-L192 |
8,007 | easy-system/es-http | src/Uploading/StrategiesQueue.php | StrategiesQueue.getOperationErrorDescription | public function getOperationErrorDescription()
{
if (empty($this->sortedQueue)) {
return;
}
$current = current($this->sortedQueue)
? current($this->sortedQueue)
: end($this->sortedQueue);
return $current->getOperationErrorDescription();
} | php | public function getOperationErrorDescription()
{
if (empty($this->sortedQueue)) {
return;
}
$current = current($this->sortedQueue)
? current($this->sortedQueue)
: end($this->sortedQueue);
return $current->getOperationErrorDescription();
} | [
"public",
"function",
"getOperationErrorDescription",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
")",
"{",
"return",
";",
"}",
"$",
"current",
"=",
"current",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
"?",
"current",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
":",
"end",
"(",
"$",
"this",
"->",
"sortedQueue",
")",
";",
"return",
"$",
"current",
"->",
"getOperationErrorDescription",
"(",
")",
";",
"}"
] | Gets the description of error of last operation.
@return null|string The description of error of last operation, if any | [
"Gets",
"the",
"description",
"of",
"error",
"of",
"last",
"operation",
"."
] | dd5852e94901e147a7546a8715133408ece767a1 | https://github.com/easy-system/es-http/blob/dd5852e94901e147a7546a8715133408ece767a1/src/Uploading/StrategiesQueue.php#L199-L209 |
8,008 | pho-adapters/index-neo4j | Neo4j.php | Neo4j.subscribeGraphsystem | protected function subscribeGraphsystem(): void
{
$this->kernel->events()->on('graphsystem.touched',
function(array $var) {
$this->index($var);
})
->on('graphsystem.node_deleted',
function(string $id) {
$this->nodeDeleted($id);
})
->on('graphsystem.edge_deleted',
function(string $id) {
$this->edgeDeleted($id);
}
);
} | php | protected function subscribeGraphsystem(): void
{
$this->kernel->events()->on('graphsystem.touched',
function(array $var) {
$this->index($var);
})
->on('graphsystem.node_deleted',
function(string $id) {
$this->nodeDeleted($id);
})
->on('graphsystem.edge_deleted',
function(string $id) {
$this->edgeDeleted($id);
}
);
} | [
"protected",
"function",
"subscribeGraphsystem",
"(",
")",
":",
"void",
"{",
"$",
"this",
"->",
"kernel",
"->",
"events",
"(",
")",
"->",
"on",
"(",
"'graphsystem.touched'",
",",
"function",
"(",
"array",
"$",
"var",
")",
"{",
"$",
"this",
"->",
"index",
"(",
"$",
"var",
")",
";",
"}",
")",
"->",
"on",
"(",
"'graphsystem.node_deleted'",
",",
"function",
"(",
"string",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"nodeDeleted",
"(",
"$",
"id",
")",
";",
"}",
")",
"->",
"on",
"(",
"'graphsystem.edge_deleted'",
",",
"function",
"(",
"string",
"$",
"id",
")",
"{",
"$",
"this",
"->",
"edgeDeleted",
"(",
"$",
"id",
")",
";",
"}",
")",
";",
"}"
] | Listener for kernel events
Interfaces graphsystem and indexes
in every touch or delete operation.
@return void | [
"Listener",
"for",
"kernel",
"events"
] | fb0dd62439e0e4bcf306c7af6bd0f82ad55f9f94 | https://github.com/pho-adapters/index-neo4j/blob/fb0dd62439e0e4bcf306c7af6bd0f82ad55f9f94/Neo4j.php#L72-L87 |
8,009 | pho-adapters/index-neo4j | Neo4j.php | Neo4j.indexNode | protected function indexNode(array $entity): void
{
//$this->kernel->logger()->info("Header qualifies it to be indexed");
$entity["attributes"]["udid"] = $entity["id"];
$cq = sprintf("MERGE (n:%s {udid: {udid}}) SET n = {data}", $entity["label"]);
$this->kernel->logger()->info(
"The query will be as follows; %s with data ",
$cq
// print_r($entity["attributes"], true)
);
$result = $this->client->run($cq, [
"udid" => $entity["id"],
"data" => $entity["attributes"]
]);
} | php | protected function indexNode(array $entity): void
{
//$this->kernel->logger()->info("Header qualifies it to be indexed");
$entity["attributes"]["udid"] = $entity["id"];
$cq = sprintf("MERGE (n:%s {udid: {udid}}) SET n = {data}", $entity["label"]);
$this->kernel->logger()->info(
"The query will be as follows; %s with data ",
$cq
// print_r($entity["attributes"], true)
);
$result = $this->client->run($cq, [
"udid" => $entity["id"],
"data" => $entity["attributes"]
]);
} | [
"protected",
"function",
"indexNode",
"(",
"array",
"$",
"entity",
")",
":",
"void",
"{",
"//$this->kernel->logger()->info(\"Header qualifies it to be indexed\");",
"$",
"entity",
"[",
"\"attributes\"",
"]",
"[",
"\"udid\"",
"]",
"=",
"$",
"entity",
"[",
"\"id\"",
"]",
";",
"$",
"cq",
"=",
"sprintf",
"(",
"\"MERGE (n:%s {udid: {udid}}) SET n = {data}\"",
",",
"$",
"entity",
"[",
"\"label\"",
"]",
")",
";",
"$",
"this",
"->",
"kernel",
"->",
"logger",
"(",
")",
"->",
"info",
"(",
"\"The query will be as follows; %s with data \"",
",",
"$",
"cq",
"// print_r($entity[\"attributes\"], true)",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"run",
"(",
"$",
"cq",
",",
"[",
"\"udid\"",
"=>",
"$",
"entity",
"[",
"\"id\"",
"]",
",",
"\"data\"",
"=>",
"$",
"entity",
"[",
"\"attributes\"",
"]",
"]",
")",
";",
"}"
] | Indexes a node
@param array $entity In array form.
@return void | [
"Indexes",
"a",
"node"
] | fb0dd62439e0e4bcf306c7af6bd0f82ad55f9f94 | https://github.com/pho-adapters/index-neo4j/blob/fb0dd62439e0e4bcf306c7af6bd0f82ad55f9f94/Neo4j.php#L153-L167 |
8,010 | pho-adapters/index-neo4j | Neo4j.php | Neo4j.indexEdge | protected function indexEdge(array $entity): void
{
//$tail_id = $entity[]
$entity["attributes"]["udid"] = $entity["id"];
$cq = sprintf("MATCH(t {udid: {tail}}), (h {udid: {head}}) MERGE (t)-[e:%s {udid: {udid}}]->(h) SET e = {data}", $entity["label"]);
$result = $this->client->run($cq, [
"tail" => $entity["tail"],
"head" => $entity["head"],
"udid" => $entity["id"],
"data" => $entity["attributes"]
]);
} | php | protected function indexEdge(array $entity): void
{
//$tail_id = $entity[]
$entity["attributes"]["udid"] = $entity["id"];
$cq = sprintf("MATCH(t {udid: {tail}}), (h {udid: {head}}) MERGE (t)-[e:%s {udid: {udid}}]->(h) SET e = {data}", $entity["label"]);
$result = $this->client->run($cq, [
"tail" => $entity["tail"],
"head" => $entity["head"],
"udid" => $entity["id"],
"data" => $entity["attributes"]
]);
} | [
"protected",
"function",
"indexEdge",
"(",
"array",
"$",
"entity",
")",
":",
"void",
"{",
"//$tail_id = $entity[]",
"$",
"entity",
"[",
"\"attributes\"",
"]",
"[",
"\"udid\"",
"]",
"=",
"$",
"entity",
"[",
"\"id\"",
"]",
";",
"$",
"cq",
"=",
"sprintf",
"(",
"\"MATCH(t {udid: {tail}}), (h {udid: {head}}) MERGE (t)-[e:%s {udid: {udid}}]->(h) SET e = {data}\"",
",",
"$",
"entity",
"[",
"\"label\"",
"]",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"client",
"->",
"run",
"(",
"$",
"cq",
",",
"[",
"\"tail\"",
"=>",
"$",
"entity",
"[",
"\"tail\"",
"]",
",",
"\"head\"",
"=>",
"$",
"entity",
"[",
"\"head\"",
"]",
",",
"\"udid\"",
"=>",
"$",
"entity",
"[",
"\"id\"",
"]",
",",
"\"data\"",
"=>",
"$",
"entity",
"[",
"\"attributes\"",
"]",
"]",
")",
";",
"}"
] | Indexes an edge
@param array $entity In array form.
@return void | [
"Indexes",
"an",
"edge"
] | fb0dd62439e0e4bcf306c7af6bd0f82ad55f9f94 | https://github.com/pho-adapters/index-neo4j/blob/fb0dd62439e0e4bcf306c7af6bd0f82ad55f9f94/Neo4j.php#L176-L187 |
8,011 | eghojansu/nutrition | src/SQL/Criteria.php | Criteria.buildCriteria | public static function buildCriteria(array $values, $qmMode = false)
{
reset($values);
$qmMode = $qmMode ?: is_numeric(key($values));
if ($qmMode) {
$result = array_values($values);
array_unshift($result, str_repeat('?,', count($values)-1).'?');
return $result;
}
$result = [''];
foreach ($values as $key => $value) {
$key = ":$key";
$result[0] .= ($result[0]?',':'').$key;
$result[$key] = $value;
}
return $result;
} | php | public static function buildCriteria(array $values, $qmMode = false)
{
reset($values);
$qmMode = $qmMode ?: is_numeric(key($values));
if ($qmMode) {
$result = array_values($values);
array_unshift($result, str_repeat('?,', count($values)-1).'?');
return $result;
}
$result = [''];
foreach ($values as $key => $value) {
$key = ":$key";
$result[0] .= ($result[0]?',':'').$key;
$result[$key] = $value;
}
return $result;
} | [
"public",
"static",
"function",
"buildCriteria",
"(",
"array",
"$",
"values",
",",
"$",
"qmMode",
"=",
"false",
")",
"{",
"reset",
"(",
"$",
"values",
")",
";",
"$",
"qmMode",
"=",
"$",
"qmMode",
"?",
":",
"is_numeric",
"(",
"key",
"(",
"$",
"values",
")",
")",
";",
"if",
"(",
"$",
"qmMode",
")",
"{",
"$",
"result",
"=",
"array_values",
"(",
"$",
"values",
")",
";",
"array_unshift",
"(",
"$",
"result",
",",
"str_repeat",
"(",
"'?,'",
",",
"count",
"(",
"$",
"values",
")",
"-",
"1",
")",
".",
"'?'",
")",
";",
"return",
"$",
"result",
";",
"}",
"$",
"result",
"=",
"[",
"''",
"]",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"\":$key\"",
";",
"$",
"result",
"[",
"0",
"]",
".=",
"(",
"$",
"result",
"[",
"0",
"]",
"?",
"','",
":",
"''",
")",
".",
"$",
"key",
";",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Array to mapper criteria
@param array $values
@param boolean $qmMode force question mark placeholder
@return string | [
"Array",
"to",
"mapper",
"criteria"
] | 3941c62aeb6dafda55349a38dd4107d521f8964a | https://github.com/eghojansu/nutrition/blob/3941c62aeb6dafda55349a38dd4107d521f8964a/src/SQL/Criteria.php#L97-L117 |
8,012 | novuso/system | src/Utility/FastHasher.php | FastHasher.hash | public static function hash($value, string $algorithm = 'fnv1a32'): string
{
$type = gettype($value);
switch ($type) {
case 'object':
if (Validate::isEquatable($value)) {
$string = sprintf('e_%s', $value->hashValue());
} else {
$string = sprintf('o_%s', spl_object_hash($value));
}
break;
case 'string':
$string = sprintf('s_%s', $value);
break;
case 'integer':
$string = sprintf('i_%d', $value);
break;
case 'double':
$string = sprintf('f_%.14F', $value);
break;
case 'boolean':
$string = sprintf('b_%d', (int) $value);
break;
case 'resource':
$string = sprintf('r_%d', (int) $value);
break;
case 'array':
$string = sprintf('a_%s', serialize($value));
break;
default:
$string = '0';
break;
}
return hash($algorithm, $string);
} | php | public static function hash($value, string $algorithm = 'fnv1a32'): string
{
$type = gettype($value);
switch ($type) {
case 'object':
if (Validate::isEquatable($value)) {
$string = sprintf('e_%s', $value->hashValue());
} else {
$string = sprintf('o_%s', spl_object_hash($value));
}
break;
case 'string':
$string = sprintf('s_%s', $value);
break;
case 'integer':
$string = sprintf('i_%d', $value);
break;
case 'double':
$string = sprintf('f_%.14F', $value);
break;
case 'boolean':
$string = sprintf('b_%d', (int) $value);
break;
case 'resource':
$string = sprintf('r_%d', (int) $value);
break;
case 'array':
$string = sprintf('a_%s', serialize($value));
break;
default:
$string = '0';
break;
}
return hash($algorithm, $string);
} | [
"public",
"static",
"function",
"hash",
"(",
"$",
"value",
",",
"string",
"$",
"algorithm",
"=",
"'fnv1a32'",
")",
":",
"string",
"{",
"$",
"type",
"=",
"gettype",
"(",
"$",
"value",
")",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'object'",
":",
"if",
"(",
"Validate",
"::",
"isEquatable",
"(",
"$",
"value",
")",
")",
"{",
"$",
"string",
"=",
"sprintf",
"(",
"'e_%s'",
",",
"$",
"value",
"->",
"hashValue",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"string",
"=",
"sprintf",
"(",
"'o_%s'",
",",
"spl_object_hash",
"(",
"$",
"value",
")",
")",
";",
"}",
"break",
";",
"case",
"'string'",
":",
"$",
"string",
"=",
"sprintf",
"(",
"'s_%s'",
",",
"$",
"value",
")",
";",
"break",
";",
"case",
"'integer'",
":",
"$",
"string",
"=",
"sprintf",
"(",
"'i_%d'",
",",
"$",
"value",
")",
";",
"break",
";",
"case",
"'double'",
":",
"$",
"string",
"=",
"sprintf",
"(",
"'f_%.14F'",
",",
"$",
"value",
")",
";",
"break",
";",
"case",
"'boolean'",
":",
"$",
"string",
"=",
"sprintf",
"(",
"'b_%d'",
",",
"(",
"int",
")",
"$",
"value",
")",
";",
"break",
";",
"case",
"'resource'",
":",
"$",
"string",
"=",
"sprintf",
"(",
"'r_%d'",
",",
"(",
"int",
")",
"$",
"value",
")",
";",
"break",
";",
"case",
"'array'",
":",
"$",
"string",
"=",
"sprintf",
"(",
"'a_%s'",
",",
"serialize",
"(",
"$",
"value",
")",
")",
";",
"break",
";",
"default",
":",
"$",
"string",
"=",
"'0'",
";",
"break",
";",
"}",
"return",
"hash",
"(",
"$",
"algorithm",
",",
"$",
"string",
")",
";",
"}"
] | Creates a string hash for a value
@param mixed $value The value
@param string $algorithm The hash algorithm
@return string | [
"Creates",
"a",
"string",
"hash",
"for",
"a",
"value"
] | e34038b391826edc68d0b5fccfba96642de9d6f0 | https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/FastHasher.php#L22-L58 |
8,013 | unimatrix/cake | src/Shell/Helper/BenchmarkHelper.php | BenchmarkHelper.output | public function output($args = null) {
// calculate diff
$diff = $this->end->diff($this->begin);
// decide stuff
$msg = [];
if($diff->d > 0) $msg[] = $this->plural($diff->d, 'd');
if($diff->h > 0) $msg[] = $this->plural($diff->h, 'h');
if($diff->i > 0) $msg[] = $this->plural($diff->i, 'i');
$msg[] = $this->plural($diff->s);
// return stuff
return $this->str_lreplace(',', ' ' . __d('Unimatrix/cake', 'and'), implode(', ', $msg));
} | php | public function output($args = null) {
// calculate diff
$diff = $this->end->diff($this->begin);
// decide stuff
$msg = [];
if($diff->d > 0) $msg[] = $this->plural($diff->d, 'd');
if($diff->h > 0) $msg[] = $this->plural($diff->h, 'h');
if($diff->i > 0) $msg[] = $this->plural($diff->i, 'i');
$msg[] = $this->plural($diff->s);
// return stuff
return $this->str_lreplace(',', ' ' . __d('Unimatrix/cake', 'and'), implode(', ', $msg));
} | [
"public",
"function",
"output",
"(",
"$",
"args",
"=",
"null",
")",
"{",
"// calculate diff",
"$",
"diff",
"=",
"$",
"this",
"->",
"end",
"->",
"diff",
"(",
"$",
"this",
"->",
"begin",
")",
";",
"// decide stuff",
"$",
"msg",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"diff",
"->",
"d",
">",
"0",
")",
"$",
"msg",
"[",
"]",
"=",
"$",
"this",
"->",
"plural",
"(",
"$",
"diff",
"->",
"d",
",",
"'d'",
")",
";",
"if",
"(",
"$",
"diff",
"->",
"h",
">",
"0",
")",
"$",
"msg",
"[",
"]",
"=",
"$",
"this",
"->",
"plural",
"(",
"$",
"diff",
"->",
"h",
",",
"'h'",
")",
";",
"if",
"(",
"$",
"diff",
"->",
"i",
">",
"0",
")",
"$",
"msg",
"[",
"]",
"=",
"$",
"this",
"->",
"plural",
"(",
"$",
"diff",
"->",
"i",
",",
"'i'",
")",
";",
"$",
"msg",
"[",
"]",
"=",
"$",
"this",
"->",
"plural",
"(",
"$",
"diff",
"->",
"s",
")",
";",
"// return stuff",
"return",
"$",
"this",
"->",
"str_lreplace",
"(",
"','",
",",
"' '",
".",
"__d",
"(",
"'Unimatrix/cake'",
",",
"'and'",
")",
",",
"implode",
"(",
"', '",
",",
"$",
"msg",
")",
")",
";",
"}"
] | Calculate execution time
@return string | [
"Calculate",
"execution",
"time"
] | 23003aba497822bd473fdbf60514052dda1874fc | https://github.com/unimatrix/cake/blob/23003aba497822bd473fdbf60514052dda1874fc/src/Shell/Helper/BenchmarkHelper.php#L80-L93 |
8,014 | unyx/console | output/formatting/styles/Map.php | Map.get | public function get(string $name, $default = null) : ?interfaces\Style
{
return $this->items[strtolower($name)] ?? $default;
} | php | public function get(string $name, $default = null) : ?interfaces\Style
{
return $this->items[strtolower($name)] ?? $default;
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
":",
"?",
"interfaces",
"\\",
"Style",
"{",
"return",
"$",
"this",
"->",
"items",
"[",
"strtolower",
"(",
"$",
"name",
")",
"]",
"??",
"$",
"default",
";",
"}"
] | Returns a Style identified by its name.
@param string $name The name of the Style to return.
@param mixed $default The default value to return when the given Style does not exist in the Collection.
@return interfaces\Style The Style or the default value given if the Style couldn't be found. | [
"Returns",
"a",
"Style",
"identified",
"by",
"its",
"name",
"."
] | b4a76e08bbb5428b0349c0ec4259a914f81a2957 | https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/output/formatting/styles/Map.php#L38-L41 |
8,015 | unyx/console | output/formatting/styles/Map.php | Map.set | public function set(string $name, interfaces\Style $style) : Map
{
$this->items[strtolower($name)] = $style;
return $this;
} | php | public function set(string $name, interfaces\Style $style) : Map
{
$this->items[strtolower($name)] = $style;
return $this;
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"name",
",",
"interfaces",
"\\",
"Style",
"$",
"style",
")",
":",
"Map",
"{",
"$",
"this",
"->",
"items",
"[",
"strtolower",
"(",
"$",
"name",
")",
"]",
"=",
"$",
"style",
";",
"return",
"$",
"this",
";",
"}"
] | Sets the given Style in the Collection.
@param string $name The name the Style should be set as.
@param mixed $value The Style to set.
@return $this | [
"Sets",
"the",
"given",
"Style",
"in",
"the",
"Collection",
"."
] | b4a76e08bbb5428b0349c0ec4259a914f81a2957 | https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/output/formatting/styles/Map.php#L50-L55 |
8,016 | unyx/console | output/formatting/styles/Map.php | Map.contains | public function contains(interfaces\Style $style) : bool
{
return empty($this->items) ? false : (null !== $this->name($style));
} | php | public function contains(interfaces\Style $style) : bool
{
return empty($this->items) ? false : (null !== $this->name($style));
} | [
"public",
"function",
"contains",
"(",
"interfaces",
"\\",
"Style",
"$",
"style",
")",
":",
"bool",
"{",
"return",
"empty",
"(",
"$",
"this",
"->",
"items",
")",
"?",
"false",
":",
"(",
"null",
"!==",
"$",
"this",
"->",
"name",
"(",
"$",
"style",
")",
")",
";",
"}"
] | Checks whether the given Style exists in the Collection.
@param interfaces\Style $style The Style to search for.
@return bool True if the Style exists in the Collection, false otherwise. | [
"Checks",
"whether",
"the",
"given",
"Style",
"exists",
"in",
"the",
"Collection",
"."
] | b4a76e08bbb5428b0349c0ec4259a914f81a2957 | https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/output/formatting/styles/Map.php#L74-L77 |
8,017 | unyx/console | output/formatting/styles/Map.php | Map.name | public function name(interfaces\Style $style) : ?string
{
foreach ($this->items as $key => $value) {
if ($value === $style) {
return $key;
}
}
return null;
} | php | public function name(interfaces\Style $style) : ?string
{
foreach ($this->items as $key => $value) {
if ($value === $style) {
return $key;
}
}
return null;
} | [
"public",
"function",
"name",
"(",
"interfaces",
"\\",
"Style",
"$",
"style",
")",
":",
"?",
"string",
"{",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"$",
"style",
")",
"{",
"return",
"$",
"key",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Returns the name a given Style is set as within the Collection.
@param interfaces\Style $style The Style to search for.
@return string The name of the Style or null if it couldn't be found. | [
"Returns",
"the",
"name",
"a",
"given",
"Style",
"is",
"set",
"as",
"within",
"the",
"Collection",
"."
] | b4a76e08bbb5428b0349c0ec4259a914f81a2957 | https://github.com/unyx/console/blob/b4a76e08bbb5428b0349c0ec4259a914f81a2957/output/formatting/styles/Map.php#L112-L121 |
8,018 | laraning/flame | src/Commands/MakeFeatureCommand.php | MakeFeatureCommand.parseFile | protected function parseFile(string $origin, string $destination, array $translations = [], array $conversions = [])
{
$data = str_replace($translations, $conversions, file_get_contents($origin));
file_put_contents($destination, $data);
} | php | protected function parseFile(string $origin, string $destination, array $translations = [], array $conversions = [])
{
$data = str_replace($translations, $conversions, file_get_contents($origin));
file_put_contents($destination, $data);
} | [
"protected",
"function",
"parseFile",
"(",
"string",
"$",
"origin",
",",
"string",
"$",
"destination",
",",
"array",
"$",
"translations",
"=",
"[",
"]",
",",
"array",
"$",
"conversions",
"=",
"[",
"]",
")",
"{",
"$",
"data",
"=",
"str_replace",
"(",
"$",
"translations",
",",
"$",
"conversions",
",",
"file_get_contents",
"(",
"$",
"origin",
")",
")",
";",
"file_put_contents",
"(",
"$",
"destination",
",",
"$",
"data",
")",
";",
"}"
] | Parses the original file with the respective replacement pairs, and
creates the destination file with everything replaced.
@param string $origin The original file path.
@param string $destination The destination file path.
@param array $translations The keys to translate: {{example}}.
@param array $conversions The the converted values.
@return void | [
"Parses",
"the",
"original",
"file",
"with",
"the",
"respective",
"replacement",
"pairs",
"and",
"creates",
"the",
"destination",
"file",
"with",
"everything",
"replaced",
"."
] | 42bdc99fd3b7c200707bcc407d7d87390b3a7c37 | https://github.com/laraning/flame/blob/42bdc99fd3b7c200707bcc407d7d87390b3a7c37/src/Commands/MakeFeatureCommand.php#L237-L241 |
8,019 | laraning/flame | src/Commands/MakeFeatureCommand.php | MakeFeatureCommand.makeFeatureDirectories | protected function makeFeatureDirectories()
{
File::makeDirectories([$this->basePath,
$this->basePath.'/Twinkles',
$this->basePath.'/Panels',
$this->basePath.'/Controllers', ]);
} | php | protected function makeFeatureDirectories()
{
File::makeDirectories([$this->basePath,
$this->basePath.'/Twinkles',
$this->basePath.'/Panels',
$this->basePath.'/Controllers', ]);
} | [
"protected",
"function",
"makeFeatureDirectories",
"(",
")",
"{",
"File",
"::",
"makeDirectories",
"(",
"[",
"$",
"this",
"->",
"basePath",
",",
"$",
"this",
"->",
"basePath",
".",
"'/Twinkles'",
",",
"$",
"this",
"->",
"basePath",
".",
"'/Panels'",
",",
"$",
"this",
"->",
"basePath",
".",
"'/Controllers'",
",",
"]",
")",
";",
"}"
] | Creates the Feature directory and sub-directories.
@return void | [
"Creates",
"the",
"Feature",
"directory",
"and",
"sub",
"-",
"directories",
"."
] | 42bdc99fd3b7c200707bcc407d7d87390b3a7c37 | https://github.com/laraning/flame/blob/42bdc99fd3b7c200707bcc407d7d87390b3a7c37/src/Commands/MakeFeatureCommand.php#L248-L254 |
8,020 | benkle-libs/doctrine-adoption | src/Collector.php | Collector.addAdoptee | public function addAdoptee($for, $adoptee, $discriminator)
{
if (!isset($this->entities[$for]) || !is_array($this->entities[$for])) {
$this->entities[$for] = [];
}
$this->entities[$for][$discriminator] = $adoptee;
return $this;
} | php | public function addAdoptee($for, $adoptee, $discriminator)
{
if (!isset($this->entities[$for]) || !is_array($this->entities[$for])) {
$this->entities[$for] = [];
}
$this->entities[$for][$discriminator] = $adoptee;
return $this;
} | [
"public",
"function",
"addAdoptee",
"(",
"$",
"for",
",",
"$",
"adoptee",
",",
"$",
"discriminator",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"entities",
"[",
"$",
"for",
"]",
")",
"||",
"!",
"is_array",
"(",
"$",
"this",
"->",
"entities",
"[",
"$",
"for",
"]",
")",
")",
"{",
"$",
"this",
"->",
"entities",
"[",
"$",
"for",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"this",
"->",
"entities",
"[",
"$",
"for",
"]",
"[",
"$",
"discriminator",
"]",
"=",
"$",
"adoptee",
";",
"return",
"$",
"this",
";",
"}"
] | Add adoptee to the collector.
@param string $for Class name of the adopting entity
@param string $adoptee Class name of the adopted entity
@param string $discriminator Name for the discriminator column
@return $this | [
"Add",
"adoptee",
"to",
"the",
"collector",
"."
] | 01dcb48d7224c7003fa0acbac5c2ddd54d860fd4 | https://github.com/benkle-libs/doctrine-adoption/blob/01dcb48d7224c7003fa0acbac5c2ddd54d860fd4/src/Collector.php#L37-L44 |
8,021 | simonhamp/network-elements | src/Console/Commands/NetworkConfigCommand.php | NetworkConfigCommand.finalizeSetup | protected function finalizeSetup()
{
// Run migrations if possible
$attemptMigrate = false;
if ($this->connection === 'sqlite') {
$attemptMigrate = $this->createSqliteDatabase();
} else {
$attemptMigrate = $this->canConnectToDb();
}
sleep(1);
if ($attemptMigrate) {
// We need to reconnect using new settings if we're running SQLite
if ($this->connection === 'sqlite') {
app()['db']->reconnect();
}
$this->call('migrate', ['--force' => true]);
// Mark as installer complete
Storage::put('installer', '2');
sleep(1);
// Create the first user's account if we need to
if (User::count() < 1) {
$this->info("Now let's create your user account...");
$this->call('network:user', ['--name' => $this->user_name]);
}
}
// Make the symlinks we need
$this->createSymlinks();
sleep(1);
if (! $this->hasError) {
$this->alert("Great news, {$this->user_name}: your Network is set up! I hope you enjoy using Network.");
} else {
$this->warn("Sorry, {$this->user_name}, I couldn't complete your Network setup this time.");
$this->warn("Please check the warning messages to see what you need to do and rerun `php artisan network:config`.");
}
} | php | protected function finalizeSetup()
{
// Run migrations if possible
$attemptMigrate = false;
if ($this->connection === 'sqlite') {
$attemptMigrate = $this->createSqliteDatabase();
} else {
$attemptMigrate = $this->canConnectToDb();
}
sleep(1);
if ($attemptMigrate) {
// We need to reconnect using new settings if we're running SQLite
if ($this->connection === 'sqlite') {
app()['db']->reconnect();
}
$this->call('migrate', ['--force' => true]);
// Mark as installer complete
Storage::put('installer', '2');
sleep(1);
// Create the first user's account if we need to
if (User::count() < 1) {
$this->info("Now let's create your user account...");
$this->call('network:user', ['--name' => $this->user_name]);
}
}
// Make the symlinks we need
$this->createSymlinks();
sleep(1);
if (! $this->hasError) {
$this->alert("Great news, {$this->user_name}: your Network is set up! I hope you enjoy using Network.");
} else {
$this->warn("Sorry, {$this->user_name}, I couldn't complete your Network setup this time.");
$this->warn("Please check the warning messages to see what you need to do and rerun `php artisan network:config`.");
}
} | [
"protected",
"function",
"finalizeSetup",
"(",
")",
"{",
"// Run migrations if possible",
"$",
"attemptMigrate",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"connection",
"===",
"'sqlite'",
")",
"{",
"$",
"attemptMigrate",
"=",
"$",
"this",
"->",
"createSqliteDatabase",
"(",
")",
";",
"}",
"else",
"{",
"$",
"attemptMigrate",
"=",
"$",
"this",
"->",
"canConnectToDb",
"(",
")",
";",
"}",
"sleep",
"(",
"1",
")",
";",
"if",
"(",
"$",
"attemptMigrate",
")",
"{",
"// We need to reconnect using new settings if we're running SQLite",
"if",
"(",
"$",
"this",
"->",
"connection",
"===",
"'sqlite'",
")",
"{",
"app",
"(",
")",
"[",
"'db'",
"]",
"->",
"reconnect",
"(",
")",
";",
"}",
"$",
"this",
"->",
"call",
"(",
"'migrate'",
",",
"[",
"'--force'",
"=>",
"true",
"]",
")",
";",
"// Mark as installer complete",
"Storage",
"::",
"put",
"(",
"'installer'",
",",
"'2'",
")",
";",
"sleep",
"(",
"1",
")",
";",
"// Create the first user's account if we need to",
"if",
"(",
"User",
"::",
"count",
"(",
")",
"<",
"1",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"\"Now let's create your user account...\"",
")",
";",
"$",
"this",
"->",
"call",
"(",
"'network:user'",
",",
"[",
"'--name'",
"=>",
"$",
"this",
"->",
"user_name",
"]",
")",
";",
"}",
"}",
"// Make the symlinks we need",
"$",
"this",
"->",
"createSymlinks",
"(",
")",
";",
"sleep",
"(",
"1",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"hasError",
")",
"{",
"$",
"this",
"->",
"alert",
"(",
"\"Great news, {$this->user_name}: your Network is set up! I hope you enjoy using Network.\"",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"Sorry, {$this->user_name}, I couldn't complete your Network setup this time.\"",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"\"Please check the warning messages to see what you need to do and rerun `php artisan network:config`.\"",
")",
";",
"}",
"}"
] | Run main setup after we know we have the .env in place. | [
"Run",
"main",
"setup",
"after",
"we",
"know",
"we",
"have",
"the",
".",
"env",
"in",
"place",
"."
] | 17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8 | https://github.com/simonhamp/network-elements/blob/17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8/src/Console/Commands/NetworkConfigCommand.php#L214-L258 |
8,022 | simonhamp/network-elements | src/Console/Commands/NetworkConfigCommand.php | NetworkConfigCommand.createSqliteDatabase | protected function createSqliteDatabase()
{
$dbPath = config('database.connections.sqlite.database');
$createDb = new Process("touch $dbPath");
$createDb->run();
if (! $createDb->isSuccessful()) {
$this->warn("I couldn't create your SQLite database file.");
$this->warn("Please create it after setup is complete and re-run setup.");
$this->warn("Run `touch database/database.sqlite`");
Storage::put('installer', '1');
logger('NETWORK.INSTALL: Failed to create SQLite database');
$this->hasError = true;
return false;
}
$this->info("Database created at $dbPath.");
return true;
} | php | protected function createSqliteDatabase()
{
$dbPath = config('database.connections.sqlite.database');
$createDb = new Process("touch $dbPath");
$createDb->run();
if (! $createDb->isSuccessful()) {
$this->warn("I couldn't create your SQLite database file.");
$this->warn("Please create it after setup is complete and re-run setup.");
$this->warn("Run `touch database/database.sqlite`");
Storage::put('installer', '1');
logger('NETWORK.INSTALL: Failed to create SQLite database');
$this->hasError = true;
return false;
}
$this->info("Database created at $dbPath.");
return true;
} | [
"protected",
"function",
"createSqliteDatabase",
"(",
")",
"{",
"$",
"dbPath",
"=",
"config",
"(",
"'database.connections.sqlite.database'",
")",
";",
"$",
"createDb",
"=",
"new",
"Process",
"(",
"\"touch $dbPath\"",
")",
";",
"$",
"createDb",
"->",
"run",
"(",
")",
";",
"if",
"(",
"!",
"$",
"createDb",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"I couldn't create your SQLite database file.\"",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"\"Please create it after setup is complete and re-run setup.\"",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"\"Run `touch database/database.sqlite`\"",
")",
";",
"Storage",
"::",
"put",
"(",
"'installer'",
",",
"'1'",
")",
";",
"logger",
"(",
"'NETWORK.INSTALL: Failed to create SQLite database'",
")",
";",
"$",
"this",
"->",
"hasError",
"=",
"true",
";",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"info",
"(",
"\"Database created at $dbPath.\"",
")",
";",
"return",
"true",
";",
"}"
] | Create the SQLite database file if this is the driver the user wants to use.
@return bool | [
"Create",
"the",
"SQLite",
"database",
"file",
"if",
"this",
"is",
"the",
"driver",
"the",
"user",
"wants",
"to",
"use",
"."
] | 17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8 | https://github.com/simonhamp/network-elements/blob/17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8/src/Console/Commands/NetworkConfigCommand.php#L265-L285 |
8,023 | simonhamp/network-elements | src/Console/Commands/NetworkConfigCommand.php | NetworkConfigCommand.canConnectToDb | protected function canConnectToDb()
{
$dbServer = $this->validConnections[$this->connection];
try {
// Run a simple test that will fail if the database doesn't exist
Schema::connection($this->connection)->hasTable('migrations');
return true;
} catch (\PDOException $e) {
$this->warn("I couldn't connect to a database called '{$this->database}' using the credentials you gave.");
$this->warn("Please make sure the database exists and check your settings then re-run `network:config`.");
Storage::put('installer', '1');
logger('NETWORK.INSTALL: Failed to connect to database');
$this->hasError = true;
}
return false;
} | php | protected function canConnectToDb()
{
$dbServer = $this->validConnections[$this->connection];
try {
// Run a simple test that will fail if the database doesn't exist
Schema::connection($this->connection)->hasTable('migrations');
return true;
} catch (\PDOException $e) {
$this->warn("I couldn't connect to a database called '{$this->database}' using the credentials you gave.");
$this->warn("Please make sure the database exists and check your settings then re-run `network:config`.");
Storage::put('installer', '1');
logger('NETWORK.INSTALL: Failed to connect to database');
$this->hasError = true;
}
return false;
} | [
"protected",
"function",
"canConnectToDb",
"(",
")",
"{",
"$",
"dbServer",
"=",
"$",
"this",
"->",
"validConnections",
"[",
"$",
"this",
"->",
"connection",
"]",
";",
"try",
"{",
"// Run a simple test that will fail if the database doesn't exist",
"Schema",
"::",
"connection",
"(",
"$",
"this",
"->",
"connection",
")",
"->",
"hasTable",
"(",
"'migrations'",
")",
";",
"return",
"true",
";",
"}",
"catch",
"(",
"\\",
"PDOException",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"I couldn't connect to a database called '{$this->database}' using the credentials you gave.\"",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"\"Please make sure the database exists and check your settings then re-run `network:config`.\"",
")",
";",
"Storage",
"::",
"put",
"(",
"'installer'",
",",
"'1'",
")",
";",
"logger",
"(",
"'NETWORK.INSTALL: Failed to connect to database'",
")",
";",
"$",
"this",
"->",
"hasError",
"=",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Check the database connection
@return bool | [
"Check",
"the",
"database",
"connection"
] | 17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8 | https://github.com/simonhamp/network-elements/blob/17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8/src/Console/Commands/NetworkConfigCommand.php#L292-L309 |
8,024 | simonhamp/network-elements | src/Console/Commands/NetworkConfigCommand.php | NetworkConfigCommand.generateEnv | protected function generateEnv()
{
$env = null;
// Get the existing .env file contents to replace
$envPath = $this->laravel->environmentFilePath();
if (! file_exists($envPath)) {
// Create the .env file from the example file
copy($envPath.'.example', $envPath);
$this->callSilent('key:generate', ['--force' => true]);
}
$env = file_get_contents($envPath);
// Loop over all of the keys we can set and replace the values that are set
foreach ($this->keys as $key => $var) {
// Skip if it's not set
if (! isset($this->$var)) {
continue;
}
$env = preg_replace(
$this->keyReplacementPattern($key),
$key.'='.(is_string($this->$var) ? '"'.$this->$var.'"' : $this->$var),
$env,
1
);
}
return $env;
} | php | protected function generateEnv()
{
$env = null;
// Get the existing .env file contents to replace
$envPath = $this->laravel->environmentFilePath();
if (! file_exists($envPath)) {
// Create the .env file from the example file
copy($envPath.'.example', $envPath);
$this->callSilent('key:generate', ['--force' => true]);
}
$env = file_get_contents($envPath);
// Loop over all of the keys we can set and replace the values that are set
foreach ($this->keys as $key => $var) {
// Skip if it's not set
if (! isset($this->$var)) {
continue;
}
$env = preg_replace(
$this->keyReplacementPattern($key),
$key.'='.(is_string($this->$var) ? '"'.$this->$var.'"' : $this->$var),
$env,
1
);
}
return $env;
} | [
"protected",
"function",
"generateEnv",
"(",
")",
"{",
"$",
"env",
"=",
"null",
";",
"// Get the existing .env file contents to replace",
"$",
"envPath",
"=",
"$",
"this",
"->",
"laravel",
"->",
"environmentFilePath",
"(",
")",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"envPath",
")",
")",
"{",
"// Create the .env file from the example file",
"copy",
"(",
"$",
"envPath",
".",
"'.example'",
",",
"$",
"envPath",
")",
";",
"$",
"this",
"->",
"callSilent",
"(",
"'key:generate'",
",",
"[",
"'--force'",
"=>",
"true",
"]",
")",
";",
"}",
"$",
"env",
"=",
"file_get_contents",
"(",
"$",
"envPath",
")",
";",
"// Loop over all of the keys we can set and replace the values that are set",
"foreach",
"(",
"$",
"this",
"->",
"keys",
"as",
"$",
"key",
"=>",
"$",
"var",
")",
"{",
"// Skip if it's not set",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"$",
"var",
")",
")",
"{",
"continue",
";",
"}",
"$",
"env",
"=",
"preg_replace",
"(",
"$",
"this",
"->",
"keyReplacementPattern",
"(",
"$",
"key",
")",
",",
"$",
"key",
".",
"'='",
".",
"(",
"is_string",
"(",
"$",
"this",
"->",
"$",
"var",
")",
"?",
"'\"'",
".",
"$",
"this",
"->",
"$",
"var",
".",
"'\"'",
":",
"$",
"this",
"->",
"$",
"var",
")",
",",
"$",
"env",
",",
"1",
")",
";",
"}",
"return",
"$",
"env",
";",
"}"
] | Generate the full .env file by replacing values from original
@return string | [
"Generate",
"the",
"full",
".",
"env",
"file",
"by",
"replacing",
"values",
"from",
"original"
] | 17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8 | https://github.com/simonhamp/network-elements/blob/17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8/src/Console/Commands/NetworkConfigCommand.php#L341-L372 |
8,025 | simonhamp/network-elements | src/Console/Commands/NetworkConfigCommand.php | NetworkConfigCommand.createSymlinks | protected function createSymlinks()
{
// Symlink the public storage folder
if (! file_exists(public_path('storage'))) {
$this->call('storage:link');
}
// Symlink the public assets folder
if (! is_link($sitePath = public_path('network'))) {
$this->info('Symlinking public assets...');
$vendorPath = base_path('vendor/simonhamp/network-elements/public/');
$createSymlink = new Process('ln -s "'.$vendorPath.'" "'.$sitePath.'"');
$createSymlink->run();
if (! $createSymlink->isSuccessful()) {
$this->warn("I couldn't create a symlink to the Network public assets (CSS, JavaScript, fonts and images.");
$this->warn("Please create a symlink to {$vendorPath} at {$sitePath}");
logger('NETWORK.INSTALL: Failed to symlink public assets.', ['paths' => [$vendorPath, $sitePath]]);
$this->hasError = true;
return;
}
$this->info('Symlinking created successfully!');
}
} | php | protected function createSymlinks()
{
// Symlink the public storage folder
if (! file_exists(public_path('storage'))) {
$this->call('storage:link');
}
// Symlink the public assets folder
if (! is_link($sitePath = public_path('network'))) {
$this->info('Symlinking public assets...');
$vendorPath = base_path('vendor/simonhamp/network-elements/public/');
$createSymlink = new Process('ln -s "'.$vendorPath.'" "'.$sitePath.'"');
$createSymlink->run();
if (! $createSymlink->isSuccessful()) {
$this->warn("I couldn't create a symlink to the Network public assets (CSS, JavaScript, fonts and images.");
$this->warn("Please create a symlink to {$vendorPath} at {$sitePath}");
logger('NETWORK.INSTALL: Failed to symlink public assets.', ['paths' => [$vendorPath, $sitePath]]);
$this->hasError = true;
return;
}
$this->info('Symlinking created successfully!');
}
} | [
"protected",
"function",
"createSymlinks",
"(",
")",
"{",
"// Symlink the public storage folder",
"if",
"(",
"!",
"file_exists",
"(",
"public_path",
"(",
"'storage'",
")",
")",
")",
"{",
"$",
"this",
"->",
"call",
"(",
"'storage:link'",
")",
";",
"}",
"// Symlink the public assets folder",
"if",
"(",
"!",
"is_link",
"(",
"$",
"sitePath",
"=",
"public_path",
"(",
"'network'",
")",
")",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"'Symlinking public assets...'",
")",
";",
"$",
"vendorPath",
"=",
"base_path",
"(",
"'vendor/simonhamp/network-elements/public/'",
")",
";",
"$",
"createSymlink",
"=",
"new",
"Process",
"(",
"'ln -s \"'",
".",
"$",
"vendorPath",
".",
"'\" \"'",
".",
"$",
"sitePath",
".",
"'\"'",
")",
";",
"$",
"createSymlink",
"->",
"run",
"(",
")",
";",
"if",
"(",
"!",
"$",
"createSymlink",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"$",
"this",
"->",
"warn",
"(",
"\"I couldn't create a symlink to the Network public assets (CSS, JavaScript, fonts and images.\"",
")",
";",
"$",
"this",
"->",
"warn",
"(",
"\"Please create a symlink to {$vendorPath} at {$sitePath}\"",
")",
";",
"logger",
"(",
"'NETWORK.INSTALL: Failed to symlink public assets.'",
",",
"[",
"'paths'",
"=>",
"[",
"$",
"vendorPath",
",",
"$",
"sitePath",
"]",
"]",
")",
";",
"$",
"this",
"->",
"hasError",
"=",
"true",
";",
"return",
";",
"}",
"$",
"this",
"->",
"info",
"(",
"'Symlinking created successfully!'",
")",
";",
"}",
"}"
] | Create folder symlinks | [
"Create",
"folder",
"symlinks"
] | 17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8 | https://github.com/simonhamp/network-elements/blob/17cc17c5dbb8235c0c6e283a55578d72fe2d8ef8/src/Console/Commands/NetworkConfigCommand.php#L377-L401 |
8,026 | bishopb/vanilla | applications/dashboard/controllers/class.homecontroller.php | HomeController.Initialize | public function Initialize() {
$this->Head = new HeadModule($this);
$this->AddJsFile('jquery.js');
$this->AddJsFile('jquery.livequery.js');
$this->AddJsFile('jquery.form.js');
$this->AddJsFile('jquery.popup.js');
$this->AddJsFile('jquery.gardenhandleajaxform.js');
$this->AddJsFile('global.js');
$this->AddCssFile('admin.css');
$this->MasterView = 'empty';
parent::Initialize();
} | php | public function Initialize() {
$this->Head = new HeadModule($this);
$this->AddJsFile('jquery.js');
$this->AddJsFile('jquery.livequery.js');
$this->AddJsFile('jquery.form.js');
$this->AddJsFile('jquery.popup.js');
$this->AddJsFile('jquery.gardenhandleajaxform.js');
$this->AddJsFile('global.js');
$this->AddCssFile('admin.css');
$this->MasterView = 'empty';
parent::Initialize();
} | [
"public",
"function",
"Initialize",
"(",
")",
"{",
"$",
"this",
"->",
"Head",
"=",
"new",
"HeadModule",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.livequery.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.form.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.popup.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'jquery.gardenhandleajaxform.js'",
")",
";",
"$",
"this",
"->",
"AddJsFile",
"(",
"'global.js'",
")",
";",
"$",
"this",
"->",
"AddCssFile",
"(",
"'admin.css'",
")",
";",
"$",
"this",
"->",
"MasterView",
"=",
"'empty'",
";",
"parent",
"::",
"Initialize",
"(",
")",
";",
"}"
] | JS & CSS includes for all methods in this controller.
@since 2.0.0
@access public | [
"JS",
"&",
"CSS",
"includes",
"for",
"all",
"methods",
"in",
"this",
"controller",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.homecontroller.php#L29-L40 |
8,027 | bishopb/vanilla | applications/dashboard/controllers/class.homecontroller.php | HomeController.FileNotFound | public function FileNotFound() {
$this->RemoveCssFile('admin.css');
$this->AddCssFile('style.css');
$this->MasterView = 'default';
$this->CssClass = 'SplashMessage NoPanel';
if ($this->Data('ViewPaths')) {
Trace($this->Data('ViewPaths'), 'View Paths');
}
$this->SetData('_NoMessages', TRUE);
if ($this->DeliveryMethod() == DELIVERY_METHOD_XHTML) {
header("HTTP/1.0 404", TRUE, 404);
$this->Render();
} else
$this->RenderException(NotFoundException());
} | php | public function FileNotFound() {
$this->RemoveCssFile('admin.css');
$this->AddCssFile('style.css');
$this->MasterView = 'default';
$this->CssClass = 'SplashMessage NoPanel';
if ($this->Data('ViewPaths')) {
Trace($this->Data('ViewPaths'), 'View Paths');
}
$this->SetData('_NoMessages', TRUE);
if ($this->DeliveryMethod() == DELIVERY_METHOD_XHTML) {
header("HTTP/1.0 404", TRUE, 404);
$this->Render();
} else
$this->RenderException(NotFoundException());
} | [
"public",
"function",
"FileNotFound",
"(",
")",
"{",
"$",
"this",
"->",
"RemoveCssFile",
"(",
"'admin.css'",
")",
";",
"$",
"this",
"->",
"AddCssFile",
"(",
"'style.css'",
")",
";",
"$",
"this",
"->",
"MasterView",
"=",
"'default'",
";",
"$",
"this",
"->",
"CssClass",
"=",
"'SplashMessage NoPanel'",
";",
"if",
"(",
"$",
"this",
"->",
"Data",
"(",
"'ViewPaths'",
")",
")",
"{",
"Trace",
"(",
"$",
"this",
"->",
"Data",
"(",
"'ViewPaths'",
")",
",",
"'View Paths'",
")",
";",
"}",
"$",
"this",
"->",
"SetData",
"(",
"'_NoMessages'",
",",
"TRUE",
")",
";",
"if",
"(",
"$",
"this",
"->",
"DeliveryMethod",
"(",
")",
"==",
"DELIVERY_METHOD_XHTML",
")",
"{",
"header",
"(",
"\"HTTP/1.0 404\"",
",",
"TRUE",
",",
"404",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}",
"else",
"$",
"this",
"->",
"RenderException",
"(",
"NotFoundException",
"(",
")",
")",
";",
"}"
] | A standard 404 File Not Found error message is delivered when this action
is encountered.
@since 2.0.0
@access public | [
"A",
"standard",
"404",
"File",
"Not",
"Found",
"error",
"message",
"is",
"delivered",
"when",
"this",
"action",
"is",
"encountered",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.homecontroller.php#L75-L93 |
8,028 | bishopb/vanilla | applications/dashboard/controllers/class.homecontroller.php | HomeController.Permission | public function Permission() {
if ($this->DeliveryMethod() == DELIVERY_METHOD_XHTML) {
header("HTTP/1.0 401", TRUE, 401);
$this->Render();
} else
$this->RenderException(PermissionException());
} | php | public function Permission() {
if ($this->DeliveryMethod() == DELIVERY_METHOD_XHTML) {
header("HTTP/1.0 401", TRUE, 401);
$this->Render();
} else
$this->RenderException(PermissionException());
} | [
"public",
"function",
"Permission",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"DeliveryMethod",
"(",
")",
"==",
"DELIVERY_METHOD_XHTML",
")",
"{",
"header",
"(",
"\"HTTP/1.0 401\"",
",",
"TRUE",
",",
"401",
")",
";",
"$",
"this",
"->",
"Render",
"(",
")",
";",
"}",
"else",
"$",
"this",
"->",
"RenderException",
"(",
"PermissionException",
"(",
")",
")",
";",
"}"
] | Display 'no permission' page.
@since 2.0.0
@access public | [
"Display",
"no",
"permission",
"page",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.homecontroller.php#L146-L152 |
8,029 | dmeikle/pesedget | src/Gossamer/Pesedget/Commands/SaveCommand.php | SaveCommand.saveI18nValues | private function saveI18nValues($firstResult, $requestParams, &$locale) {
// file_put_contents('/var/www/db-repo/logs/cms.log', print_r($requestParams, true), FILE_APPEND);
if(!$this->entity instanceof AbstractI18nEntity || is_null($locale)) {
return;
}
// file_put_contents('/var/www/db-repo/logs/cms.log', print_r($requestParams, true), FILE_APPEND);
$parsedLocales = $locale;//$this->parseJson($locale);
foreach($parsedLocales as $parsedLocale => $row) {
$params = array($this->entity->getI18nIdentifier() => $firstResult, 'locale' => $parsedLocale);
//need to add this, since it is what associates us to the parent table
$row[$this->entity->getI18nIdentifier()] = $firstResult;
$row['locale'] = $parsedLocale;
$this->getQueryBuilder()->setValues($row);
//file_put_contents('/var/www/db-repo/logs/test.log', "i18nquery:row ".print_r($row, true) ."\r\n", FILE_APPEND);
$this->getQueryBuilder()->where($params);
$query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::SAVE_QUERY, QueryBuilder::CHILD_ONLY);
$this->query($query);
}
} | php | private function saveI18nValues($firstResult, $requestParams, &$locale) {
// file_put_contents('/var/www/db-repo/logs/cms.log', print_r($requestParams, true), FILE_APPEND);
if(!$this->entity instanceof AbstractI18nEntity || is_null($locale)) {
return;
}
// file_put_contents('/var/www/db-repo/logs/cms.log', print_r($requestParams, true), FILE_APPEND);
$parsedLocales = $locale;//$this->parseJson($locale);
foreach($parsedLocales as $parsedLocale => $row) {
$params = array($this->entity->getI18nIdentifier() => $firstResult, 'locale' => $parsedLocale);
//need to add this, since it is what associates us to the parent table
$row[$this->entity->getI18nIdentifier()] = $firstResult;
$row['locale'] = $parsedLocale;
$this->getQueryBuilder()->setValues($row);
//file_put_contents('/var/www/db-repo/logs/test.log', "i18nquery:row ".print_r($row, true) ."\r\n", FILE_APPEND);
$this->getQueryBuilder()->where($params);
$query = $this->getQueryBuilder()->getQuery($this->entity, QueryBuilder::SAVE_QUERY, QueryBuilder::CHILD_ONLY);
$this->query($query);
}
} | [
"private",
"function",
"saveI18nValues",
"(",
"$",
"firstResult",
",",
"$",
"requestParams",
",",
"&",
"$",
"locale",
")",
"{",
"// file_put_contents('/var/www/db-repo/logs/cms.log', print_r($requestParams, true), FILE_APPEND);",
"if",
"(",
"!",
"$",
"this",
"->",
"entity",
"instanceof",
"AbstractI18nEntity",
"||",
"is_null",
"(",
"$",
"locale",
")",
")",
"{",
"return",
";",
"}",
"// file_put_contents('/var/www/db-repo/logs/cms.log', print_r($requestParams, true), FILE_APPEND);",
"$",
"parsedLocales",
"=",
"$",
"locale",
";",
"//$this->parseJson($locale); ",
"foreach",
"(",
"$",
"parsedLocales",
"as",
"$",
"parsedLocale",
"=>",
"$",
"row",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"$",
"this",
"->",
"entity",
"->",
"getI18nIdentifier",
"(",
")",
"=>",
"$",
"firstResult",
",",
"'locale'",
"=>",
"$",
"parsedLocale",
")",
";",
"//need to add this, since it is what associates us to the parent table",
"$",
"row",
"[",
"$",
"this",
"->",
"entity",
"->",
"getI18nIdentifier",
"(",
")",
"]",
"=",
"$",
"firstResult",
";",
"$",
"row",
"[",
"'locale'",
"]",
"=",
"$",
"parsedLocale",
";",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"setValues",
"(",
"$",
"row",
")",
";",
"//file_put_contents('/var/www/db-repo/logs/test.log', \"i18nquery:row \".print_r($row, true) .\"\\r\\n\", FILE_APPEND);",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"where",
"(",
"$",
"params",
")",
";",
"$",
"query",
"=",
"$",
"this",
"->",
"getQueryBuilder",
"(",
")",
"->",
"getQuery",
"(",
"$",
"this",
"->",
"entity",
",",
"QueryBuilder",
"::",
"SAVE_QUERY",
",",
"QueryBuilder",
"::",
"CHILD_ONLY",
")",
";",
"$",
"this",
"->",
"query",
"(",
"$",
"query",
")",
";",
"}",
"}"
] | save child rows into I18n specific to saved entity | [
"save",
"child",
"rows",
"into",
"I18n",
"specific",
"to",
"saved",
"entity"
] | bcfca25569d1f47c073f08906a710ed895f77b4d | https://github.com/dmeikle/pesedget/blob/bcfca25569d1f47c073f08906a710ed895f77b4d/src/Gossamer/Pesedget/Commands/SaveCommand.php#L192-L219 |
8,030 | phossa2/libs | src/Phossa2/Route/Resolver/ResolverSimple.php | ResolverSimple.searchController | protected function searchController(
/*# string */ $controller,
/*# string */ $action
)/*# : callable */ {
$controllerName = $controller . $this->controller_suffix;
$actionName = $action . $this->action_suffix;
foreach ($this->namespaces as $ns) {
$class = $ns . '\\' . $controllerName;
if (class_exists($class)) {
$obj = new $class();
return [$obj, $actionName];
}
}
throw new LogicException(
Message::get(Message::RTE_HANDLER_UNKNOWN, $controller),
Message::RTE_HANDLER_UNKNOWN
);
} | php | protected function searchController(
/*# string */ $controller,
/*# string */ $action
)/*# : callable */ {
$controllerName = $controller . $this->controller_suffix;
$actionName = $action . $this->action_suffix;
foreach ($this->namespaces as $ns) {
$class = $ns . '\\' . $controllerName;
if (class_exists($class)) {
$obj = new $class();
return [$obj, $actionName];
}
}
throw new LogicException(
Message::get(Message::RTE_HANDLER_UNKNOWN, $controller),
Message::RTE_HANDLER_UNKNOWN
);
} | [
"protected",
"function",
"searchController",
"(",
"/*# string */",
"$",
"controller",
",",
"/*# string */",
"$",
"action",
")",
"/*# : callable */",
"{",
"$",
"controllerName",
"=",
"$",
"controller",
".",
"$",
"this",
"->",
"controller_suffix",
";",
"$",
"actionName",
"=",
"$",
"action",
".",
"$",
"this",
"->",
"action_suffix",
";",
"foreach",
"(",
"$",
"this",
"->",
"namespaces",
"as",
"$",
"ns",
")",
"{",
"$",
"class",
"=",
"$",
"ns",
".",
"'\\\\'",
".",
"$",
"controllerName",
";",
"if",
"(",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"obj",
"=",
"new",
"$",
"class",
"(",
")",
";",
"return",
"[",
"$",
"obj",
",",
"$",
"actionName",
"]",
";",
"}",
"}",
"throw",
"new",
"LogicException",
"(",
"Message",
"::",
"get",
"(",
"Message",
"::",
"RTE_HANDLER_UNKNOWN",
",",
"$",
"controller",
")",
",",
"Message",
"::",
"RTE_HANDLER_UNKNOWN",
")",
";",
"}"
] | Search controller base on the name
@param string $controller
@param string $action
@return callable
@throws LogicException if not found
@access protected | [
"Search",
"controller",
"base",
"on",
"the",
"name"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Route/Resolver/ResolverSimple.php#L93-L110 |
8,031 | avoo/FrameworkGeneratorBundle | Generator/Template/Template.php | Template.getBundlePrefix | public function getBundlePrefix(AbstractResourceBundle $bundle = null)
{
if (is_null($bundle)) {
$bundle = $this->bundle;
}
$containerExtension = new \ReflectionClass($bundle->getContainerExtension());
$applicationName = $containerExtension->getProperty('applicationName');
$applicationName->setAccessible(true);
$extension = $bundle->getContainerExtension();
return $applicationName->getValue(new $extension());
} | php | public function getBundlePrefix(AbstractResourceBundle $bundle = null)
{
if (is_null($bundle)) {
$bundle = $this->bundle;
}
$containerExtension = new \ReflectionClass($bundle->getContainerExtension());
$applicationName = $containerExtension->getProperty('applicationName');
$applicationName->setAccessible(true);
$extension = $bundle->getContainerExtension();
return $applicationName->getValue(new $extension());
} | [
"public",
"function",
"getBundlePrefix",
"(",
"AbstractResourceBundle",
"$",
"bundle",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"bundle",
")",
")",
"{",
"$",
"bundle",
"=",
"$",
"this",
"->",
"bundle",
";",
"}",
"$",
"containerExtension",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"bundle",
"->",
"getContainerExtension",
"(",
")",
")",
";",
"$",
"applicationName",
"=",
"$",
"containerExtension",
"->",
"getProperty",
"(",
"'applicationName'",
")",
";",
"$",
"applicationName",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"extension",
"=",
"$",
"bundle",
"->",
"getContainerExtension",
"(",
")",
";",
"return",
"$",
"applicationName",
"->",
"getValue",
"(",
"new",
"$",
"extension",
"(",
")",
")",
";",
"}"
] | Return the prefix of the bundle.
@param AbstractResourceBundle $bundle
@return string | [
"Return",
"the",
"prefix",
"of",
"the",
"bundle",
"."
] | 3178268b9e58e6c60c27e0b9ea976944c1f61a48 | https://github.com/avoo/FrameworkGeneratorBundle/blob/3178268b9e58e6c60c27e0b9ea976944c1f61a48/Generator/Template/Template.php#L146-L158 |
8,032 | avoo/FrameworkGeneratorBundle | Generator/Template/Template.php | Template.getEntityMetadata | protected function getEntityMetadata($entity, $path = null)
{
$factory = new DisconnectedMetadataFactory($this->getContainer()->get('doctrine'));
return $factory->getClassMetadata($entity, $path)->getMetadata();
} | php | protected function getEntityMetadata($entity, $path = null)
{
$factory = new DisconnectedMetadataFactory($this->getContainer()->get('doctrine'));
return $factory->getClassMetadata($entity, $path)->getMetadata();
} | [
"protected",
"function",
"getEntityMetadata",
"(",
"$",
"entity",
",",
"$",
"path",
"=",
"null",
")",
"{",
"$",
"factory",
"=",
"new",
"DisconnectedMetadataFactory",
"(",
"$",
"this",
"->",
"getContainer",
"(",
")",
"->",
"get",
"(",
"'doctrine'",
")",
")",
";",
"return",
"$",
"factory",
"->",
"getClassMetadata",
"(",
"$",
"entity",
",",
"$",
"path",
")",
"->",
"getMetadata",
"(",
")",
";",
"}"
] | Get entity metadata
@param string $entity
@param string $path
@return array
@throws MappingException | [
"Get",
"entity",
"metadata"
] | 3178268b9e58e6c60c27e0b9ea976944c1f61a48 | https://github.com/avoo/FrameworkGeneratorBundle/blob/3178268b9e58e6c60c27e0b9ea976944c1f61a48/Generator/Template/Template.php#L235-L240 |
8,033 | avoo/FrameworkGeneratorBundle | Generator/Template/Template.php | Template.refExist | protected function refExist($path, $ref)
{
$content = file_get_contents($path);
if (false === strpos($content, $ref)) {
return false;
}
return true;
} | php | protected function refExist($path, $ref)
{
$content = file_get_contents($path);
if (false === strpos($content, $ref)) {
return false;
}
return true;
} | [
"protected",
"function",
"refExist",
"(",
"$",
"path",
",",
"$",
"ref",
")",
"{",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"path",
")",
";",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"content",
",",
"$",
"ref",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Check if the reference exist in path
@param string $path
@param string $ref
@return bool | [
"Check",
"if",
"the",
"reference",
"exist",
"in",
"path"
] | 3178268b9e58e6c60c27e0b9ea976944c1f61a48 | https://github.com/avoo/FrameworkGeneratorBundle/blob/3178268b9e58e6c60c27e0b9ea976944c1f61a48/Generator/Template/Template.php#L312-L321 |
8,034 | avoo/FrameworkGeneratorBundle | Generator/Template/Template.php | Template.getRoutePrefix | public function getRoutePrefix($entity)
{
$prefix = strtolower(str_replace(array('\\', '/'), '_', $entity));
if ($prefix && '/' === $prefix[0]) {
$prefix = substr($prefix, 1);
}
return str_replace('/', '_', $prefix);
} | php | public function getRoutePrefix($entity)
{
$prefix = strtolower(str_replace(array('\\', '/'), '_', $entity));
if ($prefix && '/' === $prefix[0]) {
$prefix = substr($prefix, 1);
}
return str_replace('/', '_', $prefix);
} | [
"public",
"function",
"getRoutePrefix",
"(",
"$",
"entity",
")",
"{",
"$",
"prefix",
"=",
"strtolower",
"(",
"str_replace",
"(",
"array",
"(",
"'\\\\'",
",",
"'/'",
")",
",",
"'_'",
",",
"$",
"entity",
")",
")",
";",
"if",
"(",
"$",
"prefix",
"&&",
"'/'",
"===",
"$",
"prefix",
"[",
"0",
"]",
")",
"{",
"$",
"prefix",
"=",
"substr",
"(",
"$",
"prefix",
",",
"1",
")",
";",
"}",
"return",
"str_replace",
"(",
"'/'",
",",
"'_'",
",",
"$",
"prefix",
")",
";",
"}"
] | Get routing prefix
@param string $entity
@return string | [
"Get",
"routing",
"prefix"
] | 3178268b9e58e6c60c27e0b9ea976944c1f61a48 | https://github.com/avoo/FrameworkGeneratorBundle/blob/3178268b9e58e6c60c27e0b9ea976944c1f61a48/Generator/Template/Template.php#L338-L347 |
8,035 | avoo/FrameworkGeneratorBundle | Generator/Template/Template.php | Template.writeOutput | protected function writeOutput($message)
{
if (is_null($this->output)) {
return false;
}
$this->output->writeln($message);
return $this;
} | php | protected function writeOutput($message)
{
if (is_null($this->output)) {
return false;
}
$this->output->writeln($message);
return $this;
} | [
"protected",
"function",
"writeOutput",
"(",
"$",
"message",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"output",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"->",
"output",
"->",
"writeln",
"(",
"$",
"message",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Write output message
@param array|string $message
@return $this|bool | [
"Write",
"output",
"message"
] | 3178268b9e58e6c60c27e0b9ea976944c1f61a48 | https://github.com/avoo/FrameworkGeneratorBundle/blob/3178268b9e58e6c60c27e0b9ea976944c1f61a48/Generator/Template/Template.php#L450-L459 |
8,036 | superbrave/coding-standards | Superbrave/Sniffs/Commenting/FunctionCommentSniff.php | FunctionCommentSniff.processReturnAboveThrows | protected function processReturnAboveThrows(File $phpcsFile, $stackPtr)
{
// Fetches the full function docblock
$startToken = null;
$endToken = null;
$docblock = $this->getDocBlock($phpcsFile, $stackPtr, $startToken, $endToken);
if ($this->hasInheritDoc($phpcsFile, $stackPtr, $docblock)) {
return;
}
// Fetches tag locations
$return_pos = strpos($docblock, '@return');
$throws_pos = strpos($docblock, '@throws');
// One of the elements doesn't exist
if ($throws_pos === false || $return_pos === false) {
return;
}
// Is the throws above return?
if ($return_pos > $throws_pos) {
$error = '@throws tags should be below the @return tag, not above the @return tag';
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'ReturnAboveThrows');
// When the patcher is active, fix the issue
if ($fix === true) {
// Breaks up the docblock in three parts; original docblock, return and throws
$parts = explode('* @', $docblock);
$general = $return = $throws = array();
foreach ($parts as $part) {
if (strtolower(substr($part, 0, 6)) == 'return') {
array_push($return, $part);
} else if (strtolower(substr($part, 0, 6)) == 'throws') {
array_push($throws, $part);
} else {
array_push($general, $part);
}
}
// Reglues the three parts in correct sequence
$newDocblock = implode('* @', array_merge(
$general,
$return,
$throws
));
// Patches the file
$phpcsFile->fixer->beginChangeset();
$phpcsFile->fixer->replaceToken($startToken, $newDocblock);
for ($token = $startToken + 1; $token < $endToken; ++$token) {
$phpcsFile->fixer->replaceToken($token, "");
}
$phpcsFile->fixer->endChangeset();
}
}
} | php | protected function processReturnAboveThrows(File $phpcsFile, $stackPtr)
{
// Fetches the full function docblock
$startToken = null;
$endToken = null;
$docblock = $this->getDocBlock($phpcsFile, $stackPtr, $startToken, $endToken);
if ($this->hasInheritDoc($phpcsFile, $stackPtr, $docblock)) {
return;
}
// Fetches tag locations
$return_pos = strpos($docblock, '@return');
$throws_pos = strpos($docblock, '@throws');
// One of the elements doesn't exist
if ($throws_pos === false || $return_pos === false) {
return;
}
// Is the throws above return?
if ($return_pos > $throws_pos) {
$error = '@throws tags should be below the @return tag, not above the @return tag';
$fix = $phpcsFile->addFixableError($error, $stackPtr, 'ReturnAboveThrows');
// When the patcher is active, fix the issue
if ($fix === true) {
// Breaks up the docblock in three parts; original docblock, return and throws
$parts = explode('* @', $docblock);
$general = $return = $throws = array();
foreach ($parts as $part) {
if (strtolower(substr($part, 0, 6)) == 'return') {
array_push($return, $part);
} else if (strtolower(substr($part, 0, 6)) == 'throws') {
array_push($throws, $part);
} else {
array_push($general, $part);
}
}
// Reglues the three parts in correct sequence
$newDocblock = implode('* @', array_merge(
$general,
$return,
$throws
));
// Patches the file
$phpcsFile->fixer->beginChangeset();
$phpcsFile->fixer->replaceToken($startToken, $newDocblock);
for ($token = $startToken + 1; $token < $endToken; ++$token) {
$phpcsFile->fixer->replaceToken($token, "");
}
$phpcsFile->fixer->endChangeset();
}
}
} | [
"protected",
"function",
"processReturnAboveThrows",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
")",
"{",
"// Fetches the full function docblock",
"$",
"startToken",
"=",
"null",
";",
"$",
"endToken",
"=",
"null",
";",
"$",
"docblock",
"=",
"$",
"this",
"->",
"getDocBlock",
"(",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
",",
"$",
"startToken",
",",
"$",
"endToken",
")",
";",
"if",
"(",
"$",
"this",
"->",
"hasInheritDoc",
"(",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
",",
"$",
"docblock",
")",
")",
"{",
"return",
";",
"}",
"// Fetches tag locations",
"$",
"return_pos",
"=",
"strpos",
"(",
"$",
"docblock",
",",
"'@return'",
")",
";",
"$",
"throws_pos",
"=",
"strpos",
"(",
"$",
"docblock",
",",
"'@throws'",
")",
";",
"// One of the elements doesn't exist",
"if",
"(",
"$",
"throws_pos",
"===",
"false",
"||",
"$",
"return_pos",
"===",
"false",
")",
"{",
"return",
";",
"}",
"// Is the throws above return?",
"if",
"(",
"$",
"return_pos",
">",
"$",
"throws_pos",
")",
"{",
"$",
"error",
"=",
"'@throws tags should be below the @return tag, not above the @return tag'",
";",
"$",
"fix",
"=",
"$",
"phpcsFile",
"->",
"addFixableError",
"(",
"$",
"error",
",",
"$",
"stackPtr",
",",
"'ReturnAboveThrows'",
")",
";",
"// When the patcher is active, fix the issue",
"if",
"(",
"$",
"fix",
"===",
"true",
")",
"{",
"// Breaks up the docblock in three parts; original docblock, return and throws",
"$",
"parts",
"=",
"explode",
"(",
"'* @'",
",",
"$",
"docblock",
")",
";",
"$",
"general",
"=",
"$",
"return",
"=",
"$",
"throws",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"parts",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"strtolower",
"(",
"substr",
"(",
"$",
"part",
",",
"0",
",",
"6",
")",
")",
"==",
"'return'",
")",
"{",
"array_push",
"(",
"$",
"return",
",",
"$",
"part",
")",
";",
"}",
"else",
"if",
"(",
"strtolower",
"(",
"substr",
"(",
"$",
"part",
",",
"0",
",",
"6",
")",
")",
"==",
"'throws'",
")",
"{",
"array_push",
"(",
"$",
"throws",
",",
"$",
"part",
")",
";",
"}",
"else",
"{",
"array_push",
"(",
"$",
"general",
",",
"$",
"part",
")",
";",
"}",
"}",
"// Reglues the three parts in correct sequence",
"$",
"newDocblock",
"=",
"implode",
"(",
"'* @'",
",",
"array_merge",
"(",
"$",
"general",
",",
"$",
"return",
",",
"$",
"throws",
")",
")",
";",
"// Patches the file",
"$",
"phpcsFile",
"->",
"fixer",
"->",
"beginChangeset",
"(",
")",
";",
"$",
"phpcsFile",
"->",
"fixer",
"->",
"replaceToken",
"(",
"$",
"startToken",
",",
"$",
"newDocblock",
")",
";",
"for",
"(",
"$",
"token",
"=",
"$",
"startToken",
"+",
"1",
";",
"$",
"token",
"<",
"$",
"endToken",
";",
"++",
"$",
"token",
")",
"{",
"$",
"phpcsFile",
"->",
"fixer",
"->",
"replaceToken",
"(",
"$",
"token",
",",
"\"\"",
")",
";",
"}",
"$",
"phpcsFile",
"->",
"fixer",
"->",
"endChangeset",
"(",
")",
";",
"}",
"}",
"}"
] | A throws call must be below the return call.
The Superbrave standards follows the "Symfony Way" in this sniff.
@param File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the stack passed in $tokens.
@return void | [
"A",
"throws",
"call",
"must",
"be",
"below",
"the",
"return",
"call",
"."
] | 8237e860a6acd738122a8af58e05df81475c6610 | https://github.com/superbrave/coding-standards/blob/8237e860a6acd738122a8af58e05df81475c6610/Superbrave/Sniffs/Commenting/FunctionCommentSniff.php#L49-L104 |
8,037 | superbrave/coding-standards | Superbrave/Sniffs/Commenting/FunctionCommentSniff.php | FunctionCommentSniff.getDocBlock | protected function getDocBlock(File $phpcsFile, $stackPtr, &$startToken = null, &$endToken = null)
{
// Fetches the full function docblock
$startToken = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, $stackPtr - 1);
if ($startToken === false) {
return '';
}
$endToken = $phpcsFile->findNext(T_DOC_COMMENT_CLOSE_TAG, $startToken);
if ($endToken === false) {
return '';
}
return $phpcsFile->getTokensAsString($startToken, ($endToken - $startToken));
} | php | protected function getDocBlock(File $phpcsFile, $stackPtr, &$startToken = null, &$endToken = null)
{
// Fetches the full function docblock
$startToken = $phpcsFile->findPrevious(T_DOC_COMMENT_OPEN_TAG, $stackPtr - 1);
if ($startToken === false) {
return '';
}
$endToken = $phpcsFile->findNext(T_DOC_COMMENT_CLOSE_TAG, $startToken);
if ($endToken === false) {
return '';
}
return $phpcsFile->getTokensAsString($startToken, ($endToken - $startToken));
} | [
"protected",
"function",
"getDocBlock",
"(",
"File",
"$",
"phpcsFile",
",",
"$",
"stackPtr",
",",
"&",
"$",
"startToken",
"=",
"null",
",",
"&",
"$",
"endToken",
"=",
"null",
")",
"{",
"// Fetches the full function docblock",
"$",
"startToken",
"=",
"$",
"phpcsFile",
"->",
"findPrevious",
"(",
"T_DOC_COMMENT_OPEN_TAG",
",",
"$",
"stackPtr",
"-",
"1",
")",
";",
"if",
"(",
"$",
"startToken",
"===",
"false",
")",
"{",
"return",
"''",
";",
"}",
"$",
"endToken",
"=",
"$",
"phpcsFile",
"->",
"findNext",
"(",
"T_DOC_COMMENT_CLOSE_TAG",
",",
"$",
"startToken",
")",
";",
"if",
"(",
"$",
"endToken",
"===",
"false",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"phpcsFile",
"->",
"getTokensAsString",
"(",
"$",
"startToken",
",",
"(",
"$",
"endToken",
"-",
"$",
"startToken",
")",
")",
";",
"}"
] | Fetches the docblock as string
@param File $phpcsFile The file being scanned.
@param int $stackPtr The position of the current token in the stack passed in $tokens.
@param int|bool $startToken By reference; the token where the docblock starts
@param int|bool $endToken By reference; the token where the docblock ends
@return string | [
"Fetches",
"the",
"docblock",
"as",
"string"
] | 8237e860a6acd738122a8af58e05df81475c6610 | https://github.com/superbrave/coding-standards/blob/8237e860a6acd738122a8af58e05df81475c6610/Superbrave/Sniffs/Commenting/FunctionCommentSniff.php#L171-L183 |
8,038 | Arbitracker/VCSWrapper | src/main/php/Arbit/VCSWrapper/Cache/Manager.php | Manager.forceCleanup | public static function forceCleanup()
{
if (self::$path === null) {
throw new \RuntimeException("Cache not initilized.");
}
self::$metaDataHandler->cleanup(self::$size, self::$cleanupRate);
} | php | public static function forceCleanup()
{
if (self::$path === null) {
throw new \RuntimeException("Cache not initilized.");
}
self::$metaDataHandler->cleanup(self::$size, self::$cleanupRate);
} | [
"public",
"static",
"function",
"forceCleanup",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"path",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Cache not initilized.\"",
")",
";",
"}",
"self",
"::",
"$",
"metaDataHandler",
"->",
"cleanup",
"(",
"self",
"::",
"$",
"size",
",",
"self",
"::",
"$",
"cleanupRate",
")",
";",
"}"
] | Force cache cleanup
Force a check, if the cache currently exceeds its given size limit. If
this is the case this method will start cleaning up the cache.
Depending on the used meta data storage and the size of the cache this
operation might take some time.
@return void | [
"Force",
"cache",
"cleanup"
] | 64907c0c438600ce67d79a5d17f5155563f2bbf2 | https://github.com/Arbitracker/VCSWrapper/blob/64907c0c438600ce67d79a5d17f5155563f2bbf2/src/main/php/Arbit/VCSWrapper/Cache/Manager.php#L227-L234 |
8,039 | jelix/composer-module-setup | lib/IniModifier.php | IniModifier.setValue | public function setValue($name, $value, $section = 0, $key = null)
{
$foundValue = false;
$lastKey = -1; // last key in an array value
if (isset($this->content[$section])) {
// boolean to erase array values if the new value is not a new item for the array
$deleteMode = false;
foreach ($this->content[$section] as $k => $item) {
if ($deleteMode) {
if ($item[0] == self::TK_ARR_VALUE && $item[1] == $name) {
$this->content[$section][$k] = array(self::TK_WS, '--');
}
continue;
}
// if the item is not a value or an array value, or not the same name
if (($item[0] != self::TK_VALUE && $item[0] != self::TK_ARR_VALUE)
|| $item[1] != $name) {
continue;
}
// if it is an array value, and if the key doesn't correspond
if ($item[0] == self::TK_ARR_VALUE && $key !== null) {
if ($item[3] != $key || $key === '') {
$lastKey = $item[3];
continue;
}
}
if ($key !== null) {
// we add the value as an array value
if ($key === '') {
$key = 0;
}
$this->content[$section][$k] = array(self::TK_ARR_VALUE, $name,$value, $key);
} else {
// we store the value
$this->content[$section][$k] = array(self::TK_VALUE, $name, $value);
if ($item[0] == self::TK_ARR_VALUE) {
// the previous value was an array value, so we erase other array values
$deleteMode = true;
$foundValue = true;
continue;
}
}
$foundValue = true;
break;
}
} else {
$this->content[$section] = array(array(self::TK_SECTION, '['.$section.']'));
}
if (!$foundValue) {
if ($key === null) {
$this->content[$section][] = array(self::TK_VALUE, $name, $value);
} else {
if ($lastKey != -1) {
++$lastKey;
} else {
$lastKey = 0;
}
$this->content[$section][] = array(self::TK_ARR_VALUE, $name, $value, $lastKey);
}
}
$this->modified = true;
} | php | public function setValue($name, $value, $section = 0, $key = null)
{
$foundValue = false;
$lastKey = -1; // last key in an array value
if (isset($this->content[$section])) {
// boolean to erase array values if the new value is not a new item for the array
$deleteMode = false;
foreach ($this->content[$section] as $k => $item) {
if ($deleteMode) {
if ($item[0] == self::TK_ARR_VALUE && $item[1] == $name) {
$this->content[$section][$k] = array(self::TK_WS, '--');
}
continue;
}
// if the item is not a value or an array value, or not the same name
if (($item[0] != self::TK_VALUE && $item[0] != self::TK_ARR_VALUE)
|| $item[1] != $name) {
continue;
}
// if it is an array value, and if the key doesn't correspond
if ($item[0] == self::TK_ARR_VALUE && $key !== null) {
if ($item[3] != $key || $key === '') {
$lastKey = $item[3];
continue;
}
}
if ($key !== null) {
// we add the value as an array value
if ($key === '') {
$key = 0;
}
$this->content[$section][$k] = array(self::TK_ARR_VALUE, $name,$value, $key);
} else {
// we store the value
$this->content[$section][$k] = array(self::TK_VALUE, $name, $value);
if ($item[0] == self::TK_ARR_VALUE) {
// the previous value was an array value, so we erase other array values
$deleteMode = true;
$foundValue = true;
continue;
}
}
$foundValue = true;
break;
}
} else {
$this->content[$section] = array(array(self::TK_SECTION, '['.$section.']'));
}
if (!$foundValue) {
if ($key === null) {
$this->content[$section][] = array(self::TK_VALUE, $name, $value);
} else {
if ($lastKey != -1) {
++$lastKey;
} else {
$lastKey = 0;
}
$this->content[$section][] = array(self::TK_ARR_VALUE, $name, $value, $lastKey);
}
}
$this->modified = true;
} | [
"public",
"function",
"setValue",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"section",
"=",
"0",
",",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"foundValue",
"=",
"false",
";",
"$",
"lastKey",
"=",
"-",
"1",
";",
"// last key in an array value",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"content",
"[",
"$",
"section",
"]",
")",
")",
"{",
"// boolean to erase array values if the new value is not a new item for the array",
"$",
"deleteMode",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"content",
"[",
"$",
"section",
"]",
"as",
"$",
"k",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"deleteMode",
")",
"{",
"if",
"(",
"$",
"item",
"[",
"0",
"]",
"==",
"self",
"::",
"TK_ARR_VALUE",
"&&",
"$",
"item",
"[",
"1",
"]",
"==",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"content",
"[",
"$",
"section",
"]",
"[",
"$",
"k",
"]",
"=",
"array",
"(",
"self",
"::",
"TK_WS",
",",
"'--'",
")",
";",
"}",
"continue",
";",
"}",
"// if the item is not a value or an array value, or not the same name",
"if",
"(",
"(",
"$",
"item",
"[",
"0",
"]",
"!=",
"self",
"::",
"TK_VALUE",
"&&",
"$",
"item",
"[",
"0",
"]",
"!=",
"self",
"::",
"TK_ARR_VALUE",
")",
"||",
"$",
"item",
"[",
"1",
"]",
"!=",
"$",
"name",
")",
"{",
"continue",
";",
"}",
"// if it is an array value, and if the key doesn't correspond",
"if",
"(",
"$",
"item",
"[",
"0",
"]",
"==",
"self",
"::",
"TK_ARR_VALUE",
"&&",
"$",
"key",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"item",
"[",
"3",
"]",
"!=",
"$",
"key",
"||",
"$",
"key",
"===",
"''",
")",
"{",
"$",
"lastKey",
"=",
"$",
"item",
"[",
"3",
"]",
";",
"continue",
";",
"}",
"}",
"if",
"(",
"$",
"key",
"!==",
"null",
")",
"{",
"// we add the value as an array value",
"if",
"(",
"$",
"key",
"===",
"''",
")",
"{",
"$",
"key",
"=",
"0",
";",
"}",
"$",
"this",
"->",
"content",
"[",
"$",
"section",
"]",
"[",
"$",
"k",
"]",
"=",
"array",
"(",
"self",
"::",
"TK_ARR_VALUE",
",",
"$",
"name",
",",
"$",
"value",
",",
"$",
"key",
")",
";",
"}",
"else",
"{",
"// we store the value",
"$",
"this",
"->",
"content",
"[",
"$",
"section",
"]",
"[",
"$",
"k",
"]",
"=",
"array",
"(",
"self",
"::",
"TK_VALUE",
",",
"$",
"name",
",",
"$",
"value",
")",
";",
"if",
"(",
"$",
"item",
"[",
"0",
"]",
"==",
"self",
"::",
"TK_ARR_VALUE",
")",
"{",
"// the previous value was an array value, so we erase other array values",
"$",
"deleteMode",
"=",
"true",
";",
"$",
"foundValue",
"=",
"true",
";",
"continue",
";",
"}",
"}",
"$",
"foundValue",
"=",
"true",
";",
"break",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"content",
"[",
"$",
"section",
"]",
"=",
"array",
"(",
"array",
"(",
"self",
"::",
"TK_SECTION",
",",
"'['",
".",
"$",
"section",
".",
"']'",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"foundValue",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"content",
"[",
"$",
"section",
"]",
"[",
"]",
"=",
"array",
"(",
"self",
"::",
"TK_VALUE",
",",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"lastKey",
"!=",
"-",
"1",
")",
"{",
"++",
"$",
"lastKey",
";",
"}",
"else",
"{",
"$",
"lastKey",
"=",
"0",
";",
"}",
"$",
"this",
"->",
"content",
"[",
"$",
"section",
"]",
"[",
"]",
"=",
"array",
"(",
"self",
"::",
"TK_ARR_VALUE",
",",
"$",
"name",
",",
"$",
"value",
",",
"$",
"lastKey",
")",
";",
"}",
"}",
"$",
"this",
"->",
"modified",
"=",
"true",
";",
"}"
] | modify an option in the ini file. If the option doesn't exist,
it is created.
@param string $name the name of the option to modify
@param string $value the new value
@param string $section the section where to set the item. 0 is the global section
@param int $key for option which is an item of array, the key in the array. '' to just add a value in the array | [
"modify",
"an",
"option",
"in",
"the",
"ini",
"file",
".",
"If",
"the",
"option",
"doesn",
"t",
"exist",
"it",
"is",
"created",
"."
] | 0ee2e05a162caa532ce63c7fd12d421144533c37 | https://github.com/jelix/composer-module-setup/blob/0ee2e05a162caa532ce63c7fd12d421144533c37/lib/IniModifier.php#L162-L226 |
8,040 | jelix/composer-module-setup | lib/IniModifier.php | IniModifier.setValues | public function setValues($values, $section = 0)
{
foreach ($values as $name => $val) {
if (is_array($val)) {
// let's ignore key values, we don't want them
$i = 0;
foreach ($val as $arval) {
$this->setValue($name, $arval, $section, $i++);
}
} else {
$this->setValue($name, $val, $section);
}
}
} | php | public function setValues($values, $section = 0)
{
foreach ($values as $name => $val) {
if (is_array($val)) {
// let's ignore key values, we don't want them
$i = 0;
foreach ($val as $arval) {
$this->setValue($name, $arval, $section, $i++);
}
} else {
$this->setValue($name, $val, $section);
}
}
} | [
"public",
"function",
"setValues",
"(",
"$",
"values",
",",
"$",
"section",
"=",
"0",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"name",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"// let's ignore key values, we don't want them",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"val",
"as",
"$",
"arval",
")",
"{",
"$",
"this",
"->",
"setValue",
"(",
"$",
"name",
",",
"$",
"arval",
",",
"$",
"section",
",",
"$",
"i",
"++",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"setValue",
"(",
"$",
"name",
",",
"$",
"val",
",",
"$",
"section",
")",
";",
"}",
"}",
"}"
] | modify several options in the ini file.
@param array $value associated array with key=>value
@param string $section the section where to set the item. 0 is the global section | [
"modify",
"several",
"options",
"in",
"the",
"ini",
"file",
"."
] | 0ee2e05a162caa532ce63c7fd12d421144533c37 | https://github.com/jelix/composer-module-setup/blob/0ee2e05a162caa532ce63c7fd12d421144533c37/lib/IniModifier.php#L234-L247 |
8,041 | jelix/composer-module-setup | lib/IniModifier.php | IniModifier.getValue | public function getValue($name, $section = 0, $key = null)
{
if (!isset($this->content[$section])) {
return;
}
$arrayValue = array();
$isArray = false;
foreach ($this->content[$section] as $k => $item) {
if (($item[0] != self::TK_VALUE && $item[0] != self::TK_ARR_VALUE)
|| $item[1] != $name) {
continue;
}
if ($item[0] == self::TK_ARR_VALUE) {
if ($key !== null) {
if ($item[3] != $key) {
continue;
}
} else {
$isArray = true;
$arrayValue[] = $item[2];
continue;
}
}
if (preg_match('/^-?[0-9]$/', $item[2])) {
return intval($item[2]);
} elseif (preg_match('/^-?[0-9\.]$/', $item[2])) {
return floatval($item[2]);
} elseif (strtolower($item[2]) === 'true' || strtolower($item[2]) === 'on') {
return true;
} elseif (strtolower($item[2]) === 'false' || strtolower($item[2]) === 'off') {
return false;
}
return $item[2];
}
if ($isArray) {
return $arrayValue;
}
return;
} | php | public function getValue($name, $section = 0, $key = null)
{
if (!isset($this->content[$section])) {
return;
}
$arrayValue = array();
$isArray = false;
foreach ($this->content[$section] as $k => $item) {
if (($item[0] != self::TK_VALUE && $item[0] != self::TK_ARR_VALUE)
|| $item[1] != $name) {
continue;
}
if ($item[0] == self::TK_ARR_VALUE) {
if ($key !== null) {
if ($item[3] != $key) {
continue;
}
} else {
$isArray = true;
$arrayValue[] = $item[2];
continue;
}
}
if (preg_match('/^-?[0-9]$/', $item[2])) {
return intval($item[2]);
} elseif (preg_match('/^-?[0-9\.]$/', $item[2])) {
return floatval($item[2]);
} elseif (strtolower($item[2]) === 'true' || strtolower($item[2]) === 'on') {
return true;
} elseif (strtolower($item[2]) === 'false' || strtolower($item[2]) === 'off') {
return false;
}
return $item[2];
}
if ($isArray) {
return $arrayValue;
}
return;
} | [
"public",
"function",
"getValue",
"(",
"$",
"name",
",",
"$",
"section",
"=",
"0",
",",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"content",
"[",
"$",
"section",
"]",
")",
")",
"{",
"return",
";",
"}",
"$",
"arrayValue",
"=",
"array",
"(",
")",
";",
"$",
"isArray",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"content",
"[",
"$",
"section",
"]",
"as",
"$",
"k",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"(",
"$",
"item",
"[",
"0",
"]",
"!=",
"self",
"::",
"TK_VALUE",
"&&",
"$",
"item",
"[",
"0",
"]",
"!=",
"self",
"::",
"TK_ARR_VALUE",
")",
"||",
"$",
"item",
"[",
"1",
"]",
"!=",
"$",
"name",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"item",
"[",
"0",
"]",
"==",
"self",
"::",
"TK_ARR_VALUE",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"null",
")",
"{",
"if",
"(",
"$",
"item",
"[",
"3",
"]",
"!=",
"$",
"key",
")",
"{",
"continue",
";",
"}",
"}",
"else",
"{",
"$",
"isArray",
"=",
"true",
";",
"$",
"arrayValue",
"[",
"]",
"=",
"$",
"item",
"[",
"2",
"]",
";",
"continue",
";",
"}",
"}",
"if",
"(",
"preg_match",
"(",
"'/^-?[0-9]$/'",
",",
"$",
"item",
"[",
"2",
"]",
")",
")",
"{",
"return",
"intval",
"(",
"$",
"item",
"[",
"2",
"]",
")",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^-?[0-9\\.]$/'",
",",
"$",
"item",
"[",
"2",
"]",
")",
")",
"{",
"return",
"floatval",
"(",
"$",
"item",
"[",
"2",
"]",
")",
";",
"}",
"elseif",
"(",
"strtolower",
"(",
"$",
"item",
"[",
"2",
"]",
")",
"===",
"'true'",
"||",
"strtolower",
"(",
"$",
"item",
"[",
"2",
"]",
")",
"===",
"'on'",
")",
"{",
"return",
"true",
";",
"}",
"elseif",
"(",
"strtolower",
"(",
"$",
"item",
"[",
"2",
"]",
")",
"===",
"'false'",
"||",
"strtolower",
"(",
"$",
"item",
"[",
"2",
"]",
")",
"===",
"'off'",
")",
"{",
"return",
"false",
";",
"}",
"return",
"$",
"item",
"[",
"2",
"]",
";",
"}",
"if",
"(",
"$",
"isArray",
")",
"{",
"return",
"$",
"arrayValue",
";",
"}",
"return",
";",
"}"
] | return the value of an option in the ini file. If the option doesn't exist,
it returns null.
@param string $name the name of the option to retrieve
@param string $section the section where the option is. 0 is the global section
@param int $key for option which is an item of array, the key in the array
@return mixed the value | [
"return",
"the",
"value",
"of",
"an",
"option",
"in",
"the",
"ini",
"file",
".",
"If",
"the",
"option",
"doesn",
"t",
"exist",
"it",
"returns",
"null",
"."
] | 0ee2e05a162caa532ce63c7fd12d421144533c37 | https://github.com/jelix/composer-module-setup/blob/0ee2e05a162caa532ce63c7fd12d421144533c37/lib/IniModifier.php#L389-L430 |
8,042 | jelix/composer-module-setup | lib/IniModifier.php | IniModifier.getValues | public function getValues($section = 0)
{
if (!isset($this->content[$section])) {
return array();
}
$values = array();
foreach ($this->content[$section] as $k => $item) {
if ($item[0] != self::TK_VALUE && $item[0] != self::TK_ARR_VALUE) {
continue;
}
if (preg_match('/^-?[0-9]$/', $item[2])) {
$val = intval($item[2]);
} elseif (preg_match('/^-?[0-9\.]$/', $item[2])) {
$val = floatval($item[2]);
} elseif (strtolower($item[2]) === 'true' || strtolower($item[2]) === 'on') {
$val = true;
} elseif (strtolower($item[2]) === 'false' || strtolower($item[2]) === 'off') {
$val = false;
} else {
$val = $item[2];
}
if ($item[0] == self::TK_VALUE) {
$values[$item[1]] = $val;
} else {
$values[$item[1]][$item[3]] = $val;
}
}
return $values;
} | php | public function getValues($section = 0)
{
if (!isset($this->content[$section])) {
return array();
}
$values = array();
foreach ($this->content[$section] as $k => $item) {
if ($item[0] != self::TK_VALUE && $item[0] != self::TK_ARR_VALUE) {
continue;
}
if (preg_match('/^-?[0-9]$/', $item[2])) {
$val = intval($item[2]);
} elseif (preg_match('/^-?[0-9\.]$/', $item[2])) {
$val = floatval($item[2]);
} elseif (strtolower($item[2]) === 'true' || strtolower($item[2]) === 'on') {
$val = true;
} elseif (strtolower($item[2]) === 'false' || strtolower($item[2]) === 'off') {
$val = false;
} else {
$val = $item[2];
}
if ($item[0] == self::TK_VALUE) {
$values[$item[1]] = $val;
} else {
$values[$item[1]][$item[3]] = $val;
}
}
return $values;
} | [
"public",
"function",
"getValues",
"(",
"$",
"section",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"content",
"[",
"$",
"section",
"]",
")",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"$",
"values",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"content",
"[",
"$",
"section",
"]",
"as",
"$",
"k",
"=>",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"[",
"0",
"]",
"!=",
"self",
"::",
"TK_VALUE",
"&&",
"$",
"item",
"[",
"0",
"]",
"!=",
"self",
"::",
"TK_ARR_VALUE",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/^-?[0-9]$/'",
",",
"$",
"item",
"[",
"2",
"]",
")",
")",
"{",
"$",
"val",
"=",
"intval",
"(",
"$",
"item",
"[",
"2",
"]",
")",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/^-?[0-9\\.]$/'",
",",
"$",
"item",
"[",
"2",
"]",
")",
")",
"{",
"$",
"val",
"=",
"floatval",
"(",
"$",
"item",
"[",
"2",
"]",
")",
";",
"}",
"elseif",
"(",
"strtolower",
"(",
"$",
"item",
"[",
"2",
"]",
")",
"===",
"'true'",
"||",
"strtolower",
"(",
"$",
"item",
"[",
"2",
"]",
")",
"===",
"'on'",
")",
"{",
"$",
"val",
"=",
"true",
";",
"}",
"elseif",
"(",
"strtolower",
"(",
"$",
"item",
"[",
"2",
"]",
")",
"===",
"'false'",
"||",
"strtolower",
"(",
"$",
"item",
"[",
"2",
"]",
")",
"===",
"'off'",
")",
"{",
"$",
"val",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"val",
"=",
"$",
"item",
"[",
"2",
"]",
";",
"}",
"if",
"(",
"$",
"item",
"[",
"0",
"]",
"==",
"self",
"::",
"TK_VALUE",
")",
"{",
"$",
"values",
"[",
"$",
"item",
"[",
"1",
"]",
"]",
"=",
"$",
"val",
";",
"}",
"else",
"{",
"$",
"values",
"[",
"$",
"item",
"[",
"1",
"]",
"]",
"[",
"$",
"item",
"[",
"3",
"]",
"]",
"=",
"$",
"val",
";",
"}",
"}",
"return",
"$",
"values",
";",
"}"
] | return all values of a section in the ini file.
@param string $section the section from wich we want values. 0 is the global section
@return array the list of values, $key=>$value | [
"return",
"all",
"values",
"of",
"a",
"section",
"in",
"the",
"ini",
"file",
"."
] | 0ee2e05a162caa532ce63c7fd12d421144533c37 | https://github.com/jelix/composer-module-setup/blob/0ee2e05a162caa532ce63c7fd12d421144533c37/lib/IniModifier.php#L439-L470 |
8,043 | jelix/composer-module-setup | lib/IniModifier.php | IniModifier.save | public function save($chmod = null)
{
if ($this->modified) {
if (false === @file_put_contents($this->filename, $this->generateIni())) {
throw new \Exception('Impossible to write into '.$this->filename);
} elseif ($chmod) {
chmod($this->filename, $chmod);
}
$this->modified = false;
}
} | php | public function save($chmod = null)
{
if ($this->modified) {
if (false === @file_put_contents($this->filename, $this->generateIni())) {
throw new \Exception('Impossible to write into '.$this->filename);
} elseif ($chmod) {
chmod($this->filename, $chmod);
}
$this->modified = false;
}
} | [
"public",
"function",
"save",
"(",
"$",
"chmod",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"modified",
")",
"{",
"if",
"(",
"false",
"===",
"@",
"file_put_contents",
"(",
"$",
"this",
"->",
"filename",
",",
"$",
"this",
"->",
"generateIni",
"(",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'Impossible to write into '",
".",
"$",
"this",
"->",
"filename",
")",
";",
"}",
"elseif",
"(",
"$",
"chmod",
")",
"{",
"chmod",
"(",
"$",
"this",
"->",
"filename",
",",
"$",
"chmod",
")",
";",
"}",
"$",
"this",
"->",
"modified",
"=",
"false",
";",
"}",
"}"
] | save the ini file. | [
"save",
"the",
"ini",
"file",
"."
] | 0ee2e05a162caa532ce63c7fd12d421144533c37 | https://github.com/jelix/composer-module-setup/blob/0ee2e05a162caa532ce63c7fd12d421144533c37/lib/IniModifier.php#L475-L485 |
8,044 | laravel-commode/common | src/LaravelCommode/Common/Controllers/CommodeController.php | CommodeController.checkParametersResolving | private function checkParametersResolving($method, array $params = [])
{
if (!$this->resolveMethods) {
return $params;
}
return app()->make(ServiceShortCuts::RESOLVER_SERVICE)->resolveMethodParameters($this, $method, $params);
} | php | private function checkParametersResolving($method, array $params = [])
{
if (!$this->resolveMethods) {
return $params;
}
return app()->make(ServiceShortCuts::RESOLVER_SERVICE)->resolveMethodParameters($this, $method, $params);
} | [
"private",
"function",
"checkParametersResolving",
"(",
"$",
"method",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"resolveMethods",
")",
"{",
"return",
"$",
"params",
";",
"}",
"return",
"app",
"(",
")",
"->",
"make",
"(",
"ServiceShortCuts",
"::",
"RESOLVER_SERVICE",
")",
"->",
"resolveMethodParameters",
"(",
"$",
"this",
",",
"$",
"method",
",",
"$",
"params",
")",
";",
"}"
] | Determines resolving is enabled. If it's enabled then
it returns method resolved parameters, otherwise it
returns parameters as they are.
@param string $method Method name.
@param array $params Array of known parameters.
@return mixed | [
"Determines",
"resolving",
"is",
"enabled",
".",
"If",
"it",
"s",
"enabled",
"then",
"it",
"returns",
"method",
"resolved",
"parameters",
"otherwise",
"it",
"returns",
"parameters",
"as",
"they",
"are",
"."
] | 5c9289c3ce5bbd934281c4ac7537657d32c5a9ec | https://github.com/laravel-commode/common/blob/5c9289c3ce5bbd934281c4ac7537657d32c5a9ec/src/LaravelCommode/Common/Controllers/CommodeController.php#L41-L48 |
8,045 | laravel-commode/common | src/LaravelCommode/Common/Controllers/CommodeController.php | CommodeController.callAction | public function callAction($method, array $parameters = [])
{
$isAjax = app()->make('request')->ajax();
$method = $this->checkAjaxMethod($method, $isAjax);
$parameters = $this->checkParametersResolving($method, $parameters);
return parent::callAction($method, $parameters);
} | php | public function callAction($method, array $parameters = [])
{
$isAjax = app()->make('request')->ajax();
$method = $this->checkAjaxMethod($method, $isAjax);
$parameters = $this->checkParametersResolving($method, $parameters);
return parent::callAction($method, $parameters);
} | [
"public",
"function",
"callAction",
"(",
"$",
"method",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"isAjax",
"=",
"app",
"(",
")",
"->",
"make",
"(",
"'request'",
")",
"->",
"ajax",
"(",
")",
";",
"$",
"method",
"=",
"$",
"this",
"->",
"checkAjaxMethod",
"(",
"$",
"method",
",",
"$",
"isAjax",
")",
";",
"$",
"parameters",
"=",
"$",
"this",
"->",
"checkParametersResolving",
"(",
"$",
"method",
",",
"$",
"parameters",
")",
";",
"return",
"parent",
"::",
"callAction",
"(",
"$",
"method",
",",
"$",
"parameters",
")",
";",
"}"
] | Calls controller action.
@param string $method
@param array $parameters
@return mixed | [
"Calls",
"controller",
"action",
"."
] | 5c9289c3ce5bbd934281c4ac7537657d32c5a9ec | https://github.com/laravel-commode/common/blob/5c9289c3ce5bbd934281c4ac7537657d32c5a9ec/src/LaravelCommode/Common/Controllers/CommodeController.php#L75-L83 |
8,046 | webbuilders-group/silverstripe-kapost-bridge | code/model/KapostConversionHistory.php | KapostConversionHistory.getDestinationLink | public function getDestinationLink() {
$destinationType=$this->DestinationType;
if(!empty($destinationType) && class_exists($destinationType) && is_subclass_of($destinationType, 'DataObject')) {
$dest=$destinationType::get()->byID($this->DestinationID);
if(!empty($dest) && $dest!==false && $dest->exists()) {
if($dest->hasMethod('CMSEditLink')) {
return $dest->CMSEditLink();
}else if($dest->hasMethod('getDestinationLink')) {
return $dest->getDestinationLink();
}else {
user_error('You must implement the getDestinationLink() method on a decendent of KapostConversionHistory "'.$this->class.'" or implement the method CMSEditLink on "'.$this->DestinationType.'"', E_USER_WARNING);
}
}else {
return;
}
}
} | php | public function getDestinationLink() {
$destinationType=$this->DestinationType;
if(!empty($destinationType) && class_exists($destinationType) && is_subclass_of($destinationType, 'DataObject')) {
$dest=$destinationType::get()->byID($this->DestinationID);
if(!empty($dest) && $dest!==false && $dest->exists()) {
if($dest->hasMethod('CMSEditLink')) {
return $dest->CMSEditLink();
}else if($dest->hasMethod('getDestinationLink')) {
return $dest->getDestinationLink();
}else {
user_error('You must implement the getDestinationLink() method on a decendent of KapostConversionHistory "'.$this->class.'" or implement the method CMSEditLink on "'.$this->DestinationType.'"', E_USER_WARNING);
}
}else {
return;
}
}
} | [
"public",
"function",
"getDestinationLink",
"(",
")",
"{",
"$",
"destinationType",
"=",
"$",
"this",
"->",
"DestinationType",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"destinationType",
")",
"&&",
"class_exists",
"(",
"$",
"destinationType",
")",
"&&",
"is_subclass_of",
"(",
"$",
"destinationType",
",",
"'DataObject'",
")",
")",
"{",
"$",
"dest",
"=",
"$",
"destinationType",
"::",
"get",
"(",
")",
"->",
"byID",
"(",
"$",
"this",
"->",
"DestinationID",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"dest",
")",
"&&",
"$",
"dest",
"!==",
"false",
"&&",
"$",
"dest",
"->",
"exists",
"(",
")",
")",
"{",
"if",
"(",
"$",
"dest",
"->",
"hasMethod",
"(",
"'CMSEditLink'",
")",
")",
"{",
"return",
"$",
"dest",
"->",
"CMSEditLink",
"(",
")",
";",
"}",
"else",
"if",
"(",
"$",
"dest",
"->",
"hasMethod",
"(",
"'getDestinationLink'",
")",
")",
"{",
"return",
"$",
"dest",
"->",
"getDestinationLink",
"(",
")",
";",
"}",
"else",
"{",
"user_error",
"(",
"'You must implement the getDestinationLink() method on a decendent of KapostConversionHistory \"'",
".",
"$",
"this",
"->",
"class",
".",
"'\" or implement the method CMSEditLink on \"'",
".",
"$",
"this",
"->",
"DestinationType",
".",
"'\"'",
",",
"E_USER_WARNING",
")",
";",
"}",
"}",
"else",
"{",
"return",
";",
"}",
"}",
"}"
] | Gets the link to the desination in the cms
@return string Relative link to the destination page | [
"Gets",
"the",
"link",
"to",
"the",
"desination",
"in",
"the",
"cms"
] | 718f498cad0eec764d19c9081404b2a0c8f44d71 | https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/model/KapostConversionHistory.php#L134-L150 |
8,047 | webbuilders-group/silverstripe-kapost-bridge | code/model/KapostConversionHistory.php | KapostConversionHistory.getDestinationTypeNice | public function getDestinationTypeNice() {
$className=$this->DestinationType;
if(class_exists($className)) {
$sng=singleton($className);
if(method_exists($sng, 'i18n_singular_name')) {
return $sng->i18n_singular_name();
}else if(method_exists($sng, 'singular_name')) {
return $sng->singular_name();
}
}
return $className;
} | php | public function getDestinationTypeNice() {
$className=$this->DestinationType;
if(class_exists($className)) {
$sng=singleton($className);
if(method_exists($sng, 'i18n_singular_name')) {
return $sng->i18n_singular_name();
}else if(method_exists($sng, 'singular_name')) {
return $sng->singular_name();
}
}
return $className;
} | [
"public",
"function",
"getDestinationTypeNice",
"(",
")",
"{",
"$",
"className",
"=",
"$",
"this",
"->",
"DestinationType",
";",
"if",
"(",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"$",
"sng",
"=",
"singleton",
"(",
"$",
"className",
")",
";",
"if",
"(",
"method_exists",
"(",
"$",
"sng",
",",
"'i18n_singular_name'",
")",
")",
"{",
"return",
"$",
"sng",
"->",
"i18n_singular_name",
"(",
")",
";",
"}",
"else",
"if",
"(",
"method_exists",
"(",
"$",
"sng",
",",
"'singular_name'",
")",
")",
"{",
"return",
"$",
"sng",
"->",
"singular_name",
"(",
")",
";",
"}",
"}",
"return",
"$",
"className",
";",
"}"
] | Gets the singular name of the destination type or just returs what was stored for the destination type if the class does not have one of i18n_singular_name or singular_name or the class does not exist
@return string | [
"Gets",
"the",
"singular",
"name",
"of",
"the",
"destination",
"type",
"or",
"just",
"returs",
"what",
"was",
"stored",
"for",
"the",
"destination",
"type",
"if",
"the",
"class",
"does",
"not",
"have",
"one",
"of",
"i18n_singular_name",
"or",
"singular_name",
"or",
"the",
"class",
"does",
"not",
"exist"
] | 718f498cad0eec764d19c9081404b2a0c8f44d71 | https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/model/KapostConversionHistory.php#L169-L181 |
8,048 | webbuilders-group/silverstripe-kapost-bridge | code/model/KapostConversionHistory.php | KapostConversionHistory.CMSEditLink | public function CMSEditLink() {
return Controller::join_links(LeftAndMain::config()->url_base, KapostAdmin::config()->url_segment, 'KapostConversionHistory/EditForm/field/KapostConversionHistory/item', $this->ID, 'edit');
} | php | public function CMSEditLink() {
return Controller::join_links(LeftAndMain::config()->url_base, KapostAdmin::config()->url_segment, 'KapostConversionHistory/EditForm/field/KapostConversionHistory/item', $this->ID, 'edit');
} | [
"public",
"function",
"CMSEditLink",
"(",
")",
"{",
"return",
"Controller",
"::",
"join_links",
"(",
"LeftAndMain",
"::",
"config",
"(",
")",
"->",
"url_base",
",",
"KapostAdmin",
"::",
"config",
"(",
")",
"->",
"url_segment",
",",
"'KapostConversionHistory/EditForm/field/KapostConversionHistory/item'",
",",
"$",
"this",
"->",
"ID",
",",
"'edit'",
")",
";",
"}"
] | Gets the edit link for this conversion history record
@return string | [
"Gets",
"the",
"edit",
"link",
"for",
"this",
"conversion",
"history",
"record"
] | 718f498cad0eec764d19c9081404b2a0c8f44d71 | https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/model/KapostConversionHistory.php#L201-L203 |
8,049 | webbuilders-group/silverstripe-kapost-bridge | code/model/KapostConversionHistory.php | KapostConversionHistory.onAfterWrite | protected function onAfterWrite() {
parent::onAfterWrite();
$records=KapostConversionHistory::get()->filter('Created:LessThan', date('Y-m-d H:i:s', strtotime('-'.self::config()->expires_days.' days')));
if($records->count()>0) {
foreach($records as $record) {
$record->delete();
}
}
} | php | protected function onAfterWrite() {
parent::onAfterWrite();
$records=KapostConversionHistory::get()->filter('Created:LessThan', date('Y-m-d H:i:s', strtotime('-'.self::config()->expires_days.' days')));
if($records->count()>0) {
foreach($records as $record) {
$record->delete();
}
}
} | [
"protected",
"function",
"onAfterWrite",
"(",
")",
"{",
"parent",
"::",
"onAfterWrite",
"(",
")",
";",
"$",
"records",
"=",
"KapostConversionHistory",
"::",
"get",
"(",
")",
"->",
"filter",
"(",
"'Created:LessThan'",
",",
"date",
"(",
"'Y-m-d H:i:s'",
",",
"strtotime",
"(",
"'-'",
".",
"self",
"::",
"config",
"(",
")",
"->",
"expires_days",
".",
"' days'",
")",
")",
")",
";",
"if",
"(",
"$",
"records",
"->",
"count",
"(",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"records",
"as",
"$",
"record",
")",
"{",
"$",
"record",
"->",
"delete",
"(",
")",
";",
"}",
"}",
"}"
] | Cleans up the conversion history records after X days, after writing to the database where X is defined in the config | [
"Cleans",
"up",
"the",
"conversion",
"history",
"records",
"after",
"X",
"days",
"after",
"writing",
"to",
"the",
"database",
"where",
"X",
"is",
"defined",
"in",
"the",
"config"
] | 718f498cad0eec764d19c9081404b2a0c8f44d71 | https://github.com/webbuilders-group/silverstripe-kapost-bridge/blob/718f498cad0eec764d19c9081404b2a0c8f44d71/code/model/KapostConversionHistory.php#L208-L217 |
8,050 | ItinerisLtd/preflight-command | src/ConfigPaths.php | ConfigPaths.mergeAbsPath | public static function mergeAbsPath(array $paths): array
{
if (defined('ABSPATH')) {
$dir = constant('ABSPATH');
$path = trailingslashit($dir) . 'preflight.toml';
$paths[] = normalize_path($path);
}
return $paths;
} | php | public static function mergeAbsPath(array $paths): array
{
if (defined('ABSPATH')) {
$dir = constant('ABSPATH');
$path = trailingslashit($dir) . 'preflight.toml';
$paths[] = normalize_path($path);
}
return $paths;
} | [
"public",
"static",
"function",
"mergeAbsPath",
"(",
"array",
"$",
"paths",
")",
":",
"array",
"{",
"if",
"(",
"defined",
"(",
"'ABSPATH'",
")",
")",
"{",
"$",
"dir",
"=",
"constant",
"(",
"'ABSPATH'",
")",
";",
"$",
"path",
"=",
"trailingslashit",
"(",
"$",
"dir",
")",
".",
"'preflight.toml'",
";",
"$",
"paths",
"[",
"]",
"=",
"normalize_path",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"paths",
";",
"}"
] | Register preflight.toml under ABSPATH.
Used in self::HOOK.
@param array $paths The .toml config file paths.
@return string[] | [
"Register",
"preflight",
".",
"toml",
"under",
"ABSPATH",
"."
] | d1c1360ea8d7de0312b5c0c09c9c486949594049 | https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/ConfigPaths.php#L58-L68 |
8,051 | ItinerisLtd/preflight-command | src/ConfigPaths.php | ConfigPaths.mergePreflightDir | public static function mergePreflightDir(array $paths): array
{
if (defined('PREFLIGHT_DIR')) {
$dir = constant('PREFLIGHT_DIR');
$path = trailingslashit($dir) . 'preflight.toml';
$paths[] = normalize_path($path);
}
return $paths;
} | php | public static function mergePreflightDir(array $paths): array
{
if (defined('PREFLIGHT_DIR')) {
$dir = constant('PREFLIGHT_DIR');
$path = trailingslashit($dir) . 'preflight.toml';
$paths[] = normalize_path($path);
}
return $paths;
} | [
"public",
"static",
"function",
"mergePreflightDir",
"(",
"array",
"$",
"paths",
")",
":",
"array",
"{",
"if",
"(",
"defined",
"(",
"'PREFLIGHT_DIR'",
")",
")",
"{",
"$",
"dir",
"=",
"constant",
"(",
"'PREFLIGHT_DIR'",
")",
";",
"$",
"path",
"=",
"trailingslashit",
"(",
"$",
"dir",
")",
".",
"'preflight.toml'",
";",
"$",
"paths",
"[",
"]",
"=",
"normalize_path",
"(",
"$",
"path",
")",
";",
"}",
"return",
"$",
"paths",
";",
"}"
] | Register preflight.toml under PREFLIGHT_DIR.
Used in self::HOOK.
@param array $paths The .toml config file paths.
@return string[] | [
"Register",
"preflight",
".",
"toml",
"under",
"PREFLIGHT_DIR",
"."
] | d1c1360ea8d7de0312b5c0c09c9c486949594049 | https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/ConfigPaths.php#L79-L89 |
8,052 | cityware/city-snmp | src/MIBS/Routes.php | Routes.routeProto | public function routeProto($translate = false) {
$s = $this->getSNMP()->subOidWalkLong(self::OID_ROUTE_ENTRY_PROTO, 12, 24);
if (!$translate)
return $s;
return $this->getSNMP()->translate($s, self::$ROUTE_ENTRY_PROTOS);
} | php | public function routeProto($translate = false) {
$s = $this->getSNMP()->subOidWalkLong(self::OID_ROUTE_ENTRY_PROTO, 12, 24);
if (!$translate)
return $s;
return $this->getSNMP()->translate($s, self::$ROUTE_ENTRY_PROTOS);
} | [
"public",
"function",
"routeProto",
"(",
"$",
"translate",
"=",
"false",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"subOidWalkLong",
"(",
"self",
"::",
"OID_ROUTE_ENTRY_PROTO",
",",
"12",
",",
"24",
")",
";",
"if",
"(",
"!",
"$",
"translate",
")",
"return",
"$",
"s",
";",
"return",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"translate",
"(",
"$",
"s",
",",
"self",
"::",
"$",
"ROUTE_ENTRY_PROTOS",
")",
";",
"}"
] | Returns the route protocol.
> "The routing mechanism via which this route was learned. Inclusion
> of values for gateway rout-ing protocols is not intended to imply
> that hosts should support those protocols."
@param bool $translate If true, use the `$ROUTE_ENTRY_PROTOS` array to return textual representation
@return array The route protocols (see `self::$ROUTE_ENTRY_PROTOS`) | [
"Returns",
"the",
"route",
"protocol",
"."
] | 831b7485b6c932a84f081d5ceeb9c5f4e7a8641d | https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/Routes.php#L282-L289 |
8,053 | cityware/city-snmp | src/MIBS/Routes.php | Routes.routeStatus | public function routeStatus($translate = false) {
$s = $this->getSNMP()->subOidWalkLong(self::OID_ROUTE_ENTRY_STATUS, 12, 24);
if (!$translate)
return $s;
return $this->getSNMP()->translate($s, self::$ROUTE_STATUS_TYPES);
} | php | public function routeStatus($translate = false) {
$s = $this->getSNMP()->subOidWalkLong(self::OID_ROUTE_ENTRY_STATUS, 12, 24);
if (!$translate)
return $s;
return $this->getSNMP()->translate($s, self::$ROUTE_STATUS_TYPES);
} | [
"public",
"function",
"routeStatus",
"(",
"$",
"translate",
"=",
"false",
")",
"{",
"$",
"s",
"=",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"subOidWalkLong",
"(",
"self",
"::",
"OID_ROUTE_ENTRY_STATUS",
",",
"12",
",",
"24",
")",
";",
"if",
"(",
"!",
"$",
"translate",
")",
"return",
"$",
"s",
";",
"return",
"$",
"this",
"->",
"getSNMP",
"(",
")",
"->",
"translate",
"(",
"$",
"s",
",",
"self",
"::",
"$",
"ROUTE_STATUS_TYPES",
")",
";",
"}"
] | Returns the route status
> "The row status variable, used according to row installation and
> removal conventions."
@return array The routes installation and removal status | [
"Returns",
"the",
"route",
"status"
] | 831b7485b6c932a84f081d5ceeb9c5f4e7a8641d | https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/Routes.php#L434-L441 |
8,054 | cityware/city-snmp | src/MIBS/Routes.php | Routes.routeDetails | public function routeDetails($translate = false) {
$fetchList = [
'routeDest' => 'destination',
'routeMask' => 'mask',
'routeTos' => 'TOS',
'routeNextHop' => 'nextHop',
'routeIfIndex' => 'ifIndex',
'routeType' => 'type',
'routeProto' => 'protocol',
'routeAge' => 'age',
'routeInfo' => 'info',
'routeNextHopAS' => 'nextHopAS',
'routeMetric1' => 'metric1',
'routeMetric2' => 'metric2',
'routeMetric3' => 'metric3',
'routeMetric4' => 'metric4',
'routeMetric5' => 'metric5',
'routeStatus' => 'status'
];
$canTranslate = [ 'routeType', 'routeProto', 'routeStatus'];
$details = [];
foreach ($fetchList as $fn => $idx) {
if (in_array($fn, $canTranslate))
$values = $this->$fn($translate);
else
$values = $this->$fn();
foreach ($values as $ip => $value)
$details[$ip][$idx] = $value;
}
return $details;
} | php | public function routeDetails($translate = false) {
$fetchList = [
'routeDest' => 'destination',
'routeMask' => 'mask',
'routeTos' => 'TOS',
'routeNextHop' => 'nextHop',
'routeIfIndex' => 'ifIndex',
'routeType' => 'type',
'routeProto' => 'protocol',
'routeAge' => 'age',
'routeInfo' => 'info',
'routeNextHopAS' => 'nextHopAS',
'routeMetric1' => 'metric1',
'routeMetric2' => 'metric2',
'routeMetric3' => 'metric3',
'routeMetric4' => 'metric4',
'routeMetric5' => 'metric5',
'routeStatus' => 'status'
];
$canTranslate = [ 'routeType', 'routeProto', 'routeStatus'];
$details = [];
foreach ($fetchList as $fn => $idx) {
if (in_array($fn, $canTranslate))
$values = $this->$fn($translate);
else
$values = $this->$fn();
foreach ($values as $ip => $value)
$details[$ip][$idx] = $value;
}
return $details;
} | [
"public",
"function",
"routeDetails",
"(",
"$",
"translate",
"=",
"false",
")",
"{",
"$",
"fetchList",
"=",
"[",
"'routeDest'",
"=>",
"'destination'",
",",
"'routeMask'",
"=>",
"'mask'",
",",
"'routeTos'",
"=>",
"'TOS'",
",",
"'routeNextHop'",
"=>",
"'nextHop'",
",",
"'routeIfIndex'",
"=>",
"'ifIndex'",
",",
"'routeType'",
"=>",
"'type'",
",",
"'routeProto'",
"=>",
"'protocol'",
",",
"'routeAge'",
"=>",
"'age'",
",",
"'routeInfo'",
"=>",
"'info'",
",",
"'routeNextHopAS'",
"=>",
"'nextHopAS'",
",",
"'routeMetric1'",
"=>",
"'metric1'",
",",
"'routeMetric2'",
"=>",
"'metric2'",
",",
"'routeMetric3'",
"=>",
"'metric3'",
",",
"'routeMetric4'",
"=>",
"'metric4'",
",",
"'routeMetric5'",
"=>",
"'metric5'",
",",
"'routeStatus'",
"=>",
"'status'",
"]",
";",
"$",
"canTranslate",
"=",
"[",
"'routeType'",
",",
"'routeProto'",
",",
"'routeStatus'",
"]",
";",
"$",
"details",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"fetchList",
"as",
"$",
"fn",
"=>",
"$",
"idx",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"fn",
",",
"$",
"canTranslate",
")",
")",
"$",
"values",
"=",
"$",
"this",
"->",
"$",
"fn",
"(",
"$",
"translate",
")",
";",
"else",
"$",
"values",
"=",
"$",
"this",
"->",
"$",
"fn",
"(",
")",
";",
"foreach",
"(",
"$",
"values",
"as",
"$",
"ip",
"=>",
"$",
"value",
")",
"$",
"details",
"[",
"$",
"ip",
"]",
"[",
"$",
"idx",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"details",
";",
"}"
] | Utility function to gather all routes into a single array.
@param bool $translate Where a called function supports translation, if true then translate
@return array Array of routes | [
"Utility",
"function",
"to",
"gather",
"all",
"routes",
"into",
"a",
"single",
"array",
"."
] | 831b7485b6c932a84f081d5ceeb9c5f4e7a8641d | https://github.com/cityware/city-snmp/blob/831b7485b6c932a84f081d5ceeb9c5f4e7a8641d/src/MIBS/Routes.php#L448-L479 |
8,055 | open-orchestra/open-orchestra-front-bundle | FrontBundle/Twig/GetSpecialPageExtension.php | GetSpecialPageExtension.loadSpecialPages | protected function loadSpecialPages()
{
$language = $this->siteManager->getSiteLanguage();
$siteId = $this->siteManager->getSiteId();
$this->specialPages = $this->nodeRepository->findAllPublishedSpecialPage($language, $siteId);
} | php | protected function loadSpecialPages()
{
$language = $this->siteManager->getSiteLanguage();
$siteId = $this->siteManager->getSiteId();
$this->specialPages = $this->nodeRepository->findAllPublishedSpecialPage($language, $siteId);
} | [
"protected",
"function",
"loadSpecialPages",
"(",
")",
"{",
"$",
"language",
"=",
"$",
"this",
"->",
"siteManager",
"->",
"getSiteLanguage",
"(",
")",
";",
"$",
"siteId",
"=",
"$",
"this",
"->",
"siteManager",
"->",
"getSiteId",
"(",
")",
";",
"$",
"this",
"->",
"specialPages",
"=",
"$",
"this",
"->",
"nodeRepository",
"->",
"findAllPublishedSpecialPage",
"(",
"$",
"language",
",",
"$",
"siteId",
")",
";",
"}"
] | Load special pages | [
"Load",
"special",
"pages"
] | 3c2cf3998af03e7a69fb6475b71d9c7d65b058bb | https://github.com/open-orchestra/open-orchestra-front-bundle/blob/3c2cf3998af03e7a69fb6475b71d9c7d65b058bb/FrontBundle/Twig/GetSpecialPageExtension.php#L69-L74 |
8,056 | chemel/http-headers | src/HttpHeaders.php | HttpHeaders.getFirefox | public function getFirefox($format = self::FORMAT_GUZZLE, $platfom = 'win7', $lang = 'en') {
return $this->getHeaders($platfom.'-firefox-'.$lang, $format);
} | php | public function getFirefox($format = self::FORMAT_GUZZLE, $platfom = 'win7', $lang = 'en') {
return $this->getHeaders($platfom.'-firefox-'.$lang, $format);
} | [
"public",
"function",
"getFirefox",
"(",
"$",
"format",
"=",
"self",
"::",
"FORMAT_GUZZLE",
",",
"$",
"platfom",
"=",
"'win7'",
",",
"$",
"lang",
"=",
"'en'",
")",
"{",
"return",
"$",
"this",
"->",
"getHeaders",
"(",
"$",
"platfom",
".",
"'-firefox-'",
".",
"$",
"lang",
",",
"$",
"format",
")",
";",
"}"
] | Get Firefox headers
@param int format
@param string platfom
@param string lang
@return array headers | [
"Get",
"Firefox",
"headers"
] | 0011f68145eccf38c80393385805b8f0868edd07 | https://github.com/chemel/http-headers/blob/0011f68145eccf38c80393385805b8f0868edd07/src/HttpHeaders.php#L62-L65 |
8,057 | chemel/http-headers | src/HttpHeaders.php | HttpHeaders.getChrome | public function getChrome($format = self::FORMAT_GUZZLE, $platfom = 'win7', $lang = 'en') {
return $this->getHeaders($platfom.'-chrome-'.$lang, $format);
} | php | public function getChrome($format = self::FORMAT_GUZZLE, $platfom = 'win7', $lang = 'en') {
return $this->getHeaders($platfom.'-chrome-'.$lang, $format);
} | [
"public",
"function",
"getChrome",
"(",
"$",
"format",
"=",
"self",
"::",
"FORMAT_GUZZLE",
",",
"$",
"platfom",
"=",
"'win7'",
",",
"$",
"lang",
"=",
"'en'",
")",
"{",
"return",
"$",
"this",
"->",
"getHeaders",
"(",
"$",
"platfom",
".",
"'-chrome-'",
".",
"$",
"lang",
",",
"$",
"format",
")",
";",
"}"
] | Get Chrome headers
@param int format
@param string platfom
@param string lang
@return array headers | [
"Get",
"Chrome",
"headers"
] | 0011f68145eccf38c80393385805b8f0868edd07 | https://github.com/chemel/http-headers/blob/0011f68145eccf38c80393385805b8f0868edd07/src/HttpHeaders.php#L76-L79 |
8,058 | devbr/pack-blog | Page.php | Page.tmp | function tmp()
{
//$xlog = new Model\Xlog;
//$xlog->decodeAgent();
//Fazendo login
//Lib\User::this()->login('admin', 'admin#123');
//Lib\User::this()->setCriptoCookie();
//Lib\User::this()->unsetCriptoCookie();
$user = new Lib\User();
$user->login('jessica', 'jessica#123');
//$user->unsetCriptoCookie();
//
//
Lib\App::p($user->get(), true);
Lib\App::p(Lib\User::this()->get(), true);
Lib\App::p($_SERVER['REMOTE_ADDR'], true);
Lib\App::p($_SERVER['HTTP_USER_AGENT'], true);
Lib\App::p($_SERVER['HTTP_ACCEPT_LANGUAGE'], true);
echo "<br>OS: </b>".$this->operating_system_detection();
echo '<hr/>';
$jsonBrowser = json_encode(get_browser());
echo '<br><b>Tamanho do arquivo: </b>'.strlen($jsonBrowser).'<br>';
Lib\App::p(json_decode($jsonBrowser), true);
//Fazendo login
//Lib\User::this()->login('jessica', 'jessica#123');
//Lib\User::this()->setCriptoCookie();
//Lib\App::p(Lib\User::this()->get(), true);
echo "<hr/><b>Finished!</b>";
} | php | function tmp()
{
//$xlog = new Model\Xlog;
//$xlog->decodeAgent();
//Fazendo login
//Lib\User::this()->login('admin', 'admin#123');
//Lib\User::this()->setCriptoCookie();
//Lib\User::this()->unsetCriptoCookie();
$user = new Lib\User();
$user->login('jessica', 'jessica#123');
//$user->unsetCriptoCookie();
//
//
Lib\App::p($user->get(), true);
Lib\App::p(Lib\User::this()->get(), true);
Lib\App::p($_SERVER['REMOTE_ADDR'], true);
Lib\App::p($_SERVER['HTTP_USER_AGENT'], true);
Lib\App::p($_SERVER['HTTP_ACCEPT_LANGUAGE'], true);
echo "<br>OS: </b>".$this->operating_system_detection();
echo '<hr/>';
$jsonBrowser = json_encode(get_browser());
echo '<br><b>Tamanho do arquivo: </b>'.strlen($jsonBrowser).'<br>';
Lib\App::p(json_decode($jsonBrowser), true);
//Fazendo login
//Lib\User::this()->login('jessica', 'jessica#123');
//Lib\User::this()->setCriptoCookie();
//Lib\App::p(Lib\User::this()->get(), true);
echo "<hr/><b>Finished!</b>";
} | [
"function",
"tmp",
"(",
")",
"{",
"//$xlog = new Model\\Xlog;",
"//$xlog->decodeAgent();",
"//Fazendo login",
"//Lib\\User::this()->login('admin', 'admin#123');",
"//Lib\\User::this()->setCriptoCookie();",
"//Lib\\User::this()->unsetCriptoCookie();",
"$",
"user",
"=",
"new",
"Lib",
"\\",
"User",
"(",
")",
";",
"$",
"user",
"->",
"login",
"(",
"'jessica'",
",",
"'jessica#123'",
")",
";",
"//$user->unsetCriptoCookie();",
"//",
"//",
"Lib",
"\\",
"App",
"::",
"p",
"(",
"$",
"user",
"->",
"get",
"(",
")",
",",
"true",
")",
";",
"Lib",
"\\",
"App",
"::",
"p",
"(",
"Lib",
"\\",
"User",
"::",
"this",
"(",
")",
"->",
"get",
"(",
")",
",",
"true",
")",
";",
"Lib",
"\\",
"App",
"::",
"p",
"(",
"$",
"_SERVER",
"[",
"'REMOTE_ADDR'",
"]",
",",
"true",
")",
";",
"Lib",
"\\",
"App",
"::",
"p",
"(",
"$",
"_SERVER",
"[",
"'HTTP_USER_AGENT'",
"]",
",",
"true",
")",
";",
"Lib",
"\\",
"App",
"::",
"p",
"(",
"$",
"_SERVER",
"[",
"'HTTP_ACCEPT_LANGUAGE'",
"]",
",",
"true",
")",
";",
"echo",
"\"<br>OS: </b>\"",
".",
"$",
"this",
"->",
"operating_system_detection",
"(",
")",
";",
"echo",
"'<hr/>'",
";",
"$",
"jsonBrowser",
"=",
"json_encode",
"(",
"get_browser",
"(",
")",
")",
";",
"echo",
"'<br><b>Tamanho do arquivo: </b>'",
".",
"strlen",
"(",
"$",
"jsonBrowser",
")",
".",
"'<br>'",
";",
"Lib",
"\\",
"App",
"::",
"p",
"(",
"json_decode",
"(",
"$",
"jsonBrowser",
")",
",",
"true",
")",
";",
"//Fazendo login",
"//Lib\\User::this()->login('jessica', 'jessica#123');",
"//Lib\\User::this()->setCriptoCookie();",
"//Lib\\App::p(Lib\\User::this()->get(), true);",
"echo",
"\"<hr/><b>Finished!</b>\"",
";",
"}"
] | TEMP - de le te me | [
"TEMP",
"-",
"de",
"le",
"te",
"me"
] | 4693e36521ee3d08077f0db3e013afb99785cc9d | https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Page.php#L264-L305 |
8,059 | zepi/turbo-base | Zepi/DataSource/Core/src/Entity/DataRequest.php | DataRequest.hasFilter | public function hasFilter($name)
{
foreach ($this->filters as $filter) {
if ($filter->getFieldName() === $name) {
return true;
}
}
return false;
} | php | public function hasFilter($name)
{
foreach ($this->filters as $filter) {
if ($filter->getFieldName() === $name) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasFilter",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"filter",
"->",
"getFieldName",
"(",
")",
"===",
"$",
"name",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns true if the request has a filter for the given name
@access public
@param string $name
@return boolean | [
"Returns",
"true",
"if",
"the",
"request",
"has",
"a",
"filter",
"for",
"the",
"given",
"name"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/DataSource/Core/src/Entity/DataRequest.php#L131-L140 |
8,060 | zepi/turbo-base | Zepi/DataSource/Core/src/Entity/DataRequest.php | DataRequest.getFilter | public function getFilter($name)
{
foreach ($this->filters as $filter) {
if ($filter->getFieldName() === $name) {
return $filter;
}
}
return false;
} | php | public function getFilter($name)
{
foreach ($this->filters as $filter) {
if ($filter->getFieldName() === $name) {
return $filter;
}
}
return false;
} | [
"public",
"function",
"getFilter",
"(",
"$",
"name",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"filters",
"as",
"$",
"filter",
")",
"{",
"if",
"(",
"$",
"filter",
"->",
"getFieldName",
"(",
")",
"===",
"$",
"name",
")",
"{",
"return",
"$",
"filter",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Returns the Filter object for the given key
@access public
@param string $name
@return false|\Zepi\DataSource\Core\Entity\Filter | [
"Returns",
"the",
"Filter",
"object",
"for",
"the",
"given",
"key"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/DataSource/Core/src/Entity/DataRequest.php#L149-L158 |
8,061 | zepi/turbo-base | Zepi/DataSource/Core/src/Entity/DataRequest.php | DataRequest.setPage | public function setPage($page)
{
$this->page = intval($page);
if ($this->page == 0) {
$this->page = 1;
}
} | php | public function setPage($page)
{
$this->page = intval($page);
if ($this->page == 0) {
$this->page = 1;
}
} | [
"public",
"function",
"setPage",
"(",
"$",
"page",
")",
"{",
"$",
"this",
"->",
"page",
"=",
"intval",
"(",
"$",
"page",
")",
";",
"if",
"(",
"$",
"this",
"->",
"page",
"==",
"0",
")",
"{",
"$",
"this",
"->",
"page",
"=",
"1",
";",
"}",
"}"
] | Sets the number of the loaded page
@access public
@param integer $page | [
"Sets",
"the",
"number",
"of",
"the",
"loaded",
"page"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/DataSource/Core/src/Entity/DataRequest.php#L187-L194 |
8,062 | zepi/turbo-base | Zepi/DataSource/Core/src/Entity/DataRequest.php | DataRequest.hasRange | public function hasRange()
{
return ($this->getOffset() !== false && $this->getOffset() >= 0 && $this->getNumberOfEntries() !== false && $this->getNumberOfEntries() > 0);
} | php | public function hasRange()
{
return ($this->getOffset() !== false && $this->getOffset() >= 0 && $this->getNumberOfEntries() !== false && $this->getNumberOfEntries() > 0);
} | [
"public",
"function",
"hasRange",
"(",
")",
"{",
"return",
"(",
"$",
"this",
"->",
"getOffset",
"(",
")",
"!==",
"false",
"&&",
"$",
"this",
"->",
"getOffset",
"(",
")",
">=",
"0",
"&&",
"$",
"this",
"->",
"getNumberOfEntries",
"(",
")",
"!==",
"false",
"&&",
"$",
"this",
"->",
"getNumberOfEntries",
"(",
")",
">",
"0",
")",
";",
"}"
] | Returns true if only a range of the result is requested
@return boolean | [
"Returns",
"true",
"if",
"only",
"a",
"range",
"of",
"the",
"result",
"is",
"requested"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/DataSource/Core/src/Entity/DataRequest.php#L238-L241 |
8,063 | joverthegrey/singleton | src/Singleton.php | Singleton.getInstance | public static function getInstance() {
// late-static-bound class name
$classname = get_called_class();
if (!isset(self::$instances[$classname])) {
self::$instances[$classname] = new static;
}
return self::$instances[$classname];
} | php | public static function getInstance() {
// late-static-bound class name
$classname = get_called_class();
if (!isset(self::$instances[$classname])) {
self::$instances[$classname] = new static;
}
return self::$instances[$classname];
} | [
"public",
"static",
"function",
"getInstance",
"(",
")",
"{",
"// late-static-bound class name",
"$",
"classname",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"instances",
"[",
"$",
"classname",
"]",
")",
")",
"{",
"self",
"::",
"$",
"instances",
"[",
"$",
"classname",
"]",
"=",
"new",
"static",
";",
"}",
"return",
"self",
"::",
"$",
"instances",
"[",
"$",
"classname",
"]",
";",
"}"
] | return an instance of the called class
@return mixed | [
"return",
"an",
"instance",
"of",
"the",
"called",
"class"
] | 069afddc5ed766f7613477b873de0f31f3b6ab92 | https://github.com/joverthegrey/singleton/blob/069afddc5ed766f7613477b873de0f31f3b6ab92/src/Singleton.php#L40-L48 |
8,064 | tlumx/tlumx-view | src/TemplatesManager.php | TemplatesManager.addTemplatePath | public function addTemplatePath($namespace, $path)
{
if (!is_string($namespace) || !is_string($path) || empty($namespace) || empty($path)) {
throw new \InvalidArgumentException('Template namespace and path must be a not empty string');
}
$this->paths[$namespace] = $this->normalizePath($path);
} | php | public function addTemplatePath($namespace, $path)
{
if (!is_string($namespace) || !is_string($path) || empty($namespace) || empty($path)) {
throw new \InvalidArgumentException('Template namespace and path must be a not empty string');
}
$this->paths[$namespace] = $this->normalizePath($path);
} | [
"public",
"function",
"addTemplatePath",
"(",
"$",
"namespace",
",",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"namespace",
")",
"||",
"!",
"is_string",
"(",
"$",
"path",
")",
"||",
"empty",
"(",
"$",
"namespace",
")",
"||",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Template namespace and path must be a not empty string'",
")",
";",
"}",
"$",
"this",
"->",
"paths",
"[",
"$",
"namespace",
"]",
"=",
"$",
"this",
"->",
"normalizePath",
"(",
"$",
"path",
")",
";",
"}"
] | Add template path
@param string $namespace
@param string $path
@throws \InvalidArgumentException | [
"Add",
"template",
"path"
] | 9f784eb8092ac2971e05cb478849ade6d485bbfa | https://github.com/tlumx/tlumx-view/blob/9f784eb8092ac2971e05cb478849ade6d485bbfa/src/TemplatesManager.php#L62-L69 |
8,065 | tlumx/tlumx-view | src/TemplatesManager.php | TemplatesManager.getTemplatePath | public function getTemplatePath($namespace)
{
if (!$this->hasTemplatePath($namespace)) {
throw new \RuntimeException("Path with namespace \"".$namespace."\" is not exist");
}
$path = $this->paths[$namespace];
if (!is_dir($path)) {
throw new \RuntimeException("Invalid template path with namespace \"".$namespace."\"");
}
return $path;
} | php | public function getTemplatePath($namespace)
{
if (!$this->hasTemplatePath($namespace)) {
throw new \RuntimeException("Path with namespace \"".$namespace."\" is not exist");
}
$path = $this->paths[$namespace];
if (!is_dir($path)) {
throw new \RuntimeException("Invalid template path with namespace \"".$namespace."\"");
}
return $path;
} | [
"public",
"function",
"getTemplatePath",
"(",
"$",
"namespace",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasTemplatePath",
"(",
"$",
"namespace",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Path with namespace \\\"\"",
".",
"$",
"namespace",
".",
"\"\\\" is not exist\"",
")",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"paths",
"[",
"$",
"namespace",
"]",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Invalid template path with namespace \\\"\"",
".",
"$",
"namespace",
".",
"\"\\\"\"",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | Get themplate path by namespace
@param string $namespace
@return string
@throws \RuntimeException | [
"Get",
"themplate",
"path",
"by",
"namespace"
] | 9f784eb8092ac2971e05cb478849ade6d485bbfa | https://github.com/tlumx/tlumx-view/blob/9f784eb8092ac2971e05cb478849ade6d485bbfa/src/TemplatesManager.php#L89-L102 |
8,066 | tlumx/tlumx-view | src/TemplatesManager.php | TemplatesManager.addTemplate | public function addTemplate($name, $filename)
{
if (!is_string($name) || !is_string($filename) || empty($name) || empty($filename)) {
throw new \InvalidArgumentException('Template name and filename must be a not empty string');
}
$this->templateMap[$name] = $filename;
} | php | public function addTemplate($name, $filename)
{
if (!is_string($name) || !is_string($filename) || empty($name) || empty($filename)) {
throw new \InvalidArgumentException('Template name and filename must be a not empty string');
}
$this->templateMap[$name] = $filename;
} | [
"public",
"function",
"addTemplate",
"(",
"$",
"name",
",",
"$",
"filename",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"name",
")",
"||",
"!",
"is_string",
"(",
"$",
"filename",
")",
"||",
"empty",
"(",
"$",
"name",
")",
"||",
"empty",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Template name and filename must be a not empty string'",
")",
";",
"}",
"$",
"this",
"->",
"templateMap",
"[",
"$",
"name",
"]",
"=",
"$",
"filename",
";",
"}"
] | Add template to the map
@param string $name
@param string $filename
@throws \InvalidArgumentException | [
"Add",
"template",
"to",
"the",
"map"
] | 9f784eb8092ac2971e05cb478849ade6d485bbfa | https://github.com/tlumx/tlumx-view/blob/9f784eb8092ac2971e05cb478849ade6d485bbfa/src/TemplatesManager.php#L142-L149 |
8,067 | tlumx/tlumx-view | src/TemplatesManager.php | TemplatesManager.getTemplate | public function getTemplate($name)
{
if (!$this->hasTemplate($name)) {
throw new \RuntimeException("Template with name \"".$name."\" is not exist");
}
$filename = $this->templateMap[$name];
if (!file_exists($filename)) {
throw new \RuntimeException("Invalid template filename with name \"".$name."\"");
}
return $filename;
} | php | public function getTemplate($name)
{
if (!$this->hasTemplate($name)) {
throw new \RuntimeException("Template with name \"".$name."\" is not exist");
}
$filename = $this->templateMap[$name];
if (!file_exists($filename)) {
throw new \RuntimeException("Invalid template filename with name \"".$name."\"");
}
return $filename;
} | [
"public",
"function",
"getTemplate",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasTemplate",
"(",
"$",
"name",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Template with name \\\"\"",
".",
"$",
"name",
".",
"\"\\\" is not exist\"",
")",
";",
"}",
"$",
"filename",
"=",
"$",
"this",
"->",
"templateMap",
"[",
"$",
"name",
"]",
";",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"filename",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Invalid template filename with name \\\"\"",
".",
"$",
"name",
".",
"\"\\\"\"",
")",
";",
"}",
"return",
"$",
"filename",
";",
"}"
] | Get template filename
@param string $name
@return string
@throws \RuntimeException | [
"Get",
"template",
"filename"
] | 9f784eb8092ac2971e05cb478849ade6d485bbfa | https://github.com/tlumx/tlumx-view/blob/9f784eb8092ac2971e05cb478849ade6d485bbfa/src/TemplatesManager.php#L169-L182 |
8,068 | niconoe-/asserts | src/Asserts/Categories/AssertCountableTrait.php | AssertCountableTrait.assertEmpty | public static function assertEmpty($countableElement, Throwable $exception): bool
{
static::makeAssertion(0 === \count($countableElement), $exception);
return true;
} | php | public static function assertEmpty($countableElement, Throwable $exception): bool
{
static::makeAssertion(0 === \count($countableElement), $exception);
return true;
} | [
"public",
"static",
"function",
"assertEmpty",
"(",
"$",
"countableElement",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"0",
"===",
"\\",
"count",
"(",
"$",
"countableElement",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the given array is empty.
@param array|\Countable $countableElement The array or the countable object to assert its emptiness.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"given",
"array",
"is",
"empty",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertCountableTrait.php#L26-L30 |
8,069 | niconoe-/asserts | src/Asserts/Categories/AssertCountableTrait.php | AssertCountableTrait.assertNotEmpty | public static function assertNotEmpty($countableElement, Throwable $exception): bool
{
static::makeAssertion(0 !== \count($countableElement), $exception);
return true;
} | php | public static function assertNotEmpty($countableElement, Throwable $exception): bool
{
static::makeAssertion(0 !== \count($countableElement), $exception);
return true;
} | [
"public",
"static",
"function",
"assertNotEmpty",
"(",
"$",
"countableElement",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"0",
"!==",
"\\",
"count",
"(",
"$",
"countableElement",
")",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the given array is not empty.
@param array|\Countable $countableElement The array or the countable object to assert its emptiness.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"given",
"array",
"is",
"not",
"empty",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertCountableTrait.php#L39-L43 |
8,070 | niconoe-/asserts | src/Asserts/Categories/AssertCountableTrait.php | AssertCountableTrait.assertCount | public static function assertCount($countableElement, int $expected, Throwable $exception): bool
{
static::makeAssertion(\count($countableElement) === $expected, $exception);
return true;
} | php | public static function assertCount($countableElement, int $expected, Throwable $exception): bool
{
static::makeAssertion(\count($countableElement) === $expected, $exception);
return true;
} | [
"public",
"static",
"function",
"assertCount",
"(",
"$",
"countableElement",
",",
"int",
"$",
"expected",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"count",
"(",
"$",
"countableElement",
")",
"===",
"$",
"expected",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the given array contains the given number of elements.
@param array|\Countable $countableElement The array or the countable object to count its content.
@param int $expected The number of expected elements.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"given",
"array",
"contains",
"the",
"given",
"number",
"of",
"elements",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertCountableTrait.php#L53-L57 |
8,071 | niconoe-/asserts | src/Asserts/Categories/AssertCountableTrait.php | AssertCountableTrait.assertNotCount | public static function assertNotCount($countableElement, int $notExpected, Throwable $exception): bool
{
static::makeAssertion(\count($countableElement) !== $notExpected, $exception);
return true;
} | php | public static function assertNotCount($countableElement, int $notExpected, Throwable $exception): bool
{
static::makeAssertion(\count($countableElement) !== $notExpected, $exception);
return true;
} | [
"public",
"static",
"function",
"assertNotCount",
"(",
"$",
"countableElement",
",",
"int",
"$",
"notExpected",
",",
"Throwable",
"$",
"exception",
")",
":",
"bool",
"{",
"static",
"::",
"makeAssertion",
"(",
"\\",
"count",
"(",
"$",
"countableElement",
")",
"!==",
"$",
"notExpected",
",",
"$",
"exception",
")",
";",
"return",
"true",
";",
"}"
] | Asserts that the given array does not contain the given number of elements.
@param array|\Countable $countableElement The array or the countable object to count its content.
@param int $notExpected The number of not expected elements.
@param Throwable $exception The exception to throw if the assertion fails.
@return bool | [
"Asserts",
"that",
"the",
"given",
"array",
"does",
"not",
"contain",
"the",
"given",
"number",
"of",
"elements",
"."
] | a33dd3fb8983ae6965533c8ff4ff8380367b561d | https://github.com/niconoe-/asserts/blob/a33dd3fb8983ae6965533c8ff4ff8380367b561d/src/Asserts/Categories/AssertCountableTrait.php#L67-L71 |
8,072 | crip-laravel/core | src/Data/RelationInputService.php | RelationInputService.apply | public function apply(Builder $builder, Repository $repository, array $relations = [])
{
$relations = $this->getRelations($repository, $relations);
return $builder->with($relations);
} | php | public function apply(Builder $builder, Repository $repository, array $relations = [])
{
$relations = $this->getRelations($repository, $relations);
return $builder->with($relations);
} | [
"public",
"function",
"apply",
"(",
"Builder",
"$",
"builder",
",",
"Repository",
"$",
"repository",
",",
"array",
"$",
"relations",
"=",
"[",
"]",
")",
"{",
"$",
"relations",
"=",
"$",
"this",
"->",
"getRelations",
"(",
"$",
"repository",
",",
"$",
"relations",
")",
";",
"return",
"$",
"builder",
"->",
"with",
"(",
"$",
"relations",
")",
";",
"}"
] | Apply eager load relations to query builder
@param Builder $builder
@param Repository $repository
@param array $relations
@return Builder | [
"Apply",
"eager",
"load",
"relations",
"to",
"query",
"builder"
] | d58cef97d97fba8b01bec33801452ecbd7c992de | https://github.com/crip-laravel/core/blob/d58cef97d97fba8b01bec33801452ecbd7c992de/src/Data/RelationInputService.php#L35-L40 |
8,073 | crip-laravel/core | src/Data/RelationInputService.php | RelationInputService.getRelations | private function getRelations(Repository $repository, array $relations = [])
{
// if we have relation array passed, ignore request input
if (count($relations) === 0) {
$relations = Input::get('with');
if (!is_array($relations)) {
$relations = $this->inputService->decode('with');
}
}
$result = [];
$repo_relations = $repository->relations();
foreach ($relations as $key => $value) {
if (in_array($key, $repo_relations)) {
$result[] = $key;
} elseif (in_array($value, $repo_relations)) {
$result[] = $value;
}
}
return $result;
} | php | private function getRelations(Repository $repository, array $relations = [])
{
// if we have relation array passed, ignore request input
if (count($relations) === 0) {
$relations = Input::get('with');
if (!is_array($relations)) {
$relations = $this->inputService->decode('with');
}
}
$result = [];
$repo_relations = $repository->relations();
foreach ($relations as $key => $value) {
if (in_array($key, $repo_relations)) {
$result[] = $key;
} elseif (in_array($value, $repo_relations)) {
$result[] = $value;
}
}
return $result;
} | [
"private",
"function",
"getRelations",
"(",
"Repository",
"$",
"repository",
",",
"array",
"$",
"relations",
"=",
"[",
"]",
")",
"{",
"// if we have relation array passed, ignore request input",
"if",
"(",
"count",
"(",
"$",
"relations",
")",
"===",
"0",
")",
"{",
"$",
"relations",
"=",
"Input",
"::",
"get",
"(",
"'with'",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"relations",
")",
")",
"{",
"$",
"relations",
"=",
"$",
"this",
"->",
"inputService",
"->",
"decode",
"(",
"'with'",
")",
";",
"}",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"repo_relations",
"=",
"$",
"repository",
"->",
"relations",
"(",
")",
";",
"foreach",
"(",
"$",
"relations",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"key",
",",
"$",
"repo_relations",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"key",
";",
"}",
"elseif",
"(",
"in_array",
"(",
"$",
"value",
",",
"$",
"repo_relations",
")",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Get relation array
@param Repository $repository
@param array $relations
@return array | [
"Get",
"relation",
"array"
] | d58cef97d97fba8b01bec33801452ecbd7c992de | https://github.com/crip-laravel/core/blob/d58cef97d97fba8b01bec33801452ecbd7c992de/src/Data/RelationInputService.php#L49-L71 |
8,074 | sios13/simox | src/Tag.php | Tag.linkTo | public function linkTo( $path, $text, $is_local_path = true )
{
$url = $this->_di->getService( "url" );
if ( $is_local_path )
{
$path = $url->get( $path );
}
$link = "<a href='$path'>$text</a>";
return $link;
} | php | public function linkTo( $path, $text, $is_local_path = true )
{
$url = $this->_di->getService( "url" );
if ( $is_local_path )
{
$path = $url->get( $path );
}
$link = "<a href='$path'>$text</a>";
return $link;
} | [
"public",
"function",
"linkTo",
"(",
"$",
"path",
",",
"$",
"text",
",",
"$",
"is_local_path",
"=",
"true",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"_di",
"->",
"getService",
"(",
"\"url\"",
")",
";",
"if",
"(",
"$",
"is_local_path",
")",
"{",
"$",
"path",
"=",
"$",
"url",
"->",
"get",
"(",
"$",
"path",
")",
";",
"}",
"$",
"link",
"=",
"\"<a href='$path'>$text</a>\"",
";",
"return",
"$",
"link",
";",
"}"
] | Creates an HTML anchor tag using the Url Simox service
<code>
<p>Hello, my name is Simon. Click <?php $this->tag->linkTo( "/blog/", "here" ); ?> to read my blog!</p>
<p>Check out my <?php $this->tag->linkTo( "http://www.example.com/", "awesome website", false ); ?>!</p>
</code>
@param string $path
@param string $text
@param boolean $is_local_path | [
"Creates",
"an",
"HTML",
"anchor",
"tag",
"using",
"the",
"Url",
"Simox",
"service"
] | 8be964949ef179aba7eceb3fc6439815a1af2ad2 | https://github.com/sios13/simox/blob/8be964949ef179aba7eceb3fc6439815a1af2ad2/src/Tag.php#L88-L100 |
8,075 | railsphp/framework | src/Rails/ActiveRecord/Associations/Associations.php | Associations.associations | public function associations()
{
if (!$this->associations) {
if ($this->getService('rails.config')['use_cache']) {
$this->associations = $this->getCachedData();
} else {
$this->associations = $this->getAssociationsData();
}
}
return $this->associations;
} | php | public function associations()
{
if (!$this->associations) {
if ($this->getService('rails.config')['use_cache']) {
$this->associations = $this->getCachedData();
} else {
$this->associations = $this->getAssociationsData();
}
}
return $this->associations;
} | [
"public",
"function",
"associations",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"associations",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getService",
"(",
"'rails.config'",
")",
"[",
"'use_cache'",
"]",
")",
"{",
"$",
"this",
"->",
"associations",
"=",
"$",
"this",
"->",
"getCachedData",
"(",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"associations",
"=",
"$",
"this",
"->",
"getAssociationsData",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"associations",
";",
"}"
] | Get all associations and their options.
@return array | [
"Get",
"all",
"associations",
"and",
"their",
"options",
"."
] | 2ac9d3e493035dcc68f3c3812423327127327cd5 | https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveRecord/Associations/Associations.php#L54-L64 |
8,076 | railsphp/framework | src/Rails/ActiveRecord/Associations/Associations.php | Associations.callbacks | public function callbacks()
{
$dependent = false;
$autosave = false;
$callbacks = [
'beforeDestroy' => [],
'beforeSave' => []
];
foreach ($this->associations() as $data) {
switch ($data['type']) {
case 'belongsTo':
case 'hasMany':
case 'hasOne':
if (
!empty($data['dependent']) &&
!$dependent
) {
$callbacks = [
'beforeDestroy' => [
'alterDependencies'
]
];
}
# Fallthrough
default:
if (
!empty($data['autosave']) &&
!$autosave
) {
$callbacks = [
'beforeSave' => [
'saveDependencies'
]
];
}
break;
}
if ($autosave && $dependent) {
break;
}
}
return array_filter($callbacks);
} | php | public function callbacks()
{
$dependent = false;
$autosave = false;
$callbacks = [
'beforeDestroy' => [],
'beforeSave' => []
];
foreach ($this->associations() as $data) {
switch ($data['type']) {
case 'belongsTo':
case 'hasMany':
case 'hasOne':
if (
!empty($data['dependent']) &&
!$dependent
) {
$callbacks = [
'beforeDestroy' => [
'alterDependencies'
]
];
}
# Fallthrough
default:
if (
!empty($data['autosave']) &&
!$autosave
) {
$callbacks = [
'beforeSave' => [
'saveDependencies'
]
];
}
break;
}
if ($autosave && $dependent) {
break;
}
}
return array_filter($callbacks);
} | [
"public",
"function",
"callbacks",
"(",
")",
"{",
"$",
"dependent",
"=",
"false",
";",
"$",
"autosave",
"=",
"false",
";",
"$",
"callbacks",
"=",
"[",
"'beforeDestroy'",
"=>",
"[",
"]",
",",
"'beforeSave'",
"=>",
"[",
"]",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"associations",
"(",
")",
"as",
"$",
"data",
")",
"{",
"switch",
"(",
"$",
"data",
"[",
"'type'",
"]",
")",
"{",
"case",
"'belongsTo'",
":",
"case",
"'hasMany'",
":",
"case",
"'hasOne'",
":",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'dependent'",
"]",
")",
"&&",
"!",
"$",
"dependent",
")",
"{",
"$",
"callbacks",
"=",
"[",
"'beforeDestroy'",
"=>",
"[",
"'alterDependencies'",
"]",
"]",
";",
"}",
"# Fallthrough",
"default",
":",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'autosave'",
"]",
")",
"&&",
"!",
"$",
"autosave",
")",
"{",
"$",
"callbacks",
"=",
"[",
"'beforeSave'",
"=>",
"[",
"'saveDependencies'",
"]",
"]",
";",
"}",
"break",
";",
"}",
"if",
"(",
"$",
"autosave",
"&&",
"$",
"dependent",
")",
"{",
"break",
";",
"}",
"}",
"return",
"array_filter",
"(",
"$",
"callbacks",
")",
";",
"}"
] | If any of the associations has a 'dependent' option, the
before-destroy callback 'alterDependencies' should be called.
That method will take care of executing the proper tasks with
the dependencies according to the options set.
Same with the 'autosave' option.
# TODO: Move this info somewhere else?
The children's 'autosave' option will override the parent's. For example, User has
many posts with 'autosave' => true, and Post belongs to User with 'autosave' => false.
Upon User save, although User set autosave => true for its association, since Post set
autosave to false, the posts won't be automatically saved. This also clarifies that
the 'autosave' option in a child doesn't mean that the parent will be autosaved, rather,
it defines if the child itself will be saved on parent's save.
If the children are set to be saved alongside its parent, and one of the fails to be saved,
the parent will also stay unsaved.
* If the children aren't set to be saved, their attributes, however, are 'reset':
* <pre>
* // User has many posts, autosave: false
* $user = User::find(1);
* $user->posts()[0]->title = 'Some new title'; // Set new title to first post
* $user->name = 'Some new name'; // Edit user so it can be saved
* $user->save(); // User saved successfuly
* $user->posts()[0]->title = 'Old title'; // Posts attributes got reset
* </pre>
@return array | [
"If",
"any",
"of",
"the",
"associations",
"has",
"a",
"dependent",
"option",
"the",
"before",
"-",
"destroy",
"callback",
"alterDependencies",
"should",
"be",
"called",
".",
"That",
"method",
"will",
"take",
"care",
"of",
"executing",
"the",
"proper",
"tasks",
"with",
"the",
"dependencies",
"according",
"to",
"the",
"options",
"set",
".",
"Same",
"with",
"the",
"autosave",
"option",
"."
] | 2ac9d3e493035dcc68f3c3812423327127327cd5 | https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveRecord/Associations/Associations.php#L133-L179 |
8,077 | rafaelnajera/matcher | Matcher/Matcher.php | Matcher.match | public function match($input)
{
if ($this->currentState===State::MATCH_FOUND) {
return true;
}
if ($this->noMatch) {
return false;
}
$advancing = true;
while ($advancing) {
$hasEmpty = false;
foreach ($this->states[$this->currentState]->conditions as $condition) {
if ($condition->isTokenEmpty()) {
// Move on to next state and check again
$this->callCallbacks($this->currentState, $condition->nextState);
$this->currentState = $condition->nextState;
$hasEmpty = true;
break;
}
if ($condition->match($input)) {
$this->matched[] = $condition->matched($input);
$this->actualMatched[] = $condition->matched($input);
$this->callCallbacks($this->currentState, $condition->nextState);
$this->currentState = $condition->nextState;
return true;
}
}
$advancing = $hasEmpty;
}
// A no-match is confirmed
$this->error = self::E_NOMATCH;
$this->noMatch = true;
$this->currentState = State::NO_MATCH;
return false;
} | php | public function match($input)
{
if ($this->currentState===State::MATCH_FOUND) {
return true;
}
if ($this->noMatch) {
return false;
}
$advancing = true;
while ($advancing) {
$hasEmpty = false;
foreach ($this->states[$this->currentState]->conditions as $condition) {
if ($condition->isTokenEmpty()) {
// Move on to next state and check again
$this->callCallbacks($this->currentState, $condition->nextState);
$this->currentState = $condition->nextState;
$hasEmpty = true;
break;
}
if ($condition->match($input)) {
$this->matched[] = $condition->matched($input);
$this->actualMatched[] = $condition->matched($input);
$this->callCallbacks($this->currentState, $condition->nextState);
$this->currentState = $condition->nextState;
return true;
}
}
$advancing = $hasEmpty;
}
// A no-match is confirmed
$this->error = self::E_NOMATCH;
$this->noMatch = true;
$this->currentState = State::NO_MATCH;
return false;
} | [
"public",
"function",
"match",
"(",
"$",
"input",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"currentState",
"===",
"State",
"::",
"MATCH_FOUND",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"noMatch",
")",
"{",
"return",
"false",
";",
"}",
"$",
"advancing",
"=",
"true",
";",
"while",
"(",
"$",
"advancing",
")",
"{",
"$",
"hasEmpty",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"states",
"[",
"$",
"this",
"->",
"currentState",
"]",
"->",
"conditions",
"as",
"$",
"condition",
")",
"{",
"if",
"(",
"$",
"condition",
"->",
"isTokenEmpty",
"(",
")",
")",
"{",
"// Move on to next state and check again",
"$",
"this",
"->",
"callCallbacks",
"(",
"$",
"this",
"->",
"currentState",
",",
"$",
"condition",
"->",
"nextState",
")",
";",
"$",
"this",
"->",
"currentState",
"=",
"$",
"condition",
"->",
"nextState",
";",
"$",
"hasEmpty",
"=",
"true",
";",
"break",
";",
"}",
"if",
"(",
"$",
"condition",
"->",
"match",
"(",
"$",
"input",
")",
")",
"{",
"$",
"this",
"->",
"matched",
"[",
"]",
"=",
"$",
"condition",
"->",
"matched",
"(",
"$",
"input",
")",
";",
"$",
"this",
"->",
"actualMatched",
"[",
"]",
"=",
"$",
"condition",
"->",
"matched",
"(",
"$",
"input",
")",
";",
"$",
"this",
"->",
"callCallbacks",
"(",
"$",
"this",
"->",
"currentState",
",",
"$",
"condition",
"->",
"nextState",
")",
";",
"$",
"this",
"->",
"currentState",
"=",
"$",
"condition",
"->",
"nextState",
";",
"return",
"true",
";",
"}",
"}",
"$",
"advancing",
"=",
"$",
"hasEmpty",
";",
"}",
"// A no-match is confirmed",
"$",
"this",
"->",
"error",
"=",
"self",
"::",
"E_NOMATCH",
";",
"$",
"this",
"->",
"noMatch",
"=",
"true",
";",
"$",
"this",
"->",
"currentState",
"=",
"State",
"::",
"NO_MATCH",
";",
"return",
"false",
";",
"}"
] | Processes one input token and changes the state of
the pattern accordingly. Returns true if the given input
did not cause the pattern go in an unmatched state.
@param any $input It can be of any type, the conditions used to build
the pattern should know what to do with it.
@return boolean | [
"Processes",
"one",
"input",
"token",
"and",
"changes",
"the",
"state",
"of",
"the",
"pattern",
"accordingly",
".",
"Returns",
"true",
"if",
"the",
"given",
"input",
"did",
"not",
"cause",
"the",
"pattern",
"go",
"in",
"an",
"unmatched",
"state",
"."
] | f8fb4cf5c4969d8ef7b7377384e972fc3ef9e2cf | https://github.com/rafaelnajera/matcher/blob/f8fb4cf5c4969d8ef7b7377384e972fc3ef9e2cf/Matcher/Matcher.php#L124-L160 |
8,078 | rafaelnajera/matcher | Matcher/Matcher.php | Matcher.callCallbacks | private function callCallbacks(int $initialState, int $endState)
{
if (isset($this->callbacks[$initialState][$endState]) &&
is_callable($this->callbacks[$initialState][$endState])) {
$this->matched = call_user_func($this->callbacks[$initialState][$endState], $this->matched);
}
} | php | private function callCallbacks(int $initialState, int $endState)
{
if (isset($this->callbacks[$initialState][$endState]) &&
is_callable($this->callbacks[$initialState][$endState])) {
$this->matched = call_user_func($this->callbacks[$initialState][$endState], $this->matched);
}
} | [
"private",
"function",
"callCallbacks",
"(",
"int",
"$",
"initialState",
",",
"int",
"$",
"endState",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"initialState",
"]",
"[",
"$",
"endState",
"]",
")",
"&&",
"is_callable",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"initialState",
"]",
"[",
"$",
"endState",
"]",
")",
")",
"{",
"$",
"this",
"->",
"matched",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"callbacks",
"[",
"$",
"initialState",
"]",
"[",
"$",
"endState",
"]",
",",
"$",
"this",
"->",
"matched",
")",
";",
"}",
"}"
] | Calls callbacks for the given state number
@param int $stateNumber | [
"Calls",
"callbacks",
"for",
"the",
"given",
"state",
"number"
] | f8fb4cf5c4969d8ef7b7377384e972fc3ef9e2cf | https://github.com/rafaelnajera/matcher/blob/f8fb4cf5c4969d8ef7b7377384e972fc3ef9e2cf/Matcher/Matcher.php#L190-L196 |
8,079 | lucifurious/kisma | src/Kisma/Core/Utility/FilterInput.php | FilterInput.smart | public static function smart( $value, $emptyValueIsNull = false )
{
if ( is_array( $value ) )
{
filter_var_array( $value, FILTER_SANITIZE_STRING );
}
switch ( getType( $value ) )
{
case 'double':
case 'float':
$_filter = FILTER_SANITIZE_NUMBER_FLOAT;
break;
case 'integer':
$_filter = FILTER_SANITIZE_NUMBER_INT;
break;
case 'string':
$_filter = FILTER_SANITIZE_STRING;
break;
default:
$_filter = FILTER_DEFAULT;
break;
}
$_result = filter_var( $value, $_filter );
return $emptyValueIsNull && empty( $_result ) ? null : $_result;
} | php | public static function smart( $value, $emptyValueIsNull = false )
{
if ( is_array( $value ) )
{
filter_var_array( $value, FILTER_SANITIZE_STRING );
}
switch ( getType( $value ) )
{
case 'double':
case 'float':
$_filter = FILTER_SANITIZE_NUMBER_FLOAT;
break;
case 'integer':
$_filter = FILTER_SANITIZE_NUMBER_INT;
break;
case 'string':
$_filter = FILTER_SANITIZE_STRING;
break;
default:
$_filter = FILTER_DEFAULT;
break;
}
$_result = filter_var( $value, $_filter );
return $emptyValueIsNull && empty( $_result ) ? null : $_result;
} | [
"public",
"static",
"function",
"smart",
"(",
"$",
"value",
",",
"$",
"emptyValueIsNull",
"=",
"false",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"filter_var_array",
"(",
"$",
"value",
",",
"FILTER_SANITIZE_STRING",
")",
";",
"}",
"switch",
"(",
"getType",
"(",
"$",
"value",
")",
")",
"{",
"case",
"'double'",
":",
"case",
"'float'",
":",
"$",
"_filter",
"=",
"FILTER_SANITIZE_NUMBER_FLOAT",
";",
"break",
";",
"case",
"'integer'",
":",
"$",
"_filter",
"=",
"FILTER_SANITIZE_NUMBER_INT",
";",
"break",
";",
"case",
"'string'",
":",
"$",
"_filter",
"=",
"FILTER_SANITIZE_STRING",
";",
"break",
";",
"default",
":",
"$",
"_filter",
"=",
"FILTER_DEFAULT",
";",
"break",
";",
"}",
"$",
"_result",
"=",
"filter_var",
"(",
"$",
"value",
",",
"$",
"_filter",
")",
";",
"return",
"$",
"emptyValueIsNull",
"&&",
"empty",
"(",
"$",
"_result",
")",
"?",
"null",
":",
"$",
"_result",
";",
"}"
] | Filter chooser based on number or string. Not very smart really.
@param mixed $value
@param bool $emptyValueIsNull If true, empty() values will be returned as NULL
@return mixed | [
"Filter",
"chooser",
"based",
"on",
"number",
"or",
"string",
".",
"Not",
"very",
"smart",
"really",
"."
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/FilterInput.php#L54-L84 |
8,080 | lucifurious/kisma | src/Kisma/Core/Utility/FilterInput.php | FilterInput.get | public static function get( $type, $key, $defaultValue = null, $filter = FILTER_DEFAULT, $filterOptions = null, $emptyValueIsNull = false )
{
// Allow usage as filter_var()
if ( is_array( $type ) )
{
$_result = filter_var( Option::get( $type, $key, $defaultValue ), $filter, $filterOptions );
return $emptyValueIsNull && empty( $_result ) ? null : $_result;
}
$_haystack = null;
// Based on the type, pull the right value
switch ( $type )
{
case INPUT_REQUEST:
$_haystack = isset( $_REQUEST ) ? $_REQUEST : array();
break;
case INPUT_SESSION:
$_haystack = isset( $_SESSION ) ? $_SESSION : array();
break;
case INPUT_GET:
$_haystack = isset( $_GET ) ? $_GET : array();
break;
case INPUT_POST:
$_haystack = isset( $_POST ) ? $_POST : array();
break;
case INPUT_COOKIE:
$_haystack = isset( $_COOKIE ) ? $_COOKIE : array();
break;
case INPUT_SERVER:
$_haystack = isset( $_SERVER ) ? $_SERVER : array();
break;
case INPUT_ENV:
$_haystack = isset( $_ENV ) ? $_ENV : array();
break;
default:
// No clue what you want man...
throw new \InvalidArgumentException( 'The filter type of "' . $type . '" is unknown or not supported.' );
}
$_value = empty( $_haystack ) ? $defaultValue : filter_var( Option::get( $_haystack, $key, $defaultValue ), $filter, $filterOptions );
return $emptyValueIsNull && empty( $_value ) ? null : $_value;
} | php | public static function get( $type, $key, $defaultValue = null, $filter = FILTER_DEFAULT, $filterOptions = null, $emptyValueIsNull = false )
{
// Allow usage as filter_var()
if ( is_array( $type ) )
{
$_result = filter_var( Option::get( $type, $key, $defaultValue ), $filter, $filterOptions );
return $emptyValueIsNull && empty( $_result ) ? null : $_result;
}
$_haystack = null;
// Based on the type, pull the right value
switch ( $type )
{
case INPUT_REQUEST:
$_haystack = isset( $_REQUEST ) ? $_REQUEST : array();
break;
case INPUT_SESSION:
$_haystack = isset( $_SESSION ) ? $_SESSION : array();
break;
case INPUT_GET:
$_haystack = isset( $_GET ) ? $_GET : array();
break;
case INPUT_POST:
$_haystack = isset( $_POST ) ? $_POST : array();
break;
case INPUT_COOKIE:
$_haystack = isset( $_COOKIE ) ? $_COOKIE : array();
break;
case INPUT_SERVER:
$_haystack = isset( $_SERVER ) ? $_SERVER : array();
break;
case INPUT_ENV:
$_haystack = isset( $_ENV ) ? $_ENV : array();
break;
default:
// No clue what you want man...
throw new \InvalidArgumentException( 'The filter type of "' . $type . '" is unknown or not supported.' );
}
$_value = empty( $_haystack ) ? $defaultValue : filter_var( Option::get( $_haystack, $key, $defaultValue ), $filter, $filterOptions );
return $emptyValueIsNull && empty( $_value ) ? null : $_value;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"type",
",",
"$",
"key",
",",
"$",
"defaultValue",
"=",
"null",
",",
"$",
"filter",
"=",
"FILTER_DEFAULT",
",",
"$",
"filterOptions",
"=",
"null",
",",
"$",
"emptyValueIsNull",
"=",
"false",
")",
"{",
"//\tAllow usage as filter_var()",
"if",
"(",
"is_array",
"(",
"$",
"type",
")",
")",
"{",
"$",
"_result",
"=",
"filter_var",
"(",
"Option",
"::",
"get",
"(",
"$",
"type",
",",
"$",
"key",
",",
"$",
"defaultValue",
")",
",",
"$",
"filter",
",",
"$",
"filterOptions",
")",
";",
"return",
"$",
"emptyValueIsNull",
"&&",
"empty",
"(",
"$",
"_result",
")",
"?",
"null",
":",
"$",
"_result",
";",
"}",
"$",
"_haystack",
"=",
"null",
";",
"//\tBased on the type, pull the right value",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"INPUT_REQUEST",
":",
"$",
"_haystack",
"=",
"isset",
"(",
"$",
"_REQUEST",
")",
"?",
"$",
"_REQUEST",
":",
"array",
"(",
")",
";",
"break",
";",
"case",
"INPUT_SESSION",
":",
"$",
"_haystack",
"=",
"isset",
"(",
"$",
"_SESSION",
")",
"?",
"$",
"_SESSION",
":",
"array",
"(",
")",
";",
"break",
";",
"case",
"INPUT_GET",
":",
"$",
"_haystack",
"=",
"isset",
"(",
"$",
"_GET",
")",
"?",
"$",
"_GET",
":",
"array",
"(",
")",
";",
"break",
";",
"case",
"INPUT_POST",
":",
"$",
"_haystack",
"=",
"isset",
"(",
"$",
"_POST",
")",
"?",
"$",
"_POST",
":",
"array",
"(",
")",
";",
"break",
";",
"case",
"INPUT_COOKIE",
":",
"$",
"_haystack",
"=",
"isset",
"(",
"$",
"_COOKIE",
")",
"?",
"$",
"_COOKIE",
":",
"array",
"(",
")",
";",
"break",
";",
"case",
"INPUT_SERVER",
":",
"$",
"_haystack",
"=",
"isset",
"(",
"$",
"_SERVER",
")",
"?",
"$",
"_SERVER",
":",
"array",
"(",
")",
";",
"break",
";",
"case",
"INPUT_ENV",
":",
"$",
"_haystack",
"=",
"isset",
"(",
"$",
"_ENV",
")",
"?",
"$",
"_ENV",
":",
"array",
"(",
")",
";",
"break",
";",
"default",
":",
"//\tNo clue what you want man...",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The filter type of \"'",
".",
"$",
"type",
".",
"'\" is unknown or not supported.'",
")",
";",
"}",
"$",
"_value",
"=",
"empty",
"(",
"$",
"_haystack",
")",
"?",
"$",
"defaultValue",
":",
"filter_var",
"(",
"Option",
"::",
"get",
"(",
"$",
"_haystack",
",",
"$",
"key",
",",
"$",
"defaultValue",
")",
",",
"$",
"filter",
",",
"$",
"filterOptions",
")",
";",
"return",
"$",
"emptyValueIsNull",
"&&",
"empty",
"(",
"$",
"_value",
")",
"?",
"null",
":",
"$",
"_value",
";",
"}"
] | The master function, performs all filters and gets. Gets around lack of INPUT_SESSION and INPUT_REQUEST
support.
@param int|array $type One of INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, INPUT_ENV,
INPUT_SESSION and INPUT_REQUEST. You may also pass in an array and use this
method to call filter_var with the value found in the array
@param string $key The name of a variable to get.
@param mixed $defaultValue The default value if the key is not found
@param int $filter The filter to use (see the manual page). Defaults to FILTER_DEFAULT.
@param int|array|null $filterOptions Associative array of options or bitwise disjunction of flags. If
filter accepts options,
flags can be provided in "flags" field of array. For the "callback" filter,
callback type should be passed. The callback must accept one argument,
the value to be filtered, and return the value after filtering/sanitizing it.
@param bool $emptyValueIsNull If true, empty() values will be returned as NULL
@throws \InvalidArgumentException
@return mixed | [
"The",
"master",
"function",
"performs",
"all",
"filters",
"and",
"gets",
".",
"Gets",
"around",
"lack",
"of",
"INPUT_SESSION",
"and",
"INPUT_REQUEST",
"support",
"."
] | 4cc9954249da4e535b52f154e728935f07e648ae | https://github.com/lucifurious/kisma/blob/4cc9954249da4e535b52f154e728935f07e648ae/src/Kisma/Core/Utility/FilterInput.php#L106-L150 |
8,081 | slickframework/mvc | src/Router.php | Router.getRouterContainer | public function getRouterContainer()
{
if (null === $this->routerContainer) {
$this->setRouterContainer(new RouterContainer());
$this->routerContainer
->setMapBuilder([$this->getRouteBuilder(), 'build']);
}
return $this->routerContainer;
} | php | public function getRouterContainer()
{
if (null === $this->routerContainer) {
$this->setRouterContainer(new RouterContainer());
$this->routerContainer
->setMapBuilder([$this->getRouteBuilder(), 'build']);
}
return $this->routerContainer;
} | [
"public",
"function",
"getRouterContainer",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"routerContainer",
")",
"{",
"$",
"this",
"->",
"setRouterContainer",
"(",
"new",
"RouterContainer",
"(",
")",
")",
";",
"$",
"this",
"->",
"routerContainer",
"->",
"setMapBuilder",
"(",
"[",
"$",
"this",
"->",
"getRouteBuilder",
"(",
")",
",",
"'build'",
"]",
")",
";",
"}",
"return",
"$",
"this",
"->",
"routerContainer",
";",
"}"
] | Returns route container
@return RouterContainer | [
"Returns",
"route",
"container"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Router.php#L54-L62 |
8,082 | slickframework/mvc | src/Router.php | Router.getMatcher | public function getMatcher()
{
if (null === $this->matcher) {
$this->setMatcher($this->getRouterContainer()->getMatcher());
}
return $this->matcher;
} | php | public function getMatcher()
{
if (null === $this->matcher) {
$this->setMatcher($this->getRouterContainer()->getMatcher());
}
return $this->matcher;
} | [
"public",
"function",
"getMatcher",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"matcher",
")",
"{",
"$",
"this",
"->",
"setMatcher",
"(",
"$",
"this",
"->",
"getRouterContainer",
"(",
")",
"->",
"getMatcher",
"(",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"matcher",
";",
"}"
] | Gets route matcher for this router
@return Matcher | [
"Gets",
"route",
"matcher",
"for",
"this",
"router"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Router.php#L99-L105 |
8,083 | slickframework/mvc | src/Router.php | Router.getRouteBuilder | public function getRouteBuilder()
{
if (null == $this->routeBuilder) {
$this->setRouteBuilder(new RouteBuilder($this->getRouteFile()));
}
return $this->routeBuilder;
} | php | public function getRouteBuilder()
{
if (null == $this->routeBuilder) {
$this->setRouteBuilder(new RouteBuilder($this->getRouteFile()));
}
return $this->routeBuilder;
} | [
"public",
"function",
"getRouteBuilder",
"(",
")",
"{",
"if",
"(",
"null",
"==",
"$",
"this",
"->",
"routeBuilder",
")",
"{",
"$",
"this",
"->",
"setRouteBuilder",
"(",
"new",
"RouteBuilder",
"(",
"$",
"this",
"->",
"getRouteFile",
"(",
")",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"routeBuilder",
";",
"}"
] | Get route builder
@return RouteBuilder | [
"Get",
"route",
"builder"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Router.php#L125-L131 |
8,084 | 20TRIES/date_range | src/DateRange.php | DateRange.forTimePeriod | public static function forTimePeriod($time_period, Carbon $date_time)
{
$time_period = self::parseTimePeriod($time_period);
switch ($time_period) {
case self::HOUR:
return static::between(
$date_time->copy()->minute(0)->second(0),
$date_time->copy()->minute(59)->second(59)
);
default:
return static::between(
$date_time->copy()->{"startOf{$time_period}"}(),
$date_time->copy()->{"endOf{$time_period}"}()
);
}
} | php | public static function forTimePeriod($time_period, Carbon $date_time)
{
$time_period = self::parseTimePeriod($time_period);
switch ($time_period) {
case self::HOUR:
return static::between(
$date_time->copy()->minute(0)->second(0),
$date_time->copy()->minute(59)->second(59)
);
default:
return static::between(
$date_time->copy()->{"startOf{$time_period}"}(),
$date_time->copy()->{"endOf{$time_period}"}()
);
}
} | [
"public",
"static",
"function",
"forTimePeriod",
"(",
"$",
"time_period",
",",
"Carbon",
"$",
"date_time",
")",
"{",
"$",
"time_period",
"=",
"self",
"::",
"parseTimePeriod",
"(",
"$",
"time_period",
")",
";",
"switch",
"(",
"$",
"time_period",
")",
"{",
"case",
"self",
"::",
"HOUR",
":",
"return",
"static",
"::",
"between",
"(",
"$",
"date_time",
"->",
"copy",
"(",
")",
"->",
"minute",
"(",
"0",
")",
"->",
"second",
"(",
"0",
")",
",",
"$",
"date_time",
"->",
"copy",
"(",
")",
"->",
"minute",
"(",
"59",
")",
"->",
"second",
"(",
"59",
")",
")",
";",
"default",
":",
"return",
"static",
"::",
"between",
"(",
"$",
"date_time",
"->",
"copy",
"(",
")",
"->",
"{",
"\"startOf{$time_period}\"",
"}",
"(",
")",
",",
"$",
"date_time",
"->",
"copy",
"(",
")",
"->",
"{",
"\"endOf{$time_period}\"",
"}",
"(",
")",
")",
";",
"}",
"}"
] | Gets a date range for a time period.
@param string $time_period
@param Carbon $date_time
@return static | [
"Gets",
"a",
"date",
"range",
"for",
"a",
"time",
"period",
"."
] | c03099d81fe6ea348f68c2cdaa7f6b39e8efb196 | https://github.com/20TRIES/date_range/blob/c03099d81fe6ea348f68c2cdaa7f6b39e8efb196/src/DateRange.php#L224-L239 |
8,085 | 20TRIES/date_range | src/DateRange.php | DateRange.spans | public function spans($time_period)
{
$time_period = self::parseTimePeriod($time_period);
// If the date range does not have a bound then it will not span any time periods.
if (! $this->isBounded()) {
return false;
}
// After must be positioned at the end of the time period
$end = self::forTimePeriod($time_period, $this->after)->end();
if (! $end->eq($this->after)) {
return;
}
// Before must be positioned at the start of the time period
$start = self::forTimePeriod($time_period, $this->before)->start();
if (! $start->eq($this->before)) {
return;
}
// The start of the date range should equal the end of the date range set back to the start of its time period.
// This ensures that the range spans only a single time period; otherwise if we only checked the bounds, they
// could be two or more time periods apart.
if (! self::forTimePeriod($time_period, $this->end())->start()->eq($this->start())) {
return;
}
return $this->start();
} | php | public function spans($time_period)
{
$time_period = self::parseTimePeriod($time_period);
// If the date range does not have a bound then it will not span any time periods.
if (! $this->isBounded()) {
return false;
}
// After must be positioned at the end of the time period
$end = self::forTimePeriod($time_period, $this->after)->end();
if (! $end->eq($this->after)) {
return;
}
// Before must be positioned at the start of the time period
$start = self::forTimePeriod($time_period, $this->before)->start();
if (! $start->eq($this->before)) {
return;
}
// The start of the date range should equal the end of the date range set back to the start of its time period.
// This ensures that the range spans only a single time period; otherwise if we only checked the bounds, they
// could be two or more time periods apart.
if (! self::forTimePeriod($time_period, $this->end())->start()->eq($this->start())) {
return;
}
return $this->start();
} | [
"public",
"function",
"spans",
"(",
"$",
"time_period",
")",
"{",
"$",
"time_period",
"=",
"self",
"::",
"parseTimePeriod",
"(",
"$",
"time_period",
")",
";",
"// If the date range does not have a bound then it will not span any time periods.",
"if",
"(",
"!",
"$",
"this",
"->",
"isBounded",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"// After must be positioned at the end of the time period",
"$",
"end",
"=",
"self",
"::",
"forTimePeriod",
"(",
"$",
"time_period",
",",
"$",
"this",
"->",
"after",
")",
"->",
"end",
"(",
")",
";",
"if",
"(",
"!",
"$",
"end",
"->",
"eq",
"(",
"$",
"this",
"->",
"after",
")",
")",
"{",
"return",
";",
"}",
"// Before must be positioned at the start of the time period",
"$",
"start",
"=",
"self",
"::",
"forTimePeriod",
"(",
"$",
"time_period",
",",
"$",
"this",
"->",
"before",
")",
"->",
"start",
"(",
")",
";",
"if",
"(",
"!",
"$",
"start",
"->",
"eq",
"(",
"$",
"this",
"->",
"before",
")",
")",
"{",
"return",
";",
"}",
"// The start of the date range should equal the end of the date range set back to the start of its time period.",
"// This ensures that the range spans only a single time period; otherwise if we only checked the bounds, they",
"// could be two or more time periods apart.",
"if",
"(",
"!",
"self",
"::",
"forTimePeriod",
"(",
"$",
"time_period",
",",
"$",
"this",
"->",
"end",
"(",
")",
")",
"->",
"start",
"(",
")",
"->",
"eq",
"(",
"$",
"this",
"->",
"start",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"return",
"$",
"this",
"->",
"start",
"(",
")",
";",
"}"
] | Determines if a date range spans exactly one entire time period.
@param $time_period
@return Carbon|boolean The beginning of the time period, or null. | [
"Determines",
"if",
"a",
"date",
"range",
"spans",
"exactly",
"one",
"entire",
"time",
"period",
"."
] | c03099d81fe6ea348f68c2cdaa7f6b39e8efb196 | https://github.com/20TRIES/date_range/blob/c03099d81fe6ea348f68c2cdaa7f6b39e8efb196/src/DateRange.php#L446-L475 |
8,086 | 20TRIES/date_range | src/DateRange.php | DateRange.getTimeperiod | public function getTimeperiod()
{
foreach (array_keys(self::$time_periods) as $time_period) {
if (!is_null($this->spans($time_period))) {
return $time_period;
}
}
return;
} | php | public function getTimeperiod()
{
foreach (array_keys(self::$time_periods) as $time_period) {
if (!is_null($this->spans($time_period))) {
return $time_period;
}
}
return;
} | [
"public",
"function",
"getTimeperiod",
"(",
")",
"{",
"foreach",
"(",
"array_keys",
"(",
"self",
"::",
"$",
"time_periods",
")",
"as",
"$",
"time_period",
")",
"{",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"spans",
"(",
"$",
"time_period",
")",
")",
")",
"{",
"return",
"$",
"time_period",
";",
"}",
"}",
"return",
";",
"}"
] | Determines the time period that a date range spans.
@return string|null A string which corresponds to a class constant time period
or null if the date range does not match any supported time spans. | [
"Determines",
"the",
"time",
"period",
"that",
"a",
"date",
"range",
"spans",
"."
] | c03099d81fe6ea348f68c2cdaa7f6b39e8efb196 | https://github.com/20TRIES/date_range/blob/c03099d81fe6ea348f68c2cdaa7f6b39e8efb196/src/DateRange.php#L483-L492 |
8,087 | 20TRIES/date_range | src/DateRange.php | DateRange.isOpenEnded | public function isOpenEnded()
{
return is_null($this->before) || (!is_null($this->after) && $this->before->lte($this->after));
} | php | public function isOpenEnded()
{
return is_null($this->before) || (!is_null($this->after) && $this->before->lte($this->after));
} | [
"public",
"function",
"isOpenEnded",
"(",
")",
"{",
"return",
"is_null",
"(",
"$",
"this",
"->",
"before",
")",
"||",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"after",
")",
"&&",
"$",
"this",
"->",
"before",
"->",
"lte",
"(",
"$",
"this",
"->",
"after",
")",
")",
";",
"}"
] | Determines if a date range has an upper bound.
@return bool | [
"Determines",
"if",
"a",
"date",
"range",
"has",
"an",
"upper",
"bound",
"."
] | c03099d81fe6ea348f68c2cdaa7f6b39e8efb196 | https://github.com/20TRIES/date_range/blob/c03099d81fe6ea348f68c2cdaa7f6b39e8efb196/src/DateRange.php#L499-L502 |
8,088 | 20TRIES/date_range | src/DateRange.php | DateRange.combine | public static function combine(array $ranges)
{
$range = new static();
foreach ($ranges as $cur_range) {
$cur_start = $cur_range->after;
$cur_end = $cur_range->before;
if (is_null($range->before) || $cur_end->lt($range->before)) {
$range->before = $cur_end;
}
if (is_null($range->after) || $cur_start->gt($range->after)) {
$range->after = $cur_start;
}
}
return $range;
} | php | public static function combine(array $ranges)
{
$range = new static();
foreach ($ranges as $cur_range) {
$cur_start = $cur_range->after;
$cur_end = $cur_range->before;
if (is_null($range->before) || $cur_end->lt($range->before)) {
$range->before = $cur_end;
}
if (is_null($range->after) || $cur_start->gt($range->after)) {
$range->after = $cur_start;
}
}
return $range;
} | [
"public",
"static",
"function",
"combine",
"(",
"array",
"$",
"ranges",
")",
"{",
"$",
"range",
"=",
"new",
"static",
"(",
")",
";",
"foreach",
"(",
"$",
"ranges",
"as",
"$",
"cur_range",
")",
"{",
"$",
"cur_start",
"=",
"$",
"cur_range",
"->",
"after",
";",
"$",
"cur_end",
"=",
"$",
"cur_range",
"->",
"before",
";",
"if",
"(",
"is_null",
"(",
"$",
"range",
"->",
"before",
")",
"||",
"$",
"cur_end",
"->",
"lt",
"(",
"$",
"range",
"->",
"before",
")",
")",
"{",
"$",
"range",
"->",
"before",
"=",
"$",
"cur_end",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"range",
"->",
"after",
")",
"||",
"$",
"cur_start",
"->",
"gt",
"(",
"$",
"range",
"->",
"after",
")",
")",
"{",
"$",
"range",
"->",
"after",
"=",
"$",
"cur_start",
";",
"}",
"}",
"return",
"$",
"range",
";",
"}"
] | Combines a collection of date ranges into a single date range.
@param DateRange[] $ranges
@return DateRange
@TODO Doesn't support open started or open ended ranges.
@TODO Doesn't support non-intersecting ranges.
@TODO Look at the possibility of implementing an "inersect" method instead. | [
"Combines",
"a",
"collection",
"of",
"date",
"ranges",
"into",
"a",
"single",
"date",
"range",
"."
] | c03099d81fe6ea348f68c2cdaa7f6b39e8efb196 | https://github.com/20TRIES/date_range/blob/c03099d81fe6ea348f68c2cdaa7f6b39e8efb196/src/DateRange.php#L516-L534 |
8,089 | 20TRIES/date_range | src/DateRange.php | DateRange.days | public function days()
{
if ($this->isOpenEnded() || $this->isOpenStarted()) {
throw new Exception('The number of days within a range cannot be calculated for ranges that are open ended or open started.');
}
return $this->after->diffInDays($this->before);
} | php | public function days()
{
if ($this->isOpenEnded() || $this->isOpenStarted()) {
throw new Exception('The number of days within a range cannot be calculated for ranges that are open ended or open started.');
}
return $this->after->diffInDays($this->before);
} | [
"public",
"function",
"days",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isOpenEnded",
"(",
")",
"||",
"$",
"this",
"->",
"isOpenStarted",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'The number of days within a range cannot be calculated for ranges that are open ended or open started.'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"after",
"->",
"diffInDays",
"(",
"$",
"this",
"->",
"before",
")",
";",
"}"
] | Gets the number of days that a date range spans.
This is not possible, for obvious reasons, on open ended or open start date ranges.
@throws Exception
@return int | [
"Gets",
"the",
"number",
"of",
"days",
"that",
"a",
"date",
"range",
"spans",
"."
] | c03099d81fe6ea348f68c2cdaa7f6b39e8efb196 | https://github.com/20TRIES/date_range/blob/c03099d81fe6ea348f68c2cdaa7f6b39e8efb196/src/DateRange.php#L545-L552 |
8,090 | 20TRIES/date_range | src/DateRange.php | DateRange.isOpenStarted | public function isOpenStarted()
{
return is_null($this->after) || (!is_null($this->before) && $this->before->lte($this->after));
} | php | public function isOpenStarted()
{
return is_null($this->after) || (!is_null($this->before) && $this->before->lte($this->after));
} | [
"public",
"function",
"isOpenStarted",
"(",
")",
"{",
"return",
"is_null",
"(",
"$",
"this",
"->",
"after",
")",
"||",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"before",
")",
"&&",
"$",
"this",
"->",
"before",
"->",
"lte",
"(",
"$",
"this",
"->",
"after",
")",
")",
";",
"}"
] | Determines if a date range has a lower bound.
@return bool | [
"Determines",
"if",
"a",
"date",
"range",
"has",
"a",
"lower",
"bound",
"."
] | c03099d81fe6ea348f68c2cdaa7f6b39e8efb196 | https://github.com/20TRIES/date_range/blob/c03099d81fe6ea348f68c2cdaa7f6b39e8efb196/src/DateRange.php#L559-L562 |
8,091 | 20TRIES/date_range | src/DateRange.php | DateRange.getDatePositionIn | protected function getDatePositionIn(Carbon $date_time, $time_period)
{
// First we need to validate the time period.
if (!array_key_exists($time_period, self::$time_periods)) {
throw new \InvalidArgumentException('Time period must be one of the time periods listed in the class constants');
}
// Now we will check to see whether the date is positioned at the beginning of the time
// period provided.
$start_date = self::forTimePeriod($time_period, $date_time)->start();
if ($date_time->copy()->eq($start_date)) {
return self::START;
}
// Now we will check to see whether the date is positioned at the end of the time period
// provided.
$end_date = self::forTimePeriod($time_period, $date_time)->end();
if ($date_time->copy()->eq($end_date)) {
return self::END;
}
} | php | protected function getDatePositionIn(Carbon $date_time, $time_period)
{
// First we need to validate the time period.
if (!array_key_exists($time_period, self::$time_periods)) {
throw new \InvalidArgumentException('Time period must be one of the time periods listed in the class constants');
}
// Now we will check to see whether the date is positioned at the beginning of the time
// period provided.
$start_date = self::forTimePeriod($time_period, $date_time)->start();
if ($date_time->copy()->eq($start_date)) {
return self::START;
}
// Now we will check to see whether the date is positioned at the end of the time period
// provided.
$end_date = self::forTimePeriod($time_period, $date_time)->end();
if ($date_time->copy()->eq($end_date)) {
return self::END;
}
} | [
"protected",
"function",
"getDatePositionIn",
"(",
"Carbon",
"$",
"date_time",
",",
"$",
"time_period",
")",
"{",
"// First we need to validate the time period.",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"time_period",
",",
"self",
"::",
"$",
"time_periods",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Time period must be one of the time periods listed in the class constants'",
")",
";",
"}",
"// Now we will check to see whether the date is positioned at the beginning of the time",
"// period provided.",
"$",
"start_date",
"=",
"self",
"::",
"forTimePeriod",
"(",
"$",
"time_period",
",",
"$",
"date_time",
")",
"->",
"start",
"(",
")",
";",
"if",
"(",
"$",
"date_time",
"->",
"copy",
"(",
")",
"->",
"eq",
"(",
"$",
"start_date",
")",
")",
"{",
"return",
"self",
"::",
"START",
";",
"}",
"// Now we will check to see whether the date is positioned at the end of the time period",
"// provided.",
"$",
"end_date",
"=",
"self",
"::",
"forTimePeriod",
"(",
"$",
"time_period",
",",
"$",
"date_time",
")",
"->",
"end",
"(",
")",
";",
"if",
"(",
"$",
"date_time",
"->",
"copy",
"(",
")",
"->",
"eq",
"(",
"$",
"end_date",
")",
")",
"{",
"return",
"self",
"::",
"END",
";",
"}",
"}"
] | Determines a dates position within a time period.
@param Carbon $date_time
@param $time_period
@return string|null A class constant that represents a time period, or null. | [
"Determines",
"a",
"dates",
"position",
"within",
"a",
"time",
"period",
"."
] | c03099d81fe6ea348f68c2cdaa7f6b39e8efb196 | https://github.com/20TRIES/date_range/blob/c03099d81fe6ea348f68c2cdaa7f6b39e8efb196/src/DateRange.php#L673-L693 |
8,092 | 20TRIES/date_range | src/DateRange.php | DateRange.offsetMonthInDate | protected function offsetMonthInDate(Carbon $original_date, $offset)
{
$original_month = $original_date->month;
// Calculate expected month if offset is positive.
if ($offset >= 0 && ($original_month + $offset) <= 12) {
$expected_month = $original_month + $offset;
} elseif ($offset >= 0) {
$expected_month = 0 + ($offset - (12 - $original_month));
}
// Calculate expected month if offset is negative.
elseif ($offset < 0 && ($original_month + $offset) >= 1) {
$expected_month = $original_month + $offset;
} elseif ($offset < 0) {
$expected_month = 12 + ($offset + $original_month);
}
return $expected_month;
} | php | protected function offsetMonthInDate(Carbon $original_date, $offset)
{
$original_month = $original_date->month;
// Calculate expected month if offset is positive.
if ($offset >= 0 && ($original_month + $offset) <= 12) {
$expected_month = $original_month + $offset;
} elseif ($offset >= 0) {
$expected_month = 0 + ($offset - (12 - $original_month));
}
// Calculate expected month if offset is negative.
elseif ($offset < 0 && ($original_month + $offset) >= 1) {
$expected_month = $original_month + $offset;
} elseif ($offset < 0) {
$expected_month = 12 + ($offset + $original_month);
}
return $expected_month;
} | [
"protected",
"function",
"offsetMonthInDate",
"(",
"Carbon",
"$",
"original_date",
",",
"$",
"offset",
")",
"{",
"$",
"original_month",
"=",
"$",
"original_date",
"->",
"month",
";",
"// Calculate expected month if offset is positive.",
"if",
"(",
"$",
"offset",
">=",
"0",
"&&",
"(",
"$",
"original_month",
"+",
"$",
"offset",
")",
"<=",
"12",
")",
"{",
"$",
"expected_month",
"=",
"$",
"original_month",
"+",
"$",
"offset",
";",
"}",
"elseif",
"(",
"$",
"offset",
">=",
"0",
")",
"{",
"$",
"expected_month",
"=",
"0",
"+",
"(",
"$",
"offset",
"-",
"(",
"12",
"-",
"$",
"original_month",
")",
")",
";",
"}",
"// Calculate expected month if offset is negative.",
"elseif",
"(",
"$",
"offset",
"<",
"0",
"&&",
"(",
"$",
"original_month",
"+",
"$",
"offset",
")",
">=",
"1",
")",
"{",
"$",
"expected_month",
"=",
"$",
"original_month",
"+",
"$",
"offset",
";",
"}",
"elseif",
"(",
"$",
"offset",
"<",
"0",
")",
"{",
"$",
"expected_month",
"=",
"12",
"+",
"(",
"$",
"offset",
"+",
"$",
"original_month",
")",
";",
"}",
"return",
"$",
"expected_month",
";",
"}"
] | Offsets a month in a date by a set value; offsets >12 are not currently supported.
@param Carbon $original_date
@param $offset
@return bool
@TODO Add support for offsets greater then 12 for months. | [
"Offsets",
"a",
"month",
"in",
"a",
"date",
"by",
"a",
"set",
"value",
";",
"offsets",
">",
"12",
"are",
"not",
"currently",
"supported",
"."
] | c03099d81fe6ea348f68c2cdaa7f6b39e8efb196 | https://github.com/20TRIES/date_range/blob/c03099d81fe6ea348f68c2cdaa7f6b39e8efb196/src/DateRange.php#L705-L724 |
8,093 | 20TRIES/date_range | src/DateRange.php | DateRange.refactorRolledOverDate | protected function refactorRolledOverDate(Carbon $date, Carbon $original_date)
{
return $date
->subMonth()
->endOfMonth()
->setTime($original_date->hour, $original_date->minute, $original_date->second);
} | php | protected function refactorRolledOverDate(Carbon $date, Carbon $original_date)
{
return $date
->subMonth()
->endOfMonth()
->setTime($original_date->hour, $original_date->minute, $original_date->second);
} | [
"protected",
"function",
"refactorRolledOverDate",
"(",
"Carbon",
"$",
"date",
",",
"Carbon",
"$",
"original_date",
")",
"{",
"return",
"$",
"date",
"->",
"subMonth",
"(",
")",
"->",
"endOfMonth",
"(",
")",
"->",
"setTime",
"(",
"$",
"original_date",
"->",
"hour",
",",
"$",
"original_date",
"->",
"minute",
",",
"$",
"original_date",
"->",
"second",
")",
";",
"}"
] | Adjusts a date that has rolled over back to the previous month; setting the day
to the last day of the previous month; time values are maintained.
@param Carbon $date
@param Carbon $original_date
@return \DateTime | [
"Adjusts",
"a",
"date",
"that",
"has",
"rolled",
"over",
"back",
"to",
"the",
"previous",
"month",
";",
"setting",
"the",
"day",
"to",
"the",
"last",
"day",
"of",
"the",
"previous",
"month",
";",
"time",
"values",
"are",
"maintained",
"."
] | c03099d81fe6ea348f68c2cdaa7f6b39e8efb196 | https://github.com/20TRIES/date_range/blob/c03099d81fe6ea348f68c2cdaa7f6b39e8efb196/src/DateRange.php#L735-L741 |
8,094 | CatLabInteractive/Neuron | src/Neuron/Core/Template.php | Template.addPath | public static function addPath ($path, $prefix = '', $priority = 0)
{
if (substr ($path, -1) !== '/')
$path .= '/';
if ($prefix) {
$name = $prefix . '|' . $path;
}
else {
$name = $path;
}
// Set priority
self::$pathpriorities[$name] = $priority;
// Calculate the position based on priority.
$position = 0;
foreach (self::$paths as $path)
{
if (self::$pathpriorities[$path] < $priority)
{
break;
}
$position ++;
}
array_splice (self::$paths, $position, 0, array ($name));
} | php | public static function addPath ($path, $prefix = '', $priority = 0)
{
if (substr ($path, -1) !== '/')
$path .= '/';
if ($prefix) {
$name = $prefix . '|' . $path;
}
else {
$name = $path;
}
// Set priority
self::$pathpriorities[$name] = $priority;
// Calculate the position based on priority.
$position = 0;
foreach (self::$paths as $path)
{
if (self::$pathpriorities[$path] < $priority)
{
break;
}
$position ++;
}
array_splice (self::$paths, $position, 0, array ($name));
} | [
"public",
"static",
"function",
"addPath",
"(",
"$",
"path",
",",
"$",
"prefix",
"=",
"''",
",",
"$",
"priority",
"=",
"0",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"path",
",",
"-",
"1",
")",
"!==",
"'/'",
")",
"$",
"path",
".=",
"'/'",
";",
"if",
"(",
"$",
"prefix",
")",
"{",
"$",
"name",
"=",
"$",
"prefix",
".",
"'|'",
".",
"$",
"path",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"$",
"path",
";",
"}",
"// Set priority",
"self",
"::",
"$",
"pathpriorities",
"[",
"$",
"name",
"]",
"=",
"$",
"priority",
";",
"// Calculate the position based on priority.",
"$",
"position",
"=",
"0",
";",
"foreach",
"(",
"self",
"::",
"$",
"paths",
"as",
"$",
"path",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"pathpriorities",
"[",
"$",
"path",
"]",
"<",
"$",
"priority",
")",
"{",
"break",
";",
"}",
"$",
"position",
"++",
";",
"}",
"array_splice",
"(",
"self",
"::",
"$",
"paths",
",",
"$",
"position",
",",
"0",
",",
"array",
"(",
"$",
"name",
")",
")",
";",
"}"
] | Add a folder to the template path.
@param $path: path to add
@param $prefix: only templates starting with given prefix will be loaded from this path.
@param $priority | [
"Add",
"a",
"folder",
"to",
"the",
"template",
"path",
"."
] | 67dca5349891e23b31a96dcdead893b9491a1b8b | https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Core/Template.php#L99-L126 |
8,095 | CatLabInteractive/Neuron | src/Neuron/Core/Template.php | Template.getFilenames | private static function getFilenames ($template, $all = false)
{
$out = array ();
foreach (self::getPaths () as $v) {
// Split prefix and folder
$split = explode ('|', $v);
if (count ($split) === 2)
{
$prefix = array_shift ($split);
$folder = implode ('|', $split);
$templatefixed = substr ($template, 0, strlen ($prefix));
if ($templatefixed == $prefix)
{
$templaterest = substr ($template, strlen ($templatefixed));
if (is_readable ($folder . $templaterest))
{
$out[] = $folder . $templaterest;
if (!$all)
return $out;
}
}
}
else
{
if (is_readable ($v . $template))
{
$out[] = $v . $template;
if (!$all)
return $out;
}
}
}
if (count ($out) > 0)
{
return $out;
}
return false;
} | php | private static function getFilenames ($template, $all = false)
{
$out = array ();
foreach (self::getPaths () as $v) {
// Split prefix and folder
$split = explode ('|', $v);
if (count ($split) === 2)
{
$prefix = array_shift ($split);
$folder = implode ('|', $split);
$templatefixed = substr ($template, 0, strlen ($prefix));
if ($templatefixed == $prefix)
{
$templaterest = substr ($template, strlen ($templatefixed));
if (is_readable ($folder . $templaterest))
{
$out[] = $folder . $templaterest;
if (!$all)
return $out;
}
}
}
else
{
if (is_readable ($v . $template))
{
$out[] = $v . $template;
if (!$all)
return $out;
}
}
}
if (count ($out) > 0)
{
return $out;
}
return false;
} | [
"private",
"static",
"function",
"getFilenames",
"(",
"$",
"template",
",",
"$",
"all",
"=",
"false",
")",
"{",
"$",
"out",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"getPaths",
"(",
")",
"as",
"$",
"v",
")",
"{",
"// Split prefix and folder",
"$",
"split",
"=",
"explode",
"(",
"'|'",
",",
"$",
"v",
")",
";",
"if",
"(",
"count",
"(",
"$",
"split",
")",
"===",
"2",
")",
"{",
"$",
"prefix",
"=",
"array_shift",
"(",
"$",
"split",
")",
";",
"$",
"folder",
"=",
"implode",
"(",
"'|'",
",",
"$",
"split",
")",
";",
"$",
"templatefixed",
"=",
"substr",
"(",
"$",
"template",
",",
"0",
",",
"strlen",
"(",
"$",
"prefix",
")",
")",
";",
"if",
"(",
"$",
"templatefixed",
"==",
"$",
"prefix",
")",
"{",
"$",
"templaterest",
"=",
"substr",
"(",
"$",
"template",
",",
"strlen",
"(",
"$",
"templatefixed",
")",
")",
";",
"if",
"(",
"is_readable",
"(",
"$",
"folder",
".",
"$",
"templaterest",
")",
")",
"{",
"$",
"out",
"[",
"]",
"=",
"$",
"folder",
".",
"$",
"templaterest",
";",
"if",
"(",
"!",
"$",
"all",
")",
"return",
"$",
"out",
";",
"}",
"}",
"}",
"else",
"{",
"if",
"(",
"is_readable",
"(",
"$",
"v",
".",
"$",
"template",
")",
")",
"{",
"$",
"out",
"[",
"]",
"=",
"$",
"v",
".",
"$",
"template",
";",
"if",
"(",
"!",
"$",
"all",
")",
"return",
"$",
"out",
";",
"}",
"}",
"}",
"if",
"(",
"count",
"(",
"$",
"out",
")",
">",
"0",
")",
"{",
"return",
"$",
"out",
";",
"}",
"return",
"false",
";",
"}"
] | Return an array of all filenames, or FALSE if none are found.
@param $template
@param bool $all
@return bool|string | [
"Return",
"an",
"array",
"of",
"all",
"filenames",
"or",
"FALSE",
"if",
"none",
"are",
"found",
"."
] | 67dca5349891e23b31a96dcdead893b9491a1b8b | https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Core/Template.php#L211-L255 |
8,096 | CatLabInteractive/Neuron | src/Neuron/Core/Template.php | Template.combine | private function combine ($template)
{
ob_start();
foreach (self::$shares as $k => $v) {
${$k} = $v;
}
foreach ($this->values as $k => $v) {
${$k} = $v;
}
if ($ctlbtmpltfiles = $this->getFilenames($template, true)) {
foreach ($ctlbtmpltfiles as $ctlbtmpltfile) {
include $ctlbtmpltfile;
}
}
$val = ob_get_contents();
ob_end_clean();
return $val;
} | php | private function combine ($template)
{
ob_start();
foreach (self::$shares as $k => $v) {
${$k} = $v;
}
foreach ($this->values as $k => $v) {
${$k} = $v;
}
if ($ctlbtmpltfiles = $this->getFilenames($template, true)) {
foreach ($ctlbtmpltfiles as $ctlbtmpltfile) {
include $ctlbtmpltfile;
}
}
$val = ob_get_contents();
ob_end_clean();
return $val;
} | [
"private",
"function",
"combine",
"(",
"$",
"template",
")",
"{",
"ob_start",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"shares",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"{",
"$",
"k",
"}",
"=",
"$",
"v",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"values",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"{",
"$",
"k",
"}",
"=",
"$",
"v",
";",
"}",
"if",
"(",
"$",
"ctlbtmpltfiles",
"=",
"$",
"this",
"->",
"getFilenames",
"(",
"$",
"template",
",",
"true",
")",
")",
"{",
"foreach",
"(",
"$",
"ctlbtmpltfiles",
"as",
"$",
"ctlbtmpltfile",
")",
"{",
"include",
"$",
"ctlbtmpltfile",
";",
"}",
"}",
"$",
"val",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"return",
"$",
"val",
";",
"}"
] | Go trough all set template directories and search for
a specific template. Concat all of them. | [
"Go",
"trough",
"all",
"set",
"template",
"directories",
"and",
"search",
"for",
"a",
"specific",
"template",
".",
"Concat",
"all",
"of",
"them",
"."
] | 67dca5349891e23b31a96dcdead893b9491a1b8b | https://github.com/CatLabInteractive/Neuron/blob/67dca5349891e23b31a96dcdead893b9491a1b8b/src/Neuron/Core/Template.php#L338-L360 |
8,097 | mbrevda/aurasql-queryproxy | src/QueryProxy.php | QueryProxy.filter | public function filter()
{
$opts = func_get_args();
$callable = array_shift($opts);
// allow for a false call
if (!is_callable($callable)) {
return $this;
}
array_unshift($opts, $this);
return call_user_func_array($callable, $opts);
} | php | public function filter()
{
$opts = func_get_args();
$callable = array_shift($opts);
// allow for a false call
if (!is_callable($callable)) {
return $this;
}
array_unshift($opts, $this);
return call_user_func_array($callable, $opts);
} | [
"public",
"function",
"filter",
"(",
")",
"{",
"$",
"opts",
"=",
"func_get_args",
"(",
")",
";",
"$",
"callable",
"=",
"array_shift",
"(",
"$",
"opts",
")",
";",
"// allow for a false call",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callable",
")",
")",
"{",
"return",
"$",
"this",
";",
"}",
"array_unshift",
"(",
"$",
"opts",
",",
"$",
"this",
")",
";",
"return",
"call_user_func_array",
"(",
"$",
"callable",
",",
"$",
"opts",
")",
";",
"}"
] | Pass current instance to a callable for manipulation and return the
processed object
@param callable the callable that can minpulate $this
@param array $opts to be passed to the function.
will be prepeneded with $this
@retrun object $this | [
"Pass",
"current",
"instance",
"to",
"a",
"callable",
"for",
"manipulation",
"and",
"return",
"the",
"processed",
"object"
] | e8768a0c482c807aeb11324eea627f8b37cfc01d | https://github.com/mbrevda/aurasql-queryproxy/blob/e8768a0c482c807aeb11324eea627f8b37cfc01d/src/QueryProxy.php#L110-L122 |
8,098 | iriber/cose | src/main/php/Cose/persistence/PersistenceContext.php | PersistenceContext.rollback | public function rollback($unitName=""){
if(empty($unitName))
$unitName = PersistenceConfig::getDefaultUnit();
$entityManager = self::getEntityManager( $unitName );
$entityManager->getConnection()->rollback();
} | php | public function rollback($unitName=""){
if(empty($unitName))
$unitName = PersistenceConfig::getDefaultUnit();
$entityManager = self::getEntityManager( $unitName );
$entityManager->getConnection()->rollback();
} | [
"public",
"function",
"rollback",
"(",
"$",
"unitName",
"=",
"\"\"",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"unitName",
")",
")",
"$",
"unitName",
"=",
"PersistenceConfig",
"::",
"getDefaultUnit",
"(",
")",
";",
"$",
"entityManager",
"=",
"self",
"::",
"getEntityManager",
"(",
"$",
"unitName",
")",
";",
"$",
"entityManager",
"->",
"getConnection",
"(",
")",
"->",
"rollback",
"(",
")",
";",
"}"
] | se realiza el rolback sobre la unidad de persistencia indicada.
si no se indica ninguna se toma la default.
@param string $unitName nombre de la unidad de persistencia. | [
"se",
"realiza",
"el",
"rolback",
"sobre",
"la",
"unidad",
"de",
"persistencia",
"indicada",
".",
"si",
"no",
"se",
"indica",
"ninguna",
"se",
"toma",
"la",
"default",
"."
] | 291ea274a86017bac173fdc7bfcd4fb13419679e | https://github.com/iriber/cose/blob/291ea274a86017bac173fdc7bfcd4fb13419679e/src/main/php/Cose/persistence/PersistenceContext.php#L111-L119 |
8,099 | JumpGateio/ViewResolution | src/JumpGate/ViewResolution/Resolvers/Path.php | Path.setPath | protected function setPath($view)
{
$this->viewModel = new ViewModel([], $this->layout->getName());
if ($view == null) {
$view = $this->findView();
}
$this->viewModel->view = $view;
viewResolver()->collectDetails($this->viewModel);
$this->path = $view;
} | php | protected function setPath($view)
{
$this->viewModel = new ViewModel([], $this->layout->getName());
if ($view == null) {
$view = $this->findView();
}
$this->viewModel->view = $view;
viewResolver()->collectDetails($this->viewModel);
$this->path = $view;
} | [
"protected",
"function",
"setPath",
"(",
"$",
"view",
")",
"{",
"$",
"this",
"->",
"viewModel",
"=",
"new",
"ViewModel",
"(",
"[",
"]",
",",
"$",
"this",
"->",
"layout",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"view",
"==",
"null",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"findView",
"(",
")",
";",
"}",
"$",
"this",
"->",
"viewModel",
"->",
"view",
"=",
"$",
"view",
";",
"viewResolver",
"(",
")",
"->",
"collectDetails",
"(",
"$",
"this",
"->",
"viewModel",
")",
";",
"$",
"this",
"->",
"path",
"=",
"$",
"view",
";",
"}"
] | Get a valid view path save it.
@param $view | [
"Get",
"a",
"valid",
"view",
"path",
"save",
"it",
"."
] | 49339e160db55876ca2a8fbe15bb3e26148b33f2 | https://github.com/JumpGateio/ViewResolution/blob/49339e160db55876ca2a8fbe15bb3e26148b33f2/src/JumpGate/ViewResolution/Resolvers/Path.php#L69-L82 |
Subsets and Splits