id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
sequence | docstring
stringlengths 3
47.2k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
9,800 | Ocelot-Framework/ocelot-mvc | src/Web/Servlet/DispatcherServlet.php | DispatcherServlet.getHandlerAdapter | protected function getHandlerAdapter($handler)
{
foreach ($this->handlerAdapters as $ha) {
if ($ha->supports($handler)) {
return $ha;
}
}
throw new \Exception("No adapter for handler [".get_class($handler)."]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler.");
} | php | protected function getHandlerAdapter($handler)
{
foreach ($this->handlerAdapters as $ha) {
if ($ha->supports($handler)) {
return $ha;
}
}
throw new \Exception("No adapter for handler [".get_class($handler)."]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler.");
} | [
"protected",
"function",
"getHandlerAdapter",
"(",
"$",
"handler",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"handlerAdapters",
"as",
"$",
"ha",
")",
"{",
"if",
"(",
"$",
"ha",
"->",
"supports",
"(",
"$",
"handler",
")",
")",
"{",
"return",
"$",
"ha",
";",
"}",
"}",
"throw",
"new",
"\\",
"Exception",
"(",
"\"No adapter for handler [\"",
".",
"get_class",
"(",
"$",
"handler",
")",
".",
"\"]: The DispatcherServlet configuration needs to include a HandlerAdapter that supports this handler.\"",
")",
";",
"}"
] | Return the HandlerAdapter for this handler object.
@param mixed $handler the handler object to find an adapter for
@return HandlerAdapter The handler adapter for the given handler
@throws \Exception if no HandlerAdapter can be found for the handler. | [
"Return",
"the",
"HandlerAdapter",
"for",
"this",
"handler",
"object",
"."
] | 42a08208c6cebb87b363a0479331bafb7ec257c6 | https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/DispatcherServlet.php#L382-L390 |
9,801 | Ocelot-Framework/ocelot-mvc | src/Web/Servlet/DispatcherServlet.php | DispatcherServlet.processDispatchResult | protected function processDispatchResult(Request $request, Response $response, HandlerExecutionChain $mappedHandler, ModelAndView $mv = null, \Exception $ex = null)
{
// TODO: Render Exception
if ($mv != null && !$mv->wasCleared()) {
$this->render($mv, $request, $response);
}
if ($mappedHandler != null) {
$mappedHandler->triggerAfterCompletion($request, $response, $ex);
}
} | php | protected function processDispatchResult(Request $request, Response $response, HandlerExecutionChain $mappedHandler, ModelAndView $mv = null, \Exception $ex = null)
{
// TODO: Render Exception
if ($mv != null && !$mv->wasCleared()) {
$this->render($mv, $request, $response);
}
if ($mappedHandler != null) {
$mappedHandler->triggerAfterCompletion($request, $response, $ex);
}
} | [
"protected",
"function",
"processDispatchResult",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"HandlerExecutionChain",
"$",
"mappedHandler",
",",
"ModelAndView",
"$",
"mv",
"=",
"null",
",",
"\\",
"Exception",
"$",
"ex",
"=",
"null",
")",
"{",
"// TODO: Render Exception",
"if",
"(",
"$",
"mv",
"!=",
"null",
"&&",
"!",
"$",
"mv",
"->",
"wasCleared",
"(",
")",
")",
"{",
"$",
"this",
"->",
"render",
"(",
"$",
"mv",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"if",
"(",
"$",
"mappedHandler",
"!=",
"null",
")",
"{",
"$",
"mappedHandler",
"->",
"triggerAfterCompletion",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"ex",
")",
";",
"}",
"}"
] | Handle the result of a handler selection and handler invocation, which is
either a ModelAndView or an Exception to be resolved to a ModelAndView
@param Request $request current HTTP request
@param Response $response current HTTP response
@param HandlerExecutionChain $mappedHandler the mapped HandlerExecutionChain
@param ModelAndView $mv the ModelAndView to be processed, if any
@param \Exception $ex the thrown Exception, if any
@return void | [
"Handle",
"the",
"result",
"of",
"a",
"handler",
"selection",
"and",
"handler",
"invocation",
"which",
"is",
"either",
"a",
"ModelAndView",
"or",
"an",
"Exception",
"to",
"be",
"resolved",
"to",
"a",
"ModelAndView"
] | 42a08208c6cebb87b363a0479331bafb7ec257c6 | https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/DispatcherServlet.php#L402-L411 |
9,802 | Ocelot-Framework/ocelot-mvc | src/Web/Servlet/DispatcherServlet.php | DispatcherServlet.render | protected function render(ModelAndView $mv, Request $request, Response $response)
{
$view = null;
if ($mv->isReference()) {
$view = resolveViewName($mv->getViewName(), $mv->getModelMap(), null, $request);
if ($view == null) {
throw new \Exception("Could not resolve view with name '".$mv->getViewName()."'.");
}
} else {
$view = $mv->getView();
if ($view == null) {
throw new \Exception("ModelAndView neither contains a view name nor a View object.");
}
}
try {
$view->render($mv->getModelMap(), $request, $response);
} catch (\Exception $ex) {
$this->logger->debug("Error rendering view.");
throw $ex;
}
} | php | protected function render(ModelAndView $mv, Request $request, Response $response)
{
$view = null;
if ($mv->isReference()) {
$view = resolveViewName($mv->getViewName(), $mv->getModelMap(), null, $request);
if ($view == null) {
throw new \Exception("Could not resolve view with name '".$mv->getViewName()."'.");
}
} else {
$view = $mv->getView();
if ($view == null) {
throw new \Exception("ModelAndView neither contains a view name nor a View object.");
}
}
try {
$view->render($mv->getModelMap(), $request, $response);
} catch (\Exception $ex) {
$this->logger->debug("Error rendering view.");
throw $ex;
}
} | [
"protected",
"function",
"render",
"(",
"ModelAndView",
"$",
"mv",
",",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
")",
"{",
"$",
"view",
"=",
"null",
";",
"if",
"(",
"$",
"mv",
"->",
"isReference",
"(",
")",
")",
"{",
"$",
"view",
"=",
"resolveViewName",
"(",
"$",
"mv",
"->",
"getViewName",
"(",
")",
",",
"$",
"mv",
"->",
"getModelMap",
"(",
")",
",",
"null",
",",
"$",
"request",
")",
";",
"if",
"(",
"$",
"view",
"==",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Could not resolve view with name '\"",
".",
"$",
"mv",
"->",
"getViewName",
"(",
")",
".",
"\"'.\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"view",
"=",
"$",
"mv",
"->",
"getView",
"(",
")",
";",
"if",
"(",
"$",
"view",
"==",
"null",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"ModelAndView neither contains a view name nor a View object.\"",
")",
";",
"}",
"}",
"try",
"{",
"$",
"view",
"->",
"render",
"(",
"$",
"mv",
"->",
"getModelMap",
"(",
")",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"debug",
"(",
"\"Error rendering view.\"",
")",
";",
"throw",
"$",
"ex",
";",
"}",
"}"
] | Render the given ModelAndView.
@param ModelAndView $mv the ModelAndView to render
@param Request $request current HTTP servlet request
@param Response $response current HTTP servlet response
@throws \Exception if there's a problem rendering the view
@return void | [
"Render",
"the",
"given",
"ModelAndView",
"."
] | 42a08208c6cebb87b363a0479331bafb7ec257c6 | https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/DispatcherServlet.php#L421-L441 |
9,803 | Ocelot-Framework/ocelot-mvc | src/Web/Servlet/DispatcherServlet.php | DispatcherServlet.triggerAfterCompletion | protected function triggerAfterCompletion(Request $request, Response $response, HandlerExecutionChain $mappedHandler, \Exception $ex)
{
if ($mappedHandler != null) {
$mappedHandler->triggerAfterCompletion($request, $response, $ex);
}
throw $ex;
} | php | protected function triggerAfterCompletion(Request $request, Response $response, HandlerExecutionChain $mappedHandler, \Exception $ex)
{
if ($mappedHandler != null) {
$mappedHandler->triggerAfterCompletion($request, $response, $ex);
}
throw $ex;
} | [
"protected",
"function",
"triggerAfterCompletion",
"(",
"Request",
"$",
"request",
",",
"Response",
"$",
"response",
",",
"HandlerExecutionChain",
"$",
"mappedHandler",
",",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"if",
"(",
"$",
"mappedHandler",
"!=",
"null",
")",
"{",
"$",
"mappedHandler",
"->",
"triggerAfterCompletion",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"ex",
")",
";",
"}",
"throw",
"$",
"ex",
";",
"}"
] | Triggers after completion of the mappedHandler, if any
@param Request $request current HTTP request
@param Response $response current HTTP response
@param HandlerExecutionChain $mappedHandler the mapped HandlerExecutionChain
@param \Exception $ex the thrown Exception
@throws \Exception the thrown Exception
@return void | [
"Triggers",
"after",
"completion",
"of",
"the",
"mappedHandler",
"if",
"any"
] | 42a08208c6cebb87b363a0479331bafb7ec257c6 | https://github.com/Ocelot-Framework/ocelot-mvc/blob/42a08208c6cebb87b363a0479331bafb7ec257c6/src/Web/Servlet/DispatcherServlet.php#L471-L477 |
9,804 | wasabi-cms/core | src/Mailer/UserMailer.php | UserMailer.verifyEmail | public function verifyEmail(User $user, $token)
{
$this->_prepareEmail($user, __d('wasabi_core', 'Verify your email address'));
$this->_email->template('Wasabi/Core.User/verify');
$this->_email->viewVars([
'user' => $user,
'verifyEmailLink' => [
'plugin' => 'Wasabi/Core',
'controller' => 'Users',
'action' => 'verifyByToken',
'token' => $token
],
'instanceName' => Wasabi::getInstanceName()
]);
} | php | public function verifyEmail(User $user, $token)
{
$this->_prepareEmail($user, __d('wasabi_core', 'Verify your email address'));
$this->_email->template('Wasabi/Core.User/verify');
$this->_email->viewVars([
'user' => $user,
'verifyEmailLink' => [
'plugin' => 'Wasabi/Core',
'controller' => 'Users',
'action' => 'verifyByToken',
'token' => $token
],
'instanceName' => Wasabi::getInstanceName()
]);
} | [
"public",
"function",
"verifyEmail",
"(",
"User",
"$",
"user",
",",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"_prepareEmail",
"(",
"$",
"user",
",",
"__d",
"(",
"'wasabi_core'",
",",
"'Verify your email address'",
")",
")",
";",
"$",
"this",
"->",
"_email",
"->",
"template",
"(",
"'Wasabi/Core.User/verify'",
")",
";",
"$",
"this",
"->",
"_email",
"->",
"viewVars",
"(",
"[",
"'user'",
"=>",
"$",
"user",
",",
"'verifyEmailLink'",
"=>",
"[",
"'plugin'",
"=>",
"'Wasabi/Core'",
",",
"'controller'",
"=>",
"'Users'",
",",
"'action'",
"=>",
"'verifyByToken'",
",",
"'token'",
"=>",
"$",
"token",
"]",
",",
"'instanceName'",
"=>",
"Wasabi",
"::",
"getInstanceName",
"(",
")",
"]",
")",
";",
"}"
] | Send a "verify" email to the user, so that he can verify his email address.
@param User $user The user who should verify his email address.
@param string $token The verification token.
@return void | [
"Send",
"a",
"verify",
"email",
"to",
"the",
"user",
"so",
"that",
"he",
"can",
"verify",
"his",
"email",
"address",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Mailer/UserMailer.php#L31-L45 |
9,805 | wasabi-cms/core | src/Mailer/UserMailer.php | UserMailer.verifyAndResetPasswordEmail | public function verifyAndResetPasswordEmail(User $user, $token)
{
$this->_prepareEmail($user, __d('wasabi_core', 'Verify your email address'));
$this->_email->template('Wasabi/Core.User/verify');
$this->_email->viewVars([
'user' => $user,
'verifyEmailLink' => [
'plugin' => null,
'controller' => 'Backend/Users',
'action' => 'verifyByTokenResetPassword',
'token' => $token
],
'instanceName' => Wasabi::getInstanceName()
]);
} | php | public function verifyAndResetPasswordEmail(User $user, $token)
{
$this->_prepareEmail($user, __d('wasabi_core', 'Verify your email address'));
$this->_email->template('Wasabi/Core.User/verify');
$this->_email->viewVars([
'user' => $user,
'verifyEmailLink' => [
'plugin' => null,
'controller' => 'Backend/Users',
'action' => 'verifyByTokenResetPassword',
'token' => $token
],
'instanceName' => Wasabi::getInstanceName()
]);
} | [
"public",
"function",
"verifyAndResetPasswordEmail",
"(",
"User",
"$",
"user",
",",
"$",
"token",
")",
"{",
"$",
"this",
"->",
"_prepareEmail",
"(",
"$",
"user",
",",
"__d",
"(",
"'wasabi_core'",
",",
"'Verify your email address'",
")",
")",
";",
"$",
"this",
"->",
"_email",
"->",
"template",
"(",
"'Wasabi/Core.User/verify'",
")",
";",
"$",
"this",
"->",
"_email",
"->",
"viewVars",
"(",
"[",
"'user'",
"=>",
"$",
"user",
",",
"'verifyEmailLink'",
"=>",
"[",
"'plugin'",
"=>",
"null",
",",
"'controller'",
"=>",
"'Backend/Users'",
",",
"'action'",
"=>",
"'verifyByTokenResetPassword'",
",",
"'token'",
"=>",
"$",
"token",
"]",
",",
"'instanceName'",
"=>",
"Wasabi",
"::",
"getInstanceName",
"(",
")",
"]",
")",
";",
"}"
] | Send a "verify" email to the user that contains a link to verify his email address and setup his password.
This mail is sent, whenever an Admin creates a new user via the backend.
@param User $user The user who wants to reset his password.
@param string $token The verify and reset token.
@return void | [
"Send",
"a",
"verify",
"email",
"to",
"the",
"user",
"that",
"contains",
"a",
"link",
"to",
"verify",
"his",
"email",
"address",
"and",
"setup",
"his",
"password",
".",
"This",
"mail",
"is",
"sent",
"whenever",
"an",
"Admin",
"creates",
"a",
"new",
"user",
"via",
"the",
"backend",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Mailer/UserMailer.php#L55-L69 |
9,806 | wasabi-cms/core | src/Mailer/UserMailer.php | UserMailer.verifiedEmail | public function verifiedEmail(User $user)
{
$this->_prepareEmail($user, __d('wasabi_core', 'Email address verified'));
$this->_email->template('Wasabi/Core.User/verfied');
$this->_email->viewVars([
'user' => $user,
'instanceName' => Wasabi::getInstanceName()
]);
} | php | public function verifiedEmail(User $user)
{
$this->_prepareEmail($user, __d('wasabi_core', 'Email address verified'));
$this->_email->template('Wasabi/Core.User/verfied');
$this->_email->viewVars([
'user' => $user,
'instanceName' => Wasabi::getInstanceName()
]);
} | [
"public",
"function",
"verifiedEmail",
"(",
"User",
"$",
"user",
")",
"{",
"$",
"this",
"->",
"_prepareEmail",
"(",
"$",
"user",
",",
"__d",
"(",
"'wasabi_core'",
",",
"'Email address verified'",
")",
")",
";",
"$",
"this",
"->",
"_email",
"->",
"template",
"(",
"'Wasabi/Core.User/verfied'",
")",
";",
"$",
"this",
"->",
"_email",
"->",
"viewVars",
"(",
"[",
"'user'",
"=>",
"$",
"user",
",",
"'instanceName'",
"=>",
"Wasabi",
"::",
"getInstanceName",
"(",
")",
"]",
")",
";",
"}"
] | Send a "verified" email to the user, when his email address has been verified.
@param User $user The user who has verified his email address.
@return void | [
"Send",
"a",
"verified",
"email",
"to",
"the",
"user",
"when",
"his",
"email",
"address",
"has",
"been",
"verified",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Mailer/UserMailer.php#L77-L85 |
9,807 | wasabi-cms/core | src/Mailer/UserMailer.php | UserMailer._prepareEmail | protected function _prepareEmail(User $user, $subject)
{
$this->layout('Wasabi/Core.responsive');
$this->_email->transport('default');
$this->_email->emailFormat('both');
$this->_email->from(Wasabi::getSenderEmail(), Wasabi::getSenderName());
$this->_email->to($user->email, $user->username);
$this->_email->subject($subject);
$this->_email->helpers([
'Email' => [
'className' => 'Wasabi/Core.Email'
]
]);
} | php | protected function _prepareEmail(User $user, $subject)
{
$this->layout('Wasabi/Core.responsive');
$this->_email->transport('default');
$this->_email->emailFormat('both');
$this->_email->from(Wasabi::getSenderEmail(), Wasabi::getSenderName());
$this->_email->to($user->email, $user->username);
$this->_email->subject($subject);
$this->_email->helpers([
'Email' => [
'className' => 'Wasabi/Core.Email'
]
]);
} | [
"protected",
"function",
"_prepareEmail",
"(",
"User",
"$",
"user",
",",
"$",
"subject",
")",
"{",
"$",
"this",
"->",
"layout",
"(",
"'Wasabi/Core.responsive'",
")",
";",
"$",
"this",
"->",
"_email",
"->",
"transport",
"(",
"'default'",
")",
";",
"$",
"this",
"->",
"_email",
"->",
"emailFormat",
"(",
"'both'",
")",
";",
"$",
"this",
"->",
"_email",
"->",
"from",
"(",
"Wasabi",
"::",
"getSenderEmail",
"(",
")",
",",
"Wasabi",
"::",
"getSenderName",
"(",
")",
")",
";",
"$",
"this",
"->",
"_email",
"->",
"to",
"(",
"$",
"user",
"->",
"email",
",",
"$",
"user",
"->",
"username",
")",
";",
"$",
"this",
"->",
"_email",
"->",
"subject",
"(",
"$",
"subject",
")",
";",
"$",
"this",
"->",
"_email",
"->",
"helpers",
"(",
"[",
"'Email'",
"=>",
"[",
"'className'",
"=>",
"'Wasabi/Core.Email'",
"]",
"]",
")",
";",
"}"
] | Prepare the UserMailer Email instance.
@param User $user The user to send the email to.
@param string $subject The subject of the email.
@return void | [
"Prepare",
"the",
"UserMailer",
"Email",
"instance",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Mailer/UserMailer.php#L165-L178 |
9,808 | wasabi-cms/core | src/Mailer/UserMailer.php | UserMailer.send | public function send($action, $args = [], $headers = [])
{
$results = [];
try {
$results = parent::send($action, $args, $headers);
} catch (\Exception $e) {
Log::write(LOG_CRIT, 'Emails cannot be sent: ' . $e->getMessage(), $this->_email);
}
return $results;
} | php | public function send($action, $args = [], $headers = [])
{
$results = [];
try {
$results = parent::send($action, $args, $headers);
} catch (\Exception $e) {
Log::write(LOG_CRIT, 'Emails cannot be sent: ' . $e->getMessage(), $this->_email);
}
return $results;
} | [
"public",
"function",
"send",
"(",
"$",
"action",
",",
"$",
"args",
"=",
"[",
"]",
",",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"results",
"=",
"[",
"]",
";",
"try",
"{",
"$",
"results",
"=",
"parent",
"::",
"send",
"(",
"$",
"action",
",",
"$",
"args",
",",
"$",
"headers",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"Log",
"::",
"write",
"(",
"LOG_CRIT",
",",
"'Emails cannot be sent: '",
".",
"$",
"e",
"->",
"getMessage",
"(",
")",
",",
"$",
"this",
"->",
"_email",
")",
";",
"}",
"return",
"$",
"results",
";",
"}"
] | Wrap the original send to catch erros and log them.
@param string $action The name of the mailer action to trigger.
@param array $args Arguments to pass to the triggered mailer action.
@param array $headers Headers to set.
@throws \Cake\Mailer\Exception\MissingActionException
@throws \BadMethodCallException
@return array | [
"Wrap",
"the",
"original",
"send",
"to",
"catch",
"erros",
"and",
"log",
"them",
"."
] | 0eadbb64d2fc201bacc63c93814adeca70e08f90 | https://github.com/wasabi-cms/core/blob/0eadbb64d2fc201bacc63c93814adeca70e08f90/src/Mailer/UserMailer.php#L190-L201 |
9,809 | matryoshka-model/mongo-wrapper | library/Paginator/MongoPaginatorAdapter.php | MongoPaginatorAdapter.getItems | public function getItems($offset, $itemCountPerPage)
{
$this->cursor->skip($offset);
$this->cursor->limit($itemCountPerPage);
$resultSet = clone $this->resultSetPrototype;
$resultSet->initialize($this->cursor);
return $resultSet;
} | php | public function getItems($offset, $itemCountPerPage)
{
$this->cursor->skip($offset);
$this->cursor->limit($itemCountPerPage);
$resultSet = clone $this->resultSetPrototype;
$resultSet->initialize($this->cursor);
return $resultSet;
} | [
"public",
"function",
"getItems",
"(",
"$",
"offset",
",",
"$",
"itemCountPerPage",
")",
"{",
"$",
"this",
"->",
"cursor",
"->",
"skip",
"(",
"$",
"offset",
")",
";",
"$",
"this",
"->",
"cursor",
"->",
"limit",
"(",
"$",
"itemCountPerPage",
")",
";",
"$",
"resultSet",
"=",
"clone",
"$",
"this",
"->",
"resultSetPrototype",
";",
"$",
"resultSet",
"->",
"initialize",
"(",
"$",
"this",
"->",
"cursor",
")",
";",
"return",
"$",
"resultSet",
";",
"}"
] | Returns an result set of items for a page.
@param int $offset Page offset
@param int $itemCountPerPage Number of items per page
@return HydratingResultSet | [
"Returns",
"an",
"result",
"set",
"of",
"items",
"for",
"a",
"page",
"."
] | d69511d7f7fc58e708c771ea0cd3c8ba7e8a155a | https://github.com/matryoshka-model/mongo-wrapper/blob/d69511d7f7fc58e708c771ea0cd3c8ba7e8a155a/library/Paginator/MongoPaginatorAdapter.php#L66-L75 |
9,810 | deasilworks/cef | src/EntityDataManager.php | EntityDataManager.getModel | public function getModel()
{
$collection = $this->getCollection();
/** @var EntityDataModel $model */
$model = $collection->getModel();
$model->setEntityManager($this);
return $model;
} | php | public function getModel()
{
$collection = $this->getCollection();
/** @var EntityDataModel $model */
$model = $collection->getModel();
$model->setEntityManager($this);
return $model;
} | [
"public",
"function",
"getModel",
"(",
")",
"{",
"$",
"collection",
"=",
"$",
"this",
"->",
"getCollection",
"(",
")",
";",
"/** @var EntityDataModel $model */",
"$",
"model",
"=",
"$",
"collection",
"->",
"getModel",
"(",
")",
";",
"$",
"model",
"->",
"setEntityManager",
"(",
"$",
"this",
")",
";",
"return",
"$",
"model",
";",
"}"
] | Get the model associated with the collection.
@return EntityDataModel | [
"Get",
"the",
"model",
"associated",
"with",
"the",
"collection",
"."
] | 18c65f2b123512bba2208975dc655354f57670be | https://github.com/deasilworks/cef/blob/18c65f2b123512bba2208975dc655354f57670be/src/EntityDataManager.php#L90-L99 |
9,811 | deasilworks/cef | src/EntityDataManager.php | EntityDataManager.getStatementManager | public function getStatementManager($statementClass = Simple::class)
{
/** @var StatementManager $statementManager */
$statementManager = new $statementClass($this->config, $this);
$collectionClass = $this->getCollectionClass();
if (!$statementManager instanceof StatementManager) {
throw new \Exception($statementClass.' is not an instance of Deasil\CEF\StatementManager.');
}
$statementManager->setResultContainerClass($collectionClass);
return $statementManager;
} | php | public function getStatementManager($statementClass = Simple::class)
{
/** @var StatementManager $statementManager */
$statementManager = new $statementClass($this->config, $this);
$collectionClass = $this->getCollectionClass();
if (!$statementManager instanceof StatementManager) {
throw new \Exception($statementClass.' is not an instance of Deasil\CEF\StatementManager.');
}
$statementManager->setResultContainerClass($collectionClass);
return $statementManager;
} | [
"public",
"function",
"getStatementManager",
"(",
"$",
"statementClass",
"=",
"Simple",
"::",
"class",
")",
"{",
"/** @var StatementManager $statementManager */",
"$",
"statementManager",
"=",
"new",
"$",
"statementClass",
"(",
"$",
"this",
"->",
"config",
",",
"$",
"this",
")",
";",
"$",
"collectionClass",
"=",
"$",
"this",
"->",
"getCollectionClass",
"(",
")",
";",
"if",
"(",
"!",
"$",
"statementManager",
"instanceof",
"StatementManager",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"statementClass",
".",
"' is not an instance of Deasil\\CEF\\StatementManager.'",
")",
";",
"}",
"$",
"statementManager",
"->",
"setResultContainerClass",
"(",
"$",
"collectionClass",
")",
";",
"return",
"$",
"statementManager",
";",
"}"
] | Statement Manager Factory.
@param string $statementClass
@throws \Exception
@return StatementManager | [
"Statement",
"Manager",
"Factory",
"."
] | 18c65f2b123512bba2208975dc655354f57670be | https://github.com/deasilworks/cef/blob/18c65f2b123512bba2208975dc655354f57670be/src/EntityDataManager.php#L130-L144 |
9,812 | tadcka/Routing | RouteAwareTrait.php | RouteAwareTrait.getRouteFromRequest | protected function getRouteFromRequest(Request $request)
{
$attributes = $request->attributes->get('_route_params');
if (isset($attributes[RouteObjectInterface::ROUTE_OBJECT])
&& ($attributes[RouteObjectInterface::ROUTE_OBJECT] instanceof RouteInterface)
) {
return $attributes[RouteObjectInterface::ROUTE_OBJECT];
}
return null;
} | php | protected function getRouteFromRequest(Request $request)
{
$attributes = $request->attributes->get('_route_params');
if (isset($attributes[RouteObjectInterface::ROUTE_OBJECT])
&& ($attributes[RouteObjectInterface::ROUTE_OBJECT] instanceof RouteInterface)
) {
return $attributes[RouteObjectInterface::ROUTE_OBJECT];
}
return null;
} | [
"protected",
"function",
"getRouteFromRequest",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"attributes",
"=",
"$",
"request",
"->",
"attributes",
"->",
"get",
"(",
"'_route_params'",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"attributes",
"[",
"RouteObjectInterface",
"::",
"ROUTE_OBJECT",
"]",
")",
"&&",
"(",
"$",
"attributes",
"[",
"RouteObjectInterface",
"::",
"ROUTE_OBJECT",
"]",
"instanceof",
"RouteInterface",
")",
")",
"{",
"return",
"$",
"attributes",
"[",
"RouteObjectInterface",
"::",
"ROUTE_OBJECT",
"]",
";",
"}",
"return",
"null",
";",
"}"
] | Get route from request.
@param Request $request
@return null|RouteInterface | [
"Get",
"route",
"from",
"request",
"."
] | b2280bac33eb76eec76ecc8d665c70092f3cbba9 | https://github.com/tadcka/Routing/blob/b2280bac33eb76eec76ecc8d665c70092f3cbba9/RouteAwareTrait.php#L32-L43 |
9,813 | padosoft/io | src/DirHelper.php | DirHelper.collapseDotFolder | protected static function collapseDotFolder($root, $part, &$canonicalParts)
{
if ('.' === $part) {
return;
}
// Collapse ".." with the previous part, if one exists
// Don't collapse ".." if the previous part is also ".."
if ('..' === $part && count($canonicalParts) > 0
&& '..' !== $canonicalParts[count($canonicalParts) - 1]
) {
array_pop($canonicalParts);
return;
}
// Only add ".." prefixes for relative paths
if ('..' !== $part || '' === $root) {
$canonicalParts[] = $part;
}
} | php | protected static function collapseDotFolder($root, $part, &$canonicalParts)
{
if ('.' === $part) {
return;
}
// Collapse ".." with the previous part, if one exists
// Don't collapse ".." if the previous part is also ".."
if ('..' === $part && count($canonicalParts) > 0
&& '..' !== $canonicalParts[count($canonicalParts) - 1]
) {
array_pop($canonicalParts);
return;
}
// Only add ".." prefixes for relative paths
if ('..' !== $part || '' === $root) {
$canonicalParts[] = $part;
}
} | [
"protected",
"static",
"function",
"collapseDotFolder",
"(",
"$",
"root",
",",
"$",
"part",
",",
"&",
"$",
"canonicalParts",
")",
"{",
"if",
"(",
"'.'",
"===",
"$",
"part",
")",
"{",
"return",
";",
"}",
"// Collapse \"..\" with the previous part, if one exists",
"// Don't collapse \"..\" if the previous part is also \"..\"",
"if",
"(",
"'..'",
"===",
"$",
"part",
"&&",
"count",
"(",
"$",
"canonicalParts",
")",
">",
"0",
"&&",
"'..'",
"!==",
"$",
"canonicalParts",
"[",
"count",
"(",
"$",
"canonicalParts",
")",
"-",
"1",
"]",
")",
"{",
"array_pop",
"(",
"$",
"canonicalParts",
")",
";",
"return",
";",
"}",
"// Only add \"..\" prefixes for relative paths",
"if",
"(",
"'..'",
"!==",
"$",
"part",
"||",
"''",
"===",
"$",
"root",
")",
"{",
"$",
"canonicalParts",
"[",
"]",
"=",
"$",
"part",
";",
"}",
"}"
] | Collapse dot folder '.', '..', if possible
@param string $root
@param $part
@param $canonicalParts | [
"Collapse",
"dot",
"folder",
".",
"..",
"if",
"possible"
] | 788eef6d9b00d28bb17f7fa1e78489df0075259e | https://github.com/padosoft/io/blob/788eef6d9b00d28bb17f7fa1e78489df0075259e/src/DirHelper.php#L521-L538 |
9,814 | padosoft/io | src/DirHelper.php | DirHelper.isDirEmpty | public static function isDirEmpty(string $path) : bool
{
//che if no such dir, not a dir, not readable
if (!self::isReadable($path)) {
return false;
}
$result = true;
$handle = opendir($path);
while (false !== ($entry = readdir($handle))) {
if (!self::isDotDir($entry)) {
$result = false;
break;
}
}
closedir($handle);
return $result;
} | php | public static function isDirEmpty(string $path) : bool
{
//che if no such dir, not a dir, not readable
if (!self::isReadable($path)) {
return false;
}
$result = true;
$handle = opendir($path);
while (false !== ($entry = readdir($handle))) {
if (!self::isDotDir($entry)) {
$result = false;
break;
}
}
closedir($handle);
return $result;
} | [
"public",
"static",
"function",
"isDirEmpty",
"(",
"string",
"$",
"path",
")",
":",
"bool",
"{",
"//che if no such dir, not a dir, not readable",
"if",
"(",
"!",
"self",
"::",
"isReadable",
"(",
"$",
"path",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"result",
"=",
"true",
";",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"path",
")",
";",
"while",
"(",
"false",
"!==",
"(",
"$",
"entry",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"isDotDir",
"(",
"$",
"entry",
")",
")",
"{",
"$",
"result",
"=",
"false",
";",
"break",
";",
"}",
"}",
"closedir",
"(",
"$",
"handle",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Check if a directory is empty in efficent way.
Check hidden files too.
@param string $path
@return bool | [
"Check",
"if",
"a",
"directory",
"is",
"empty",
"in",
"efficent",
"way",
".",
"Check",
"hidden",
"files",
"too",
"."
] | 788eef6d9b00d28bb17f7fa1e78489df0075259e | https://github.com/padosoft/io/blob/788eef6d9b00d28bb17f7fa1e78489df0075259e/src/DirHelper.php#L592-L609 |
9,815 | factorio-item-browser/api-database | src/Repository/ModRepository.php | ModRepository.findByNamesWithDependencies | public function findByNamesWithDependencies(array $modNames): array
{
$result = [];
if (count($modNames) > 0) {
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select(['m', 'd', 'dm'])
->from(Mod::class, 'm')
->leftJoin('m.dependencies', 'd')
->leftJoin('d.requiredMod', 'dm')
->andWhere('m.name IN (:modNames)')
->setParameter('modNames', array_values($modNames));
$result = $queryBuilder->getQuery()->getResult();
}
return $result;
} | php | public function findByNamesWithDependencies(array $modNames): array
{
$result = [];
if (count($modNames) > 0) {
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select(['m', 'd', 'dm'])
->from(Mod::class, 'm')
->leftJoin('m.dependencies', 'd')
->leftJoin('d.requiredMod', 'dm')
->andWhere('m.name IN (:modNames)')
->setParameter('modNames', array_values($modNames));
$result = $queryBuilder->getQuery()->getResult();
}
return $result;
} | [
"public",
"function",
"findByNamesWithDependencies",
"(",
"array",
"$",
"modNames",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"count",
"(",
"$",
"modNames",
")",
">",
"0",
")",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"[",
"'m'",
",",
"'d'",
",",
"'dm'",
"]",
")",
"->",
"from",
"(",
"Mod",
"::",
"class",
",",
"'m'",
")",
"->",
"leftJoin",
"(",
"'m.dependencies'",
",",
"'d'",
")",
"->",
"leftJoin",
"(",
"'d.requiredMod'",
",",
"'dm'",
")",
"->",
"andWhere",
"(",
"'m.name IN (:modNames)'",
")",
"->",
"setParameter",
"(",
"'modNames'",
",",
"array_values",
"(",
"$",
"modNames",
")",
")",
";",
"$",
"result",
"=",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getResult",
"(",
")",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Finds all mods with the specified names, fetching their dependencies as well.
@param array|string[] $modNames
@return array|Mod[] | [
"Finds",
"all",
"mods",
"with",
"the",
"specified",
"names",
"fetching",
"their",
"dependencies",
"as",
"well",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/ModRepository.php#L23-L38 |
9,816 | factorio-item-browser/api-database | src/Repository/ModRepository.php | ModRepository.count | public function count(array $modCombinationIds = []): int
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('COUNT(DISTINCT m.id) AS numberOfMods')
->from(Mod::class, 'm');
if (count($modCombinationIds) > 0) {
$queryBuilder->innerJoin('m.combinations', 'mc')
->andWhere('mc.id IN (:modCombinationIds)')
->setParameter('modCombinationIds', array_values($modCombinationIds));
}
try {
$result = (int) $queryBuilder->getQuery()->getSingleScalarResult();
} catch (NonUniqueResultException $e) {
$result = 0;
}
return $result;
} | php | public function count(array $modCombinationIds = []): int
{
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('COUNT(DISTINCT m.id) AS numberOfMods')
->from(Mod::class, 'm');
if (count($modCombinationIds) > 0) {
$queryBuilder->innerJoin('m.combinations', 'mc')
->andWhere('mc.id IN (:modCombinationIds)')
->setParameter('modCombinationIds', array_values($modCombinationIds));
}
try {
$result = (int) $queryBuilder->getQuery()->getSingleScalarResult();
} catch (NonUniqueResultException $e) {
$result = 0;
}
return $result;
} | [
"public",
"function",
"count",
"(",
"array",
"$",
"modCombinationIds",
"=",
"[",
"]",
")",
":",
"int",
"{",
"$",
"queryBuilder",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"createQueryBuilder",
"(",
")",
";",
"$",
"queryBuilder",
"->",
"select",
"(",
"'COUNT(DISTINCT m.id) AS numberOfMods'",
")",
"->",
"from",
"(",
"Mod",
"::",
"class",
",",
"'m'",
")",
";",
"if",
"(",
"count",
"(",
"$",
"modCombinationIds",
")",
">",
"0",
")",
"{",
"$",
"queryBuilder",
"->",
"innerJoin",
"(",
"'m.combinations'",
",",
"'mc'",
")",
"->",
"andWhere",
"(",
"'mc.id IN (:modCombinationIds)'",
")",
"->",
"setParameter",
"(",
"'modCombinationIds'",
",",
"array_values",
"(",
"$",
"modCombinationIds",
")",
")",
";",
"}",
"try",
"{",
"$",
"result",
"=",
"(",
"int",
")",
"$",
"queryBuilder",
"->",
"getQuery",
"(",
")",
"->",
"getSingleScalarResult",
"(",
")",
";",
"}",
"catch",
"(",
"NonUniqueResultException",
"$",
"e",
")",
"{",
"$",
"result",
"=",
"0",
";",
"}",
"return",
"$",
"result",
";",
"}"
] | Counts the mods.
@param array|int[] $modCombinationIds
@return int | [
"Counts",
"the",
"mods",
"."
] | c3a27e5673462a58b5afafc0ea0e0002f6db9803 | https://github.com/factorio-item-browser/api-database/blob/c3a27e5673462a58b5afafc0ea0e0002f6db9803/src/Repository/ModRepository.php#L58-L76 |
9,817 | indigophp-archive/guardian | src/SessionAuth.php | SessionAuth.getCurrentCaller | public function getCurrentCaller()
{
if (is_null($this->currentCaller)) {
$loginToken = $this->session->getLoginToken();
try {
$this->currentCaller = $this->identifier->identifyByLoginToken($loginToken);
} catch (IdentificationFailed $e) {
// we couldn't identify the caller, so we destroy the session
// TODO: think about this
$this->session->destroy();
}
}
return $this->currentCaller;
} | php | public function getCurrentCaller()
{
if (is_null($this->currentCaller)) {
$loginToken = $this->session->getLoginToken();
try {
$this->currentCaller = $this->identifier->identifyByLoginToken($loginToken);
} catch (IdentificationFailed $e) {
// we couldn't identify the caller, so we destroy the session
// TODO: think about this
$this->session->destroy();
}
}
return $this->currentCaller;
} | [
"public",
"function",
"getCurrentCaller",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"currentCaller",
")",
")",
"{",
"$",
"loginToken",
"=",
"$",
"this",
"->",
"session",
"->",
"getLoginToken",
"(",
")",
";",
"try",
"{",
"$",
"this",
"->",
"currentCaller",
"=",
"$",
"this",
"->",
"identifier",
"->",
"identifyByLoginToken",
"(",
"$",
"loginToken",
")",
";",
"}",
"catch",
"(",
"IdentificationFailed",
"$",
"e",
")",
"{",
"// we couldn't identify the caller, so we destroy the session",
"// TODO: think about this",
"$",
"this",
"->",
"session",
"->",
"destroy",
"(",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"currentCaller",
";",
"}"
] | Returns the current caller
@return HasLoginToken | [
"Returns",
"the",
"current",
"caller"
] | 244b1c3be1cc3da428c9dea03e80f9d74593830a | https://github.com/indigophp-archive/guardian/blob/244b1c3be1cc3da428c9dea03e80f9d74593830a/src/SessionAuth.php#L97-L112 |
9,818 | g105b/phpcsv | src/Csv.php | Csv.checkIdField | private function checkIdField() {
if(is_null($this->headers)) {
return;
}
if(in_array($this->idField, $this->headers)) {
return;
}
foreach($this->headers as $header) {
if(strtolower($this->idField) == strtolower($header)) {
$this->setIdField($header);
}
}
} | php | private function checkIdField() {
if(is_null($this->headers)) {
return;
}
if(in_array($this->idField, $this->headers)) {
return;
}
foreach($this->headers as $header) {
if(strtolower($this->idField) == strtolower($header)) {
$this->setIdField($header);
}
}
} | [
"private",
"function",
"checkIdField",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"headers",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"in_array",
"(",
"$",
"this",
"->",
"idField",
",",
"$",
"this",
"->",
"headers",
")",
")",
"{",
"return",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"header",
")",
"{",
"if",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"idField",
")",
"==",
"strtolower",
"(",
"$",
"header",
")",
")",
"{",
"$",
"this",
"->",
"setIdField",
"(",
"$",
"header",
")",
";",
"}",
"}",
"}"
] | Check the header line for variations on the default ID field name, fixing
the case of the ID field. | [
"Check",
"the",
"header",
"line",
"for",
"variations",
"on",
"the",
"default",
"ID",
"field",
"name",
"fixing",
"the",
"case",
"of",
"the",
"ID",
"field",
"."
] | 07515f794c7fc4406dbfd3e87ce96ea5bc1483d5 | https://github.com/g105b/phpcsv/blob/07515f794c7fc4406dbfd3e87ce96ea5bc1483d5/src/Csv.php#L111-L124 |
9,819 | g105b/phpcsv | src/Csv.php | Csv.toAssociative | public function toAssociative($data) {
foreach ($data as $i => $value) {
$headerName = $this->headers[$i];
$data[$headerName] = $value;
unset($data[$i]);
}
return $data;
} | php | public function toAssociative($data) {
foreach ($data as $i => $value) {
$headerName = $this->headers[$i];
$data[$headerName] = $value;
unset($data[$i]);
}
return $data;
} | [
"public",
"function",
"toAssociative",
"(",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"i",
"=>",
"$",
"value",
")",
"{",
"$",
"headerName",
"=",
"$",
"this",
"->",
"headers",
"[",
"$",
"i",
"]",
";",
"$",
"data",
"[",
"$",
"headerName",
"]",
"=",
"$",
"value",
";",
"unset",
"(",
"$",
"data",
"[",
"$",
"i",
"]",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Converts an indexed array of data into an associative array with field names.
@param array $data Indexed array of data representing row
@return array Associative array of data with field names | [
"Converts",
"an",
"indexed",
"array",
"of",
"data",
"into",
"an",
"associative",
"array",
"with",
"field",
"names",
"."
] | 07515f794c7fc4406dbfd3e87ce96ea5bc1483d5 | https://github.com/g105b/phpcsv/blob/07515f794c7fc4406dbfd3e87ce96ea5bc1483d5/src/Csv.php#L176-L184 |
9,820 | g105b/phpcsv | src/Csv.php | Csv.toIndexed | public function toIndexed($data, $fillMissing = false) {
foreach ($data as $key => $value) {
if(!in_array($key, $this->headers)) {
throw new InvalidFieldException($key);
}
$headerIndex = (int)array_search($key, $this->headers);
$data[$headerIndex] = $value;
unset($data[$key]);
}
ksort($data);
if($fillMissing) {
$data = $this->fillMissing($data);
}
return $data;
} | php | public function toIndexed($data, $fillMissing = false) {
foreach ($data as $key => $value) {
if(!in_array($key, $this->headers)) {
throw new InvalidFieldException($key);
}
$headerIndex = (int)array_search($key, $this->headers);
$data[$headerIndex] = $value;
unset($data[$key]);
}
ksort($data);
if($fillMissing) {
$data = $this->fillMissing($data);
}
return $data;
} | [
"public",
"function",
"toIndexed",
"(",
"$",
"data",
",",
"$",
"fillMissing",
"=",
"false",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"headers",
")",
")",
"{",
"throw",
"new",
"InvalidFieldException",
"(",
"$",
"key",
")",
";",
"}",
"$",
"headerIndex",
"=",
"(",
"int",
")",
"array_search",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"headers",
")",
";",
"$",
"data",
"[",
"$",
"headerIndex",
"]",
"=",
"$",
"value",
";",
"unset",
"(",
"$",
"data",
"[",
"$",
"key",
"]",
")",
";",
"}",
"ksort",
"(",
"$",
"data",
")",
";",
"if",
"(",
"$",
"fillMissing",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"fillMissing",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Converts an associative array into an indexed array, according to the
currently stored headers.
@param array $data Associative array of data representing row
@param bool $fillMissing True to fill missing indices
@return array Indexed array of data in order of columns | [
"Converts",
"an",
"associative",
"array",
"into",
"an",
"indexed",
"array",
"according",
"to",
"the",
"currently",
"stored",
"headers",
"."
] | 07515f794c7fc4406dbfd3e87ce96ea5bc1483d5 | https://github.com/g105b/phpcsv/blob/07515f794c7fc4406dbfd3e87ce96ea5bc1483d5/src/Csv.php#L195-L211 |
9,821 | g105b/phpcsv | src/Csv.php | Csv.fillMissing | private function fillMissing($data, $existingData = []) {
if($this->isAssoc($data)) {
foreach ($this->headers as $header) {
if(!isset($data[$header])) {
$replaceWith = isset($existingData[$header])
? $existingData[$header]
: "";
$data[$header] = $replaceWith;
}
}
}
else {
end($this->headers);
for($i = 0, $max = key($this->headers); $i <= $max; $i++) {
if(!isset($data[$i])) {
$replaceWith = isset($existingData[$i])
? $existingData[$i]
: "";
$data[$i] = $replaceWith;
}
}
ksort($data);
}
return $data;
} | php | private function fillMissing($data, $existingData = []) {
if($this->isAssoc($data)) {
foreach ($this->headers as $header) {
if(!isset($data[$header])) {
$replaceWith = isset($existingData[$header])
? $existingData[$header]
: "";
$data[$header] = $replaceWith;
}
}
}
else {
end($this->headers);
for($i = 0, $max = key($this->headers); $i <= $max; $i++) {
if(!isset($data[$i])) {
$replaceWith = isset($existingData[$i])
? $existingData[$i]
: "";
$data[$i] = $replaceWith;
}
}
ksort($data);
}
return $data;
} | [
"private",
"function",
"fillMissing",
"(",
"$",
"data",
",",
"$",
"existingData",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAssoc",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"header",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"header",
"]",
")",
")",
"{",
"$",
"replaceWith",
"=",
"isset",
"(",
"$",
"existingData",
"[",
"$",
"header",
"]",
")",
"?",
"$",
"existingData",
"[",
"$",
"header",
"]",
":",
"\"\"",
";",
"$",
"data",
"[",
"$",
"header",
"]",
"=",
"$",
"replaceWith",
";",
"}",
"}",
"}",
"else",
"{",
"end",
"(",
"$",
"this",
"->",
"headers",
")",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"max",
"=",
"key",
"(",
"$",
"this",
"->",
"headers",
")",
";",
"$",
"i",
"<=",
"$",
"max",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"replaceWith",
"=",
"isset",
"(",
"$",
"existingData",
"[",
"$",
"i",
"]",
")",
"?",
"$",
"existingData",
"[",
"$",
"i",
"]",
":",
"\"\"",
";",
"$",
"data",
"[",
"$",
"i",
"]",
"=",
"$",
"replaceWith",
";",
"}",
"}",
"ksort",
"(",
"$",
"data",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Fills any missing keys with blank fields, or merging with an existing data
set if provided.
@param array $data Indexed or associative array containing row data
@param array $existingData Indexed or associative array of existing data to
fill in blank fields with
@return array Array in the same format (indexed or associative) as the input
data array, but with all keys present | [
"Fills",
"any",
"missing",
"keys",
"with",
"blank",
"fields",
"or",
"merging",
"with",
"an",
"existing",
"data",
"set",
"if",
"provided",
"."
] | 07515f794c7fc4406dbfd3e87ce96ea5bc1483d5 | https://github.com/g105b/phpcsv/blob/07515f794c7fc4406dbfd3e87ce96ea5bc1483d5/src/Csv.php#L224-L249 |
9,822 | g105b/phpcsv | src/Csv.php | Csv.get | public function get($index = null, $fetchFields = []) {
$this->lock();
if(is_null($index)) {
$index = $this->file->key();
}
else {
if(!(is_int($index) || ctype_digit($index))
|| $index < 0) {
throw new InvalidIndexException($index);
}
$index = (int)$index;
}
if($index <= $this->file->key() + 1) {
$this->file->rewind();
}
while($index >= $this->file->key()) {
$this->file->next();
}
if(!$this->file->valid()) {
$this->file->flock(LOCK_UN);
return false;
}
$data = $this->file->current();
$this->file->flock(LOCK_UN);
$row = $this->toAssociative($data);
return $row;
} | php | public function get($index = null, $fetchFields = []) {
$this->lock();
if(is_null($index)) {
$index = $this->file->key();
}
else {
if(!(is_int($index) || ctype_digit($index))
|| $index < 0) {
throw new InvalidIndexException($index);
}
$index = (int)$index;
}
if($index <= $this->file->key() + 1) {
$this->file->rewind();
}
while($index >= $this->file->key()) {
$this->file->next();
}
if(!$this->file->valid()) {
$this->file->flock(LOCK_UN);
return false;
}
$data = $this->file->current();
$this->file->flock(LOCK_UN);
$row = $this->toAssociative($data);
return $row;
} | [
"public",
"function",
"get",
"(",
"$",
"index",
"=",
"null",
",",
"$",
"fetchFields",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"lock",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"index",
")",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"file",
"->",
"key",
"(",
")",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"(",
"is_int",
"(",
"$",
"index",
")",
"||",
"ctype_digit",
"(",
"$",
"index",
")",
")",
"||",
"$",
"index",
"<",
"0",
")",
"{",
"throw",
"new",
"InvalidIndexException",
"(",
"$",
"index",
")",
";",
"}",
"$",
"index",
"=",
"(",
"int",
")",
"$",
"index",
";",
"}",
"if",
"(",
"$",
"index",
"<=",
"$",
"this",
"->",
"file",
"->",
"key",
"(",
")",
"+",
"1",
")",
"{",
"$",
"this",
"->",
"file",
"->",
"rewind",
"(",
")",
";",
"}",
"while",
"(",
"$",
"index",
">=",
"$",
"this",
"->",
"file",
"->",
"key",
"(",
")",
")",
"{",
"$",
"this",
"->",
"file",
"->",
"next",
"(",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"file",
"->",
"valid",
"(",
")",
")",
"{",
"$",
"this",
"->",
"file",
"->",
"flock",
"(",
"LOCK_UN",
")",
";",
"return",
"false",
";",
"}",
"$",
"data",
"=",
"$",
"this",
"->",
"file",
"->",
"current",
"(",
")",
";",
"$",
"this",
"->",
"file",
"->",
"flock",
"(",
"LOCK_UN",
")",
";",
"$",
"row",
"=",
"$",
"this",
"->",
"toAssociative",
"(",
"$",
"data",
")",
";",
"return",
"$",
"row",
";",
"}"
] | Returns the row at the given index, or the current file pointer position if
not supplied. Optionally supply the headers to retrieve, ignoring any others.
@param null|int $index Zero-based row number (0 is the first row after the
header row)
@param array $fetchFields NOT IMPLEMENTED List of fields to include in
resulting rows
@return array|bool Associative array of fields, or false if index is out
of bounds | [
"Returns",
"the",
"row",
"at",
"the",
"given",
"index",
"or",
"the",
"current",
"file",
"pointer",
"position",
"if",
"not",
"supplied",
".",
"Optionally",
"supply",
"the",
"headers",
"to",
"retrieve",
"ignoring",
"any",
"others",
"."
] | 07515f794c7fc4406dbfd3e87ce96ea5bc1483d5 | https://github.com/g105b/phpcsv/blob/07515f794c7fc4406dbfd3e87ce96ea5bc1483d5/src/Csv.php#L267-L299 |
9,823 | g105b/phpcsv | src/Csv.php | Csv.getAll | public function getAll() {
$this->file->rewind();
$data = [];
while(false !== $row = $this->get()) {
$data []= $row;
}
return $data;
} | php | public function getAll() {
$this->file->rewind();
$data = [];
while(false !== $row = $this->get()) {
$data []= $row;
}
return $data;
} | [
"public",
"function",
"getAll",
"(",
")",
"{",
"$",
"this",
"->",
"file",
"->",
"rewind",
"(",
")",
";",
"$",
"data",
"=",
"[",
"]",
";",
"while",
"(",
"false",
"!==",
"$",
"row",
"=",
"$",
"this",
"->",
"get",
"(",
")",
")",
"{",
"$",
"data",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"return",
"$",
"data",
";",
"}"
] | Returns an array of all rows.
@return array Indexed array, containing associative arrays of row data | [
"Returns",
"an",
"array",
"of",
"all",
"rows",
"."
] | 07515f794c7fc4406dbfd3e87ce96ea5bc1483d5 | https://github.com/g105b/phpcsv/blob/07515f794c7fc4406dbfd3e87ce96ea5bc1483d5/src/Csv.php#L306-L315 |
9,824 | g105b/phpcsv | src/Csv.php | Csv.getBy | public function getBy($fieldName, $fieldValue, $fetchFields = []) {
$result = $this->getAllBy($fieldName, $fieldValue, $fetchFields, 1);
if(isset($result[0])) {
return $result[0];
}
else {
return null;
}
} | php | public function getBy($fieldName, $fieldValue, $fetchFields = []) {
$result = $this->getAllBy($fieldName, $fieldValue, $fetchFields, 1);
if(isset($result[0])) {
return $result[0];
}
else {
return null;
}
} | [
"public",
"function",
"getBy",
"(",
"$",
"fieldName",
",",
"$",
"fieldValue",
",",
"$",
"fetchFields",
"=",
"[",
"]",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getAllBy",
"(",
"$",
"fieldName",
",",
"$",
"fieldValue",
",",
"$",
"fetchFields",
",",
"1",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"result",
"[",
"0",
"]",
")",
")",
"{",
"return",
"$",
"result",
"[",
"0",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Returns the first element in the matching rows, without iterating over the
whole data.
@param string $fieldName Name of field to match on
@param string $fieldValue Value of field to match
@param string $fetchFields NOT IMPLEMENTED List of fields to include
@return array|null Associative array of first matching row, or null if no
match found | [
"Returns",
"the",
"first",
"element",
"in",
"the",
"matching",
"rows",
"without",
"iterating",
"over",
"the",
"whole",
"data",
"."
] | 07515f794c7fc4406dbfd3e87ce96ea5bc1483d5 | https://github.com/g105b/phpcsv/blob/07515f794c7fc4406dbfd3e87ce96ea5bc1483d5/src/Csv.php#L359-L367 |
9,825 | g105b/phpcsv | src/Csv.php | Csv.getIdField | public function getIdField() {
if(!empty($this->headers)
&& !in_array($this->idField, $this->headers)) {
throw new InvalidFieldException($this->idField);
}
return $this->idField;
} | php | public function getIdField() {
if(!empty($this->headers)
&& !in_array($this->idField, $this->headers)) {
throw new InvalidFieldException($this->idField);
}
return $this->idField;
} | [
"public",
"function",
"getIdField",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"headers",
")",
"&&",
"!",
"in_array",
"(",
"$",
"this",
"->",
"idField",
",",
"$",
"this",
"->",
"headers",
")",
")",
"{",
"throw",
"new",
"InvalidFieldException",
"(",
"$",
"this",
"->",
"idField",
")",
";",
"}",
"return",
"$",
"this",
"->",
"idField",
";",
"}"
] | Retrieves the internally set field used for ID. By default, this is "ID",
but if there is no field with that name then this function returns null.
@return string|null Name of field, or null if the default field does not
exist in the CSV | [
"Retrieves",
"the",
"internally",
"set",
"field",
"used",
"for",
"ID",
".",
"By",
"default",
"this",
"is",
"ID",
"but",
"if",
"there",
"is",
"no",
"field",
"with",
"that",
"name",
"then",
"this",
"function",
"returns",
"null",
"."
] | 07515f794c7fc4406dbfd3e87ce96ea5bc1483d5 | https://github.com/g105b/phpcsv/blob/07515f794c7fc4406dbfd3e87ce96ea5bc1483d5/src/Csv.php#L388-L395 |
9,826 | g105b/phpcsv | src/Csv.php | Csv.add | public function add($row) {
$this->changesMade = true;
$rowColumns = $row;
$rowAssociative = $row;
$this->lock();
if($this->isAssoc($row)) {
if(!$this->headers) {
$this->headers = array_keys($row);
$this->file->fputcsv($this->headers);
}
$rowColumns = $this->toIndexed($row, true);
}
else {
$rowAssociative = $this->toAssociative($row);
}
if(!$this->headers) {
throw new HeadersNotSetException();
}
$rowColumns = $this->fillMissing($rowColumns);
$this->file->fseek(0, SEEK_END);
$this->file->fputcsv($rowColumns);
$this->file->fflush();
$this->file->flock(LOCK_UN);
return $rowAssociative;
} | php | public function add($row) {
$this->changesMade = true;
$rowColumns = $row;
$rowAssociative = $row;
$this->lock();
if($this->isAssoc($row)) {
if(!$this->headers) {
$this->headers = array_keys($row);
$this->file->fputcsv($this->headers);
}
$rowColumns = $this->toIndexed($row, true);
}
else {
$rowAssociative = $this->toAssociative($row);
}
if(!$this->headers) {
throw new HeadersNotSetException();
}
$rowColumns = $this->fillMissing($rowColumns);
$this->file->fseek(0, SEEK_END);
$this->file->fputcsv($rowColumns);
$this->file->fflush();
$this->file->flock(LOCK_UN);
return $rowAssociative;
} | [
"public",
"function",
"add",
"(",
"$",
"row",
")",
"{",
"$",
"this",
"->",
"changesMade",
"=",
"true",
";",
"$",
"rowColumns",
"=",
"$",
"row",
";",
"$",
"rowAssociative",
"=",
"$",
"row",
";",
"$",
"this",
"->",
"lock",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"isAssoc",
"(",
"$",
"row",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"headers",
")",
"{",
"$",
"this",
"->",
"headers",
"=",
"array_keys",
"(",
"$",
"row",
")",
";",
"$",
"this",
"->",
"file",
"->",
"fputcsv",
"(",
"$",
"this",
"->",
"headers",
")",
";",
"}",
"$",
"rowColumns",
"=",
"$",
"this",
"->",
"toIndexed",
"(",
"$",
"row",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"rowAssociative",
"=",
"$",
"this",
"->",
"toAssociative",
"(",
"$",
"row",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"headers",
")",
"{",
"throw",
"new",
"HeadersNotSetException",
"(",
")",
";",
"}",
"$",
"rowColumns",
"=",
"$",
"this",
"->",
"fillMissing",
"(",
"$",
"rowColumns",
")",
";",
"$",
"this",
"->",
"file",
"->",
"fseek",
"(",
"0",
",",
"SEEK_END",
")",
";",
"$",
"this",
"->",
"file",
"->",
"fputcsv",
"(",
"$",
"rowColumns",
")",
";",
"$",
"this",
"->",
"file",
"->",
"fflush",
"(",
")",
";",
"$",
"this",
"->",
"file",
"->",
"flock",
"(",
"LOCK_UN",
")",
";",
"return",
"$",
"rowAssociative",
";",
"}"
] | Adds a single row to the CSV file, the values according to associative
array keys matching the currently stored headers. If there are no headers
stored, the headers will take the form of the current associative array's
keys, in the order they exist in the array.
@param array $row Associative array containing key-value pairs. Alternatively
an indexed array can be passed in, which will be converted into an
associative array from the stored headers
@return array Returns the added row in associative form | [
"Adds",
"a",
"single",
"row",
"to",
"the",
"CSV",
"file",
"the",
"values",
"according",
"to",
"associative",
"array",
"keys",
"matching",
"the",
"currently",
"stored",
"headers",
".",
"If",
"there",
"are",
"no",
"headers",
"stored",
"the",
"headers",
"will",
"take",
"the",
"form",
"of",
"the",
"current",
"associative",
"array",
"s",
"keys",
"in",
"the",
"order",
"they",
"exist",
"in",
"the",
"array",
"."
] | 07515f794c7fc4406dbfd3e87ce96ea5bc1483d5 | https://github.com/g105b/phpcsv/blob/07515f794c7fc4406dbfd3e87ce96ea5bc1483d5/src/Csv.php#L423-L453 |
9,827 | g105b/phpcsv | src/Csv.php | Csv.isAssoc | private function isAssoc($array) {
$allIntegerKeys = true;
foreach ($array as $key => $value) {
if(!is_integer($key)) {
$allIntegerKeys = false;
break;
}
}
return $allIntegerKeys === false;
} | php | private function isAssoc($array) {
$allIntegerKeys = true;
foreach ($array as $key => $value) {
if(!is_integer($key)) {
$allIntegerKeys = false;
break;
}
}
return $allIntegerKeys === false;
} | [
"private",
"function",
"isAssoc",
"(",
"$",
"array",
")",
"{",
"$",
"allIntegerKeys",
"=",
"true",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"key",
")",
")",
"{",
"$",
"allIntegerKeys",
"=",
"false",
";",
"break",
";",
"}",
"}",
"return",
"$",
"allIntegerKeys",
"===",
"false",
";",
"}"
] | Checks whether a given array is associative or indexed.
@param array $array The input array to check
@return bool True if input array is associative, false if the input array is
indexed | [
"Checks",
"whether",
"a",
"given",
"array",
"is",
"associative",
"or",
"indexed",
"."
] | 07515f794c7fc4406dbfd3e87ce96ea5bc1483d5 | https://github.com/g105b/phpcsv/blob/07515f794c7fc4406dbfd3e87ce96ea5bc1483d5/src/Csv.php#L463-L473 |
9,828 | subcosm/observatory | src/ObserverQueue.php | ObserverQueue.attach | public function attach(ObserverInterface $observer): void
{
$key = spl_object_hash($observer);
if ( array_key_exists($key, $this->observers) ) {
throw new ObservatoryException(
'Provided observer already known, hash: '.$key
);
}
$this->observers[$key] = $observer;
} | php | public function attach(ObserverInterface $observer): void
{
$key = spl_object_hash($observer);
if ( array_key_exists($key, $this->observers) ) {
throw new ObservatoryException(
'Provided observer already known, hash: '.$key
);
}
$this->observers[$key] = $observer;
} | [
"public",
"function",
"attach",
"(",
"ObserverInterface",
"$",
"observer",
")",
":",
"void",
"{",
"$",
"key",
"=",
"spl_object_hash",
"(",
"$",
"observer",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"this",
"->",
"observers",
")",
")",
"{",
"throw",
"new",
"ObservatoryException",
"(",
"'Provided observer already known, hash: '",
".",
"$",
"key",
")",
";",
"}",
"$",
"this",
"->",
"observers",
"[",
"$",
"key",
"]",
"=",
"$",
"observer",
";",
"}"
] | attaches an observer to the observable.
@param ObserverInterface $observer
@throws ObservatoryException when the provided observer is already known
@return void | [
"attaches",
"an",
"observer",
"to",
"the",
"observable",
"."
] | 7c8c4eb0193fff9a2f40c33b2d3eb344314852e9 | https://github.com/subcosm/observatory/blob/7c8c4eb0193fff9a2f40c33b2d3eb344314852e9/src/ObserverQueue.php#L30-L41 |
9,829 | subcosm/observatory | src/ObserverQueue.php | ObserverQueue.detach | public function detach(ObserverInterface $observer): void
{
$key = spl_object_hash($observer);
unset($this->observers[$key]);
} | php | public function detach(ObserverInterface $observer): void
{
$key = spl_object_hash($observer);
unset($this->observers[$key]);
} | [
"public",
"function",
"detach",
"(",
"ObserverInterface",
"$",
"observer",
")",
":",
"void",
"{",
"$",
"key",
"=",
"spl_object_hash",
"(",
"$",
"observer",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"observers",
"[",
"$",
"key",
"]",
")",
";",
"}"
] | detaches an observer from the observable.
@param ObserverInterface $observer
@return void | [
"detaches",
"an",
"observer",
"from",
"the",
"observable",
"."
] | 7c8c4eb0193fff9a2f40c33b2d3eb344314852e9 | https://github.com/subcosm/observatory/blob/7c8c4eb0193fff9a2f40c33b2d3eb344314852e9/src/ObserverQueue.php#L49-L54 |
9,830 | phossa2/libs | src/Phossa2/Route/Dispatcher.php | Dispatcher.isDispatched | protected function isDispatched()/*# : bool */
{
$param = ['result' => $this->result];
if ($this->trigger(self::EVENT_BEFORE_DISPATCH, $param) &&
$this->executeHandler() &&
$this->trigger(self::EVENT_AFTER_DISPATCH, $param)
) {
return true;
}
return false;
} | php | protected function isDispatched()/*# : bool */
{
$param = ['result' => $this->result];
if ($this->trigger(self::EVENT_BEFORE_DISPATCH, $param) &&
$this->executeHandler() &&
$this->trigger(self::EVENT_AFTER_DISPATCH, $param)
) {
return true;
}
return false;
} | [
"protected",
"function",
"isDispatched",
"(",
")",
"/*# : bool */",
"{",
"$",
"param",
"=",
"[",
"'result'",
"=>",
"$",
"this",
"->",
"result",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_BEFORE_DISPATCH",
",",
"$",
"param",
")",
"&&",
"$",
"this",
"->",
"executeHandler",
"(",
")",
"&&",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_AFTER_DISPATCH",
",",
"$",
"param",
")",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] | Real dispatching process
@return bool
@access protected | [
"Real",
"dispatching",
"process"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Route/Dispatcher.php#L211-L221 |
9,831 | phossa2/libs | src/Phossa2/Route/Dispatcher.php | Dispatcher.executeHandler | protected function executeHandler()/*# : bool */
{
try {
$handler = $this->result->getHandler();
$callable = $this->getResolver()->resolve($handler);
if ($this->result->getRoute()) {
return $this->callableWithRoute($callable);
} else {
call_user_func($callable, $this->result);
return true;
}
} catch (\Exception $e) {
$this->result->setHandler(null);
return false;
}
} | php | protected function executeHandler()/*# : bool */
{
try {
$handler = $this->result->getHandler();
$callable = $this->getResolver()->resolve($handler);
if ($this->result->getRoute()) {
return $this->callableWithRoute($callable);
} else {
call_user_func($callable, $this->result);
return true;
}
} catch (\Exception $e) {
$this->result->setHandler(null);
return false;
}
} | [
"protected",
"function",
"executeHandler",
"(",
")",
"/*# : bool */",
"{",
"try",
"{",
"$",
"handler",
"=",
"$",
"this",
"->",
"result",
"->",
"getHandler",
"(",
")",
";",
"$",
"callable",
"=",
"$",
"this",
"->",
"getResolver",
"(",
")",
"->",
"resolve",
"(",
"$",
"handler",
")",
";",
"if",
"(",
"$",
"this",
"->",
"result",
"->",
"getRoute",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"callableWithRoute",
"(",
"$",
"callable",
")",
";",
"}",
"else",
"{",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"this",
"->",
"result",
")",
";",
"return",
"true",
";",
"}",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"result",
"->",
"setHandler",
"(",
"null",
")",
";",
"return",
"false",
";",
"}",
"}"
] | Execute handler of the result
IF HANDLER NOT EXECUTED, REMOVE IT !!
@return bool true if handler executed
@access protected | [
"Execute",
"handler",
"of",
"the",
"result"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Route/Dispatcher.php#L231-L247 |
9,832 | phossa2/libs | src/Phossa2/Route/Dispatcher.php | Dispatcher.callableWithRoute | protected function callableWithRoute(callable $callable)/*# : bool */
{
/* @var EventCapableAbstract $route */
$route = $this->result->getRoute();
$param = ['result' => $this->result];
if ($route->trigger(Route::EVENT_BEFORE_HANDLER, $param)) {
call_user_func($callable, $this->result);
$route->trigger(Route::EVENT_AFTER_HANDLER, $param);
return true;
}
$this->result->setHandler(null);
return false;
} | php | protected function callableWithRoute(callable $callable)/*# : bool */
{
/* @var EventCapableAbstract $route */
$route = $this->result->getRoute();
$param = ['result' => $this->result];
if ($route->trigger(Route::EVENT_BEFORE_HANDLER, $param)) {
call_user_func($callable, $this->result);
$route->trigger(Route::EVENT_AFTER_HANDLER, $param);
return true;
}
$this->result->setHandler(null);
return false;
} | [
"protected",
"function",
"callableWithRoute",
"(",
"callable",
"$",
"callable",
")",
"/*# : bool */",
"{",
"/* @var EventCapableAbstract $route */",
"$",
"route",
"=",
"$",
"this",
"->",
"result",
"->",
"getRoute",
"(",
")",
";",
"$",
"param",
"=",
"[",
"'result'",
"=>",
"$",
"this",
"->",
"result",
"]",
";",
"if",
"(",
"$",
"route",
"->",
"trigger",
"(",
"Route",
"::",
"EVENT_BEFORE_HANDLER",
",",
"$",
"param",
")",
")",
"{",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"this",
"->",
"result",
")",
";",
"$",
"route",
"->",
"trigger",
"(",
"Route",
"::",
"EVENT_AFTER_HANDLER",
",",
"$",
"param",
")",
";",
"return",
"true",
";",
"}",
"$",
"this",
"->",
"result",
"->",
"setHandler",
"(",
"null",
")",
";",
"return",
"false",
";",
"}"
] | Execute the callable with route events
IF HANDLER NOT EXECUTED, REMOVE IT !!
@param callable $callable
@return bool true if callable executed
@access protected | [
"Execute",
"the",
"callable",
"with",
"route",
"events"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Route/Dispatcher.php#L258-L270 |
9,833 | phossa2/libs | src/Phossa2/Route/Dispatcher.php | Dispatcher.defaultHandler | protected function defaultHandler()/*# : bool */
{
$status = $this->result->getStatus();
$handler = $this->result->getHandler() ?: $this->getHandler($status);
if ($handler) {
$param = ['result' => $this->result];
$callable = $this->getResolver()->resolve($handler);
if ($this->trigger(self::EVENT_BEFORE_HANDLER, $param)) {
call_user_func($callable, $this->result);
$this->trigger(self::EVENT_AFTER_HANDLER, $param);
}
}
return false;
} | php | protected function defaultHandler()/*# : bool */
{
$status = $this->result->getStatus();
$handler = $this->result->getHandler() ?: $this->getHandler($status);
if ($handler) {
$param = ['result' => $this->result];
$callable = $this->getResolver()->resolve($handler);
if ($this->trigger(self::EVENT_BEFORE_HANDLER, $param)) {
call_user_func($callable, $this->result);
$this->trigger(self::EVENT_AFTER_HANDLER, $param);
}
}
return false;
} | [
"protected",
"function",
"defaultHandler",
"(",
")",
"/*# : bool */",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"result",
"->",
"getStatus",
"(",
")",
";",
"$",
"handler",
"=",
"$",
"this",
"->",
"result",
"->",
"getHandler",
"(",
")",
"?",
":",
"$",
"this",
"->",
"getHandler",
"(",
"$",
"status",
")",
";",
"if",
"(",
"$",
"handler",
")",
"{",
"$",
"param",
"=",
"[",
"'result'",
"=>",
"$",
"this",
"->",
"result",
"]",
";",
"$",
"callable",
"=",
"$",
"this",
"->",
"getResolver",
"(",
")",
"->",
"resolve",
"(",
"$",
"handler",
")",
";",
"if",
"(",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_BEFORE_HANDLER",
",",
"$",
"param",
")",
")",
"{",
"call_user_func",
"(",
"$",
"callable",
",",
"$",
"this",
"->",
"result",
")",
";",
"$",
"this",
"->",
"trigger",
"(",
"self",
"::",
"EVENT_AFTER_HANDLER",
",",
"$",
"param",
")",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Execute dispatcher level handler
@return bool
@access protected | [
"Execute",
"dispatcher",
"level",
"handler"
] | 921e485c8cc29067f279da2cdd06f47a9bddd115 | https://github.com/phossa2/libs/blob/921e485c8cc29067f279da2cdd06f47a9bddd115/src/Phossa2/Route/Dispatcher.php#L278-L292 |
9,834 | titon/model | src/Titon/Model/Relation/ManyToOne.php | ManyToOne.link | public function link(Model $model) {
$this->getLinked()->flush()->append($model);
$this->getPrimaryModel()->set($this->getPrimaryForeignKey(), $model->id());
return $this;
} | php | public function link(Model $model) {
$this->getLinked()->flush()->append($model);
$this->getPrimaryModel()->set($this->getPrimaryForeignKey(), $model->id());
return $this;
} | [
"public",
"function",
"link",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"this",
"->",
"getLinked",
"(",
")",
"->",
"flush",
"(",
")",
"->",
"append",
"(",
"$",
"model",
")",
";",
"$",
"this",
"->",
"getPrimaryModel",
"(",
")",
"->",
"set",
"(",
"$",
"this",
"->",
"getPrimaryForeignKey",
"(",
")",
",",
"$",
"model",
"->",
"id",
"(",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Only one record at a time can be linked in a belongs to relation.
Also include the ID from the foreign model as an attribute on the primary model.
@param \Titon\Model\Model $model
@return $this | [
"Only",
"one",
"record",
"at",
"a",
"time",
"can",
"be",
"linked",
"in",
"a",
"belongs",
"to",
"relation",
".",
"Also",
"include",
"the",
"ID",
"from",
"the",
"foreign",
"model",
"as",
"an",
"attribute",
"on",
"the",
"primary",
"model",
"."
] | 274e3810c2cfbb6818a388daaa462ff05de99cbd | https://github.com/titon/model/blob/274e3810c2cfbb6818a388daaa462ff05de99cbd/src/Titon/Model/Relation/ManyToOne.php#L75-L81 |
9,835 | titon/model | src/Titon/Model/Relation/ManyToOne.php | ManyToOne.unlink | public function unlink(Model $model) {
$this->getUnlinked()->flush()->append($model);
$this->getPrimaryModel()->set($this->getPrimaryForeignKey(), null);
return $this;
} | php | public function unlink(Model $model) {
$this->getUnlinked()->flush()->append($model);
$this->getPrimaryModel()->set($this->getPrimaryForeignKey(), null);
return $this;
} | [
"public",
"function",
"unlink",
"(",
"Model",
"$",
"model",
")",
"{",
"$",
"this",
"->",
"getUnlinked",
"(",
")",
"->",
"flush",
"(",
")",
"->",
"append",
"(",
"$",
"model",
")",
";",
"$",
"this",
"->",
"getPrimaryModel",
"(",
")",
"->",
"set",
"(",
"$",
"this",
"->",
"getPrimaryForeignKey",
"(",
")",
",",
"null",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Only one record at a time can be unlinked in a belongs to relation.
Also reset the foreign key attribute in the primary model.
@param \Titon\Model\Model $model
@return $this | [
"Only",
"one",
"record",
"at",
"a",
"time",
"can",
"be",
"unlinked",
"in",
"a",
"belongs",
"to",
"relation",
".",
"Also",
"reset",
"the",
"foreign",
"key",
"attribute",
"in",
"the",
"primary",
"model",
"."
] | 274e3810c2cfbb6818a388daaa462ff05de99cbd | https://github.com/titon/model/blob/274e3810c2cfbb6818a388daaa462ff05de99cbd/src/Titon/Model/Relation/ManyToOne.php#L140-L146 |
9,836 | PSESD/cascade-core-types | TypeTask/models/ObjectTask.php | ObjectTask.setCompletedStatus | public function setCompletedStatus($value)
{
if (empty($value)) {
$this->completed = null;
} elseif (empty($this->completed)) {
$this->completed = DateHelper::date($this->dbDateFormat . " " . $this->dbTimeFormat, time());
}
} | php | public function setCompletedStatus($value)
{
if (empty($value)) {
$this->completed = null;
} elseif (empty($this->completed)) {
$this->completed = DateHelper::date($this->dbDateFormat . " " . $this->dbTimeFormat, time());
}
} | [
"public",
"function",
"setCompletedStatus",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"completed",
"=",
"null",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"this",
"->",
"completed",
")",
")",
"{",
"$",
"this",
"->",
"completed",
"=",
"DateHelper",
"::",
"date",
"(",
"$",
"this",
"->",
"dbDateFormat",
".",
"\" \"",
".",
"$",
"this",
"->",
"dbTimeFormat",
",",
"time",
"(",
")",
")",
";",
"}",
"}"
] | Set completed status.
@param [[@doctodo param_type:value]] $value [[@doctodo param_description:value]] | [
"Set",
"completed",
"status",
"."
] | 5a2bc524bd89545f0f28230e34518c9f92e7db1f | https://github.com/PSESD/cascade-core-types/blob/5a2bc524bd89545f0f28230e34518c9f92e7db1f/TypeTask/models/ObjectTask.php#L169-L176 |
9,837 | oschildt/SmartFactory | src/SmartFactory/FactoryBuilder.php | FactoryBuilder.bindClass | static public function bindClass($interface_or_class, $class, $init_function = null)
{
if (empty($class)) {
throw new \Exception("Bound class is empty!");
}
if (empty($interface_or_class)) {
throw new \Exception("Bound interface or class is empty!");
}
if (!interface_exists($interface_or_class) && !class_exists($interface_or_class)) {
throw new \Exception(sprintf("The interface or class '%s' does not exist!", $interface_or_class));
}
if (!class_exists($class)) {
throw new \Exception(sprintf("The class '%s' does not exist!", $class));
}
try {
$ic = new \ReflectionClass($interface_or_class);
$c = new \ReflectionClass($class);
} catch (\Exception $ex) {
throw new \Exception($ex->getMessage());
}
if (!$c->isInstantiable()) {
throw new \Exception(sprintf("The class '%s' is not instantiable!", $c->getName()));
}
if ($c != $ic) {
if (!$c->isSubclassOf($ic)) {
throw new \Exception(sprintf("The class '%s' does not implement the interface '%s'!", $c->getName(), $ic->getName()));
}
}
$f = null;
if ($init_function !== null) {
if (!is_callable($init_function)) {
throw new \Exception(sprintf("'%s' is not a function!", $init_function));
}
try {
$f = new \ReflectionFunction($init_function);
} catch (\Exception $ex) {
throw new \Exception($ex->getMessage());
}
}
self::$itable[$ic->getName()] = ["class" => $c, "init_function" => $f];
} | php | static public function bindClass($interface_or_class, $class, $init_function = null)
{
if (empty($class)) {
throw new \Exception("Bound class is empty!");
}
if (empty($interface_or_class)) {
throw new \Exception("Bound interface or class is empty!");
}
if (!interface_exists($interface_or_class) && !class_exists($interface_or_class)) {
throw new \Exception(sprintf("The interface or class '%s' does not exist!", $interface_or_class));
}
if (!class_exists($class)) {
throw new \Exception(sprintf("The class '%s' does not exist!", $class));
}
try {
$ic = new \ReflectionClass($interface_or_class);
$c = new \ReflectionClass($class);
} catch (\Exception $ex) {
throw new \Exception($ex->getMessage());
}
if (!$c->isInstantiable()) {
throw new \Exception(sprintf("The class '%s' is not instantiable!", $c->getName()));
}
if ($c != $ic) {
if (!$c->isSubclassOf($ic)) {
throw new \Exception(sprintf("The class '%s' does not implement the interface '%s'!", $c->getName(), $ic->getName()));
}
}
$f = null;
if ($init_function !== null) {
if (!is_callable($init_function)) {
throw new \Exception(sprintf("'%s' is not a function!", $init_function));
}
try {
$f = new \ReflectionFunction($init_function);
} catch (\Exception $ex) {
throw new \Exception($ex->getMessage());
}
}
self::$itable[$ic->getName()] = ["class" => $c, "init_function" => $f];
} | [
"static",
"public",
"function",
"bindClass",
"(",
"$",
"interface_or_class",
",",
"$",
"class",
",",
"$",
"init_function",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Bound class is empty!\"",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"interface_or_class",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Bound interface or class is empty!\"",
")",
";",
"}",
"if",
"(",
"!",
"interface_exists",
"(",
"$",
"interface_or_class",
")",
"&&",
"!",
"class_exists",
"(",
"$",
"interface_or_class",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"The interface or class '%s' does not exist!\"",
",",
"$",
"interface_or_class",
")",
")",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"The class '%s' does not exist!\"",
",",
"$",
"class",
")",
")",
";",
"}",
"try",
"{",
"$",
"ic",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"interface_or_class",
")",
";",
"$",
"c",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"class",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"c",
"->",
"isInstantiable",
"(",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"The class '%s' is not instantiable!\"",
",",
"$",
"c",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"c",
"!=",
"$",
"ic",
")",
"{",
"if",
"(",
"!",
"$",
"c",
"->",
"isSubclassOf",
"(",
"$",
"ic",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"The class '%s' does not implement the interface '%s'!\"",
",",
"$",
"c",
"->",
"getName",
"(",
")",
",",
"$",
"ic",
"->",
"getName",
"(",
")",
")",
")",
";",
"}",
"}",
"$",
"f",
"=",
"null",
";",
"if",
"(",
"$",
"init_function",
"!==",
"null",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"init_function",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"sprintf",
"(",
"\"'%s' is not a function!\"",
",",
"$",
"init_function",
")",
")",
";",
"}",
"try",
"{",
"$",
"f",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"init_function",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"ex",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"ex",
"->",
"getMessage",
"(",
")",
")",
";",
"}",
"}",
"self",
"::",
"$",
"itable",
"[",
"$",
"ic",
"->",
"getName",
"(",
")",
"]",
"=",
"[",
"\"class\"",
"=>",
"$",
"c",
",",
"\"init_function\"",
"=>",
"$",
"f",
"]",
";",
"}"
] | Binds a class to an interface or a parent class.
The key point of this approach is the definition common interfaces
and implementation of them in classes. When an object that supoorts an
interface is requested, an instance of the corresponding bound class
is created. When you want to change the class, you need just bind
the new class to the interface.
You can also bind a class to itself and reqest it by own name in factory
method. And later, you can implement a derived class and change the binding
without affecting the code in the business logic.
@param string|object $interface_or_class
Name of the class/interface as string or the class/interface.
@param string|object $class
The class which instance should be created if the object is requested.
@param callable $init_function
The optional initialization function. You can provide it to do some
custom intialization. The signature of
this function is:
```php
function (object $instance) : void;
```
- $instance - the created instance.
Example:
```php
FactoryBuilder::bindClass(ILanguageManager::class, LanguageManager::class, function($instance) {
$instance->detectLanguage();
});
FactoryBuilder::bindClass(IRecordsetManager::class, RecordsetManager::class, function($instance) {
$instance->setDBWorker(dbworker());
});
```
@return void
@throws \Exception
It might throw the following exceptions in the case of any errors:
- if the interface or bound class is not specified.
- if the interface or class does not exist.
- if the bound class is empty.
- if the bound class does not implement the corresponding interface.
- if the bound class is not instantiable.
- if the check of the classes and interfaces fails.
@author Oleg Schildt | [
"Binds",
"a",
"class",
"to",
"an",
"interface",
"or",
"a",
"parent",
"class",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/FactoryBuilder.php#L97-L146 |
9,838 | marando/phpSOFA | src/Marando/IAU/iauBp00.php | iauBp00.Bp00 | public static function Bp00($date1, $date2, array &$rb, array &$rp,
array &$rbp) {
/* J2000.0 obliquity (Lieske et al. 1977) */
$EPS0 = 84381.448 * DAS2R;
$t;
$dpsibi;
$depsbi;
$dra0;
$psia77;
$oma77;
$chia;
$dpsipr;
$depspr;
$psia;
$oma;
$rbw = [];
/* Interval between fundamental epoch J2000.0 and current date (JC). */
$t = (($date1 - DJ00) + $date2) / DJC;
/* Frame bias. */
IAU::Bi00($dpsibi, $depsbi, $dra0);
/* Precession angles (Lieske et al. 1977) */
$psia77 = (5038.7784 + (-1.07259 + (-0.001147) * $t) * $t) * $t * DAS2R;
$oma77 = $EPS0 + ((0.05127 + (-0.007726) * $t) * $t) * $t * DAS2R;
$chia = ( 10.5526 + (-2.38064 + (-0.001125) * $t) * $t) * $t * DAS2R;
/* Apply IAU 2000 precession corrections. */
IAU::Pr00($date1, $date2, $dpsipr, $depspr);
$psia = $psia77 + $dpsipr;
$oma = $oma77 + $depspr;
/* Frame bias matrix: GCRS to J2000.0. */
IAU::Ir($rbw);
IAU::Rz($dra0, $rbw);
IAU::Ry($dpsibi * sin($EPS0), $rbw);
IAU::Rx(-$depsbi, $rbw);
IAU::Cr($rbw, $rb);
/* Precession matrix: J2000.0 to mean of date. */
IAU::Ir($rp);
IAU::Rx($EPS0, $rp);
IAU::Rz(-$psia, $rp);
IAU::Rx(-$oma, $rp);
IAU::Rz($chia, $rp);
/* Bias-precession matrix: GCRS to mean of date. */
IAU::Rxr($rp, $rbw, $rbp);
return;
} | php | public static function Bp00($date1, $date2, array &$rb, array &$rp,
array &$rbp) {
/* J2000.0 obliquity (Lieske et al. 1977) */
$EPS0 = 84381.448 * DAS2R;
$t;
$dpsibi;
$depsbi;
$dra0;
$psia77;
$oma77;
$chia;
$dpsipr;
$depspr;
$psia;
$oma;
$rbw = [];
/* Interval between fundamental epoch J2000.0 and current date (JC). */
$t = (($date1 - DJ00) + $date2) / DJC;
/* Frame bias. */
IAU::Bi00($dpsibi, $depsbi, $dra0);
/* Precession angles (Lieske et al. 1977) */
$psia77 = (5038.7784 + (-1.07259 + (-0.001147) * $t) * $t) * $t * DAS2R;
$oma77 = $EPS0 + ((0.05127 + (-0.007726) * $t) * $t) * $t * DAS2R;
$chia = ( 10.5526 + (-2.38064 + (-0.001125) * $t) * $t) * $t * DAS2R;
/* Apply IAU 2000 precession corrections. */
IAU::Pr00($date1, $date2, $dpsipr, $depspr);
$psia = $psia77 + $dpsipr;
$oma = $oma77 + $depspr;
/* Frame bias matrix: GCRS to J2000.0. */
IAU::Ir($rbw);
IAU::Rz($dra0, $rbw);
IAU::Ry($dpsibi * sin($EPS0), $rbw);
IAU::Rx(-$depsbi, $rbw);
IAU::Cr($rbw, $rb);
/* Precession matrix: J2000.0 to mean of date. */
IAU::Ir($rp);
IAU::Rx($EPS0, $rp);
IAU::Rz(-$psia, $rp);
IAU::Rx(-$oma, $rp);
IAU::Rz($chia, $rp);
/* Bias-precession matrix: GCRS to mean of date. */
IAU::Rxr($rp, $rbw, $rbp);
return;
} | [
"public",
"static",
"function",
"Bp00",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"array",
"&",
"$",
"rb",
",",
"array",
"&",
"$",
"rp",
",",
"array",
"&",
"$",
"rbp",
")",
"{",
"/* J2000.0 obliquity (Lieske et al. 1977) */",
"$",
"EPS0",
"=",
"84381.448",
"*",
"DAS2R",
";",
"$",
"t",
";",
"$",
"dpsibi",
";",
"$",
"depsbi",
";",
"$",
"dra0",
";",
"$",
"psia77",
";",
"$",
"oma77",
";",
"$",
"chia",
";",
"$",
"dpsipr",
";",
"$",
"depspr",
";",
"$",
"psia",
";",
"$",
"oma",
";",
"$",
"rbw",
"=",
"[",
"]",
";",
"/* Interval between fundamental epoch J2000.0 and current date (JC). */",
"$",
"t",
"=",
"(",
"(",
"$",
"date1",
"-",
"DJ00",
")",
"+",
"$",
"date2",
")",
"/",
"DJC",
";",
"/* Frame bias. */",
"IAU",
"::",
"Bi00",
"(",
"$",
"dpsibi",
",",
"$",
"depsbi",
",",
"$",
"dra0",
")",
";",
"/* Precession angles (Lieske et al. 1977) */",
"$",
"psia77",
"=",
"(",
"5038.7784",
"+",
"(",
"-",
"1.07259",
"+",
"(",
"-",
"0.001147",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
"*",
"DAS2R",
";",
"$",
"oma77",
"=",
"$",
"EPS0",
"+",
"(",
"(",
"0.05127",
"+",
"(",
"-",
"0.007726",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
"*",
"DAS2R",
";",
"$",
"chia",
"=",
"(",
"10.5526",
"+",
"(",
"-",
"2.38064",
"+",
"(",
"-",
"0.001125",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
")",
"*",
"$",
"t",
"*",
"DAS2R",
";",
"/* Apply IAU 2000 precession corrections. */",
"IAU",
"::",
"Pr00",
"(",
"$",
"date1",
",",
"$",
"date2",
",",
"$",
"dpsipr",
",",
"$",
"depspr",
")",
";",
"$",
"psia",
"=",
"$",
"psia77",
"+",
"$",
"dpsipr",
";",
"$",
"oma",
"=",
"$",
"oma77",
"+",
"$",
"depspr",
";",
"/* Frame bias matrix: GCRS to J2000.0. */",
"IAU",
"::",
"Ir",
"(",
"$",
"rbw",
")",
";",
"IAU",
"::",
"Rz",
"(",
"$",
"dra0",
",",
"$",
"rbw",
")",
";",
"IAU",
"::",
"Ry",
"(",
"$",
"dpsibi",
"*",
"sin",
"(",
"$",
"EPS0",
")",
",",
"$",
"rbw",
")",
";",
"IAU",
"::",
"Rx",
"(",
"-",
"$",
"depsbi",
",",
"$",
"rbw",
")",
";",
"IAU",
"::",
"Cr",
"(",
"$",
"rbw",
",",
"$",
"rb",
")",
";",
"/* Precession matrix: J2000.0 to mean of date. */",
"IAU",
"::",
"Ir",
"(",
"$",
"rp",
")",
";",
"IAU",
"::",
"Rx",
"(",
"$",
"EPS0",
",",
"$",
"rp",
")",
";",
"IAU",
"::",
"Rz",
"(",
"-",
"$",
"psia",
",",
"$",
"rp",
")",
";",
"IAU",
"::",
"Rx",
"(",
"-",
"$",
"oma",
",",
"$",
"rp",
")",
";",
"IAU",
"::",
"Rz",
"(",
"$",
"chia",
",",
"$",
"rp",
")",
";",
"/* Bias-precession matrix: GCRS to mean of date. */",
"IAU",
"::",
"Rxr",
"(",
"$",
"rp",
",",
"$",
"rbw",
",",
"$",
"rbp",
")",
";",
"return",
";",
"}"
] | - - - - - - - -
i a u B p 0 0
- - - - - - - -
Frame bias and precession, IAU 2000.
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: canonical model.
Given:
date1,date2 double TT as a 2-part Julian Date (Note 1)
Returned:
rb double[3][3] frame bias matrix (Note 2)
rp double[3][3] precession matrix (Note 3)
rbp double[3][3] bias-precession matrix (Note 4)
Notes:
1) The TT date date1+date2 is a Julian Date, apportioned in any
convenient way between the two arguments. For example,
JD(TT)=2450123.7 could be expressed in any of these ways,
among others:
date1 date2
2450123.7 0.0 (JD method)
2451545.0 -1421.3 (J2000 method)
2400000.5 50123.2 (MJD method)
2450123.5 0.2 (date & time method)
The JD method is the most natural and convenient to use in
cases where the loss of several decimal digits of resolution
is acceptable. The J2000 method is best matched to the way
the argument is handled internally and will deliver the
optimum resolution. The MJD method and the date & time methods
are both good compromises between resolution and convenience.
2) The matrix rb transforms vectors from GCRS to mean J2000.0 by
applying frame bias.
3) The matrix rp transforms vectors from J2000.0 mean equator and
equinox to mean equator and equinox of date by applying
precession.
4) The matrix rbp transforms vectors from GCRS to mean equator and
equinox of date by applying frame bias then precession. It is
the product rp x rb.
5) It is permissible to re-use the same array in the returned
arguments. The arrays are filled in the order given.
Called:
iauBi00 frame bias components, IAU 2000
iauPr00 IAU 2000 precession adjustments
iauIr initialize r-matrix to identity
iauRx rotate around X-axis
iauRy rotate around Y-axis
iauRz rotate around Z-axis
iauCr copy r-matrix
iauRxr product of two r-matrices
Reference:
"Expressions for the Celestial Intermediate Pole and Celestial
Ephemeris Origin consistent with the IAU 2000A precession-
nutation model", Astron.Astrophys. 400, 1145-1154 (2003)
n.b. The celestial ephemeris origin (CEO) was renamed "celestial
intermediate origin" (CIO) by IAU 2006 Resolution 2.
This revision: 2013 August 21
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"B",
"p",
"0",
"0",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauBp00.php#L86-L139 |
9,839 | XTAIN/JoomlaBundle | Debug/Debug.php | Debug.enable | public static function enable($errorReportingLevel = null, $displayErrors = true)
{
if (static::$enabled) {
return;
}
static::$enabled = true;
if (null !== $errorReportingLevel) {
error_reporting($errorReportingLevel);
} else {
error_reporting(-1);
}
if ('cli' !== PHP_SAPI) {
ini_set('display_errors', 0);
ExceptionHandler::register();
} elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
// CLI - display errors only if they're not already logged to STDERR
ini_set('display_errors', 1);
}
if ($displayErrors) {
ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
} else {
ErrorHandler::register()->throwAt(0, true);
}
DebugClassLoader::enable();
} | php | public static function enable($errorReportingLevel = null, $displayErrors = true)
{
if (static::$enabled) {
return;
}
static::$enabled = true;
if (null !== $errorReportingLevel) {
error_reporting($errorReportingLevel);
} else {
error_reporting(-1);
}
if ('cli' !== PHP_SAPI) {
ini_set('display_errors', 0);
ExceptionHandler::register();
} elseif ($displayErrors && (!ini_get('log_errors') || ini_get('error_log'))) {
// CLI - display errors only if they're not already logged to STDERR
ini_set('display_errors', 1);
}
if ($displayErrors) {
ErrorHandler::register(new ErrorHandler(new BufferingLogger()));
} else {
ErrorHandler::register()->throwAt(0, true);
}
DebugClassLoader::enable();
} | [
"public",
"static",
"function",
"enable",
"(",
"$",
"errorReportingLevel",
"=",
"null",
",",
"$",
"displayErrors",
"=",
"true",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"enabled",
")",
"{",
"return",
";",
"}",
"static",
"::",
"$",
"enabled",
"=",
"true",
";",
"if",
"(",
"null",
"!==",
"$",
"errorReportingLevel",
")",
"{",
"error_reporting",
"(",
"$",
"errorReportingLevel",
")",
";",
"}",
"else",
"{",
"error_reporting",
"(",
"-",
"1",
")",
";",
"}",
"if",
"(",
"'cli'",
"!==",
"PHP_SAPI",
")",
"{",
"ini_set",
"(",
"'display_errors'",
",",
"0",
")",
";",
"ExceptionHandler",
"::",
"register",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"displayErrors",
"&&",
"(",
"!",
"ini_get",
"(",
"'log_errors'",
")",
"||",
"ini_get",
"(",
"'error_log'",
")",
")",
")",
"{",
"// CLI - display errors only if they're not already logged to STDERR",
"ini_set",
"(",
"'display_errors'",
",",
"1",
")",
";",
"}",
"if",
"(",
"$",
"displayErrors",
")",
"{",
"ErrorHandler",
"::",
"register",
"(",
"new",
"ErrorHandler",
"(",
"new",
"BufferingLogger",
"(",
")",
")",
")",
";",
"}",
"else",
"{",
"ErrorHandler",
"::",
"register",
"(",
")",
"->",
"throwAt",
"(",
"0",
",",
"true",
")",
";",
"}",
"DebugClassLoader",
"::",
"enable",
"(",
")",
";",
"}"
] | Enables the debug tools.
This method registers an error handler and an exception handler.
If the Symfony ClassLoader component is available, a special
class loader is also registered.
@param int $errorReportingLevel The level of error reporting you want
@param bool $displayErrors Whether to display errors (for development) or just log them (for production) | [
"Enables",
"the",
"debug",
"tools",
"."
] | 3d39e1278deba77c5a2197ad91973964ed2a38bd | https://github.com/XTAIN/JoomlaBundle/blob/3d39e1278deba77c5a2197ad91973964ed2a38bd/Debug/Debug.php#L27-L55 |
9,840 | slickframework/mvc | src/Renderer/HtmlExtension.php | HtmlExtension.addCss | public function addCss($file, $path='/css', $attr = [])
{
$attr = array_merge(['rel' => 'stylesheet'], $attr);
$output = [];
foreach ($attr as $name => $value) {
$output[] = "{$name}=\"{$value}\"";
}
$attr = implode(' ', $output);
$file = str_replace('//', '', "{$path}/{$file}");
return sprintf('<link href="%s" %s>', $file, $attr);
} | php | public function addCss($file, $path='/css', $attr = [])
{
$attr = array_merge(['rel' => 'stylesheet'], $attr);
$output = [];
foreach ($attr as $name => $value) {
$output[] = "{$name}=\"{$value}\"";
}
$attr = implode(' ', $output);
$file = str_replace('//', '', "{$path}/{$file}");
return sprintf('<link href="%s" %s>', $file, $attr);
} | [
"public",
"function",
"addCss",
"(",
"$",
"file",
",",
"$",
"path",
"=",
"'/css'",
",",
"$",
"attr",
"=",
"[",
"]",
")",
"{",
"$",
"attr",
"=",
"array_merge",
"(",
"[",
"'rel'",
"=>",
"'stylesheet'",
"]",
",",
"$",
"attr",
")",
";",
"$",
"output",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"attr",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"output",
"[",
"]",
"=",
"\"{$name}=\\\"{$value}\\\"\"",
";",
"}",
"$",
"attr",
"=",
"implode",
"(",
"' '",
",",
"$",
"output",
")",
";",
"$",
"file",
"=",
"str_replace",
"(",
"'//'",
",",
"''",
",",
"\"{$path}/{$file}\"",
")",
";",
"return",
"sprintf",
"(",
"'<link href=\"%s\" %s>'",
",",
"$",
"file",
",",
"$",
"attr",
")",
";",
"}"
] | Creates an HTML style tag
@param string $file
@param string $path
@param array $attr
@return string | [
"Creates",
"an",
"HTML",
"style",
"tag"
] | 91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab | https://github.com/slickframework/mvc/blob/91a6c512f8aaa5a7fb9c1a96f8012d2274dc30ab/src/Renderer/HtmlExtension.php#L107-L117 |
9,841 | GroundSix/password | src/Validators/PasswordBlacklistValidator.php | PasswordBlacklistValidator.getBlacklistPasswords | private function getBlacklistPasswords(): Generator
{
$fh = fopen($this->file, 'rb');
while (($password = fgets($fh)) !== false) {
yield trim($password);
}
fclose($fh);
} | php | private function getBlacklistPasswords(): Generator
{
$fh = fopen($this->file, 'rb');
while (($password = fgets($fh)) !== false) {
yield trim($password);
}
fclose($fh);
} | [
"private",
"function",
"getBlacklistPasswords",
"(",
")",
":",
"Generator",
"{",
"$",
"fh",
"=",
"fopen",
"(",
"$",
"this",
"->",
"file",
",",
"'rb'",
")",
";",
"while",
"(",
"(",
"$",
"password",
"=",
"fgets",
"(",
"$",
"fh",
")",
")",
"!==",
"false",
")",
"{",
"yield",
"trim",
"(",
"$",
"password",
")",
";",
"}",
"fclose",
"(",
"$",
"fh",
")",
";",
"}"
] | Iterates over and yields each blacklisted password
@return Generator | [
"Iterates",
"over",
"and",
"yields",
"each",
"blacklisted",
"password"
] | 83241a362051c28f09cd7cdcd0fbd03918ce0a5b | https://github.com/GroundSix/password/blob/83241a362051c28f09cd7cdcd0fbd03918ce0a5b/src/Validators/PasswordBlacklistValidator.php#L41-L50 |
9,842 | rb-cohen/ical-php | src/Ical/Component/Event.php | Event.between | public function between(DateTime $start, DateTime $end) {
$this->start($start)
->end($end);
return $this;
} | php | public function between(DateTime $start, DateTime $end) {
$this->start($start)
->end($end);
return $this;
} | [
"public",
"function",
"between",
"(",
"DateTime",
"$",
"start",
",",
"DateTime",
"$",
"end",
")",
"{",
"$",
"this",
"->",
"start",
"(",
"$",
"start",
")",
"->",
"end",
"(",
"$",
"end",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Shortcut from start and end dates
@param \DateTime $start
@param \DateTime $end
@return \Ical\Component\Event | [
"Shortcut",
"from",
"start",
"and",
"end",
"dates"
] | d041dc3aba67b4924c0a54ba19196ff88fc19f1f | https://github.com/rb-cohen/ical-php/blob/d041dc3aba67b4924c0a54ba19196ff88fc19f1f/src/Ical/Component/Event.php#L63-L68 |
9,843 | rb-cohen/ical-php | src/Ical/Component/Event.php | Event.on | public function on(DateTime $on) {
if ($on->format('His') !== '000000') {
throw new RuntimeException('One day events must start at midnight');
}
$fin = clone $on;
$fin->add(new \DateInterval('P1D'));
$this->start($on)
->end($fin)
->allDay(true);
return $this;
} | php | public function on(DateTime $on) {
if ($on->format('His') !== '000000') {
throw new RuntimeException('One day events must start at midnight');
}
$fin = clone $on;
$fin->add(new \DateInterval('P1D'));
$this->start($on)
->end($fin)
->allDay(true);
return $this;
} | [
"public",
"function",
"on",
"(",
"DateTime",
"$",
"on",
")",
"{",
"if",
"(",
"$",
"on",
"->",
"format",
"(",
"'His'",
")",
"!==",
"'000000'",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'One day events must start at midnight'",
")",
";",
"}",
"$",
"fin",
"=",
"clone",
"$",
"on",
";",
"$",
"fin",
"->",
"add",
"(",
"new",
"\\",
"DateInterval",
"(",
"'P1D'",
")",
")",
";",
"$",
"this",
"->",
"start",
"(",
"$",
"on",
")",
"->",
"end",
"(",
"$",
"fin",
")",
"->",
"allDay",
"(",
"true",
")",
";",
"return",
"$",
"this",
";",
"}"
] | One day helper
Sets event to a single day
@param \DateTime $on
@return \Ical\Component\Event | [
"One",
"day",
"helper",
"Sets",
"event",
"to",
"a",
"single",
"day"
] | d041dc3aba67b4924c0a54ba19196ff88fc19f1f | https://github.com/rb-cohen/ical-php/blob/d041dc3aba67b4924c0a54ba19196ff88fc19f1f/src/Ical/Component/Event.php#L77-L90 |
9,844 | mijohansen/php-gae-util | src/Fetch.php | Fetch.secureUrl | static public function secureUrl($url, $params = []) {
if (is_array($url)) {
$url = implode("/", $url);
}
$headers = [
"Authorization: Bearer " . JWT::getInternalToken()
];
$opts = [
"http" => [
"method" => "GET",
"header" => implode("\r\n", $headers)
],
"ssl" => array(
"verify_peer" => false,
"verify_peer_name" => false,
)
];
$stream_context = stream_context_create($opts);
if (count($params)) {
$url = $url . "?" . http_build_query($params);
}
syslog(LOG_INFO, __METHOD__ . " fetching: " . $url);
$content = file_get_contents($url, false, $stream_context);
$result = json_decode($content, JSON_OBJECT_AS_ARRAY);
return $result;
} | php | static public function secureUrl($url, $params = []) {
if (is_array($url)) {
$url = implode("/", $url);
}
$headers = [
"Authorization: Bearer " . JWT::getInternalToken()
];
$opts = [
"http" => [
"method" => "GET",
"header" => implode("\r\n", $headers)
],
"ssl" => array(
"verify_peer" => false,
"verify_peer_name" => false,
)
];
$stream_context = stream_context_create($opts);
if (count($params)) {
$url = $url . "?" . http_build_query($params);
}
syslog(LOG_INFO, __METHOD__ . " fetching: " . $url);
$content = file_get_contents($url, false, $stream_context);
$result = json_decode($content, JSON_OBJECT_AS_ARRAY);
return $result;
} | [
"static",
"public",
"function",
"secureUrl",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"implode",
"(",
"\"/\"",
",",
"$",
"url",
")",
";",
"}",
"$",
"headers",
"=",
"[",
"\"Authorization: Bearer \"",
".",
"JWT",
"::",
"getInternalToken",
"(",
")",
"]",
";",
"$",
"opts",
"=",
"[",
"\"http\"",
"=>",
"[",
"\"method\"",
"=>",
"\"GET\"",
",",
"\"header\"",
"=>",
"implode",
"(",
"\"\\r\\n\"",
",",
"$",
"headers",
")",
"]",
",",
"\"ssl\"",
"=>",
"array",
"(",
"\"verify_peer\"",
"=>",
"false",
",",
"\"verify_peer_name\"",
"=>",
"false",
",",
")",
"]",
";",
"$",
"stream_context",
"=",
"stream_context_create",
"(",
"$",
"opts",
")",
";",
"if",
"(",
"count",
"(",
"$",
"params",
")",
")",
"{",
"$",
"url",
"=",
"$",
"url",
".",
"\"?\"",
".",
"http_build_query",
"(",
"$",
"params",
")",
";",
"}",
"syslog",
"(",
"LOG_INFO",
",",
"__METHOD__",
".",
"\" fetching: \"",
".",
"$",
"url",
")",
";",
"$",
"content",
"=",
"file_get_contents",
"(",
"$",
"url",
",",
"false",
",",
"$",
"stream_context",
")",
";",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"content",
",",
"JSON_OBJECT_AS_ARRAY",
")",
";",
"return",
"$",
"result",
";",
"}"
] | Fetching an url secured by the Internal accesstoken.
Should be using guzzle just like other Google Api stuff
@param $url
@param array $params
@return mixed
@throws \Exception | [
"Fetching",
"an",
"url",
"secured",
"by",
"the",
"Internal",
"accesstoken",
".",
"Should",
"be",
"using",
"guzzle",
"just",
"like",
"other",
"Google",
"Api",
"stuff"
] | dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde | https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/Fetch.php#L22-L47 |
9,845 | mijohansen/php-gae-util | src/Fetch.php | Fetch.secureUrlCached | static public function secureUrlCached($url, $params = []) {
if (is_array($url)) {
$url = implode("/", $url);
}
$cacheKey = Cached::keymaker(__METHOD__, $url, $params);
$cached = new Cached($cacheKey);
if (!$cached->exists()) {
$result = self::secureUrl($url, $params);
syslog(LOG_INFO, "Returned " . count($result) . " rows.");
$cached->set($result);
}
return $cached->get();
} | php | static public function secureUrlCached($url, $params = []) {
if (is_array($url)) {
$url = implode("/", $url);
}
$cacheKey = Cached::keymaker(__METHOD__, $url, $params);
$cached = new Cached($cacheKey);
if (!$cached->exists()) {
$result = self::secureUrl($url, $params);
syslog(LOG_INFO, "Returned " . count($result) . " rows.");
$cached->set($result);
}
return $cached->get();
} | [
"static",
"public",
"function",
"secureUrlCached",
"(",
"$",
"url",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"url",
")",
")",
"{",
"$",
"url",
"=",
"implode",
"(",
"\"/\"",
",",
"$",
"url",
")",
";",
"}",
"$",
"cacheKey",
"=",
"Cached",
"::",
"keymaker",
"(",
"__METHOD__",
",",
"$",
"url",
",",
"$",
"params",
")",
";",
"$",
"cached",
"=",
"new",
"Cached",
"(",
"$",
"cacheKey",
")",
";",
"if",
"(",
"!",
"$",
"cached",
"->",
"exists",
"(",
")",
")",
"{",
"$",
"result",
"=",
"self",
"::",
"secureUrl",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"syslog",
"(",
"LOG_INFO",
",",
"\"Returned \"",
".",
"count",
"(",
"$",
"result",
")",
".",
"\" rows.\"",
")",
";",
"$",
"cached",
"->",
"set",
"(",
"$",
"result",
")",
";",
"}",
"return",
"$",
"cached",
"->",
"get",
"(",
")",
";",
"}"
] | Wrapper that caches hits towards an service. Internal or otherwise.
@param $url
@param array $params
@return mixed|\the
@throws \Exception | [
"Wrapper",
"that",
"caches",
"hits",
"towards",
"an",
"service",
".",
"Internal",
"or",
"otherwise",
"."
] | dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde | https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/Fetch.php#L57-L69 |
9,846 | mijohansen/php-gae-util | src/Fetch.php | Fetch.internalService | static public function internalService($application_id, $service, $path, $params = []) {
$url = "https://$service-dot-$application_id.appspot.com" . $path;
return self::secureUrl($url, $params);
} | php | static public function internalService($application_id, $service, $path, $params = []) {
$url = "https://$service-dot-$application_id.appspot.com" . $path;
return self::secureUrl($url, $params);
} | [
"static",
"public",
"function",
"internalService",
"(",
"$",
"application_id",
",",
"$",
"service",
",",
"$",
"path",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"\"https://$service-dot-$application_id.appspot.com\"",
".",
"$",
"path",
";",
"return",
"self",
"::",
"secureUrl",
"(",
"$",
"url",
",",
"$",
"params",
")",
";",
"}"
] | For internal service on Google App Engine. Basically just expands application and service
to the correct domain on App Engine. This url is the fastest url to use internally on
App engine, so this method is prefered for service to service communication.
@param $application_id
@param $service
@param $path
@param array $params
@return mixed
@throws \Exception | [
"For",
"internal",
"service",
"on",
"Google",
"App",
"Engine",
".",
"Basically",
"just",
"expands",
"application",
"and",
"service",
"to",
"the",
"correct",
"domain",
"on",
"App",
"Engine",
".",
"This",
"url",
"is",
"the",
"fastest",
"url",
"to",
"use",
"internally",
"on",
"App",
"engine",
"so",
"this",
"method",
"is",
"prefered",
"for",
"service",
"to",
"service",
"communication",
"."
] | dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde | https://github.com/mijohansen/php-gae-util/blob/dfa7a1a4d61aa435351d6a5b1b120c0e23d81dde/src/Fetch.php#L83-L86 |
9,847 | itavero/AMNL-Mollie | lib/AMNL/Mollie/Client.php | Client.checkResponseForError | protected function checkResponseForError(\SimpleXMLElement $response)
{
if ($response->item != null && ((string) $response->item['type']) == 'error') {
throw new MollieServerErrorException((string) $response->item->message, intval($response->item->errorcode));
}
} | php | protected function checkResponseForError(\SimpleXMLElement $response)
{
if ($response->item != null && ((string) $response->item['type']) == 'error') {
throw new MollieServerErrorException((string) $response->item->message, intval($response->item->errorcode));
}
} | [
"protected",
"function",
"checkResponseForError",
"(",
"\\",
"SimpleXMLElement",
"$",
"response",
")",
"{",
"if",
"(",
"$",
"response",
"->",
"item",
"!=",
"null",
"&&",
"(",
"(",
"string",
")",
"$",
"response",
"->",
"item",
"[",
"'type'",
"]",
")",
"==",
"'error'",
")",
"{",
"throw",
"new",
"MollieServerErrorException",
"(",
"(",
"string",
")",
"$",
"response",
"->",
"item",
"->",
"message",
",",
"intval",
"(",
"$",
"response",
"->",
"item",
"->",
"errorcode",
")",
")",
";",
"}",
"}"
] | Check if the given response contains an error, if so, it will
throw an exception.
@param \SimpleXMLElement $response
@throws \AMNL\Mollie\Exception\MollieServerErrorException | [
"Check",
"if",
"the",
"given",
"response",
"contains",
"an",
"error",
"if",
"so",
"it",
"will",
"throw",
"an",
"exception",
"."
] | 6254720a980eae86ac1f4340a54f2a13a3a5b74b | https://github.com/itavero/AMNL-Mollie/blob/6254720a980eae86ac1f4340a54f2a13a3a5b74b/lib/AMNL/Mollie/Client.php#L142-L147 |
9,848 | asbsoft/yii2-common_2_170212 | web/BaseRoutesBuilder.php | BaseRoutesBuilder.buildRoutes | public static function buildRoutes($routeConfig, $app = null)
{
$app = empty($app) ? Yii::$app : $app;
$rules = static::collectRoutes($routeConfig, $app);
$app->urlManager->addRules($rules, $routeConfig['append']);
} | php | public static function buildRoutes($routeConfig, $app = null)
{
$app = empty($app) ? Yii::$app : $app;
$rules = static::collectRoutes($routeConfig, $app);
$app->urlManager->addRules($rules, $routeConfig['append']);
} | [
"public",
"static",
"function",
"buildRoutes",
"(",
"$",
"routeConfig",
",",
"$",
"app",
"=",
"null",
")",
"{",
"$",
"app",
"=",
"empty",
"(",
"$",
"app",
")",
"?",
"Yii",
"::",
"$",
"app",
":",
"$",
"app",
";",
"$",
"rules",
"=",
"static",
"::",
"collectRoutes",
"(",
"$",
"routeConfig",
",",
"$",
"app",
")",
";",
"$",
"app",
"->",
"urlManager",
"->",
"addRules",
"(",
"$",
"rules",
",",
"$",
"routeConfig",
"[",
"'append'",
"]",
")",
";",
"}"
] | Build routes by routes config.
@param array $routeConfig
@param yii\base\Application $app | [
"Build",
"routes",
"by",
"routes",
"config",
"."
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/web/BaseRoutesBuilder.php#L33-L38 |
9,849 | asbsoft/yii2-common_2_170212 | web/BaseRoutesBuilder.php | BaseRoutesBuilder.collectRoutes | public static function collectRoutes($routeConfig, $app = null)
{
$app = empty($app) ? Yii::$app : $app;
$rules = [];
if (isset($routeConfig['urlPrefix']) && $routeConfig['urlPrefix'] !== false && is_file($routeConfig['fileRoutes'])) {
//!! config file use var $routeConfig:
$routes = include($routeConfig['fileRoutes']);
if (empty($routes)) return [];
switch ($routeConfig['class']) {
case GroupUrlRule::className(): // only for this class config-routes-files very simple
$configGroupRules = [
'rules' => $routes,
'prefix' => $routeConfig['urlPrefix'],
'routePrefix' => $routeConfig['moduleUid'],
];
$rules = [new GroupUrlRule($configGroupRules)];
break;
default: // universal
if (isset($routes['enablePrettyUrl'])) {
$app->urlManager->enablePrettyUrl = $routes['enablePrettyUrl'];
unset($routes['enablePrettyUrl']);
}
$rules = $routes;
break;
}
}
return $rules;
} | php | public static function collectRoutes($routeConfig, $app = null)
{
$app = empty($app) ? Yii::$app : $app;
$rules = [];
if (isset($routeConfig['urlPrefix']) && $routeConfig['urlPrefix'] !== false && is_file($routeConfig['fileRoutes'])) {
//!! config file use var $routeConfig:
$routes = include($routeConfig['fileRoutes']);
if (empty($routes)) return [];
switch ($routeConfig['class']) {
case GroupUrlRule::className(): // only for this class config-routes-files very simple
$configGroupRules = [
'rules' => $routes,
'prefix' => $routeConfig['urlPrefix'],
'routePrefix' => $routeConfig['moduleUid'],
];
$rules = [new GroupUrlRule($configGroupRules)];
break;
default: // universal
if (isset($routes['enablePrettyUrl'])) {
$app->urlManager->enablePrettyUrl = $routes['enablePrettyUrl'];
unset($routes['enablePrettyUrl']);
}
$rules = $routes;
break;
}
}
return $rules;
} | [
"public",
"static",
"function",
"collectRoutes",
"(",
"$",
"routeConfig",
",",
"$",
"app",
"=",
"null",
")",
"{",
"$",
"app",
"=",
"empty",
"(",
"$",
"app",
")",
"?",
"Yii",
"::",
"$",
"app",
":",
"$",
"app",
";",
"$",
"rules",
"=",
"[",
"]",
";",
"if",
"(",
"isset",
"(",
"$",
"routeConfig",
"[",
"'urlPrefix'",
"]",
")",
"&&",
"$",
"routeConfig",
"[",
"'urlPrefix'",
"]",
"!==",
"false",
"&&",
"is_file",
"(",
"$",
"routeConfig",
"[",
"'fileRoutes'",
"]",
")",
")",
"{",
"//!! config file use var $routeConfig:",
"$",
"routes",
"=",
"include",
"(",
"$",
"routeConfig",
"[",
"'fileRoutes'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"routes",
")",
")",
"return",
"[",
"]",
";",
"switch",
"(",
"$",
"routeConfig",
"[",
"'class'",
"]",
")",
"{",
"case",
"GroupUrlRule",
"::",
"className",
"(",
")",
":",
"// only for this class config-routes-files very simple",
"$",
"configGroupRules",
"=",
"[",
"'rules'",
"=>",
"$",
"routes",
",",
"'prefix'",
"=>",
"$",
"routeConfig",
"[",
"'urlPrefix'",
"]",
",",
"'routePrefix'",
"=>",
"$",
"routeConfig",
"[",
"'moduleUid'",
"]",
",",
"]",
";",
"$",
"rules",
"=",
"[",
"new",
"GroupUrlRule",
"(",
"$",
"configGroupRules",
")",
"]",
";",
"break",
";",
"default",
":",
"// universal",
"if",
"(",
"isset",
"(",
"$",
"routes",
"[",
"'enablePrettyUrl'",
"]",
")",
")",
"{",
"$",
"app",
"->",
"urlManager",
"->",
"enablePrettyUrl",
"=",
"$",
"routes",
"[",
"'enablePrettyUrl'",
"]",
";",
"unset",
"(",
"$",
"routes",
"[",
"'enablePrettyUrl'",
"]",
")",
";",
"}",
"$",
"rules",
"=",
"$",
"routes",
";",
"break",
";",
"}",
"}",
"return",
"$",
"rules",
";",
"}"
] | Collect routes by routes config.
@param array $routeConfig
@param yii\base\Application $app
@return yii\web\UrlRuleInterface[] rules for UrlManager | [
"Collect",
"routes",
"by",
"routes",
"config",
"."
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/web/BaseRoutesBuilder.php#L46-L74 |
9,850 | asbsoft/yii2-common_2_170212 | web/BaseRoutesBuilder.php | BaseRoutesBuilder.properRule | public static function properRule($rule, $link)
{
if (isset($rule->pattern)) {
if (preg_match($rule->pattern, $link) > 0) return true;
}
if ($rule instanceof GroupUrlRule) {
foreach ($rule->rules as $nextRule) {
if (preg_match($nextRule->pattern, $link) > 0) return true;
}
}
return false;
} | php | public static function properRule($rule, $link)
{
if (isset($rule->pattern)) {
if (preg_match($rule->pattern, $link) > 0) return true;
}
if ($rule instanceof GroupUrlRule) {
foreach ($rule->rules as $nextRule) {
if (preg_match($nextRule->pattern, $link) > 0) return true;
}
}
return false;
} | [
"public",
"static",
"function",
"properRule",
"(",
"$",
"rule",
",",
"$",
"link",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"rule",
"->",
"pattern",
")",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"rule",
"->",
"pattern",
",",
"$",
"link",
")",
">",
"0",
")",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"rule",
"instanceof",
"GroupUrlRule",
")",
"{",
"foreach",
"(",
"$",
"rule",
"->",
"rules",
"as",
"$",
"nextRule",
")",
"{",
"if",
"(",
"preg_match",
"(",
"$",
"nextRule",
"->",
"pattern",
",",
"$",
"link",
")",
">",
"0",
")",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Check if link will recognize by route's rule.
@return boolean true if found $rule correspond to $link | [
"Check",
"if",
"link",
"will",
"recognize",
"by",
"route",
"s",
"rule",
"."
] | 6c58012ff89225d7d4e42b200cf39e009e9d9dac | https://github.com/asbsoft/yii2-common_2_170212/blob/6c58012ff89225d7d4e42b200cf39e009e9d9dac/web/BaseRoutesBuilder.php#L138-L149 |
9,851 | n0m4dz/laracasa | Zend/Gdata/YouTube/VideoQuery.php | Zend_Gdata_YouTube_VideoQuery.setFeedType | public function setFeedType($feedType, $videoId = null, $entry = null)
{
switch ($feedType) {
case 'top rated':
$this->_url = Zend_Gdata_YouTube::STANDARD_TOP_RATED_URI;
break;
case 'most viewed':
$this->_url = Zend_Gdata_YouTube::STANDARD_MOST_VIEWED_URI;
break;
case 'recently featured':
$this->_url = Zend_Gdata_YouTube::STANDARD_RECENTLY_FEATURED_URI;
break;
case 'mobile':
$this->_url = Zend_Gdata_YouTube::STANDARD_WATCH_ON_MOBILE_URI;
break;
case 'related':
if ($videoId === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Video ID must be set for feed of type: ' . $feedType);
} else {
$this->_url = Zend_Gdata_YouTube::VIDEO_URI . '/' . $videoId .
'/related';
}
break;
case 'responses':
if ($videoId === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_Exception(
'Video ID must be set for feed of type: ' . $feedType);
} else {
$this->_url = Zend_Gdata_YouTube::VIDEO_URI . '/' . $videoId .
'/responses';
}
break;
case 'comments':
if ($videoId === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_Exception(
'Video ID must be set for feed of type: ' . $feedType);
} else {
$this->_url = Zend_Gdata_YouTube::VIDEO_URI . '/' .
$videoId . '/comments';
if ($entry !== null) {
$this->_url .= '/' . $entry;
}
}
break;
default:
require_once 'Zend/Gdata/App/Exception.php';
throw new Zend_Gdata_App_Exception('Unknown feed type');
break;
}
} | php | public function setFeedType($feedType, $videoId = null, $entry = null)
{
switch ($feedType) {
case 'top rated':
$this->_url = Zend_Gdata_YouTube::STANDARD_TOP_RATED_URI;
break;
case 'most viewed':
$this->_url = Zend_Gdata_YouTube::STANDARD_MOST_VIEWED_URI;
break;
case 'recently featured':
$this->_url = Zend_Gdata_YouTube::STANDARD_RECENTLY_FEATURED_URI;
break;
case 'mobile':
$this->_url = Zend_Gdata_YouTube::STANDARD_WATCH_ON_MOBILE_URI;
break;
case 'related':
if ($videoId === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Video ID must be set for feed of type: ' . $feedType);
} else {
$this->_url = Zend_Gdata_YouTube::VIDEO_URI . '/' . $videoId .
'/related';
}
break;
case 'responses':
if ($videoId === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_Exception(
'Video ID must be set for feed of type: ' . $feedType);
} else {
$this->_url = Zend_Gdata_YouTube::VIDEO_URI . '/' . $videoId .
'/responses';
}
break;
case 'comments':
if ($videoId === null) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_Exception(
'Video ID must be set for feed of type: ' . $feedType);
} else {
$this->_url = Zend_Gdata_YouTube::VIDEO_URI . '/' .
$videoId . '/comments';
if ($entry !== null) {
$this->_url .= '/' . $entry;
}
}
break;
default:
require_once 'Zend/Gdata/App/Exception.php';
throw new Zend_Gdata_App_Exception('Unknown feed type');
break;
}
} | [
"public",
"function",
"setFeedType",
"(",
"$",
"feedType",
",",
"$",
"videoId",
"=",
"null",
",",
"$",
"entry",
"=",
"null",
")",
"{",
"switch",
"(",
"$",
"feedType",
")",
"{",
"case",
"'top rated'",
":",
"$",
"this",
"->",
"_url",
"=",
"Zend_Gdata_YouTube",
"::",
"STANDARD_TOP_RATED_URI",
";",
"break",
";",
"case",
"'most viewed'",
":",
"$",
"this",
"->",
"_url",
"=",
"Zend_Gdata_YouTube",
"::",
"STANDARD_MOST_VIEWED_URI",
";",
"break",
";",
"case",
"'recently featured'",
":",
"$",
"this",
"->",
"_url",
"=",
"Zend_Gdata_YouTube",
"::",
"STANDARD_RECENTLY_FEATURED_URI",
";",
"break",
";",
"case",
"'mobile'",
":",
"$",
"this",
"->",
"_url",
"=",
"Zend_Gdata_YouTube",
"::",
"STANDARD_WATCH_ON_MOBILE_URI",
";",
"break",
";",
"case",
"'related'",
":",
"if",
"(",
"$",
"videoId",
"===",
"null",
")",
"{",
"require_once",
"'Zend/Gdata/App/InvalidArgumentException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_InvalidArgumentException",
"(",
"'Video ID must be set for feed of type: '",
".",
"$",
"feedType",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_url",
"=",
"Zend_Gdata_YouTube",
"::",
"VIDEO_URI",
".",
"'/'",
".",
"$",
"videoId",
".",
"'/related'",
";",
"}",
"break",
";",
"case",
"'responses'",
":",
"if",
"(",
"$",
"videoId",
"===",
"null",
")",
"{",
"require_once",
"'Zend/Gdata/App/InvalidArgumentException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_Exception",
"(",
"'Video ID must be set for feed of type: '",
".",
"$",
"feedType",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_url",
"=",
"Zend_Gdata_YouTube",
"::",
"VIDEO_URI",
".",
"'/'",
".",
"$",
"videoId",
".",
"'/responses'",
";",
"}",
"break",
";",
"case",
"'comments'",
":",
"if",
"(",
"$",
"videoId",
"===",
"null",
")",
"{",
"require_once",
"'Zend/Gdata/App/InvalidArgumentException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_Exception",
"(",
"'Video ID must be set for feed of type: '",
".",
"$",
"feedType",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"_url",
"=",
"Zend_Gdata_YouTube",
"::",
"VIDEO_URI",
".",
"'/'",
".",
"$",
"videoId",
".",
"'/comments'",
";",
"if",
"(",
"$",
"entry",
"!==",
"null",
")",
"{",
"$",
"this",
"->",
"_url",
".=",
"'/'",
".",
"$",
"entry",
";",
"}",
"}",
"break",
";",
"default",
":",
"require_once",
"'Zend/Gdata/App/Exception.php'",
";",
"throw",
"new",
"Zend_Gdata_App_Exception",
"(",
"'Unknown feed type'",
")",
";",
"break",
";",
"}",
"}"
] | Sets the type of feed this query should be used to search
@param string $feedType The type of feed
@param string $videoId The ID of the video associated with this query
@param string $entry The ID of the entry associated with this query | [
"Sets",
"the",
"type",
"of",
"feed",
"this",
"query",
"should",
"be",
"used",
"to",
"search"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/VideoQuery.php#L63-L116 |
9,852 | n0m4dz/laracasa | Zend/Gdata/YouTube/VideoQuery.php | Zend_Gdata_YouTube_VideoQuery.setLocation | public function setLocation($value)
{
switch($value) {
case null:
unset($this->_params['location']);
default:
$parameters = explode(',', $value);
if (count($parameters) != 2) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'You must provide 2 coordinates to the location ' .
'URL parameter');
}
foreach($parameters as $param) {
$temp = trim($param);
// strip off the optional exclamation mark for numeric check
if (substr($temp, -1) == '!') {
$temp = substr($temp, 0, -1);
}
if (!is_numeric($temp)) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Value provided to location parameter must' .
' be in the form of two coordinates');
}
}
$this->_params['location'] = $value;
}
} | php | public function setLocation($value)
{
switch($value) {
case null:
unset($this->_params['location']);
default:
$parameters = explode(',', $value);
if (count($parameters) != 2) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'You must provide 2 coordinates to the location ' .
'URL parameter');
}
foreach($parameters as $param) {
$temp = trim($param);
// strip off the optional exclamation mark for numeric check
if (substr($temp, -1) == '!') {
$temp = substr($temp, 0, -1);
}
if (!is_numeric($temp)) {
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Value provided to location parameter must' .
' be in the form of two coordinates');
}
}
$this->_params['location'] = $value;
}
} | [
"public",
"function",
"setLocation",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"value",
")",
"{",
"case",
"null",
":",
"unset",
"(",
"$",
"this",
"->",
"_params",
"[",
"'location'",
"]",
")",
";",
"default",
":",
"$",
"parameters",
"=",
"explode",
"(",
"','",
",",
"$",
"value",
")",
";",
"if",
"(",
"count",
"(",
"$",
"parameters",
")",
"!=",
"2",
")",
"{",
"require_once",
"'Zend/Gdata/App/InvalidArgumentException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_InvalidArgumentException",
"(",
"'You must provide 2 coordinates to the location '",
".",
"'URL parameter'",
")",
";",
"}",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"param",
")",
"{",
"$",
"temp",
"=",
"trim",
"(",
"$",
"param",
")",
";",
"// strip off the optional exclamation mark for numeric check",
"if",
"(",
"substr",
"(",
"$",
"temp",
",",
"-",
"1",
")",
"==",
"'!'",
")",
"{",
"$",
"temp",
"=",
"substr",
"(",
"$",
"temp",
",",
"0",
",",
"-",
"1",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"temp",
")",
")",
"{",
"require_once",
"'Zend/Gdata/App/InvalidArgumentException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_InvalidArgumentException",
"(",
"'Value provided to location parameter must'",
".",
"' be in the form of two coordinates'",
")",
";",
"}",
"}",
"$",
"this",
"->",
"_params",
"[",
"'location'",
"]",
"=",
"$",
"value",
";",
"}",
"}"
] | Sets the location parameter for the query
@param string $value
@throws Zend_Gdata_App_InvalidArgumentException
@return Zend_Gdata_YouTube_VideoQuery Provides a fluent interface | [
"Sets",
"the",
"location",
"parameter",
"for",
"the",
"query"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/VideoQuery.php#L125-L154 |
9,853 | n0m4dz/laracasa | Zend/Gdata/YouTube/VideoQuery.php | Zend_Gdata_YouTube_VideoQuery.setTime | public function setTime($value = null)
{
switch ($value) {
case 'today':
$this->_params['time'] = 'today';
break;
case 'this_week':
$this->_params['time'] = 'this_week';
break;
case 'this_month':
$this->_params['time'] = 'this_month';
break;
case 'all_time':
$this->_params['time'] = 'all_time';
break;
case null:
unset($this->_params['time']);
default:
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Unknown time value');
break;
}
return $this;
} | php | public function setTime($value = null)
{
switch ($value) {
case 'today':
$this->_params['time'] = 'today';
break;
case 'this_week':
$this->_params['time'] = 'this_week';
break;
case 'this_month':
$this->_params['time'] = 'this_month';
break;
case 'all_time':
$this->_params['time'] = 'all_time';
break;
case null:
unset($this->_params['time']);
default:
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Unknown time value');
break;
}
return $this;
} | [
"public",
"function",
"setTime",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"switch",
"(",
"$",
"value",
")",
"{",
"case",
"'today'",
":",
"$",
"this",
"->",
"_params",
"[",
"'time'",
"]",
"=",
"'today'",
";",
"break",
";",
"case",
"'this_week'",
":",
"$",
"this",
"->",
"_params",
"[",
"'time'",
"]",
"=",
"'this_week'",
";",
"break",
";",
"case",
"'this_month'",
":",
"$",
"this",
"->",
"_params",
"[",
"'time'",
"]",
"=",
"'this_month'",
";",
"break",
";",
"case",
"'all_time'",
":",
"$",
"this",
"->",
"_params",
"[",
"'time'",
"]",
"=",
"'all_time'",
";",
"break",
";",
"case",
"null",
":",
"unset",
"(",
"$",
"this",
"->",
"_params",
"[",
"'time'",
"]",
")",
";",
"default",
":",
"require_once",
"'Zend/Gdata/App/InvalidArgumentException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_InvalidArgumentException",
"(",
"'Unknown time value'",
")",
";",
"break",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the time period over which this query should apply
@param string $value
@throws Zend_Gdata_App_InvalidArgumentException
@return Zend_Gdata_YouTube_VideoQuery Provides a fluent interface | [
"Sets",
"the",
"time",
"period",
"over",
"which",
"this",
"query",
"should",
"apply"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/VideoQuery.php#L209-L233 |
9,854 | n0m4dz/laracasa | Zend/Gdata/YouTube/VideoQuery.php | Zend_Gdata_YouTube_VideoQuery.setUploader | public function setUploader($value = null)
{
switch ($value) {
case 'partner':
$this->_params['uploader'] = 'partner';
break;
case null:
unset($this->_params['uploader']);
break;
default:
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Unknown value for uploader');
}
return $this;
} | php | public function setUploader($value = null)
{
switch ($value) {
case 'partner':
$this->_params['uploader'] = 'partner';
break;
case null:
unset($this->_params['uploader']);
break;
default:
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'Unknown value for uploader');
}
return $this;
} | [
"public",
"function",
"setUploader",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"switch",
"(",
"$",
"value",
")",
"{",
"case",
"'partner'",
":",
"$",
"this",
"->",
"_params",
"[",
"'uploader'",
"]",
"=",
"'partner'",
";",
"break",
";",
"case",
"null",
":",
"unset",
"(",
"$",
"this",
"->",
"_params",
"[",
"'uploader'",
"]",
")",
";",
"break",
";",
"default",
":",
"require_once",
"'Zend/Gdata/App/InvalidArgumentException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_InvalidArgumentException",
"(",
"'Unknown value for uploader'",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the value of the uploader parameter
@param string $value The value of the uploader parameter. Currently this
can only be set to the value of 'partner'.
@throws Zend_Gdata_App_InvalidArgumentException
@return Zend_Gdata_YouTube_VideoQuery Provides a fluent interface | [
"Sets",
"the",
"value",
"of",
"the",
"uploader",
"parameter"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/VideoQuery.php#L243-L258 |
9,855 | n0m4dz/laracasa | Zend/Gdata/YouTube/VideoQuery.php | Zend_Gdata_YouTube_VideoQuery.setFormat | public function setFormat($value = null)
{
if ($value != null) {
$this->_params['format'] = $value;
} else {
unset($this->_params['format']);
}
return $this;
} | php | public function setFormat($value = null)
{
if ($value != null) {
$this->_params['format'] = $value;
} else {
unset($this->_params['format']);
}
return $this;
} | [
"public",
"function",
"setFormat",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"value",
"!=",
"null",
")",
"{",
"$",
"this",
"->",
"_params",
"[",
"'format'",
"]",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"this",
"->",
"_params",
"[",
"'format'",
"]",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets the param to return videos of a specific format
@param string $value
@return Zend_Gdata_YouTube_VideoQuery Provides a fluent interface | [
"Sets",
"the",
"param",
"to",
"return",
"videos",
"of",
"a",
"specific",
"format"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/VideoQuery.php#L282-L290 |
9,856 | n0m4dz/laracasa | Zend/Gdata/YouTube/VideoQuery.php | Zend_Gdata_YouTube_VideoQuery.setRacy | public function setRacy($value = null)
{
switch ($value) {
case 'include':
$this->_params['racy'] = $value;
break;
case 'exclude':
$this->_params['racy'] = $value;
break;
case null:
unset($this->_params['racy']);
break;
}
return $this;
} | php | public function setRacy($value = null)
{
switch ($value) {
case 'include':
$this->_params['racy'] = $value;
break;
case 'exclude':
$this->_params['racy'] = $value;
break;
case null:
unset($this->_params['racy']);
break;
}
return $this;
} | [
"public",
"function",
"setRacy",
"(",
"$",
"value",
"=",
"null",
")",
"{",
"switch",
"(",
"$",
"value",
")",
"{",
"case",
"'include'",
":",
"$",
"this",
"->",
"_params",
"[",
"'racy'",
"]",
"=",
"$",
"value",
";",
"break",
";",
"case",
"'exclude'",
":",
"$",
"this",
"->",
"_params",
"[",
"'racy'",
"]",
"=",
"$",
"value",
";",
"break",
";",
"case",
"null",
":",
"unset",
"(",
"$",
"this",
"->",
"_params",
"[",
"'racy'",
"]",
")",
";",
"break",
";",
"}",
"return",
"$",
"this",
";",
"}"
] | Sets whether or not to include racy videos in the search results
@param string $value
@return Zend_Gdata_YouTube_VideoQuery Provides a fluent interface | [
"Sets",
"whether",
"or",
"not",
"to",
"include",
"racy",
"videos",
"in",
"the",
"search",
"results"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/VideoQuery.php#L298-L312 |
9,857 | n0m4dz/laracasa | Zend/Gdata/YouTube/VideoQuery.php | Zend_Gdata_YouTube_VideoQuery.setSafeSearch | public function setSafeSearch($value)
{
switch ($value) {
case 'none':
$this->_params['safeSearch'] = 'none';
break;
case 'moderate':
$this->_params['safeSearch'] = 'moderate';
break;
case 'strict':
$this->_params['safeSearch'] = 'strict';
break;
case null:
unset($this->_params['safeSearch']);
default:
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'The safeSearch parameter only supports the values '.
'\'none\', \'moderate\' or \'strict\'.');
}
} | php | public function setSafeSearch($value)
{
switch ($value) {
case 'none':
$this->_params['safeSearch'] = 'none';
break;
case 'moderate':
$this->_params['safeSearch'] = 'moderate';
break;
case 'strict':
$this->_params['safeSearch'] = 'strict';
break;
case null:
unset($this->_params['safeSearch']);
default:
require_once 'Zend/Gdata/App/InvalidArgumentException.php';
throw new Zend_Gdata_App_InvalidArgumentException(
'The safeSearch parameter only supports the values '.
'\'none\', \'moderate\' or \'strict\'.');
}
} | [
"public",
"function",
"setSafeSearch",
"(",
"$",
"value",
")",
"{",
"switch",
"(",
"$",
"value",
")",
"{",
"case",
"'none'",
":",
"$",
"this",
"->",
"_params",
"[",
"'safeSearch'",
"]",
"=",
"'none'",
";",
"break",
";",
"case",
"'moderate'",
":",
"$",
"this",
"->",
"_params",
"[",
"'safeSearch'",
"]",
"=",
"'moderate'",
";",
"break",
";",
"case",
"'strict'",
":",
"$",
"this",
"->",
"_params",
"[",
"'safeSearch'",
"]",
"=",
"'strict'",
";",
"break",
";",
"case",
"null",
":",
"unset",
"(",
"$",
"this",
"->",
"_params",
"[",
"'safeSearch'",
"]",
")",
";",
"default",
":",
"require_once",
"'Zend/Gdata/App/InvalidArgumentException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_InvalidArgumentException",
"(",
"'The safeSearch parameter only supports the values '",
".",
"'\\'none\\', \\'moderate\\' or \\'strict\\'.'",
")",
";",
"}",
"}"
] | Set the safeSearch parameter
@param string $value The value of the parameter, currently only 'none',
'moderate' or 'strict' are allowed values.
@throws Zend_Gdata_App_InvalidArgumentException
@return Zend_Gdata_YouTube_VideoQuery Provides a fluent interface | [
"Set",
"the",
"safeSearch",
"parameter"
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/VideoQuery.php#L336-L356 |
9,858 | n0m4dz/laracasa | Zend/Gdata/YouTube/VideoQuery.php | Zend_Gdata_YouTube_VideoQuery.getQueryString | public function getQueryString($majorProtocolVersion = null,
$minorProtocolVersion = null)
{
$queryArray = array();
foreach ($this->_params as $name => $value) {
if (substr($name, 0, 1) == '_') {
continue;
}
switch($name) {
case 'location-radius':
if ($majorProtocolVersion == 1) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException("The $name " .
"parameter is only supported in version 2.");
}
break;
case 'racy':
if ($majorProtocolVersion == 2) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException("The $name " .
"parameter is not supported in version 2. " .
"Please use 'safeSearch'.");
}
break;
case 'safeSearch':
if ($majorProtocolVersion == 1) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException("The $name " .
"parameter is only supported in version 2. " .
"Please use 'racy'.");
}
break;
case 'uploader':
if ($majorProtocolVersion == 1) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException("The $name " .
"parameter is only supported in version 2.");
}
break;
case 'vq':
if ($majorProtocolVersion == 2) {
$name = 'q';
}
break;
}
$queryArray[] = urlencode($name) . '=' . urlencode($value);
}
if (count($queryArray) > 0) {
return '?' . implode('&', $queryArray);
} else {
return '';
}
} | php | public function getQueryString($majorProtocolVersion = null,
$minorProtocolVersion = null)
{
$queryArray = array();
foreach ($this->_params as $name => $value) {
if (substr($name, 0, 1) == '_') {
continue;
}
switch($name) {
case 'location-radius':
if ($majorProtocolVersion == 1) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException("The $name " .
"parameter is only supported in version 2.");
}
break;
case 'racy':
if ($majorProtocolVersion == 2) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException("The $name " .
"parameter is not supported in version 2. " .
"Please use 'safeSearch'.");
}
break;
case 'safeSearch':
if ($majorProtocolVersion == 1) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException("The $name " .
"parameter is only supported in version 2. " .
"Please use 'racy'.");
}
break;
case 'uploader':
if ($majorProtocolVersion == 1) {
require_once 'Zend/Gdata/App/VersionException.php';
throw new Zend_Gdata_App_VersionException("The $name " .
"parameter is only supported in version 2.");
}
break;
case 'vq':
if ($majorProtocolVersion == 2) {
$name = 'q';
}
break;
}
$queryArray[] = urlencode($name) . '=' . urlencode($value);
}
if (count($queryArray) > 0) {
return '?' . implode('&', $queryArray);
} else {
return '';
}
} | [
"public",
"function",
"getQueryString",
"(",
"$",
"majorProtocolVersion",
"=",
"null",
",",
"$",
"minorProtocolVersion",
"=",
"null",
")",
"{",
"$",
"queryArray",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"_params",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"name",
",",
"0",
",",
"1",
")",
"==",
"'_'",
")",
"{",
"continue",
";",
"}",
"switch",
"(",
"$",
"name",
")",
"{",
"case",
"'location-radius'",
":",
"if",
"(",
"$",
"majorProtocolVersion",
"==",
"1",
")",
"{",
"require_once",
"'Zend/Gdata/App/VersionException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_VersionException",
"(",
"\"The $name \"",
".",
"\"parameter is only supported in version 2.\"",
")",
";",
"}",
"break",
";",
"case",
"'racy'",
":",
"if",
"(",
"$",
"majorProtocolVersion",
"==",
"2",
")",
"{",
"require_once",
"'Zend/Gdata/App/VersionException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_VersionException",
"(",
"\"The $name \"",
".",
"\"parameter is not supported in version 2. \"",
".",
"\"Please use 'safeSearch'.\"",
")",
";",
"}",
"break",
";",
"case",
"'safeSearch'",
":",
"if",
"(",
"$",
"majorProtocolVersion",
"==",
"1",
")",
"{",
"require_once",
"'Zend/Gdata/App/VersionException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_VersionException",
"(",
"\"The $name \"",
".",
"\"parameter is only supported in version 2. \"",
".",
"\"Please use 'racy'.\"",
")",
";",
"}",
"break",
";",
"case",
"'uploader'",
":",
"if",
"(",
"$",
"majorProtocolVersion",
"==",
"1",
")",
"{",
"require_once",
"'Zend/Gdata/App/VersionException.php'",
";",
"throw",
"new",
"Zend_Gdata_App_VersionException",
"(",
"\"The $name \"",
".",
"\"parameter is only supported in version 2.\"",
")",
";",
"}",
"break",
";",
"case",
"'vq'",
":",
"if",
"(",
"$",
"majorProtocolVersion",
"==",
"2",
")",
"{",
"$",
"name",
"=",
"'q'",
";",
"}",
"break",
";",
"}",
"$",
"queryArray",
"[",
"]",
"=",
"urlencode",
"(",
"$",
"name",
")",
".",
"'='",
".",
"urlencode",
"(",
"$",
"value",
")",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"queryArray",
")",
">",
"0",
")",
"{",
"return",
"'?'",
".",
"implode",
"(",
"'&'",
",",
"$",
"queryArray",
")",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] | Generate the query string from the URL parameters, optionally modifying
them based on protocol version.
@param integer $majorProtocolVersion The major protocol version
@param integer $minorProtocolVersion The minor protocol version
@throws Zend_Gdata_App_VersionException
@return string querystring | [
"Generate",
"the",
"query",
"string",
"from",
"the",
"URL",
"parameters",
"optionally",
"modifying",
"them",
"based",
"on",
"protocol",
"version",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/VideoQuery.php#L454-L514 |
9,859 | n0m4dz/laracasa | Zend/Gdata/YouTube/VideoQuery.php | Zend_Gdata_YouTube_VideoQuery.getQueryUrl | public function getQueryUrl($majorProtocolVersion = null,
$minorProtocolVersion = null)
{
if (isset($this->_url)) {
$url = $this->_url;
} else {
$url = Zend_Gdata_YouTube::VIDEO_URI;
}
if ($this->getCategory() !== null) {
$url .= '/-/' . $this->getCategory();
}
$url = $url . $this->getQueryString($majorProtocolVersion,
$minorProtocolVersion);
return $url;
} | php | public function getQueryUrl($majorProtocolVersion = null,
$minorProtocolVersion = null)
{
if (isset($this->_url)) {
$url = $this->_url;
} else {
$url = Zend_Gdata_YouTube::VIDEO_URI;
}
if ($this->getCategory() !== null) {
$url .= '/-/' . $this->getCategory();
}
$url = $url . $this->getQueryString($majorProtocolVersion,
$minorProtocolVersion);
return $url;
} | [
"public",
"function",
"getQueryUrl",
"(",
"$",
"majorProtocolVersion",
"=",
"null",
",",
"$",
"minorProtocolVersion",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_url",
")",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"_url",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"Zend_Gdata_YouTube",
"::",
"VIDEO_URI",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"getCategory",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"url",
".=",
"'/-/'",
".",
"$",
"this",
"->",
"getCategory",
"(",
")",
";",
"}",
"$",
"url",
"=",
"$",
"url",
".",
"$",
"this",
"->",
"getQueryString",
"(",
"$",
"majorProtocolVersion",
",",
"$",
"minorProtocolVersion",
")",
";",
"return",
"$",
"url",
";",
"}"
] | Returns the generated full query URL, optionally modifying it based on
the protocol version.
@param integer $majorProtocolVersion The major protocol version
@param integer $minorProtocolVersion The minor protocol version
@return string The URL | [
"Returns",
"the",
"generated",
"full",
"query",
"URL",
"optionally",
"modifying",
"it",
"based",
"on",
"the",
"protocol",
"version",
"."
] | 6141f0c16c7d4453275e3b74be5041f336085c91 | https://github.com/n0m4dz/laracasa/blob/6141f0c16c7d4453275e3b74be5041f336085c91/Zend/Gdata/YouTube/VideoQuery.php#L524-L538 |
9,860 | marando/phpSOFA | src/Marando/IAU/iauGst00b.php | iauGst00b.Gst00b | public static function Gst00b($uta, $utb) {
$gmst00;
$ee00b;
$gst;
$gmst00 = IAU::Gmst00($uta, $utb, $uta, $utb);
$ee00b = IAU::Ee00b($uta, $utb);
$gst = IAU::Anp($gmst00 + $ee00b);
return $gst;
} | php | public static function Gst00b($uta, $utb) {
$gmst00;
$ee00b;
$gst;
$gmst00 = IAU::Gmst00($uta, $utb, $uta, $utb);
$ee00b = IAU::Ee00b($uta, $utb);
$gst = IAU::Anp($gmst00 + $ee00b);
return $gst;
} | [
"public",
"static",
"function",
"Gst00b",
"(",
"$",
"uta",
",",
"$",
"utb",
")",
"{",
"$",
"gmst00",
";",
"$",
"ee00b",
";",
"$",
"gst",
";",
"$",
"gmst00",
"=",
"IAU",
"::",
"Gmst00",
"(",
"$",
"uta",
",",
"$",
"utb",
",",
"$",
"uta",
",",
"$",
"utb",
")",
";",
"$",
"ee00b",
"=",
"IAU",
"::",
"Ee00b",
"(",
"$",
"uta",
",",
"$",
"utb",
")",
";",
"$",
"gst",
"=",
"IAU",
"::",
"Anp",
"(",
"$",
"gmst00",
"+",
"$",
"ee00b",
")",
";",
"return",
"$",
"gst",
";",
"}"
] | - - - - - - - - - -
i a u G s t 0 0 b
- - - - - - - - - -
Greenwich apparent sidereal time (consistent with IAU 2000
resolutions but using the truncated nutation model IAU 2000B).
This function is part of the International Astronomical Union's
SOFA (Standards Of Fundamental Astronomy) software collection.
Status: support function.
Given:
uta,utb double UT1 as a 2-part Julian Date (Notes 1,2)
Returned (function value):
double Greenwich apparent sidereal time (radians)
Notes:
1) The UT1 date uta+utb is a Julian Date, apportioned in any
convenient way between the argument pair. For example,
JD=2450123.7 could be expressed in any of these ways, among
others:
uta utb
2450123.7 0.0 (JD method)
2451545.0 -1421.3 (J2000 method)
2400000.5 50123.2 (MJD method)
2450123.5 0.2 (date & time method)
The JD method is the most natural and convenient to use in cases
where the loss of several decimal digits of resolution is
acceptable. The J2000 and MJD methods are good compromises
between resolution and convenience. For UT, the date & time
method is best matched to the algorithm that is used by the Earth
Rotation Angle function, called internally: maximum precision is
delivered when the uta argument is for 0hrs UT1 on the day in
question and the utb argument lies in the range 0 to 1, or vice
versa.
2) The result is compatible with the IAU 2000 resolutions, except
that accuracy has been compromised for the sake of speed and
convenience in two respects:
. UT is used instead of TDB (or TT) to compute the precession
component of GMST and the equation of the equinoxes. This
results in errors of order 0.1 mas at present.
. The IAU 2000B abridged nutation model (McCarthy & Luzum, 2001)
is used, introducing errors of up to 1 mas.
3) This GAST is compatible with the IAU 2000 resolutions and must be
used only in conjunction with other IAU 2000 compatible
components such as precession-nutation.
4) The result is returned in the range 0 to 2pi.
5) The algorithm is from Capitaine et al. (2003) and IERS
Conventions 2003.
Called:
iauGmst00 Greenwich mean sidereal time, IAU 2000
iauEe00b equation of the equinoxes, IAU 2000B
iauAnp normalize angle into range 0 to 2pi
References:
Capitaine, N., Wallace, P.T. and McCarthy, D.D., "Expressions to
implement the IAU 2000 definition of UT1", Astronomy &
Astrophysics, 406, 1135-1149 (2003)
McCarthy, D.D. & Luzum, B.J., "An abridged model of the
precession-nutation of the celestial pole", Celestial Mechanics &
Dynamical Astronomy, 85, 37-49 (2003)
McCarthy, D. D., Petit, G. (eds.), IERS Conventions (2003),
IERS Technical Note No. 32, BKG (2004)
This revision: 2013 June 18
SOFA release 2015-02-09
Copyright (C) 2015 IAU SOFA Board. See notes at end. | [
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"i",
"a",
"u",
"G",
"s",
"t",
"0",
"0",
"b",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-"
] | 757fa49fe335ae1210eaa7735473fd4388b13f07 | https://github.com/marando/phpSOFA/blob/757fa49fe335ae1210eaa7735473fd4388b13f07/src/Marando/IAU/iauGst00b.php#L94-L104 |
9,861 | tasoftch/config | src/ConfigurableTrait.php | ConfigurableTrait.setConfiguration | public function setConfiguration($config) {
if(!($config instanceof Config))
$config = new Config($config);
$this->config = $config;
} | php | public function setConfiguration($config) {
if(!($config instanceof Config))
$config = new Config($config);
$this->config = $config;
} | [
"public",
"function",
"setConfiguration",
"(",
"$",
"config",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"config",
"instanceof",
"Config",
")",
")",
"$",
"config",
"=",
"new",
"Config",
"(",
"$",
"config",
")",
";",
"$",
"this",
"->",
"config",
"=",
"$",
"config",
";",
"}"
] | Sets the configuration of the instance
@param iterable|Config $config | [
"Sets",
"the",
"configuration",
"of",
"the",
"instance"
] | 4937668bd7d56150edf3a77de5d529db6f6a4a80 | https://github.com/tasoftch/config/blob/4937668bd7d56150edf3a77de5d529db6f6a4a80/src/ConfigurableTrait.php#L40-L44 |
9,862 | sndatabase/core | src/Result.php | Result.setFetchMode | public function setFetchMode($mode, $complement_info = null, array $ctor_args = array()) {
$this->fetchMode = new FetchMode($mode, $complement_info, $ctor_args);
} | php | public function setFetchMode($mode, $complement_info = null, array $ctor_args = array()) {
$this->fetchMode = new FetchMode($mode, $complement_info, $ctor_args);
} | [
"public",
"function",
"setFetchMode",
"(",
"$",
"mode",
",",
"$",
"complement_info",
"=",
"null",
",",
"array",
"$",
"ctor_args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"fetchMode",
"=",
"new",
"FetchMode",
"(",
"$",
"mode",
",",
"$",
"complement_info",
",",
"$",
"ctor_args",
")",
";",
"}"
] | Sets fetch mode for this result set
@param int $mode Fetch mode : combinaison of constants DB::FETCH_*
@param mixed $complement_info For some modes : additionnal information
@param array $ctor_args For DB::FETCH_CLASS : constructor argument list
@see FetchMode | [
"Sets",
"fetch",
"mode",
"for",
"this",
"result",
"set"
] | 8645b71f1cb437a845fcf12ae742655dd874b229 | https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/Result.php#L100-L102 |
9,863 | sndatabase/core | src/Result.php | Result.setCursorMode | public function setCursorMode($mode) {
switch($mode) {
case DB::CURSOR_FIRST:
case DB::CURSOR_PREV:
case DB::CURSOR_NEXT:
case DB::CURSOR_LAST:
$this->cursorMode = $mode;
break;
default:
throw new \InvalidArgumentException('Invalid cursor mode');
}
} | php | public function setCursorMode($mode) {
switch($mode) {
case DB::CURSOR_FIRST:
case DB::CURSOR_PREV:
case DB::CURSOR_NEXT:
case DB::CURSOR_LAST:
$this->cursorMode = $mode;
break;
default:
throw new \InvalidArgumentException('Invalid cursor mode');
}
} | [
"public",
"function",
"setCursorMode",
"(",
"$",
"mode",
")",
"{",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"DB",
"::",
"CURSOR_FIRST",
":",
"case",
"DB",
"::",
"CURSOR_PREV",
":",
"case",
"DB",
"::",
"CURSOR_NEXT",
":",
"case",
"DB",
"::",
"CURSOR_LAST",
":",
"$",
"this",
"->",
"cursorMode",
"=",
"$",
"mode",
";",
"break",
";",
"default",
":",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid cursor mode'",
")",
";",
"}",
"}"
] | Sets cursor fetching mode for next fetch
@param int $mode Constant DB::CURSOR_*
@throws \InvalidArgumentException | [
"Sets",
"cursor",
"fetching",
"mode",
"for",
"next",
"fetch"
] | 8645b71f1cb437a845fcf12ae742655dd874b229 | https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/Result.php#L109-L120 |
9,864 | sndatabase/core | src/Result.php | Result.prefetch | final private function prefetch() {
static $prefetched = false;
if(!$prefetched) {
$prefetched = true;
while($row = $this->doFetch()) $this->prefetched[] = $row;
}
} | php | final private function prefetch() {
static $prefetched = false;
if(!$prefetched) {
$prefetched = true;
while($row = $this->doFetch()) $this->prefetched[] = $row;
}
} | [
"final",
"private",
"function",
"prefetch",
"(",
")",
"{",
"static",
"$",
"prefetched",
"=",
"false",
";",
"if",
"(",
"!",
"$",
"prefetched",
")",
"{",
"$",
"prefetched",
"=",
"true",
";",
"while",
"(",
"$",
"row",
"=",
"$",
"this",
"->",
"doFetch",
"(",
")",
")",
"$",
"this",
"->",
"prefetched",
"[",
"]",
"=",
"$",
"row",
";",
"}",
"}"
] | Prefetch method allows to load in memory all the rows quickly and allows for a faster acces with scrollable possibilities.
@staticvar boolean $prefetched Variable checking if prefetch has already been done. If so, won't be done a second time. | [
"Prefetch",
"method",
"allows",
"to",
"load",
"in",
"memory",
"all",
"the",
"rows",
"quickly",
"and",
"allows",
"for",
"a",
"faster",
"acces",
"with",
"scrollable",
"possibilities",
"."
] | 8645b71f1cb437a845fcf12ae742655dd874b229 | https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/Result.php#L132-L138 |
9,865 | sndatabase/core | src/Result.php | Result.parseFetched | final private function parseFetched(array $row, FetchMode $fetchmode) {
foreach($row as $tag => $value) {
if(isset($this->parameters[$tag])) {
$param =& $this->parameters[$tag]['param'];
$type = $this->parameters[$tag]['type'];
$param = $this->connection->quote($value, $type);
}
}
if($fetchmode->hasMode(DB::FETCH_BOTH)) return array_merge ($row, array_values ($row));
if($fetchmode->hasMode(DB::FETCH_ASSOC)) return $row;
if($fetchmode->hasMode(DB::FETCH_NUM)) return array_values ($row);
if($fetchmode->hasMode(DB::FETCH_COLUMN)) {
$values = array_values($row);
return isset($values[$fetchmode->col]) ? $values[$fetchmode->col] : null;
}
if($fetchmode->hasMode(DB::FETCH_OBJ)) return (object)$row;
if($fetchmode->hasMode(DB::FETCH_CLASS)) {
$classname = $fetchmode->hasMode(DB::FETCH_CLASSTYPE) ? array_shift($row) : $fetchmode->classname;
$refl = new \ReflectionClass($classname);
$obj = $fetchmode->hasMode(DB::FETCH_PROPS_EARLY)
? $refl->newInstanceWithoutConstructor()
: $refl->newInstanceArgs($fetchmode->ctor_args);
$refl = new \ReflectionObject($obj);
foreach($row as $tag => $value) {
if($refl->hasProperty($tag)) $refl->getProperty($tag)->setValue($obj, $value);
else $obj->$tag = $value;
}
if($fetchmode->hasMode(DB::FETCH_PROPS_EARLY))
$refl->getConstructor()->invokeArgs($obj, $fetchmode->ctor_args);
return $obj;
}
if($fetchmode->hasMode(DB::FETCH_INTO)) {
$refl = new \ReflectionObject($fetchmode->obj);
foreach($row as $tag => $value) {
if($refl->hasProperty($tag)) $refl->getProperty($tag)->setValue($obj, $value);
else $obj->$tag = $value;
}
}
} | php | final private function parseFetched(array $row, FetchMode $fetchmode) {
foreach($row as $tag => $value) {
if(isset($this->parameters[$tag])) {
$param =& $this->parameters[$tag]['param'];
$type = $this->parameters[$tag]['type'];
$param = $this->connection->quote($value, $type);
}
}
if($fetchmode->hasMode(DB::FETCH_BOTH)) return array_merge ($row, array_values ($row));
if($fetchmode->hasMode(DB::FETCH_ASSOC)) return $row;
if($fetchmode->hasMode(DB::FETCH_NUM)) return array_values ($row);
if($fetchmode->hasMode(DB::FETCH_COLUMN)) {
$values = array_values($row);
return isset($values[$fetchmode->col]) ? $values[$fetchmode->col] : null;
}
if($fetchmode->hasMode(DB::FETCH_OBJ)) return (object)$row;
if($fetchmode->hasMode(DB::FETCH_CLASS)) {
$classname = $fetchmode->hasMode(DB::FETCH_CLASSTYPE) ? array_shift($row) : $fetchmode->classname;
$refl = new \ReflectionClass($classname);
$obj = $fetchmode->hasMode(DB::FETCH_PROPS_EARLY)
? $refl->newInstanceWithoutConstructor()
: $refl->newInstanceArgs($fetchmode->ctor_args);
$refl = new \ReflectionObject($obj);
foreach($row as $tag => $value) {
if($refl->hasProperty($tag)) $refl->getProperty($tag)->setValue($obj, $value);
else $obj->$tag = $value;
}
if($fetchmode->hasMode(DB::FETCH_PROPS_EARLY))
$refl->getConstructor()->invokeArgs($obj, $fetchmode->ctor_args);
return $obj;
}
if($fetchmode->hasMode(DB::FETCH_INTO)) {
$refl = new \ReflectionObject($fetchmode->obj);
foreach($row as $tag => $value) {
if($refl->hasProperty($tag)) $refl->getProperty($tag)->setValue($obj, $value);
else $obj->$tag = $value;
}
}
} | [
"final",
"private",
"function",
"parseFetched",
"(",
"array",
"$",
"row",
",",
"FetchMode",
"$",
"fetchmode",
")",
"{",
"foreach",
"(",
"$",
"row",
"as",
"$",
"tag",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"parameters",
"[",
"$",
"tag",
"]",
")",
")",
"{",
"$",
"param",
"=",
"&",
"$",
"this",
"->",
"parameters",
"[",
"$",
"tag",
"]",
"[",
"'param'",
"]",
";",
"$",
"type",
"=",
"$",
"this",
"->",
"parameters",
"[",
"$",
"tag",
"]",
"[",
"'type'",
"]",
";",
"$",
"param",
"=",
"$",
"this",
"->",
"connection",
"->",
"quote",
"(",
"$",
"value",
",",
"$",
"type",
")",
";",
"}",
"}",
"if",
"(",
"$",
"fetchmode",
"->",
"hasMode",
"(",
"DB",
"::",
"FETCH_BOTH",
")",
")",
"return",
"array_merge",
"(",
"$",
"row",
",",
"array_values",
"(",
"$",
"row",
")",
")",
";",
"if",
"(",
"$",
"fetchmode",
"->",
"hasMode",
"(",
"DB",
"::",
"FETCH_ASSOC",
")",
")",
"return",
"$",
"row",
";",
"if",
"(",
"$",
"fetchmode",
"->",
"hasMode",
"(",
"DB",
"::",
"FETCH_NUM",
")",
")",
"return",
"array_values",
"(",
"$",
"row",
")",
";",
"if",
"(",
"$",
"fetchmode",
"->",
"hasMode",
"(",
"DB",
"::",
"FETCH_COLUMN",
")",
")",
"{",
"$",
"values",
"=",
"array_values",
"(",
"$",
"row",
")",
";",
"return",
"isset",
"(",
"$",
"values",
"[",
"$",
"fetchmode",
"->",
"col",
"]",
")",
"?",
"$",
"values",
"[",
"$",
"fetchmode",
"->",
"col",
"]",
":",
"null",
";",
"}",
"if",
"(",
"$",
"fetchmode",
"->",
"hasMode",
"(",
"DB",
"::",
"FETCH_OBJ",
")",
")",
"return",
"(",
"object",
")",
"$",
"row",
";",
"if",
"(",
"$",
"fetchmode",
"->",
"hasMode",
"(",
"DB",
"::",
"FETCH_CLASS",
")",
")",
"{",
"$",
"classname",
"=",
"$",
"fetchmode",
"->",
"hasMode",
"(",
"DB",
"::",
"FETCH_CLASSTYPE",
")",
"?",
"array_shift",
"(",
"$",
"row",
")",
":",
"$",
"fetchmode",
"->",
"classname",
";",
"$",
"refl",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"classname",
")",
";",
"$",
"obj",
"=",
"$",
"fetchmode",
"->",
"hasMode",
"(",
"DB",
"::",
"FETCH_PROPS_EARLY",
")",
"?",
"$",
"refl",
"->",
"newInstanceWithoutConstructor",
"(",
")",
":",
"$",
"refl",
"->",
"newInstanceArgs",
"(",
"$",
"fetchmode",
"->",
"ctor_args",
")",
";",
"$",
"refl",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"obj",
")",
";",
"foreach",
"(",
"$",
"row",
"as",
"$",
"tag",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"refl",
"->",
"hasProperty",
"(",
"$",
"tag",
")",
")",
"$",
"refl",
"->",
"getProperty",
"(",
"$",
"tag",
")",
"->",
"setValue",
"(",
"$",
"obj",
",",
"$",
"value",
")",
";",
"else",
"$",
"obj",
"->",
"$",
"tag",
"=",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"fetchmode",
"->",
"hasMode",
"(",
"DB",
"::",
"FETCH_PROPS_EARLY",
")",
")",
"$",
"refl",
"->",
"getConstructor",
"(",
")",
"->",
"invokeArgs",
"(",
"$",
"obj",
",",
"$",
"fetchmode",
"->",
"ctor_args",
")",
";",
"return",
"$",
"obj",
";",
"}",
"if",
"(",
"$",
"fetchmode",
"->",
"hasMode",
"(",
"DB",
"::",
"FETCH_INTO",
")",
")",
"{",
"$",
"refl",
"=",
"new",
"\\",
"ReflectionObject",
"(",
"$",
"fetchmode",
"->",
"obj",
")",
";",
"foreach",
"(",
"$",
"row",
"as",
"$",
"tag",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"refl",
"->",
"hasProperty",
"(",
"$",
"tag",
")",
")",
"$",
"refl",
"->",
"getProperty",
"(",
"$",
"tag",
")",
"->",
"setValue",
"(",
"$",
"obj",
",",
"$",
"value",
")",
";",
"else",
"$",
"obj",
"->",
"$",
"tag",
"=",
"$",
"value",
";",
"}",
"}",
"}"
] | Parse a fetched row, using fetch mode.
This method also populates bound columns.
@param array $row Fetched row to parse
@param FetchMode $fetchmode Fetch mode to use
@return mixed Fetched row, after transformation and parsing based on fetch mode | [
"Parse",
"a",
"fetched",
"row",
"using",
"fetch",
"mode",
".",
"This",
"method",
"also",
"populates",
"bound",
"columns",
"."
] | 8645b71f1cb437a845fcf12ae742655dd874b229 | https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/Result.php#L147-L185 |
9,866 | sndatabase/core | src/Result.php | Result.fetch | public function fetch($mode = null, $complement_info = null, array $ctor_args = array()) {
$fetchmode = is_null($mode) ? $this->fetchMode : new FetchMode($mode, $complement_info, $ctor_args);
/* @var $fetchmode FetchMode */
switch($this->cursorMode) {
case DB::CURSOR_FIRST:
$this->rewind();
break;
case DB::CURSOR_PREV:
$this->prev();
break;
case DB::CURSOR_NEXT:
$this->next();
break;
case DB::CURSOR_LAST:
$this->end();
break;
}
$this->setCursorMode(DB::CURSOR_NEXT);
return $this->valid() ? $this->parseFetched($this->current(), $fetchmode) : false;
} | php | public function fetch($mode = null, $complement_info = null, array $ctor_args = array()) {
$fetchmode = is_null($mode) ? $this->fetchMode : new FetchMode($mode, $complement_info, $ctor_args);
/* @var $fetchmode FetchMode */
switch($this->cursorMode) {
case DB::CURSOR_FIRST:
$this->rewind();
break;
case DB::CURSOR_PREV:
$this->prev();
break;
case DB::CURSOR_NEXT:
$this->next();
break;
case DB::CURSOR_LAST:
$this->end();
break;
}
$this->setCursorMode(DB::CURSOR_NEXT);
return $this->valid() ? $this->parseFetched($this->current(), $fetchmode) : false;
} | [
"public",
"function",
"fetch",
"(",
"$",
"mode",
"=",
"null",
",",
"$",
"complement_info",
"=",
"null",
",",
"array",
"$",
"ctor_args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"fetchmode",
"=",
"is_null",
"(",
"$",
"mode",
")",
"?",
"$",
"this",
"->",
"fetchMode",
":",
"new",
"FetchMode",
"(",
"$",
"mode",
",",
"$",
"complement_info",
",",
"$",
"ctor_args",
")",
";",
"/* @var $fetchmode FetchMode */",
"switch",
"(",
"$",
"this",
"->",
"cursorMode",
")",
"{",
"case",
"DB",
"::",
"CURSOR_FIRST",
":",
"$",
"this",
"->",
"rewind",
"(",
")",
";",
"break",
";",
"case",
"DB",
"::",
"CURSOR_PREV",
":",
"$",
"this",
"->",
"prev",
"(",
")",
";",
"break",
";",
"case",
"DB",
"::",
"CURSOR_NEXT",
":",
"$",
"this",
"->",
"next",
"(",
")",
";",
"break",
";",
"case",
"DB",
"::",
"CURSOR_LAST",
":",
"$",
"this",
"->",
"end",
"(",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"setCursorMode",
"(",
"DB",
"::",
"CURSOR_NEXT",
")",
";",
"return",
"$",
"this",
"->",
"valid",
"(",
")",
"?",
"$",
"this",
"->",
"parseFetched",
"(",
"$",
"this",
"->",
"current",
"(",
")",
",",
"$",
"fetchmode",
")",
":",
"false",
";",
"}"
] | Fetches next row
@param int|null $mode New fetch mode. If null, the result set default fetch mode is used.
@param mixed $complement_info For some fetch modes, additionnal information
@param array $ctor_args For DB::FETCH_CLASS : list of constructor arguments
@return mixed|boolean Fetched row, false if none left.
@see Result::setFetchMode() | [
"Fetches",
"next",
"row"
] | 8645b71f1cb437a845fcf12ae742655dd874b229 | https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/Result.php#L195-L214 |
9,867 | sndatabase/core | src/Result.php | Result.fetchAll | public function fetchAll($mode = null, $complement_info = null, array $ctor_args = array()) {
$fetchmode = is_null($mode) ? $this->fetchMode : new FetchMode($mode, $complement_info, $ctor_args);
/* @var $fetchmode FetchMode */
$rows = array();
foreach($this->prefetched as $row) {
if($fetchmode->hasMode(DB::FETCHALL_KEY_PAIR)) {
$rows[array_shift($row)] = array_shift($row);
} elseif($fetchmode->hasMode(DB::FETCHALL_UNIQUE)) {
$rows[array_shift($row)] = $this->parseFetched($rows, $fetchmode);
} else {
$rows[] = $this->parseFetched($rows, $fetchmode);
}
}
return $rows;
} | php | public function fetchAll($mode = null, $complement_info = null, array $ctor_args = array()) {
$fetchmode = is_null($mode) ? $this->fetchMode : new FetchMode($mode, $complement_info, $ctor_args);
/* @var $fetchmode FetchMode */
$rows = array();
foreach($this->prefetched as $row) {
if($fetchmode->hasMode(DB::FETCHALL_KEY_PAIR)) {
$rows[array_shift($row)] = array_shift($row);
} elseif($fetchmode->hasMode(DB::FETCHALL_UNIQUE)) {
$rows[array_shift($row)] = $this->parseFetched($rows, $fetchmode);
} else {
$rows[] = $this->parseFetched($rows, $fetchmode);
}
}
return $rows;
} | [
"public",
"function",
"fetchAll",
"(",
"$",
"mode",
"=",
"null",
",",
"$",
"complement_info",
"=",
"null",
",",
"array",
"$",
"ctor_args",
"=",
"array",
"(",
")",
")",
"{",
"$",
"fetchmode",
"=",
"is_null",
"(",
"$",
"mode",
")",
"?",
"$",
"this",
"->",
"fetchMode",
":",
"new",
"FetchMode",
"(",
"$",
"mode",
",",
"$",
"complement_info",
",",
"$",
"ctor_args",
")",
";",
"/* @var $fetchmode FetchMode */",
"$",
"rows",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"prefetched",
"as",
"$",
"row",
")",
"{",
"if",
"(",
"$",
"fetchmode",
"->",
"hasMode",
"(",
"DB",
"::",
"FETCHALL_KEY_PAIR",
")",
")",
"{",
"$",
"rows",
"[",
"array_shift",
"(",
"$",
"row",
")",
"]",
"=",
"array_shift",
"(",
"$",
"row",
")",
";",
"}",
"elseif",
"(",
"$",
"fetchmode",
"->",
"hasMode",
"(",
"DB",
"::",
"FETCHALL_UNIQUE",
")",
")",
"{",
"$",
"rows",
"[",
"array_shift",
"(",
"$",
"row",
")",
"]",
"=",
"$",
"this",
"->",
"parseFetched",
"(",
"$",
"rows",
",",
"$",
"fetchmode",
")",
";",
"}",
"else",
"{",
"$",
"rows",
"[",
"]",
"=",
"$",
"this",
"->",
"parseFetched",
"(",
"$",
"rows",
",",
"$",
"fetchmode",
")",
";",
"}",
"}",
"return",
"$",
"rows",
";",
"}"
] | Fetches all found rows as an array
@param int|null $mode Fetch mode to use. If null, will use the result set default fetch mode
@param mixed $complement_info For some fetch modes, additionnal information
@param array $ctor_args For DB::FETCH_CLASS : list of constructor arguments
@return array list of fetched rows
@see Result::setFetchMode | [
"Fetches",
"all",
"found",
"rows",
"as",
"an",
"array"
] | 8645b71f1cb437a845fcf12ae742655dd874b229 | https://github.com/sndatabase/core/blob/8645b71f1cb437a845fcf12ae742655dd874b229/src/Result.php#L224-L238 |
9,868 | dotfilesphp/core | ApplicationFactory.php | ApplicationFactory.loadDirectoryFromAutoloader | private function loadDirectoryFromAutoloader()
{
$spl = spl_autoload_functions();
$dirs = array();
foreach ($spl as $item) {
$object = $item[0];
if (!$object instanceof ClassLoader) {
continue;
}
$temp = array_merge($object->getPrefixes(), $object->getPrefixesPsr4());
foreach ($temp as $name => $dir) {
if (false === strpos($name, 'Dotfiles')) {
continue;
}
foreach ($dir as $num => $path) {
$path = realpath($path);
if ($path && is_dir($path) && !in_array($path, $dirs)) {
$dirs[] = $path;
}
}
}
}
return $dirs;
} | php | private function loadDirectoryFromAutoloader()
{
$spl = spl_autoload_functions();
$dirs = array();
foreach ($spl as $item) {
$object = $item[0];
if (!$object instanceof ClassLoader) {
continue;
}
$temp = array_merge($object->getPrefixes(), $object->getPrefixesPsr4());
foreach ($temp as $name => $dir) {
if (false === strpos($name, 'Dotfiles')) {
continue;
}
foreach ($dir as $num => $path) {
$path = realpath($path);
if ($path && is_dir($path) && !in_array($path, $dirs)) {
$dirs[] = $path;
}
}
}
}
return $dirs;
} | [
"private",
"function",
"loadDirectoryFromAutoloader",
"(",
")",
"{",
"$",
"spl",
"=",
"spl_autoload_functions",
"(",
")",
";",
"$",
"dirs",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"spl",
"as",
"$",
"item",
")",
"{",
"$",
"object",
"=",
"$",
"item",
"[",
"0",
"]",
";",
"if",
"(",
"!",
"$",
"object",
"instanceof",
"ClassLoader",
")",
"{",
"continue",
";",
"}",
"$",
"temp",
"=",
"array_merge",
"(",
"$",
"object",
"->",
"getPrefixes",
"(",
")",
",",
"$",
"object",
"->",
"getPrefixesPsr4",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"temp",
"as",
"$",
"name",
"=>",
"$",
"dir",
")",
"{",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"name",
",",
"'Dotfiles'",
")",
")",
"{",
"continue",
";",
"}",
"foreach",
"(",
"$",
"dir",
"as",
"$",
"num",
"=>",
"$",
"path",
")",
"{",
"$",
"path",
"=",
"realpath",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"path",
"&&",
"is_dir",
"(",
"$",
"path",
")",
"&&",
"!",
"in_array",
"(",
"$",
"path",
",",
"$",
"dirs",
")",
")",
"{",
"$",
"dirs",
"[",
"]",
"=",
"$",
"path",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"dirs",
";",
"}"
] | Load available plugins directory.
@return array | [
"Load",
"available",
"plugins",
"directory",
"."
] | d55e44449cf67e9d56a22863447fd782c88d9b2d | https://github.com/dotfilesphp/core/blob/d55e44449cf67e9d56a22863447fd782c88d9b2d/ApplicationFactory.php#L233-L258 |
9,869 | dotfilesphp/core | ApplicationFactory.php | ApplicationFactory.loadPlugins | private function loadPlugins(): void
{
$finder = Finder::create();
$finder
->name('*Plugin.php')
;
if (is_dir($dir = __DIR__.'/../Plugins')) {
$finder->in(__DIR__.'/../Plugins');
}
$dirs = $this->loadDirectoryFromAutoloader();
$finder->in($dirs);
foreach ($finder->files() as $file) {
$namespace = 'Dotfiles\\Plugins\\'.str_replace('Plugin.php', '', $file->getFileName());
$className = $namespace.'\\'.str_replace('.php', '', $file->getFileName());
if (class_exists($className)) {
/* @var \Dotfiles\Core\Plugin $plugin */
$plugin = new $className();
$this->registerPlugin($plugin);
}
}
} | php | private function loadPlugins(): void
{
$finder = Finder::create();
$finder
->name('*Plugin.php')
;
if (is_dir($dir = __DIR__.'/../Plugins')) {
$finder->in(__DIR__.'/../Plugins');
}
$dirs = $this->loadDirectoryFromAutoloader();
$finder->in($dirs);
foreach ($finder->files() as $file) {
$namespace = 'Dotfiles\\Plugins\\'.str_replace('Plugin.php', '', $file->getFileName());
$className = $namespace.'\\'.str_replace('.php', '', $file->getFileName());
if (class_exists($className)) {
/* @var \Dotfiles\Core\Plugin $plugin */
$plugin = new $className();
$this->registerPlugin($plugin);
}
}
} | [
"private",
"function",
"loadPlugins",
"(",
")",
":",
"void",
"{",
"$",
"finder",
"=",
"Finder",
"::",
"create",
"(",
")",
";",
"$",
"finder",
"->",
"name",
"(",
"'*Plugin.php'",
")",
";",
"if",
"(",
"is_dir",
"(",
"$",
"dir",
"=",
"__DIR__",
".",
"'/../Plugins'",
")",
")",
"{",
"$",
"finder",
"->",
"in",
"(",
"__DIR__",
".",
"'/../Plugins'",
")",
";",
"}",
"$",
"dirs",
"=",
"$",
"this",
"->",
"loadDirectoryFromAutoloader",
"(",
")",
";",
"$",
"finder",
"->",
"in",
"(",
"$",
"dirs",
")",
";",
"foreach",
"(",
"$",
"finder",
"->",
"files",
"(",
")",
"as",
"$",
"file",
")",
"{",
"$",
"namespace",
"=",
"'Dotfiles\\\\Plugins\\\\'",
".",
"str_replace",
"(",
"'Plugin.php'",
",",
"''",
",",
"$",
"file",
"->",
"getFileName",
"(",
")",
")",
";",
"$",
"className",
"=",
"$",
"namespace",
".",
"'\\\\'",
".",
"str_replace",
"(",
"'.php'",
",",
"''",
",",
"$",
"file",
"->",
"getFileName",
"(",
")",
")",
";",
"if",
"(",
"class_exists",
"(",
"$",
"className",
")",
")",
"{",
"/* @var \\Dotfiles\\Core\\Plugin $plugin */",
"$",
"plugin",
"=",
"new",
"$",
"className",
"(",
")",
";",
"$",
"this",
"->",
"registerPlugin",
"(",
"$",
"plugin",
")",
";",
"}",
"}",
"}"
] | Load available plugins. | [
"Load",
"available",
"plugins",
"."
] | d55e44449cf67e9d56a22863447fd782c88d9b2d | https://github.com/dotfilesphp/core/blob/d55e44449cf67e9d56a22863447fd782c88d9b2d/ApplicationFactory.php#L304-L324 |
9,870 | dotfilesphp/core | ApplicationFactory.php | ApplicationFactory.registerPlugin | private function registerPlugin(Plugin $plugin): void
{
if ($this->hasPlugin($plugin->getName())) {
return;
}
$this->plugins[$plugin->getName()] = $plugin;
} | php | private function registerPlugin(Plugin $plugin): void
{
if ($this->hasPlugin($plugin->getName())) {
return;
}
$this->plugins[$plugin->getName()] = $plugin;
} | [
"private",
"function",
"registerPlugin",
"(",
"Plugin",
"$",
"plugin",
")",
":",
"void",
"{",
"if",
"(",
"$",
"this",
"->",
"hasPlugin",
"(",
"$",
"plugin",
"->",
"getName",
"(",
")",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"plugins",
"[",
"$",
"plugin",
"->",
"getName",
"(",
")",
"]",
"=",
"$",
"plugin",
";",
"}"
] | Register plugin.
@param Plugin $plugin | [
"Register",
"plugin",
"."
] | d55e44449cf67e9d56a22863447fd782c88d9b2d | https://github.com/dotfilesphp/core/blob/d55e44449cf67e9d56a22863447fd782c88d9b2d/ApplicationFactory.php#L346-L353 |
9,871 | gossi/trixionary | src/model/Base/VideoQuery.php | VideoQuery.filterByIsTutorial | public function filterByIsTutorial($isTutorial = null, $comparison = null)
{
if (is_string($isTutorial)) {
$isTutorial = in_array(strtolower($isTutorial), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(VideoTableMap::COL_IS_TUTORIAL, $isTutorial, $comparison);
} | php | public function filterByIsTutorial($isTutorial = null, $comparison = null)
{
if (is_string($isTutorial)) {
$isTutorial = in_array(strtolower($isTutorial), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(VideoTableMap::COL_IS_TUTORIAL, $isTutorial, $comparison);
} | [
"public",
"function",
"filterByIsTutorial",
"(",
"$",
"isTutorial",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"isTutorial",
")",
")",
"{",
"$",
"isTutorial",
"=",
"in_array",
"(",
"strtolower",
"(",
"$",
"isTutorial",
")",
",",
"array",
"(",
"'false'",
",",
"'off'",
",",
"'-'",
",",
"'no'",
",",
"'n'",
",",
"'0'",
",",
"''",
")",
")",
"?",
"false",
":",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_IS_TUTORIAL",
",",
"$",
"isTutorial",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the is_tutorial column
Example usage:
<code>
$query->filterByIsTutorial(true); // WHERE is_tutorial = true
$query->filterByIsTutorial('yes'); // WHERE is_tutorial = true
</code>
@param boolean|string $isTutorial The value to use as filter.
Non-boolean arguments are converted using the following rules:
* 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* 0, '0', 'false', 'off', and 'no' are converted to boolean false
Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildVideoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"is_tutorial",
"column"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/VideoQuery.php#L464-L471 |
9,872 | gossi/trixionary | src/model/Base/VideoQuery.php | VideoQuery.filterByAthleteId | public function filterByAthleteId($athleteId = null, $comparison = null)
{
if (is_array($athleteId)) {
$useMinMax = false;
if (isset($athleteId['min'])) {
$this->addUsingAlias(VideoTableMap::COL_ATHLETE_ID, $athleteId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($athleteId['max'])) {
$this->addUsingAlias(VideoTableMap::COL_ATHLETE_ID, $athleteId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(VideoTableMap::COL_ATHLETE_ID, $athleteId, $comparison);
} | php | public function filterByAthleteId($athleteId = null, $comparison = null)
{
if (is_array($athleteId)) {
$useMinMax = false;
if (isset($athleteId['min'])) {
$this->addUsingAlias(VideoTableMap::COL_ATHLETE_ID, $athleteId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($athleteId['max'])) {
$this->addUsingAlias(VideoTableMap::COL_ATHLETE_ID, $athleteId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(VideoTableMap::COL_ATHLETE_ID, $athleteId, $comparison);
} | [
"public",
"function",
"filterByAthleteId",
"(",
"$",
"athleteId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"athleteId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"athleteId",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_ATHLETE_ID",
",",
"$",
"athleteId",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"athleteId",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_ATHLETE_ID",
",",
"$",
"athleteId",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_ATHLETE_ID",
",",
"$",
"athleteId",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the athlete_id column
Example usage:
<code>
$query->filterByAthleteId(1234); // WHERE athlete_id = 1234
$query->filterByAthleteId(array(12, 34)); // WHERE athlete_id IN (12, 34)
$query->filterByAthleteId(array('min' => 12)); // WHERE athlete_id > 12
</code>
@param mixed $athleteId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildVideoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"athlete_id",
"column"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/VideoQuery.php#L520-L541 |
9,873 | gossi/trixionary | src/model/Base/VideoQuery.php | VideoQuery.filterByUploaderId | public function filterByUploaderId($uploaderId = null, $comparison = null)
{
if (is_array($uploaderId)) {
$useMinMax = false;
if (isset($uploaderId['min'])) {
$this->addUsingAlias(VideoTableMap::COL_UPLOADER_ID, $uploaderId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($uploaderId['max'])) {
$this->addUsingAlias(VideoTableMap::COL_UPLOADER_ID, $uploaderId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(VideoTableMap::COL_UPLOADER_ID, $uploaderId, $comparison);
} | php | public function filterByUploaderId($uploaderId = null, $comparison = null)
{
if (is_array($uploaderId)) {
$useMinMax = false;
if (isset($uploaderId['min'])) {
$this->addUsingAlias(VideoTableMap::COL_UPLOADER_ID, $uploaderId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($uploaderId['max'])) {
$this->addUsingAlias(VideoTableMap::COL_UPLOADER_ID, $uploaderId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(VideoTableMap::COL_UPLOADER_ID, $uploaderId, $comparison);
} | [
"public",
"function",
"filterByUploaderId",
"(",
"$",
"uploaderId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"uploaderId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"uploaderId",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_UPLOADER_ID",
",",
"$",
"uploaderId",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"uploaderId",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_UPLOADER_ID",
",",
"$",
"uploaderId",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_UPLOADER_ID",
",",
"$",
"uploaderId",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the uploader_id column
Example usage:
<code>
$query->filterByUploaderId(1234); // WHERE uploader_id = 1234
$query->filterByUploaderId(array(12, 34)); // WHERE uploader_id IN (12, 34)
$query->filterByUploaderId(array('min' => 12)); // WHERE uploader_id > 12
</code>
@param mixed $uploaderId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildVideoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"uploader_id",
"column"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/VideoQuery.php#L561-L582 |
9,874 | gossi/trixionary | src/model/Base/VideoQuery.php | VideoQuery.filterByReferenceId | public function filterByReferenceId($referenceId = null, $comparison = null)
{
if (is_array($referenceId)) {
$useMinMax = false;
if (isset($referenceId['min'])) {
$this->addUsingAlias(VideoTableMap::COL_REFERENCE_ID, $referenceId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($referenceId['max'])) {
$this->addUsingAlias(VideoTableMap::COL_REFERENCE_ID, $referenceId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(VideoTableMap::COL_REFERENCE_ID, $referenceId, $comparison);
} | php | public function filterByReferenceId($referenceId = null, $comparison = null)
{
if (is_array($referenceId)) {
$useMinMax = false;
if (isset($referenceId['min'])) {
$this->addUsingAlias(VideoTableMap::COL_REFERENCE_ID, $referenceId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($referenceId['max'])) {
$this->addUsingAlias(VideoTableMap::COL_REFERENCE_ID, $referenceId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(VideoTableMap::COL_REFERENCE_ID, $referenceId, $comparison);
} | [
"public",
"function",
"filterByReferenceId",
"(",
"$",
"referenceId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"referenceId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"referenceId",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_REFERENCE_ID",
",",
"$",
"referenceId",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"referenceId",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_REFERENCE_ID",
",",
"$",
"referenceId",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_REFERENCE_ID",
",",
"$",
"referenceId",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the reference_id column
Example usage:
<code>
$query->filterByReferenceId(1234); // WHERE reference_id = 1234
$query->filterByReferenceId(array(12, 34)); // WHERE reference_id IN (12, 34)
$query->filterByReferenceId(array('min' => 12)); // WHERE reference_id > 12
</code>
@see filterByReference()
@param mixed $referenceId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildVideoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"reference_id",
"column"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/VideoQuery.php#L647-L668 |
9,875 | gossi/trixionary | src/model/Base/VideoQuery.php | VideoQuery.filterByPosterUrl | public function filterByPosterUrl($posterUrl = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($posterUrl)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $posterUrl)) {
$posterUrl = str_replace('*', '%', $posterUrl);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(VideoTableMap::COL_POSTER_URL, $posterUrl, $comparison);
} | php | public function filterByPosterUrl($posterUrl = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($posterUrl)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $posterUrl)) {
$posterUrl = str_replace('*', '%', $posterUrl);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(VideoTableMap::COL_POSTER_URL, $posterUrl, $comparison);
} | [
"public",
"function",
"filterByPosterUrl",
"(",
"$",
"posterUrl",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"posterUrl",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"posterUrl",
")",
")",
"{",
"$",
"posterUrl",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"posterUrl",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_POSTER_URL",
",",
"$",
"posterUrl",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the poster_url column
Example usage:
<code>
$query->filterByPosterUrl('fooValue'); // WHERE poster_url = 'fooValue'
$query->filterByPosterUrl('%fooValue%'); // WHERE poster_url LIKE '%fooValue%'
</code>
@param string $posterUrl The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildVideoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"poster_url",
"column"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/VideoQuery.php#L685-L697 |
9,876 | gossi/trixionary | src/model/Base/VideoQuery.php | VideoQuery.filterByProvider | public function filterByProvider($provider = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($provider)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $provider)) {
$provider = str_replace('*', '%', $provider);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(VideoTableMap::COL_PROVIDER, $provider, $comparison);
} | php | public function filterByProvider($provider = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($provider)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $provider)) {
$provider = str_replace('*', '%', $provider);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(VideoTableMap::COL_PROVIDER, $provider, $comparison);
} | [
"public",
"function",
"filterByProvider",
"(",
"$",
"provider",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"provider",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"provider",
")",
")",
"{",
"$",
"provider",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"provider",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_PROVIDER",
",",
"$",
"provider",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the provider column
Example usage:
<code>
$query->filterByProvider('fooValue'); // WHERE provider = 'fooValue'
$query->filterByProvider('%fooValue%'); // WHERE provider LIKE '%fooValue%'
</code>
@param string $provider The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildVideoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"provider",
"column"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/VideoQuery.php#L714-L726 |
9,877 | gossi/trixionary | src/model/Base/VideoQuery.php | VideoQuery.filterByProviderId | public function filterByProviderId($providerId = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($providerId)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $providerId)) {
$providerId = str_replace('*', '%', $providerId);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(VideoTableMap::COL_PROVIDER_ID, $providerId, $comparison);
} | php | public function filterByProviderId($providerId = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($providerId)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $providerId)) {
$providerId = str_replace('*', '%', $providerId);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(VideoTableMap::COL_PROVIDER_ID, $providerId, $comparison);
} | [
"public",
"function",
"filterByProviderId",
"(",
"$",
"providerId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"providerId",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"providerId",
")",
")",
"{",
"$",
"providerId",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"providerId",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_PROVIDER_ID",
",",
"$",
"providerId",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the provider_id column
Example usage:
<code>
$query->filterByProviderId('fooValue'); // WHERE provider_id = 'fooValue'
$query->filterByProviderId('%fooValue%'); // WHERE provider_id LIKE '%fooValue%'
</code>
@param string $providerId The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildVideoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"provider_id",
"column"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/VideoQuery.php#L743-L755 |
9,878 | gossi/trixionary | src/model/Base/VideoQuery.php | VideoQuery.filterByPlayerUrl | public function filterByPlayerUrl($playerUrl = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($playerUrl)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $playerUrl)) {
$playerUrl = str_replace('*', '%', $playerUrl);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(VideoTableMap::COL_PLAYER_URL, $playerUrl, $comparison);
} | php | public function filterByPlayerUrl($playerUrl = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($playerUrl)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $playerUrl)) {
$playerUrl = str_replace('*', '%', $playerUrl);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(VideoTableMap::COL_PLAYER_URL, $playerUrl, $comparison);
} | [
"public",
"function",
"filterByPlayerUrl",
"(",
"$",
"playerUrl",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"playerUrl",
")",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"elseif",
"(",
"preg_match",
"(",
"'/[\\%\\*]/'",
",",
"$",
"playerUrl",
")",
")",
"{",
"$",
"playerUrl",
"=",
"str_replace",
"(",
"'*'",
",",
"'%'",
",",
"$",
"playerUrl",
")",
";",
"$",
"comparison",
"=",
"Criteria",
"::",
"LIKE",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_PLAYER_URL",
",",
"$",
"playerUrl",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the player_url column
Example usage:
<code>
$query->filterByPlayerUrl('fooValue'); // WHERE player_url = 'fooValue'
$query->filterByPlayerUrl('%fooValue%'); // WHERE player_url LIKE '%fooValue%'
</code>
@param string $playerUrl The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildVideoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"player_url",
"column"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/VideoQuery.php#L772-L784 |
9,879 | gossi/trixionary | src/model/Base/VideoQuery.php | VideoQuery.filterByWidth | public function filterByWidth($width = null, $comparison = null)
{
if (is_array($width)) {
$useMinMax = false;
if (isset($width['min'])) {
$this->addUsingAlias(VideoTableMap::COL_WIDTH, $width['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($width['max'])) {
$this->addUsingAlias(VideoTableMap::COL_WIDTH, $width['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(VideoTableMap::COL_WIDTH, $width, $comparison);
} | php | public function filterByWidth($width = null, $comparison = null)
{
if (is_array($width)) {
$useMinMax = false;
if (isset($width['min'])) {
$this->addUsingAlias(VideoTableMap::COL_WIDTH, $width['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($width['max'])) {
$this->addUsingAlias(VideoTableMap::COL_WIDTH, $width['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(VideoTableMap::COL_WIDTH, $width, $comparison);
} | [
"public",
"function",
"filterByWidth",
"(",
"$",
"width",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"width",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"width",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_WIDTH",
",",
"$",
"width",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"width",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_WIDTH",
",",
"$",
"width",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_WIDTH",
",",
"$",
"width",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the width column
Example usage:
<code>
$query->filterByWidth(1234); // WHERE width = 1234
$query->filterByWidth(array(12, 34)); // WHERE width IN (12, 34)
$query->filterByWidth(array('min' => 12)); // WHERE width > 12
</code>
@param mixed $width The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildVideoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"width",
"column"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/VideoQuery.php#L804-L825 |
9,880 | gossi/trixionary | src/model/Base/VideoQuery.php | VideoQuery.filterByHeight | public function filterByHeight($height = null, $comparison = null)
{
if (is_array($height)) {
$useMinMax = false;
if (isset($height['min'])) {
$this->addUsingAlias(VideoTableMap::COL_HEIGHT, $height['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($height['max'])) {
$this->addUsingAlias(VideoTableMap::COL_HEIGHT, $height['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(VideoTableMap::COL_HEIGHT, $height, $comparison);
} | php | public function filterByHeight($height = null, $comparison = null)
{
if (is_array($height)) {
$useMinMax = false;
if (isset($height['min'])) {
$this->addUsingAlias(VideoTableMap::COL_HEIGHT, $height['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($height['max'])) {
$this->addUsingAlias(VideoTableMap::COL_HEIGHT, $height['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(VideoTableMap::COL_HEIGHT, $height, $comparison);
} | [
"public",
"function",
"filterByHeight",
"(",
"$",
"height",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"height",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"$",
"height",
"[",
"'min'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_HEIGHT",
",",
"$",
"height",
"[",
"'min'",
"]",
",",
"Criteria",
"::",
"GREATER_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"height",
"[",
"'max'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_HEIGHT",
",",
"$",
"height",
"[",
"'max'",
"]",
",",
"Criteria",
"::",
"LESS_EQUAL",
")",
";",
"$",
"useMinMax",
"=",
"true",
";",
"}",
"if",
"(",
"$",
"useMinMax",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"$",
"comparison",
"=",
"Criteria",
"::",
"IN",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"addUsingAlias",
"(",
"VideoTableMap",
"::",
"COL_HEIGHT",
",",
"$",
"height",
",",
"$",
"comparison",
")",
";",
"}"
] | Filter the query on the height column
Example usage:
<code>
$query->filterByHeight(1234); // WHERE height = 1234
$query->filterByHeight(array(12, 34)); // WHERE height IN (12, 34)
$query->filterByHeight(array('min' => 12)); // WHERE height > 12
</code>
@param mixed $height The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return $this|ChildVideoQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"height",
"column"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/VideoQuery.php#L845-L866 |
9,881 | gossi/trixionary | src/model/Base/VideoQuery.php | VideoQuery.useFeaturedSkillQuery | public function useFeaturedSkillQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinFeaturedSkill($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'FeaturedSkill', '\gossi\trixionary\model\SkillQuery');
} | php | public function useFeaturedSkillQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinFeaturedSkill($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'FeaturedSkill', '\gossi\trixionary\model\SkillQuery');
} | [
"public",
"function",
"useFeaturedSkillQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"LEFT_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinFeaturedSkill",
"(",
"$",
"relationAlias",
",",
"$",
"joinType",
")",
"->",
"useQuery",
"(",
"$",
"relationAlias",
"?",
"$",
"relationAlias",
":",
"'FeaturedSkill'",
",",
"'\\gossi\\trixionary\\model\\SkillQuery'",
")",
";",
"}"
] | Use the FeaturedSkill relation Skill object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \gossi\trixionary\model\SkillQuery A secondary query class using the current class as primary query | [
"Use",
"the",
"FeaturedSkill",
"relation",
"Skill",
"object"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/VideoQuery.php#L1088-L1093 |
9,882 | gossi/trixionary | src/model/Base/VideoQuery.php | VideoQuery.useFeaturedTutorialSkillQuery | public function useFeaturedTutorialSkillQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinFeaturedTutorialSkill($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'FeaturedTutorialSkill', '\gossi\trixionary\model\SkillQuery');
} | php | public function useFeaturedTutorialSkillQuery($relationAlias = null, $joinType = Criteria::LEFT_JOIN)
{
return $this
->joinFeaturedTutorialSkill($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'FeaturedTutorialSkill', '\gossi\trixionary\model\SkillQuery');
} | [
"public",
"function",
"useFeaturedTutorialSkillQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"LEFT_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinFeaturedTutorialSkill",
"(",
"$",
"relationAlias",
",",
"$",
"joinType",
")",
"->",
"useQuery",
"(",
"$",
"relationAlias",
"?",
"$",
"relationAlias",
":",
"'FeaturedTutorialSkill'",
",",
"'\\gossi\\trixionary\\model\\SkillQuery'",
")",
";",
"}"
] | Use the FeaturedTutorialSkill relation Skill object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \gossi\trixionary\model\SkillQuery A secondary query class using the current class as primary query | [
"Use",
"the",
"FeaturedTutorialSkill",
"relation",
"Skill",
"object"
] | 221a6c5322473d7d7f8e322958a3ee46d87da150 | https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/VideoQuery.php#L1161-L1166 |
9,883 | WellCommerce/DataSet | Pagination/DataSetPagination.php | DataSetPagination.getPages | protected function getPages($totalPages, $currentPage)
{
$range = range(1, $totalPages);
$pages = [];
foreach ($range as $page) {
$pages[] = [
'number' => $page,
'active' => (int)$page === (int)$currentPage
];
}
return $pages;
} | php | protected function getPages($totalPages, $currentPage)
{
$range = range(1, $totalPages);
$pages = [];
foreach ($range as $page) {
$pages[] = [
'number' => $page,
'active' => (int)$page === (int)$currentPage
];
}
return $pages;
} | [
"protected",
"function",
"getPages",
"(",
"$",
"totalPages",
",",
"$",
"currentPage",
")",
"{",
"$",
"range",
"=",
"range",
"(",
"1",
",",
"$",
"totalPages",
")",
";",
"$",
"pages",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"range",
"as",
"$",
"page",
")",
"{",
"$",
"pages",
"[",
"]",
"=",
"[",
"'number'",
"=>",
"$",
"page",
",",
"'active'",
"=>",
"(",
"int",
")",
"$",
"page",
"===",
"(",
"int",
")",
"$",
"currentPage",
"]",
";",
"}",
"return",
"$",
"pages",
";",
"}"
] | Returns an array containing all page numbers
@param int $totalPages
@param int $currentPage
@return array | [
"Returns",
"an",
"array",
"containing",
"all",
"page",
"numbers"
] | 18720dc5416f245d22c502ceafce1a1b2db2b905 | https://github.com/WellCommerce/DataSet/blob/18720dc5416f245d22c502ceafce1a1b2db2b905/Pagination/DataSetPagination.php#L81-L93 |
9,884 | WellCommerce/DataSet | Pagination/DataSetPagination.php | DataSetPagination.getNextPage | protected function getNextPage($totalPages, $offset, $limit)
{
$nextPage = ($offset / $limit) + 2;
if ($nextPage > $totalPages) {
return null;
}
return $nextPage;
} | php | protected function getNextPage($totalPages, $offset, $limit)
{
$nextPage = ($offset / $limit) + 2;
if ($nextPage > $totalPages) {
return null;
}
return $nextPage;
} | [
"protected",
"function",
"getNextPage",
"(",
"$",
"totalPages",
",",
"$",
"offset",
",",
"$",
"limit",
")",
"{",
"$",
"nextPage",
"=",
"(",
"$",
"offset",
"/",
"$",
"limit",
")",
"+",
"2",
";",
"if",
"(",
"$",
"nextPage",
">",
"$",
"totalPages",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"nextPage",
";",
"}"
] | Returns the next page or false if last page
@param int $totalPages
@param int $offset
@param int $limit
@return null|int | [
"Returns",
"the",
"next",
"page",
"or",
"false",
"if",
"last",
"page"
] | 18720dc5416f245d22c502ceafce1a1b2db2b905 | https://github.com/WellCommerce/DataSet/blob/18720dc5416f245d22c502ceafce1a1b2db2b905/Pagination/DataSetPagination.php#L104-L112 |
9,885 | gmo/cache | src/DoctrineProxy.php | DoctrineProxy.set | public function set($key, $value, $expiration = 0)
{
$this->cache->save($key, $value, $expiration);
} | php | public function set($key, $value, $expiration = 0)
{
$this->cache->save($key, $value, $expiration);
} | [
"public",
"function",
"set",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expiration",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"cache",
"->",
"save",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"expiration",
")",
";",
"}"
] | Puts data into cache.
@param string $key
@param mixed $value
@param int $expiration Sets a specific lifetime for this cache entry (0 => infinite lifeTime). | [
"Puts",
"data",
"into",
"cache",
"."
] | c42ba5571bc0e2fca47c98e4e05e96e44dcd9bfd | https://github.com/gmo/cache/blob/c42ba5571bc0e2fca47c98e4e05e96e44dcd9bfd/src/DoctrineProxy.php#L49-L52 |
9,886 | gmo/cache | src/DoctrineProxy.php | DoctrineProxy.increment | public function increment($key, $value = 1, $expiration = 0)
{
$new = intval($this->get($key));
$new += $value;
$this->set($key, $new, $expiration);
} | php | public function increment($key, $value = 1, $expiration = 0)
{
$new = intval($this->get($key));
$new += $value;
$this->set($key, $new, $expiration);
} | [
"public",
"function",
"increment",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"1",
",",
"$",
"expiration",
"=",
"0",
")",
"{",
"$",
"new",
"=",
"intval",
"(",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
")",
";",
"$",
"new",
"+=",
"$",
"value",
";",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"new",
",",
"$",
"expiration",
")",
";",
"}"
] | Increment a key.
Note: This is not atomic. It is faked in PHP.
@param string $key
@param int $value
@param int $expiration | [
"Increment",
"a",
"key",
"."
] | c42ba5571bc0e2fca47c98e4e05e96e44dcd9bfd | https://github.com/gmo/cache/blob/c42ba5571bc0e2fca47c98e4e05e96e44dcd9bfd/src/DoctrineProxy.php#L88-L93 |
9,887 | gmo/cache | src/DoctrineProxy.php | DoctrineProxy.decrement | public function decrement($key, $value = 1, $expiration = 0)
{
$new = intval($this->get($key));
$new -= $value;
$this->set($key, $new, $expiration);
} | php | public function decrement($key, $value = 1, $expiration = 0)
{
$new = intval($this->get($key));
$new -= $value;
$this->set($key, $new, $expiration);
} | [
"public",
"function",
"decrement",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"1",
",",
"$",
"expiration",
"=",
"0",
")",
"{",
"$",
"new",
"=",
"intval",
"(",
"$",
"this",
"->",
"get",
"(",
"$",
"key",
")",
")",
";",
"$",
"new",
"-=",
"$",
"value",
";",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"new",
",",
"$",
"expiration",
")",
";",
"}"
] | Decrement a key.
Note: This is not atomic. It is faked in PHP.
@param string $key
@param int $value
@param int $expiration | [
"Decrement",
"a",
"key",
"."
] | c42ba5571bc0e2fca47c98e4e05e96e44dcd9bfd | https://github.com/gmo/cache/blob/c42ba5571bc0e2fca47c98e4e05e96e44dcd9bfd/src/DoctrineProxy.php#L104-L109 |
9,888 | DatingVIP/IRC | src/DatingVIP/IRC/Connection.php | Connection.recv | protected function recv() {
if (($line = fgets($this->handle)) &&
($line = trim($line))) {
if ($this->logger) {
$this->logger
->onReceive($line);
}
return $line;
}
throw new \RuntimeException(
"failed to receive data from {$this->server}");
} | php | protected function recv() {
if (($line = fgets($this->handle)) &&
($line = trim($line))) {
if ($this->logger) {
$this->logger
->onReceive($line);
}
return $line;
}
throw new \RuntimeException(
"failed to receive data from {$this->server}");
} | [
"protected",
"function",
"recv",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"line",
"=",
"fgets",
"(",
"$",
"this",
"->",
"handle",
")",
")",
"&&",
"(",
"$",
"line",
"=",
"trim",
"(",
"$",
"line",
")",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"logger",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"onReceive",
"(",
"$",
"line",
")",
";",
"}",
"return",
"$",
"line",
";",
"}",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"failed to receive data from {$this->server}\"",
")",
";",
"}"
] | Recv response from server
@return string
@throws \RuntimeException
@access synchronized | [
"Recv",
"response",
"from",
"server"
] | c09add1317210cd772529146fc617130db957c16 | https://github.com/DatingVIP/IRC/blob/c09add1317210cd772529146fc617130db957c16/src/DatingVIP/IRC/Connection.php#L69-L82 |
9,889 | vinala/kernel | src/Http/Input.php | Input.register | public static function register()
{
self::$list = [];
//
self::$list['post'] = !isset($_POST) ?: $_POST;
self::$list['get'] = !isset($_GET) ?: $_GET;
self::$list['session'] = !isset($_SESSION) ?: $_SESSION;
self::$list['cookie'] = !isset($_COOKIE) ?: $_COOKIE;
self::$list['files'] = !isset($_FILES) ?: $_FILES;
self::$list['server'] = !isset($_SERVER) ?: $_SERVER;
self::$list['env'] = !isset($_ENV) ?: $_ENV;
self::$list['request'] = !isset($_REQUEST) ?: $_REQUEST;
//
return self::$list;
} | php | public static function register()
{
self::$list = [];
//
self::$list['post'] = !isset($_POST) ?: $_POST;
self::$list['get'] = !isset($_GET) ?: $_GET;
self::$list['session'] = !isset($_SESSION) ?: $_SESSION;
self::$list['cookie'] = !isset($_COOKIE) ?: $_COOKIE;
self::$list['files'] = !isset($_FILES) ?: $_FILES;
self::$list['server'] = !isset($_SERVER) ?: $_SERVER;
self::$list['env'] = !isset($_ENV) ?: $_ENV;
self::$list['request'] = !isset($_REQUEST) ?: $_REQUEST;
//
return self::$list;
} | [
"public",
"static",
"function",
"register",
"(",
")",
"{",
"self",
"::",
"$",
"list",
"=",
"[",
"]",
";",
"//",
"self",
"::",
"$",
"list",
"[",
"'post'",
"]",
"=",
"!",
"isset",
"(",
"$",
"_POST",
")",
"?",
":",
"$",
"_POST",
";",
"self",
"::",
"$",
"list",
"[",
"'get'",
"]",
"=",
"!",
"isset",
"(",
"$",
"_GET",
")",
"?",
":",
"$",
"_GET",
";",
"self",
"::",
"$",
"list",
"[",
"'session'",
"]",
"=",
"!",
"isset",
"(",
"$",
"_SESSION",
")",
"?",
":",
"$",
"_SESSION",
";",
"self",
"::",
"$",
"list",
"[",
"'cookie'",
"]",
"=",
"!",
"isset",
"(",
"$",
"_COOKIE",
")",
"?",
":",
"$",
"_COOKIE",
";",
"self",
"::",
"$",
"list",
"[",
"'files'",
"]",
"=",
"!",
"isset",
"(",
"$",
"_FILES",
")",
"?",
":",
"$",
"_FILES",
";",
"self",
"::",
"$",
"list",
"[",
"'server'",
"]",
"=",
"!",
"isset",
"(",
"$",
"_SERVER",
")",
"?",
":",
"$",
"_SERVER",
";",
"self",
"::",
"$",
"list",
"[",
"'env'",
"]",
"=",
"!",
"isset",
"(",
"$",
"_ENV",
")",
"?",
":",
"$",
"_ENV",
";",
"self",
"::",
"$",
"list",
"[",
"'request'",
"]",
"=",
"!",
"isset",
"(",
"$",
"_REQUEST",
")",
"?",
":",
"$",
"_REQUEST",
";",
"//",
"return",
"self",
"::",
"$",
"list",
";",
"}"
] | regsiter all http input vars.
@return array | [
"regsiter",
"all",
"http",
"input",
"vars",
"."
] | 346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a | https://github.com/vinala/kernel/blob/346c8a4dca48fd1ab88fdc9f7004ecb7bce6a67a/src/Http/Input.php#L22-L36 |
9,890 | adrenalinkin/entity-helper-bundle | Helper/EntityHelper.php | EntityHelper.createEntity | public function createEntity($className, array $fields = [])
{
$metadata = $this->getEntityMetadata($className);
if (is_null($metadata)) {
return null;
}
$reflection = $metadata->getReflectionClass();
try {
$entity = $reflection->newInstance();
} catch (\Exception $e) {
$entity = $reflection->newInstanceWithoutConstructor();
}
foreach ($fields as $fieldName => $fieldValue) {
if (self::IDENTITY === $fieldName) {
$property = $reflection->getProperty($this->getEntityIdName($className));
} else {
$property = $reflection->getProperty($fieldName);
}
try {
$property->setValue($entity, $fieldValue);
} catch (\Exception $e) {
$property->setAccessible(true);
$property->setValue($entity, $fieldValue);
$property->setAccessible(false);
}
}
return $entity;
} | php | public function createEntity($className, array $fields = [])
{
$metadata = $this->getEntityMetadata($className);
if (is_null($metadata)) {
return null;
}
$reflection = $metadata->getReflectionClass();
try {
$entity = $reflection->newInstance();
} catch (\Exception $e) {
$entity = $reflection->newInstanceWithoutConstructor();
}
foreach ($fields as $fieldName => $fieldValue) {
if (self::IDENTITY === $fieldName) {
$property = $reflection->getProperty($this->getEntityIdName($className));
} else {
$property = $reflection->getProperty($fieldName);
}
try {
$property->setValue($entity, $fieldValue);
} catch (\Exception $e) {
$property->setAccessible(true);
$property->setValue($entity, $fieldValue);
$property->setAccessible(false);
}
}
return $entity;
} | [
"public",
"function",
"createEntity",
"(",
"$",
"className",
",",
"array",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"getEntityMetadata",
"(",
"$",
"className",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"metadata",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"reflection",
"=",
"$",
"metadata",
"->",
"getReflectionClass",
"(",
")",
";",
"try",
"{",
"$",
"entity",
"=",
"$",
"reflection",
"->",
"newInstance",
"(",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"entity",
"=",
"$",
"reflection",
"->",
"newInstanceWithoutConstructor",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"fieldName",
"=>",
"$",
"fieldValue",
")",
"{",
"if",
"(",
"self",
"::",
"IDENTITY",
"===",
"$",
"fieldName",
")",
"{",
"$",
"property",
"=",
"$",
"reflection",
"->",
"getProperty",
"(",
"$",
"this",
"->",
"getEntityIdName",
"(",
"$",
"className",
")",
")",
";",
"}",
"else",
"{",
"$",
"property",
"=",
"$",
"reflection",
"->",
"getProperty",
"(",
"$",
"fieldName",
")",
";",
"}",
"try",
"{",
"$",
"property",
"->",
"setValue",
"(",
"$",
"entity",
",",
"$",
"fieldValue",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"property",
"->",
"setAccessible",
"(",
"true",
")",
";",
"$",
"property",
"->",
"setValue",
"(",
"$",
"entity",
",",
"$",
"fieldValue",
")",
";",
"$",
"property",
"->",
"setAccessible",
"(",
"false",
")",
";",
"}",
"}",
"return",
"$",
"entity",
";",
"}"
] | Create instance of the class, which managed by Doctrine, by received class name
@param string $className
@param array $fields
@return object|null | [
"Create",
"instance",
"of",
"the",
"class",
"which",
"managed",
"by",
"Doctrine",
"by",
"received",
"class",
"name"
] | 92ef8e87e59e2ef1dff29969ace9a6430d9d007a | https://github.com/adrenalinkin/entity-helper-bundle/blob/92ef8e87e59e2ef1dff29969ace9a6430d9d007a/Helper/EntityHelper.php#L62-L95 |
9,891 | adrenalinkin/entity-helper-bundle | Helper/EntityHelper.php | EntityHelper.getEntityClassFull | public function getEntityClassFull($entity)
{
$entity = $this->toString($entity);
if (isset($this->cache[$entity])) {
return $entity;
}
if ($this->managed || $this->isManagedByDoctrine($entity)) {
/** @var \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetaData */
$classMetaData = $this->entityManager->getClassMetadata($entity);
$entity = $classMetaData->getName();
$this->cache[$entity] = ['metadata' => $classMetaData];
$this->managed = false;
} else {
$this->cache[$entity] = [];
}
return $entity;
} | php | public function getEntityClassFull($entity)
{
$entity = $this->toString($entity);
if (isset($this->cache[$entity])) {
return $entity;
}
if ($this->managed || $this->isManagedByDoctrine($entity)) {
/** @var \Doctrine\Common\Persistence\Mapping\ClassMetadata $classMetaData */
$classMetaData = $this->entityManager->getClassMetadata($entity);
$entity = $classMetaData->getName();
$this->cache[$entity] = ['metadata' => $classMetaData];
$this->managed = false;
} else {
$this->cache[$entity] = [];
}
return $entity;
} | [
"public",
"function",
"getEntityClassFull",
"(",
"$",
"entity",
")",
"{",
"$",
"entity",
"=",
"$",
"this",
"->",
"toString",
"(",
"$",
"entity",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"entity",
"]",
")",
")",
"{",
"return",
"$",
"entity",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"managed",
"||",
"$",
"this",
"->",
"isManagedByDoctrine",
"(",
"$",
"entity",
")",
")",
"{",
"/** @var \\Doctrine\\Common\\Persistence\\Mapping\\ClassMetadata $classMetaData */",
"$",
"classMetaData",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getClassMetadata",
"(",
"$",
"entity",
")",
";",
"$",
"entity",
"=",
"$",
"classMetaData",
"->",
"getName",
"(",
")",
";",
"$",
"this",
"->",
"cache",
"[",
"$",
"entity",
"]",
"=",
"[",
"'metadata'",
"=>",
"$",
"classMetaData",
"]",
";",
"$",
"this",
"->",
"managed",
"=",
"false",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"cache",
"[",
"$",
"entity",
"]",
"=",
"[",
"]",
";",
"}",
"return",
"$",
"entity",
";",
"}"
] | Returns full name of the received entity or class name.
@param object|string $entity Entity object or just entity name in the full or shot notation
@return string For example 'AcmeBundle\Entity\User' | [
"Returns",
"full",
"name",
"of",
"the",
"received",
"entity",
"or",
"class",
"name",
"."
] | 92ef8e87e59e2ef1dff29969ace9a6430d9d007a | https://github.com/adrenalinkin/entity-helper-bundle/blob/92ef8e87e59e2ef1dff29969ace9a6430d9d007a/Helper/EntityHelper.php#L104-L123 |
9,892 | adrenalinkin/entity-helper-bundle | Helper/EntityHelper.php | EntityHelper.getEntityClassShort | public function getEntityClassShort($entity)
{
$cacheKey = 'short';
$entity = $this->getEntityClassFull($entity);
$short = $this->getFromCache($entity, $cacheKey);
if (false !== $short) {
return $short;
}
foreach ($this->entityManager->getConfiguration()->getEntityNamespaces() as $short => $full) {
if (false === strpos($entity, $full)) {
continue;
}
$short .= ':'.ltrim(str_replace($full, '', $entity), '\\');
$this->cache[$full][$cacheKey] = $short;
return $short;
}
return $entity;
} | php | public function getEntityClassShort($entity)
{
$cacheKey = 'short';
$entity = $this->getEntityClassFull($entity);
$short = $this->getFromCache($entity, $cacheKey);
if (false !== $short) {
return $short;
}
foreach ($this->entityManager->getConfiguration()->getEntityNamespaces() as $short => $full) {
if (false === strpos($entity, $full)) {
continue;
}
$short .= ':'.ltrim(str_replace($full, '', $entity), '\\');
$this->cache[$full][$cacheKey] = $short;
return $short;
}
return $entity;
} | [
"public",
"function",
"getEntityClassShort",
"(",
"$",
"entity",
")",
"{",
"$",
"cacheKey",
"=",
"'short'",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"getEntityClassFull",
"(",
"$",
"entity",
")",
";",
"$",
"short",
"=",
"$",
"this",
"->",
"getFromCache",
"(",
"$",
"entity",
",",
"$",
"cacheKey",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"short",
")",
"{",
"return",
"$",
"short",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"entityManager",
"->",
"getConfiguration",
"(",
")",
"->",
"getEntityNamespaces",
"(",
")",
"as",
"$",
"short",
"=>",
"$",
"full",
")",
"{",
"if",
"(",
"false",
"===",
"strpos",
"(",
"$",
"entity",
",",
"$",
"full",
")",
")",
"{",
"continue",
";",
"}",
"$",
"short",
".=",
"':'",
".",
"ltrim",
"(",
"str_replace",
"(",
"$",
"full",
",",
"''",
",",
"$",
"entity",
")",
",",
"'\\\\'",
")",
";",
"$",
"this",
"->",
"cache",
"[",
"$",
"full",
"]",
"[",
"$",
"cacheKey",
"]",
"=",
"$",
"short",
";",
"return",
"$",
"short",
";",
"}",
"return",
"$",
"entity",
";",
"}"
] | Returns short name of the received entity or class name.
@param string|object $entity Entity object or just entity name in the full or shot notation
@return string For example 'AcmeBundle:User' | [
"Returns",
"short",
"name",
"of",
"the",
"received",
"entity",
"or",
"class",
"name",
"."
] | 92ef8e87e59e2ef1dff29969ace9a6430d9d007a | https://github.com/adrenalinkin/entity-helper-bundle/blob/92ef8e87e59e2ef1dff29969ace9a6430d9d007a/Helper/EntityHelper.php#L132-L154 |
9,893 | adrenalinkin/entity-helper-bundle | Helper/EntityHelper.php | EntityHelper.getEntityMetadata | public function getEntityMetadata($entity)
{
if (!$this->isManagedByDoctrine($entity)) {
return null;
}
$cacheKey = 'metadata';
$entity = $this->getEntityClassFull($entity);
$metadata = $this->getFromCache($entity, $cacheKey);
if (false !== $metadata) {
return $metadata;
}
$metadata = $this->entityManager->getClassMetadata($entity);
$this->cache[$metadata->getName()][$cacheKey] = $metadata;
return $metadata;
} | php | public function getEntityMetadata($entity)
{
if (!$this->isManagedByDoctrine($entity)) {
return null;
}
$cacheKey = 'metadata';
$entity = $this->getEntityClassFull($entity);
$metadata = $this->getFromCache($entity, $cacheKey);
if (false !== $metadata) {
return $metadata;
}
$metadata = $this->entityManager->getClassMetadata($entity);
$this->cache[$metadata->getName()][$cacheKey] = $metadata;
return $metadata;
} | [
"public",
"function",
"getEntityMetadata",
"(",
"$",
"entity",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isManagedByDoctrine",
"(",
"$",
"entity",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"cacheKey",
"=",
"'metadata'",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"getEntityClassFull",
"(",
"$",
"entity",
")",
";",
"$",
"metadata",
"=",
"$",
"this",
"->",
"getFromCache",
"(",
"$",
"entity",
",",
"$",
"cacheKey",
")",
";",
"if",
"(",
"false",
"!==",
"$",
"metadata",
")",
"{",
"return",
"$",
"metadata",
";",
"}",
"$",
"metadata",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getClassMetadata",
"(",
"$",
"entity",
")",
";",
"$",
"this",
"->",
"cache",
"[",
"$",
"metadata",
"->",
"getName",
"(",
")",
"]",
"[",
"$",
"cacheKey",
"]",
"=",
"$",
"metadata",
";",
"return",
"$",
"metadata",
";",
"}"
] | Returns ClassMetadata object for received entity
@param string|object $entity Entity object or just entity name in the full or shot notation
@return \Doctrine\ORM\Mapping\ClassMetadata|null | [
"Returns",
"ClassMetadata",
"object",
"for",
"received",
"entity"
] | 92ef8e87e59e2ef1dff29969ace9a6430d9d007a | https://github.com/adrenalinkin/entity-helper-bundle/blob/92ef8e87e59e2ef1dff29969ace9a6430d9d007a/Helper/EntityHelper.php#L221-L239 |
9,894 | adrenalinkin/entity-helper-bundle | Helper/EntityHelper.php | EntityHelper.isManagedByDoctrine | public function isManagedByDoctrine($entity)
{
$cacheKey = 'managed';
$entity = $this->toString($entity);
$isManaged = $this->getFromCache($entity, $cacheKey, null);
if (null !== $isManaged) {
return $isManaged;
}
try {
$this->managed = $isManaged = (bool) $this->entityManager->getReference($entity, 0);
$entity = $this->getEntityClassFull($entity);
} catch (\Exception $e) {
$isManaged = false;
}
$this->cache[$entity][$cacheKey] = $isManaged;
return $isManaged;
} | php | public function isManagedByDoctrine($entity)
{
$cacheKey = 'managed';
$entity = $this->toString($entity);
$isManaged = $this->getFromCache($entity, $cacheKey, null);
if (null !== $isManaged) {
return $isManaged;
}
try {
$this->managed = $isManaged = (bool) $this->entityManager->getReference($entity, 0);
$entity = $this->getEntityClassFull($entity);
} catch (\Exception $e) {
$isManaged = false;
}
$this->cache[$entity][$cacheKey] = $isManaged;
return $isManaged;
} | [
"public",
"function",
"isManagedByDoctrine",
"(",
"$",
"entity",
")",
"{",
"$",
"cacheKey",
"=",
"'managed'",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"toString",
"(",
"$",
"entity",
")",
";",
"$",
"isManaged",
"=",
"$",
"this",
"->",
"getFromCache",
"(",
"$",
"entity",
",",
"$",
"cacheKey",
",",
"null",
")",
";",
"if",
"(",
"null",
"!==",
"$",
"isManaged",
")",
"{",
"return",
"$",
"isManaged",
";",
"}",
"try",
"{",
"$",
"this",
"->",
"managed",
"=",
"$",
"isManaged",
"=",
"(",
"bool",
")",
"$",
"this",
"->",
"entityManager",
"->",
"getReference",
"(",
"$",
"entity",
",",
"0",
")",
";",
"$",
"entity",
"=",
"$",
"this",
"->",
"getEntityClassFull",
"(",
"$",
"entity",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"$",
"isManaged",
"=",
"false",
";",
"}",
"$",
"this",
"->",
"cache",
"[",
"$",
"entity",
"]",
"[",
"$",
"cacheKey",
"]",
"=",
"$",
"isManaged",
";",
"return",
"$",
"isManaged",
";",
"}"
] | Returns is received entity managed by doctrine or not
@param object|string $entity Entity object or just entity name in the full or shot notation
@return bool | [
"Returns",
"is",
"received",
"entity",
"managed",
"by",
"doctrine",
"or",
"not"
] | 92ef8e87e59e2ef1dff29969ace9a6430d9d007a | https://github.com/adrenalinkin/entity-helper-bundle/blob/92ef8e87e59e2ef1dff29969ace9a6430d9d007a/Helper/EntityHelper.php#L248-L268 |
9,895 | adrenalinkin/entity-helper-bundle | Helper/EntityHelper.php | EntityHelper.getFromCache | private function getFromCache($className, $property, $default = false)
{
return empty($this->cache[$className][$property]) ? $default : $this->cache[$className][$property];
} | php | private function getFromCache($className, $property, $default = false)
{
return empty($this->cache[$className][$property]) ? $default : $this->cache[$className][$property];
} | [
"private",
"function",
"getFromCache",
"(",
"$",
"className",
",",
"$",
"property",
",",
"$",
"default",
"=",
"false",
")",
"{",
"return",
"empty",
"(",
"$",
"this",
"->",
"cache",
"[",
"$",
"className",
"]",
"[",
"$",
"property",
"]",
")",
"?",
"$",
"default",
":",
"$",
"this",
"->",
"cache",
"[",
"$",
"className",
"]",
"[",
"$",
"property",
"]",
";",
"}"
] | Returns appropriated property value form the local cache if exists. Otherwise return default value.
@param string $className Entity entity class name in the FULL notation only
@param string $property Name of the property
@param bool|mixed $default Value which should be return be default when requested data
does not found in the cache
@return mixed | [
"Returns",
"appropriated",
"property",
"value",
"form",
"the",
"local",
"cache",
"if",
"exists",
".",
"Otherwise",
"return",
"default",
"value",
"."
] | 92ef8e87e59e2ef1dff29969ace9a6430d9d007a | https://github.com/adrenalinkin/entity-helper-bundle/blob/92ef8e87e59e2ef1dff29969ace9a6430d9d007a/Helper/EntityHelper.php#L280-L283 |
9,896 | liverbool/dos-resource-bundle | Templating/PageBuilder.php | PageBuilder.setOptions | public function setOptions(array $options = array())
{
$options['inited'] = true;
// Resolve merged options
$resolver = new OptionsResolver();
$this->configureOptions($resolver);
$options = $resolver->resolve($options);
$this->options = array_merge($this->options, $options);
if (empty($this->options['blocks']['header'])) {
$this->options['header'] = false;
}
if (!$this->options['header']) {
$this->options['css'] = trim($this->options['css'].' no page header');
}
if (isset($options['keywords'])) {
$this->options['metas']['keywords'] = $options['keywords'];
}
if (isset($options['description'])) {
$this->options['metas']['description'] = $options['description'];
}
if ($seo = $this->seoPage) {
$seo->setTitle($this->options['title']);
$seo->addHtmlAttributes('lang', $this->options['locale']);
if ($this->options['canonical']) {
$seo->setLinkCanonical($this->options['canonical']);
}
foreach ($this->options['metas'] as $key => $value) {
if (is_array($value)) {
foreach ($value as $k => $v) {
$seo->addMeta('property', $k, $v);
}
} else {
$seo->addMeta('name', $key, $value);
}
}
}
} | php | public function setOptions(array $options = array())
{
$options['inited'] = true;
// Resolve merged options
$resolver = new OptionsResolver();
$this->configureOptions($resolver);
$options = $resolver->resolve($options);
$this->options = array_merge($this->options, $options);
if (empty($this->options['blocks']['header'])) {
$this->options['header'] = false;
}
if (!$this->options['header']) {
$this->options['css'] = trim($this->options['css'].' no page header');
}
if (isset($options['keywords'])) {
$this->options['metas']['keywords'] = $options['keywords'];
}
if (isset($options['description'])) {
$this->options['metas']['description'] = $options['description'];
}
if ($seo = $this->seoPage) {
$seo->setTitle($this->options['title']);
$seo->addHtmlAttributes('lang', $this->options['locale']);
if ($this->options['canonical']) {
$seo->setLinkCanonical($this->options['canonical']);
}
foreach ($this->options['metas'] as $key => $value) {
if (is_array($value)) {
foreach ($value as $k => $v) {
$seo->addMeta('property', $k, $v);
}
} else {
$seo->addMeta('name', $key, $value);
}
}
}
} | [
"public",
"function",
"setOptions",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"[",
"'inited'",
"]",
"=",
"true",
";",
"// Resolve merged options",
"$",
"resolver",
"=",
"new",
"OptionsResolver",
"(",
")",
";",
"$",
"this",
"->",
"configureOptions",
"(",
"$",
"resolver",
")",
";",
"$",
"options",
"=",
"$",
"resolver",
"->",
"resolve",
"(",
"$",
"options",
")",
";",
"$",
"this",
"->",
"options",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"options",
",",
"$",
"options",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"options",
"[",
"'blocks'",
"]",
"[",
"'header'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'header'",
"]",
"=",
"false",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"options",
"[",
"'header'",
"]",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'css'",
"]",
"=",
"trim",
"(",
"$",
"this",
"->",
"options",
"[",
"'css'",
"]",
".",
"' no page header'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'keywords'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'metas'",
"]",
"[",
"'keywords'",
"]",
"=",
"$",
"options",
"[",
"'keywords'",
"]",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"options",
"[",
"'description'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"options",
"[",
"'metas'",
"]",
"[",
"'description'",
"]",
"=",
"$",
"options",
"[",
"'description'",
"]",
";",
"}",
"if",
"(",
"$",
"seo",
"=",
"$",
"this",
"->",
"seoPage",
")",
"{",
"$",
"seo",
"->",
"setTitle",
"(",
"$",
"this",
"->",
"options",
"[",
"'title'",
"]",
")",
";",
"$",
"seo",
"->",
"addHtmlAttributes",
"(",
"'lang'",
",",
"$",
"this",
"->",
"options",
"[",
"'locale'",
"]",
")",
";",
"if",
"(",
"$",
"this",
"->",
"options",
"[",
"'canonical'",
"]",
")",
"{",
"$",
"seo",
"->",
"setLinkCanonical",
"(",
"$",
"this",
"->",
"options",
"[",
"'canonical'",
"]",
")",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"options",
"[",
"'metas'",
"]",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"seo",
"->",
"addMeta",
"(",
"'property'",
",",
"$",
"k",
",",
"$",
"v",
")",
";",
"}",
"}",
"else",
"{",
"$",
"seo",
"->",
"addMeta",
"(",
"'name'",
",",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"}",
"}",
"}"
] | Set page options.
@param array $options | [
"Set",
"page",
"options",
"."
] | c8607a46c2cea80cc138994be74f4dea3c197abc | https://github.com/liverbool/dos-resource-bundle/blob/c8607a46c2cea80cc138994be74f4dea3c197abc/Templating/PageBuilder.php#L47-L91 |
9,897 | singlequote/docblock-parser | src/DocblockParser.php | DocblockParser.parse | private function parse()
{
$this->rawDocblock = $this->reflection->getDocComment();
$raw = str_replace("\r\n", "\n", $this->rawDocblock);
$lines = explode("\n", $raw);
$matches = null;
switch (count($lines)) {
case 1:
if (!preg_match('#\\/\\*\\*([^*]*)\\*\\/#', $lines[0], $matches)) {
return;
}
$lines[0] = substr($lines[0], 3, -2);
break;
case 2:
break;
default:
array_shift($lines);
array_pop($lines);
break;
}
$this->parseLines($lines);
} | php | private function parse()
{
$this->rawDocblock = $this->reflection->getDocComment();
$raw = str_replace("\r\n", "\n", $this->rawDocblock);
$lines = explode("\n", $raw);
$matches = null;
switch (count($lines)) {
case 1:
if (!preg_match('#\\/\\*\\*([^*]*)\\*\\/#', $lines[0], $matches)) {
return;
}
$lines[0] = substr($lines[0], 3, -2);
break;
case 2:
break;
default:
array_shift($lines);
array_pop($lines);
break;
}
$this->parseLines($lines);
} | [
"private",
"function",
"parse",
"(",
")",
"{",
"$",
"this",
"->",
"rawDocblock",
"=",
"$",
"this",
"->",
"reflection",
"->",
"getDocComment",
"(",
")",
";",
"$",
"raw",
"=",
"str_replace",
"(",
"\"\\r\\n\"",
",",
"\"\\n\"",
",",
"$",
"this",
"->",
"rawDocblock",
")",
";",
"$",
"lines",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"raw",
")",
";",
"$",
"matches",
"=",
"null",
";",
"switch",
"(",
"count",
"(",
"$",
"lines",
")",
")",
"{",
"case",
"1",
":",
"if",
"(",
"!",
"preg_match",
"(",
"'#\\\\/\\\\*\\\\*([^*]*)\\\\*\\\\/#'",
",",
"$",
"lines",
"[",
"0",
"]",
",",
"$",
"matches",
")",
")",
"{",
"return",
";",
"}",
"$",
"lines",
"[",
"0",
"]",
"=",
"substr",
"(",
"$",
"lines",
"[",
"0",
"]",
",",
"3",
",",
"-",
"2",
")",
";",
"break",
";",
"case",
"2",
":",
"break",
";",
"default",
":",
"array_shift",
"(",
"$",
"lines",
")",
";",
"array_pop",
"(",
"$",
"lines",
")",
";",
"break",
";",
"}",
"$",
"this",
"->",
"parseLines",
"(",
"$",
"lines",
")",
";",
"}"
] | Parse the docblock. | [
"Parse",
"the",
"docblock",
"."
] | ab72023b6b1eaf9005b7166f1259e85741c2b79f | https://github.com/singlequote/docblock-parser/blob/ab72023b6b1eaf9005b7166f1259e85741c2b79f/src/DocblockParser.php#L50-L72 |
9,898 | singlequote/docblock-parser | src/DocblockParser.php | DocblockParser.parseLines | private function parseLines($lines)
{
foreach ($lines as $line) {
$line = preg_replace('#^[ \t\*]*#', '', $line);
if (strlen($line) < 2) {
continue;
}
if (preg_match('#@([^ ]+)(.*)#', $line, $matches)) {
$tag_name = $matches[1];
$tag_value = trim($matches[2]);
// If this tag was already parsed, make its value an array
if (isset($this->tags[$tag_name])) {
if (!is_array($this->tags[$tag_name])) {
$this->tags[$tag_name] = [$this->tags[$tag_name]];
}
$this->tags[$tag_name][] = $tag_value;
} else {
$this->tags[$tag_name] = $tag_value;
}
continue;
}
$this->comment .= "$line\n";
}
$this->comment = trim($this->comment);
} | php | private function parseLines($lines)
{
foreach ($lines as $line) {
$line = preg_replace('#^[ \t\*]*#', '', $line);
if (strlen($line) < 2) {
continue;
}
if (preg_match('#@([^ ]+)(.*)#', $line, $matches)) {
$tag_name = $matches[1];
$tag_value = trim($matches[2]);
// If this tag was already parsed, make its value an array
if (isset($this->tags[$tag_name])) {
if (!is_array($this->tags[$tag_name])) {
$this->tags[$tag_name] = [$this->tags[$tag_name]];
}
$this->tags[$tag_name][] = $tag_value;
} else {
$this->tags[$tag_name] = $tag_value;
}
continue;
}
$this->comment .= "$line\n";
}
$this->comment = trim($this->comment);
} | [
"private",
"function",
"parseLines",
"(",
"$",
"lines",
")",
"{",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"line",
")",
"{",
"$",
"line",
"=",
"preg_replace",
"(",
"'#^[ \\t\\*]*#'",
",",
"''",
",",
"$",
"line",
")",
";",
"if",
"(",
"strlen",
"(",
"$",
"line",
")",
"<",
"2",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"preg_match",
"(",
"'#@([^ ]+)(.*)#'",
",",
"$",
"line",
",",
"$",
"matches",
")",
")",
"{",
"$",
"tag_name",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"$",
"tag_value",
"=",
"trim",
"(",
"$",
"matches",
"[",
"2",
"]",
")",
";",
"// If this tag was already parsed, make its value an array",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag_name",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag_name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag_name",
"]",
"=",
"[",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag_name",
"]",
"]",
";",
"}",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag_name",
"]",
"[",
"]",
"=",
"$",
"tag_value",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"tags",
"[",
"$",
"tag_name",
"]",
"=",
"$",
"tag_value",
";",
"}",
"continue",
";",
"}",
"$",
"this",
"->",
"comment",
".=",
"\"$line\\n\"",
";",
"}",
"$",
"this",
"->",
"comment",
"=",
"trim",
"(",
"$",
"this",
"->",
"comment",
")",
";",
"}"
] | Parse the lines from the docblock.
@param string[] $lines - all lines from the docblock | [
"Parse",
"the",
"lines",
"from",
"the",
"docblock",
"."
] | ab72023b6b1eaf9005b7166f1259e85741c2b79f | https://github.com/singlequote/docblock-parser/blob/ab72023b6b1eaf9005b7166f1259e85741c2b79f/src/DocblockParser.php#L79-L103 |
9,899 | singlequote/docblock-parser | src/DocblockParser.php | DocblockParser.getTag | public function getTag(string $name, $default = null)
{
return isset($this->tags[$name]) ? $this->tags[$name] : $default;
} | php | public function getTag(string $name, $default = null)
{
return isset($this->tags[$name]) ? $this->tags[$name] : $default;
} | [
"public",
"function",
"getTag",
"(",
"string",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"tags",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"tags",
"[",
"$",
"name",
"]",
":",
"$",
"default",
";",
"}"
] | Get a tag by name.
@param string $name - name of the tag to get
@param null $default - default value if the tag does not exist
@return mixed|null | [
"Get",
"a",
"tag",
"by",
"name",
"."
] | ab72023b6b1eaf9005b7166f1259e85741c2b79f | https://github.com/singlequote/docblock-parser/blob/ab72023b6b1eaf9005b7166f1259e85741c2b79f/src/DocblockParser.php#L204-L207 |
Subsets and Splits