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
|
---|---|---|---|---|---|---|---|---|---|---|---|
700 | cityware/city-parallel-jobs | src/ForkManager.php | ForkManager.runJob | protected function runJob() {
if (isset($this->callbackChildren[$this->uid])) {
$callback = $this->callbackChildren[$this->uid];
$result = $callback->call($this->callbackParamChildren[$this->uid]);
} else if ($this->callback) {
$result = $this->callback->call($this->callbackParam);
} else {
$result = null; // no job
}
if ($this->getShareResult()) {
$this->getStorage()->write($this->uid, $result);
}
posix_kill($this->pid, 9);
} | php | protected function runJob() {
if (isset($this->callbackChildren[$this->uid])) {
$callback = $this->callbackChildren[$this->uid];
$result = $callback->call($this->callbackParamChildren[$this->uid]);
} else if ($this->callback) {
$result = $this->callback->call($this->callbackParam);
} else {
$result = null; // no job
}
if ($this->getShareResult()) {
$this->getStorage()->write($this->uid, $result);
}
posix_kill($this->pid, 9);
} | [
"protected",
"function",
"runJob",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"callbackChildren",
"[",
"$",
"this",
"->",
"uid",
"]",
")",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"callbackChildren",
"[",
"$",
"this",
"->",
"uid",
"]",
";",
"$",
"result",
"=",
"$",
"callback",
"->",
"call",
"(",
"$",
"this",
"->",
"callbackParamChildren",
"[",
"$",
"this",
"->",
"uid",
"]",
")",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"callback",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"callback",
"->",
"call",
"(",
"$",
"this",
"->",
"callbackParam",
")",
";",
"}",
"else",
"{",
"$",
"result",
"=",
"null",
";",
"// no job",
"}",
"if",
"(",
"$",
"this",
"->",
"getShareResult",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getStorage",
"(",
")",
"->",
"write",
"(",
"$",
"this",
"->",
"uid",
",",
"$",
"result",
")",
";",
"}",
"posix_kill",
"(",
"$",
"this",
"->",
"pid",
",",
"9",
")",
";",
"}"
] | Run the fork job | [
"Run",
"the",
"fork",
"job"
] | 587d3cea9c765a3bb32d9642fed30a8b12cc6aa2 | https://github.com/cityware/city-parallel-jobs/blob/587d3cea9c765a3bb32d9642fed30a8b12cc6aa2/src/ForkManager.php#L227-L240 |
701 | cityware/city-parallel-jobs | src/ForkManager.php | ForkManager.doTheJob | public function doTheJob($callback, $params = array()) {
if (!$callback instanceof CallbackHandler) {
$callback = new CallbackHandler($callback);
}
if (!is_array($params)) {
$params = array($params);
}
$this->callback = $callback;
$this->callbackParam = $params;
return $this;
} | php | public function doTheJob($callback, $params = array()) {
if (!$callback instanceof CallbackHandler) {
$callback = new CallbackHandler($callback);
}
if (!is_array($params)) {
$params = array($params);
}
$this->callback = $callback;
$this->callbackParam = $params;
return $this;
} | [
"public",
"function",
"doTheJob",
"(",
"$",
"callback",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"callback",
"instanceof",
"CallbackHandler",
")",
"{",
"$",
"callback",
"=",
"new",
"CallbackHandler",
"(",
"$",
"callback",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"$",
"params",
")",
";",
"}",
"$",
"this",
"->",
"callback",
"=",
"$",
"callback",
";",
"$",
"this",
"->",
"callbackParam",
"=",
"$",
"params",
";",
"return",
"$",
"this",
";",
"}"
] | Set default jobs
@param mixed $callback
@param mixed $params | [
"Set",
"default",
"jobs"
] | 587d3cea9c765a3bb32d9642fed30a8b12cc6aa2 | https://github.com/cityware/city-parallel-jobs/blob/587d3cea9c765a3bb32d9642fed30a8b12cc6aa2/src/ForkManager.php#L247-L257 |
702 | cityware/city-parallel-jobs | src/ForkManager.php | ForkManager.doTheJobChild | public function doTheJobChild($num, $callback, $params = array()) {
if (!$callback instanceof CallbackHandler) {
$callback = new CallbackHandler($callback);
}
if (!is_array($params)) {
$params = array($params);
}
$this->callbackChildren[$num] = $callback;
$this->callbackParamChildren[$num] = $params;
return $this;
} | php | public function doTheJobChild($num, $callback, $params = array()) {
if (!$callback instanceof CallbackHandler) {
$callback = new CallbackHandler($callback);
}
if (!is_array($params)) {
$params = array($params);
}
$this->callbackChildren[$num] = $callback;
$this->callbackParamChildren[$num] = $params;
return $this;
} | [
"public",
"function",
"doTheJobChild",
"(",
"$",
"num",
",",
"$",
"callback",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"$",
"callback",
"instanceof",
"CallbackHandler",
")",
"{",
"$",
"callback",
"=",
"new",
"CallbackHandler",
"(",
"$",
"callback",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"$",
"params",
")",
";",
"}",
"$",
"this",
"->",
"callbackChildren",
"[",
"$",
"num",
"]",
"=",
"$",
"callback",
";",
"$",
"this",
"->",
"callbackParamChildren",
"[",
"$",
"num",
"]",
"=",
"$",
"params",
";",
"return",
"$",
"this",
";",
"}"
] | Set cild jobs
@param mixed $callback
@param mixed $params | [
"Set",
"cild",
"jobs"
] | 587d3cea9c765a3bb32d9642fed30a8b12cc6aa2 | https://github.com/cityware/city-parallel-jobs/blob/587d3cea9c765a3bb32d9642fed30a8b12cc6aa2/src/ForkManager.php#L264-L274 |
703 | cityware/city-parallel-jobs | src/ForkManager.php | ForkManager.handler | public function handler($signal) {
switch ($signal) {
case SIGALRM :
$this->isStopped = true;
$this->closeChildren();
break;
case SIGINT :
case SIGKILL :
$this->broadcast($signal);
exit;
default: break;
}
} | php | public function handler($signal) {
switch ($signal) {
case SIGALRM :
$this->isStopped = true;
$this->closeChildren();
break;
case SIGINT :
case SIGKILL :
$this->broadcast($signal);
exit;
default: break;
}
} | [
"public",
"function",
"handler",
"(",
"$",
"signal",
")",
"{",
"switch",
"(",
"$",
"signal",
")",
"{",
"case",
"SIGALRM",
":",
"$",
"this",
"->",
"isStopped",
"=",
"true",
";",
"$",
"this",
"->",
"closeChildren",
"(",
")",
";",
"break",
";",
"case",
"SIGINT",
":",
"case",
"SIGKILL",
":",
"$",
"this",
"->",
"broadcast",
"(",
"$",
"signal",
")",
";",
"exit",
";",
"default",
":",
"break",
";",
"}",
"}"
] | ISignal handler.
@param integer $signal signal number | [
"ISignal",
"handler",
"."
] | 587d3cea9c765a3bb32d9642fed30a8b12cc6aa2 | https://github.com/cityware/city-parallel-jobs/blob/587d3cea9c765a3bb32d9642fed30a8b12cc6aa2/src/ForkManager.php#L281-L293 |
704 | cityware/city-parallel-jobs | src/ForkManager.php | ForkManager.getSharedResults | public function getSharedResults() {
if (!$this->shareResult) {
return false;
}
if (!$this->isStarted) {
return false;
}
if (!$this->isFinished) {
trigger_error('children process was not interrupted', E_USER_NOTICE);
return false;
}
$resultsContainer = $this->getDefaultResultsContainer();
$results = new $resultsContainer();
foreach ($this->handlers as $uid => $handler) {
$resultContainer = $this->getDefaultResultContainer();
$result = new $resultContainer();
$result->setUid($uid);
$result->setPid($handler);
$result->setResult($this->getStorage()->read($uid));
$results->addResult($uid, $result);
}
return $results;
} | php | public function getSharedResults() {
if (!$this->shareResult) {
return false;
}
if (!$this->isStarted) {
return false;
}
if (!$this->isFinished) {
trigger_error('children process was not interrupted', E_USER_NOTICE);
return false;
}
$resultsContainer = $this->getDefaultResultsContainer();
$results = new $resultsContainer();
foreach ($this->handlers as $uid => $handler) {
$resultContainer = $this->getDefaultResultContainer();
$result = new $resultContainer();
$result->setUid($uid);
$result->setPid($handler);
$result->setResult($this->getStorage()->read($uid));
$results->addResult($uid, $result);
}
return $results;
} | [
"public",
"function",
"getSharedResults",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"shareResult",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isStarted",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"isFinished",
")",
"{",
"trigger_error",
"(",
"'children process was not interrupted'",
",",
"E_USER_NOTICE",
")",
";",
"return",
"false",
";",
"}",
"$",
"resultsContainer",
"=",
"$",
"this",
"->",
"getDefaultResultsContainer",
"(",
")",
";",
"$",
"results",
"=",
"new",
"$",
"resultsContainer",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"handlers",
"as",
"$",
"uid",
"=>",
"$",
"handler",
")",
"{",
"$",
"resultContainer",
"=",
"$",
"this",
"->",
"getDefaultResultContainer",
"(",
")",
";",
"$",
"result",
"=",
"new",
"$",
"resultContainer",
"(",
")",
";",
"$",
"result",
"->",
"setUid",
"(",
"$",
"uid",
")",
";",
"$",
"result",
"->",
"setPid",
"(",
"$",
"handler",
")",
";",
"$",
"result",
"->",
"setResult",
"(",
"$",
"this",
"->",
"getStorage",
"(",
")",
"->",
"read",
"(",
"$",
"uid",
")",
")",
";",
"$",
"results",
"->",
"addResult",
"(",
"$",
"uid",
",",
"$",
"result",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] | Close all children | [
"Close",
"all",
"children"
] | 587d3cea9c765a3bb32d9642fed30a8b12cc6aa2 | https://github.com/cityware/city-parallel-jobs/blob/587d3cea9c765a3bb32d9642fed30a8b12cc6aa2/src/ForkManager.php#L320-L345 |
705 | cityware/city-parallel-jobs | src/ForkManager.php | ForkManager.setShareResult | public function setShareResult($b) {
if ($this->isStarted) {
throw new Exception\RuntimeException('Invalid timeout value');
}
$this->shareResult = $b;
return $this;
} | php | public function setShareResult($b) {
if ($this->isStarted) {
throw new Exception\RuntimeException('Invalid timeout value');
}
$this->shareResult = $b;
return $this;
} | [
"public",
"function",
"setShareResult",
"(",
"$",
"b",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isStarted",
")",
"{",
"throw",
"new",
"Exception",
"\\",
"RuntimeException",
"(",
"'Invalid timeout value'",
")",
";",
"}",
"$",
"this",
"->",
"shareResult",
"=",
"$",
"b",
";",
"return",
"$",
"this",
";",
"}"
] | Set flag to share result
@param bool $b
@return ForkManager | [
"Set",
"flag",
"to",
"share",
"result"
] | 587d3cea9c765a3bb32d9642fed30a8b12cc6aa2 | https://github.com/cityware/city-parallel-jobs/blob/587d3cea9c765a3bb32d9642fed30a8b12cc6aa2/src/ForkManager.php#L427-L433 |
706 | encorephp/container | src/Container.php | Container.addProvider | public function addProvider($provider)
{
if (is_string($provider)) {
$provider = new $provider($this);
}
// Only allow a service provider to be registered
// once.
if (in_array($provider, $this->providers)) {
return;
}
$this->providers[] = $provider;
$this->registerEvents($provider);
$this->registerProvides($provider);
$this->registerProvider($provider);
} | php | public function addProvider($provider)
{
if (is_string($provider)) {
$provider = new $provider($this);
}
// Only allow a service provider to be registered
// once.
if (in_array($provider, $this->providers)) {
return;
}
$this->providers[] = $provider;
$this->registerEvents($provider);
$this->registerProvides($provider);
$this->registerProvider($provider);
} | [
"public",
"function",
"addProvider",
"(",
"$",
"provider",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"provider",
")",
")",
"{",
"$",
"provider",
"=",
"new",
"$",
"provider",
"(",
"$",
"this",
")",
";",
"}",
"// Only allow a service provider to be registered",
"// once.",
"if",
"(",
"in_array",
"(",
"$",
"provider",
",",
"$",
"this",
"->",
"providers",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"providers",
"[",
"]",
"=",
"$",
"provider",
";",
"$",
"this",
"->",
"registerEvents",
"(",
"$",
"provider",
")",
";",
"$",
"this",
"->",
"registerProvides",
"(",
"$",
"provider",
")",
";",
"$",
"this",
"->",
"registerProvider",
"(",
"$",
"provider",
")",
";",
"}"
] | Add a service provider to the application.
@param mixed $provider
@return void | [
"Add",
"a",
"service",
"provider",
"to",
"the",
"application",
"."
] | 49cb0b34fef912a9df962c5d4968a8e740eda4e8 | https://github.com/encorephp/container/blob/49cb0b34fef912a9df962c5d4968a8e740eda4e8/src/Container.php#L95-L113 |
707 | encorephp/container | src/Container.php | Container.registerProvidersFor | public function registerProvidersFor($binding)
{
foreach ($this->provides($binding) as $provider) {
$this->registerProvider($provider, true, $binding);
}
} | php | public function registerProvidersFor($binding)
{
foreach ($this->provides($binding) as $provider) {
$this->registerProvider($provider, true, $binding);
}
} | [
"public",
"function",
"registerProvidersFor",
"(",
"$",
"binding",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"provides",
"(",
"$",
"binding",
")",
"as",
"$",
"provider",
")",
"{",
"$",
"this",
"->",
"registerProvider",
"(",
"$",
"provider",
",",
"true",
",",
"$",
"binding",
")",
";",
"}",
"}"
] | Register the service providers for a specific binding
@param string $binding The name of binding.
@return void | [
"Register",
"the",
"service",
"providers",
"for",
"a",
"specific",
"binding"
] | 49cb0b34fef912a9df962c5d4968a8e740eda4e8 | https://github.com/encorephp/container/blob/49cb0b34fef912a9df962c5d4968a8e740eda4e8/src/Container.php#L204-L209 |
708 | encorephp/container | src/Container.php | Container.registerEvents | protected function registerEvents(ServiceProvider $provider)
{
if ( ! isset($this->event)) return;
foreach ($provider->when() as $event) {
$this->event->listen($event, function() use ($provider) {
$this->registerProvider($provider, true);
});
}
} | php | protected function registerEvents(ServiceProvider $provider)
{
if ( ! isset($this->event)) return;
foreach ($provider->when() as $event) {
$this->event->listen($event, function() use ($provider) {
$this->registerProvider($provider, true);
});
}
} | [
"protected",
"function",
"registerEvents",
"(",
"ServiceProvider",
"$",
"provider",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"event",
")",
")",
"return",
";",
"foreach",
"(",
"$",
"provider",
"->",
"when",
"(",
")",
"as",
"$",
"event",
")",
"{",
"$",
"this",
"->",
"event",
"->",
"listen",
"(",
"$",
"event",
",",
"function",
"(",
")",
"use",
"(",
"$",
"provider",
")",
"{",
"$",
"this",
"->",
"registerProvider",
"(",
"$",
"provider",
",",
"true",
")",
";",
"}",
")",
";",
"}",
"}"
] | Register the events that register the specified provider
@param ServiceProvider $provider The service provider object.
@return void | [
"Register",
"the",
"events",
"that",
"register",
"the",
"specified",
"provider"
] | 49cb0b34fef912a9df962c5d4968a8e740eda4e8 | https://github.com/encorephp/container/blob/49cb0b34fef912a9df962c5d4968a8e740eda4e8/src/Container.php#L400-L409 |
709 | encorephp/container | src/Container.php | Container.registerProvides | protected function registerProvides(ServiceProvider $provider)
{
foreach ($provider->provides() as $binding) {
$this->provides[$binding][] = $provider;
}
} | php | protected function registerProvides(ServiceProvider $provider)
{
foreach ($provider->provides() as $binding) {
$this->provides[$binding][] = $provider;
}
} | [
"protected",
"function",
"registerProvides",
"(",
"ServiceProvider",
"$",
"provider",
")",
"{",
"foreach",
"(",
"$",
"provider",
"->",
"provides",
"(",
")",
"as",
"$",
"binding",
")",
"{",
"$",
"this",
"->",
"provides",
"[",
"$",
"binding",
"]",
"[",
"]",
"=",
"$",
"provider",
";",
"}",
"}"
] | Remember the bindings that the specified service provider provides
@param ServiceProvider $provider The service provider object.
@return void | [
"Remember",
"the",
"bindings",
"that",
"the",
"specified",
"service",
"provider",
"provides"
] | 49cb0b34fef912a9df962c5d4968a8e740eda4e8 | https://github.com/encorephp/container/blob/49cb0b34fef912a9df962c5d4968a8e740eda4e8/src/Container.php#L445-L450 |
710 | apioo/psx-oauth2 | src/AuthorizationAbstract.php | AuthorizationAbstract.refreshToken | public function refreshToken(AccessToken $accessToken)
{
// request data
$refreshToken = $accessToken->getRefreshToken();
$scope = $accessToken->getScope();
if (empty($refreshToken)) {
throw new RuntimeException('No refresh token was set');
}
$data = array(
'grant_type' => 'refresh_token',
'refresh_token' => $refreshToken,
);
if (!empty($scope)) {
$data['scope'] = $scope;
}
// authentication
$header = array();
if ($this->type == self::AUTH_BASIC) {
$header['Authorization'] = 'Basic ' . base64_encode($this->clientId . ':' . $this->clientSecret);
}
if ($this->type == self::AUTH_POST) {
$data['client_id'] = $this->clientId;
$data['client_secret'] = $this->clientSecret;
}
$request = new PostRequest($this->url, $header, $data);
$response = $this->httpClient->request($request);
$data = Json\Parser::decode($response->getBody());
if ($response->getStatusCode() == 200) {
return $this->newToken($data);
} else {
throw new RuntimeException('Could not refresh access token');
}
} | php | public function refreshToken(AccessToken $accessToken)
{
// request data
$refreshToken = $accessToken->getRefreshToken();
$scope = $accessToken->getScope();
if (empty($refreshToken)) {
throw new RuntimeException('No refresh token was set');
}
$data = array(
'grant_type' => 'refresh_token',
'refresh_token' => $refreshToken,
);
if (!empty($scope)) {
$data['scope'] = $scope;
}
// authentication
$header = array();
if ($this->type == self::AUTH_BASIC) {
$header['Authorization'] = 'Basic ' . base64_encode($this->clientId . ':' . $this->clientSecret);
}
if ($this->type == self::AUTH_POST) {
$data['client_id'] = $this->clientId;
$data['client_secret'] = $this->clientSecret;
}
$request = new PostRequest($this->url, $header, $data);
$response = $this->httpClient->request($request);
$data = Json\Parser::decode($response->getBody());
if ($response->getStatusCode() == 200) {
return $this->newToken($data);
} else {
throw new RuntimeException('Could not refresh access token');
}
} | [
"public",
"function",
"refreshToken",
"(",
"AccessToken",
"$",
"accessToken",
")",
"{",
"// request data",
"$",
"refreshToken",
"=",
"$",
"accessToken",
"->",
"getRefreshToken",
"(",
")",
";",
"$",
"scope",
"=",
"$",
"accessToken",
"->",
"getScope",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"refreshToken",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'No refresh token was set'",
")",
";",
"}",
"$",
"data",
"=",
"array",
"(",
"'grant_type'",
"=>",
"'refresh_token'",
",",
"'refresh_token'",
"=>",
"$",
"refreshToken",
",",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"scope",
")",
")",
"{",
"$",
"data",
"[",
"'scope'",
"]",
"=",
"$",
"scope",
";",
"}",
"// authentication",
"$",
"header",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"self",
"::",
"AUTH_BASIC",
")",
"{",
"$",
"header",
"[",
"'Authorization'",
"]",
"=",
"'Basic '",
".",
"base64_encode",
"(",
"$",
"this",
"->",
"clientId",
".",
"':'",
".",
"$",
"this",
"->",
"clientSecret",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"type",
"==",
"self",
"::",
"AUTH_POST",
")",
"{",
"$",
"data",
"[",
"'client_id'",
"]",
"=",
"$",
"this",
"->",
"clientId",
";",
"$",
"data",
"[",
"'client_secret'",
"]",
"=",
"$",
"this",
"->",
"clientSecret",
";",
"}",
"$",
"request",
"=",
"new",
"PostRequest",
"(",
"$",
"this",
"->",
"url",
",",
"$",
"header",
",",
"$",
"data",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"httpClient",
"->",
"request",
"(",
"$",
"request",
")",
";",
"$",
"data",
"=",
"Json",
"\\",
"Parser",
"::",
"decode",
"(",
"$",
"response",
"->",
"getBody",
"(",
")",
")",
";",
"if",
"(",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
"==",
"200",
")",
"{",
"return",
"$",
"this",
"->",
"newToken",
"(",
"$",
"data",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'Could not refresh access token'",
")",
";",
"}",
"}"
] | Tries to refresh an access token if an refresh token is available.
Returns the new received access token or throws an excepion
@param \PSX\Oauth2\AccessToken $accessToken
@return \PSX\Oauth2\AccessToken | [
"Tries",
"to",
"refresh",
"an",
"access",
"token",
"if",
"an",
"refresh",
"token",
"is",
"available",
".",
"Returns",
"the",
"new",
"received",
"access",
"token",
"or",
"throws",
"an",
"excepion"
] | 60c6eb824393bfc49f9f60ae06b56543c8eab548 | https://github.com/apioo/psx-oauth2/blob/60c6eb824393bfc49f9f60ae06b56543c8eab548/src/AuthorizationAbstract.php#L112-L153 |
711 | ifsale/fluidphp-framework | App.php | App._setPhpInit | protected static function _setPhpInit( )
{
$init = Module::merge( ptc_path( 'root' ) . '/app/config/init.php' );
foreach ( $init as $k => $v )
{
if ( is_array( $v ) )
{
foreach ( $v as $key => $val )
{
ini_set( $k . '.' . $key , $val );
}
}
else
{
ini_set( $k , $v );
}
}
static::option( 'init' , $init );
} | php | protected static function _setPhpInit( )
{
$init = Module::merge( ptc_path( 'root' ) . '/app/config/init.php' );
foreach ( $init as $k => $v )
{
if ( is_array( $v ) )
{
foreach ( $v as $key => $val )
{
ini_set( $k . '.' . $key , $val );
}
}
else
{
ini_set( $k , $v );
}
}
static::option( 'init' , $init );
} | [
"protected",
"static",
"function",
"_setPhpInit",
"(",
")",
"{",
"$",
"init",
"=",
"Module",
"::",
"merge",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/app/config/init.php'",
")",
";",
"foreach",
"(",
"$",
"init",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"v",
")",
")",
"{",
"foreach",
"(",
"$",
"v",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"ini_set",
"(",
"$",
"k",
".",
"'.'",
".",
"$",
"key",
",",
"$",
"val",
")",
";",
"}",
"}",
"else",
"{",
"ini_set",
"(",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}",
"static",
"::",
"option",
"(",
"'init'",
",",
"$",
"init",
")",
";",
"}"
] | Php configuration at runtime | [
"Php",
"configuration",
"at",
"runtime"
] | 34e67aeca2ede0ab43b6db2b136194dc998644ca | https://github.com/ifsale/fluidphp-framework/blob/34e67aeca2ede0ab43b6db2b136194dc998644ca/App.php#L197-L215 |
712 | ifsale/fluidphp-framework | App.php | App._setDebug | protected static function _setDebug( )
{
$debug = Module::merge( ptc_path( 'root' ) . '/app/config/debug.php' );
if ( file_exists( ptc_path( 'root' ) . '/app/config/debug_ajax.php' ) )
{
if ( !empty( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) &&
( 'xmlhttprequest' === strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) ||
'ajax' === strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) ) )
{
$debug_ajax = require_once( ptc_path( 'root' ) . '/app/config/debug_ajax.php' );
$debug = array_merge( $debug , $debug_ajax );
}
}
static::option( 'debug' , $debug );
require_once( ptc_path( 'root' ) . '/vendor/phptoolcase/phptoolcase/PtcDebug.php' );
if ( !is_null( ptc_array_get( static::$_config , 'debug.replace_error_handler' , null ) ) )
{
$die_on_error = ( ptc_array_get( static::$_config , 'debug.die_on_error' ) ) ? true : false;
Debug::setErrorHandler( $die_on_error );
ptc_array_set( static::$_config , 'debug.replace_error_handler' , false , true );
}
if ( ptc_array_get( static::$_config , 'debug.start' ) )
{
$exclude = ptc_array_get( static::$_config , 'debug.exclude_categories' );
if ( is_string( $exclude ) && array_key_exists( $exclude , static::$_debugLevels ) )
{
ptc_array_set( static::$_config , 'debug.exclude_categories' ,
static::$_debugLevels[ $exclude ], true );
}
if ( isset( $_GET[ 'debug_level' ] ) )
{
ptc_array_set( static::$_config , 'debug.exclude_categories' ,
static::$_debugLevels[ $_GET[ 'debug_level' ] ] , true );
}
Debug::load( static::$_config[ 'debug' ] );
}
} | php | protected static function _setDebug( )
{
$debug = Module::merge( ptc_path( 'root' ) . '/app/config/debug.php' );
if ( file_exists( ptc_path( 'root' ) . '/app/config/debug_ajax.php' ) )
{
if ( !empty( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) &&
( 'xmlhttprequest' === strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ] ) ||
'ajax' === strtolower( $_SERVER[ 'HTTP_X_REQUESTED_WITH' ]) ) )
{
$debug_ajax = require_once( ptc_path( 'root' ) . '/app/config/debug_ajax.php' );
$debug = array_merge( $debug , $debug_ajax );
}
}
static::option( 'debug' , $debug );
require_once( ptc_path( 'root' ) . '/vendor/phptoolcase/phptoolcase/PtcDebug.php' );
if ( !is_null( ptc_array_get( static::$_config , 'debug.replace_error_handler' , null ) ) )
{
$die_on_error = ( ptc_array_get( static::$_config , 'debug.die_on_error' ) ) ? true : false;
Debug::setErrorHandler( $die_on_error );
ptc_array_set( static::$_config , 'debug.replace_error_handler' , false , true );
}
if ( ptc_array_get( static::$_config , 'debug.start' ) )
{
$exclude = ptc_array_get( static::$_config , 'debug.exclude_categories' );
if ( is_string( $exclude ) && array_key_exists( $exclude , static::$_debugLevels ) )
{
ptc_array_set( static::$_config , 'debug.exclude_categories' ,
static::$_debugLevels[ $exclude ], true );
}
if ( isset( $_GET[ 'debug_level' ] ) )
{
ptc_array_set( static::$_config , 'debug.exclude_categories' ,
static::$_debugLevels[ $_GET[ 'debug_level' ] ] , true );
}
Debug::load( static::$_config[ 'debug' ] );
}
} | [
"protected",
"static",
"function",
"_setDebug",
"(",
")",
"{",
"$",
"debug",
"=",
"Module",
"::",
"merge",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/app/config/debug.php'",
")",
";",
"if",
"(",
"file_exists",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/app/config/debug_ajax.php'",
")",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_REQUESTED_WITH'",
"]",
")",
"&&",
"(",
"'xmlhttprequest'",
"===",
"strtolower",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_REQUESTED_WITH'",
"]",
")",
"||",
"'ajax'",
"===",
"strtolower",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_REQUESTED_WITH'",
"]",
")",
")",
")",
"{",
"$",
"debug_ajax",
"=",
"require_once",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/app/config/debug_ajax.php'",
")",
";",
"$",
"debug",
"=",
"array_merge",
"(",
"$",
"debug",
",",
"$",
"debug_ajax",
")",
";",
"}",
"}",
"static",
"::",
"option",
"(",
"'debug'",
",",
"$",
"debug",
")",
";",
"require_once",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/vendor/phptoolcase/phptoolcase/PtcDebug.php'",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'debug.replace_error_handler'",
",",
"null",
")",
")",
")",
"{",
"$",
"die_on_error",
"=",
"(",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'debug.die_on_error'",
")",
")",
"?",
"true",
":",
"false",
";",
"Debug",
"::",
"setErrorHandler",
"(",
"$",
"die_on_error",
")",
";",
"ptc_array_set",
"(",
"static",
"::",
"$",
"_config",
",",
"'debug.replace_error_handler'",
",",
"false",
",",
"true",
")",
";",
"}",
"if",
"(",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'debug.start'",
")",
")",
"{",
"$",
"exclude",
"=",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'debug.exclude_categories'",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"exclude",
")",
"&&",
"array_key_exists",
"(",
"$",
"exclude",
",",
"static",
"::",
"$",
"_debugLevels",
")",
")",
"{",
"ptc_array_set",
"(",
"static",
"::",
"$",
"_config",
",",
"'debug.exclude_categories'",
",",
"static",
"::",
"$",
"_debugLevels",
"[",
"$",
"exclude",
"]",
",",
"true",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"_GET",
"[",
"'debug_level'",
"]",
")",
")",
"{",
"ptc_array_set",
"(",
"static",
"::",
"$",
"_config",
",",
"'debug.exclude_categories'",
",",
"static",
"::",
"$",
"_debugLevels",
"[",
"$",
"_GET",
"[",
"'debug_level'",
"]",
"]",
",",
"true",
")",
";",
"}",
"Debug",
"::",
"load",
"(",
"static",
"::",
"$",
"_config",
"[",
"'debug'",
"]",
")",
";",
"}",
"}"
] | Set debug at runtime | [
"Set",
"debug",
"at",
"runtime"
] | 34e67aeca2ede0ab43b6db2b136194dc998644ca | https://github.com/ifsale/fluidphp-framework/blob/34e67aeca2ede0ab43b6db2b136194dc998644ca/App.php#L219-L255 |
713 | ifsale/fluidphp-framework | App.php | App._setAppConfig | protected static function _setAppConfig( )
{
/* paths */
static::option( 'paths' , Module::merge( ptc_path( 'root' ) . '/app/config/paths.php' ) );
ptc_add_path( ptc_array_get( static::$_config , 'paths' ) );
/* application */
static::option( 'app' , Module::merge( ptc_path( 'root' ) . '/app/config/app.php' ) );
HandyMan::addAlias( ptc_array_get( static::$_config , 'app.aliases' ) );
if ( $locale = ptc_array_get( static::$_config , 'app.locale' ) )
{
setlocale( LC_ALL , $locale . 'UTF-8' );
}
if ( $timezone = ptc_array_get( static::$_config , 'app.timezone' ) )
{
date_default_timezone_set( $timezone );
}
ptc_add_file( ptc_array_get( static::$_config , 'app.files' ) );
ptc_add_dir( ptc_array_get( static::$_config , 'app.directories' ) );
ptc_add_dir( ptc_array_get( static::$_config , 'app.namespaces' ) );
if ( $sep = ptc_array_get( static::$_config , 'app.separators' ) )
{
HandyMan::addSeparators( $sep );
}
if ( $conv = ptc_array_get( static::$_config , 'app.conventions' ) )
{
HandyMan::addConventions( $conv );
}
/* database */
static::option( 'db' , Module::merge( ptc_path( 'root' ) . '/app/config/db.php' ) );
if ( $db = ptc_array_get( static::$_config , 'db' ) )
{
$loop = ( static::option( 'app.test_env' ) ) ? $db[ 'develop' ] : $db[ 'prod' ];
foreach ( $loop as $k => $v )
{
if ( ptc_array_get( $v , 'user' ) )
{
DB::add( $v , $k );
}
}
}
/* auth */
static::option( 'auth' , Module::merge( ptc_path( 'root' ) . '/app/config/auth.php' ) );
} | php | protected static function _setAppConfig( )
{
/* paths */
static::option( 'paths' , Module::merge( ptc_path( 'root' ) . '/app/config/paths.php' ) );
ptc_add_path( ptc_array_get( static::$_config , 'paths' ) );
/* application */
static::option( 'app' , Module::merge( ptc_path( 'root' ) . '/app/config/app.php' ) );
HandyMan::addAlias( ptc_array_get( static::$_config , 'app.aliases' ) );
if ( $locale = ptc_array_get( static::$_config , 'app.locale' ) )
{
setlocale( LC_ALL , $locale . 'UTF-8' );
}
if ( $timezone = ptc_array_get( static::$_config , 'app.timezone' ) )
{
date_default_timezone_set( $timezone );
}
ptc_add_file( ptc_array_get( static::$_config , 'app.files' ) );
ptc_add_dir( ptc_array_get( static::$_config , 'app.directories' ) );
ptc_add_dir( ptc_array_get( static::$_config , 'app.namespaces' ) );
if ( $sep = ptc_array_get( static::$_config , 'app.separators' ) )
{
HandyMan::addSeparators( $sep );
}
if ( $conv = ptc_array_get( static::$_config , 'app.conventions' ) )
{
HandyMan::addConventions( $conv );
}
/* database */
static::option( 'db' , Module::merge( ptc_path( 'root' ) . '/app/config/db.php' ) );
if ( $db = ptc_array_get( static::$_config , 'db' ) )
{
$loop = ( static::option( 'app.test_env' ) ) ? $db[ 'develop' ] : $db[ 'prod' ];
foreach ( $loop as $k => $v )
{
if ( ptc_array_get( $v , 'user' ) )
{
DB::add( $v , $k );
}
}
}
/* auth */
static::option( 'auth' , Module::merge( ptc_path( 'root' ) . '/app/config/auth.php' ) );
} | [
"protected",
"static",
"function",
"_setAppConfig",
"(",
")",
"{",
"/* paths */",
"static",
"::",
"option",
"(",
"'paths'",
",",
"Module",
"::",
"merge",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/app/config/paths.php'",
")",
")",
";",
"ptc_add_path",
"(",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'paths'",
")",
")",
";",
"/* application */",
"static",
"::",
"option",
"(",
"'app'",
",",
"Module",
"::",
"merge",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/app/config/app.php'",
")",
")",
";",
"HandyMan",
"::",
"addAlias",
"(",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'app.aliases'",
")",
")",
";",
"if",
"(",
"$",
"locale",
"=",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'app.locale'",
")",
")",
"{",
"setlocale",
"(",
"LC_ALL",
",",
"$",
"locale",
".",
"'UTF-8'",
")",
";",
"}",
"if",
"(",
"$",
"timezone",
"=",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'app.timezone'",
")",
")",
"{",
"date_default_timezone_set",
"(",
"$",
"timezone",
")",
";",
"}",
"ptc_add_file",
"(",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'app.files'",
")",
")",
";",
"ptc_add_dir",
"(",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'app.directories'",
")",
")",
";",
"ptc_add_dir",
"(",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'app.namespaces'",
")",
")",
";",
"if",
"(",
"$",
"sep",
"=",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'app.separators'",
")",
")",
"{",
"HandyMan",
"::",
"addSeparators",
"(",
"$",
"sep",
")",
";",
"}",
"if",
"(",
"$",
"conv",
"=",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'app.conventions'",
")",
")",
"{",
"HandyMan",
"::",
"addConventions",
"(",
"$",
"conv",
")",
";",
"}",
"/* database */",
"static",
"::",
"option",
"(",
"'db'",
",",
"Module",
"::",
"merge",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/app/config/db.php'",
")",
")",
";",
"if",
"(",
"$",
"db",
"=",
"ptc_array_get",
"(",
"static",
"::",
"$",
"_config",
",",
"'db'",
")",
")",
"{",
"$",
"loop",
"=",
"(",
"static",
"::",
"option",
"(",
"'app.test_env'",
")",
")",
"?",
"$",
"db",
"[",
"'develop'",
"]",
":",
"$",
"db",
"[",
"'prod'",
"]",
";",
"foreach",
"(",
"$",
"loop",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"ptc_array_get",
"(",
"$",
"v",
",",
"'user'",
")",
")",
"{",
"DB",
"::",
"add",
"(",
"$",
"v",
",",
"$",
"k",
")",
";",
"}",
"}",
"}",
"/* auth */",
"static",
"::",
"option",
"(",
"'auth'",
",",
"Module",
"::",
"merge",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/app/config/auth.php'",
")",
")",
";",
"}"
] | Application bootstrap configuration | [
"Application",
"bootstrap",
"configuration"
] | 34e67aeca2ede0ab43b6db2b136194dc998644ca | https://github.com/ifsale/fluidphp-framework/blob/34e67aeca2ede0ab43b6db2b136194dc998644ca/App.php#L267-L309 |
714 | ifsale/fluidphp-framework | App.php | App._setCustomConfigFiles | protected static function _setCustomConfigFiles( )
{
/* custom config files */
$files = array( '..' , '.' , 'app.php' , 'db.php' , 'debug.php' , 'init.php' , 'modules.php' ,
'paths.php' , 'auth.php' , 'debug_ajax.php' );
$scanned_directory = array_diff( scandir( ptc_path( 'root' ) . '/app/config' ) , $files );
if ( !empty( $scanned_directory ) )
{
foreach ( $scanned_directory as $file )
{
$option_name = str_replace( '.php' , '' , $file );
$options = Module::merge( ptc_path( 'root' ) . '/app/config/' . $file );
if ( ptc_array_get( $options , '_load' ) )
{
$options = call_user_func( ptc_array_get( $options , '_load' ) , $options );
}
static::option( $option_name , $options );
}
}
static::_loadModulesConfig( );
} | php | protected static function _setCustomConfigFiles( )
{
/* custom config files */
$files = array( '..' , '.' , 'app.php' , 'db.php' , 'debug.php' , 'init.php' , 'modules.php' ,
'paths.php' , 'auth.php' , 'debug_ajax.php' );
$scanned_directory = array_diff( scandir( ptc_path( 'root' ) . '/app/config' ) , $files );
if ( !empty( $scanned_directory ) )
{
foreach ( $scanned_directory as $file )
{
$option_name = str_replace( '.php' , '' , $file );
$options = Module::merge( ptc_path( 'root' ) . '/app/config/' . $file );
if ( ptc_array_get( $options , '_load' ) )
{
$options = call_user_func( ptc_array_get( $options , '_load' ) , $options );
}
static::option( $option_name , $options );
}
}
static::_loadModulesConfig( );
} | [
"protected",
"static",
"function",
"_setCustomConfigFiles",
"(",
")",
"{",
"/* custom config files */",
"$",
"files",
"=",
"array",
"(",
"'..'",
",",
"'.'",
",",
"'app.php'",
",",
"'db.php'",
",",
"'debug.php'",
",",
"'init.php'",
",",
"'modules.php'",
",",
"'paths.php'",
",",
"'auth.php'",
",",
"'debug_ajax.php'",
")",
";",
"$",
"scanned_directory",
"=",
"array_diff",
"(",
"scandir",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/app/config'",
")",
",",
"$",
"files",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"scanned_directory",
")",
")",
"{",
"foreach",
"(",
"$",
"scanned_directory",
"as",
"$",
"file",
")",
"{",
"$",
"option_name",
"=",
"str_replace",
"(",
"'.php'",
",",
"''",
",",
"$",
"file",
")",
";",
"$",
"options",
"=",
"Module",
"::",
"merge",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/app/config/'",
".",
"$",
"file",
")",
";",
"if",
"(",
"ptc_array_get",
"(",
"$",
"options",
",",
"'_load'",
")",
")",
"{",
"$",
"options",
"=",
"call_user_func",
"(",
"ptc_array_get",
"(",
"$",
"options",
",",
"'_load'",
")",
",",
"$",
"options",
")",
";",
"}",
"static",
"::",
"option",
"(",
"$",
"option_name",
",",
"$",
"options",
")",
";",
"}",
"}",
"static",
"::",
"_loadModulesConfig",
"(",
")",
";",
"}"
] | Load custom config files | [
"Load",
"custom",
"config",
"files"
] | 34e67aeca2ede0ab43b6db2b136194dc998644ca | https://github.com/ifsale/fluidphp-framework/blob/34e67aeca2ede0ab43b6db2b136194dc998644ca/App.php#L313-L333 |
715 | ifsale/fluidphp-framework | App.php | App._loadModulesConfig | protected static function _loadModulesConfig( )
{
$config = array( '..' , '.' );
foreach ( static::options( ) as $key => $val )
{
$config[ ] = $key . '.php';
}
foreach ( Module::all( ) as $k => $module )
{
$scanned_directory = array_diff( scandir( ptc_path( 'root' ) . '/modules/' . $k . '/config' ) , $config );
if ( !empty( $scanned_directory ) )
{
foreach ( $scanned_directory as $file )
{
$option_name = str_replace( '.php' , '' , $file );
$options = require( ptc_path( 'root' ) . '/modules/' . $k . '/config/' . $file );
if ( ptc_array_get( $options , '_load' ) )
{
$options = call_user_func( ptc_array_get( $options , '_load' ) , $options );
}
static::option( $option_name , $options );
}
}
}
} | php | protected static function _loadModulesConfig( )
{
$config = array( '..' , '.' );
foreach ( static::options( ) as $key => $val )
{
$config[ ] = $key . '.php';
}
foreach ( Module::all( ) as $k => $module )
{
$scanned_directory = array_diff( scandir( ptc_path( 'root' ) . '/modules/' . $k . '/config' ) , $config );
if ( !empty( $scanned_directory ) )
{
foreach ( $scanned_directory as $file )
{
$option_name = str_replace( '.php' , '' , $file );
$options = require( ptc_path( 'root' ) . '/modules/' . $k . '/config/' . $file );
if ( ptc_array_get( $options , '_load' ) )
{
$options = call_user_func( ptc_array_get( $options , '_load' ) , $options );
}
static::option( $option_name , $options );
}
}
}
} | [
"protected",
"static",
"function",
"_loadModulesConfig",
"(",
")",
"{",
"$",
"config",
"=",
"array",
"(",
"'..'",
",",
"'.'",
")",
";",
"foreach",
"(",
"static",
"::",
"options",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"config",
"[",
"]",
"=",
"$",
"key",
".",
"'.php'",
";",
"}",
"foreach",
"(",
"Module",
"::",
"all",
"(",
")",
"as",
"$",
"k",
"=>",
"$",
"module",
")",
"{",
"$",
"scanned_directory",
"=",
"array_diff",
"(",
"scandir",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/modules/'",
".",
"$",
"k",
".",
"'/config'",
")",
",",
"$",
"config",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"scanned_directory",
")",
")",
"{",
"foreach",
"(",
"$",
"scanned_directory",
"as",
"$",
"file",
")",
"{",
"$",
"option_name",
"=",
"str_replace",
"(",
"'.php'",
",",
"''",
",",
"$",
"file",
")",
";",
"$",
"options",
"=",
"require",
"(",
"ptc_path",
"(",
"'root'",
")",
".",
"'/modules/'",
".",
"$",
"k",
".",
"'/config/'",
".",
"$",
"file",
")",
";",
"if",
"(",
"ptc_array_get",
"(",
"$",
"options",
",",
"'_load'",
")",
")",
"{",
"$",
"options",
"=",
"call_user_func",
"(",
"ptc_array_get",
"(",
"$",
"options",
",",
"'_load'",
")",
",",
"$",
"options",
")",
";",
"}",
"static",
"::",
"option",
"(",
"$",
"option_name",
",",
"$",
"options",
")",
";",
"}",
"}",
"}",
"}"
] | Load module config files that are not in root config | [
"Load",
"module",
"config",
"files",
"that",
"are",
"not",
"in",
"root",
"config"
] | 34e67aeca2ede0ab43b6db2b136194dc998644ca | https://github.com/ifsale/fluidphp-framework/blob/34e67aeca2ede0ab43b6db2b136194dc998644ca/App.php#L337-L361 |
716 | stefanotorresi/thorr-oauth2 | src/Server/ServerInitializer.php | ServerInitializer.createDelegatorWithName | public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback)
{
/** @var OAuth2Server|callable $oauth2Server */
$oauth2Server = $callback();
/* ensure compatibility with https://github.com/zfcampus/zf-oauth2/pull/93 */
if (is_callable($oauth2Server)) {
$oauth2ServerFactory = $oauth2Server;
$oauth2Server = $oauth2ServerFactory();
}
/** @var ModuleOptions $moduleOptions */
$moduleOptions = $serviceLocator->get(ModuleOptions::class);
$thirdPartyProviders = $moduleOptions->getThirdPartyProviders();
if ($moduleOptions->isThirdPartyGrantTypeEnabled() && ! empty($thirdPartyProviders)) {
/** @var ThirdPartyGrantType $thirdPartyGrant */
$thirdPartyGrant = $serviceLocator->get(ThirdPartyGrantType::class);
$oauth2Server->addGrantType($thirdPartyGrant);
}
return isset($oauth2ServerFactory) ? $oauth2ServerFactory : $oauth2Server;
} | php | public function createDelegatorWithName(ServiceLocatorInterface $serviceLocator, $name, $requestedName, $callback)
{
/** @var OAuth2Server|callable $oauth2Server */
$oauth2Server = $callback();
/* ensure compatibility with https://github.com/zfcampus/zf-oauth2/pull/93 */
if (is_callable($oauth2Server)) {
$oauth2ServerFactory = $oauth2Server;
$oauth2Server = $oauth2ServerFactory();
}
/** @var ModuleOptions $moduleOptions */
$moduleOptions = $serviceLocator->get(ModuleOptions::class);
$thirdPartyProviders = $moduleOptions->getThirdPartyProviders();
if ($moduleOptions->isThirdPartyGrantTypeEnabled() && ! empty($thirdPartyProviders)) {
/** @var ThirdPartyGrantType $thirdPartyGrant */
$thirdPartyGrant = $serviceLocator->get(ThirdPartyGrantType::class);
$oauth2Server->addGrantType($thirdPartyGrant);
}
return isset($oauth2ServerFactory) ? $oauth2ServerFactory : $oauth2Server;
} | [
"public",
"function",
"createDelegatorWithName",
"(",
"ServiceLocatorInterface",
"$",
"serviceLocator",
",",
"$",
"name",
",",
"$",
"requestedName",
",",
"$",
"callback",
")",
"{",
"/** @var OAuth2Server|callable $oauth2Server */",
"$",
"oauth2Server",
"=",
"$",
"callback",
"(",
")",
";",
"/* ensure compatibility with https://github.com/zfcampus/zf-oauth2/pull/93 */",
"if",
"(",
"is_callable",
"(",
"$",
"oauth2Server",
")",
")",
"{",
"$",
"oauth2ServerFactory",
"=",
"$",
"oauth2Server",
";",
"$",
"oauth2Server",
"=",
"$",
"oauth2ServerFactory",
"(",
")",
";",
"}",
"/** @var ModuleOptions $moduleOptions */",
"$",
"moduleOptions",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"ModuleOptions",
"::",
"class",
")",
";",
"$",
"thirdPartyProviders",
"=",
"$",
"moduleOptions",
"->",
"getThirdPartyProviders",
"(",
")",
";",
"if",
"(",
"$",
"moduleOptions",
"->",
"isThirdPartyGrantTypeEnabled",
"(",
")",
"&&",
"!",
"empty",
"(",
"$",
"thirdPartyProviders",
")",
")",
"{",
"/** @var ThirdPartyGrantType $thirdPartyGrant */",
"$",
"thirdPartyGrant",
"=",
"$",
"serviceLocator",
"->",
"get",
"(",
"ThirdPartyGrantType",
"::",
"class",
")",
";",
"$",
"oauth2Server",
"->",
"addGrantType",
"(",
"$",
"thirdPartyGrant",
")",
";",
"}",
"return",
"isset",
"(",
"$",
"oauth2ServerFactory",
")",
"?",
"$",
"oauth2ServerFactory",
":",
"$",
"oauth2Server",
";",
"}"
] | A factory that creates delegates of a given service
@param ServiceLocatorInterface $serviceLocator the service locator which requested the service
@param string $name the normalized service name
@param string $requestedName the requested service name
@param callable $callback the callback that is responsible for creating the service
@throws \RuntimeException
@return OAuth2Server | [
"A",
"factory",
"that",
"creates",
"delegates",
"of",
"a",
"given",
"service"
] | 6c2ba962dfc6ae5c0944a6f93f29e6570e5a68ca | https://github.com/stefanotorresi/thorr-oauth2/blob/6c2ba962dfc6ae5c0944a6f93f29e6570e5a68ca/src/Server/ServerInitializer.php#L30-L54 |
717 | gossi/trixionary | src/model/Base/StructureNode.php | StructureNode.initStructureNodeParentsRelatedByStructureNodeId | public function initStructureNodeParentsRelatedByStructureNodeId($overrideExisting = true)
{
if (null !== $this->collStructureNodeParentsRelatedByStructureNodeId && !$overrideExisting) {
return;
}
$this->collStructureNodeParentsRelatedByStructureNodeId = new ObjectCollection();
$this->collStructureNodeParentsRelatedByStructureNodeId->setModel('\gossi\trixionary\model\StructureNodeParent');
} | php | public function initStructureNodeParentsRelatedByStructureNodeId($overrideExisting = true)
{
if (null !== $this->collStructureNodeParentsRelatedByStructureNodeId && !$overrideExisting) {
return;
}
$this->collStructureNodeParentsRelatedByStructureNodeId = new ObjectCollection();
$this->collStructureNodeParentsRelatedByStructureNodeId->setModel('\gossi\trixionary\model\StructureNodeParent');
} | [
"public",
"function",
"initStructureNodeParentsRelatedByStructureNodeId",
"(",
"$",
"overrideExisting",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collStructureNodeParentsRelatedByStructureNodeId",
"&&",
"!",
"$",
"overrideExisting",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"collStructureNodeParentsRelatedByStructureNodeId",
"=",
"new",
"ObjectCollection",
"(",
")",
";",
"$",
"this",
"->",
"collStructureNodeParentsRelatedByStructureNodeId",
"->",
"setModel",
"(",
"'\\gossi\\trixionary\\model\\StructureNodeParent'",
")",
";",
"}"
] | Initializes the collStructureNodeParentsRelatedByStructureNodeId collection.
By default this just sets the collStructureNodeParentsRelatedByStructureNodeId collection to an empty array (like clearcollStructureNodeParentsRelatedByStructureNodeId());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@param boolean $overrideExisting If set to true, the method call initializes
the collection even if it is not empty
@return void | [
"Initializes",
"the",
"collStructureNodeParentsRelatedByStructureNodeId",
"collection",
"."
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNode.php#L1571-L1578 |
718 | gossi/trixionary | src/model/Base/StructureNode.php | StructureNode.initStructureNodeParentsRelatedByParentId | public function initStructureNodeParentsRelatedByParentId($overrideExisting = true)
{
if (null !== $this->collStructureNodeParentsRelatedByParentId && !$overrideExisting) {
return;
}
$this->collStructureNodeParentsRelatedByParentId = new ObjectCollection();
$this->collStructureNodeParentsRelatedByParentId->setModel('\gossi\trixionary\model\StructureNodeParent');
} | php | public function initStructureNodeParentsRelatedByParentId($overrideExisting = true)
{
if (null !== $this->collStructureNodeParentsRelatedByParentId && !$overrideExisting) {
return;
}
$this->collStructureNodeParentsRelatedByParentId = new ObjectCollection();
$this->collStructureNodeParentsRelatedByParentId->setModel('\gossi\trixionary\model\StructureNodeParent');
} | [
"public",
"function",
"initStructureNodeParentsRelatedByParentId",
"(",
"$",
"overrideExisting",
"=",
"true",
")",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"collStructureNodeParentsRelatedByParentId",
"&&",
"!",
"$",
"overrideExisting",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"collStructureNodeParentsRelatedByParentId",
"=",
"new",
"ObjectCollection",
"(",
")",
";",
"$",
"this",
"->",
"collStructureNodeParentsRelatedByParentId",
"->",
"setModel",
"(",
"'\\gossi\\trixionary\\model\\StructureNodeParent'",
")",
";",
"}"
] | Initializes the collStructureNodeParentsRelatedByParentId collection.
By default this just sets the collStructureNodeParentsRelatedByParentId collection to an empty array (like clearcollStructureNodeParentsRelatedByParentId());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@param boolean $overrideExisting If set to true, the method call initializes
the collection even if it is not empty
@return void | [
"Initializes",
"the",
"collStructureNodeParentsRelatedByParentId",
"collection",
"."
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNode.php#L1792-L1799 |
719 | gossi/trixionary | src/model/Base/StructureNode.php | StructureNode.getKstruktur | public function getKstruktur(ConnectionInterface $con = null)
{
if ($this->singleKstruktur === null && !$this->isNew()) {
$this->singleKstruktur = ChildKstrukturQuery::create()->findPk($this->getPrimaryKey(), $con);
}
return $this->singleKstruktur;
} | php | public function getKstruktur(ConnectionInterface $con = null)
{
if ($this->singleKstruktur === null && !$this->isNew()) {
$this->singleKstruktur = ChildKstrukturQuery::create()->findPk($this->getPrimaryKey(), $con);
}
return $this->singleKstruktur;
} | [
"public",
"function",
"getKstruktur",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"singleKstruktur",
"===",
"null",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"this",
"->",
"singleKstruktur",
"=",
"ChildKstrukturQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
",",
"$",
"con",
")",
";",
"}",
"return",
"$",
"this",
"->",
"singleKstruktur",
";",
"}"
] | Gets a single ChildKstruktur object, which is related to this object by a one-to-one relationship.
@param ConnectionInterface $con optional connection object
@return ChildKstruktur
@throws PropelException | [
"Gets",
"a",
"single",
"ChildKstruktur",
"object",
"which",
"is",
"related",
"to",
"this",
"object",
"by",
"a",
"one",
"-",
"to",
"-",
"one",
"relationship",
"."
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNode.php#L1986-L1994 |
720 | gossi/trixionary | src/model/Base/StructureNode.php | StructureNode.setKstruktur | public function setKstruktur(ChildKstruktur $v = null)
{
$this->singleKstruktur = $v;
// Make sure that that the passed-in ChildKstruktur isn't already associated with this object
if ($v !== null && $v->getStructureNode(null, false) === null) {
$v->setStructureNode($this);
}
return $this;
} | php | public function setKstruktur(ChildKstruktur $v = null)
{
$this->singleKstruktur = $v;
// Make sure that that the passed-in ChildKstruktur isn't already associated with this object
if ($v !== null && $v->getStructureNode(null, false) === null) {
$v->setStructureNode($this);
}
return $this;
} | [
"public",
"function",
"setKstruktur",
"(",
"ChildKstruktur",
"$",
"v",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"singleKstruktur",
"=",
"$",
"v",
";",
"// Make sure that that the passed-in ChildKstruktur isn't already associated with this object",
"if",
"(",
"$",
"v",
"!==",
"null",
"&&",
"$",
"v",
"->",
"getStructureNode",
"(",
"null",
",",
"false",
")",
"===",
"null",
")",
"{",
"$",
"v",
"->",
"setStructureNode",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets a single ChildKstruktur object as related to this object by a one-to-one relationship.
@param ChildKstruktur $v ChildKstruktur
@return $this|\gossi\trixionary\model\StructureNode The current object (for fluent API support)
@throws PropelException | [
"Sets",
"a",
"single",
"ChildKstruktur",
"object",
"as",
"related",
"to",
"this",
"object",
"by",
"a",
"one",
"-",
"to",
"-",
"one",
"relationship",
"."
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNode.php#L2003-L2013 |
721 | gossi/trixionary | src/model/Base/StructureNode.php | StructureNode.getFunctionPhase | public function getFunctionPhase(ConnectionInterface $con = null)
{
if ($this->singleFunctionPhase === null && !$this->isNew()) {
$this->singleFunctionPhase = ChildFunctionPhaseQuery::create()->findPk($this->getPrimaryKey(), $con);
}
return $this->singleFunctionPhase;
} | php | public function getFunctionPhase(ConnectionInterface $con = null)
{
if ($this->singleFunctionPhase === null && !$this->isNew()) {
$this->singleFunctionPhase = ChildFunctionPhaseQuery::create()->findPk($this->getPrimaryKey(), $con);
}
return $this->singleFunctionPhase;
} | [
"public",
"function",
"getFunctionPhase",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"singleFunctionPhase",
"===",
"null",
"&&",
"!",
"$",
"this",
"->",
"isNew",
"(",
")",
")",
"{",
"$",
"this",
"->",
"singleFunctionPhase",
"=",
"ChildFunctionPhaseQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
",",
"$",
"con",
")",
";",
"}",
"return",
"$",
"this",
"->",
"singleFunctionPhase",
";",
"}"
] | Gets a single ChildFunctionPhase object, which is related to this object by a one-to-one relationship.
@param ConnectionInterface $con optional connection object
@return ChildFunctionPhase
@throws PropelException | [
"Gets",
"a",
"single",
"ChildFunctionPhase",
"object",
"which",
"is",
"related",
"to",
"this",
"object",
"by",
"a",
"one",
"-",
"to",
"-",
"one",
"relationship",
"."
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNode.php#L2022-L2030 |
722 | gossi/trixionary | src/model/Base/StructureNode.php | StructureNode.setFunctionPhase | public function setFunctionPhase(ChildFunctionPhase $v = null)
{
$this->singleFunctionPhase = $v;
// Make sure that that the passed-in ChildFunctionPhase isn't already associated with this object
if ($v !== null && $v->getStructureNode(null, false) === null) {
$v->setStructureNode($this);
}
return $this;
} | php | public function setFunctionPhase(ChildFunctionPhase $v = null)
{
$this->singleFunctionPhase = $v;
// Make sure that that the passed-in ChildFunctionPhase isn't already associated with this object
if ($v !== null && $v->getStructureNode(null, false) === null) {
$v->setStructureNode($this);
}
return $this;
} | [
"public",
"function",
"setFunctionPhase",
"(",
"ChildFunctionPhase",
"$",
"v",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"singleFunctionPhase",
"=",
"$",
"v",
";",
"// Make sure that that the passed-in ChildFunctionPhase isn't already associated with this object",
"if",
"(",
"$",
"v",
"!==",
"null",
"&&",
"$",
"v",
"->",
"getStructureNode",
"(",
"null",
",",
"false",
")",
"===",
"null",
")",
"{",
"$",
"v",
"->",
"setStructureNode",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets a single ChildFunctionPhase object as related to this object by a one-to-one relationship.
@param ChildFunctionPhase $v ChildFunctionPhase
@return $this|\gossi\trixionary\model\StructureNode The current object (for fluent API support)
@throws PropelException | [
"Sets",
"a",
"single",
"ChildFunctionPhase",
"object",
"as",
"related",
"to",
"this",
"object",
"by",
"a",
"one",
"-",
"to",
"-",
"one",
"relationship",
"."
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNode.php#L2039-L2049 |
723 | gossi/trixionary | src/model/Base/StructureNode.php | StructureNode.initStructureNodesRelatedByParentId | public function initStructureNodesRelatedByParentId()
{
$this->collStructureNodesRelatedByParentId = new ObjectCollection();
$this->collStructureNodesRelatedByParentIdPartial = true;
$this->collStructureNodesRelatedByParentId->setModel('\gossi\trixionary\model\StructureNode');
} | php | public function initStructureNodesRelatedByParentId()
{
$this->collStructureNodesRelatedByParentId = new ObjectCollection();
$this->collStructureNodesRelatedByParentIdPartial = true;
$this->collStructureNodesRelatedByParentId->setModel('\gossi\trixionary\model\StructureNode');
} | [
"public",
"function",
"initStructureNodesRelatedByParentId",
"(",
")",
"{",
"$",
"this",
"->",
"collStructureNodesRelatedByParentId",
"=",
"new",
"ObjectCollection",
"(",
")",
";",
"$",
"this",
"->",
"collStructureNodesRelatedByParentIdPartial",
"=",
"true",
";",
"$",
"this",
"->",
"collStructureNodesRelatedByParentId",
"->",
"setModel",
"(",
"'\\gossi\\trixionary\\model\\StructureNode'",
")",
";",
"}"
] | Initializes the collStructureNodesRelatedByParentId crossRef collection.
By default this just sets the collStructureNodesRelatedByParentId collection to an empty collection (like clearStructureNodesRelatedByParentId());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@return void | [
"Initializes",
"the",
"collStructureNodesRelatedByParentId",
"crossRef",
"collection",
"."
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNode.php#L2074-L2080 |
724 | gossi/trixionary | src/model/Base/StructureNode.php | StructureNode.removeStructureNodeRelatedByParentId | public function removeStructureNodeRelatedByParentId(ChildStructureNode $structureNodeRelatedByParentId)
{
if ($this->getStructureNodesRelatedByParentId()->contains($structureNodeRelatedByParentId)) { $structureNodeParent = new ChildStructureNodeParent();
$structureNodeParent->setStructureNodeRelatedByParentId($structureNodeRelatedByParentId);
if ($structureNodeRelatedByParentId->isStructureNodeRelatedByStructureNodeIdsLoaded()) {
//remove the back reference if available
$structureNodeRelatedByParentId->getStructureNodeRelatedByStructureNodeIds()->removeObject($this);
}
$structureNodeParent->setStructureNodeRelatedByStructureNodeId($this);
$this->removeStructureNodeParentRelatedByStructureNodeId(clone $structureNodeParent);
$structureNodeParent->clear();
$this->collStructureNodesRelatedByParentId->remove($this->collStructureNodesRelatedByParentId->search($structureNodeRelatedByParentId));
if (null === $this->structureNodesRelatedByParentIdScheduledForDeletion) {
$this->structureNodesRelatedByParentIdScheduledForDeletion = clone $this->collStructureNodesRelatedByParentId;
$this->structureNodesRelatedByParentIdScheduledForDeletion->clear();
}
$this->structureNodesRelatedByParentIdScheduledForDeletion->push($structureNodeRelatedByParentId);
}
return $this;
} | php | public function removeStructureNodeRelatedByParentId(ChildStructureNode $structureNodeRelatedByParentId)
{
if ($this->getStructureNodesRelatedByParentId()->contains($structureNodeRelatedByParentId)) { $structureNodeParent = new ChildStructureNodeParent();
$structureNodeParent->setStructureNodeRelatedByParentId($structureNodeRelatedByParentId);
if ($structureNodeRelatedByParentId->isStructureNodeRelatedByStructureNodeIdsLoaded()) {
//remove the back reference if available
$structureNodeRelatedByParentId->getStructureNodeRelatedByStructureNodeIds()->removeObject($this);
}
$structureNodeParent->setStructureNodeRelatedByStructureNodeId($this);
$this->removeStructureNodeParentRelatedByStructureNodeId(clone $structureNodeParent);
$structureNodeParent->clear();
$this->collStructureNodesRelatedByParentId->remove($this->collStructureNodesRelatedByParentId->search($structureNodeRelatedByParentId));
if (null === $this->structureNodesRelatedByParentIdScheduledForDeletion) {
$this->structureNodesRelatedByParentIdScheduledForDeletion = clone $this->collStructureNodesRelatedByParentId;
$this->structureNodesRelatedByParentIdScheduledForDeletion->clear();
}
$this->structureNodesRelatedByParentIdScheduledForDeletion->push($structureNodeRelatedByParentId);
}
return $this;
} | [
"public",
"function",
"removeStructureNodeRelatedByParentId",
"(",
"ChildStructureNode",
"$",
"structureNodeRelatedByParentId",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getStructureNodesRelatedByParentId",
"(",
")",
"->",
"contains",
"(",
"$",
"structureNodeRelatedByParentId",
")",
")",
"{",
"$",
"structureNodeParent",
"=",
"new",
"ChildStructureNodeParent",
"(",
")",
";",
"$",
"structureNodeParent",
"->",
"setStructureNodeRelatedByParentId",
"(",
"$",
"structureNodeRelatedByParentId",
")",
";",
"if",
"(",
"$",
"structureNodeRelatedByParentId",
"->",
"isStructureNodeRelatedByStructureNodeIdsLoaded",
"(",
")",
")",
"{",
"//remove the back reference if available",
"$",
"structureNodeRelatedByParentId",
"->",
"getStructureNodeRelatedByStructureNodeIds",
"(",
")",
"->",
"removeObject",
"(",
"$",
"this",
")",
";",
"}",
"$",
"structureNodeParent",
"->",
"setStructureNodeRelatedByStructureNodeId",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"removeStructureNodeParentRelatedByStructureNodeId",
"(",
"clone",
"$",
"structureNodeParent",
")",
";",
"$",
"structureNodeParent",
"->",
"clear",
"(",
")",
";",
"$",
"this",
"->",
"collStructureNodesRelatedByParentId",
"->",
"remove",
"(",
"$",
"this",
"->",
"collStructureNodesRelatedByParentId",
"->",
"search",
"(",
"$",
"structureNodeRelatedByParentId",
")",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"structureNodesRelatedByParentIdScheduledForDeletion",
")",
"{",
"$",
"this",
"->",
"structureNodesRelatedByParentIdScheduledForDeletion",
"=",
"clone",
"$",
"this",
"->",
"collStructureNodesRelatedByParentId",
";",
"$",
"this",
"->",
"structureNodesRelatedByParentIdScheduledForDeletion",
"->",
"clear",
"(",
")",
";",
"}",
"$",
"this",
"->",
"structureNodesRelatedByParentIdScheduledForDeletion",
"->",
"push",
"(",
"$",
"structureNodeRelatedByParentId",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove structureNodeRelatedByParentId of this object
through the kk_trixionary_structure_node_parent cross reference table.
@param ChildStructureNode $structureNodeRelatedByParentId
@return ChildStructureNode The current object (for fluent API support) | [
"Remove",
"structureNodeRelatedByParentId",
"of",
"this",
"object",
"through",
"the",
"kk_trixionary_structure_node_parent",
"cross",
"reference",
"table",
"."
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNode.php#L2265-L2291 |
725 | gossi/trixionary | src/model/Base/StructureNode.php | StructureNode.initStructureNodesRelatedByStructureNodeId | public function initStructureNodesRelatedByStructureNodeId()
{
$this->collStructureNodesRelatedByStructureNodeId = new ObjectCollection();
$this->collStructureNodesRelatedByStructureNodeIdPartial = true;
$this->collStructureNodesRelatedByStructureNodeId->setModel('\gossi\trixionary\model\StructureNode');
} | php | public function initStructureNodesRelatedByStructureNodeId()
{
$this->collStructureNodesRelatedByStructureNodeId = new ObjectCollection();
$this->collStructureNodesRelatedByStructureNodeIdPartial = true;
$this->collStructureNodesRelatedByStructureNodeId->setModel('\gossi\trixionary\model\StructureNode');
} | [
"public",
"function",
"initStructureNodesRelatedByStructureNodeId",
"(",
")",
"{",
"$",
"this",
"->",
"collStructureNodesRelatedByStructureNodeId",
"=",
"new",
"ObjectCollection",
"(",
")",
";",
"$",
"this",
"->",
"collStructureNodesRelatedByStructureNodeIdPartial",
"=",
"true",
";",
"$",
"this",
"->",
"collStructureNodesRelatedByStructureNodeId",
"->",
"setModel",
"(",
"'\\gossi\\trixionary\\model\\StructureNode'",
")",
";",
"}"
] | Initializes the collStructureNodesRelatedByStructureNodeId crossRef collection.
By default this just sets the collStructureNodesRelatedByStructureNodeId collection to an empty collection (like clearStructureNodesRelatedByStructureNodeId());
however, you may wish to override this method in your stub class to provide setting appropriate
to your application -- for example, setting the initial array to the values stored in database.
@return void | [
"Initializes",
"the",
"collStructureNodesRelatedByStructureNodeId",
"crossRef",
"collection",
"."
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNode.php#L2316-L2322 |
726 | gossi/trixionary | src/model/Base/StructureNode.php | StructureNode.removeStructureNodeRelatedByStructureNodeId | public function removeStructureNodeRelatedByStructureNodeId(ChildStructureNode $structureNodeRelatedByStructureNodeId)
{
if ($this->getStructureNodesRelatedByStructureNodeId()->contains($structureNodeRelatedByStructureNodeId)) { $structureNodeParent = new ChildStructureNodeParent();
$structureNodeParent->setStructureNodeRelatedByStructureNodeId($structureNodeRelatedByStructureNodeId);
if ($structureNodeRelatedByStructureNodeId->isStructureNodeRelatedByParentIdsLoaded()) {
//remove the back reference if available
$structureNodeRelatedByStructureNodeId->getStructureNodeRelatedByParentIds()->removeObject($this);
}
$structureNodeParent->setStructureNodeRelatedByParentId($this);
$this->removeStructureNodeParentRelatedByParentId(clone $structureNodeParent);
$structureNodeParent->clear();
$this->collStructureNodesRelatedByStructureNodeId->remove($this->collStructureNodesRelatedByStructureNodeId->search($structureNodeRelatedByStructureNodeId));
if (null === $this->structureNodesRelatedByStructureNodeIdScheduledForDeletion) {
$this->structureNodesRelatedByStructureNodeIdScheduledForDeletion = clone $this->collStructureNodesRelatedByStructureNodeId;
$this->structureNodesRelatedByStructureNodeIdScheduledForDeletion->clear();
}
$this->structureNodesRelatedByStructureNodeIdScheduledForDeletion->push($structureNodeRelatedByStructureNodeId);
}
return $this;
} | php | public function removeStructureNodeRelatedByStructureNodeId(ChildStructureNode $structureNodeRelatedByStructureNodeId)
{
if ($this->getStructureNodesRelatedByStructureNodeId()->contains($structureNodeRelatedByStructureNodeId)) { $structureNodeParent = new ChildStructureNodeParent();
$structureNodeParent->setStructureNodeRelatedByStructureNodeId($structureNodeRelatedByStructureNodeId);
if ($structureNodeRelatedByStructureNodeId->isStructureNodeRelatedByParentIdsLoaded()) {
//remove the back reference if available
$structureNodeRelatedByStructureNodeId->getStructureNodeRelatedByParentIds()->removeObject($this);
}
$structureNodeParent->setStructureNodeRelatedByParentId($this);
$this->removeStructureNodeParentRelatedByParentId(clone $structureNodeParent);
$structureNodeParent->clear();
$this->collStructureNodesRelatedByStructureNodeId->remove($this->collStructureNodesRelatedByStructureNodeId->search($structureNodeRelatedByStructureNodeId));
if (null === $this->structureNodesRelatedByStructureNodeIdScheduledForDeletion) {
$this->structureNodesRelatedByStructureNodeIdScheduledForDeletion = clone $this->collStructureNodesRelatedByStructureNodeId;
$this->structureNodesRelatedByStructureNodeIdScheduledForDeletion->clear();
}
$this->structureNodesRelatedByStructureNodeIdScheduledForDeletion->push($structureNodeRelatedByStructureNodeId);
}
return $this;
} | [
"public",
"function",
"removeStructureNodeRelatedByStructureNodeId",
"(",
"ChildStructureNode",
"$",
"structureNodeRelatedByStructureNodeId",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getStructureNodesRelatedByStructureNodeId",
"(",
")",
"->",
"contains",
"(",
"$",
"structureNodeRelatedByStructureNodeId",
")",
")",
"{",
"$",
"structureNodeParent",
"=",
"new",
"ChildStructureNodeParent",
"(",
")",
";",
"$",
"structureNodeParent",
"->",
"setStructureNodeRelatedByStructureNodeId",
"(",
"$",
"structureNodeRelatedByStructureNodeId",
")",
";",
"if",
"(",
"$",
"structureNodeRelatedByStructureNodeId",
"->",
"isStructureNodeRelatedByParentIdsLoaded",
"(",
")",
")",
"{",
"//remove the back reference if available",
"$",
"structureNodeRelatedByStructureNodeId",
"->",
"getStructureNodeRelatedByParentIds",
"(",
")",
"->",
"removeObject",
"(",
"$",
"this",
")",
";",
"}",
"$",
"structureNodeParent",
"->",
"setStructureNodeRelatedByParentId",
"(",
"$",
"this",
")",
";",
"$",
"this",
"->",
"removeStructureNodeParentRelatedByParentId",
"(",
"clone",
"$",
"structureNodeParent",
")",
";",
"$",
"structureNodeParent",
"->",
"clear",
"(",
")",
";",
"$",
"this",
"->",
"collStructureNodesRelatedByStructureNodeId",
"->",
"remove",
"(",
"$",
"this",
"->",
"collStructureNodesRelatedByStructureNodeId",
"->",
"search",
"(",
"$",
"structureNodeRelatedByStructureNodeId",
")",
")",
";",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"structureNodesRelatedByStructureNodeIdScheduledForDeletion",
")",
"{",
"$",
"this",
"->",
"structureNodesRelatedByStructureNodeIdScheduledForDeletion",
"=",
"clone",
"$",
"this",
"->",
"collStructureNodesRelatedByStructureNodeId",
";",
"$",
"this",
"->",
"structureNodesRelatedByStructureNodeIdScheduledForDeletion",
"->",
"clear",
"(",
")",
";",
"}",
"$",
"this",
"->",
"structureNodesRelatedByStructureNodeIdScheduledForDeletion",
"->",
"push",
"(",
"$",
"structureNodeRelatedByStructureNodeId",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Remove structureNodeRelatedByStructureNodeId of this object
through the kk_trixionary_structure_node_parent cross reference table.
@param ChildStructureNode $structureNodeRelatedByStructureNodeId
@return ChildStructureNode The current object (for fluent API support) | [
"Remove",
"structureNodeRelatedByStructureNodeId",
"of",
"this",
"object",
"through",
"the",
"kk_trixionary_structure_node_parent",
"cross",
"reference",
"table",
"."
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNode.php#L2507-L2533 |
727 | gossi/trixionary | src/model/Base/StructureNode.php | StructureNode.getChildObject | public function getChildObject()
{
if (!$this->hasChildObject()) {
return null;
}
$childObjectClass = $this->getDescendantClass();
$childObject = PropelQuery::from($childObjectClass)->findPk($this->getPrimaryKey());
return $childObject->hasChildObject() ? $childObject->getChildObject() : $childObject;
} | php | public function getChildObject()
{
if (!$this->hasChildObject()) {
return null;
}
$childObjectClass = $this->getDescendantClass();
$childObject = PropelQuery::from($childObjectClass)->findPk($this->getPrimaryKey());
return $childObject->hasChildObject() ? $childObject->getChildObject() : $childObject;
} | [
"public",
"function",
"getChildObject",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasChildObject",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"childObjectClass",
"=",
"$",
"this",
"->",
"getDescendantClass",
"(",
")",
";",
"$",
"childObject",
"=",
"PropelQuery",
"::",
"from",
"(",
"$",
"childObjectClass",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"getPrimaryKey",
"(",
")",
")",
";",
"return",
"$",
"childObject",
"->",
"hasChildObject",
"(",
")",
"?",
"$",
"childObject",
"->",
"getChildObject",
"(",
")",
":",
"$",
"childObject",
";",
"}"
] | Get the child object of this object
@return mixed | [
"Get",
"the",
"child",
"object",
"of",
"this",
"object"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNode.php#L2632-L2641 |
728 | OWeb/OWeb-Framework | OWeb/manage/Controller.php | Controller.initController | public function initController(\OWeb\types\Controller $controller = null)
{
if ($this->controller == null)
return;
Events::getInstance()->sendEvent('Init_Prepare@OWeb\manage\Controller', $this->controller);
$this->controller->initController();
Events::getInstance()->sendEvent('Init_Done@OWeb\manage\Controller', $this->controller);
Events::getInstance()->sendEvent('ActionDist_Prepare@OWeb\manage\Controller', $this->controller);
//gestion des Actions...
$source[] = \OWeb\OWeb::getInstance()->get_get();
$source[] = \OWeb\OWeb::getInstance()->get_post();
foreach ($source as $get) {
if (isset($get['action']))
$this->controller->doAction($get['action']);
$i = 1;
while (isset($get['action_' . $i])) {
$this->controller->doAction($get['action_' . $i]);
$i++;
}
}
Events::getInstance()->sendEvent('ActionDist_Done@OWeb\manage\Controller', $this->controller);
} | php | public function initController(\OWeb\types\Controller $controller = null)
{
if ($this->controller == null)
return;
Events::getInstance()->sendEvent('Init_Prepare@OWeb\manage\Controller', $this->controller);
$this->controller->initController();
Events::getInstance()->sendEvent('Init_Done@OWeb\manage\Controller', $this->controller);
Events::getInstance()->sendEvent('ActionDist_Prepare@OWeb\manage\Controller', $this->controller);
//gestion des Actions...
$source[] = \OWeb\OWeb::getInstance()->get_get();
$source[] = \OWeb\OWeb::getInstance()->get_post();
foreach ($source as $get) {
if (isset($get['action']))
$this->controller->doAction($get['action']);
$i = 1;
while (isset($get['action_' . $i])) {
$this->controller->doAction($get['action_' . $i]);
$i++;
}
}
Events::getInstance()->sendEvent('ActionDist_Done@OWeb\manage\Controller', $this->controller);
} | [
"public",
"function",
"initController",
"(",
"\\",
"OWeb",
"\\",
"types",
"\\",
"Controller",
"$",
"controller",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"controller",
"==",
"null",
")",
"return",
";",
"Events",
"::",
"getInstance",
"(",
")",
"->",
"sendEvent",
"(",
"'Init_Prepare@OWeb\\manage\\Controller'",
",",
"$",
"this",
"->",
"controller",
")",
";",
"$",
"this",
"->",
"controller",
"->",
"initController",
"(",
")",
";",
"Events",
"::",
"getInstance",
"(",
")",
"->",
"sendEvent",
"(",
"'Init_Done@OWeb\\manage\\Controller'",
",",
"$",
"this",
"->",
"controller",
")",
";",
"Events",
"::",
"getInstance",
"(",
")",
"->",
"sendEvent",
"(",
"'ActionDist_Prepare@OWeb\\manage\\Controller'",
",",
"$",
"this",
"->",
"controller",
")",
";",
"//gestion des Actions...",
"$",
"source",
"[",
"]",
"=",
"\\",
"OWeb",
"\\",
"OWeb",
"::",
"getInstance",
"(",
")",
"->",
"get_get",
"(",
")",
";",
"$",
"source",
"[",
"]",
"=",
"\\",
"OWeb",
"\\",
"OWeb",
"::",
"getInstance",
"(",
")",
"->",
"get_post",
"(",
")",
";",
"foreach",
"(",
"$",
"source",
"as",
"$",
"get",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"get",
"[",
"'action'",
"]",
")",
")",
"$",
"this",
"->",
"controller",
"->",
"doAction",
"(",
"$",
"get",
"[",
"'action'",
"]",
")",
";",
"$",
"i",
"=",
"1",
";",
"while",
"(",
"isset",
"(",
"$",
"get",
"[",
"'action_'",
".",
"$",
"i",
"]",
")",
")",
"{",
"$",
"this",
"->",
"controller",
"->",
"doAction",
"(",
"$",
"get",
"[",
"'action_'",
".",
"$",
"i",
"]",
")",
";",
"$",
"i",
"++",
";",
"}",
"}",
"Events",
"::",
"getInstance",
"(",
")",
"->",
"sendEvent",
"(",
"'ActionDist_Done@OWeb\\manage\\Controller'",
",",
"$",
"this",
"->",
"controller",
")",
";",
"}"
] | Will initialize the Controller and will do the Actions to which the Controller has register
@param \OWeb\types\Controller $controller The controller to Initialize | [
"Will",
"initialize",
"the",
"Controller",
"and",
"will",
"do",
"the",
"Actions",
"to",
"which",
"the",
"Controller",
"has",
"register"
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/manage/Controller.php#L54-L84 |
729 | OWeb/OWeb-Framework | OWeb/manage/Controller.php | Controller.loadController | public function loadController($name)
{
if ($this->controller != null) {
throw new \OWeb\manage\exceptions\Controller("A Controller was already loaded");
} else {
try {
$controller = new $name(true);
$this->controller = $controller;
if (!($controller instanceof \OWeb\types\Controller))
throw new \OWeb\manage\exceptions\Controller("A Controller needs to be an instance of \\OWeb\\Types\\Controller");
\OWeb\manage\Events::getInstance()->sendEvent('loaded@OWeb\manage\Controller', $this->controller);
} catch (\Exception $ex) {
throw new \OWeb\manage\exceptions\Controller("The Controller couldn't be loaded due to Errors", 0, $ex);
}
}
return $this->controller;
} | php | public function loadController($name)
{
if ($this->controller != null) {
throw new \OWeb\manage\exceptions\Controller("A Controller was already loaded");
} else {
try {
$controller = new $name(true);
$this->controller = $controller;
if (!($controller instanceof \OWeb\types\Controller))
throw new \OWeb\manage\exceptions\Controller("A Controller needs to be an instance of \\OWeb\\Types\\Controller");
\OWeb\manage\Events::getInstance()->sendEvent('loaded@OWeb\manage\Controller', $this->controller);
} catch (\Exception $ex) {
throw new \OWeb\manage\exceptions\Controller("The Controller couldn't be loaded due to Errors", 0, $ex);
}
}
return $this->controller;
} | [
"public",
"function",
"loadController",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"controller",
"!=",
"null",
")",
"{",
"throw",
"new",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"exceptions",
"\\",
"Controller",
"(",
"\"A Controller was already loaded\"",
")",
";",
"}",
"else",
"{",
"try",
"{",
"$",
"controller",
"=",
"new",
"$",
"name",
"(",
"true",
")",
";",
"$",
"this",
"->",
"controller",
"=",
"$",
"controller",
";",
"if",
"(",
"!",
"(",
"$",
"controller",
"instanceof",
"\\",
"OWeb",
"\\",
"types",
"\\",
"Controller",
")",
")",
"throw",
"new",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"exceptions",
"\\",
"Controller",
"(",
"\"A Controller needs to be an instance of \\\\OWeb\\\\Types\\\\Controller\"",
")",
";",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"Events",
"::",
"getInstance",
"(",
")",
"->",
"sendEvent",
"(",
"'loaded@OWeb\\manage\\Controller'",
",",
"$",
"this",
"->",
"controller",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"exceptions",
"\\",
"Controller",
"(",
"\"The Controller couldn't be loaded due to Errors\"",
",",
"0",
",",
"$",
"ex",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"controller",
";",
"}"
] | Will load the Controller as main controller.
Will automaticlly set up the initialisation sequence for the Controller.
The Controller will be initialized once OWeb has finished initialisation.
@param \String $name of the Controller to load.
@return \OWeb\types\Controller Loaded Controller
@throws \OWeb\manage\exceptions\Controller If there is a error to the loading of the COntroller | [
"Will",
"load",
"the",
"Controller",
"as",
"main",
"controller",
".",
"Will",
"automaticlly",
"set",
"up",
"the",
"initialisation",
"sequence",
"for",
"the",
"Controller",
".",
"The",
"Controller",
"will",
"be",
"initialized",
"once",
"OWeb",
"has",
"finished",
"initialisation",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/manage/Controller.php#L96-L117 |
730 | OWeb/OWeb-Framework | OWeb/manage/Controller.php | Controller.display | public function display()
{
if ($this->controller != null) {
try {
$this->controller->display();
} catch (\Exception $ex) {
throw new \OWeb\manage\exceptions\Controller("The Controller couldn't be shown due to Errors", 0, $ex);
}
} else {
throw new \OWeb\manage\exceptions\Controller("A Controller wasn't loaded to be shown");
}
} | php | public function display()
{
if ($this->controller != null) {
try {
$this->controller->display();
} catch (\Exception $ex) {
throw new \OWeb\manage\exceptions\Controller("The Controller couldn't be shown due to Errors", 0, $ex);
}
} else {
throw new \OWeb\manage\exceptions\Controller("A Controller wasn't loaded to be shown");
}
} | [
"public",
"function",
"display",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"controller",
"!=",
"null",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"controller",
"->",
"display",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"exceptions",
"\\",
"Controller",
"(",
"\"The Controller couldn't be shown due to Errors\"",
",",
"0",
",",
"$",
"ex",
")",
";",
"}",
"}",
"else",
"{",
"throw",
"new",
"\\",
"OWeb",
"\\",
"manage",
"\\",
"exceptions",
"\\",
"Controller",
"(",
"\"A Controller wasn't loaded to be shown\"",
")",
";",
"}",
"}"
] | Will start the display sequence of the controller.
First will prepare controller for display.
Then it will ask the controller to display it's View.
@throws \OWeb\manage\exceptions\Controller If there is a problem about Displaying the Controller | [
"Will",
"start",
"the",
"display",
"sequence",
"of",
"the",
"controller",
".",
"First",
"will",
"prepare",
"controller",
"for",
"display",
".",
"Then",
"it",
"will",
"ask",
"the",
"controller",
"to",
"display",
"it",
"s",
"View",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/manage/Controller.php#L142-L153 |
731 | web-complete/core | src/utils/helpers/SecurityHelper.php | SecurityHelper.generateRandomKey | public function generateRandomKey(int $length = 32): string
{
if ($length < 1) {
throw new \RuntimeException('First parameter ($length) must be greater than 0');
}
// always use random_bytes() if it is available
if (\function_exists('random_bytes')) {
return \random_bytes($length);
}
throw new \RuntimeException('Function random_bytes not found');
} | php | public function generateRandomKey(int $length = 32): string
{
if ($length < 1) {
throw new \RuntimeException('First parameter ($length) must be greater than 0');
}
// always use random_bytes() if it is available
if (\function_exists('random_bytes')) {
return \random_bytes($length);
}
throw new \RuntimeException('Function random_bytes not found');
} | [
"public",
"function",
"generateRandomKey",
"(",
"int",
"$",
"length",
"=",
"32",
")",
":",
"string",
"{",
"if",
"(",
"$",
"length",
"<",
"1",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'First parameter ($length) must be greater than 0'",
")",
";",
"}",
"// always use random_bytes() if it is available",
"if",
"(",
"\\",
"function_exists",
"(",
"'random_bytes'",
")",
")",
"{",
"return",
"\\",
"random_bytes",
"(",
"$",
"length",
")",
";",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'Function random_bytes not found'",
")",
";",
"}"
] | Generates specified number of random bytes.
Note that output may not be ASCII.
@see generateRandomString() if you need a string.
@param int $length the number of bytes to generate
@return string the generated random bytes
@throws \RuntimeException | [
"Generates",
"specified",
"number",
"of",
"random",
"bytes",
".",
"Note",
"that",
"output",
"may",
"not",
"be",
"ASCII",
"."
] | d6ccb7847a5aa084eccc547bb77fc3e70bac41c8 | https://github.com/web-complete/core/blob/d6ccb7847a5aa084eccc547bb77fc3e70bac41c8/src/utils/helpers/SecurityHelper.php#L64-L75 |
732 | jeromeklam/freefw | src/FreeFW/Tools/Email.php | Email.verifyFormatting | public static function verifyFormatting($p_address)
{
if (strstr($p_address, "@") == false) {
return false;
} else {
list($user, $domain) = explode('@', $p_address);
if (strstr($domain, '.') == false) {
return false;
} else {
return true;
}
}
} | php | public static function verifyFormatting($p_address)
{
if (strstr($p_address, "@") == false) {
return false;
} else {
list($user, $domain) = explode('@', $p_address);
if (strstr($domain, '.') == false) {
return false;
} else {
return true;
}
}
} | [
"public",
"static",
"function",
"verifyFormatting",
"(",
"$",
"p_address",
")",
"{",
"if",
"(",
"strstr",
"(",
"$",
"p_address",
",",
"\"@\"",
")",
"==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"list",
"(",
"$",
"user",
",",
"$",
"domain",
")",
"=",
"explode",
"(",
"'@'",
",",
"$",
"p_address",
")",
";",
"if",
"(",
"strstr",
"(",
"$",
"domain",
",",
"'.'",
")",
"==",
"false",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"true",
";",
"}",
"}",
"}"
] | Verify email global format
@param string $p_address
@return boolean | [
"Verify",
"email",
"global",
"format"
] | 16ecf24192375c920a070296f396b9d3fd994a1e | https://github.com/jeromeklam/freefw/blob/16ecf24192375c920a070296f396b9d3fd994a1e/src/FreeFW/Tools/Email.php#L56-L68 |
733 | vinala/kernel | src/Security/Hash.php | Hash.make | public static function make($string)
{
$key1 = config('security.key1');
$key2 = config('security.key2');
return sha1(md5($string.'youssef'.$key1)).md5(sha1($string.'Vinala'.$key2));
} | php | public static function make($string)
{
$key1 = config('security.key1');
$key2 = config('security.key2');
return sha1(md5($string.'youssef'.$key1)).md5(sha1($string.'Vinala'.$key2));
} | [
"public",
"static",
"function",
"make",
"(",
"$",
"string",
")",
"{",
"$",
"key1",
"=",
"config",
"(",
"'security.key1'",
")",
";",
"$",
"key2",
"=",
"config",
"(",
"'security.key2'",
")",
";",
"return",
"sha1",
"(",
"md5",
"(",
"$",
"string",
".",
"'youssef'",
".",
"$",
"key1",
")",
")",
".",
"md5",
"(",
"sha1",
"(",
"$",
"string",
".",
"'Vinala'",
".",
"$",
"key2",
")",
")",
";",
"}"
] | A function to create a hash string based on another string.
@param string $string
@return simplexml_load_string | [
"A",
"function",
"to",
"create",
"a",
"hash",
"string",
"based",
"on",
"another",
"string",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Security/Hash.php#L29-L35 |
734 | vinala/kernel | src/Security/Hash.php | Hash.create | public static function create($lenght)
{
$characters = 'abcdefghijk01234lmnopq56789rstuxyvwz';
$charLenght = strlen($characters);
$string = '';
for ($i = 0; $i < $lenght; $i++) {
$index = mt_rand(0, $charLenght - 1);
$string .= $characters[$index];
}
return $string;
} | php | public static function create($lenght)
{
$characters = 'abcdefghijk01234lmnopq56789rstuxyvwz';
$charLenght = strlen($characters);
$string = '';
for ($i = 0; $i < $lenght; $i++) {
$index = mt_rand(0, $charLenght - 1);
$string .= $characters[$index];
}
return $string;
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"lenght",
")",
"{",
"$",
"characters",
"=",
"'abcdefghijk01234lmnopq56789rstuxyvwz'",
";",
"$",
"charLenght",
"=",
"strlen",
"(",
"$",
"characters",
")",
";",
"$",
"string",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"$",
"lenght",
";",
"$",
"i",
"++",
")",
"{",
"$",
"index",
"=",
"mt_rand",
"(",
"0",
",",
"$",
"charLenght",
"-",
"1",
")",
";",
"$",
"string",
".=",
"$",
"characters",
"[",
"$",
"index",
"]",
";",
"}",
"return",
"$",
"string",
";",
"}"
] | Create a hash string.
@param int $lenght
@return string | [
"Create",
"a",
"hash",
"string",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Security/Hash.php#L57-L69 |
735 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth/opauth.php | Auth_Opauth.link_provider | public function link_provider(array $data)
{
// do some validation
if ( ! is_numeric($data['expires']))
{
if ($date = \DateTime::createFromFormat(\DateTime::ISO8601, $data['expires']))
{
$data['expires'] = $date->getTimestamp();
}
elseif ($date = \DateTime::createFromFormat('Y-m-d H:i:s', $data['expires']))
{
$data['expires'] = $date->getTimestamp();
}
else
{
$data['expires'] = time();
}
}
// get rid of old registrations to prevent duplicates
\DB::delete($this->config['table'])->where('uid', '=', $data['uid'])->where('provider', '=', $data['provider'])->execute(static::$db_connection);
// insert the new provider UID
list($insert_id, $rows_affected) = \DB::insert($this->config['table'])->set($data)->execute(static::$db_connection);
return $rows_affected ? $insert_id : false;
} | php | public function link_provider(array $data)
{
// do some validation
if ( ! is_numeric($data['expires']))
{
if ($date = \DateTime::createFromFormat(\DateTime::ISO8601, $data['expires']))
{
$data['expires'] = $date->getTimestamp();
}
elseif ($date = \DateTime::createFromFormat('Y-m-d H:i:s', $data['expires']))
{
$data['expires'] = $date->getTimestamp();
}
else
{
$data['expires'] = time();
}
}
// get rid of old registrations to prevent duplicates
\DB::delete($this->config['table'])->where('uid', '=', $data['uid'])->where('provider', '=', $data['provider'])->execute(static::$db_connection);
// insert the new provider UID
list($insert_id, $rows_affected) = \DB::insert($this->config['table'])->set($data)->execute(static::$db_connection);
return $rows_affected ? $insert_id : false;
} | [
"public",
"function",
"link_provider",
"(",
"array",
"$",
"data",
")",
"{",
"// do some validation",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"data",
"[",
"'expires'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"date",
"=",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"\\",
"DateTime",
"::",
"ISO8601",
",",
"$",
"data",
"[",
"'expires'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'expires'",
"]",
"=",
"$",
"date",
"->",
"getTimestamp",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"date",
"=",
"\\",
"DateTime",
"::",
"createFromFormat",
"(",
"'Y-m-d H:i:s'",
",",
"$",
"data",
"[",
"'expires'",
"]",
")",
")",
"{",
"$",
"data",
"[",
"'expires'",
"]",
"=",
"$",
"date",
"->",
"getTimestamp",
"(",
")",
";",
"}",
"else",
"{",
"$",
"data",
"[",
"'expires'",
"]",
"=",
"time",
"(",
")",
";",
"}",
"}",
"// get rid of old registrations to prevent duplicates",
"\\",
"DB",
"::",
"delete",
"(",
"$",
"this",
"->",
"config",
"[",
"'table'",
"]",
")",
"->",
"where",
"(",
"'uid'",
",",
"'='",
",",
"$",
"data",
"[",
"'uid'",
"]",
")",
"->",
"where",
"(",
"'provider'",
",",
"'='",
",",
"$",
"data",
"[",
"'provider'",
"]",
")",
"->",
"execute",
"(",
"static",
"::",
"$",
"db_connection",
")",
";",
"// insert the new provider UID",
"list",
"(",
"$",
"insert_id",
",",
"$",
"rows_affected",
")",
"=",
"\\",
"DB",
"::",
"insert",
"(",
"$",
"this",
"->",
"config",
"[",
"'table'",
"]",
")",
"->",
"set",
"(",
"$",
"data",
")",
"->",
"execute",
"(",
"static",
"::",
"$",
"db_connection",
")",
";",
"return",
"$",
"rows_affected",
"?",
"$",
"insert_id",
":",
"false",
";",
"}"
] | create a remote entry for this login | [
"create",
"a",
"remote",
"entry",
"for",
"this",
"login"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/opauth.php#L319-L344 |
736 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth/opauth.php | Auth_Opauth.get | public function get($key, $default = null)
{
return is_array($this->response) ? \Arr::get($this->response, $key, $default) : $default;
} | php | public function get($key, $default = null)
{
return is_array($this->response) ? \Arr::get($this->response, $key, $default) : $default;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"is_array",
"(",
"$",
"this",
"->",
"response",
")",
"?",
"\\",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"response",
",",
"$",
"key",
",",
"$",
"default",
")",
":",
"$",
"default",
";",
"}"
] | Get a response value | [
"Get",
"a",
"response",
"value"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/opauth.php#L349-L352 |
737 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth/opauth.php | Auth_Opauth.callback | protected function callback()
{
// fetch the response and decode it
$this->response = \Input::get('opauth', false) and $this->response = unserialize(base64_decode($this->response));
// did we receive a response at all?
if ( ! $this->response)
{
throw new \OpauthException('no valid response received in the callback');
}
// did we receive one, but was it an error
if (array_key_exists('error', $this->response))
{
throw new \OpauthException('Authentication error: the callback returned an error auth response');
}
// validate the response
if ($this->get('auth') === null or $this->get('timestamp') === null or
$this->get('signature') === null or $this->get('auth.provider') === null or $this->get('auth.uid') === null)
{
throw new \OpauthException('Invalid auth response: Missing key auth response components');
}
elseif ( ! $this->opauth->validate(sha1(print_r($this->get('auth'), true)), $this->get('timestamp'), $this->get('signature'), $reason))
{
throw new \OpauthException('Invalid auth response: '.$reason);
}
} | php | protected function callback()
{
// fetch the response and decode it
$this->response = \Input::get('opauth', false) and $this->response = unserialize(base64_decode($this->response));
// did we receive a response at all?
if ( ! $this->response)
{
throw new \OpauthException('no valid response received in the callback');
}
// did we receive one, but was it an error
if (array_key_exists('error', $this->response))
{
throw new \OpauthException('Authentication error: the callback returned an error auth response');
}
// validate the response
if ($this->get('auth') === null or $this->get('timestamp') === null or
$this->get('signature') === null or $this->get('auth.provider') === null or $this->get('auth.uid') === null)
{
throw new \OpauthException('Invalid auth response: Missing key auth response components');
}
elseif ( ! $this->opauth->validate(sha1(print_r($this->get('auth'), true)), $this->get('timestamp'), $this->get('signature'), $reason))
{
throw new \OpauthException('Invalid auth response: '.$reason);
}
} | [
"protected",
"function",
"callback",
"(",
")",
"{",
"// fetch the response and decode it",
"$",
"this",
"->",
"response",
"=",
"\\",
"Input",
"::",
"get",
"(",
"'opauth'",
",",
"false",
")",
"and",
"$",
"this",
"->",
"response",
"=",
"unserialize",
"(",
"base64_decode",
"(",
"$",
"this",
"->",
"response",
")",
")",
";",
"// did we receive a response at all?",
"if",
"(",
"!",
"$",
"this",
"->",
"response",
")",
"{",
"throw",
"new",
"\\",
"OpauthException",
"(",
"'no valid response received in the callback'",
")",
";",
"}",
"// did we receive one, but was it an error",
"if",
"(",
"array_key_exists",
"(",
"'error'",
",",
"$",
"this",
"->",
"response",
")",
")",
"{",
"throw",
"new",
"\\",
"OpauthException",
"(",
"'Authentication error: the callback returned an error auth response'",
")",
";",
"}",
"// validate the response",
"if",
"(",
"$",
"this",
"->",
"get",
"(",
"'auth'",
")",
"===",
"null",
"or",
"$",
"this",
"->",
"get",
"(",
"'timestamp'",
")",
"===",
"null",
"or",
"$",
"this",
"->",
"get",
"(",
"'signature'",
")",
"===",
"null",
"or",
"$",
"this",
"->",
"get",
"(",
"'auth.provider'",
")",
"===",
"null",
"or",
"$",
"this",
"->",
"get",
"(",
"'auth.uid'",
")",
"===",
"null",
")",
"{",
"throw",
"new",
"\\",
"OpauthException",
"(",
"'Invalid auth response: Missing key auth response components'",
")",
";",
"}",
"elseif",
"(",
"!",
"$",
"this",
"->",
"opauth",
"->",
"validate",
"(",
"sha1",
"(",
"print_r",
"(",
"$",
"this",
"->",
"get",
"(",
"'auth'",
")",
",",
"true",
")",
")",
",",
"$",
"this",
"->",
"get",
"(",
"'timestamp'",
")",
",",
"$",
"this",
"->",
"get",
"(",
"'signature'",
")",
",",
"$",
"reason",
")",
")",
"{",
"throw",
"new",
"\\",
"OpauthException",
"(",
"'Invalid auth response: '",
".",
"$",
"reason",
")",
";",
"}",
"}"
] | fetch the callback response | [
"fetch",
"the",
"callback",
"response"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/opauth.php#L357-L384 |
738 | indigophp-archive/codeception-fuel-module | fuel/fuel/packages/auth/classes/auth/opauth.php | Auth_Opauth.create_user | protected function create_user(array $user)
{
$user_id = \Auth::create_user(
// username
isset($user['nickname']) ? $user['nickname'] : null,
// password (random string will do if none provided)
isset($user['password']) ? $user['password'] : \Str::random(),
// email address
isset($user['email']) ? $user['email'] : null,
// which group are they in?
\Config::get('opauth.default_group', -1),
// extra information
array(
// got their name? full name? or first and last to make up a full name?
'fullname' => isset($user['name']) ? $user['name'] : (
isset($user['full_name']) ? $user['full_name'] : (
isset($user['first_name'], $user['last_name']) ? $user['first_name'].' '.$user['last_name'] : null
)
),
)
);
return $user_id ?: false;
} | php | protected function create_user(array $user)
{
$user_id = \Auth::create_user(
// username
isset($user['nickname']) ? $user['nickname'] : null,
// password (random string will do if none provided)
isset($user['password']) ? $user['password'] : \Str::random(),
// email address
isset($user['email']) ? $user['email'] : null,
// which group are they in?
\Config::get('opauth.default_group', -1),
// extra information
array(
// got their name? full name? or first and last to make up a full name?
'fullname' => isset($user['name']) ? $user['name'] : (
isset($user['full_name']) ? $user['full_name'] : (
isset($user['first_name'], $user['last_name']) ? $user['first_name'].' '.$user['last_name'] : null
)
),
)
);
return $user_id ?: false;
} | [
"protected",
"function",
"create_user",
"(",
"array",
"$",
"user",
")",
"{",
"$",
"user_id",
"=",
"\\",
"Auth",
"::",
"create_user",
"(",
"// username",
"isset",
"(",
"$",
"user",
"[",
"'nickname'",
"]",
")",
"?",
"$",
"user",
"[",
"'nickname'",
"]",
":",
"null",
",",
"// password (random string will do if none provided)",
"isset",
"(",
"$",
"user",
"[",
"'password'",
"]",
")",
"?",
"$",
"user",
"[",
"'password'",
"]",
":",
"\\",
"Str",
"::",
"random",
"(",
")",
",",
"// email address",
"isset",
"(",
"$",
"user",
"[",
"'email'",
"]",
")",
"?",
"$",
"user",
"[",
"'email'",
"]",
":",
"null",
",",
"// which group are they in?",
"\\",
"Config",
"::",
"get",
"(",
"'opauth.default_group'",
",",
"-",
"1",
")",
",",
"// extra information",
"array",
"(",
"// got their name? full name? or first and last to make up a full name?",
"'fullname'",
"=>",
"isset",
"(",
"$",
"user",
"[",
"'name'",
"]",
")",
"?",
"$",
"user",
"[",
"'name'",
"]",
":",
"(",
"isset",
"(",
"$",
"user",
"[",
"'full_name'",
"]",
")",
"?",
"$",
"user",
"[",
"'full_name'",
"]",
":",
"(",
"isset",
"(",
"$",
"user",
"[",
"'first_name'",
"]",
",",
"$",
"user",
"[",
"'last_name'",
"]",
")",
"?",
"$",
"user",
"[",
"'first_name'",
"]",
".",
"' '",
".",
"$",
"user",
"[",
"'last_name'",
"]",
":",
"null",
")",
")",
",",
")",
")",
";",
"return",
"$",
"user_id",
"?",
":",
"false",
";",
"}"
] | use Auth to create a new user, in case we've received enough information to do so
@param array array with the raw Opauth response user fields
@return mixed id of the user record created, or false if the create failed | [
"use",
"Auth",
"to",
"create",
"a",
"new",
"user",
"in",
"case",
"we",
"ve",
"received",
"enough",
"information",
"to",
"do",
"so"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/packages/auth/classes/auth/opauth.php#L393-L422 |
739 | OWeb/OWeb-Framework | OWeb/defaults/extensions/bbcode/JBBCode/ElementNode.php | ElementNode.addChild | public function addChild(Node $child) {
array_push($this->children, $child);
$child->setParent( $this );
} | php | public function addChild(Node $child) {
array_push($this->children, $child);
$child->setParent( $this );
} | [
"public",
"function",
"addChild",
"(",
"Node",
"$",
"child",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"children",
",",
"$",
"child",
")",
";",
"$",
"child",
"->",
"setParent",
"(",
"$",
"this",
")",
";",
"}"
] | Adds a child to this node's content. A child may be a TextNode, or another ElementNode... or anything else
that may extend the abstract Node class.
@param child the node to add as a child | [
"Adds",
"a",
"child",
"to",
"this",
"node",
"s",
"content",
".",
"A",
"child",
"may",
"be",
"a",
"TextNode",
"or",
"another",
"ElementNode",
"...",
"or",
"anything",
"else",
"that",
"may",
"extend",
"the",
"abstract",
"Node",
"class",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/JBBCode/ElementNode.php#L142-L145 |
740 | OWeb/OWeb-Framework | OWeb/defaults/extensions/bbcode/JBBCode/ElementNode.php | ElementNode.removeChild | public function removeChild(Node $child) {
foreach( $this->children as $key => $value) {
if( $value == $child)
unset($this->children[$key]);
}
} | php | public function removeChild(Node $child) {
foreach( $this->children as $key => $value) {
if( $value == $child)
unset($this->children[$key]);
}
} | [
"public",
"function",
"removeChild",
"(",
"Node",
"$",
"child",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"==",
"$",
"child",
")",
"unset",
"(",
"$",
"this",
"->",
"children",
"[",
"$",
"key",
"]",
")",
";",
"}",
"}"
] | Removes a child from this node's contnet.
@param child the child node to remove | [
"Removes",
"a",
"child",
"from",
"this",
"node",
"s",
"contnet",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/JBBCode/ElementNode.php#L152-L157 |
741 | OWeb/OWeb-Framework | OWeb/defaults/extensions/bbcode/JBBCode/ElementNode.php | ElementNode.closestParentOfType | public function closestParentOfType( $str ) {
$str = strtolower($str);
$currentEl = $this;
while( strtolower($currentEl->getTagName()) != $str && $currentEl->hasParent() )
$currentEl = $currentEl->getParent();
if( strtolower($currentEl->getTagName()) != $str )
return null;
else
return $currentEl;
} | php | public function closestParentOfType( $str ) {
$str = strtolower($str);
$currentEl = $this;
while( strtolower($currentEl->getTagName()) != $str && $currentEl->hasParent() )
$currentEl = $currentEl->getParent();
if( strtolower($currentEl->getTagName()) != $str )
return null;
else
return $currentEl;
} | [
"public",
"function",
"closestParentOfType",
"(",
"$",
"str",
")",
"{",
"$",
"str",
"=",
"strtolower",
"(",
"$",
"str",
")",
";",
"$",
"currentEl",
"=",
"$",
"this",
";",
"while",
"(",
"strtolower",
"(",
"$",
"currentEl",
"->",
"getTagName",
"(",
")",
")",
"!=",
"$",
"str",
"&&",
"$",
"currentEl",
"->",
"hasParent",
"(",
")",
")",
"$",
"currentEl",
"=",
"$",
"currentEl",
"->",
"getParent",
"(",
")",
";",
"if",
"(",
"strtolower",
"(",
"$",
"currentEl",
"->",
"getTagName",
"(",
")",
")",
"!=",
"$",
"str",
")",
"return",
"null",
";",
"else",
"return",
"$",
"currentEl",
";",
"}"
] | Traverses the parse tree upwards, going from parent to parent, until it finds a parent who has the given tag name. Returns the
parent with the matching tag name if it exists, otherwise returns null.
@param str the tag name to search for
@return the closest parent with the given tag name | [
"Traverses",
"the",
"parse",
"tree",
"upwards",
"going",
"from",
"parent",
"to",
"parent",
"until",
"it",
"finds",
"a",
"parent",
"who",
"has",
"the",
"given",
"tag",
"name",
".",
"Returns",
"the",
"parent",
"with",
"the",
"matching",
"tag",
"name",
"if",
"it",
"exists",
"otherwise",
"returns",
"null",
"."
] | fb441f51afb16860b0c946a55c36c789fbb125fa | https://github.com/OWeb/OWeb-Framework/blob/fb441f51afb16860b0c946a55c36c789fbb125fa/OWeb/defaults/extensions/bbcode/JBBCode/ElementNode.php#L186-L197 |
742 | Humanized/yii2-clihelpers | controllers/Controller.php | Controller.importCSV | protected function importCSV($config, $fn = NULL)
{
$fileName = $config['fileName'];
$file = fopen($fileName, "r");
while (!feof($file)) {
$record = fgetcsv($file, 0, $config['delimiter']);
if (isset($record[0])) {
//Parse attribute map
$attributes = $this->parseAttributeMap($config['attributeMap'], $record);
isset($fn) ? $fn($attributes, $config) : NULL;
var_dump($attributes);
$model = new $config['saveModel']();
$model->setAttributes($attributes);
$model->save();
} else {
break;
}
}
} | php | protected function importCSV($config, $fn = NULL)
{
$fileName = $config['fileName'];
$file = fopen($fileName, "r");
while (!feof($file)) {
$record = fgetcsv($file, 0, $config['delimiter']);
if (isset($record[0])) {
//Parse attribute map
$attributes = $this->parseAttributeMap($config['attributeMap'], $record);
isset($fn) ? $fn($attributes, $config) : NULL;
var_dump($attributes);
$model = new $config['saveModel']();
$model->setAttributes($attributes);
$model->save();
} else {
break;
}
}
} | [
"protected",
"function",
"importCSV",
"(",
"$",
"config",
",",
"$",
"fn",
"=",
"NULL",
")",
"{",
"$",
"fileName",
"=",
"$",
"config",
"[",
"'fileName'",
"]",
";",
"$",
"file",
"=",
"fopen",
"(",
"$",
"fileName",
",",
"\"r\"",
")",
";",
"while",
"(",
"!",
"feof",
"(",
"$",
"file",
")",
")",
"{",
"$",
"record",
"=",
"fgetcsv",
"(",
"$",
"file",
",",
"0",
",",
"$",
"config",
"[",
"'delimiter'",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"record",
"[",
"0",
"]",
")",
")",
"{",
"//Parse attribute map",
"$",
"attributes",
"=",
"$",
"this",
"->",
"parseAttributeMap",
"(",
"$",
"config",
"[",
"'attributeMap'",
"]",
",",
"$",
"record",
")",
";",
"isset",
"(",
"$",
"fn",
")",
"?",
"$",
"fn",
"(",
"$",
"attributes",
",",
"$",
"config",
")",
":",
"NULL",
";",
"var_dump",
"(",
"$",
"attributes",
")",
";",
"$",
"model",
"=",
"new",
"$",
"config",
"[",
"'saveModel'",
"]",
"(",
")",
";",
"$",
"model",
"->",
"setAttributes",
"(",
"$",
"attributes",
")",
";",
"$",
"model",
"->",
"save",
"(",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"}"
] | Import a CSV file
Imports a CSV table, in to a database provided an array of configuration options
- modelClassPath string
- columnMap array<int>=string Map of the columns
Protected as such methods can be overwritten and or extended
@param array<mixed> $config | [
"Import",
"a",
"CSV",
"file"
] | 74c97232c098e7982866bbae7efdaa738052e5f1 | https://github.com/Humanized/yii2-clihelpers/blob/74c97232c098e7982866bbae7efdaa738052e5f1/controllers/Controller.php#L117-L137 |
743 | pletfix/core | src/Services/Flash.php | Flash.session | private function session()
{
if ($this->session === null) {
$this->session = DI::getInstance()->get('session');
}
return $this->session;
} | php | private function session()
{
if ($this->session === null) {
$this->session = DI::getInstance()->get('session');
}
return $this->session;
} | [
"private",
"function",
"session",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"session",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"session",
"=",
"DI",
"::",
"getInstance",
"(",
")",
"->",
"get",
"(",
"'session'",
")",
";",
"}",
"return",
"$",
"this",
"->",
"session",
";",
"}"
] | Get the session.
@return Session | [
"Get",
"the",
"session",
"."
] | 974945500f278eb6c1779832e08bbfca1007a7b3 | https://github.com/pletfix/core/blob/974945500f278eb6c1779832e08bbfca1007a7b3/src/Services/Flash.php#L24-L31 |
744 | alister/faker-extensions | src/Skills.php | Skills.skills | public static function skills($qty = 1, $max = 0)
{
if ($max > 0) {
$qty = self::numberBetween($qty, $max);
}
return self::randomElements(self::$skills, $qty);
} | php | public static function skills($qty = 1, $max = 0)
{
if ($max > 0) {
$qty = self::numberBetween($qty, $max);
}
return self::randomElements(self::$skills, $qty);
} | [
"public",
"static",
"function",
"skills",
"(",
"$",
"qty",
"=",
"1",
",",
"$",
"max",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"max",
">",
"0",
")",
"{",
"$",
"qty",
"=",
"self",
"::",
"numberBetween",
"(",
"$",
"qty",
",",
"$",
"max",
")",
";",
"}",
"return",
"self",
"::",
"randomElements",
"(",
"self",
"::",
"$",
"skills",
",",
"$",
"qty",
")",
";",
"}"
] | Generate fake 'skills', from a list.
@example 'zf2' or ['css', 'redis'] | [
"Generate",
"fake",
"skills",
"from",
"a",
"list",
"."
] | ed0b6177dc07eaeb98212e1e1efd640ebcba85ac | https://github.com/alister/faker-extensions/blob/ed0b6177dc07eaeb98212e1e1efd640ebcba85ac/src/Skills.php#L29-L36 |
745 | bishopb/vanilla | applications/dashboard/models/class.searchmodel.php | SearchModel.AddMatchSql | public function AddMatchSql($Sql, $Columns, $LikeRelavenceColumn = '') {
if ($this->_SearchMode == 'like') {
if ($LikeRelavenceColumn)
$Sql->Select($LikeRelavenceColumn, '', 'Relavence');
else
$Sql->Select(1, '', 'Relavence');
$Sql->BeginWhereGroup();
$ColumnsArray = explode(',', $Columns);
$First = TRUE;
foreach ($ColumnsArray as $Column) {
$Column = trim($Column);
$Param = $this->Parameter();
if ($First) {
$Sql->Where("$Column like $Param", NULL, FALSE, FALSE);
$First = FALSE;
} else {
$Sql->OrWhere("$Column like $Param", NULL, FALSE, FALSE);
}
}
$Sql->EndWhereGroup();
} else {
$Boolean = $this->_SearchMode == 'boolean' ? ' in boolean mode' : '';
$Param = $this->Parameter();
$Sql->Select($Columns, "match(%s) against($Param{$Boolean})", 'Relavence');
$Param = $this->Parameter();
$Sql->Where("match($Columns) against ($Param{$Boolean})", NULL, FALSE, FALSE);
}
} | php | public function AddMatchSql($Sql, $Columns, $LikeRelavenceColumn = '') {
if ($this->_SearchMode == 'like') {
if ($LikeRelavenceColumn)
$Sql->Select($LikeRelavenceColumn, '', 'Relavence');
else
$Sql->Select(1, '', 'Relavence');
$Sql->BeginWhereGroup();
$ColumnsArray = explode(',', $Columns);
$First = TRUE;
foreach ($ColumnsArray as $Column) {
$Column = trim($Column);
$Param = $this->Parameter();
if ($First) {
$Sql->Where("$Column like $Param", NULL, FALSE, FALSE);
$First = FALSE;
} else {
$Sql->OrWhere("$Column like $Param", NULL, FALSE, FALSE);
}
}
$Sql->EndWhereGroup();
} else {
$Boolean = $this->_SearchMode == 'boolean' ? ' in boolean mode' : '';
$Param = $this->Parameter();
$Sql->Select($Columns, "match(%s) against($Param{$Boolean})", 'Relavence');
$Param = $this->Parameter();
$Sql->Where("match($Columns) against ($Param{$Boolean})", NULL, FALSE, FALSE);
}
} | [
"public",
"function",
"AddMatchSql",
"(",
"$",
"Sql",
",",
"$",
"Columns",
",",
"$",
"LikeRelavenceColumn",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_SearchMode",
"==",
"'like'",
")",
"{",
"if",
"(",
"$",
"LikeRelavenceColumn",
")",
"$",
"Sql",
"->",
"Select",
"(",
"$",
"LikeRelavenceColumn",
",",
"''",
",",
"'Relavence'",
")",
";",
"else",
"$",
"Sql",
"->",
"Select",
"(",
"1",
",",
"''",
",",
"'Relavence'",
")",
";",
"$",
"Sql",
"->",
"BeginWhereGroup",
"(",
")",
";",
"$",
"ColumnsArray",
"=",
"explode",
"(",
"','",
",",
"$",
"Columns",
")",
";",
"$",
"First",
"=",
"TRUE",
";",
"foreach",
"(",
"$",
"ColumnsArray",
"as",
"$",
"Column",
")",
"{",
"$",
"Column",
"=",
"trim",
"(",
"$",
"Column",
")",
";",
"$",
"Param",
"=",
"$",
"this",
"->",
"Parameter",
"(",
")",
";",
"if",
"(",
"$",
"First",
")",
"{",
"$",
"Sql",
"->",
"Where",
"(",
"\"$Column like $Param\"",
",",
"NULL",
",",
"FALSE",
",",
"FALSE",
")",
";",
"$",
"First",
"=",
"FALSE",
";",
"}",
"else",
"{",
"$",
"Sql",
"->",
"OrWhere",
"(",
"\"$Column like $Param\"",
",",
"NULL",
",",
"FALSE",
",",
"FALSE",
")",
";",
"}",
"}",
"$",
"Sql",
"->",
"EndWhereGroup",
"(",
")",
";",
"}",
"else",
"{",
"$",
"Boolean",
"=",
"$",
"this",
"->",
"_SearchMode",
"==",
"'boolean'",
"?",
"' in boolean mode'",
":",
"''",
";",
"$",
"Param",
"=",
"$",
"this",
"->",
"Parameter",
"(",
")",
";",
"$",
"Sql",
"->",
"Select",
"(",
"$",
"Columns",
",",
"\"match(%s) against($Param{$Boolean})\"",
",",
"'Relavence'",
")",
";",
"$",
"Param",
"=",
"$",
"this",
"->",
"Parameter",
"(",
")",
";",
"$",
"Sql",
"->",
"Where",
"(",
"\"match($Columns) against ($Param{$Boolean})\"",
",",
"NULL",
",",
"FALSE",
",",
"FALSE",
")",
";",
"}",
"}"
] | Add the sql to perform a search.
@param Gdn_SQLDriver $Sql
@param string $Columns a comma seperated list of columns to search on. | [
"Add",
"the",
"sql",
"to",
"perform",
"a",
"search",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.searchmodel.php#L33-L66 |
746 | tlumx/tlumx-router | src/RouteCollector.php | RouteCollector.addRoute | public function addRoute(
string $name,
array $methods,
string $pattern,
array $middlewares,
array $handler,
string $group = null
) {
$this->routes[$name] = [
'methods' => $methods,
'pattern' => $pattern,
'middlewares' => $middlewares,
'handler' => $handler,
'group' => $group
];
} | php | public function addRoute(
string $name,
array $methods,
string $pattern,
array $middlewares,
array $handler,
string $group = null
) {
$this->routes[$name] = [
'methods' => $methods,
'pattern' => $pattern,
'middlewares' => $middlewares,
'handler' => $handler,
'group' => $group
];
} | [
"public",
"function",
"addRoute",
"(",
"string",
"$",
"name",
",",
"array",
"$",
"methods",
",",
"string",
"$",
"pattern",
",",
"array",
"$",
"middlewares",
",",
"array",
"$",
"handler",
",",
"string",
"$",
"group",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"routes",
"[",
"$",
"name",
"]",
"=",
"[",
"'methods'",
"=>",
"$",
"methods",
",",
"'pattern'",
"=>",
"$",
"pattern",
",",
"'middlewares'",
"=>",
"$",
"middlewares",
",",
"'handler'",
"=>",
"$",
"handler",
",",
"'group'",
"=>",
"$",
"group",
"]",
";",
"}"
] | Add route to collection.
@param string $name
@param array $methods
@param string $pattern
@param array $middlewares
@param array $handler
@param string $group | [
"Add",
"route",
"to",
"collection",
"."
] | bf0c2a1e217198fe5d804298ffa423c4d9b72a9f | https://github.com/tlumx/tlumx-router/blob/bf0c2a1e217198fe5d804298ffa423c4d9b72a9f/src/RouteCollector.php#L44-L59 |
747 | tlumx/tlumx-router | src/RouteCollector.php | RouteCollector.addGroup | public function addGroup(string $name, string $prefix = '', array $middlewares = [])
{
$this->groups[$name] = [$prefix, $middlewares];
} | php | public function addGroup(string $name, string $prefix = '', array $middlewares = [])
{
$this->groups[$name] = [$prefix, $middlewares];
} | [
"public",
"function",
"addGroup",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"prefix",
"=",
"''",
",",
"array",
"$",
"middlewares",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"groups",
"[",
"$",
"name",
"]",
"=",
"[",
"$",
"prefix",
",",
"$",
"middlewares",
"]",
";",
"}"
] | Add group for routes to collection.
@param string $name
@param string $prefix
@param array $middlewares | [
"Add",
"group",
"for",
"routes",
"to",
"collection",
"."
] | bf0c2a1e217198fe5d804298ffa423c4d9b72a9f | https://github.com/tlumx/tlumx-router/blob/bf0c2a1e217198fe5d804298ffa423c4d9b72a9f/src/RouteCollector.php#L68-L71 |
748 | tlumx/tlumx-router | src/RouteCollector.php | RouteCollector.generateRoutesData | public function generateRoutesData(RouteParser $routeParser, DataGenerator $dataGenerator)
{
$routes = [];
foreach ($this->routes as $name => $route) {
if ($route['group']) {
if (!isset($this->groups[$route['group']])) {
throw new \LogicException(sprintf(
'The route group "%s" is not found',
$route['group']
));
}
$pattern = $this->groups[$route['group']][0] . $route['pattern'];
$middlewares = array_merge($this->groups[$route['group']][1], $route['middlewares']);
} else {
$pattern = $route['pattern'];
$middlewares = $route['middlewares'];
}
$routeDatas = $routeParser->parse($pattern);
$this->addToDataGenerator($route['methods'], $routeDatas, $name, $dataGenerator);
$routes[$name] = [
'datas' => $routeDatas,
'methods' => $route['methods'],
'pattern' => $pattern,
'middlewares' => $middlewares,
'handler' => $route['handler'],
'group' => $route['group']
];
}
return ['routes' => $routes, 'dispatch_data' => $dataGenerator->getData()];
} | php | public function generateRoutesData(RouteParser $routeParser, DataGenerator $dataGenerator)
{
$routes = [];
foreach ($this->routes as $name => $route) {
if ($route['group']) {
if (!isset($this->groups[$route['group']])) {
throw new \LogicException(sprintf(
'The route group "%s" is not found',
$route['group']
));
}
$pattern = $this->groups[$route['group']][0] . $route['pattern'];
$middlewares = array_merge($this->groups[$route['group']][1], $route['middlewares']);
} else {
$pattern = $route['pattern'];
$middlewares = $route['middlewares'];
}
$routeDatas = $routeParser->parse($pattern);
$this->addToDataGenerator($route['methods'], $routeDatas, $name, $dataGenerator);
$routes[$name] = [
'datas' => $routeDatas,
'methods' => $route['methods'],
'pattern' => $pattern,
'middlewares' => $middlewares,
'handler' => $route['handler'],
'group' => $route['group']
];
}
return ['routes' => $routes, 'dispatch_data' => $dataGenerator->getData()];
} | [
"public",
"function",
"generateRoutesData",
"(",
"RouteParser",
"$",
"routeParser",
",",
"DataGenerator",
"$",
"dataGenerator",
")",
"{",
"$",
"routes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"routes",
"as",
"$",
"name",
"=>",
"$",
"route",
")",
"{",
"if",
"(",
"$",
"route",
"[",
"'group'",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"groups",
"[",
"$",
"route",
"[",
"'group'",
"]",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"LogicException",
"(",
"sprintf",
"(",
"'The route group \"%s\" is not found'",
",",
"$",
"route",
"[",
"'group'",
"]",
")",
")",
";",
"}",
"$",
"pattern",
"=",
"$",
"this",
"->",
"groups",
"[",
"$",
"route",
"[",
"'group'",
"]",
"]",
"[",
"0",
"]",
".",
"$",
"route",
"[",
"'pattern'",
"]",
";",
"$",
"middlewares",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"groups",
"[",
"$",
"route",
"[",
"'group'",
"]",
"]",
"[",
"1",
"]",
",",
"$",
"route",
"[",
"'middlewares'",
"]",
")",
";",
"}",
"else",
"{",
"$",
"pattern",
"=",
"$",
"route",
"[",
"'pattern'",
"]",
";",
"$",
"middlewares",
"=",
"$",
"route",
"[",
"'middlewares'",
"]",
";",
"}",
"$",
"routeDatas",
"=",
"$",
"routeParser",
"->",
"parse",
"(",
"$",
"pattern",
")",
";",
"$",
"this",
"->",
"addToDataGenerator",
"(",
"$",
"route",
"[",
"'methods'",
"]",
",",
"$",
"routeDatas",
",",
"$",
"name",
",",
"$",
"dataGenerator",
")",
";",
"$",
"routes",
"[",
"$",
"name",
"]",
"=",
"[",
"'datas'",
"=>",
"$",
"routeDatas",
",",
"'methods'",
"=>",
"$",
"route",
"[",
"'methods'",
"]",
",",
"'pattern'",
"=>",
"$",
"pattern",
",",
"'middlewares'",
"=>",
"$",
"middlewares",
",",
"'handler'",
"=>",
"$",
"route",
"[",
"'handler'",
"]",
",",
"'group'",
"=>",
"$",
"route",
"[",
"'group'",
"]",
"]",
";",
"}",
"return",
"[",
"'routes'",
"=>",
"$",
"routes",
",",
"'dispatch_data'",
"=>",
"$",
"dataGenerator",
"->",
"getData",
"(",
")",
"]",
";",
"}"
] | Generate routes data for FastRouter
@param RouteParser $routeParser
@param DataGenerator $dataGenerator
@return array | [
"Generate",
"routes",
"data",
"for",
"FastRouter"
] | bf0c2a1e217198fe5d804298ffa423c4d9b72a9f | https://github.com/tlumx/tlumx-router/blob/bf0c2a1e217198fe5d804298ffa423c4d9b72a9f/src/RouteCollector.php#L80-L113 |
749 | tlumx/tlumx-router | src/RouteCollector.php | RouteCollector.addToDataGenerator | protected function addToDataGenerator(
array $methods,
array $routeDatas,
string $routeName,
DataGenerator $dataGenerator
) : DataGenerator {
foreach ($methods as $method) {
foreach ($routeDatas as $routeData) {
$dataGenerator->addRoute($method, $routeData, $routeName);
}
}
return $dataGenerator;
} | php | protected function addToDataGenerator(
array $methods,
array $routeDatas,
string $routeName,
DataGenerator $dataGenerator
) : DataGenerator {
foreach ($methods as $method) {
foreach ($routeDatas as $routeData) {
$dataGenerator->addRoute($method, $routeData, $routeName);
}
}
return $dataGenerator;
} | [
"protected",
"function",
"addToDataGenerator",
"(",
"array",
"$",
"methods",
",",
"array",
"$",
"routeDatas",
",",
"string",
"$",
"routeName",
",",
"DataGenerator",
"$",
"dataGenerator",
")",
":",
"DataGenerator",
"{",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"foreach",
"(",
"$",
"routeDatas",
"as",
"$",
"routeData",
")",
"{",
"$",
"dataGenerator",
"->",
"addRoute",
"(",
"$",
"method",
",",
"$",
"routeData",
",",
"$",
"routeName",
")",
";",
"}",
"}",
"return",
"$",
"dataGenerator",
";",
"}"
] | Set route data to DataGenerator
@param array $methods
@param array $routeDatas
@param DataGenerator $dataGenerator
@return DataGenerator | [
"Set",
"route",
"data",
"to",
"DataGenerator"
] | bf0c2a1e217198fe5d804298ffa423c4d9b72a9f | https://github.com/tlumx/tlumx-router/blob/bf0c2a1e217198fe5d804298ffa423c4d9b72a9f/src/RouteCollector.php#L123-L136 |
750 | silverorange/Net_Notifier | Net/Notifier/WebSocket/FrameParser.php | Net_Notifier_WebSocket_FrameParser.parse | public function parse($data)
{
$frames = array();
while ($data != '') {
$data = $this->currentFrame->parse($data);
if ($data != '') {
$frames[] = $this->currentFrame;
$this->currentFrame = new Net_Notifier_WebSocket_Frame();
}
}
// if we received exactly enough data, the last frame is also complete
$state = $this->currentFrame->getState();
if ($state === Net_Notifier_WebSocket_Frame::STATE_DONE) {
$frames[] = $this->currentFrame;
$this->currentFrame = new Net_Notifier_WebSocket_Frame();
}
return $frames;
} | php | public function parse($data)
{
$frames = array();
while ($data != '') {
$data = $this->currentFrame->parse($data);
if ($data != '') {
$frames[] = $this->currentFrame;
$this->currentFrame = new Net_Notifier_WebSocket_Frame();
}
}
// if we received exactly enough data, the last frame is also complete
$state = $this->currentFrame->getState();
if ($state === Net_Notifier_WebSocket_Frame::STATE_DONE) {
$frames[] = $this->currentFrame;
$this->currentFrame = new Net_Notifier_WebSocket_Frame();
}
return $frames;
} | [
"public",
"function",
"parse",
"(",
"$",
"data",
")",
"{",
"$",
"frames",
"=",
"array",
"(",
")",
";",
"while",
"(",
"$",
"data",
"!=",
"''",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"currentFrame",
"->",
"parse",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"data",
"!=",
"''",
")",
"{",
"$",
"frames",
"[",
"]",
"=",
"$",
"this",
"->",
"currentFrame",
";",
"$",
"this",
"->",
"currentFrame",
"=",
"new",
"Net_Notifier_WebSocket_Frame",
"(",
")",
";",
"}",
"}",
"// if we received exactly enough data, the last frame is also complete",
"$",
"state",
"=",
"$",
"this",
"->",
"currentFrame",
"->",
"getState",
"(",
")",
";",
"if",
"(",
"$",
"state",
"===",
"Net_Notifier_WebSocket_Frame",
"::",
"STATE_DONE",
")",
"{",
"$",
"frames",
"[",
"]",
"=",
"$",
"this",
"->",
"currentFrame",
";",
"$",
"this",
"->",
"currentFrame",
"=",
"new",
"Net_Notifier_WebSocket_Frame",
"(",
")",
";",
"}",
"return",
"$",
"frames",
";",
"}"
] | Parses WebSocket frames out of a raw data stream
Any numbe of frames may be parsed. If the data chunk contains no
complete frames, no frames may be returned. The frame parses maintains
its state so subsequent data reads can be passed to this method to
complete partial frames.
@param string $data the raw data.
@return array an array of parsed {@link Net_Notifier_WebSocket_Frame}
objects. | [
"Parses",
"WebSocket",
"frames",
"out",
"of",
"a",
"raw",
"data",
"stream"
] | b446e27cd1bebd58ba89243cde1272c5d281d3fb | https://github.com/silverorange/Net_Notifier/blob/b446e27cd1bebd58ba89243cde1272c5d281d3fb/Net/Notifier/WebSocket/FrameParser.php#L82-L102 |
751 | mvccore/ext-view-helper-formatmoney | src/MvcCore/Ext/Views/Helpers/FormatMoneyHelper.php | FormatMoneyHelper.formatByIntlMoneyFormatter | protected function formatByIntlMoneyFormatter ($valueToFormat = 0.0, $decimalsCount = NULL, $currency = NULL) {
$formatter = $this->getIntlNumberFormatter(
$this->langAndLocale,
\NumberFormatter::CURRENCY,
NULL,
($decimalsCount !== NULL
? [\NumberFormatter::FRACTION_DIGITS => $decimalsCount]
: [])
);
if ($currency === NULL) {
if ($this->defaultCurrency !== NULL) {
// try to get default currency
$currency = $this->defaultCurrency;
} else {
// try to get currency from localized formatter
$currency = \numfmt_get_symbol($formatter, \NumberFormatter::INTL_CURRENCY_SYMBOL);
if (mb_strlen($currency) !== 3) {
// try to get currency by system locale settings, by formatting conventions
if ($this->encodingConversion === NULL) {
$this->setUpSystemLocaleAndEncodings();
$this->setUpLocaleConventions();
}
$currency = $this->localeConventions->int_curr_symbol;
}
}
}
return \numfmt_format_currency($formatter, $valueToFormat, $currency);
} | php | protected function formatByIntlMoneyFormatter ($valueToFormat = 0.0, $decimalsCount = NULL, $currency = NULL) {
$formatter = $this->getIntlNumberFormatter(
$this->langAndLocale,
\NumberFormatter::CURRENCY,
NULL,
($decimalsCount !== NULL
? [\NumberFormatter::FRACTION_DIGITS => $decimalsCount]
: [])
);
if ($currency === NULL) {
if ($this->defaultCurrency !== NULL) {
// try to get default currency
$currency = $this->defaultCurrency;
} else {
// try to get currency from localized formatter
$currency = \numfmt_get_symbol($formatter, \NumberFormatter::INTL_CURRENCY_SYMBOL);
if (mb_strlen($currency) !== 3) {
// try to get currency by system locale settings, by formatting conventions
if ($this->encodingConversion === NULL) {
$this->setUpSystemLocaleAndEncodings();
$this->setUpLocaleConventions();
}
$currency = $this->localeConventions->int_curr_symbol;
}
}
}
return \numfmt_format_currency($formatter, $valueToFormat, $currency);
} | [
"protected",
"function",
"formatByIntlMoneyFormatter",
"(",
"$",
"valueToFormat",
"=",
"0.0",
",",
"$",
"decimalsCount",
"=",
"NULL",
",",
"$",
"currency",
"=",
"NULL",
")",
"{",
"$",
"formatter",
"=",
"$",
"this",
"->",
"getIntlNumberFormatter",
"(",
"$",
"this",
"->",
"langAndLocale",
",",
"\\",
"NumberFormatter",
"::",
"CURRENCY",
",",
"NULL",
",",
"(",
"$",
"decimalsCount",
"!==",
"NULL",
"?",
"[",
"\\",
"NumberFormatter",
"::",
"FRACTION_DIGITS",
"=>",
"$",
"decimalsCount",
"]",
":",
"[",
"]",
")",
")",
";",
"if",
"(",
"$",
"currency",
"===",
"NULL",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"defaultCurrency",
"!==",
"NULL",
")",
"{",
"// try to get default currency",
"$",
"currency",
"=",
"$",
"this",
"->",
"defaultCurrency",
";",
"}",
"else",
"{",
"// try to get currency from localized formatter",
"$",
"currency",
"=",
"\\",
"numfmt_get_symbol",
"(",
"$",
"formatter",
",",
"\\",
"NumberFormatter",
"::",
"INTL_CURRENCY_SYMBOL",
")",
";",
"if",
"(",
"mb_strlen",
"(",
"$",
"currency",
")",
"!==",
"3",
")",
"{",
"// try to get currency by system locale settings, by formatting conventions",
"if",
"(",
"$",
"this",
"->",
"encodingConversion",
"===",
"NULL",
")",
"{",
"$",
"this",
"->",
"setUpSystemLocaleAndEncodings",
"(",
")",
";",
"$",
"this",
"->",
"setUpLocaleConventions",
"(",
")",
";",
"}",
"$",
"currency",
"=",
"$",
"this",
"->",
"localeConventions",
"->",
"int_curr_symbol",
";",
"}",
"}",
"}",
"return",
"\\",
"numfmt_format_currency",
"(",
"$",
"formatter",
",",
"$",
"valueToFormat",
",",
"$",
"currency",
")",
";",
"}"
] | Format money by `Intl` extension formatter. If no international three chars currency
symbol is provided, there is used currency symbol from localized `Intl` formatter instance.
@see http://php.net/manual/en/numberformatter.create.php
@see http://php.net/manual/en/numberformatter.formatcurrency.php
@param int|float $valueToFormat Numeric value to format.
@param int|NULL $decimalsCount Optional, numerics count after decimal point,
If `NULL`, there is used `Intl` localized formatter
default value for money, usually two - `2`.
@param string|NULL $currency Optional, 3-letter ISO 4217 currency code
indicating the currency to use.
@return string | [
"Format",
"money",
"by",
"Intl",
"extension",
"formatter",
".",
"If",
"no",
"international",
"three",
"chars",
"currency",
"symbol",
"is",
"provided",
"there",
"is",
"used",
"currency",
"symbol",
"from",
"localized",
"Intl",
"formatter",
"instance",
"."
] | 09b8e1d9b2fd57d7a75d96c9b5a5a57ad5ddb390 | https://github.com/mvccore/ext-view-helper-formatmoney/blob/09b8e1d9b2fd57d7a75d96c9b5a5a57ad5ddb390/src/MvcCore/Ext/Views/Helpers/FormatMoneyHelper.php#L129-L156 |
752 | koinephp/Core | lib/Koine/ArrayReference.php | ArrayReference.offsetSet | public function offsetSet($key, $value)
{
if ($key !== null) {
$this->data[$key] = $value;
} else {
$this->data[] = $value;
}
return $this;
} | php | public function offsetSet($key, $value)
{
if ($key !== null) {
$this->data[$key] = $value;
} else {
$this->data[] = $value;
}
return $this;
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"data",
"[",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the value
ArrayAccess implementation
@param mixed $key
@param mixed $value | [
"Sets",
"the",
"value",
"ArrayAccess",
"implementation"
] | 9b9543f1b4699fd515590f2f94654bad098821ff | https://github.com/koinephp/Core/blob/9b9543f1b4699fd515590f2f94654bad098821ff/lib/Koine/ArrayReference.php#L64-L73 |
753 | themichaelhall/datatypes | src/Url.php | Url.equals | public function equals(UrlInterface $url): bool
{
return $this->getScheme()->equals($url->getScheme()) && $this->getHost()->equals($url->getHost()) && $this->getPort() === $url->getPort() && $this->getPath()->equals($url->getPath()) && $this->getQueryString() === $url->getQueryString() && $this->getFragment() === $url->getFragment();
} | php | public function equals(UrlInterface $url): bool
{
return $this->getScheme()->equals($url->getScheme()) && $this->getHost()->equals($url->getHost()) && $this->getPort() === $url->getPort() && $this->getPath()->equals($url->getPath()) && $this->getQueryString() === $url->getQueryString() && $this->getFragment() === $url->getFragment();
} | [
"public",
"function",
"equals",
"(",
"UrlInterface",
"$",
"url",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"getScheme",
"(",
")",
"->",
"equals",
"(",
"$",
"url",
"->",
"getScheme",
"(",
")",
")",
"&&",
"$",
"this",
"->",
"getHost",
"(",
")",
"->",
"equals",
"(",
"$",
"url",
"->",
"getHost",
"(",
")",
")",
"&&",
"$",
"this",
"->",
"getPort",
"(",
")",
"===",
"$",
"url",
"->",
"getPort",
"(",
")",
"&&",
"$",
"this",
"->",
"getPath",
"(",
")",
"->",
"equals",
"(",
"$",
"url",
"->",
"getPath",
"(",
")",
")",
"&&",
"$",
"this",
"->",
"getQueryString",
"(",
")",
"===",
"$",
"url",
"->",
"getQueryString",
"(",
")",
"&&",
"$",
"this",
"->",
"getFragment",
"(",
")",
"===",
"$",
"url",
"->",
"getFragment",
"(",
")",
";",
"}"
] | Returns true if the url equals other url, false otherwise.
@since 1.2.0
@param UrlInterface $url The other url.
@return bool True if the url equals other url, false otherwise. | [
"Returns",
"true",
"if",
"the",
"url",
"equals",
"other",
"url",
"false",
"otherwise",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L37-L40 |
754 | themichaelhall/datatypes | src/Url.php | Url.getHostAndPort | public function getHostAndPort(): string
{
if ($this->myPort !== $this->myScheme->getDefaultPort()) {
return $this->myHost . ':' . $this->myPort;
}
return $this->myHost->__toString();
} | php | public function getHostAndPort(): string
{
if ($this->myPort !== $this->myScheme->getDefaultPort()) {
return $this->myHost . ':' . $this->myPort;
}
return $this->myHost->__toString();
} | [
"public",
"function",
"getHostAndPort",
"(",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"myPort",
"!==",
"$",
"this",
"->",
"myScheme",
"->",
"getDefaultPort",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"myHost",
".",
"':'",
".",
"$",
"this",
"->",
"myPort",
";",
"}",
"return",
"$",
"this",
"->",
"myHost",
"->",
"__toString",
"(",
")",
";",
"}"
] | Returns the host and port of the url as a string.
@since 1.0.0
@return string The host and port of the url. | [
"Returns",
"the",
"host",
"and",
"port",
"of",
"the",
"url",
"as",
"a",
"string",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L73-L80 |
755 | themichaelhall/datatypes | src/Url.php | Url.withFragment | public function withFragment(?string $fragment = null): UrlInterface
{
if (!self::myValidateFragment($fragment, $error)) {
throw new UrlInvalidArgumentException($error);
}
return new self($this->myScheme, $this->myHost, $this->myPort, $this->myPath, $this->myQueryString, $fragment);
} | php | public function withFragment(?string $fragment = null): UrlInterface
{
if (!self::myValidateFragment($fragment, $error)) {
throw new UrlInvalidArgumentException($error);
}
return new self($this->myScheme, $this->myHost, $this->myPort, $this->myPath, $this->myQueryString, $fragment);
} | [
"public",
"function",
"withFragment",
"(",
"?",
"string",
"$",
"fragment",
"=",
"null",
")",
":",
"UrlInterface",
"{",
"if",
"(",
"!",
"self",
"::",
"myValidateFragment",
"(",
"$",
"fragment",
",",
"$",
"error",
")",
")",
"{",
"throw",
"new",
"UrlInvalidArgumentException",
"(",
"$",
"error",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"this",
"->",
"myScheme",
",",
"$",
"this",
"->",
"myHost",
",",
"$",
"this",
"->",
"myPort",
",",
"$",
"this",
"->",
"myPath",
",",
"$",
"this",
"->",
"myQueryString",
",",
"$",
"fragment",
")",
";",
"}"
] | Returns a copy of the Url instance with the specified fragment.
@since 1.0.0
@param string|null $fragment The fragment or null for no fragment.
@throws UrlInvalidArgumentException If the fragment parameter is invalid.
@return UrlInterface The url instance. | [
"Returns",
"a",
"copy",
"of",
"the",
"Url",
"instance",
"with",
"the",
"specified",
"fragment",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L141-L148 |
756 | themichaelhall/datatypes | src/Url.php | Url.withHost | public function withHost(HostInterface $host): UrlInterface
{
return new self($this->myScheme, $host, $this->myPort, $this->myPath, $this->myQueryString, $this->myFragment);
} | php | public function withHost(HostInterface $host): UrlInterface
{
return new self($this->myScheme, $host, $this->myPort, $this->myPath, $this->myQueryString, $this->myFragment);
} | [
"public",
"function",
"withHost",
"(",
"HostInterface",
"$",
"host",
")",
":",
"UrlInterface",
"{",
"return",
"new",
"self",
"(",
"$",
"this",
"->",
"myScheme",
",",
"$",
"host",
",",
"$",
"this",
"->",
"myPort",
",",
"$",
"this",
"->",
"myPath",
",",
"$",
"this",
"->",
"myQueryString",
",",
"$",
"this",
"->",
"myFragment",
")",
";",
"}"
] | Returns a copy of the Url instance with the specified host.
@since 1.0.0
@param HostInterface $host The host.
@return UrlInterface The Url instance. | [
"Returns",
"a",
"copy",
"of",
"the",
"Url",
"instance",
"with",
"the",
"specified",
"host",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L159-L162 |
757 | themichaelhall/datatypes | src/Url.php | Url.withPort | public function withPort(int $port): UrlInterface
{
if (!self::myValidatePort($port, $error)) {
throw new UrlInvalidArgumentException($error);
}
return new self($this->myScheme, $this->myHost, $port, $this->myPath, $this->myQueryString, $this->myFragment);
} | php | public function withPort(int $port): UrlInterface
{
if (!self::myValidatePort($port, $error)) {
throw new UrlInvalidArgumentException($error);
}
return new self($this->myScheme, $this->myHost, $port, $this->myPath, $this->myQueryString, $this->myFragment);
} | [
"public",
"function",
"withPort",
"(",
"int",
"$",
"port",
")",
":",
"UrlInterface",
"{",
"if",
"(",
"!",
"self",
"::",
"myValidatePort",
"(",
"$",
"port",
",",
"$",
"error",
")",
")",
"{",
"throw",
"new",
"UrlInvalidArgumentException",
"(",
"$",
"error",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"this",
"->",
"myScheme",
",",
"$",
"this",
"->",
"myHost",
",",
"$",
"port",
",",
"$",
"this",
"->",
"myPath",
",",
"$",
"this",
"->",
"myQueryString",
",",
"$",
"this",
"->",
"myFragment",
")",
";",
"}"
] | Returns a copy of the Url instance with the specified port.
@since 1.0.0
@param int $port The port.
@throws UrlInvalidArgumentException If the port is out of range.
@return UrlInterface The Url instance. | [
"Returns",
"a",
"copy",
"of",
"the",
"Url",
"instance",
"with",
"the",
"specified",
"port",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L175-L182 |
758 | themichaelhall/datatypes | src/Url.php | Url.withPath | public function withPath(UrlPathInterface $path): UrlInterface
{
return new self($this->myScheme, $this->myHost, $this->myPort, $this->myPath->withUrlPath($path), $this->myQueryString, $this->myFragment);
} | php | public function withPath(UrlPathInterface $path): UrlInterface
{
return new self($this->myScheme, $this->myHost, $this->myPort, $this->myPath->withUrlPath($path), $this->myQueryString, $this->myFragment);
} | [
"public",
"function",
"withPath",
"(",
"UrlPathInterface",
"$",
"path",
")",
":",
"UrlInterface",
"{",
"return",
"new",
"self",
"(",
"$",
"this",
"->",
"myScheme",
",",
"$",
"this",
"->",
"myHost",
",",
"$",
"this",
"->",
"myPort",
",",
"$",
"this",
"->",
"myPath",
"->",
"withUrlPath",
"(",
"$",
"path",
")",
",",
"$",
"this",
"->",
"myQueryString",
",",
"$",
"this",
"->",
"myFragment",
")",
";",
"}"
] | Returns a copy of the Url instance with the specified path.
@since 1.0.0
@param UrlPathInterface $path The path.
@return UrlInterface The Url instance. | [
"Returns",
"a",
"copy",
"of",
"the",
"Url",
"instance",
"with",
"the",
"specified",
"path",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L193-L196 |
759 | themichaelhall/datatypes | src/Url.php | Url.withQueryString | public function withQueryString(?string $queryString = null): UrlInterface
{
if (!self::myValidateQueryString($queryString, $error)) {
throw new UrlInvalidArgumentException($error);
}
return new self($this->myScheme, $this->myHost, $this->myPort, $this->myPath, $queryString, $this->myFragment);
} | php | public function withQueryString(?string $queryString = null): UrlInterface
{
if (!self::myValidateQueryString($queryString, $error)) {
throw new UrlInvalidArgumentException($error);
}
return new self($this->myScheme, $this->myHost, $this->myPort, $this->myPath, $queryString, $this->myFragment);
} | [
"public",
"function",
"withQueryString",
"(",
"?",
"string",
"$",
"queryString",
"=",
"null",
")",
":",
"UrlInterface",
"{",
"if",
"(",
"!",
"self",
"::",
"myValidateQueryString",
"(",
"$",
"queryString",
",",
"$",
"error",
")",
")",
"{",
"throw",
"new",
"UrlInvalidArgumentException",
"(",
"$",
"error",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"this",
"->",
"myScheme",
",",
"$",
"this",
"->",
"myHost",
",",
"$",
"this",
"->",
"myPort",
",",
"$",
"this",
"->",
"myPath",
",",
"$",
"queryString",
",",
"$",
"this",
"->",
"myFragment",
")",
";",
"}"
] | Returns a copy of the Url instance with the specified query string.
@since 1.0.0
@param string|null $queryString The query string or null for no query string.
@throws UrlInvalidArgumentException If the query parameter is invalid.
@return UrlInterface The url instance. | [
"Returns",
"a",
"copy",
"of",
"the",
"Url",
"instance",
"with",
"the",
"specified",
"query",
"string",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L209-L216 |
760 | themichaelhall/datatypes | src/Url.php | Url.withScheme | public function withScheme(SchemeInterface $scheme, bool $keepDefaultPort = true): UrlInterface
{
return new self($scheme, $this->myHost, ($keepDefaultPort && $this->myPort === $this->myScheme->getDefaultPort() ? $scheme->getDefaultPort() : $this->myPort), $this->myPath, $this->myQueryString, $this->myFragment);
} | php | public function withScheme(SchemeInterface $scheme, bool $keepDefaultPort = true): UrlInterface
{
return new self($scheme, $this->myHost, ($keepDefaultPort && $this->myPort === $this->myScheme->getDefaultPort() ? $scheme->getDefaultPort() : $this->myPort), $this->myPath, $this->myQueryString, $this->myFragment);
} | [
"public",
"function",
"withScheme",
"(",
"SchemeInterface",
"$",
"scheme",
",",
"bool",
"$",
"keepDefaultPort",
"=",
"true",
")",
":",
"UrlInterface",
"{",
"return",
"new",
"self",
"(",
"$",
"scheme",
",",
"$",
"this",
"->",
"myHost",
",",
"(",
"$",
"keepDefaultPort",
"&&",
"$",
"this",
"->",
"myPort",
"===",
"$",
"this",
"->",
"myScheme",
"->",
"getDefaultPort",
"(",
")",
"?",
"$",
"scheme",
"->",
"getDefaultPort",
"(",
")",
":",
"$",
"this",
"->",
"myPort",
")",
",",
"$",
"this",
"->",
"myPath",
",",
"$",
"this",
"->",
"myQueryString",
",",
"$",
"this",
"->",
"myFragment",
")",
";",
"}"
] | Returns a copy of the Url instance with the specified scheme.
@since 1.0.0
@param SchemeInterface $scheme The scheme.
@param bool $keepDefaultPort If true, port is changed to the schemes default port if port is current schemes default port, if false port is not changed.
@return UrlInterface The Url instance. | [
"Returns",
"a",
"copy",
"of",
"the",
"Url",
"instance",
"with",
"the",
"specified",
"scheme",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L228-L231 |
761 | themichaelhall/datatypes | src/Url.php | Url.fromParts | public static function fromParts(SchemeInterface $scheme, HostInterface $host, ?int $port = null, UrlPathInterface $urlPath = null, ?string $queryString = null, ?string $fragment = null)
{
// Default values.
if ($port === null) {
$port = $scheme->getDefaultPort();
}
if ($urlPath === null) {
$urlPath = UrlPath::parse('/');
}
// Validate parts.
if (!self::myValidateParts($port, $urlPath, $queryString, $fragment, $error)) {
throw new UrlInvalidArgumentException($error);
}
return new self($scheme, $host, $port, $urlPath, $queryString, $fragment);
} | php | public static function fromParts(SchemeInterface $scheme, HostInterface $host, ?int $port = null, UrlPathInterface $urlPath = null, ?string $queryString = null, ?string $fragment = null)
{
// Default values.
if ($port === null) {
$port = $scheme->getDefaultPort();
}
if ($urlPath === null) {
$urlPath = UrlPath::parse('/');
}
// Validate parts.
if (!self::myValidateParts($port, $urlPath, $queryString, $fragment, $error)) {
throw new UrlInvalidArgumentException($error);
}
return new self($scheme, $host, $port, $urlPath, $queryString, $fragment);
} | [
"public",
"static",
"function",
"fromParts",
"(",
"SchemeInterface",
"$",
"scheme",
",",
"HostInterface",
"$",
"host",
",",
"?",
"int",
"$",
"port",
"=",
"null",
",",
"UrlPathInterface",
"$",
"urlPath",
"=",
"null",
",",
"?",
"string",
"$",
"queryString",
"=",
"null",
",",
"?",
"string",
"$",
"fragment",
"=",
"null",
")",
"{",
"// Default values.",
"if",
"(",
"$",
"port",
"===",
"null",
")",
"{",
"$",
"port",
"=",
"$",
"scheme",
"->",
"getDefaultPort",
"(",
")",
";",
"}",
"if",
"(",
"$",
"urlPath",
"===",
"null",
")",
"{",
"$",
"urlPath",
"=",
"UrlPath",
"::",
"parse",
"(",
"'/'",
")",
";",
"}",
"// Validate parts.",
"if",
"(",
"!",
"self",
"::",
"myValidateParts",
"(",
"$",
"port",
",",
"$",
"urlPath",
",",
"$",
"queryString",
",",
"$",
"fragment",
",",
"$",
"error",
")",
")",
"{",
"throw",
"new",
"UrlInvalidArgumentException",
"(",
"$",
"error",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"scheme",
",",
"$",
"host",
",",
"$",
"port",
",",
"$",
"urlPath",
",",
"$",
"queryString",
",",
"$",
"fragment",
")",
";",
"}"
] | Creates a url from url parts.
@since 1.0.0
@param SchemeInterface $scheme The scheme.
@param HostInterface $host The host.
@param int|null $port The port or null if default port for the scheme should be used.
@param UrlPathInterface|null $urlPath The url path or null if root path should be used.
@param string|null $queryString The query string or null if no query string should be used.
@param string|null $fragment The fragment or null if no fragment should be used.
@throws UrlInvalidArgumentException If any of the parameters are invalid.
@return UrlInterface The url. | [
"Creates",
"a",
"url",
"from",
"url",
"parts",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L261-L278 |
762 | themichaelhall/datatypes | src/Url.php | Url.isValidRelative | public static function isValidRelative(string $url, UrlInterface $baseUrl): bool
{
try {
return self::myParse($baseUrl, $url);
} catch (UrlPathLogicException $exception) {
return false;
}
} | php | public static function isValidRelative(string $url, UrlInterface $baseUrl): bool
{
try {
return self::myParse($baseUrl, $url);
} catch (UrlPathLogicException $exception) {
return false;
}
} | [
"public",
"static",
"function",
"isValidRelative",
"(",
"string",
"$",
"url",
",",
"UrlInterface",
"$",
"baseUrl",
")",
":",
"bool",
"{",
"try",
"{",
"return",
"self",
"::",
"myParse",
"(",
"$",
"baseUrl",
",",
"$",
"url",
")",
";",
"}",
"catch",
"(",
"UrlPathLogicException",
"$",
"exception",
")",
"{",
"return",
"false",
";",
"}",
"}"
] | Checks if a relative url is valid.
@since 1.0.0
@param string $url The url.
@param UrlInterface $baseUrl The base url.
@return bool True if the $url parameter is a valid url, false otherwise. | [
"Checks",
"if",
"a",
"relative",
"url",
"is",
"valid",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L304-L311 |
763 | themichaelhall/datatypes | src/Url.php | Url.myParse | private static function myParse(?UrlInterface $baseUrl = null, string $url, ?SchemeInterface &$scheme = null, ?HostInterface &$host = null, ?int &$port = null, ?UrlPathInterface &$path = null, ?string &$queryString = null, ?string &$fragment = null, ?string &$error = null): bool
{
if ($baseUrl === null && $url === '') {
$error = 'Url "" is empty.';
return false;
}
// Split the url in its main components.
self::mySplit($url, $schemeString, $authorityString, $pathString);
// Parse scheme.
if (!self::myParseScheme($baseUrl, $schemeString, $scheme, $error)) {
$error = 'Url "' . $url . '" is invalid: ' . $error;
return false;
}
// Parse authority.
if (!self::myParseAuthority($baseUrl, $authorityString, $host, $port, $error)) {
$error = 'Url "' . $url . '" is invalid: ' . $error;
return false;
}
// Set default port if needed.
if ($port === null) {
$port = $scheme->getDefaultPort();
}
// Parse path.
if (!self::myParsePath($baseUrl, $pathString, $path, $queryString, $fragment, $error)) {
$error = 'Url "' . $url . '" is invalid: ' . $error;
return false;
}
return true;
} | php | private static function myParse(?UrlInterface $baseUrl = null, string $url, ?SchemeInterface &$scheme = null, ?HostInterface &$host = null, ?int &$port = null, ?UrlPathInterface &$path = null, ?string &$queryString = null, ?string &$fragment = null, ?string &$error = null): bool
{
if ($baseUrl === null && $url === '') {
$error = 'Url "" is empty.';
return false;
}
// Split the url in its main components.
self::mySplit($url, $schemeString, $authorityString, $pathString);
// Parse scheme.
if (!self::myParseScheme($baseUrl, $schemeString, $scheme, $error)) {
$error = 'Url "' . $url . '" is invalid: ' . $error;
return false;
}
// Parse authority.
if (!self::myParseAuthority($baseUrl, $authorityString, $host, $port, $error)) {
$error = 'Url "' . $url . '" is invalid: ' . $error;
return false;
}
// Set default port if needed.
if ($port === null) {
$port = $scheme->getDefaultPort();
}
// Parse path.
if (!self::myParsePath($baseUrl, $pathString, $path, $queryString, $fragment, $error)) {
$error = 'Url "' . $url . '" is invalid: ' . $error;
return false;
}
return true;
} | [
"private",
"static",
"function",
"myParse",
"(",
"?",
"UrlInterface",
"$",
"baseUrl",
"=",
"null",
",",
"string",
"$",
"url",
",",
"?",
"SchemeInterface",
"&",
"$",
"scheme",
"=",
"null",
",",
"?",
"HostInterface",
"&",
"$",
"host",
"=",
"null",
",",
"?",
"int",
"&",
"$",
"port",
"=",
"null",
",",
"?",
"UrlPathInterface",
"&",
"$",
"path",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"queryString",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"fragment",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"baseUrl",
"===",
"null",
"&&",
"$",
"url",
"===",
"''",
")",
"{",
"$",
"error",
"=",
"'Url \"\" is empty.'",
";",
"return",
"false",
";",
"}",
"// Split the url in its main components.",
"self",
"::",
"mySplit",
"(",
"$",
"url",
",",
"$",
"schemeString",
",",
"$",
"authorityString",
",",
"$",
"pathString",
")",
";",
"// Parse scheme.",
"if",
"(",
"!",
"self",
"::",
"myParseScheme",
"(",
"$",
"baseUrl",
",",
"$",
"schemeString",
",",
"$",
"scheme",
",",
"$",
"error",
")",
")",
"{",
"$",
"error",
"=",
"'Url \"'",
".",
"$",
"url",
".",
"'\" is invalid: '",
".",
"$",
"error",
";",
"return",
"false",
";",
"}",
"// Parse authority.",
"if",
"(",
"!",
"self",
"::",
"myParseAuthority",
"(",
"$",
"baseUrl",
",",
"$",
"authorityString",
",",
"$",
"host",
",",
"$",
"port",
",",
"$",
"error",
")",
")",
"{",
"$",
"error",
"=",
"'Url \"'",
".",
"$",
"url",
".",
"'\" is invalid: '",
".",
"$",
"error",
";",
"return",
"false",
";",
"}",
"// Set default port if needed.",
"if",
"(",
"$",
"port",
"===",
"null",
")",
"{",
"$",
"port",
"=",
"$",
"scheme",
"->",
"getDefaultPort",
"(",
")",
";",
"}",
"// Parse path.",
"if",
"(",
"!",
"self",
"::",
"myParsePath",
"(",
"$",
"baseUrl",
",",
"$",
"pathString",
",",
"$",
"path",
",",
"$",
"queryString",
",",
"$",
"fragment",
",",
"$",
"error",
")",
")",
"{",
"$",
"error",
"=",
"'Url \"'",
".",
"$",
"url",
".",
"'\" is invalid: '",
".",
"$",
"error",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Tries to parse a url and returns the result or error text.
@param UrlInterface|null $baseUrl The base url or null if no base url is present.
@param string $url The url.
@param SchemeInterface|null $scheme The scheme if parsing was successful, undefined otherwise.
@param HostInterface|null $host The host if parsing was successful, undefined otherwise.
@param int|null $port The port if parsing was successful, undefined otherwise.
@param UrlPathInterface|null $path The path if parsing was successful, undefined otherwise.
@param string|null $queryString The query string if parsing was successful, undefined otherwise.
@param string|null $fragment The fragment if parsing was successful, undefined otherwise.
@param string|null $error The error text if parsing was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise. | [
"Tries",
"to",
"parse",
"a",
"url",
"and",
"returns",
"the",
"result",
"or",
"error",
"text",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L430-L468 |
764 | themichaelhall/datatypes | src/Url.php | Url.mySplit | private static function mySplit(string $url, ?string &$schemeString = null, ?string &$authorityString = null, ?string &$pathString = null): void
{
$schemeString = null;
$authorityString = null;
$pathString = null;
$parts = explode('://', $url, 2);
if (count($parts) === 2) {
// Absolute url.
$schemeString = $parts[0];
$parts = explode('/', $parts[1], 2);
$authorityString = $parts[0];
$pathString = '/' . (count($parts) === 2 ? $parts[1] : '');
return;
}
if (substr($url, 0, 2) === '//') {
// Relative url beginning with "//".
$parts = explode('/', substr($url, 2), 2);
$authorityString = $parts[0];
$pathString = '/' . (count($parts) === 2 ? $parts[1] : '');
return;
}
// Relative url as a path.
$pathString = $url;
} | php | private static function mySplit(string $url, ?string &$schemeString = null, ?string &$authorityString = null, ?string &$pathString = null): void
{
$schemeString = null;
$authorityString = null;
$pathString = null;
$parts = explode('://', $url, 2);
if (count($parts) === 2) {
// Absolute url.
$schemeString = $parts[0];
$parts = explode('/', $parts[1], 2);
$authorityString = $parts[0];
$pathString = '/' . (count($parts) === 2 ? $parts[1] : '');
return;
}
if (substr($url, 0, 2) === '//') {
// Relative url beginning with "//".
$parts = explode('/', substr($url, 2), 2);
$authorityString = $parts[0];
$pathString = '/' . (count($parts) === 2 ? $parts[1] : '');
return;
}
// Relative url as a path.
$pathString = $url;
} | [
"private",
"static",
"function",
"mySplit",
"(",
"string",
"$",
"url",
",",
"?",
"string",
"&",
"$",
"schemeString",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"authorityString",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"pathString",
"=",
"null",
")",
":",
"void",
"{",
"$",
"schemeString",
"=",
"null",
";",
"$",
"authorityString",
"=",
"null",
";",
"$",
"pathString",
"=",
"null",
";",
"$",
"parts",
"=",
"explode",
"(",
"'://'",
",",
"$",
"url",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"===",
"2",
")",
"{",
"// Absolute url.",
"$",
"schemeString",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"parts",
"[",
"1",
"]",
",",
"2",
")",
";",
"$",
"authorityString",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"$",
"pathString",
"=",
"'/'",
".",
"(",
"count",
"(",
"$",
"parts",
")",
"===",
"2",
"?",
"$",
"parts",
"[",
"1",
"]",
":",
"''",
")",
";",
"return",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"url",
",",
"0",
",",
"2",
")",
"===",
"'//'",
")",
"{",
"// Relative url beginning with \"//\".",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"substr",
"(",
"$",
"url",
",",
"2",
")",
",",
"2",
")",
";",
"$",
"authorityString",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"$",
"pathString",
"=",
"'/'",
".",
"(",
"count",
"(",
"$",
"parts",
")",
"===",
"2",
"?",
"$",
"parts",
"[",
"1",
"]",
":",
"''",
")",
";",
"return",
";",
"}",
"// Relative url as a path.",
"$",
"pathString",
"=",
"$",
"url",
";",
"}"
] | Splits a url in its main components.
@param string $url The url.
@param string|null $schemeString The scheme or null if scheme is not present.
@param string|null $authorityString The authority part or null if authority part is not present.
@param string|null $pathString The path or null if path is not present. | [
"Splits",
"a",
"url",
"in",
"its",
"main",
"components",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L478-L507 |
765 | themichaelhall/datatypes | src/Url.php | Url.myParseScheme | private static function myParseScheme(?UrlInterface $baseUrl = null, ?string $schemeString, ?SchemeInterface &$scheme = null, ?string &$error = null): bool
{
if ($schemeString === null) {
if ($baseUrl === null) {
$error = 'Scheme is missing.';
return false;
}
$scheme = $baseUrl->getScheme();
return true;
}
try {
$scheme = Scheme::parse($schemeString);
} catch (SchemeInvalidArgumentException $e) {
$error = $e->getMessage();
return false;
}
return true;
} | php | private static function myParseScheme(?UrlInterface $baseUrl = null, ?string $schemeString, ?SchemeInterface &$scheme = null, ?string &$error = null): bool
{
if ($schemeString === null) {
if ($baseUrl === null) {
$error = 'Scheme is missing.';
return false;
}
$scheme = $baseUrl->getScheme();
return true;
}
try {
$scheme = Scheme::parse($schemeString);
} catch (SchemeInvalidArgumentException $e) {
$error = $e->getMessage();
return false;
}
return true;
} | [
"private",
"static",
"function",
"myParseScheme",
"(",
"?",
"UrlInterface",
"$",
"baseUrl",
"=",
"null",
",",
"?",
"string",
"$",
"schemeString",
",",
"?",
"SchemeInterface",
"&",
"$",
"scheme",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"schemeString",
"===",
"null",
")",
"{",
"if",
"(",
"$",
"baseUrl",
"===",
"null",
")",
"{",
"$",
"error",
"=",
"'Scheme is missing.'",
";",
"return",
"false",
";",
"}",
"$",
"scheme",
"=",
"$",
"baseUrl",
"->",
"getScheme",
"(",
")",
";",
"return",
"true",
";",
"}",
"try",
"{",
"$",
"scheme",
"=",
"Scheme",
"::",
"parse",
"(",
"$",
"schemeString",
")",
";",
"}",
"catch",
"(",
"SchemeInvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"error",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Parse scheme.
@param UrlInterface|null $baseUrl The base url or null if no base url is present.
@param string|null $schemeString The scheme that is to be parsed or null if no scheme is present.
@param SchemeInterface|null $scheme The scheme if parsing was successful, undefined otherwise.
@param string|null $error The error text if parsing was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise. | [
"Parse",
"scheme",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L519-L542 |
766 | themichaelhall/datatypes | src/Url.php | Url.myParseAuthority | private static function myParseAuthority(?UrlInterface $baseUrl = null, ?string $authorityString, ?HostInterface &$host = null, ?int &$port = null, ?string &$error = null): bool
{
if ($authorityString === null && $baseUrl !== null) {
$host = $baseUrl->getHost();
$port = $baseUrl->getPort();
return true;
}
// Throw away username and password if present.
$parts = explode('@', $authorityString, 2);
if (count($parts) > 1) {
$authorityString = $parts[1];
}
$parts = explode(':', $authorityString, 2);
$port = null;
// Try parse and validate port.
if (count($parts) === 2 && $parts[1] !== '') {
// Port containing invalid character is invalid.
if (preg_match('/[^0-9]/', $parts[1], $matches)) {
$error = 'Port "' . $parts[1] . '" contains invalid character "' . $matches[0] . '".';
return false;
}
$port = intval($parts[1]);
// Port out of range is invalid.
if (!self::myValidatePort($port, $error)) {
return false;
}
}
try {
$host = Host::parse($parts[0]);
} catch (HostInvalidArgumentException $e) {
$error = $e->getMessage();
return false;
}
return true;
} | php | private static function myParseAuthority(?UrlInterface $baseUrl = null, ?string $authorityString, ?HostInterface &$host = null, ?int &$port = null, ?string &$error = null): bool
{
if ($authorityString === null && $baseUrl !== null) {
$host = $baseUrl->getHost();
$port = $baseUrl->getPort();
return true;
}
// Throw away username and password if present.
$parts = explode('@', $authorityString, 2);
if (count($parts) > 1) {
$authorityString = $parts[1];
}
$parts = explode(':', $authorityString, 2);
$port = null;
// Try parse and validate port.
if (count($parts) === 2 && $parts[1] !== '') {
// Port containing invalid character is invalid.
if (preg_match('/[^0-9]/', $parts[1], $matches)) {
$error = 'Port "' . $parts[1] . '" contains invalid character "' . $matches[0] . '".';
return false;
}
$port = intval($parts[1]);
// Port out of range is invalid.
if (!self::myValidatePort($port, $error)) {
return false;
}
}
try {
$host = Host::parse($parts[0]);
} catch (HostInvalidArgumentException $e) {
$error = $e->getMessage();
return false;
}
return true;
} | [
"private",
"static",
"function",
"myParseAuthority",
"(",
"?",
"UrlInterface",
"$",
"baseUrl",
"=",
"null",
",",
"?",
"string",
"$",
"authorityString",
",",
"?",
"HostInterface",
"&",
"$",
"host",
"=",
"null",
",",
"?",
"int",
"&",
"$",
"port",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"authorityString",
"===",
"null",
"&&",
"$",
"baseUrl",
"!==",
"null",
")",
"{",
"$",
"host",
"=",
"$",
"baseUrl",
"->",
"getHost",
"(",
")",
";",
"$",
"port",
"=",
"$",
"baseUrl",
"->",
"getPort",
"(",
")",
";",
"return",
"true",
";",
"}",
"// Throw away username and password if present.",
"$",
"parts",
"=",
"explode",
"(",
"'@'",
",",
"$",
"authorityString",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
">",
"1",
")",
"{",
"$",
"authorityString",
"=",
"$",
"parts",
"[",
"1",
"]",
";",
"}",
"$",
"parts",
"=",
"explode",
"(",
"':'",
",",
"$",
"authorityString",
",",
"2",
")",
";",
"$",
"port",
"=",
"null",
";",
"// Try parse and validate port.",
"if",
"(",
"count",
"(",
"$",
"parts",
")",
"===",
"2",
"&&",
"$",
"parts",
"[",
"1",
"]",
"!==",
"''",
")",
"{",
"// Port containing invalid character is invalid.",
"if",
"(",
"preg_match",
"(",
"'/[^0-9]/'",
",",
"$",
"parts",
"[",
"1",
"]",
",",
"$",
"matches",
")",
")",
"{",
"$",
"error",
"=",
"'Port \"'",
".",
"$",
"parts",
"[",
"1",
"]",
".",
"'\" contains invalid character \"'",
".",
"$",
"matches",
"[",
"0",
"]",
".",
"'\".'",
";",
"return",
"false",
";",
"}",
"$",
"port",
"=",
"intval",
"(",
"$",
"parts",
"[",
"1",
"]",
")",
";",
"// Port out of range is invalid.",
"if",
"(",
"!",
"self",
"::",
"myValidatePort",
"(",
"$",
"port",
",",
"$",
"error",
")",
")",
"{",
"return",
"false",
";",
"}",
"}",
"try",
"{",
"$",
"host",
"=",
"Host",
"::",
"parse",
"(",
"$",
"parts",
"[",
"0",
"]",
")",
";",
"}",
"catch",
"(",
"HostInvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"error",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Parse authority part.
@param UrlInterface|null $baseUrl The base url or null if no base url is present.
@param string|null $authorityString The authority part that is to be parsed or null if no authority part is present.
@param HostInterface|null $host The host if parsing was successful, undefined otherwise.
@param int|null $port The port if parsing was successful, undefined otherwise.
@param string|null $error The error text if parsing was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise. | [
"Parse",
"authority",
"part",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L555-L599 |
767 | themichaelhall/datatypes | src/Url.php | Url.myParsePath | private static function myParsePath(?UrlInterface $baseUrl = null, string $pathString, ?UrlPathInterface &$path = null, ?string &$queryString = null, ?string &$fragment = null, ?string &$error = null): bool
{
// Fragment.
$parts = explode('#', $pathString, 2);
$pathString = $parts[0];
$fragment = count($parts) > 1 ? $parts[1] : null;
if (!self::myValidateFragment($fragment, $error)) {
return false;
}
// Query string.
$parts = explode('?', $pathString, 2);
$pathString = $parts[0];
$queryString = count($parts) > 1 ? $parts[1] : null;
if (!self::myValidateQueryString($queryString, $error)) {
return false;
}
// Try parse url path.
if (!self::myParseUrlPath($baseUrl, $pathString, $path, $error)) {
return false;
}
// If path is empty and there is a base url, handle query string and fragment.
if ($pathString === '' && $baseUrl !== null && $queryString === null) {
$queryString = $baseUrl->getQueryString();
$fragment = $fragment ?: $baseUrl->getFragment();
}
return true;
} | php | private static function myParsePath(?UrlInterface $baseUrl = null, string $pathString, ?UrlPathInterface &$path = null, ?string &$queryString = null, ?string &$fragment = null, ?string &$error = null): bool
{
// Fragment.
$parts = explode('#', $pathString, 2);
$pathString = $parts[0];
$fragment = count($parts) > 1 ? $parts[1] : null;
if (!self::myValidateFragment($fragment, $error)) {
return false;
}
// Query string.
$parts = explode('?', $pathString, 2);
$pathString = $parts[0];
$queryString = count($parts) > 1 ? $parts[1] : null;
if (!self::myValidateQueryString($queryString, $error)) {
return false;
}
// Try parse url path.
if (!self::myParseUrlPath($baseUrl, $pathString, $path, $error)) {
return false;
}
// If path is empty and there is a base url, handle query string and fragment.
if ($pathString === '' && $baseUrl !== null && $queryString === null) {
$queryString = $baseUrl->getQueryString();
$fragment = $fragment ?: $baseUrl->getFragment();
}
return true;
} | [
"private",
"static",
"function",
"myParsePath",
"(",
"?",
"UrlInterface",
"$",
"baseUrl",
"=",
"null",
",",
"string",
"$",
"pathString",
",",
"?",
"UrlPathInterface",
"&",
"$",
"path",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"queryString",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"fragment",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"// Fragment.",
"$",
"parts",
"=",
"explode",
"(",
"'#'",
",",
"$",
"pathString",
",",
"2",
")",
";",
"$",
"pathString",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"$",
"fragment",
"=",
"count",
"(",
"$",
"parts",
")",
">",
"1",
"?",
"$",
"parts",
"[",
"1",
"]",
":",
"null",
";",
"if",
"(",
"!",
"self",
"::",
"myValidateFragment",
"(",
"$",
"fragment",
",",
"$",
"error",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Query string.",
"$",
"parts",
"=",
"explode",
"(",
"'?'",
",",
"$",
"pathString",
",",
"2",
")",
";",
"$",
"pathString",
"=",
"$",
"parts",
"[",
"0",
"]",
";",
"$",
"queryString",
"=",
"count",
"(",
"$",
"parts",
")",
">",
"1",
"?",
"$",
"parts",
"[",
"1",
"]",
":",
"null",
";",
"if",
"(",
"!",
"self",
"::",
"myValidateQueryString",
"(",
"$",
"queryString",
",",
"$",
"error",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Try parse url path.",
"if",
"(",
"!",
"self",
"::",
"myParseUrlPath",
"(",
"$",
"baseUrl",
",",
"$",
"pathString",
",",
"$",
"path",
",",
"$",
"error",
")",
")",
"{",
"return",
"false",
";",
"}",
"// If path is empty and there is a base url, handle query string and fragment.",
"if",
"(",
"$",
"pathString",
"===",
"''",
"&&",
"$",
"baseUrl",
"!==",
"null",
"&&",
"$",
"queryString",
"===",
"null",
")",
"{",
"$",
"queryString",
"=",
"$",
"baseUrl",
"->",
"getQueryString",
"(",
")",
";",
"$",
"fragment",
"=",
"$",
"fragment",
"?",
":",
"$",
"baseUrl",
"->",
"getFragment",
"(",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Parse path.
@param UrlInterface|null $baseUrl The base url or null if no base url is present.
@param string $pathString The path that is to be parsed.
@param UrlPathInterface|null $path The path if parsing was successful, undefined otherwise.
@param string|null $queryString The query string if parsing was successful, undefined otherwise.
@param string|null $fragment The fragment if parsing was successful, undefined otherwise.
@param string|null $error The error text if parsing was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise. | [
"Parse",
"path",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L613-L645 |
768 | themichaelhall/datatypes | src/Url.php | Url.myParseUrlPath | private static function myParseUrlPath(?UrlInterface $baseUrl = null, string $pathString, ?UrlPathInterface &$path = null, ?string &$error = null): bool
{
// If path is empty and there is a base url, use the path from base url.
if ($baseUrl !== null && $pathString === '') {
$path = $baseUrl->getPath();
return true;
}
// Parse path.
try {
$path = UrlPath::parse($pathString);
} catch (UrlPathInvalidArgumentException $e) {
$error = $e->getMessage();
return false;
}
// If there is a base url, paths should be combined.
if ($baseUrl !== null) {
$path = $baseUrl->getPath()->withUrlPath($path);
}
return true;
} | php | private static function myParseUrlPath(?UrlInterface $baseUrl = null, string $pathString, ?UrlPathInterface &$path = null, ?string &$error = null): bool
{
// If path is empty and there is a base url, use the path from base url.
if ($baseUrl !== null && $pathString === '') {
$path = $baseUrl->getPath();
return true;
}
// Parse path.
try {
$path = UrlPath::parse($pathString);
} catch (UrlPathInvalidArgumentException $e) {
$error = $e->getMessage();
return false;
}
// If there is a base url, paths should be combined.
if ($baseUrl !== null) {
$path = $baseUrl->getPath()->withUrlPath($path);
}
return true;
} | [
"private",
"static",
"function",
"myParseUrlPath",
"(",
"?",
"UrlInterface",
"$",
"baseUrl",
"=",
"null",
",",
"string",
"$",
"pathString",
",",
"?",
"UrlPathInterface",
"&",
"$",
"path",
"=",
"null",
",",
"?",
"string",
"&",
"$",
"error",
"=",
"null",
")",
":",
"bool",
"{",
"// If path is empty and there is a base url, use the path from base url.",
"if",
"(",
"$",
"baseUrl",
"!==",
"null",
"&&",
"$",
"pathString",
"===",
"''",
")",
"{",
"$",
"path",
"=",
"$",
"baseUrl",
"->",
"getPath",
"(",
")",
";",
"return",
"true",
";",
"}",
"// Parse path.",
"try",
"{",
"$",
"path",
"=",
"UrlPath",
"::",
"parse",
"(",
"$",
"pathString",
")",
";",
"}",
"catch",
"(",
"UrlPathInvalidArgumentException",
"$",
"e",
")",
"{",
"$",
"error",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"return",
"false",
";",
"}",
"// If there is a base url, paths should be combined.",
"if",
"(",
"$",
"baseUrl",
"!==",
"null",
")",
"{",
"$",
"path",
"=",
"$",
"baseUrl",
"->",
"getPath",
"(",
")",
"->",
"withUrlPath",
"(",
"$",
"path",
")",
";",
"}",
"return",
"true",
";",
"}"
] | Try to validate or parse path.
@param UrlInterface|null $baseUrl The base url or null if no base url is present.
@param string $pathString The path that is to be parsed.
@param UrlPathInterface|null $path The path if parsing was successful, undefined otherwise.
@param string|null $error The error text if parsing was not successful, undefined otherwise.
@return bool True if parsing was successful, false otherwise. | [
"Try",
"to",
"validate",
"or",
"parse",
"path",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L657-L681 |
769 | themichaelhall/datatypes | src/Url.php | Url.myValidateParts | private static function myValidateParts(int $port, UrlPathInterface $urlPath, ?string $queryString, ?string $fragment, ?string &$error): bool
{
// Validate port.
if (!self::myValidatePort($port, $error)) {
return false;
}
// Url path can not be relative.
if ($urlPath->isRelative()) {
$error = 'Url path "' . $urlPath . '" is relative.';
return false;
}
// Validate query string.
if (!self::myValidateQueryString($queryString, $error)) {
return false;
}
// Validate fragment.
if (!self::myValidateFragment($fragment, $error)) {
return false;
}
return true;
} | php | private static function myValidateParts(int $port, UrlPathInterface $urlPath, ?string $queryString, ?string $fragment, ?string &$error): bool
{
// Validate port.
if (!self::myValidatePort($port, $error)) {
return false;
}
// Url path can not be relative.
if ($urlPath->isRelative()) {
$error = 'Url path "' . $urlPath . '" is relative.';
return false;
}
// Validate query string.
if (!self::myValidateQueryString($queryString, $error)) {
return false;
}
// Validate fragment.
if (!self::myValidateFragment($fragment, $error)) {
return false;
}
return true;
} | [
"private",
"static",
"function",
"myValidateParts",
"(",
"int",
"$",
"port",
",",
"UrlPathInterface",
"$",
"urlPath",
",",
"?",
"string",
"$",
"queryString",
",",
"?",
"string",
"$",
"fragment",
",",
"?",
"string",
"&",
"$",
"error",
")",
":",
"bool",
"{",
"// Validate port.",
"if",
"(",
"!",
"self",
"::",
"myValidatePort",
"(",
"$",
"port",
",",
"$",
"error",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Url path can not be relative.",
"if",
"(",
"$",
"urlPath",
"->",
"isRelative",
"(",
")",
")",
"{",
"$",
"error",
"=",
"'Url path \"'",
".",
"$",
"urlPath",
".",
"'\" is relative.'",
";",
"return",
"false",
";",
"}",
"// Validate query string.",
"if",
"(",
"!",
"self",
"::",
"myValidateQueryString",
"(",
"$",
"queryString",
",",
"$",
"error",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Validate fragment.",
"if",
"(",
"!",
"self",
"::",
"myValidateFragment",
"(",
"$",
"fragment",
",",
"$",
"error",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Validates parts of url.
@param int $port The port.
@param UrlPathInterface $urlPath The url path.
@param string|null $queryString The query string or null if no query string should be used.
@param string|null $fragment The fragment or null if no fragment should be used.
@param string|null $error The error text if validation was not successful, undefined otherwise.
@return bool True if validation was successful, false otherwise. | [
"Validates",
"parts",
"of",
"url",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L694-L719 |
770 | themichaelhall/datatypes | src/Url.php | Url.myValidatePort | private static function myValidatePort(int $port, ?string &$error): bool
{
// Port below 0 is invalid.
if ($port < 0) {
$error = 'Port ' . $port . ' is out of range: Minimum port number is 0.';
return false;
}
// Port above 65535 is invalid.
if ($port > 65535) {
$error = 'Port ' . $port . ' is out of range: Maximum port number is 65535.';
return false;
}
return true;
} | php | private static function myValidatePort(int $port, ?string &$error): bool
{
// Port below 0 is invalid.
if ($port < 0) {
$error = 'Port ' . $port . ' is out of range: Minimum port number is 0.';
return false;
}
// Port above 65535 is invalid.
if ($port > 65535) {
$error = 'Port ' . $port . ' is out of range: Maximum port number is 65535.';
return false;
}
return true;
} | [
"private",
"static",
"function",
"myValidatePort",
"(",
"int",
"$",
"port",
",",
"?",
"string",
"&",
"$",
"error",
")",
":",
"bool",
"{",
"// Port below 0 is invalid.",
"if",
"(",
"$",
"port",
"<",
"0",
")",
"{",
"$",
"error",
"=",
"'Port '",
".",
"$",
"port",
".",
"' is out of range: Minimum port number is 0.'",
";",
"return",
"false",
";",
"}",
"// Port above 65535 is invalid.",
"if",
"(",
"$",
"port",
">",
"65535",
")",
"{",
"$",
"error",
"=",
"'Port '",
".",
"$",
"port",
".",
"' is out of range: Maximum port number is 65535.'",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Validates a port.
@param int $port The port.
@param string $error The error text if validation was not successful, undefined otherwise.
@return bool True if validation was successful, false otherwise. | [
"Validates",
"a",
"port",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L729-L746 |
771 | themichaelhall/datatypes | src/Url.php | Url.myValidateQueryString | private static function myValidateQueryString(?string $queryString, ?string &$error): bool
{
if ($queryString === null) {
return true;
}
if (preg_match('/[^0-9a-zA-Z._~!\$&\'()*\+,;=:@\[\]\/\?%-]/', $queryString, $matches)) {
$error = 'Query string "' . $queryString . '" contains invalid character "' . $matches[0] . '".';
return false;
}
return true;
} | php | private static function myValidateQueryString(?string $queryString, ?string &$error): bool
{
if ($queryString === null) {
return true;
}
if (preg_match('/[^0-9a-zA-Z._~!\$&\'()*\+,;=:@\[\]\/\?%-]/', $queryString, $matches)) {
$error = 'Query string "' . $queryString . '" contains invalid character "' . $matches[0] . '".';
return false;
}
return true;
} | [
"private",
"static",
"function",
"myValidateQueryString",
"(",
"?",
"string",
"$",
"queryString",
",",
"?",
"string",
"&",
"$",
"error",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"queryString",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/[^0-9a-zA-Z._~!\\$&\\'()*\\+,;=:@\\[\\]\\/\\?%-]/'",
",",
"$",
"queryString",
",",
"$",
"matches",
")",
")",
"{",
"$",
"error",
"=",
"'Query string \"'",
".",
"$",
"queryString",
".",
"'\" contains invalid character \"'",
".",
"$",
"matches",
"[",
"0",
"]",
".",
"'\".'",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Validates a query string.
@param string|null $queryString The query string.
@param string $error The error text if validation was not successful, undefined otherwise.
@return bool True if validation was successful, false otherwise. | [
"Validates",
"a",
"query",
"string",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L756-L769 |
772 | themichaelhall/datatypes | src/Url.php | Url.myValidateFragment | private static function myValidateFragment(?string $fragment, ?string &$error): bool
{
if ($fragment === null) {
return true;
}
if (preg_match('/[^0-9a-zA-Z._~!\$&\'()*\+,;=:@\[\]\/\?%-]/', $fragment, $matches)) {
$error = 'Fragment "' . $fragment . '" contains invalid character "' . $matches[0] . '".';
return false;
}
return true;
} | php | private static function myValidateFragment(?string $fragment, ?string &$error): bool
{
if ($fragment === null) {
return true;
}
if (preg_match('/[^0-9a-zA-Z._~!\$&\'()*\+,;=:@\[\]\/\?%-]/', $fragment, $matches)) {
$error = 'Fragment "' . $fragment . '" contains invalid character "' . $matches[0] . '".';
return false;
}
return true;
} | [
"private",
"static",
"function",
"myValidateFragment",
"(",
"?",
"string",
"$",
"fragment",
",",
"?",
"string",
"&",
"$",
"error",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"fragment",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'/[^0-9a-zA-Z._~!\\$&\\'()*\\+,;=:@\\[\\]\\/\\?%-]/'",
",",
"$",
"fragment",
",",
"$",
"matches",
")",
")",
"{",
"$",
"error",
"=",
"'Fragment \"'",
".",
"$",
"fragment",
".",
"'\" contains invalid character \"'",
".",
"$",
"matches",
"[",
"0",
"]",
".",
"'\".'",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Validates a fragment.
@param string|null $fragment The fragment.
@param string $error The error text if validation was not successful, undefined otherwise.
@return bool True if validation was successful, false otherwise. | [
"Validates",
"a",
"fragment",
"."
] | c738fdf4ffca2e613badcb3011dbd5268e4309d8 | https://github.com/themichaelhall/datatypes/blob/c738fdf4ffca2e613badcb3011dbd5268e4309d8/src/Url.php#L779-L792 |
773 | ARCANESOFT/Core | src/Helpers/UI/AbstractClickable.php | AbstractClickable.setDisabled | public function setDisabled($disabled)
{
$this->disabled = (bool) $disabled;
if ($this->disabled) {
$this->attributes = $this->attributes->reject(function ($value, $key) {
return Str::startsWith($key, ['data-']);
});
}
return $this;
} | php | public function setDisabled($disabled)
{
$this->disabled = (bool) $disabled;
if ($this->disabled) {
$this->attributes = $this->attributes->reject(function ($value, $key) {
return Str::startsWith($key, ['data-']);
});
}
return $this;
} | [
"public",
"function",
"setDisabled",
"(",
"$",
"disabled",
")",
"{",
"$",
"this",
"->",
"disabled",
"=",
"(",
"bool",
")",
"$",
"disabled",
";",
"if",
"(",
"$",
"this",
"->",
"disabled",
")",
"{",
"$",
"this",
"->",
"attributes",
"=",
"$",
"this",
"->",
"attributes",
"->",
"reject",
"(",
"function",
"(",
"$",
"value",
",",
"$",
"key",
")",
"{",
"return",
"Str",
"::",
"startsWith",
"(",
"$",
"key",
",",
"[",
"'data-'",
"]",
")",
";",
"}",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Set disabled state.
@param bool $disabled
@return $this | [
"Set",
"disabled",
"state",
"."
] | d0798074d47785cf0a768f51d82c0315363213be | https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/AbstractClickable.php#L112-L123 |
774 | ARCANESOFT/Core | src/Helpers/UI/AbstractClickable.php | AbstractClickable.renderValue | protected function renderValue()
{
if ($this->withTooltip || ! $this->withTitle)
return $this->renderIcon();
return $this->withIcon
? $this->renderIcon().' '.$this->getTitle()
: $this->getTitle();
} | php | protected function renderValue()
{
if ($this->withTooltip || ! $this->withTitle)
return $this->renderIcon();
return $this->withIcon
? $this->renderIcon().' '.$this->getTitle()
: $this->getTitle();
} | [
"protected",
"function",
"renderValue",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"withTooltip",
"||",
"!",
"$",
"this",
"->",
"withTitle",
")",
"return",
"$",
"this",
"->",
"renderIcon",
"(",
")",
";",
"return",
"$",
"this",
"->",
"withIcon",
"?",
"$",
"this",
"->",
"renderIcon",
"(",
")",
".",
"' '",
".",
"$",
"this",
"->",
"getTitle",
"(",
")",
":",
"$",
"this",
"->",
"getTitle",
"(",
")",
";",
"}"
] | Render the value.
@return string | [
"Render",
"the",
"value",
"."
] | d0798074d47785cf0a768f51d82c0315363213be | https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/AbstractClickable.php#L240-L248 |
775 | ARCANESOFT/Core | src/Helpers/UI/AbstractClickable.php | AbstractClickable.getStyleClass | protected function getStyleClass()
{
$classes = array_merge([
$this->getBaseStyleClass(),
$this->getSize(),
$this->getColor(),
], $this->extraClass);
return implode(' ', array_filter(array_unique($classes, SORT_STRING)));
} | php | protected function getStyleClass()
{
$classes = array_merge([
$this->getBaseStyleClass(),
$this->getSize(),
$this->getColor(),
], $this->extraClass);
return implode(' ', array_filter(array_unique($classes, SORT_STRING)));
} | [
"protected",
"function",
"getStyleClass",
"(",
")",
"{",
"$",
"classes",
"=",
"array_merge",
"(",
"[",
"$",
"this",
"->",
"getBaseStyleClass",
"(",
")",
",",
"$",
"this",
"->",
"getSize",
"(",
")",
",",
"$",
"this",
"->",
"getColor",
"(",
")",
",",
"]",
",",
"$",
"this",
"->",
"extraClass",
")",
";",
"return",
"implode",
"(",
"' '",
",",
"array_filter",
"(",
"array_unique",
"(",
"$",
"classes",
",",
"SORT_STRING",
")",
")",
")",
";",
"}"
] | Get the button class.
@return string | [
"Get",
"the",
"button",
"class",
"."
] | d0798074d47785cf0a768f51d82c0315363213be | https://github.com/ARCANESOFT/Core/blob/d0798074d47785cf0a768f51d82c0315363213be/src/Helpers/UI/AbstractClickable.php#L285-L294 |
776 | vinala/kernel | src/Maintenance/Maintenance.php | Maintenance.check | public static function check()
{
$route = isset($_GET['_framework_url_']) ? $_GET['_framework_url_'] : '';
$out = config('maintenance.out', []);
$out[] = config('panel.route', 'vinala');
if (config('panel.setup', true)) {
if (config('maintenance.enabled', false) && !in_array($route, $out)) {
return static::$enabled = true;
}
}
return static::$enabled = false;
} | php | public static function check()
{
$route = isset($_GET['_framework_url_']) ? $_GET['_framework_url_'] : '';
$out = config('maintenance.out', []);
$out[] = config('panel.route', 'vinala');
if (config('panel.setup', true)) {
if (config('maintenance.enabled', false) && !in_array($route, $out)) {
return static::$enabled = true;
}
}
return static::$enabled = false;
} | [
"public",
"static",
"function",
"check",
"(",
")",
"{",
"$",
"route",
"=",
"isset",
"(",
"$",
"_GET",
"[",
"'_framework_url_'",
"]",
")",
"?",
"$",
"_GET",
"[",
"'_framework_url_'",
"]",
":",
"''",
";",
"$",
"out",
"=",
"config",
"(",
"'maintenance.out'",
",",
"[",
"]",
")",
";",
"$",
"out",
"[",
"]",
"=",
"config",
"(",
"'panel.route'",
",",
"'vinala'",
")",
";",
"if",
"(",
"config",
"(",
"'panel.setup'",
",",
"true",
")",
")",
"{",
"if",
"(",
"config",
"(",
"'maintenance.enabled'",
",",
"false",
")",
"&&",
"!",
"in_array",
"(",
"$",
"route",
",",
"$",
"out",
")",
")",
"{",
"return",
"static",
"::",
"$",
"enabled",
"=",
"true",
";",
"}",
"}",
"return",
"static",
"::",
"$",
"enabled",
"=",
"false",
";",
"}"
] | Check if the app is under maintenance.
@return bool | [
"Check",
"if",
"the",
"app",
"is",
"under",
"maintenance",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Maintenance/Maintenance.php#L38-L53 |
777 | vinala/kernel | src/Maintenance/Maintenance.php | Maintenance.launch | public static function launch()
{
if (static::check()) {
clean();
$view = config('maintenance.view');
$view = str_replace('.', '/', $view).'.php';
// $view = '../app/views/'.$view;
$view = '../resources/views/'.$view;
// d($view);:
if (!file_exists($view)) {
throw new \Exception('The view \''.config('maintenance.view').'\' not found');
}
include $view;
out('');
}
} | php | public static function launch()
{
if (static::check()) {
clean();
$view = config('maintenance.view');
$view = str_replace('.', '/', $view).'.php';
// $view = '../app/views/'.$view;
$view = '../resources/views/'.$view;
// d($view);:
if (!file_exists($view)) {
throw new \Exception('The view \''.config('maintenance.view').'\' not found');
}
include $view;
out('');
}
} | [
"public",
"static",
"function",
"launch",
"(",
")",
"{",
"if",
"(",
"static",
"::",
"check",
"(",
")",
")",
"{",
"clean",
"(",
")",
";",
"$",
"view",
"=",
"config",
"(",
"'maintenance.view'",
")",
";",
"$",
"view",
"=",
"str_replace",
"(",
"'.'",
",",
"'/'",
",",
"$",
"view",
")",
".",
"'.php'",
";",
"// $view = '../app/views/'.$view;",
"$",
"view",
"=",
"'../resources/views/'",
".",
"$",
"view",
";",
"// d($view);:",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"view",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"'The view \\''",
".",
"config",
"(",
"'maintenance.view'",
")",
".",
"'\\' not found'",
")",
";",
"}",
"include",
"$",
"view",
";",
"out",
"(",
"''",
")",
";",
"}",
"}"
] | Launch maintenance view.
@return null | [
"Launch",
"maintenance",
"view",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Maintenance/Maintenance.php#L60-L79 |
778 | novuso/common | src/Domain/Value/DateTime/Time.php | Time.create | public static function create(int $hour, int $minute, int $second): Time
{
return new static($hour, $minute, $second);
} | php | public static function create(int $hour, int $minute, int $second): Time
{
return new static($hour, $minute, $second);
} | [
"public",
"static",
"function",
"create",
"(",
"int",
"$",
"hour",
",",
"int",
"$",
"minute",
",",
"int",
"$",
"second",
")",
":",
"Time",
"{",
"return",
"new",
"static",
"(",
"$",
"hour",
",",
"$",
"minute",
",",
"$",
"second",
")",
";",
"}"
] | Creates instance from time values
@param int $hour The hour
@param int $minute The minute
@param int $second The second
@return Time
@throws DomainException When the time is not valid | [
"Creates",
"instance",
"from",
"time",
"values"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/Time.php#L113-L116 |
779 | novuso/common | src/Domain/Value/DateTime/Time.php | Time.now | public static function now(?string $timezone = null): Time
{
$timezone = $timezone ?: date_default_timezone_get();
assert(Validate::isTimezone($timezone), sprintf('Invalid timezone: %s', $timezone));
$dateTime = new DateTimeImmutable('now', new DateTimeZone($timezone));
$hour = (int) $dateTime->format('G');
$minute = (int) $dateTime->format('i');
$second = (int) $dateTime->format('s');
return new static($hour, $minute, $second);
} | php | public static function now(?string $timezone = null): Time
{
$timezone = $timezone ?: date_default_timezone_get();
assert(Validate::isTimezone($timezone), sprintf('Invalid timezone: %s', $timezone));
$dateTime = new DateTimeImmutable('now', new DateTimeZone($timezone));
$hour = (int) $dateTime->format('G');
$minute = (int) $dateTime->format('i');
$second = (int) $dateTime->format('s');
return new static($hour, $minute, $second);
} | [
"public",
"static",
"function",
"now",
"(",
"?",
"string",
"$",
"timezone",
"=",
"null",
")",
":",
"Time",
"{",
"$",
"timezone",
"=",
"$",
"timezone",
"?",
":",
"date_default_timezone_get",
"(",
")",
";",
"assert",
"(",
"Validate",
"::",
"isTimezone",
"(",
"$",
"timezone",
")",
",",
"sprintf",
"(",
"'Invalid timezone: %s'",
",",
"$",
"timezone",
")",
")",
";",
"$",
"dateTime",
"=",
"new",
"DateTimeImmutable",
"(",
"'now'",
",",
"new",
"DateTimeZone",
"(",
"$",
"timezone",
")",
")",
";",
"$",
"hour",
"=",
"(",
"int",
")",
"$",
"dateTime",
"->",
"format",
"(",
"'G'",
")",
";",
"$",
"minute",
"=",
"(",
"int",
")",
"$",
"dateTime",
"->",
"format",
"(",
"'i'",
")",
";",
"$",
"second",
"=",
"(",
"int",
")",
"$",
"dateTime",
"->",
"format",
"(",
"'s'",
")",
";",
"return",
"new",
"static",
"(",
"$",
"hour",
",",
"$",
"minute",
",",
"$",
"second",
")",
";",
"}"
] | Creates instance for the current time
@param string|null $timezone The timezone string or null for default
@return Time | [
"Creates",
"instance",
"for",
"the",
"current",
"time"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/Time.php#L125-L136 |
780 | novuso/common | src/Domain/Value/DateTime/Time.php | Time.fromNative | public static function fromNative(DateTimeInterface $dateTime): Time
{
$hour = (int) $dateTime->format('G');
$minute = (int) $dateTime->format('i');
$second = (int) $dateTime->format('s');
return new static($hour, $minute, $second);
} | php | public static function fromNative(DateTimeInterface $dateTime): Time
{
$hour = (int) $dateTime->format('G');
$minute = (int) $dateTime->format('i');
$second = (int) $dateTime->format('s');
return new static($hour, $minute, $second);
} | [
"public",
"static",
"function",
"fromNative",
"(",
"DateTimeInterface",
"$",
"dateTime",
")",
":",
"Time",
"{",
"$",
"hour",
"=",
"(",
"int",
")",
"$",
"dateTime",
"->",
"format",
"(",
"'G'",
")",
";",
"$",
"minute",
"=",
"(",
"int",
")",
"$",
"dateTime",
"->",
"format",
"(",
"'i'",
")",
";",
"$",
"second",
"=",
"(",
"int",
")",
"$",
"dateTime",
"->",
"format",
"(",
"'s'",
")",
";",
"return",
"new",
"static",
"(",
"$",
"hour",
",",
"$",
"minute",
",",
"$",
"second",
")",
";",
"}"
] | Creates an instance from a native DateTime
@param DateTimeInterface $dateTime A DateTimeInterface instance
@return Time | [
"Creates",
"an",
"instance",
"from",
"a",
"native",
"DateTime"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/Time.php#L145-L152 |
781 | novuso/common | src/Domain/Value/DateTime/Time.php | Time.guardTime | protected function guardTime(int $hour, int $minute, int $second): void
{
if ($hour < static::MIN_HOUR || $hour > static::MAX_HOUR) {
$message = sprintf('Hour (%d) out of range[%d, %d]', $hour, static::MIN_HOUR, static::MAX_HOUR);
throw new DomainException($message);
}
if ($minute < static::MIN_MINUTE || $minute > static::MAX_MINUTE) {
$message = sprintf('Minute (%d) out of range[%d, %d]', $minute, static::MIN_MINUTE, static::MAX_MINUTE);
throw new DomainException($message);
}
if ($second < static::MIN_SECOND || $second > static::MAX_SECOND) {
$message = sprintf('Second (%d) out of range[%d, %d]', $second, static::MIN_SECOND, static::MAX_SECOND);
throw new DomainException($message);
}
} | php | protected function guardTime(int $hour, int $minute, int $second): void
{
if ($hour < static::MIN_HOUR || $hour > static::MAX_HOUR) {
$message = sprintf('Hour (%d) out of range[%d, %d]', $hour, static::MIN_HOUR, static::MAX_HOUR);
throw new DomainException($message);
}
if ($minute < static::MIN_MINUTE || $minute > static::MAX_MINUTE) {
$message = sprintf('Minute (%d) out of range[%d, %d]', $minute, static::MIN_MINUTE, static::MAX_MINUTE);
throw new DomainException($message);
}
if ($second < static::MIN_SECOND || $second > static::MAX_SECOND) {
$message = sprintf('Second (%d) out of range[%d, %d]', $second, static::MIN_SECOND, static::MAX_SECOND);
throw new DomainException($message);
}
} | [
"protected",
"function",
"guardTime",
"(",
"int",
"$",
"hour",
",",
"int",
"$",
"minute",
",",
"int",
"$",
"second",
")",
":",
"void",
"{",
"if",
"(",
"$",
"hour",
"<",
"static",
"::",
"MIN_HOUR",
"||",
"$",
"hour",
">",
"static",
"::",
"MAX_HOUR",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Hour (%d) out of range[%d, %d]'",
",",
"$",
"hour",
",",
"static",
"::",
"MIN_HOUR",
",",
"static",
"::",
"MAX_HOUR",
")",
";",
"throw",
"new",
"DomainException",
"(",
"$",
"message",
")",
";",
"}",
"if",
"(",
"$",
"minute",
"<",
"static",
"::",
"MIN_MINUTE",
"||",
"$",
"minute",
">",
"static",
"::",
"MAX_MINUTE",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Minute (%d) out of range[%d, %d]'",
",",
"$",
"minute",
",",
"static",
"::",
"MIN_MINUTE",
",",
"static",
"::",
"MAX_MINUTE",
")",
";",
"throw",
"new",
"DomainException",
"(",
"$",
"message",
")",
";",
"}",
"if",
"(",
"$",
"second",
"<",
"static",
"::",
"MIN_SECOND",
"||",
"$",
"second",
">",
"static",
"::",
"MAX_SECOND",
")",
"{",
"$",
"message",
"=",
"sprintf",
"(",
"'Second (%d) out of range[%d, %d]'",
",",
"$",
"second",
",",
"static",
"::",
"MIN_SECOND",
",",
"static",
"::",
"MAX_SECOND",
")",
";",
"throw",
"new",
"DomainException",
"(",
"$",
"message",
")",
";",
"}",
"}"
] | Validates the time
@param int $hour The hour
@param int $minute The minute
@param int $second The second
@return void
@throws DomainException When the time is not valid | [
"Validates",
"the",
"time"
] | 7d0e5a4f4c79c9622e068efc8b7c70815c460863 | https://github.com/novuso/common/blob/7d0e5a4f4c79c9622e068efc8b7c70815c460863/src/Domain/Value/DateTime/Time.php#L282-L298 |
782 | stk2k/decoy | src/Decoy.php | Decoy.mock | public function mock(string $class) : MockedCode
{
$generator = new MockCodeGenerator($this->vfsRoot);
try{
$rc = new \ReflectionClass($class);
return $generator->generate($rc);
}
catch(\ReflectionException $e){
throw new DecoyException('Class not found: ' . $class, $e);
}
catch(MockCodeGeneratorException $e){
throw new DecoyException('Failed to generate mock code for class: ' . $class, $e);
}
} | php | public function mock(string $class) : MockedCode
{
$generator = new MockCodeGenerator($this->vfsRoot);
try{
$rc = new \ReflectionClass($class);
return $generator->generate($rc);
}
catch(\ReflectionException $e){
throw new DecoyException('Class not found: ' . $class, $e);
}
catch(MockCodeGeneratorException $e){
throw new DecoyException('Failed to generate mock code for class: ' . $class, $e);
}
} | [
"public",
"function",
"mock",
"(",
"string",
"$",
"class",
")",
":",
"MockedCode",
"{",
"$",
"generator",
"=",
"new",
"MockCodeGenerator",
"(",
"$",
"this",
"->",
"vfsRoot",
")",
";",
"try",
"{",
"$",
"rc",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"return",
"$",
"generator",
"->",
"generate",
"(",
"$",
"rc",
")",
";",
"}",
"catch",
"(",
"\\",
"ReflectionException",
"$",
"e",
")",
"{",
"throw",
"new",
"DecoyException",
"(",
"'Class not found: '",
".",
"$",
"class",
",",
"$",
"e",
")",
";",
"}",
"catch",
"(",
"MockCodeGeneratorException",
"$",
"e",
")",
"{",
"throw",
"new",
"DecoyException",
"(",
"'Failed to generate mock code for class: '",
".",
"$",
"class",
",",
"$",
"e",
")",
";",
"}",
"}"
] | Generate mock class
@param string $class
@return MockedCode
@throws DecoyException | [
"Generate",
"mock",
"class"
] | 743653d78b3a67e5e4fba8e4297eb3ffe64e4899 | https://github.com/stk2k/decoy/blob/743653d78b3a67e5e4fba8e4297eb3ffe64e4899/src/Decoy.php#L37-L51 |
783 | phlexible/phlexible | src/Phlexible/Bundle/MessageBundle/Mailer/Mailer.php | Mailer.sendDigestMail | public function sendDigestMail(UserInterface $user, array $messages)
{
$template = $this->parameters['digest']['template'];
$from = $this->parameters['digest']['from'];
$content = $this->templating->render(
$template,
[
'date' => date('Y-m-d H:i:s'),
'messages' => $messages,
]
);
return $this->sendEmailMessage($content, $from, $user->getEmail());
} | php | public function sendDigestMail(UserInterface $user, array $messages)
{
$template = $this->parameters['digest']['template'];
$from = $this->parameters['digest']['from'];
$content = $this->templating->render(
$template,
[
'date' => date('Y-m-d H:i:s'),
'messages' => $messages,
]
);
return $this->sendEmailMessage($content, $from, $user->getEmail());
} | [
"public",
"function",
"sendDigestMail",
"(",
"UserInterface",
"$",
"user",
",",
"array",
"$",
"messages",
")",
"{",
"$",
"template",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'digest'",
"]",
"[",
"'template'",
"]",
";",
"$",
"from",
"=",
"$",
"this",
"->",
"parameters",
"[",
"'digest'",
"]",
"[",
"'from'",
"]",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"templating",
"->",
"render",
"(",
"$",
"template",
",",
"[",
"'date'",
"=>",
"date",
"(",
"'Y-m-d H:i:s'",
")",
",",
"'messages'",
"=>",
"$",
"messages",
",",
"]",
")",
";",
"return",
"$",
"this",
"->",
"sendEmailMessage",
"(",
"$",
"content",
",",
"$",
"from",
",",
"$",
"user",
"->",
"getEmail",
"(",
")",
")",
";",
"}"
] | Send digest mail.
@param UserInterface $user
@param Message[] $messages
@return bool | [
"Send",
"digest",
"mail",
"."
] | 132f24924c9bb0dbb6c1ea84db0a463f97fa3893 | https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MessageBundle/Mailer/Mailer.php#L72-L86 |
784 | unyx/diagnostics | debug/Frame.php | Frame.getFileContents | public function getFileContents() : string
{
// No point in continuing if there is no file assigned to this frame.
if (!$this->file || $this->file === 'Unknown') {
return '';
}
// If the contents aren't cached yet, grab them into our rudimentary in-memory cache.
// Note: This may cache a boolean false if the retrieval fails for whatever reason. We're gonna handle
// that afterwards and return an empty string instead.
if (!isset(static::$files[$this->file])) {
static::$files[$this->file] = file_get_contents($this->file);
}
// Return the cached contents of the file or an empty string if no contents could be fetched.
return static::$files[$this->file] ?: '';
} | php | public function getFileContents() : string
{
// No point in continuing if there is no file assigned to this frame.
if (!$this->file || $this->file === 'Unknown') {
return '';
}
// If the contents aren't cached yet, grab them into our rudimentary in-memory cache.
// Note: This may cache a boolean false if the retrieval fails for whatever reason. We're gonna handle
// that afterwards and return an empty string instead.
if (!isset(static::$files[$this->file])) {
static::$files[$this->file] = file_get_contents($this->file);
}
// Return the cached contents of the file or an empty string if no contents could be fetched.
return static::$files[$this->file] ?: '';
} | [
"public",
"function",
"getFileContents",
"(",
")",
":",
"string",
"{",
"// No point in continuing if there is no file assigned to this frame.",
"if",
"(",
"!",
"$",
"this",
"->",
"file",
"||",
"$",
"this",
"->",
"file",
"===",
"'Unknown'",
")",
"{",
"return",
"''",
";",
"}",
"// If the contents aren't cached yet, grab them into our rudimentary in-memory cache.",
"// Note: This may cache a boolean false if the retrieval fails for whatever reason. We're gonna handle",
"// that afterwards and return an empty string instead.",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"files",
"[",
"$",
"this",
"->",
"file",
"]",
")",
")",
"{",
"static",
"::",
"$",
"files",
"[",
"$",
"this",
"->",
"file",
"]",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"file",
")",
";",
"}",
"// Return the cached contents of the file or an empty string if no contents could be fetched.",
"return",
"static",
"::",
"$",
"files",
"[",
"$",
"this",
"->",
"file",
"]",
"?",
":",
"''",
";",
"}"
] | Returns the contents of the file assigned to this frame as a string.
@return string Returns either the contents of the assigned file or an empty string if no file is assigned
or its contents could not be fetched. | [
"Returns",
"the",
"contents",
"of",
"the",
"file",
"assigned",
"to",
"this",
"frame",
"as",
"a",
"string",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/Frame.php#L180-L196 |
785 | unyx/diagnostics | debug/Frame.php | Frame.setData | protected function setData(array $data) : Frame
{
$this->file = $data['file'] ?? '';
$this->line = $data['line'] ?? 0;
$this->class = $data['class'] ?? '';
$this->function = $data['function'] ?? '';
$this->type = $data['type'] ?? '';
$this->args = $data['args'] ?? [];
// If we're dealing with a class, try to get its namespace and short name.
if ($this->class) {
$parts = explode('\\', $this->class);
$this->shortClass = array_pop($parts);
$this->namespace = implode('\\', $parts);
} else {
// Otherwise initialize with zero-values.
$this->shortClass = '';
$this->namespace = '';
}
return $this;
} | php | protected function setData(array $data) : Frame
{
$this->file = $data['file'] ?? '';
$this->line = $data['line'] ?? 0;
$this->class = $data['class'] ?? '';
$this->function = $data['function'] ?? '';
$this->type = $data['type'] ?? '';
$this->args = $data['args'] ?? [];
// If we're dealing with a class, try to get its namespace and short name.
if ($this->class) {
$parts = explode('\\', $this->class);
$this->shortClass = array_pop($parts);
$this->namespace = implode('\\', $parts);
} else {
// Otherwise initialize with zero-values.
$this->shortClass = '';
$this->namespace = '';
}
return $this;
} | [
"protected",
"function",
"setData",
"(",
"array",
"$",
"data",
")",
":",
"Frame",
"{",
"$",
"this",
"->",
"file",
"=",
"$",
"data",
"[",
"'file'",
"]",
"??",
"''",
";",
"$",
"this",
"->",
"line",
"=",
"$",
"data",
"[",
"'line'",
"]",
"??",
"0",
";",
"$",
"this",
"->",
"class",
"=",
"$",
"data",
"[",
"'class'",
"]",
"??",
"''",
";",
"$",
"this",
"->",
"function",
"=",
"$",
"data",
"[",
"'function'",
"]",
"??",
"''",
";",
"$",
"this",
"->",
"type",
"=",
"$",
"data",
"[",
"'type'",
"]",
"??",
"''",
";",
"$",
"this",
"->",
"args",
"=",
"$",
"data",
"[",
"'args'",
"]",
"??",
"[",
"]",
";",
"// If we're dealing with a class, try to get its namespace and short name.",
"if",
"(",
"$",
"this",
"->",
"class",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"this",
"->",
"class",
")",
";",
"$",
"this",
"->",
"shortClass",
"=",
"array_pop",
"(",
"$",
"parts",
")",
";",
"$",
"this",
"->",
"namespace",
"=",
"implode",
"(",
"'\\\\'",
",",
"$",
"parts",
")",
";",
"}",
"else",
"{",
"// Otherwise initialize with zero-values.",
"$",
"this",
"->",
"shortClass",
"=",
"''",
";",
"$",
"this",
"->",
"namespace",
"=",
"''",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the Frame's data.
@param array $data The Frame's data, in the same format as returned by \Exception::getTrace().
@return $this | [
"Sets",
"the",
"Frame",
"s",
"data",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/Frame.php#L265-L287 |
786 | unyx/diagnostics | debug/Frame.php | Frame.flattenArgs | protected function flattenArgs(array $args, int $depth = 0) : array
{
$result = [];
foreach ($args as $key => $value) {
if (is_object($value)) {
$result[$key] = ['object', get_class($value)];
} elseif (is_array($value)) {
if ($depth > $this->nestingLimit) {
$result[$key] = ['array', '*DEEP NESTED ARRAY*'];
} else {
$result[$key] = ['array', $this->flattenArgs($value, ++$depth)];
}
} elseif (null === $value) {
$result[$key] = ['null', null];
} elseif (is_bool($value)) {
$result[$key] = ['boolean', $value];
} elseif (is_resource($value)) {
$result[$key] = ['resource', get_resource_type($value)];
} elseif ($value instanceof \__PHP_Incomplete_Class) {
// Special case of object - is_object() will return false.
$array = new \ArrayObject($value);
$result[$key] = ['incomplete-object', $array['__PHP_Incomplete_Class_Name']];
} else {
$result[$key] = ['string', (string) $value];
}
}
return $result;
} | php | protected function flattenArgs(array $args, int $depth = 0) : array
{
$result = [];
foreach ($args as $key => $value) {
if (is_object($value)) {
$result[$key] = ['object', get_class($value)];
} elseif (is_array($value)) {
if ($depth > $this->nestingLimit) {
$result[$key] = ['array', '*DEEP NESTED ARRAY*'];
} else {
$result[$key] = ['array', $this->flattenArgs($value, ++$depth)];
}
} elseif (null === $value) {
$result[$key] = ['null', null];
} elseif (is_bool($value)) {
$result[$key] = ['boolean', $value];
} elseif (is_resource($value)) {
$result[$key] = ['resource', get_resource_type($value)];
} elseif ($value instanceof \__PHP_Incomplete_Class) {
// Special case of object - is_object() will return false.
$array = new \ArrayObject($value);
$result[$key] = ['incomplete-object', $array['__PHP_Incomplete_Class_Name']];
} else {
$result[$key] = ['string', (string) $value];
}
}
return $result;
} | [
"protected",
"function",
"flattenArgs",
"(",
"array",
"$",
"args",
",",
"int",
"$",
"depth",
"=",
"0",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"args",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"[",
"'object'",
",",
"get_class",
"(",
"$",
"value",
")",
"]",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"$",
"depth",
">",
"$",
"this",
"->",
"nestingLimit",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"[",
"'array'",
",",
"'*DEEP NESTED ARRAY*'",
"]",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"[",
"'array'",
",",
"$",
"this",
"->",
"flattenArgs",
"(",
"$",
"value",
",",
"++",
"$",
"depth",
")",
"]",
";",
"}",
"}",
"elseif",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"[",
"'null'",
",",
"null",
"]",
";",
"}",
"elseif",
"(",
"is_bool",
"(",
"$",
"value",
")",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"[",
"'boolean'",
",",
"$",
"value",
"]",
";",
"}",
"elseif",
"(",
"is_resource",
"(",
"$",
"value",
")",
")",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"[",
"'resource'",
",",
"get_resource_type",
"(",
"$",
"value",
")",
"]",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"\\",
"__PHP_Incomplete_Class",
")",
"{",
"// Special case of object - is_object() will return false.",
"$",
"array",
"=",
"new",
"\\",
"ArrayObject",
"(",
"$",
"value",
")",
";",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"[",
"'incomplete-object'",
",",
"$",
"array",
"[",
"'__PHP_Incomplete_Class_Name'",
"]",
"]",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"$",
"key",
"]",
"=",
"[",
"'string'",
",",
"(",
"string",
")",
"$",
"value",
"]",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
] | Flattens the args to make them easier to serialize.
@param array $args The args to flatten.
@param int $depth The current nesting depth.
@return array The flattened args. | [
"Flattens",
"the",
"args",
"to",
"make",
"them",
"easier",
"to",
"serialize",
"."
] | 024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e | https://github.com/unyx/diagnostics/blob/024dbe138dc27ff1797e74cd7d1bc7e3f81ab80e/debug/Frame.php#L296-L325 |
787 | mrcoco/phalms-core | user/models/Users.php | Users.afterSave | public function afterSave()
{
// Only send the confirmation email if emails are turned on in the config
if ($this->getDI()->get('config')->useMail) {
if ($this->active == 'N') {
$emailConfirmation = new EmailConfirmations();
$emailConfirmation->usersId = $this->id;
if ($emailConfirmation->save()) {
$this->getDI()
->getFlash()
->notice('A confirmation mail has been sent to ' . $this->email);
}
}
}
} | php | public function afterSave()
{
// Only send the confirmation email if emails are turned on in the config
if ($this->getDI()->get('config')->useMail) {
if ($this->active == 'N') {
$emailConfirmation = new EmailConfirmations();
$emailConfirmation->usersId = $this->id;
if ($emailConfirmation->save()) {
$this->getDI()
->getFlash()
->notice('A confirmation mail has been sent to ' . $this->email);
}
}
}
} | [
"public",
"function",
"afterSave",
"(",
")",
"{",
"// Only send the confirmation email if emails are turned on in the config",
"if",
"(",
"$",
"this",
"->",
"getDI",
"(",
")",
"->",
"get",
"(",
"'config'",
")",
"->",
"useMail",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"active",
"==",
"'N'",
")",
"{",
"$",
"emailConfirmation",
"=",
"new",
"EmailConfirmations",
"(",
")",
";",
"$",
"emailConfirmation",
"->",
"usersId",
"=",
"$",
"this",
"->",
"id",
";",
"if",
"(",
"$",
"emailConfirmation",
"->",
"save",
"(",
")",
")",
"{",
"$",
"this",
"->",
"getDI",
"(",
")",
"->",
"getFlash",
"(",
")",
"->",
"notice",
"(",
"'A confirmation mail has been sent to '",
".",
"$",
"this",
"->",
"email",
")",
";",
"}",
"}",
"}",
"}"
] | Send a confirmation e-mail to the user if the account is not active | [
"Send",
"a",
"confirmation",
"e",
"-",
"mail",
"to",
"the",
"user",
"if",
"the",
"account",
"is",
"not",
"active"
] | 23486c3e75077896e708f0d2e257cde280a79ad4 | https://github.com/mrcoco/phalms-core/blob/23486c3e75077896e708f0d2e257cde280a79ad4/user/models/Users.php#L109-L127 |
788 | slickframework/mvc | src/Router/RouteBuilder.php | RouteBuilder.getData | public function getData()
{
if (is_null($this->data)) {
try {
$this->data = $this->getParser()->parse($this->getYmlData());
} catch (ParseException $exp) {
throw new RoutesFileParseException(
"Fail to parse routes file: ".
$exp->getMessage(),
0,
$exp
);
}
}
return $this->data;
} | php | public function getData()
{
if (is_null($this->data)) {
try {
$this->data = $this->getParser()->parse($this->getYmlData());
} catch (ParseException $exp) {
throw new RoutesFileParseException(
"Fail to parse routes file: ".
$exp->getMessage(),
0,
$exp
);
}
}
return $this->data;
} | [
"public",
"function",
"getData",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"this",
"->",
"getParser",
"(",
")",
"->",
"parse",
"(",
"$",
"this",
"->",
"getYmlData",
"(",
")",
")",
";",
"}",
"catch",
"(",
"ParseException",
"$",
"exp",
")",
"{",
"throw",
"new",
"RoutesFileParseException",
"(",
"\"Fail to parse routes file: \"",
".",
"$",
"exp",
"->",
"getMessage",
"(",
")",
",",
"0",
",",
"$",
"exp",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"data",
";",
"}"
] | Returns parsed data from YML
If no data is present the YML parser parses it and its values are
assigned to the data field.
@return mixed | [
"Returns",
"parsed",
"data",
"from",
"YML"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Router/RouteBuilder.php#L121-L136 |
789 | slickframework/mvc | src/Router/RouteBuilder.php | RouteBuilder.setMapDefaults | protected function setMapDefaults(array $data)
{
$defaults = ['tokens', 'defaults', 'host', 'accepts'];
foreach ($data as $name => $value) {
if (in_array($name, $defaults)) {
$this->map->$name($value);
}
}
} | php | protected function setMapDefaults(array $data)
{
$defaults = ['tokens', 'defaults', 'host', 'accepts'];
foreach ($data as $name => $value) {
if (in_array($name, $defaults)) {
$this->map->$name($value);
}
}
} | [
"protected",
"function",
"setMapDefaults",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"defaults",
"=",
"[",
"'tokens'",
",",
"'defaults'",
",",
"'host'",
",",
"'accepts'",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"$",
"defaults",
")",
")",
"{",
"$",
"this",
"->",
"map",
"->",
"$",
"name",
"(",
"$",
"value",
")",
";",
"}",
"}",
"}"
] | Gets the YML parser data and sets the map default defined
@param array $data | [
"Gets",
"the",
"YML",
"parser",
"data",
"and",
"sets",
"the",
"map",
"default",
"defined"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Router/RouteBuilder.php#L185-L193 |
790 | crazedsanity/arraytopath | src/arraytopath/arraytopath.class.php | ArrayToPath.get_data | public function get_data($path=NULL) {
$myIndexList = array();
$path = $this->fix_path($path);
if(is_null($path) || (strlen($path) < 1)) {
//they just want ALL THE DATA.
$retval = $this->data;
}
else {
//get the list of indices in our data that we have to traverse.
$myIndexList = $this->explode_path($path);
//set an initial retval.
$retval = $this->get_data_segment($this->data, $myIndexList[0]);
unset($myIndexList[0]);
if(count($myIndexList) > 0) {
foreach($myIndexList as $indexName) {
$retval = $this->get_data_segment($retval, $indexName);
if(is_null($retval)) {
//hmm... well, if it's null, it's nothing which can have a sub-index. Stop here.
break;
}
}
}
}
return($retval);
} | php | public function get_data($path=NULL) {
$myIndexList = array();
$path = $this->fix_path($path);
if(is_null($path) || (strlen($path) < 1)) {
//they just want ALL THE DATA.
$retval = $this->data;
}
else {
//get the list of indices in our data that we have to traverse.
$myIndexList = $this->explode_path($path);
//set an initial retval.
$retval = $this->get_data_segment($this->data, $myIndexList[0]);
unset($myIndexList[0]);
if(count($myIndexList) > 0) {
foreach($myIndexList as $indexName) {
$retval = $this->get_data_segment($retval, $indexName);
if(is_null($retval)) {
//hmm... well, if it's null, it's nothing which can have a sub-index. Stop here.
break;
}
}
}
}
return($retval);
} | [
"public",
"function",
"get_data",
"(",
"$",
"path",
"=",
"NULL",
")",
"{",
"$",
"myIndexList",
"=",
"array",
"(",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"fix_path",
"(",
"$",
"path",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"path",
")",
"||",
"(",
"strlen",
"(",
"$",
"path",
")",
"<",
"1",
")",
")",
"{",
"//they just want ALL THE DATA.",
"$",
"retval",
"=",
"$",
"this",
"->",
"data",
";",
"}",
"else",
"{",
"//get the list of indices in our data that we have to traverse.",
"$",
"myIndexList",
"=",
"$",
"this",
"->",
"explode_path",
"(",
"$",
"path",
")",
";",
"//set an initial retval.",
"$",
"retval",
"=",
"$",
"this",
"->",
"get_data_segment",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"myIndexList",
"[",
"0",
"]",
")",
";",
"unset",
"(",
"$",
"myIndexList",
"[",
"0",
"]",
")",
";",
"if",
"(",
"count",
"(",
"$",
"myIndexList",
")",
">",
"0",
")",
"{",
"foreach",
"(",
"$",
"myIndexList",
"as",
"$",
"indexName",
")",
"{",
"$",
"retval",
"=",
"$",
"this",
"->",
"get_data_segment",
"(",
"$",
"retval",
",",
"$",
"indexName",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"retval",
")",
")",
"{",
"//hmm... well, if it's null, it's nothing which can have a sub-index. Stop here.",
"break",
";",
"}",
"}",
"}",
"}",
"return",
"(",
"$",
"retval",
")",
";",
"}"
] | Takes a path & returns the appropriate index in the session.
@param $path <str> path to the appropriate section in the session.
@return <NULL> FAIL: unable to find requested index.
@return <mixed> PASS: this is the value of the index. | [
"Takes",
"a",
"path",
"&",
"returns",
"the",
"appropriate",
"index",
"in",
"the",
"session",
"."
] | e503f445234c30ec7c5d0383eb53b6d99e5222ff | https://github.com/crazedsanity/arraytopath/blob/e503f445234c30ec7c5d0383eb53b6d99e5222ff/src/arraytopath/arraytopath.class.php#L75-L104 |
791 | crazedsanity/arraytopath | src/arraytopath/arraytopath.class.php | ArrayToPath.set_data | public function set_data($path, $data) {
if(is_object($data)) {
throw new InvalidArgumentException("objects are not supported");
}
else {
//get the list of indices in the session that we have to traverse.
$myIndexList = $this->explode_path($path);
$retval = 0;
//Use an internal iterator to go through the little bits of the session & set the
// data where it's supposed to be.
if($path === '/' || count($myIndexList) == 0) {
//setting the data.
$this->data = $data;
$retval = 1;
}
elseif(count($myIndexList) == 1) {
//that should be simple: set the index to be $data.
if(!is_array($this->data)) {
$this->data = array();
}
$this->data[$myIndexList[0]] = $data;
$retval = 1;
}
elseif(count($myIndexList) > 1) {
$this->internal_iterator($this->data, $path, $data);
$retval = 1;
}
}
return($retval);
} | php | public function set_data($path, $data) {
if(is_object($data)) {
throw new InvalidArgumentException("objects are not supported");
}
else {
//get the list of indices in the session that we have to traverse.
$myIndexList = $this->explode_path($path);
$retval = 0;
//Use an internal iterator to go through the little bits of the session & set the
// data where it's supposed to be.
if($path === '/' || count($myIndexList) == 0) {
//setting the data.
$this->data = $data;
$retval = 1;
}
elseif(count($myIndexList) == 1) {
//that should be simple: set the index to be $data.
if(!is_array($this->data)) {
$this->data = array();
}
$this->data[$myIndexList[0]] = $data;
$retval = 1;
}
elseif(count($myIndexList) > 1) {
$this->internal_iterator($this->data, $path, $data);
$retval = 1;
}
}
return($retval);
} | [
"public",
"function",
"set_data",
"(",
"$",
"path",
",",
"$",
"data",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"data",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"\"objects are not supported\"",
")",
";",
"}",
"else",
"{",
"//get the list of indices in the session that we have to traverse.",
"$",
"myIndexList",
"=",
"$",
"this",
"->",
"explode_path",
"(",
"$",
"path",
")",
";",
"$",
"retval",
"=",
"0",
";",
"//Use an internal iterator to go through the little bits of the session & set the",
"//\tdata where it's supposed to be.",
"if",
"(",
"$",
"path",
"===",
"'/'",
"||",
"count",
"(",
"$",
"myIndexList",
")",
"==",
"0",
")",
"{",
"//setting the data.",
"$",
"this",
"->",
"data",
"=",
"$",
"data",
";",
"$",
"retval",
"=",
"1",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"myIndexList",
")",
"==",
"1",
")",
"{",
"//that should be simple: set the index to be $data.",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"array",
"(",
")",
";",
"}",
"$",
"this",
"->",
"data",
"[",
"$",
"myIndexList",
"[",
"0",
"]",
"]",
"=",
"$",
"data",
";",
"$",
"retval",
"=",
"1",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"myIndexList",
")",
">",
"1",
")",
"{",
"$",
"this",
"->",
"internal_iterator",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"path",
",",
"$",
"data",
")",
";",
"$",
"retval",
"=",
"1",
";",
"}",
"}",
"return",
"(",
"$",
"retval",
")",
";",
"}"
] | Sets data into the given path, with options to override our internal prefix, and to
force-overwrite data if it's not an array.
@param $path <str> path to set the data into.
@param $data <mixed> what to set into the given path.
@return 0 FAIL: old data doesn't match new data.
@return 1 PASS: everything lines-up. | [
"Sets",
"data",
"into",
"the",
"given",
"path",
"with",
"options",
"to",
"override",
"our",
"internal",
"prefix",
"and",
"to",
"force",
"-",
"overwrite",
"data",
"if",
"it",
"s",
"not",
"an",
"array",
"."
] | e503f445234c30ec7c5d0383eb53b6d99e5222ff | https://github.com/crazedsanity/arraytopath/blob/e503f445234c30ec7c5d0383eb53b6d99e5222ff/src/arraytopath/arraytopath.class.php#L160-L191 |
792 | crazedsanity/arraytopath | src/arraytopath/arraytopath.class.php | ArrayToPath.explode_path | public function explode_path($path) {
$path = preg_replace('/\/{2,}/', '/', $path);
$path = $this->fix_path($path);
$retval = explode('/', $path);
//if the initial index is blank, just remove it.
if($retval[0] == '' || strlen($retval[0]) < 1) {
//it was blank! KILL IT!
$checkItOut = array_shift($retval);
}
return($retval);
} | php | public function explode_path($path) {
$path = preg_replace('/\/{2,}/', '/', $path);
$path = $this->fix_path($path);
$retval = explode('/', $path);
//if the initial index is blank, just remove it.
if($retval[0] == '' || strlen($retval[0]) < 1) {
//it was blank! KILL IT!
$checkItOut = array_shift($retval);
}
return($retval);
} | [
"public",
"function",
"explode_path",
"(",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"preg_replace",
"(",
"'/\\/{2,}/'",
",",
"'/'",
",",
"$",
"path",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"fix_path",
"(",
"$",
"path",
")",
";",
"$",
"retval",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"//if the initial index is blank, just remove it.",
"if",
"(",
"$",
"retval",
"[",
"0",
"]",
"==",
"''",
"||",
"strlen",
"(",
"$",
"retval",
"[",
"0",
"]",
")",
"<",
"1",
")",
"{",
"//it was blank! KILL IT!",
"$",
"checkItOut",
"=",
"array_shift",
"(",
"$",
"retval",
")",
";",
"}",
"return",
"(",
"$",
"retval",
")",
";",
"}"
] | Performs all the work of exploding the path and fixing it.
@param $path <string> Path to work with.
@return <array> PASS: array contains exploded path. | [
"Performs",
"all",
"the",
"work",
"of",
"exploding",
"the",
"path",
"and",
"fixing",
"it",
"."
] | e503f445234c30ec7c5d0383eb53b6d99e5222ff | https://github.com/crazedsanity/arraytopath/blob/e503f445234c30ec7c5d0383eb53b6d99e5222ff/src/arraytopath/arraytopath.class.php#L303-L315 |
793 | vinala/kernel | src/Http/Router/Route.php | Route.format | private function format(&$url)
{
if ($url == '/') {
$value = 'project_home';
$url = '';
} else {
$value = $url;
$url = '/'.$url;
}
return $value;
} | php | private function format(&$url)
{
if ($url == '/') {
$value = 'project_home';
$url = '';
} else {
$value = $url;
$url = '/'.$url;
}
return $value;
} | [
"private",
"function",
"format",
"(",
"&",
"$",
"url",
")",
"{",
"if",
"(",
"$",
"url",
"==",
"'/'",
")",
"{",
"$",
"value",
"=",
"'project_home'",
";",
"$",
"url",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"url",
";",
"$",
"url",
"=",
"'/'",
".",
"$",
"url",
";",
"}",
"return",
"$",
"value",
";",
"}"
] | Format the name and the url of Route.
@param string $url
@return string | [
"Format",
"the",
"name",
"and",
"the",
"url",
"of",
"Route",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Route.php#L153-L164 |
794 | vinala/kernel | src/Http/Router/Route.php | Route.get | public static function get($url, $callback)
{
$route = new self($url);
$route->setClosure($callback);
$route->setMethod('get');
$route->add();
return $route;
} | php | public static function get($url, $callback)
{
$route = new self($url);
$route->setClosure($callback);
$route->setMethod('get');
$route->add();
return $route;
} | [
"public",
"static",
"function",
"get",
"(",
"$",
"url",
",",
"$",
"callback",
")",
"{",
"$",
"route",
"=",
"new",
"self",
"(",
"$",
"url",
")",
";",
"$",
"route",
"->",
"setClosure",
"(",
"$",
"callback",
")",
";",
"$",
"route",
"->",
"setMethod",
"(",
"'get'",
")",
";",
"$",
"route",
"->",
"add",
"(",
")",
";",
"return",
"$",
"route",
";",
"}"
] | To add HTTP get request.
@param string $url
@param Closure $callback
@return $this | [
"To",
"add",
"HTTP",
"get",
"request",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Route.php#L324-L333 |
795 | vinala/kernel | src/Http/Router/Route.php | Route.view | public static function view($url, $view, $data = null)
{
$callback = function () use ($view, $data) {
$view = view($view);
if (!is_null($data)) {
foreach ($data as $key => $value) {
$view = $view->with($key, $value);
}
}
return $view;
};
static::get($url, $callback);
} | php | public static function view($url, $view, $data = null)
{
$callback = function () use ($view, $data) {
$view = view($view);
if (!is_null($data)) {
foreach ($data as $key => $value) {
$view = $view->with($key, $value);
}
}
return $view;
};
static::get($url, $callback);
} | [
"public",
"static",
"function",
"view",
"(",
"$",
"url",
",",
"$",
"view",
",",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"callback",
"=",
"function",
"(",
")",
"use",
"(",
"$",
"view",
",",
"$",
"data",
")",
"{",
"$",
"view",
"=",
"view",
"(",
"$",
"view",
")",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"view",
"=",
"$",
"view",
"->",
"with",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"view",
";",
"}",
";",
"static",
"::",
"get",
"(",
"$",
"url",
",",
"$",
"callback",
")",
";",
"}"
] | Show view in route call.
@param $url
@param $view
@return $this | [
"Show",
"view",
"in",
"route",
"call",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Route.php#L343-L358 |
796 | vinala/kernel | src/Http/Router/Route.php | Route.post | public static function post($url, $callback)
{
$route = new self($url);
$route->setClosure($callback);
$route->setMethod('post');
$route->add();
return $route;
} | php | public static function post($url, $callback)
{
$route = new self($url);
$route->setClosure($callback);
$route->setMethod('post');
$route->add();
return $route;
} | [
"public",
"static",
"function",
"post",
"(",
"$",
"url",
",",
"$",
"callback",
")",
"{",
"$",
"route",
"=",
"new",
"self",
"(",
"$",
"url",
")",
";",
"$",
"route",
"->",
"setClosure",
"(",
"$",
"callback",
")",
";",
"$",
"route",
"->",
"setMethod",
"(",
"'post'",
")",
";",
"$",
"route",
"->",
"add",
"(",
")",
";",
"return",
"$",
"route",
";",
"}"
] | To add HTTP post request.
@param string $url
@param Closure $callback
@return $this | [
"To",
"add",
"HTTP",
"post",
"request",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Route.php#L368-L377 |
797 | vinala/kernel | src/Http/Router/Route.php | Route.resource | public static function resource($url, $controller)
{
$route = new self($url);
$route->targets = ['index', 'show', 'insert', 'add', 'update', 'edit', 'delete'];
$route->setResourceMethods($url, $controller);
return $route;
} | php | public static function resource($url, $controller)
{
$route = new self($url);
$route->targets = ['index', 'show', 'insert', 'add', 'update', 'edit', 'delete'];
$route->setResourceMethods($url, $controller);
return $route;
} | [
"public",
"static",
"function",
"resource",
"(",
"$",
"url",
",",
"$",
"controller",
")",
"{",
"$",
"route",
"=",
"new",
"self",
"(",
"$",
"url",
")",
";",
"$",
"route",
"->",
"targets",
"=",
"[",
"'index'",
",",
"'show'",
",",
"'insert'",
",",
"'add'",
",",
"'update'",
",",
"'edit'",
",",
"'delete'",
"]",
";",
"$",
"route",
"->",
"setResourceMethods",
"(",
"$",
"url",
",",
"$",
"controller",
")",
";",
"return",
"$",
"route",
";",
"}"
] | Call resource route.
@param string $url
@param string $controller
@return mixed | [
"Call",
"resource",
"route",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Route.php#L387-L396 |
798 | vinala/kernel | src/Http/Router/Route.php | Route.target | public static function target($url, $target)
{
$route = new self($url);
$route->setMethod('call');
$segements = explode('@', $target);
exception_if(count($segements) != 2, \LogicException::class, 'The method name in targeted route expect two names, the controller and method, '.count($segements).' given in '.$target);
$controller = $segements[0];
$method = $segements[1];
$route->setResource($url, '', $controller, $method);
return $route;
} | php | public static function target($url, $target)
{
$route = new self($url);
$route->setMethod('call');
$segements = explode('@', $target);
exception_if(count($segements) != 2, \LogicException::class, 'The method name in targeted route expect two names, the controller and method, '.count($segements).' given in '.$target);
$controller = $segements[0];
$method = $segements[1];
$route->setResource($url, '', $controller, $method);
return $route;
} | [
"public",
"static",
"function",
"target",
"(",
"$",
"url",
",",
"$",
"target",
")",
"{",
"$",
"route",
"=",
"new",
"self",
"(",
"$",
"url",
")",
";",
"$",
"route",
"->",
"setMethod",
"(",
"'call'",
")",
";",
"$",
"segements",
"=",
"explode",
"(",
"'@'",
",",
"$",
"target",
")",
";",
"exception_if",
"(",
"count",
"(",
"$",
"segements",
")",
"!=",
"2",
",",
"\\",
"LogicException",
"::",
"class",
",",
"'The method name in targeted route expect two names, the controller and method, '",
".",
"count",
"(",
"$",
"segements",
")",
".",
"' given in '",
".",
"$",
"target",
")",
";",
"$",
"controller",
"=",
"$",
"segements",
"[",
"0",
"]",
";",
"$",
"method",
"=",
"$",
"segements",
"[",
"1",
"]",
";",
"$",
"route",
"->",
"setResource",
"(",
"$",
"url",
",",
"''",
",",
"$",
"controller",
",",
"$",
"method",
")",
";",
"return",
"$",
"route",
";",
"}"
] | Call target route.
@param string $url
@param string $target
@return Route | [
"Call",
"target",
"route",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Route.php#L406-L422 |
799 | vinala/kernel | src/Http/Router/Route.php | Route.setResourceMethods | private function setResourceMethods($url, $controller)
{
//index
$this->setIndexResource($url, '', $controller);
$url = ($url == '/') ? '' : $url;
$this->setIndexResource($url, '/index', $controller);
//show
$this->setShowResource($url, '/show/{param}', $controller);
//add
$this->setAddResource($url, '/add', $controller);
//insert
$this->setInsertResource($url, '/insert', $controller);
//edit
$this->setEditResource($url, '/edit/{param}', $controller);
//update
$this->setUpdateResource($url, '/update', $controller);
$this->setUpdateResource($url, '/update/{param}', $controller);
//delete
$this->setDeleteResource($url, '/delete/{param}', $controller);
} | php | private function setResourceMethods($url, $controller)
{
//index
$this->setIndexResource($url, '', $controller);
$url = ($url == '/') ? '' : $url;
$this->setIndexResource($url, '/index', $controller);
//show
$this->setShowResource($url, '/show/{param}', $controller);
//add
$this->setAddResource($url, '/add', $controller);
//insert
$this->setInsertResource($url, '/insert', $controller);
//edit
$this->setEditResource($url, '/edit/{param}', $controller);
//update
$this->setUpdateResource($url, '/update', $controller);
$this->setUpdateResource($url, '/update/{param}', $controller);
//delete
$this->setDeleteResource($url, '/delete/{param}', $controller);
} | [
"private",
"function",
"setResourceMethods",
"(",
"$",
"url",
",",
"$",
"controller",
")",
"{",
"//index",
"$",
"this",
"->",
"setIndexResource",
"(",
"$",
"url",
",",
"''",
",",
"$",
"controller",
")",
";",
"$",
"url",
"=",
"(",
"$",
"url",
"==",
"'/'",
")",
"?",
"''",
":",
"$",
"url",
";",
"$",
"this",
"->",
"setIndexResource",
"(",
"$",
"url",
",",
"'/index'",
",",
"$",
"controller",
")",
";",
"//show",
"$",
"this",
"->",
"setShowResource",
"(",
"$",
"url",
",",
"'/show/{param}'",
",",
"$",
"controller",
")",
";",
"//add",
"$",
"this",
"->",
"setAddResource",
"(",
"$",
"url",
",",
"'/add'",
",",
"$",
"controller",
")",
";",
"//insert",
"$",
"this",
"->",
"setInsertResource",
"(",
"$",
"url",
",",
"'/insert'",
",",
"$",
"controller",
")",
";",
"//edit",
"$",
"this",
"->",
"setEditResource",
"(",
"$",
"url",
",",
"'/edit/{param}'",
",",
"$",
"controller",
")",
";",
"//update",
"$",
"this",
"->",
"setUpdateResource",
"(",
"$",
"url",
",",
"'/update'",
",",
"$",
"controller",
")",
";",
"$",
"this",
"->",
"setUpdateResource",
"(",
"$",
"url",
",",
"'/update/{param}'",
",",
"$",
"controller",
")",
";",
"//delete",
"$",
"this",
"->",
"setDeleteResource",
"(",
"$",
"url",
",",
"'/delete/{param}'",
",",
"$",
"controller",
")",
";",
"}"
] | Set the methods resource.
@param string $url
@param string $controller
@return null | [
"Set",
"the",
"methods",
"resource",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Router/Route.php#L432-L460 |