repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
FriendsOfPHP/Sismo | src/Sismo/Contrib/WallpaperNotifier.php | WallpaperNotifier.hex2rgb | private function hex2rgb($hex)
{
$hex = str_replace('#', '', $hex);
// expand shorthand notation (#36A -> #3366AA)
if (3 == strlen($hex)) {
$hex = $hex{0}
.$hex{0}
.$hex{1}
.$hex{1}
.$hex{2}
.$hex{2};
}
return array(
hexdec(substr($hex, 0, 2)),
hexdec(substr($hex, 2, 2)),
hexdec(substr($hex, 4, 2)),
);
} | php | private function hex2rgb($hex)
{
$hex = str_replace('#', '', $hex);
// expand shorthand notation (#36A -> #3366AA)
if (3 == strlen($hex)) {
$hex = $hex{0}
.$hex{0}
.$hex{1}
.$hex{1}
.$hex{2}
.$hex{2};
}
return array(
hexdec(substr($hex, 0, 2)),
hexdec(substr($hex, 2, 2)),
hexdec(substr($hex, 4, 2)),
);
} | [
"private",
"function",
"hex2rgb",
"(",
"$",
"hex",
")",
"{",
"$",
"hex",
"=",
"str_replace",
"(",
"'#'",
",",
"''",
",",
"$",
"hex",
")",
";",
"// expand shorthand notation (#36A -> #3366AA)",
"if",
"(",
"3",
"==",
"strlen",
"(",
"$",
"hex",
")",
")",
... | Convenience method to transform a color from hexadecimal to RGB.
@param string $hex The color in hexadecimal format (full or shorthand)
@return array The RGB color as an array with R, G and B components | [
"Convenience",
"method",
"to",
"transform",
"a",
"color",
"from",
"hexadecimal",
"to",
"RGB",
"."
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Contrib/WallpaperNotifier.php#L875-L894 | train |
ScriptFUSION/Porter | src/Options/EncapsulatedOptions.php | EncapsulatedOptions.get | final protected function get($option)
{
if (array_key_exists($key = "$option", $this->options)) {
return $this->options[$key];
}
if (array_key_exists($key, $this->defaults)) {
return $this->defaults[$key];
}
} | php | final protected function get($option)
{
if (array_key_exists($key = "$option", $this->options)) {
return $this->options[$key];
}
if (array_key_exists($key, $this->defaults)) {
return $this->defaults[$key];
}
} | [
"final",
"protected",
"function",
"get",
"(",
"$",
"option",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
"=",
"\"$option\"",
",",
"$",
"this",
"->",
"options",
")",
")",
"{",
"return",
"$",
"this",
"->",
"options",
"[",
"$",
"key",
"]",... | Gets the value for the specified option name. When option name is not set the default value is retrieved, if
defined, otherwise null.
@param string $option Option name.
@return mixed Option value, default value or null. | [
"Gets",
"the",
"value",
"for",
"the",
"specified",
"option",
"name",
".",
"When",
"option",
"name",
"is",
"not",
"set",
"the",
"default",
"value",
"is",
"retrieved",
"if",
"defined",
"otherwise",
"null",
"."
] | c50bc62e56993c4860b1d62819679a6c6e9ec913 | https://github.com/ScriptFUSION/Porter/blob/c50bc62e56993c4860b1d62819679a6c6e9ec913/src/Options/EncapsulatedOptions.php#L31-L40 | train |
FriendsOfPHP/Sismo | src/Sismo/Contrib/CrossFingerNotifier.php | CrossFingerNotifier.commitNeedNotification | protected function commitNeedNotification(Commit $commit)
{
if (!$commit->isSuccessful()) {
return true;
}
//getProject()->getLatestCommit() actually contains the previous build
$previousCommit = $commit->getProject()->getLatestCommit();
return !$previousCommit || $previousCommit->getStatusCode() != $commit->getStatusCode();
} | php | protected function commitNeedNotification(Commit $commit)
{
if (!$commit->isSuccessful()) {
return true;
}
//getProject()->getLatestCommit() actually contains the previous build
$previousCommit = $commit->getProject()->getLatestCommit();
return !$previousCommit || $previousCommit->getStatusCode() != $commit->getStatusCode();
} | [
"protected",
"function",
"commitNeedNotification",
"(",
"Commit",
"$",
"commit",
")",
"{",
"if",
"(",
"!",
"$",
"commit",
"->",
"isSuccessful",
"(",
")",
")",
"{",
"return",
"true",
";",
"}",
"//getProject()->getLatestCommit() actually contains the previous build",
... | Determines if a build needs to be notify
based on his status and his predecessor's one
@param Commit $commit The commit to analyse
@return bool whether the commit need notification or not | [
"Determines",
"if",
"a",
"build",
"needs",
"to",
"be",
"notify",
"based",
"on",
"his",
"status",
"and",
"his",
"predecessor",
"s",
"one"
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Contrib/CrossFingerNotifier.php#L76-L86 | train |
FriendsOfPHP/Sismo | src/Sismo/Contrib/GrowlNotifier.php | GrowlNotifier.notify | public function notify(Commit $commit)
{
try {
$this->growl->register();
$name = $commit->isSuccessful()
? self::NOTIFY_SUCCESS : self::NOTIFY_FAILURE;
$notifications = $this->growl->getApplication()->getGrowlNotifications();
$this->growl->publish(
$name,
$commit->getProject()->getName(),
$this->format($this->format, $commit),
$notifications[$name]
);
} catch (\Net_Growl_Exception $e) {
return false;
}
return true;
} | php | public function notify(Commit $commit)
{
try {
$this->growl->register();
$name = $commit->isSuccessful()
? self::NOTIFY_SUCCESS : self::NOTIFY_FAILURE;
$notifications = $this->growl->getApplication()->getGrowlNotifications();
$this->growl->publish(
$name,
$commit->getProject()->getName(),
$this->format($this->format, $commit),
$notifications[$name]
);
} catch (\Net_Growl_Exception $e) {
return false;
}
return true;
} | [
"public",
"function",
"notify",
"(",
"Commit",
"$",
"commit",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"growl",
"->",
"register",
"(",
")",
";",
"$",
"name",
"=",
"$",
"commit",
"->",
"isSuccessful",
"(",
")",
"?",
"self",
"::",
"NOTIFY_SUCCESS",
":"... | Notify a project commit
@param Sismo\Commit $commit The latest project commit
@return bool TRUE on a succesfull notification, FALSE on failure | [
"Notify",
"a",
"project",
"commit"
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Contrib/GrowlNotifier.php#L103-L123 | train |
FriendsOfPHP/Sismo | src/Sismo/Project.php | Project.getSubName | public function getSubName()
{
if (false !== $pos = strpos($this->name, '(')) {
return trim(substr($this->name, $pos + 1, -1));
}
return '';
} | php | public function getSubName()
{
if (false !== $pos = strpos($this->name, '(')) {
return trim(substr($this->name, $pos + 1, -1));
}
return '';
} | [
"public",
"function",
"getSubName",
"(",
")",
"{",
"if",
"(",
"false",
"!==",
"$",
"pos",
"=",
"strpos",
"(",
"$",
"this",
"->",
"name",
",",
"'('",
")",
")",
"{",
"return",
"trim",
"(",
"substr",
"(",
"$",
"this",
"->",
"name",
",",
"$",
"pos",
... | Gets the project sub name.
@return string The project sub name | [
"Gets",
"the",
"project",
"sub",
"name",
"."
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Project.php#L251-L258 | train |
FriendsOfPHP/Sismo | src/Sismo/Project.php | Project.setRepository | public function setRepository($url)
{
if (false !== strpos($url, '@')) {
list($url, $branch) = explode('@', $url);
$this->branch = $branch;
}
$this->repository = $url;
return $this;
} | php | public function setRepository($url)
{
if (false !== strpos($url, '@')) {
list($url, $branch) = explode('@', $url);
$this->branch = $branch;
}
$this->repository = $url;
return $this;
} | [
"public",
"function",
"setRepository",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"false",
"!==",
"strpos",
"(",
"$",
"url",
",",
"'@'",
")",
")",
"{",
"list",
"(",
"$",
"url",
",",
"$",
"branch",
")",
"=",
"explode",
"(",
"'@'",
",",
"$",
"url",
")... | Sets the project repository URL.
@param string $url The project repository URL | [
"Sets",
"the",
"project",
"repository",
"URL",
"."
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Project.php#L297-L307 | train |
ScriptFUSION/Porter | src/Connector/ConnectionContext.php | ConnectionContext.retry | public function retry(callable $callback)
{
$userHandlerCloned = $providerHandlerCloned = false;
return \ScriptFUSION\Retry\retry(
$this->maxFetchAttempts,
$callback,
function (\Exception $exception) use (&$userHandlerCloned, &$providerHandlerCloned) {
// Throw exception instead of retrying, if unrecoverable.
if (!$exception instanceof RecoverableConnectorException) {
throw $exception;
}
// Call provider's exception handler, if defined.
if ($this->resourceFetchExceptionHandler) {
self::invokeHandler($this->resourceFetchExceptionHandler, $exception, $providerHandlerCloned);
}
// Call user's exception handler.
self::invokeHandler($this->fetchExceptionHandler, $exception, $userHandlerCloned);
}
);
} | php | public function retry(callable $callback)
{
$userHandlerCloned = $providerHandlerCloned = false;
return \ScriptFUSION\Retry\retry(
$this->maxFetchAttempts,
$callback,
function (\Exception $exception) use (&$userHandlerCloned, &$providerHandlerCloned) {
// Throw exception instead of retrying, if unrecoverable.
if (!$exception instanceof RecoverableConnectorException) {
throw $exception;
}
// Call provider's exception handler, if defined.
if ($this->resourceFetchExceptionHandler) {
self::invokeHandler($this->resourceFetchExceptionHandler, $exception, $providerHandlerCloned);
}
// Call user's exception handler.
self::invokeHandler($this->fetchExceptionHandler, $exception, $userHandlerCloned);
}
);
} | [
"public",
"function",
"retry",
"(",
"callable",
"$",
"callback",
")",
"{",
"$",
"userHandlerCloned",
"=",
"$",
"providerHandlerCloned",
"=",
"false",
";",
"return",
"\\",
"ScriptFUSION",
"\\",
"Retry",
"\\",
"retry",
"(",
"$",
"this",
"->",
"maxFetchAttempts",... | Retries the specified callback a predefined number of times with a predefined exception handler.
@param callable $callback Callback.
@return mixed The result of the callback invocation. | [
"Retries",
"the",
"specified",
"callback",
"a",
"predefined",
"number",
"of",
"times",
"with",
"a",
"predefined",
"exception",
"handler",
"."
] | c50bc62e56993c4860b1d62819679a6c6e9ec913 | https://github.com/ScriptFUSION/Porter/blob/c50bc62e56993c4860b1d62819679a6c6e9ec913/src/Connector/ConnectionContext.php#L54-L76 | train |
ScriptFUSION/Porter | src/Connector/ConnectionContext.php | ConnectionContext.invokeHandler | private static function invokeHandler(FetchExceptionHandler &$handler, \Exception $exception, &$cloned)
{
if (!$cloned && !$handler instanceof StatelessFetchExceptionHandler) {
$handler = clone $handler;
$handler->initialize();
$cloned = true;
}
$handler($exception);
} | php | private static function invokeHandler(FetchExceptionHandler &$handler, \Exception $exception, &$cloned)
{
if (!$cloned && !$handler instanceof StatelessFetchExceptionHandler) {
$handler = clone $handler;
$handler->initialize();
$cloned = true;
}
$handler($exception);
} | [
"private",
"static",
"function",
"invokeHandler",
"(",
"FetchExceptionHandler",
"&",
"$",
"handler",
",",
"\\",
"Exception",
"$",
"exception",
",",
"&",
"$",
"cloned",
")",
"{",
"if",
"(",
"!",
"$",
"cloned",
"&&",
"!",
"$",
"handler",
"instanceof",
"State... | Invokes the specified fetch exception handler, cloning it if required.
@param FetchExceptionHandler $handler Fetch exception handler.
@param \Exception $exception Exception to pass to the handler.
@param bool $cloned False if handler requires cloning, true if handler has already been cloned. | [
"Invokes",
"the",
"specified",
"fetch",
"exception",
"handler",
"cloning",
"it",
"if",
"required",
"."
] | c50bc62e56993c4860b1d62819679a6c6e9ec913 | https://github.com/ScriptFUSION/Porter/blob/c50bc62e56993c4860b1d62819679a6c6e9ec913/src/Connector/ConnectionContext.php#L85-L94 | train |
FriendsOfPHP/Sismo | src/Sismo/Storage/PdoStorage.php | PdoStorage.create | public static function create($dsn, $username = null, $passwd = null, array $options = array())
{
return new self(new \PDO($dsn, $username, $passwd, $options));
} | php | public static function create($dsn, $username = null, $passwd = null, array $options = array())
{
return new self(new \PDO($dsn, $username, $passwd, $options));
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"dsn",
",",
"$",
"username",
"=",
"null",
",",
"$",
"passwd",
"=",
"null",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"return",
"new",
"self",
"(",
"new",
"\\",
"PDO",
"(",
... | Create a PdoStorage by establishing a PDO connection.
@throws \PDOException If the attempt to connect to the requested database fails.
@param string $dsn The data source name.
@param string $username The username to login with.
@param string $passwd The password of the given user.
@param array $options Additional options to pass to the PDO driver.
@return PdoStorage The created storage on the defined connection. | [
"Create",
"a",
"PdoStorage",
"by",
"establishing",
"a",
"PDO",
"connection",
"."
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Storage/PdoStorage.php#L54-L57 | train |
FriendsOfPHP/Sismo | src/Sismo/Storage/PdoStorage.php | PdoStorage.getCommit | public function getCommit(Project $project, $sha)
{
$stmt = $this->db->prepare('SELECT slug, sha, author, date, build_date, message, status, output FROM `commit` WHERE slug = :slug AND sha = :sha');
$stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);
$stmt->bindValue(':sha', $sha, \PDO::PARAM_STR);
if ($stmt->execute()) {
if (false !== $result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return $this->createCommit($project, $result);
}
} else {
// @codeCoverageIgnoreStart
throw new \RuntimeException(sprintf('Unable to retrieve commit "%s" from project "%s".', $sha, $project), 1);
// @codeCoverageIgnoreEnd
}
return false;
} | php | public function getCommit(Project $project, $sha)
{
$stmt = $this->db->prepare('SELECT slug, sha, author, date, build_date, message, status, output FROM `commit` WHERE slug = :slug AND sha = :sha');
$stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);
$stmt->bindValue(':sha', $sha, \PDO::PARAM_STR);
if ($stmt->execute()) {
if (false !== $result = $stmt->fetch(\PDO::FETCH_ASSOC)) {
return $this->createCommit($project, $result);
}
} else {
// @codeCoverageIgnoreStart
throw new \RuntimeException(sprintf('Unable to retrieve commit "%s" from project "%s".', $sha, $project), 1);
// @codeCoverageIgnoreEnd
}
return false;
} | [
"public",
"function",
"getCommit",
"(",
"Project",
"$",
"project",
",",
"$",
"sha",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"db",
"->",
"prepare",
"(",
"'SELECT slug, sha, author, date, build_date, message, status, output FROM `commit` WHERE slug = :slug AND sha = ... | Retrieves a commit out of a project.
@param Project $project The project this commit is part of.
@param string $sha The hash of the commit to retrieve.
@return Commit | [
"Retrieves",
"a",
"commit",
"out",
"of",
"a",
"project",
"."
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Storage/PdoStorage.php#L67-L84 | train |
FriendsOfPHP/Sismo | src/Sismo/Storage/PdoStorage.php | PdoStorage.initCommit | public function initCommit(Project $project, $sha, $author, \DateTime $date, $message)
{
$stmt = $this->db->prepare('SELECT COUNT(*) FROM `commit` WHERE slug = :slug');
$stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);
if (false === $stmt->execute()) {
// @codeCoverageIgnoreStart
throw new \RuntimeException(sprintf('Unable to verify existence of commit "%s" from project "%s".', $sha, $project->getName()));
// @codeCoverageIgnoreEnd
}
if ($stmt->fetchColumn(0)) {
$stmt = $this->db->prepare('UPDATE `commit` SET slug = :slug, sha = :sha, author = :author, date = :date, message = :message, status = :status, output = :output, build_date = :build_date WHERE slug = :slug');
} else {
$stmt = $this->db->prepare('INSERT INTO `commit` (slug, sha, author, date, message, status, output, build_date) VALUES (:slug, :sha, :author, :date, :message, :status, :output, :build_date)');
}
$stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);
$stmt->bindValue(':sha', $sha, \PDO::PARAM_STR);
$stmt->bindValue(':author', $author, \PDO::PARAM_STR);
$stmt->bindValue(':date', $date->format('Y-m-d H:i:s'), \PDO::PARAM_STR);
$stmt->bindValue(':message', $message, \PDO::PARAM_STR);
$stmt->bindValue(':status', 'building', \PDO::PARAM_STR);
$stmt->bindValue(':output', '', \PDO::PARAM_STR);
$stmt->bindValue(':build_date', '', \PDO::PARAM_STR);
if (false === $stmt->execute()) {
// @codeCoverageIgnoreStart
throw new \RuntimeException(sprintf('Unable to save commit "%s" from project "%s".', $sha, $project->getName()));
// @codeCoverageIgnoreEnd
}
$commit = new Commit($project, $sha);
$commit->setAuthor($author);
$commit->setMessage($message);
$commit->setDate($date);
return $commit;
} | php | public function initCommit(Project $project, $sha, $author, \DateTime $date, $message)
{
$stmt = $this->db->prepare('SELECT COUNT(*) FROM `commit` WHERE slug = :slug');
$stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);
if (false === $stmt->execute()) {
// @codeCoverageIgnoreStart
throw new \RuntimeException(sprintf('Unable to verify existence of commit "%s" from project "%s".', $sha, $project->getName()));
// @codeCoverageIgnoreEnd
}
if ($stmt->fetchColumn(0)) {
$stmt = $this->db->prepare('UPDATE `commit` SET slug = :slug, sha = :sha, author = :author, date = :date, message = :message, status = :status, output = :output, build_date = :build_date WHERE slug = :slug');
} else {
$stmt = $this->db->prepare('INSERT INTO `commit` (slug, sha, author, date, message, status, output, build_date) VALUES (:slug, :sha, :author, :date, :message, :status, :output, :build_date)');
}
$stmt->bindValue(':slug', $project->getSlug(), \PDO::PARAM_STR);
$stmt->bindValue(':sha', $sha, \PDO::PARAM_STR);
$stmt->bindValue(':author', $author, \PDO::PARAM_STR);
$stmt->bindValue(':date', $date->format('Y-m-d H:i:s'), \PDO::PARAM_STR);
$stmt->bindValue(':message', $message, \PDO::PARAM_STR);
$stmt->bindValue(':status', 'building', \PDO::PARAM_STR);
$stmt->bindValue(':output', '', \PDO::PARAM_STR);
$stmt->bindValue(':build_date', '', \PDO::PARAM_STR);
if (false === $stmt->execute()) {
// @codeCoverageIgnoreStart
throw new \RuntimeException(sprintf('Unable to save commit "%s" from project "%s".', $sha, $project->getName()));
// @codeCoverageIgnoreEnd
}
$commit = new Commit($project, $sha);
$commit->setAuthor($author);
$commit->setMessage($message);
$commit->setDate($date);
return $commit;
} | [
"public",
"function",
"initCommit",
"(",
"Project",
"$",
"project",
",",
"$",
"sha",
",",
"$",
"author",
",",
"\\",
"DateTime",
"$",
"date",
",",
"$",
"message",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"db",
"->",
"prepare",
"(",
"'SELECT COUN... | Initiate, create and save a new commit.
@param Project $project The project of the new commit.
@param string $sha The hash of the commit.
@param string $author The name of the author of the new commit.
@param \DateTime $date The date the new commit was created originally (e.g. by external resources).
@param string $message The commit message.
@return Commit The newly created commit. | [
"Initiate",
"create",
"and",
"save",
"a",
"new",
"commit",
"."
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Storage/PdoStorage.php#L97-L135 | train |
FriendsOfPHP/Sismo | src/Sismo/Storage/PdoStorage.php | PdoStorage.updateCommit | public function updateCommit(Commit $commit)
{
$stmt = $this->db->prepare('UPDATE `commit` SET status = :status, output = :output, build_date = :current_date WHERE slug = :slug AND sha = :sha');
$stmt->bindValue(':slug', $commit->getProject()->getSlug(), \PDO::PARAM_STR);
$stmt->bindValue(':sha', $commit->getSha(), \PDO::PARAM_STR);
$stmt->bindValue(':status', $commit->getStatusCode(), \PDO::PARAM_STR);
$stmt->bindValue(':output', $commit->getOutput(), \PDO::PARAM_STR);
$stmt->bindValue(':current_date', date('Y-m-d H:i:s'), \PDO::PARAM_STR);
if (false === $stmt->execute()) {
// @codeCoverageIgnoreStart
throw new \RuntimeException(sprintf('Unable to save build "%s@%s".', $commit->getProject()->getName(), $commit->getSha()));
// @codeCoverageIgnoreEnd
}
} | php | public function updateCommit(Commit $commit)
{
$stmt = $this->db->prepare('UPDATE `commit` SET status = :status, output = :output, build_date = :current_date WHERE slug = :slug AND sha = :sha');
$stmt->bindValue(':slug', $commit->getProject()->getSlug(), \PDO::PARAM_STR);
$stmt->bindValue(':sha', $commit->getSha(), \PDO::PARAM_STR);
$stmt->bindValue(':status', $commit->getStatusCode(), \PDO::PARAM_STR);
$stmt->bindValue(':output', $commit->getOutput(), \PDO::PARAM_STR);
$stmt->bindValue(':current_date', date('Y-m-d H:i:s'), \PDO::PARAM_STR);
if (false === $stmt->execute()) {
// @codeCoverageIgnoreStart
throw new \RuntimeException(sprintf('Unable to save build "%s@%s".', $commit->getProject()->getName(), $commit->getSha()));
// @codeCoverageIgnoreEnd
}
} | [
"public",
"function",
"updateCommit",
"(",
"Commit",
"$",
"commit",
")",
"{",
"$",
"stmt",
"=",
"$",
"this",
"->",
"db",
"->",
"prepare",
"(",
"'UPDATE `commit` SET status = :status, output = :output, build_date = :current_date WHERE slug = :slug AND sha = :sha'",
")",
";",... | Update the commits information.
The commit is identified by its sha hash.
@param Commit $commit
@return StorageInterface $this | [
"Update",
"the",
"commits",
"information",
"."
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Storage/PdoStorage.php#L214-L228 | train |
ScriptFUSION/Porter | src/Porter.php | Porter.import | public function import(ImportSpecification $specification)
{
$specification = clone $specification;
$records = $this->fetch(
$specification->getResource(),
$specification->getProviderName(),
ConnectionContextFactory::create($specification)
);
if (!$records instanceof ProviderRecords) {
$records = $this->createProviderRecords($records, $specification->getResource());
}
$records = $this->transformRecords($records, $specification->getTransformers(), $specification->getContext());
return $this->createPorterRecords($records, $specification);
} | php | public function import(ImportSpecification $specification)
{
$specification = clone $specification;
$records = $this->fetch(
$specification->getResource(),
$specification->getProviderName(),
ConnectionContextFactory::create($specification)
);
if (!$records instanceof ProviderRecords) {
$records = $this->createProviderRecords($records, $specification->getResource());
}
$records = $this->transformRecords($records, $specification->getTransformers(), $specification->getContext());
return $this->createPorterRecords($records, $specification);
} | [
"public",
"function",
"import",
"(",
"ImportSpecification",
"$",
"specification",
")",
"{",
"$",
"specification",
"=",
"clone",
"$",
"specification",
";",
"$",
"records",
"=",
"$",
"this",
"->",
"fetch",
"(",
"$",
"specification",
"->",
"getResource",
"(",
"... | Imports data according to the design of the specified import specification.
@param ImportSpecification $specification Import specification.
@return PorterRecords|CountablePorterRecords
@throws ImportException Provider failed to return an iterator. | [
"Imports",
"data",
"according",
"to",
"the",
"design",
"of",
"the",
"specified",
"import",
"specification",
"."
] | c50bc62e56993c4860b1d62819679a6c6e9ec913 | https://github.com/ScriptFUSION/Porter/blob/c50bc62e56993c4860b1d62819679a6c6e9ec913/src/Porter.php#L56-L73 | train |
ScriptFUSION/Porter | src/Porter.php | Porter.importOne | public function importOne(ImportSpecification $specification)
{
$results = $this->import($specification);
if (!$results->valid()) {
return null;
}
$one = $results->current();
if ($results->next() || $results->valid()) {
throw new ImportException('Cannot import one: more than one record imported.');
}
return $one;
} | php | public function importOne(ImportSpecification $specification)
{
$results = $this->import($specification);
if (!$results->valid()) {
return null;
}
$one = $results->current();
if ($results->next() || $results->valid()) {
throw new ImportException('Cannot import one: more than one record imported.');
}
return $one;
} | [
"public",
"function",
"importOne",
"(",
"ImportSpecification",
"$",
"specification",
")",
"{",
"$",
"results",
"=",
"$",
"this",
"->",
"import",
"(",
"$",
"specification",
")",
";",
"if",
"(",
"!",
"$",
"results",
"->",
"valid",
"(",
")",
")",
"{",
"re... | Imports one record according to the design of the specified import specification.
@param ImportSpecification $specification Import specification.
@return array|null Record.
@throws ImportException More than one record was imported. | [
"Imports",
"one",
"record",
"according",
"to",
"the",
"design",
"of",
"the",
"specified",
"import",
"specification",
"."
] | c50bc62e56993c4860b1d62819679a6c6e9ec913 | https://github.com/ScriptFUSION/Porter/blob/c50bc62e56993c4860b1d62819679a6c6e9ec913/src/Porter.php#L84-L99 | train |
ScriptFUSION/Porter | src/Porter.php | Porter.getProvider | private function getProvider($name)
{
if ($this->providers->has($name)) {
return $this->providers->get($name);
}
try {
return $this->getOrCreateProviderFactory()->createProvider("$name");
} catch (ObjectNotCreatedException $exception) {
throw new ProviderNotFoundException("No such provider registered: \"$name\".", $exception);
}
} | php | private function getProvider($name)
{
if ($this->providers->has($name)) {
return $this->providers->get($name);
}
try {
return $this->getOrCreateProviderFactory()->createProvider("$name");
} catch (ObjectNotCreatedException $exception) {
throw new ProviderNotFoundException("No such provider registered: \"$name\".", $exception);
}
} | [
"private",
"function",
"getProvider",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"providers",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"providers",
"->",
"get",
"(",
"$",
"name",
")",
";",
"}",
"tr... | Gets the provider matching the specified name.
@param string $name Provider name.
@return Provider
@throws ProviderNotFoundException The specified provider was not found. | [
"Gets",
"the",
"provider",
"matching",
"the",
"specified",
"name",
"."
] | c50bc62e56993c4860b1d62819679a6c6e9ec913 | https://github.com/ScriptFUSION/Porter/blob/c50bc62e56993c4860b1d62819679a6c6e9ec913/src/Porter.php#L178-L189 | train |
ScriptFUSION/Porter | src/Specification/ImportSpecification.php | ImportSpecification.addTransformer | final public function addTransformer(Transformer $transformer)
{
if ($this->hasTransformer($transformer)) {
throw new DuplicateTransformerException('Transformer already added.');
}
$this->transformers[spl_object_hash($transformer)] = $transformer;
return $this;
} | php | final public function addTransformer(Transformer $transformer)
{
if ($this->hasTransformer($transformer)) {
throw new DuplicateTransformerException('Transformer already added.');
}
$this->transformers[spl_object_hash($transformer)] = $transformer;
return $this;
} | [
"final",
"public",
"function",
"addTransformer",
"(",
"Transformer",
"$",
"transformer",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"hasTransformer",
"(",
"$",
"transformer",
")",
")",
"{",
"throw",
"new",
"DuplicateTransformerException",
"(",
"'Transformer already a... | Adds the specified transformer.
@param Transformer $transformer Transformer.
@return $this | [
"Adds",
"the",
"specified",
"transformer",
"."
] | c50bc62e56993c4860b1d62819679a6c6e9ec913 | https://github.com/ScriptFUSION/Porter/blob/c50bc62e56993c4860b1d62819679a6c6e9ec913/src/Specification/ImportSpecification.php#L123-L132 | train |
ScriptFUSION/Porter | src/Specification/ImportSpecification.php | ImportSpecification.setMaxFetchAttempts | final public function setMaxFetchAttempts($attempts)
{
if (!is_int($attempts) || $attempts < 1) {
throw new \InvalidArgumentException('Fetch attempts must be greater than or equal to 1.');
}
$this->maxFetchAttempts = $attempts;
return $this;
} | php | final public function setMaxFetchAttempts($attempts)
{
if (!is_int($attempts) || $attempts < 1) {
throw new \InvalidArgumentException('Fetch attempts must be greater than or equal to 1.');
}
$this->maxFetchAttempts = $attempts;
return $this;
} | [
"final",
"public",
"function",
"setMaxFetchAttempts",
"(",
"$",
"attempts",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"attempts",
")",
"||",
"$",
"attempts",
"<",
"1",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Fetch attempts must... | Sets the maximum number of fetch attempts per connection before failure is considered permanent.
@param int $attempts Maximum fetch attempts.
@return $this | [
"Sets",
"the",
"maximum",
"number",
"of",
"fetch",
"attempts",
"per",
"connection",
"before",
"failure",
"is",
"considered",
"permanent",
"."
] | c50bc62e56993c4860b1d62819679a6c6e9ec913 | https://github.com/ScriptFUSION/Porter/blob/c50bc62e56993c4860b1d62819679a6c6e9ec913/src/Specification/ImportSpecification.php#L230-L239 | train |
FriendsOfPHP/Sismo | src/Sismo/Commit.php | Commit.setStatusCode | public function setStatusCode($status)
{
if (!in_array($status, array('building', 'success', 'failed'))) {
throw new \InvalidArgumentException(sprintf('Invalid status code "%s".', $status));
}
$this->status = $status;
} | php | public function setStatusCode($status)
{
if (!in_array($status, array('building', 'success', 'failed'))) {
throw new \InvalidArgumentException(sprintf('Invalid status code "%s".', $status));
}
$this->status = $status;
} | [
"public",
"function",
"setStatusCode",
"(",
"$",
"status",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"status",
",",
"array",
"(",
"'building'",
",",
"'success'",
",",
"'failed'",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
... | Sets the build status code of the commit.
Can be one of "building", "success", or "failed".
@param string $status The commit build status code | [
"Sets",
"the",
"build",
"status",
"code",
"of",
"the",
"commit",
"."
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Commit.php#L91-L98 | train |
FriendsOfPHP/Sismo | src/Sismo/Sismo.php | Sismo.build | public function build(Project $project, $revision = null, $flags = 0, $callback = null)
{
// project already has a running build
if ($project->isBuilding() && Sismo::FORCE_BUILD !== ($flags & Sismo::FORCE_BUILD)) {
return;
}
$this->builder->init($project, $callback);
list($sha, $author, $date, $message) = $this->builder->prepare($revision, Sismo::LOCAL_BUILD !== ($flags & Sismo::LOCAL_BUILD));
$commit = $this->storage->getCommit($project, $sha);
// commit has already been built
if ($commit && $commit->isBuilt() && Sismo::FORCE_BUILD !== ($flags & Sismo::FORCE_BUILD)) {
return;
}
$commit = $this->storage->initCommit($project, $sha, $author, \DateTime::createFromFormat('Y-m-d H:i:s O', $date), $message);
$process = $this->builder->build();
if (!$process->isSuccessful()) {
$commit->setStatusCode('failed');
$commit->setOutput(sprintf("\033[31mBuild failed\033[0m\n\n\033[33mOutput\033[0m\n%s\n\n\033[33m Error\033[0m%s", $process->getOutput(), $process->getErrorOutput()));
} else {
$commit->setStatusCode('success');
$commit->setOutput($process->getOutput());
}
$this->storage->updateCommit($commit);
if (Sismo::SILENT_BUILD !== ($flags & Sismo::SILENT_BUILD)) {
foreach ($project->getNotifiers() as $notifier) {
$notifier->notify($commit);
}
}
} | php | public function build(Project $project, $revision = null, $flags = 0, $callback = null)
{
// project already has a running build
if ($project->isBuilding() && Sismo::FORCE_BUILD !== ($flags & Sismo::FORCE_BUILD)) {
return;
}
$this->builder->init($project, $callback);
list($sha, $author, $date, $message) = $this->builder->prepare($revision, Sismo::LOCAL_BUILD !== ($flags & Sismo::LOCAL_BUILD));
$commit = $this->storage->getCommit($project, $sha);
// commit has already been built
if ($commit && $commit->isBuilt() && Sismo::FORCE_BUILD !== ($flags & Sismo::FORCE_BUILD)) {
return;
}
$commit = $this->storage->initCommit($project, $sha, $author, \DateTime::createFromFormat('Y-m-d H:i:s O', $date), $message);
$process = $this->builder->build();
if (!$process->isSuccessful()) {
$commit->setStatusCode('failed');
$commit->setOutput(sprintf("\033[31mBuild failed\033[0m\n\n\033[33mOutput\033[0m\n%s\n\n\033[33m Error\033[0m%s", $process->getOutput(), $process->getErrorOutput()));
} else {
$commit->setStatusCode('success');
$commit->setOutput($process->getOutput());
}
$this->storage->updateCommit($commit);
if (Sismo::SILENT_BUILD !== ($flags & Sismo::SILENT_BUILD)) {
foreach ($project->getNotifiers() as $notifier) {
$notifier->notify($commit);
}
}
} | [
"public",
"function",
"build",
"(",
"Project",
"$",
"project",
",",
"$",
"revision",
"=",
"null",
",",
"$",
"flags",
"=",
"0",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"// project already has a running build",
"if",
"(",
"$",
"project",
"->",
"isBuildi... | Builds a project.
@param Project $project A Project instance
@param string $revision The revision to build (or null for the latest revision)
@param integer $flags Flags (a combinaison of FORCE_BUILD, LOCAL_BUILD, and SILENT_BUILD)
@param mixed $callback A PHP callback | [
"Builds",
"a",
"project",
"."
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Sismo.php#L53-L90 | train |
FriendsOfPHP/Sismo | src/Sismo/Sismo.php | Sismo.getProject | public function getProject($slug)
{
if (!isset($this->projects[$slug])) {
throw new \InvalidArgumentException(sprintf('Project "%s" does not exist.', $slug));
}
return $this->projects[$slug];
} | php | public function getProject($slug)
{
if (!isset($this->projects[$slug])) {
throw new \InvalidArgumentException(sprintf('Project "%s" does not exist.', $slug));
}
return $this->projects[$slug];
} | [
"public",
"function",
"getProject",
"(",
"$",
"slug",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"projects",
"[",
"$",
"slug",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Project \"%s\" doe... | Gets a project.
@param string $slug A project slug | [
"Gets",
"a",
"project",
"."
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Sismo.php#L107-L114 | train |
FriendsOfPHP/Sismo | src/Sismo/Sismo.php | Sismo.addProject | public function addProject(Project $project)
{
$this->storage->updateProject($project);
$this->projects[$project->getSlug()] = $project;
} | php | public function addProject(Project $project)
{
$this->storage->updateProject($project);
$this->projects[$project->getSlug()] = $project;
} | [
"public",
"function",
"addProject",
"(",
"Project",
"$",
"project",
")",
"{",
"$",
"this",
"->",
"storage",
"->",
"updateProject",
"(",
"$",
"project",
")",
";",
"$",
"this",
"->",
"projects",
"[",
"$",
"project",
"->",
"getSlug",
"(",
")",
"]",
"=",
... | Adds a project.
@param Project $project A Project instance | [
"Adds",
"a",
"project",
"."
] | 0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68 | https://github.com/FriendsOfPHP/Sismo/blob/0b35bd0033a6c3b509ce7bf417ddc83bccfb2f68/src/Sismo/Sismo.php#L121-L126 | train |
flarum/tags | src/Access/DiscussionPolicy.php | DiscussionPolicy.tag | public function tag(User $actor, Discussion $discussion)
{
if ($discussion->user_id == $actor->id && $actor->can('reply', $discussion)) {
$allowEditTags = $this->settings->get('allow_tag_change');
if ($allowEditTags === '-1'
|| ($allowEditTags === 'reply' && $discussion->participant_count <= 1)
|| (is_numeric($allowEditTags) && $discussion->created_at->diffInMinutes(new Carbon) < $allowEditTags)
) {
return true;
}
}
} | php | public function tag(User $actor, Discussion $discussion)
{
if ($discussion->user_id == $actor->id && $actor->can('reply', $discussion)) {
$allowEditTags = $this->settings->get('allow_tag_change');
if ($allowEditTags === '-1'
|| ($allowEditTags === 'reply' && $discussion->participant_count <= 1)
|| (is_numeric($allowEditTags) && $discussion->created_at->diffInMinutes(new Carbon) < $allowEditTags)
) {
return true;
}
}
} | [
"public",
"function",
"tag",
"(",
"User",
"$",
"actor",
",",
"Discussion",
"$",
"discussion",
")",
"{",
"if",
"(",
"$",
"discussion",
"->",
"user_id",
"==",
"$",
"actor",
"->",
"id",
"&&",
"$",
"actor",
"->",
"can",
"(",
"'reply'",
",",
"$",
"discuss... | This method checks, if the user is still allowed to edit the tags
based on the configuration item.
@param User $actor
@param Discussion $discussion
@return bool | [
"This",
"method",
"checks",
"if",
"the",
"user",
"is",
"still",
"allowed",
"to",
"edit",
"the",
"tags",
"based",
"on",
"the",
"configuration",
"item",
"."
] | 85ca89dd63b5c629a10c1faf9cd53df070794f08 | https://github.com/flarum/tags/blob/85ca89dd63b5c629a10c1faf9cd53df070794f08/src/Access/DiscussionPolicy.php#L121-L133 | train |
flarum/tags | src/Tag.php | Tag.refreshLastPostedDiscussion | public function refreshLastPostedDiscussion()
{
if ($lastPostedDiscussion = $this->discussions()->latest('last_posted_at')->first()) {
$this->setLastPostedDiscussion($lastPostedDiscussion);
}
return $this;
} | php | public function refreshLastPostedDiscussion()
{
if ($lastPostedDiscussion = $this->discussions()->latest('last_posted_at')->first()) {
$this->setLastPostedDiscussion($lastPostedDiscussion);
}
return $this;
} | [
"public",
"function",
"refreshLastPostedDiscussion",
"(",
")",
"{",
"if",
"(",
"$",
"lastPostedDiscussion",
"=",
"$",
"this",
"->",
"discussions",
"(",
")",
"->",
"latest",
"(",
"'last_posted_at'",
")",
"->",
"first",
"(",
")",
")",
"{",
"$",
"this",
"->",... | Refresh a tag's last discussion details.
@return $this | [
"Refresh",
"a",
"tag",
"s",
"last",
"discussion",
"details",
"."
] | 85ca89dd63b5c629a10c1faf9cd53df070794f08 | https://github.com/flarum/tags/blob/85ca89dd63b5c629a10c1faf9cd53df070794f08/src/Tag.php#L107-L114 | train |
flarum/tags | src/Tag.php | Tag.setLastPostedDiscussion | public function setLastPostedDiscussion(Discussion $discussion)
{
$this->last_posted_at = $discussion->last_posted_at;
$this->last_posted_discussion_id = $discussion->id;
$this->last_posted_user_id = $discussion->last_posted_user_id;
return $this;
} | php | public function setLastPostedDiscussion(Discussion $discussion)
{
$this->last_posted_at = $discussion->last_posted_at;
$this->last_posted_discussion_id = $discussion->id;
$this->last_posted_user_id = $discussion->last_posted_user_id;
return $this;
} | [
"public",
"function",
"setLastPostedDiscussion",
"(",
"Discussion",
"$",
"discussion",
")",
"{",
"$",
"this",
"->",
"last_posted_at",
"=",
"$",
"discussion",
"->",
"last_posted_at",
";",
"$",
"this",
"->",
"last_posted_discussion_id",
"=",
"$",
"discussion",
"->",... | Set the tag's last discussion details.
@param Discussion $discussion
@return $this | [
"Set",
"the",
"tag",
"s",
"last",
"discussion",
"details",
"."
] | 85ca89dd63b5c629a10c1faf9cd53df070794f08 | https://github.com/flarum/tags/blob/85ca89dd63b5c629a10c1faf9cd53df070794f08/src/Tag.php#L122-L129 | train |
flarum/tags | src/TagRepository.php | TagRepository.all | public function all(User $user = null)
{
$query = Tag::query();
return $this->scopeVisibleTo($query, $user)->get();
} | php | public function all(User $user = null)
{
$query = Tag::query();
return $this->scopeVisibleTo($query, $user)->get();
} | [
"public",
"function",
"all",
"(",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"Tag",
"::",
"query",
"(",
")",
";",
"return",
"$",
"this",
"->",
"scopeVisibleTo",
"(",
"$",
"query",
",",
"$",
"user",
")",
"->",
"get",
"(",
")",
... | Find all tags, optionally making sure they are visible to a
certain user.
@param User|null $user
@return \Illuminate\Database\Eloquent\Collection | [
"Find",
"all",
"tags",
"optionally",
"making",
"sure",
"they",
"are",
"visible",
"to",
"a",
"certain",
"user",
"."
] | 85ca89dd63b5c629a10c1faf9cd53df070794f08 | https://github.com/flarum/tags/blob/85ca89dd63b5c629a10c1faf9cd53df070794f08/src/TagRepository.php#L52-L57 | train |
flarum/tags | src/TagRepository.php | TagRepository.getIdForSlug | public function getIdForSlug($slug, User $user = null)
{
$query = Tag::where('slug', 'like', $slug);
return $this->scopeVisibleTo($query, $user)->pluck('id');
} | php | public function getIdForSlug($slug, User $user = null)
{
$query = Tag::where('slug', 'like', $slug);
return $this->scopeVisibleTo($query, $user)->pluck('id');
} | [
"public",
"function",
"getIdForSlug",
"(",
"$",
"slug",
",",
"User",
"$",
"user",
"=",
"null",
")",
"{",
"$",
"query",
"=",
"Tag",
"::",
"where",
"(",
"'slug'",
",",
"'like'",
",",
"$",
"slug",
")",
";",
"return",
"$",
"this",
"->",
"scopeVisibleTo",... | Get the ID of a tag with the given slug.
@param string $slug
@param User|null $user
@return int | [
"Get",
"the",
"ID",
"of",
"a",
"tag",
"with",
"the",
"given",
"slug",
"."
] | 85ca89dd63b5c629a10c1faf9cd53df070794f08 | https://github.com/flarum/tags/blob/85ca89dd63b5c629a10c1faf9cd53df070794f08/src/TagRepository.php#L66-L71 | train |
Sylius/SyliusGridBundle | src/Bundle/Doctrine/PHPCRODM/ExpressionVisitor.php | ExpressionVisitor.dispatch | public function dispatch(Expression $expr, ?AbstractNode $parentNode = null)
{
if ($parentNode === null) {
$parentNode = $this->queryBuilder->where();
}
switch (true) {
case $expr instanceof Comparison:
return $this->walkComparison($expr, $parentNode);
case $expr instanceof CompositeExpression:
return $this->walkCompositeExpression($expr, $parentNode);
}
throw new \RuntimeException('Unknown Expression: ' . get_class($expr));
} | php | public function dispatch(Expression $expr, ?AbstractNode $parentNode = null)
{
if ($parentNode === null) {
$parentNode = $this->queryBuilder->where();
}
switch (true) {
case $expr instanceof Comparison:
return $this->walkComparison($expr, $parentNode);
case $expr instanceof CompositeExpression:
return $this->walkCompositeExpression($expr, $parentNode);
}
throw new \RuntimeException('Unknown Expression: ' . get_class($expr));
} | [
"public",
"function",
"dispatch",
"(",
"Expression",
"$",
"expr",
",",
"?",
"AbstractNode",
"$",
"parentNode",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"parentNode",
"===",
"null",
")",
"{",
"$",
"parentNode",
"=",
"$",
"this",
"->",
"queryBuilder",
"->",
... | Walk the given expression to build up the PHPCR-ODM query builder.
@throws \RuntimeException | [
"Walk",
"the",
"given",
"expression",
"to",
"build",
"up",
"the",
"PHPCR",
"-",
"ODM",
"query",
"builder",
"."
] | dfc5f4a0920010550b1af60801179bea7ada5632 | https://github.com/Sylius/SyliusGridBundle/blob/dfc5f4a0920010550b1af60801179bea7ada5632/src/Bundle/Doctrine/PHPCRODM/ExpressionVisitor.php#L133-L147 | train |
drupal-pattern-lab/unified-twig-extensions | src/TwigExtension/ExtensionLoader.php | ExtensionLoader.loadAll | static protected function loadAll($type) {
$theme = \Drupal::config('system.theme')->get('default');
$themeLocation = drupal_get_path('theme', $theme);
$themePath = DRUPAL_ROOT . '/' . $themeLocation . '/';
$extensionPaths = glob($themePath . '*/_twig-components/');
foreach ($extensionPaths as $extensionPath) {
$fullPath = $extensionPath;
foreach (scandir($fullPath . $type) as $file) {
$fileInfo = pathinfo($file);
if ($fileInfo['extension'] === 'php') {
if ($file[0] != '.' && $file[0] != '_' && substr($file, 0, 3) != 'pl_') {
static::load($type, $fullPath . $type . '/' . $file);
}
}
}
}
} | php | static protected function loadAll($type) {
$theme = \Drupal::config('system.theme')->get('default');
$themeLocation = drupal_get_path('theme', $theme);
$themePath = DRUPAL_ROOT . '/' . $themeLocation . '/';
$extensionPaths = glob($themePath . '*/_twig-components/');
foreach ($extensionPaths as $extensionPath) {
$fullPath = $extensionPath;
foreach (scandir($fullPath . $type) as $file) {
$fileInfo = pathinfo($file);
if ($fileInfo['extension'] === 'php') {
if ($file[0] != '.' && $file[0] != '_' && substr($file, 0, 3) != 'pl_') {
static::load($type, $fullPath . $type . '/' . $file);
}
}
}
}
} | [
"static",
"protected",
"function",
"loadAll",
"(",
"$",
"type",
")",
"{",
"$",
"theme",
"=",
"\\",
"Drupal",
"::",
"config",
"(",
"'system.theme'",
")",
"->",
"get",
"(",
"'default'",
")",
";",
"$",
"themeLocation",
"=",
"drupal_get_path",
"(",
"'theme'",
... | Loads all plugins of a given type.
This should be called once per $type.
@param string $type
The type to load all plugins for. | [
"Loads",
"all",
"plugins",
"of",
"a",
"given",
"type",
"."
] | 862b9deccab544ca68e3aaaccc257d14acc9b1f6 | https://github.com/drupal-pattern-lab/unified-twig-extensions/blob/862b9deccab544ca68e3aaaccc257d14acc9b1f6/src/TwigExtension/ExtensionLoader.php#L46-L64 | train |
drupal-pattern-lab/unified-twig-extensions | src/TwigExtension/ExtensionLoader.php | ExtensionLoader.load | static protected function load($type, $file) {
include $file;
switch ($type) {
case 'filters':
self::$objects['filters'][] = $filter;
break;
case 'functions':
self::$objects['functions'][] = $function;
break;
case 'tags':
if (preg_match('/^([^\.]+)\.tag\.php$/', basename($file), $matches)) {
$class = "Project_{$matches[1]}_TokenParser";
if (class_exists($class)) {
self::$objects['parsers'][] = new $class();
}
}
break;
}
} | php | static protected function load($type, $file) {
include $file;
switch ($type) {
case 'filters':
self::$objects['filters'][] = $filter;
break;
case 'functions':
self::$objects['functions'][] = $function;
break;
case 'tags':
if (preg_match('/^([^\.]+)\.tag\.php$/', basename($file), $matches)) {
$class = "Project_{$matches[1]}_TokenParser";
if (class_exists($class)) {
self::$objects['parsers'][] = new $class();
}
}
break;
}
} | [
"static",
"protected",
"function",
"load",
"(",
"$",
"type",
",",
"$",
"file",
")",
"{",
"include",
"$",
"file",
";",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"'filters'",
":",
"self",
"::",
"$",
"objects",
"[",
"'filters'",
"]",
"[",
"]",
"="... | Loads a specific plugin instance.
@param string $type
The type of the plugin to be loaded.
@param string $file
The fully qualified path of the plugin to be loaded. | [
"Loads",
"a",
"specific",
"plugin",
"instance",
"."
] | 862b9deccab544ca68e3aaaccc257d14acc9b1f6 | https://github.com/drupal-pattern-lab/unified-twig-extensions/blob/862b9deccab544ca68e3aaaccc257d14acc9b1f6/src/TwigExtension/ExtensionLoader.php#L74-L92 | train |
takeit/AmpHtmlBundle | Request/ParamConverter/ResolveEntityParamConverter.php | ResolveEntityParamConverter.resolveTargetEntity | protected function resolveTargetEntity(ParamConverter $configuration)
{
$class = $configuration->getClass();
if (isset($this->mapping[$class])) {
if ($this->mapping[$class] !== $class) {
$configuration->setClass($this->mapping[$class]);
}
}
return $configuration;
} | php | protected function resolveTargetEntity(ParamConverter $configuration)
{
$class = $configuration->getClass();
if (isset($this->mapping[$class])) {
if ($this->mapping[$class] !== $class) {
$configuration->setClass($this->mapping[$class]);
}
}
return $configuration;
} | [
"protected",
"function",
"resolveTargetEntity",
"(",
"ParamConverter",
"$",
"configuration",
")",
"{",
"$",
"class",
"=",
"$",
"configuration",
"->",
"getClass",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"mapping",
"[",
"$",
"class",
"]",
... | Resolves the target entity.
@param ParamConverter $configuration Contains the name, class and options of the object
@return ParamConverter | [
"Resolves",
"the",
"target",
"entity",
"."
] | 335df4373fd3516e3fce96c90a211511ee5d8fbf | https://github.com/takeit/AmpHtmlBundle/blob/335df4373fd3516e3fce96c90a211511ee5d8fbf/Request/ParamConverter/ResolveEntityParamConverter.php#L76-L86 | train |
e-moe/guzzle6-bundle | src/Middleware/RequestLoggerMiddleware.php | RequestLoggerMiddleware.onRequestBeforeSend | private function onRequestBeforeSend(RequestInterface $request)
{
$hash = $this->hash($request);
$this->stopwatch->start($hash, self::NAME);
} | php | private function onRequestBeforeSend(RequestInterface $request)
{
$hash = $this->hash($request);
$this->stopwatch->start($hash, self::NAME);
} | [
"private",
"function",
"onRequestBeforeSend",
"(",
"RequestInterface",
"$",
"request",
")",
"{",
"$",
"hash",
"=",
"$",
"this",
"->",
"hash",
"(",
"$",
"request",
")",
";",
"$",
"this",
"->",
"stopwatch",
"->",
"start",
"(",
"$",
"hash",
",",
"self",
"... | Starts the stopwatch.
@param RequestInterface $request | [
"Starts",
"the",
"stopwatch",
"."
] | 83ed405c40e7297ff512e5ccae8780691eb975c5 | https://github.com/e-moe/guzzle6-bundle/blob/83ed405c40e7297ff512e5ccae8780691eb975c5/src/Middleware/RequestLoggerMiddleware.php#L74-L78 | train |
e-moe/guzzle6-bundle | src/Middleware/RequestLoggerMiddleware.php | RequestLoggerMiddleware.onRequestComplete | private function onRequestComplete(RequestInterface $request, ResponseInterface $response)
{
$hash = $this->hash($request);
// Send the log message to the adapter, adding a category and host
$priority = $response && $this->isError($response) ? LOG_ERR : LOG_DEBUG;
$message = $this->formatter->format($request, $response);
$event = $this->stopwatch->stop($hash);
$this->logAdapter->log($message, $priority, array(
'request' => $request,
'response' => $response,
'time' => $event->getDuration(),
));
} | php | private function onRequestComplete(RequestInterface $request, ResponseInterface $response)
{
$hash = $this->hash($request);
// Send the log message to the adapter, adding a category and host
$priority = $response && $this->isError($response) ? LOG_ERR : LOG_DEBUG;
$message = $this->formatter->format($request, $response);
$event = $this->stopwatch->stop($hash);
$this->logAdapter->log($message, $priority, array(
'request' => $request,
'response' => $response,
'time' => $event->getDuration(),
));
} | [
"private",
"function",
"onRequestComplete",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"hash",
"=",
"$",
"this",
"->",
"hash",
"(",
"$",
"request",
")",
";",
"// Send the log message to the adapter, adding a ca... | Stops the stopwatch.
@param RequestInterface $request
@param ResponseInterface $response | [
"Stops",
"the",
"stopwatch",
"."
] | 83ed405c40e7297ff512e5ccae8780691eb975c5 | https://github.com/e-moe/guzzle6-bundle/blob/83ed405c40e7297ff512e5ccae8780691eb975c5/src/Middleware/RequestLoggerMiddleware.php#L86-L98 | train |
sizuhiko/Fabricate | src/Factory/FabricateAbstractFactory.php | FabricateAbstractFactory.applyNestedDefinitions | private function applyNestedDefinitions($definitions, $record, $world)
{
foreach ($definitions as $definition) {
$result = $definition->run($record, $world);
$record = $this->applyTraits($record, $world);
$record = array_merge($record, $result);
}
return $record;
} | php | private function applyNestedDefinitions($definitions, $record, $world)
{
foreach ($definitions as $definition) {
$result = $definition->run($record, $world);
$record = $this->applyTraits($record, $world);
$record = array_merge($record, $result);
}
return $record;
} | [
"private",
"function",
"applyNestedDefinitions",
"(",
"$",
"definitions",
",",
"$",
"record",
",",
"$",
"world",
")",
"{",
"foreach",
"(",
"$",
"definitions",
"as",
"$",
"definition",
")",
"{",
"$",
"result",
"=",
"$",
"definition",
"->",
"run",
"(",
"$"... | Apply nested definitions
@param array $definitions array of FabricateDefinition
@param array $record data
@param FabricateContext $world context
@return array record applied nested definitions | [
"Apply",
"nested",
"definitions"
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Factory/FabricateAbstractFactory.php#L100-L108 | train |
sizuhiko/Fabricate | src/Factory/FabricateFactory.php | FabricateFactory.create | public static function create($definition)
{
if ($definition instanceof FabricateDefinition) {
return new FabricateDefinitionFactory($definition);
}
if ($definition instanceof FabricateModel) {
return new FabricateModelFactory($definition);
}
throw new \InvalidArgumentException("FabricateFactory is not support instance");
} | php | public static function create($definition)
{
if ($definition instanceof FabricateDefinition) {
return new FabricateDefinitionFactory($definition);
}
if ($definition instanceof FabricateModel) {
return new FabricateModelFactory($definition);
}
throw new \InvalidArgumentException("FabricateFactory is not support instance");
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"definition",
")",
"{",
"if",
"(",
"$",
"definition",
"instanceof",
"FabricateDefinition",
")",
"{",
"return",
"new",
"FabricateDefinitionFactory",
"(",
"$",
"definition",
")",
";",
"}",
"if",
"(",
"$",
"de... | Create factory depends with definition
@param mixed $definition FabricateDifinition or FabricateModel instance.
@return FabricateAbstractFactory
@throws InvalidArgumentException | [
"Create",
"factory",
"depends",
"with",
"definition"
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Factory/FabricateFactory.php#L26-L35 | train |
sizuhiko/Fabricate | src/FabricateContext.php | FabricateContext.sequence | public function sequence($name, $start = null, $callback = null)
{
if (is_callable($start)) {
$callback = $start;
$start = null;
}
if (!array_key_exists($name, $this->sequences)) {
if ($start === null) {
$start = $this->config->sequence_start;
}
$this->sequences[$name] = new FabricateSequence($start);
}
$ret = $this->sequences[$name]->current();
if (is_callable($callback)) {
$ret = $callback($ret);
}
$this->sequences[$name]->next();
return $ret;
} | php | public function sequence($name, $start = null, $callback = null)
{
if (is_callable($start)) {
$callback = $start;
$start = null;
}
if (!array_key_exists($name, $this->sequences)) {
if ($start === null) {
$start = $this->config->sequence_start;
}
$this->sequences[$name] = new FabricateSequence($start);
}
$ret = $this->sequences[$name]->current();
if (is_callable($callback)) {
$ret = $callback($ret);
}
$this->sequences[$name]->next();
return $ret;
} | [
"public",
"function",
"sequence",
"(",
"$",
"name",
",",
"$",
"start",
"=",
"null",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"start",
")",
")",
"{",
"$",
"callback",
"=",
"$",
"start",
";",
"$",
"start",
"=... | sequence allows you to get a series of numbers unique within the fabricate context.
@param string $name sequence name
@param int $start If you want to specify the starting number, you can do it with a second parameter.
default value is 1.
@param callback $callback If you are generating something like an email address,
you can pass it a block and the block response will be returned.
@return mixed generated sequence | [
"sequence",
"allows",
"you",
"to",
"get",
"a",
"series",
"of",
"numbers",
"unique",
"within",
"the",
"fabricate",
"context",
"."
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/FabricateContext.php#L64-L82 | train |
sizuhiko/Fabricate | src/FabricateContext.php | FabricateContext.traits | public function traits($name)
{
if (is_array($name)) {
$this->traits = array_merge($this->traits, $name);
} else {
$this->traits[] = $name;
}
} | php | public function traits($name)
{
if (is_array($name)) {
$this->traits = array_merge($this->traits, $name);
} else {
$this->traits[] = $name;
}
} | [
"public",
"function",
"traits",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"name",
")",
")",
"{",
"$",
"this",
"->",
"traits",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"traits",
",",
"$",
"name",
")",
";",
"}",
"else",
"{",
... | Add apply trait in the scope.
@param string|array $name use trait name(s)
@return void | [
"Add",
"apply",
"trait",
"in",
"the",
"scope",
"."
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/FabricateContext.php#L90-L97 | train |
sizuhiko/Fabricate | src/FabricateContext.php | FabricateContext.association | public function association($association, $recordCount = 1, $callback = null)
{
if (!is_array($association)) {
$association = [$association, 'association' => $association];
}
$attributes = Fabricate::association($association[0], $recordCount, $callback);
if ($this->model) {
$associations = $this->model->getAssociated();
if (isset($associations[$association['association']])
&& $associations[$association['association']] !== 'hasMany'
&& !empty($attributes)) {
$attributes = $attributes[0];
}
}
return $attributes;
} | php | public function association($association, $recordCount = 1, $callback = null)
{
if (!is_array($association)) {
$association = [$association, 'association' => $association];
}
$attributes = Fabricate::association($association[0], $recordCount, $callback);
if ($this->model) {
$associations = $this->model->getAssociated();
if (isset($associations[$association['association']])
&& $associations[$association['association']] !== 'hasMany'
&& !empty($attributes)) {
$attributes = $attributes[0];
}
}
return $attributes;
} | [
"public",
"function",
"association",
"(",
"$",
"association",
",",
"$",
"recordCount",
"=",
"1",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"association",
")",
")",
"{",
"$",
"association",
"=",
"[",
"$",
"asso... | Only create model attributes array for association.
@param mixed $association association name
@param int $recordCount count for creating.
@param mixed $callback callback or array can change fablicated data if you want to overwrite
@return array model attributes array. | [
"Only",
"create",
"model",
"attributes",
"array",
"for",
"association",
"."
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/FabricateContext.php#L119-L134 | train |
sizuhiko/Fabricate | src/FabricateRegistry.php | FabricateRegistry.find | public function find($name)
{
if ($this->is_registered($name)) {
return $this->items[$name];
}
$model = $this->adaptor->getModel($name);
if ($model) {
return $model;
}
throw new \InvalidArgumentException("{$name} not registered");
} | php | public function find($name)
{
if ($this->is_registered($name)) {
return $this->items[$name];
}
$model = $this->adaptor->getModel($name);
if ($model) {
return $model;
}
throw new \InvalidArgumentException("{$name} not registered");
} | [
"public",
"function",
"find",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"is_registered",
"(",
"$",
"name",
")",
")",
"{",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"name",
"]",
";",
"}",
"$",
"model",
"=",
"$",
"this",
"->... | Find from registred or model by name
@param string $name model name
@return mixed registerd object
@throws InvalidArgumentException | [
"Find",
"from",
"registred",
"or",
"model",
"by",
"name"
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/FabricateRegistry.php#L67-L77 | train |
sizuhiko/Fabricate | src/Fabricate.php | Fabricate.getInstance | private static function getInstance()
{
if (self::$_instance == null) {
self::$_instance = new Fabricate();
self::$_instance->config = new FabricateConfig();
self::$_instance->registry = new FabricateRegistry('Fabricate', null);
self::$_instance->traits = [];
}
return self::$_instance;
} | php | private static function getInstance()
{
if (self::$_instance == null) {
self::$_instance = new Fabricate();
self::$_instance->config = new FabricateConfig();
self::$_instance->registry = new FabricateRegistry('Fabricate', null);
self::$_instance->traits = [];
}
return self::$_instance;
} | [
"private",
"static",
"function",
"getInstance",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"_instance",
"==",
"null",
")",
"{",
"self",
"::",
"$",
"_instance",
"=",
"new",
"Fabricate",
"(",
")",
";",
"self",
"::",
"$",
"_instance",
"->",
"config",
... | Return Fabricator instance
@return Fabricate | [
"Return",
"Fabricator",
"instance"
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Fabricate.php#L59-L68 | train |
sizuhiko/Fabricate | src/Fabricate.php | Fabricate.config | public static function config($callback)
{
$instance = self::getInstance();
$callback($instance->config);
$instance->registry->setAdaptor($instance->config->adaptor);
if ($instance->config->faker == null) {
$instance->config->faker = \Faker\Factory::create();
}
} | php | public static function config($callback)
{
$instance = self::getInstance();
$callback($instance->config);
$instance->registry->setAdaptor($instance->config->adaptor);
if ($instance->config->faker == null) {
$instance->config->faker = \Faker\Factory::create();
}
} | [
"public",
"static",
"function",
"config",
"(",
"$",
"callback",
")",
"{",
"$",
"instance",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$",
"callback",
"(",
"$",
"instance",
"->",
"config",
")",
";",
"$",
"instance",
"->",
"registry",
"->",
"setAd... | To override these settings
@param mixed $callback can override $config(class of FabricateConfig) attributes
@return void | [
"To",
"override",
"these",
"settings"
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Fabricate.php#L93-L101 | train |
sizuhiko/Fabricate | src/Fabricate.php | Fabricate.create | public static function create($modelName, $recordCount = 1, $callback = null)
{
$attributes = self::attributes_for($modelName, $recordCount, $callback);
$instance = self::getInstance();
$definition = $instance->definition($recordCount, $callback);
$recordCount = $instance->recordCount($recordCount);
return $instance->factory->create($attributes, $recordCount, $definition);
} | php | public static function create($modelName, $recordCount = 1, $callback = null)
{
$attributes = self::attributes_for($modelName, $recordCount, $callback);
$instance = self::getInstance();
$definition = $instance->definition($recordCount, $callback);
$recordCount = $instance->recordCount($recordCount);
return $instance->factory->create($attributes, $recordCount, $definition);
} | [
"public",
"static",
"function",
"create",
"(",
"$",
"modelName",
",",
"$",
"recordCount",
"=",
"1",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"attributes",
"=",
"self",
"::",
"attributes_for",
"(",
"$",
"modelName",
",",
"$",
"recordCount",
",",
... | Create and Save fablicated model data to database.
@param string $modelName name of model or defined
@param mixed $recordCount $recordCount number for creation or $callback if not require $recordCount
@param mixed $callback callback can chenge fablicated data if you want to overwrite
@return mixed results of creation | [
"Create",
"and",
"Save",
"fablicated",
"model",
"data",
"to",
"database",
"."
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Fabricate.php#L111-L118 | train |
sizuhiko/Fabricate | src/Fabricate.php | Fabricate.build | public static function build($modelName, $callback = null)
{
$data = self::attributes_for($modelName, 1, $callback);
$instance = self::getInstance();
$definition = $instance->definition(1, $callback);
return $instance->factory->build($data, $definition);
} | php | public static function build($modelName, $callback = null)
{
$data = self::attributes_for($modelName, 1, $callback);
$instance = self::getInstance();
$definition = $instance->definition(1, $callback);
return $instance->factory->build($data, $definition);
} | [
"public",
"static",
"function",
"build",
"(",
"$",
"modelName",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"self",
"::",
"attributes_for",
"(",
"$",
"modelName",
",",
"1",
",",
"$",
"callback",
")",
";",
"$",
"instance",
"=",
"sel... | Only create a model instance.
@param string $modelName name of model or defined
@param mixed $callback callback can chenge fablicated data if you want to overwrite
@return Model Initializes the model for writing a new record | [
"Only",
"create",
"a",
"model",
"instance",
"."
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Fabricate.php#L126-L132 | train |
sizuhiko/Fabricate | src/Fabricate.php | Fabricate.attributes_for | public static function attributes_for($modelName, $recordCount = 1, $callback = null)
{
$instance = self::getInstance();
$instance->factory = $instance->factory($modelName);
$definition = $instance->definition($recordCount, $callback);
$recordCount = $instance->recordCount($recordCount);
return $instance->factory->attributes_for($recordCount, $definition);
} | php | public static function attributes_for($modelName, $recordCount = 1, $callback = null)
{
$instance = self::getInstance();
$instance->factory = $instance->factory($modelName);
$definition = $instance->definition($recordCount, $callback);
$recordCount = $instance->recordCount($recordCount);
return $instance->factory->attributes_for($recordCount, $definition);
} | [
"public",
"static",
"function",
"attributes_for",
"(",
"$",
"modelName",
",",
"$",
"recordCount",
"=",
"1",
",",
"$",
"callback",
"=",
"null",
")",
"{",
"$",
"instance",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$",
"instance",
"->",
"factory",
... | Only create model attributes array.
@param string $modelName name of model or defined
@param mixed $recordCount $recordCount number for creation or $callback if not require $recordCount
@param mixed $callback callback can chenge fablicated data if you want to overwrite
@return array model attributes array. | [
"Only",
"create",
"model",
"attributes",
"array",
"."
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Fabricate.php#L141-L148 | train |
sizuhiko/Fabricate | src/Fabricate.php | Fabricate.define | public static function define($name, $define)
{
$instance = self::getInstance();
$parent = false;
$base = false;
$trait = false;
if (is_array($name)) {
$parent = array_key_exists('parent', $name)?$name['parent']:false;
$base = array_key_exists('class', $name)?$name['class']:false;
if (array_key_exists('trait', $name)) {
$name = $name['trait'];
$parent = $base = false;
$trait = true;
} else {
$name = $name[0];
}
}
if (empty($name)) {
throw new \InvalidArgumentException("name is empty");
}
if ($parent && !$instance->registry->is_registered($parent)) {
throw new \InvalidArgumentException("parent `{$parent}` is not registered");
}
if ($base && in_array($instance->config->adaptor->getModel($base), [false, null])) {
throw new \InvalidArgumentException("class `{$base}` is not found");
}
$definition = new FabricateDefinition($define);
if ($trait) {
$instance->traits[$name] = $definition;
return;
}
if (!$parent && !$base) {
$base = $name;
}
$definition->parent = $parent?FabricateFactory::create($instance->registry->find($parent)):false;
$definition->parent = $base?FabricateFactory::create($instance->config->adaptor->getModel($base)):$definition->parent;
$definition->parent->setConfig(self::getInstance()->config);
$instance->registry->register($name, $definition);
} | php | public static function define($name, $define)
{
$instance = self::getInstance();
$parent = false;
$base = false;
$trait = false;
if (is_array($name)) {
$parent = array_key_exists('parent', $name)?$name['parent']:false;
$base = array_key_exists('class', $name)?$name['class']:false;
if (array_key_exists('trait', $name)) {
$name = $name['trait'];
$parent = $base = false;
$trait = true;
} else {
$name = $name[0];
}
}
if (empty($name)) {
throw new \InvalidArgumentException("name is empty");
}
if ($parent && !$instance->registry->is_registered($parent)) {
throw new \InvalidArgumentException("parent `{$parent}` is not registered");
}
if ($base && in_array($instance->config->adaptor->getModel($base), [false, null])) {
throw new \InvalidArgumentException("class `{$base}` is not found");
}
$definition = new FabricateDefinition($define);
if ($trait) {
$instance->traits[$name] = $definition;
return;
}
if (!$parent && !$base) {
$base = $name;
}
$definition->parent = $parent?FabricateFactory::create($instance->registry->find($parent)):false;
$definition->parent = $base?FabricateFactory::create($instance->config->adaptor->getModel($base)):$definition->parent;
$definition->parent->setConfig(self::getInstance()->config);
$instance->registry->register($name, $definition);
} | [
"public",
"static",
"function",
"define",
"(",
"$",
"name",
",",
"$",
"define",
")",
"{",
"$",
"instance",
"=",
"self",
"::",
"getInstance",
"(",
")",
";",
"$",
"parent",
"=",
"false",
";",
"$",
"base",
"=",
"false",
";",
"$",
"trait",
"=",
"false"... | Define fabrication object
@param mixed $name name or with attributes
@param mixed $define definition
@return void
@throws InvalidArgumentException | [
"Define",
"fabrication",
"object"
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Fabricate.php#L185-L224 | train |
sizuhiko/Fabricate | src/Definition/FabricateDefinition.php | FabricateDefinition.run | public function run($data, $world)
{
$result = [];
if (is_callable($this->define)) {
$callback = $this->define;
$result = $callback($data, $world);
} elseif (is_array($this->define)) {
$result = $this->define;
}
return $result;
} | php | public function run($data, $world)
{
$result = [];
if (is_callable($this->define)) {
$callback = $this->define;
$result = $callback($data, $world);
} elseif (is_array($this->define)) {
$result = $this->define;
}
return $result;
} | [
"public",
"function",
"run",
"(",
"$",
"data",
",",
"$",
"world",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"define",
")",
")",
"{",
"$",
"callback",
"=",
"$",
"this",
"->",
"define",
";",
"$... | Run to apply this definition
@param array $data data
@param FabricateContext $world fabricate context
@return array applied data | [
"Run",
"to",
"apply",
"this",
"definition"
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Definition/FabricateDefinition.php#L47-L57 | train |
sizuhiko/Fabricate | src/Model/FabricateModel.php | FabricateModel.addColumn | public function addColumn($columnName, $type, $options = [])
{
$this->columns[$columnName] = ['type' => $type, 'options' => $options];
return $this;
} | php | public function addColumn($columnName, $type, $options = [])
{
$this->columns[$columnName] = ['type' => $type, 'options' => $options];
return $this;
} | [
"public",
"function",
"addColumn",
"(",
"$",
"columnName",
",",
"$",
"type",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"this",
"->",
"columns",
"[",
"$",
"columnName",
"]",
"=",
"[",
"'type'",
"=>",
"$",
"type",
",",
"'options'",
"=>",
"$"... | Add column to the model
Valid Column Types
Column types are specified as strings and can be one of:
<ul>
<li>string</li>
<li>text</li>
<li>integer</li>
<li>biginteger</li>
<li>float</li>
<li>decimal</li>
<li>datetime</li>
<li>timestamp</li>
<li>time</li>
<li>date</li>
<li>binary</li>
<li>boolean</li>
</ul>
@param string $columnName Column Name
@param string $type Column Type
@param array $options Column Options
@return FabricateModel $this | [
"Add",
"column",
"to",
"the",
"model"
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Model/FabricateModel.php#L61-L65 | train |
sizuhiko/Fabricate | src/Model/FabricateModel.php | FabricateModel.hasMany | public function hasMany($name, $foreignKey, $modelName = null)
{
$this->addAssociation('hasMany', $name, $foreignKey, $modelName);
return $this;
} | php | public function hasMany($name, $foreignKey, $modelName = null)
{
$this->addAssociation('hasMany', $name, $foreignKey, $modelName);
return $this;
} | [
"public",
"function",
"hasMany",
"(",
"$",
"name",
",",
"$",
"foreignKey",
",",
"$",
"modelName",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"addAssociation",
"(",
"'hasMany'",
",",
"$",
"name",
",",
"$",
"foreignKey",
",",
"$",
"modelName",
")",
";",
... | Add hasMany association
@param string $name Association Name
@param string $foreignKey Forreign Key Column Name
@param string $modelName If association name is not model name then should set Model Name.
@return FabricateModel $this | [
"Add",
"hasMany",
"association"
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Model/FabricateModel.php#L95-L99 | train |
sizuhiko/Fabricate | src/Model/FabricateModel.php | FabricateModel.hasOne | public function hasOne($name, $foreignKey, $modelName = null)
{
$this->addAssociation('hasOne', $name, $foreignKey, $modelName);
return $this;
} | php | public function hasOne($name, $foreignKey, $modelName = null)
{
$this->addAssociation('hasOne', $name, $foreignKey, $modelName);
return $this;
} | [
"public",
"function",
"hasOne",
"(",
"$",
"name",
",",
"$",
"foreignKey",
",",
"$",
"modelName",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"addAssociation",
"(",
"'hasOne'",
",",
"$",
"name",
",",
"$",
"foreignKey",
",",
"$",
"modelName",
")",
";",
"... | Add hasOne association
@param string $name Association Name
@param string $foreignKey Forreign Key Column Name
@param string $modelName If association name is not model name then should set Model Name.
@return FabricateModel $this | [
"Add",
"hasOne",
"association"
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Model/FabricateModel.php#L109-L113 | train |
sizuhiko/Fabricate | src/Model/FabricateModel.php | FabricateModel.belongsTo | public function belongsTo($name, $foreignKey, $modelName = null)
{
$this->addAssociation('belongsTo', $name, $foreignKey, $modelName);
return $this;
} | php | public function belongsTo($name, $foreignKey, $modelName = null)
{
$this->addAssociation('belongsTo', $name, $foreignKey, $modelName);
return $this;
} | [
"public",
"function",
"belongsTo",
"(",
"$",
"name",
",",
"$",
"foreignKey",
",",
"$",
"modelName",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"addAssociation",
"(",
"'belongsTo'",
",",
"$",
"name",
",",
"$",
"foreignKey",
",",
"$",
"modelName",
")",
";... | Set belongsTo association
@param string $name Association Name
@param string $foreignKey Forreign Key Column Name
@param string $modelName If association name is not model name then should set Model Name.
@return FabricateModel $this | [
"Set",
"belongsTo",
"association"
] | 57adf9d081c3136d25686fed19b60b930e600a5f | https://github.com/sizuhiko/Fabricate/blob/57adf9d081c3136d25686fed19b60b930e600a5f/src/Model/FabricateModel.php#L123-L127 | train |
SidRoberts/phalcon-cron | src/Manager.php | Manager.runInForeground | public function runInForeground(DateTime $now = null) : array
{
$jobs = $this->getDueJobs($now);
$outputs = [];
foreach ($jobs as $job) {
$outputs[] = $job->runInForeground();
}
return $outputs;
} | php | public function runInForeground(DateTime $now = null) : array
{
$jobs = $this->getDueJobs($now);
$outputs = [];
foreach ($jobs as $job) {
$outputs[] = $job->runInForeground();
}
return $outputs;
} | [
"public",
"function",
"runInForeground",
"(",
"DateTime",
"$",
"now",
"=",
"null",
")",
":",
"array",
"{",
"$",
"jobs",
"=",
"$",
"this",
"->",
"getDueJobs",
"(",
"$",
"now",
")",
";",
"$",
"outputs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"jobs"... | Run all due jobs in the foreground. | [
"Run",
"all",
"due",
"jobs",
"in",
"the",
"foreground",
"."
] | 6d59c94c274949400a6b563d1e37f0e85ed32ba7 | https://github.com/SidRoberts/phalcon-cron/blob/6d59c94c274949400a6b563d1e37f0e85ed32ba7/src/Manager.php#L32-L43 | train |
SidRoberts/phalcon-cron | src/Manager.php | Manager.runInBackground | public function runInBackground(DateTime $now = null) : array
{
$jobs = $this->getDueJobs($now);
foreach ($jobs as $job) {
$this->processes[] = $job->runInBackground();
}
return $this->processes;
} | php | public function runInBackground(DateTime $now = null) : array
{
$jobs = $this->getDueJobs($now);
foreach ($jobs as $job) {
$this->processes[] = $job->runInBackground();
}
return $this->processes;
} | [
"public",
"function",
"runInBackground",
"(",
"DateTime",
"$",
"now",
"=",
"null",
")",
":",
"array",
"{",
"$",
"jobs",
"=",
"$",
"this",
"->",
"getDueJobs",
"(",
"$",
"now",
")",
";",
"foreach",
"(",
"$",
"jobs",
"as",
"$",
"job",
")",
"{",
"$",
... | Run all due jobs in the background. | [
"Run",
"all",
"due",
"jobs",
"in",
"the",
"background",
"."
] | 6d59c94c274949400a6b563d1e37f0e85ed32ba7 | https://github.com/SidRoberts/phalcon-cron/blob/6d59c94c274949400a6b563d1e37f0e85ed32ba7/src/Manager.php#L48-L57 | train |
contributte/application | src/UI/BasePresenter.php | BasePresenter.isModuleCurrent | public function isModuleCurrent(string $module): bool
{
return strpos($this->getAction(true), $module) !== false;
} | php | public function isModuleCurrent(string $module): bool
{
return strpos($this->getAction(true), $module) !== false;
} | [
"public",
"function",
"isModuleCurrent",
"(",
"string",
"$",
"module",
")",
":",
"bool",
"{",
"return",
"strpos",
"(",
"$",
"this",
"->",
"getAction",
"(",
"true",
")",
",",
"$",
"module",
")",
"!==",
"false",
";",
"}"
] | Is current module active?
@param string $module Module name | [
"Is",
"current",
"module",
"active?"
] | b5c46efaabb27ccd7aeb1ae80d9c9598976465e5 | https://github.com/contributte/application/blob/b5c46efaabb27ccd7aeb1ae80d9c9598976465e5/src/UI/BasePresenter.php#L25-L28 | train |
TwistoPayments/Twisto.php | src/Twisto/Twisto.php | Twisto.encrypt | private function encrypt($data)
{
$bin_key = pack("H*", substr($this->secret_key, 8));
$aes_key = substr($bin_key, 0, 16);
$salt = substr($bin_key, 16, 16);
$iv = openssl_random_pseudo_bytes(16);
$encrypted = openssl_encrypt($data, 'aes-128-cbc', $aes_key, true, $iv);
$digest = hash_hmac('sha256', $data . $iv, $salt, true);
return base64_encode($iv . $digest . $encrypted);
} | php | private function encrypt($data)
{
$bin_key = pack("H*", substr($this->secret_key, 8));
$aes_key = substr($bin_key, 0, 16);
$salt = substr($bin_key, 16, 16);
$iv = openssl_random_pseudo_bytes(16);
$encrypted = openssl_encrypt($data, 'aes-128-cbc', $aes_key, true, $iv);
$digest = hash_hmac('sha256', $data . $iv, $salt, true);
return base64_encode($iv . $digest . $encrypted);
} | [
"private",
"function",
"encrypt",
"(",
"$",
"data",
")",
"{",
"$",
"bin_key",
"=",
"pack",
"(",
"\"H*\"",
",",
"substr",
"(",
"$",
"this",
"->",
"secret_key",
",",
"8",
")",
")",
";",
"$",
"aes_key",
"=",
"substr",
"(",
"$",
"bin_key",
",",
"0",
... | Encrypt data with AES-128-CBC and HMAC-SHA-256
@param string $data
@return string | [
"Encrypt",
"data",
"with",
"AES",
"-",
"128",
"-",
"CBC",
"and",
"HMAC",
"-",
"SHA",
"-",
"256"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Twisto.php#L53-L62 | train |
TwistoPayments/Twisto.php | src/Twisto/Twisto.php | Twisto.requestJson | public function requestJson($method, $url, $data = null)
{
$response = $this->request($method, $url, $data);
$json = json_decode($response, true);
if ($json === null) {
throw new Error('API responded with invalid JSON');
}
return $json;
} | php | public function requestJson($method, $url, $data = null)
{
$response = $this->request($method, $url, $data);
$json = json_decode($response, true);
if ($json === null) {
throw new Error('API responded with invalid JSON');
}
return $json;
} | [
"public",
"function",
"requestJson",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"data",
")",
";",
"$",
"json",
... | Perform API request and decode response JSON
@param string $method
@param string $url
@param array $data
@return mixed
@throws Error | [
"Perform",
"API",
"request",
"and",
"decode",
"response",
"JSON"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Twisto.php#L83-L93 | train |
TwistoPayments/Twisto.php | src/Twisto/Twisto.php | Twisto.request | public function request($method, $url, $data = null)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization: {$this->public_key},{$this->secret_key}"
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $this->api_url . $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
if ($data !== null) {
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
}
$response = curl_exec($curl);
if (curl_errno($curl)) {
throw new Error('Curl error: ' . curl_error($curl));
}
$info = curl_getinfo($curl);
if ($info['http_code'] != 200) {
throw new Error('API responded with wrong status code (' . $info['http_code'] . ')', json_decode($response));
}
return $response;
} | php | public function request($method, $url, $data = null)
{
$curl = curl_init();
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
"Content-Type: application/json",
"Authorization: {$this->public_key},{$this->secret_key}"
));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL, $this->api_url . $url);
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
if ($data !== null) {
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($data));
}
$response = curl_exec($curl);
if (curl_errno($curl)) {
throw new Error('Curl error: ' . curl_error($curl));
}
$info = curl_getinfo($curl);
if ($info['http_code'] != 200) {
throw new Error('API responded with wrong status code (' . $info['http_code'] . ')', json_decode($response));
}
return $response;
} | [
"public",
"function",
"request",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"curl",
"=",
"curl_init",
"(",
")",
";",
"curl_setopt",
"(",
"$",
"curl",
",",
"CURLOPT_HTTPHEADER",
",",
"array",
"(",
"\"Content-Type:... | Perform API request
@param string $method
@param string $url
@param array $data
@return mixed
@throws Error | [
"Perform",
"API",
"request"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Twisto.php#L104-L130 | train |
TwistoPayments/Twisto.php | src/Twisto/Twisto.php | Twisto.getCheckPayload | public function getCheckPayload(Customer $customer, Order $order, $previous_orders)
{
$payload = json_encode(array(
'random_nonce' => uniqid('', true),
'customer' => $customer->serialize(),
'order' => $order->serialize(),
'previous_orders' => array_map(function (Order $item) {
return $item->serialize();
}, $previous_orders)
));
return $this->encrypt($this->compress($payload));
} | php | public function getCheckPayload(Customer $customer, Order $order, $previous_orders)
{
$payload = json_encode(array(
'random_nonce' => uniqid('', true),
'customer' => $customer->serialize(),
'order' => $order->serialize(),
'previous_orders' => array_map(function (Order $item) {
return $item->serialize();
}, $previous_orders)
));
return $this->encrypt($this->compress($payload));
} | [
"public",
"function",
"getCheckPayload",
"(",
"Customer",
"$",
"customer",
",",
"Order",
"$",
"order",
",",
"$",
"previous_orders",
")",
"{",
"$",
"payload",
"=",
"json_encode",
"(",
"array",
"(",
"'random_nonce'",
"=>",
"uniqid",
"(",
"''",
",",
"true",
"... | Create check payload
@param Customer $customer
@param Order $order
@param Order[] $previous_orders
@return string | [
"Create",
"check",
"payload"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Twisto.php#L139-L150 | train |
TwistoPayments/Twisto.php | src/Twisto/Invoice.php | Invoice.get | public function get()
{
$data = $this->twisto->requestJson('GET', 'invoice/' . urlencode($this->invoice_id) . '/');
$this->deserialize($data);
} | php | public function get()
{
$data = $this->twisto->requestJson('GET', 'invoice/' . urlencode($this->invoice_id) . '/');
$this->deserialize($data);
} | [
"public",
"function",
"get",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"twisto",
"->",
"requestJson",
"(",
"'GET'",
",",
"'invoice/'",
".",
"urlencode",
"(",
"$",
"this",
"->",
"invoice_id",
")",
".",
"'/'",
")",
";",
"$",
"this",
"->",
"... | Fetch invoice data from API | [
"Fetch",
"invoice",
"data",
"from",
"API"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Invoice.php#L68-L72 | train |
TwistoPayments/Twisto.php | src/Twisto/Invoice.php | Invoice.cancel | public function cancel()
{
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/cancel/');
$this->deserialize($data);
} | php | public function cancel()
{
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/cancel/');
$this->deserialize($data);
} | [
"public",
"function",
"cancel",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"twisto",
"->",
"requestJson",
"(",
"'POST'",
",",
"'invoice/'",
".",
"urlencode",
"(",
"$",
"this",
"->",
"invoice_id",
")",
".",
"'/cancel/'",
")",
";",
"$",
"this",
... | Perform cancel invoice API request | [
"Perform",
"cancel",
"invoice",
"API",
"request"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Invoice.php#L78-L82 | train |
TwistoPayments/Twisto.php | src/Twisto/Invoice.php | Invoice.activate | public function activate()
{
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/activate/');
$this->deserialize($data);
} | php | public function activate()
{
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/activate/');
$this->deserialize($data);
} | [
"public",
"function",
"activate",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"twisto",
"->",
"requestJson",
"(",
"'POST'",
",",
"'invoice/'",
".",
"urlencode",
"(",
"$",
"this",
"->",
"invoice_id",
")",
".",
"'/activate/'",
")",
";",
"$",
"thi... | Perform activate invoice API request | [
"Perform",
"activate",
"invoice",
"API",
"request"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Invoice.php#L87-L91 | train |
TwistoPayments/Twisto.php | src/Twisto/Invoice.php | Invoice.save | public function save()
{
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/edit/', $this->serialize());
$this->deserialize($data);
} | php | public function save()
{
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/edit/', $this->serialize());
$this->deserialize($data);
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"twisto",
"->",
"requestJson",
"(",
"'POST'",
",",
"'invoice/'",
".",
"urlencode",
"(",
"$",
"this",
"->",
"invoice_id",
")",
".",
"'/edit/'",
",",
"$",
"this",
"->",
"... | Save invoice items | [
"Save",
"invoice",
"items"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Invoice.php#L96-L100 | train |
TwistoPayments/Twisto.php | src/Twisto/Invoice.php | Invoice.create | public static function create(Twisto $twisto, $transaction_id, $eshop_invoice_id = null)
{
$data = array(
'transaction_id' => $transaction_id
);
if ($eshop_invoice_id !== null) {
$data['eshop_invoice_id'] = $eshop_invoice_id;
}
$data = $twisto->requestJson('POST', 'invoice/', $data);
$invoice = new Invoice($twisto, null);
$invoice->deserialize($data);
return $invoice;
} | php | public static function create(Twisto $twisto, $transaction_id, $eshop_invoice_id = null)
{
$data = array(
'transaction_id' => $transaction_id
);
if ($eshop_invoice_id !== null) {
$data['eshop_invoice_id'] = $eshop_invoice_id;
}
$data = $twisto->requestJson('POST', 'invoice/', $data);
$invoice = new Invoice($twisto, null);
$invoice->deserialize($data);
return $invoice;
} | [
"public",
"static",
"function",
"create",
"(",
"Twisto",
"$",
"twisto",
",",
"$",
"transaction_id",
",",
"$",
"eshop_invoice_id",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'transaction_id'",
"=>",
"$",
"transaction_id",
")",
";",
"if",
"(",
... | Create new invoice using transaction_id from check
@param Twisto $twisto
@param string $transaction_id
@param string $eshop_invoice_id
@return Invoice | [
"Create",
"new",
"invoice",
"using",
"transaction_id",
"from",
"check"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Invoice.php#L109-L123 | train |
TwistoPayments/Twisto.php | src/Twisto/Invoice.php | Invoice.returnItems | public function returnItems($items, $discounts = null)
{
$data = array(
'items' => array_map(function(ItemReturn $item) {
return $item->serialize();
}, $items)
);
if ($discounts !== null) {
$data['discounts'] = array_map(function(ItemDiscountReturn $item) {
return $item->serialize();
}, $discounts);
}
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/return/', $data);
$this->deserialize($data);
} | php | public function returnItems($items, $discounts = null)
{
$data = array(
'items' => array_map(function(ItemReturn $item) {
return $item->serialize();
}, $items)
);
if ($discounts !== null) {
$data['discounts'] = array_map(function(ItemDiscountReturn $item) {
return $item->serialize();
}, $discounts);
}
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/return/', $data);
$this->deserialize($data);
} | [
"public",
"function",
"returnItems",
"(",
"$",
"items",
",",
"$",
"discounts",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'items'",
"=>",
"array_map",
"(",
"function",
"(",
"ItemReturn",
"$",
"item",
")",
"{",
"return",
"$",
"item",
"->",
... | Perform invoice return API request
@param ItemReturn[] $items
@param ItemDiscountReturn[] $discounts | [
"Perform",
"invoice",
"return",
"API",
"request"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Invoice.php#L131-L147 | train |
TwistoPayments/Twisto.php | src/Twisto/Invoice.php | Invoice.returnAll | public function returnAll()
{
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/return/all/');
$this->deserialize($data);
} | php | public function returnAll()
{
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/return/all/');
$this->deserialize($data);
} | [
"public",
"function",
"returnAll",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"twisto",
"->",
"requestJson",
"(",
"'POST'",
",",
"'invoice/'",
".",
"urlencode",
"(",
"$",
"this",
"->",
"invoice_id",
")",
".",
"'/return/all/'",
")",
";",
"$",
"... | Perform invoice return all API request | [
"Perform",
"invoice",
"return",
"all",
"API",
"request"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Invoice.php#L152-L156 | train |
TwistoPayments/Twisto.php | src/Twisto/Invoice.php | Invoice.refund | public function refund($amount)
{
$data = array(
'amount' => (float)$amount
);
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/refund/', $data);
$this->deserialize($data);
} | php | public function refund($amount)
{
$data = array(
'amount' => (float)$amount
);
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/refund/', $data);
$this->deserialize($data);
} | [
"public",
"function",
"refund",
"(",
"$",
"amount",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'amount'",
"=>",
"(",
"float",
")",
"$",
"amount",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"twisto",
"->",
"requestJson",
"(",
"'POST'",
",",
"'in... | Refunds specified amount from the invoice
@param float amount to refund | [
"Refunds",
"specified",
"amount",
"from",
"the",
"invoice"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Invoice.php#L162-L169 | train |
TwistoPayments/Twisto.php | src/Twisto/Invoice.php | Invoice.splitItems | public function splitItems($items)
{
$data = array(
'items' => array_map(function(ItemSplit $item) {
return $item->serialize();
}, $items)
);
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/split/', $data);
$split_invoice = new Invoice($this->twisto, null);
$split_invoice->deserialize($data);
$this->get();
return $split_invoice;
} | php | public function splitItems($items)
{
$data = array(
'items' => array_map(function(ItemSplit $item) {
return $item->serialize();
}, $items)
);
$data = $this->twisto->requestJson('POST', 'invoice/' . urlencode($this->invoice_id) . '/split/', $data);
$split_invoice = new Invoice($this->twisto, null);
$split_invoice->deserialize($data);
$this->get();
return $split_invoice;
} | [
"public",
"function",
"splitItems",
"(",
"$",
"items",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'items'",
"=>",
"array_map",
"(",
"function",
"(",
"ItemSplit",
"$",
"item",
")",
"{",
"return",
"$",
"item",
"->",
"serialize",
"(",
")",
";",
"}",
","... | Split invoice to new one
@param ItemSplit[] $items
@return JSON response with new invoice | [
"Split",
"invoice",
"to",
"new",
"one"
] | 89a9361830766205ce9141bfde88515043600161 | https://github.com/TwistoPayments/Twisto.php/blob/89a9361830766205ce9141bfde88515043600161/src/Twisto/Invoice.php#L176-L190 | train |
Smart-Core/AcceleratorCacheBundle | CacheClearerService.php | CacheClearerService.createTemporaryFile | private function createTemporaryFile($user, $opcode)
{
if (!is_dir($this->webDir)) {
throw new \InvalidArgumentException(sprintf('Web dir does not exist "%s"', $this->webDir));
}
if (!is_writable($this->webDir)) {
throw new \InvalidArgumentException(sprintf('Web dir is not writable "%s"', $this->webDir));
}
$filename = sprintf('%s/%s', $this->webDir, 'apc-'.md5(uniqid().mt_rand(0, 9999999).php_uname()).'.php');
$contents = strtr($this->template, array(
'%clearer_code%' => file_get_contents(__DIR__.'/AcceleratorCacheClearer.php'),
'%user%' => var_export($user, true),
'%opcode%' => var_export($opcode, true),
));
if (false === $handle = fopen($filename, 'w+')) {
throw new \RuntimeException(sprintf('Can\'t open "%s"', $filename));
}
fwrite($handle, $contents);
fclose($handle);
return $filename;
} | php | private function createTemporaryFile($user, $opcode)
{
if (!is_dir($this->webDir)) {
throw new \InvalidArgumentException(sprintf('Web dir does not exist "%s"', $this->webDir));
}
if (!is_writable($this->webDir)) {
throw new \InvalidArgumentException(sprintf('Web dir is not writable "%s"', $this->webDir));
}
$filename = sprintf('%s/%s', $this->webDir, 'apc-'.md5(uniqid().mt_rand(0, 9999999).php_uname()).'.php');
$contents = strtr($this->template, array(
'%clearer_code%' => file_get_contents(__DIR__.'/AcceleratorCacheClearer.php'),
'%user%' => var_export($user, true),
'%opcode%' => var_export($opcode, true),
));
if (false === $handle = fopen($filename, 'w+')) {
throw new \RuntimeException(sprintf('Can\'t open "%s"', $filename));
}
fwrite($handle, $contents);
fclose($handle);
return $filename;
} | [
"private",
"function",
"createTemporaryFile",
"(",
"$",
"user",
",",
"$",
"opcode",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"this",
"->",
"webDir",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'Web dir does n... | Create the temporary file and return the filename.
@param bool $user
@param bool $opcode
@return string | [
"Create",
"the",
"temporary",
"file",
"and",
"return",
"the",
"filename",
"."
] | c0d67ebe438572f9f4dd42287ade11741722fe30 | https://github.com/Smart-Core/AcceleratorCacheBundle/blob/c0d67ebe438572f9f4dd42287ade11741722fe30/CacheClearerService.php#L156-L181 | train |
thephpleague/factory-muffin-faker | src/Faker.php | Faker.getGenerator | public function getGenerator()
{
if (!$this->generator) {
$this->generator = Factory::create($this->locale);
}
return $this->generator;
} | php | public function getGenerator()
{
if (!$this->generator) {
$this->generator = Factory::create($this->locale);
}
return $this->generator;
} | [
"public",
"function",
"getGenerator",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"generator",
")",
"{",
"$",
"this",
"->",
"generator",
"=",
"Factory",
"::",
"create",
"(",
"$",
"this",
"->",
"locale",
")",
";",
"}",
"return",
"$",
"this",
"... | Get the generator instance.
@return \Faker\Generator | [
"Get",
"the",
"generator",
"instance",
"."
] | eea89951bd990fa9c51dadc7e96a1e7bad026ddf | https://github.com/thephpleague/factory-muffin-faker/blob/eea89951bd990fa9c51dadc7e96a1e7bad026ddf/src/Faker.php#L75-L82 | train |
thephpleague/factory-muffin-faker | src/Faker.php | Faker.format | public function format($formatter, array $arguments = [])
{
$generator = $this->getGenerator();
return function () use ($generator, $formatter, $arguments) {
return $generator->format($formatter, $arguments);
};
} | php | public function format($formatter, array $arguments = [])
{
$generator = $this->getGenerator();
return function () use ($generator, $formatter, $arguments) {
return $generator->format($formatter, $arguments);
};
} | [
"public",
"function",
"format",
"(",
"$",
"formatter",
",",
"array",
"$",
"arguments",
"=",
"[",
"]",
")",
"{",
"$",
"generator",
"=",
"$",
"this",
"->",
"getGenerator",
"(",
")",
";",
"return",
"function",
"(",
")",
"use",
"(",
"$",
"generator",
","... | Wrap a faker format in a closure.
@param string $formatter The formatter.
@param array $arguments The arguments.
@return \Closure | [
"Wrap",
"a",
"faker",
"format",
"in",
"a",
"closure",
"."
] | eea89951bd990fa9c51dadc7e96a1e7bad026ddf | https://github.com/thephpleague/factory-muffin-faker/blob/eea89951bd990fa9c51dadc7e96a1e7bad026ddf/src/Faker.php#L116-L123 | train |
Rias500/craft-position-fieldtype | src/fields/Position.php | Position.getOptions | private static function getOptions()
{
return [
'left' => Craft::t('position-fieldtype', 'Left'),
'center' => Craft::t('position-fieldtype', 'Center'),
'right' => Craft::t('position-fieldtype', 'Right'),
'full' => Craft::t('position-fieldtype', 'Full'),
'drop-left' => Craft::t('position-fieldtype', 'Drop-left'),
'drop-right' => Craft::t('position-fieldtype', 'Drop-right'),
];
} | php | private static function getOptions()
{
return [
'left' => Craft::t('position-fieldtype', 'Left'),
'center' => Craft::t('position-fieldtype', 'Center'),
'right' => Craft::t('position-fieldtype', 'Right'),
'full' => Craft::t('position-fieldtype', 'Full'),
'drop-left' => Craft::t('position-fieldtype', 'Drop-left'),
'drop-right' => Craft::t('position-fieldtype', 'Drop-right'),
];
} | [
"private",
"static",
"function",
"getOptions",
"(",
")",
"{",
"return",
"[",
"'left'",
"=>",
"Craft",
"::",
"t",
"(",
"'position-fieldtype'",
",",
"'Left'",
")",
",",
"'center'",
"=>",
"Craft",
"::",
"t",
"(",
"'position-fieldtype'",
",",
"'Center'",
")",
... | Returns the position options.
@return array | [
"Returns",
"the",
"position",
"options",
"."
] | 18fc333880c34fd13ec2b04f43ad0a9a8b090ce2 | https://github.com/Rias500/craft-position-fieldtype/blob/18fc333880c34fd13ec2b04f43ad0a9a8b090ce2/src/fields/Position.php#L234-L244 | train |
hiqdev/yii2-hiart | src/rest/QueryBuilder.php | QueryBuilder.buildAuth | public function buildAuth(Query $query)
{
$auth = $this->db->getAuth();
if (isset($auth['headerToken'])) {
$this->authHeaders['Authorization'] = 'token ' . $auth['headerToken'];
}
if (isset($auth['headerBearer'])) {
$this->authHeaders['Authorization'] = 'Bearer ' . $auth['headerBearer'];
}
} | php | public function buildAuth(Query $query)
{
$auth = $this->db->getAuth();
if (isset($auth['headerToken'])) {
$this->authHeaders['Authorization'] = 'token ' . $auth['headerToken'];
}
if (isset($auth['headerBearer'])) {
$this->authHeaders['Authorization'] = 'Bearer ' . $auth['headerBearer'];
}
} | [
"public",
"function",
"buildAuth",
"(",
"Query",
"$",
"query",
")",
"{",
"$",
"auth",
"=",
"$",
"this",
"->",
"db",
"->",
"getAuth",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"auth",
"[",
"'headerToken'",
"]",
")",
")",
"{",
"$",
"this",
"->",... | This function is for you to provide your authentication.
@param Query $query | [
"This",
"function",
"is",
"for",
"you",
"to",
"provide",
"your",
"authentication",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/rest/QueryBuilder.php#L23-L32 | train |
hiqdev/yii2-hiart | src/rest/Connection.php | Connection.getResponseError | public function getResponseError(ResponseInterface $response)
{
$code = $response->getStatusCode();
if ($code >= 200 && $code < 300) {
return false;
}
return $response->getReasonPhrase();
} | php | public function getResponseError(ResponseInterface $response)
{
$code = $response->getStatusCode();
if ($code >= 200 && $code < 300) {
return false;
}
return $response->getReasonPhrase();
} | [
"public",
"function",
"getResponseError",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"code",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",
"if",
"(",
"$",
"code",
">=",
"200",
"&&",
"$",
"code",
"<",
"300",
")",
"{",
"retur... | Method checks whether the response is an error.
@param ResponseInterface $response
@return false|string the error text or boolean `false`, when the response is not an error | [
"Method",
"checks",
"whether",
"the",
"response",
"is",
"an",
"error",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/rest/Connection.php#L25-L33 | train |
hiqdev/yii2-hiart | src/Command.php | Command.update | public function update($table, $columns, $condition = [], array $params = [])
{
$request = $this->db->getQueryBuilder()->update($table, $columns, $condition, $params);
return $this->setRequest($request);
} | php | public function update($table, $columns, $condition = [], array $params = [])
{
$request = $this->db->getQueryBuilder()->update($table, $columns, $condition, $params);
return $this->setRequest($request);
} | [
"public",
"function",
"update",
"(",
"$",
"table",
",",
"$",
"columns",
",",
"$",
"condition",
"=",
"[",
"]",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"db",
"->",
"getQueryBuilder",
"(",
")",
"... | Sends a request to update data.
@param mixed $table entity to update
@param mixed $columns attributes of object to update
@param array $condition
@param array $params request parameters
@return $this | [
"Sends",
"a",
"request",
"to",
"update",
"data",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/Command.php#L73-L78 | train |
hiqdev/yii2-hiart | src/Command.php | Command.delete | public function delete($table, $condition, array $params = [])
{
$request = $this->db->getQueryBuilder()->delete($table, $condition, $params);
return $this->setRequest($request);
} | php | public function delete($table, $condition, array $params = [])
{
$request = $this->db->getQueryBuilder()->delete($table, $condition, $params);
return $this->setRequest($request);
} | [
"public",
"function",
"delete",
"(",
"$",
"table",
",",
"$",
"condition",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"db",
"->",
"getQueryBuilder",
"(",
")",
"->",
"delete",
"(",
"$",
"table",
",",... | Sends a request to delete data.
@param mixed $table entity to update
@param array $condition
@param array $params request parameters
@return $this | [
"Sends",
"a",
"request",
"to",
"delete",
"data",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/Command.php#L87-L92 | train |
hiqdev/yii2-hiart | src/Command.php | Command.perform | public function perform($action, $table, $body = [], array $params = [])
{
$request = $this->db->getQueryBuilder()->perform($action, $table, $body, $params);
$this->setRequest($request);
return $this->send();
} | php | public function perform($action, $table, $body = [], array $params = [])
{
$request = $this->db->getQueryBuilder()->perform($action, $table, $body, $params);
$this->setRequest($request);
return $this->send();
} | [
"public",
"function",
"perform",
"(",
"$",
"action",
",",
"$",
"table",
",",
"$",
"body",
"=",
"[",
"]",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"db",
"->",
"getQueryBuilder",
"(",
")",
"->",
... | Creates and executes request with given data.
@param string $action
@param string $table
@param mixed $body
@param array $params request parameters
@return ResponseInterface response object | [
"Creates",
"and",
"executes",
"request",
"with",
"given",
"data",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/Command.php#L102-L108 | train |
hiqdev/yii2-hiart | src/ActiveQuery.php | ActiveQuery.prepare | public function prepare($builder = null)
{
// NOTE: because the same ActiveQuery may be used to build different SQL statements
// (e.g. by ActiveDataProvider, one for count query, the other for row data query,
// it is important to make sure the same ActiveQuery can be used to build SQL statements
// multiple times.
if (!empty($this->joinWith)) {
$this->buildJoinWith();
$this->joinWith = null;
}
return $this;
} | php | public function prepare($builder = null)
{
// NOTE: because the same ActiveQuery may be used to build different SQL statements
// (e.g. by ActiveDataProvider, one for count query, the other for row data query,
// it is important to make sure the same ActiveQuery can be used to build SQL statements
// multiple times.
if (!empty($this->joinWith)) {
$this->buildJoinWith();
$this->joinWith = null;
}
return $this;
} | [
"public",
"function",
"prepare",
"(",
"$",
"builder",
"=",
"null",
")",
"{",
"// NOTE: because the same ActiveQuery may be used to build different SQL statements",
"// (e.g. by ActiveDataProvider, one for count query, the other for row data query,",
"// it is important to make sure the same ... | Prepares query for use. See NOTE.
@param QueryBuilder $builder
@return static | [
"Prepares",
"query",
"for",
"use",
".",
"See",
"NOTE",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/ActiveQuery.php#L104-L116 | train |
hiqdev/yii2-hiart | src/ActiveQuery.php | ActiveQuery.joinWithRelation | private function joinWithRelation($parent, $child)
{
if (!empty($child->join)) {
foreach ($child->join as $join) {
$this->join[] = $join;
}
}
} | php | private function joinWithRelation($parent, $child)
{
if (!empty($child->join)) {
foreach ($child->join as $join) {
$this->join[] = $join;
}
}
} | [
"private",
"function",
"joinWithRelation",
"(",
"$",
"parent",
",",
"$",
"child",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"child",
"->",
"join",
")",
")",
"{",
"foreach",
"(",
"$",
"child",
"->",
"join",
"as",
"$",
"join",
")",
"{",
"$",
"th... | Joins a parent query with a child query.
The current query object will be modified accordingly.
@param ActiveQuery $parent
@param ActiveQuery $child | [
"Joins",
"a",
"parent",
"query",
"with",
"a",
"child",
"query",
".",
"The",
"current",
"query",
"object",
"will",
"be",
"modified",
"accordingly",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/ActiveQuery.php#L203-L210 | train |
hiqdev/yii2-hiart | src/ActiveQuery.php | ActiveQuery.all | public function all($db = null)
{
if ($this->asArray) {
return parent::all($db);
}
$rows = $this->searchAll($db);
return $this->populate($rows);
} | php | public function all($db = null)
{
if ($this->asArray) {
return parent::all($db);
}
$rows = $this->searchAll($db);
return $this->populate($rows);
} | [
"public",
"function",
"all",
"(",
"$",
"db",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"asArray",
")",
"{",
"return",
"parent",
"::",
"all",
"(",
"$",
"db",
")",
";",
"}",
"$",
"rows",
"=",
"$",
"this",
"->",
"searchAll",
"(",
"$",
... | Executes query and returns all results as an array.
@param AbstractConnection $db the DB connection used to create the DB command.
If null, the DB connection returned by [[modelClass]] will be used.
@return array|ActiveRecord[] the query results. If the query results in nothing, an empty array will be returned. | [
"Executes",
"query",
"and",
"returns",
"all",
"results",
"as",
"an",
"array",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/ActiveQuery.php#L268-L277 | train |
hiqdev/yii2-hiart | src/stream/Request.php | Request.convertContextOptions | protected function convertContextOptions(array $options)
{
$contextOptions = [];
foreach ($options as $key => $value) {
$section = 'http';
if (strpos($key, 'ssl') === 0) {
$section = 'ssl';
$key = substr($key, 3);
}
$key = Inflector::underscore($key);
$contextOptions[$section][$key] = $value;
}
return $contextOptions;
} | php | protected function convertContextOptions(array $options)
{
$contextOptions = [];
foreach ($options as $key => $value) {
$section = 'http';
if (strpos($key, 'ssl') === 0) {
$section = 'ssl';
$key = substr($key, 3);
}
$key = Inflector::underscore($key);
$contextOptions[$section][$key] = $value;
}
return $contextOptions;
} | [
"protected",
"function",
"convertContextOptions",
"(",
"array",
"$",
"options",
")",
"{",
"$",
"contextOptions",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"section",
"=",
"'http'",
";",
"if... | Composes stream context options from raw options.
@param array $options raw options
@return array stream context options | [
"Composes",
"stream",
"context",
"options",
"from",
"raw",
"options",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/stream/Request.php#L83-L97 | train |
hiqdev/yii2-hiart | src/ActiveRecord.php | ActiveRecord.attributes | public function attributes()
{
$attributes = [];
foreach ($this->rules() as $rule) {
$names = reset($rule);
if (is_string($names)) {
$names = [$names];
}
foreach ($names as $name) {
if (substr_compare($name, '!', 0, 1) === 0) {
$name = mb_substr($name, 1);
}
$attributes[$name] = $name;
}
}
return array_values($attributes);
} | php | public function attributes()
{
$attributes = [];
foreach ($this->rules() as $rule) {
$names = reset($rule);
if (is_string($names)) {
$names = [$names];
}
foreach ($names as $name) {
if (substr_compare($name, '!', 0, 1) === 0) {
$name = mb_substr($name, 1);
}
$attributes[$name] = $name;
}
}
return array_values($attributes);
} | [
"public",
"function",
"attributes",
"(",
")",
"{",
"$",
"attributes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"rules",
"(",
")",
"as",
"$",
"rule",
")",
"{",
"$",
"names",
"=",
"reset",
"(",
"$",
"rule",
")",
";",
"if",
"(",
"is_... | Returns the list of attribute names.
By default, this method returns all attributes mentioned in rules.
You may override this method to change the default behavior.
@return string[] list of attribute names | [
"Returns",
"the",
"list",
"of",
"attribute",
"names",
".",
"By",
"default",
"this",
"method",
"returns",
"all",
"attributes",
"mentioned",
"in",
"rules",
".",
"You",
"may",
"override",
"this",
"method",
"to",
"change",
"the",
"default",
"behavior",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/ActiveRecord.php#L75-L92 | train |
hiqdev/yii2-hiart | src/ActiveRecord.php | ActiveRecord.query | public function query($defaultScenario, $data = [], array $options = [])
{
$action = $this->getScenarioAction($defaultScenario);
return static::perform($action, $data, $options);
} | php | public function query($defaultScenario, $data = [], array $options = [])
{
$action = $this->getScenarioAction($defaultScenario);
return static::perform($action, $data, $options);
} | [
"public",
"function",
"query",
"(",
"$",
"defaultScenario",
",",
"$",
"data",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"action",
"=",
"$",
"this",
"->",
"getScenarioAction",
"(",
"$",
"defaultScenario",
")",
";",
"re... | Perform query.
@param string $defaultScenario
@param array $data data
@param array $options
@return array result | [
"Perform",
"query",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/ActiveRecord.php#L245-L250 | train |
hiqdev/yii2-hiart | src/ActiveRecord.php | ActiveRecord.getScenarioAction | public function getScenarioAction($default = '')
{
if ($this->isScenarioDefault()) {
if (empty($default)) {
throw new InvalidConfigException('Scenario not specified');
}
return $default;
} else {
$actions = static::scenarioActions();
return isset($actions[$this->scenario]) ? $actions[$this->scenario] : $this->scenario;
}
} | php | public function getScenarioAction($default = '')
{
if ($this->isScenarioDefault()) {
if (empty($default)) {
throw new InvalidConfigException('Scenario not specified');
}
return $default;
} else {
$actions = static::scenarioActions();
return isset($actions[$this->scenario]) ? $actions[$this->scenario] : $this->scenario;
}
} | [
"public",
"function",
"getScenarioAction",
"(",
"$",
"default",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isScenarioDefault",
"(",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"default",
")",
")",
"{",
"throw",
"new",
"InvalidConfigException",
... | Converts scenario name to action.
@param string $default default action name
@throws InvalidConfigException
@throws NotSupportedException
@return string | [
"Converts",
"scenario",
"name",
"to",
"action",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/ActiveRecord.php#L271-L284 | train |
hiqdev/yii2-hiart | src/Collection.php | Collection.setModel | public function setModel($model)
{
if ($model instanceof Model) {
$this->model = $model;
} else {
$this->model = Yii::createObject($model);
}
$model = $this->model;
$this->updateFormName();
if (empty($this->getScenario())) {
$this->setScenario($model->scenario);
}
return $this->model;
} | php | public function setModel($model)
{
if ($model instanceof Model) {
$this->model = $model;
} else {
$this->model = Yii::createObject($model);
}
$model = $this->model;
$this->updateFormName();
if (empty($this->getScenario())) {
$this->setScenario($model->scenario);
}
return $this->model;
} | [
"public",
"function",
"setModel",
"(",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"model",
"instanceof",
"Model",
")",
"{",
"$",
"this",
"->",
"model",
"=",
"$",
"model",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"model",
"=",
"Yii",
"::",
"createObje... | Sets the model of the collection.
@param ActiveRecord|array $model if the model is an instance of [[Model]] - sets it, otherwise - creates the model
using given options array
@return object|ActiveRecord | [
"Sets",
"the",
"model",
"of",
"the",
"collection",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/Collection.php#L130-L146 | train |
hiqdev/yii2-hiart | src/Collection.php | Collection.set | public function set($models)
{
if ($models instanceof ActiveRecord) {
$models = [$models];
}
$first = reset($models);
if ($first === false) {
return $this;
}
$this->first = $first;
$this->formName = $first->formName();
$this->model = $this->setModel($first);
$this->models = $models;
if ($this->checkConsistency && !$this->isConsistent()) {
throw new InvalidValueException('Models are not objects of same class or not follow same operation');
}
return $this;
} | php | public function set($models)
{
if ($models instanceof ActiveRecord) {
$models = [$models];
}
$first = reset($models);
if ($first === false) {
return $this;
}
$this->first = $first;
$this->formName = $first->formName();
$this->model = $this->setModel($first);
$this->models = $models;
if ($this->checkConsistency && !$this->isConsistent()) {
throw new InvalidValueException('Models are not objects of same class or not follow same operation');
}
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"models",
")",
"{",
"if",
"(",
"$",
"models",
"instanceof",
"ActiveRecord",
")",
"{",
"$",
"models",
"=",
"[",
"$",
"models",
"]",
";",
"}",
"$",
"first",
"=",
"reset",
"(",
"$",
"models",
")",
";",
"if",
"(... | Sets the array of AR models to the collection.
@param array|ActiveRecord $models - array of AR Models or a single model
@return $this | [
"Sets",
"the",
"array",
"of",
"AR",
"models",
"to",
"the",
"collection",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/Collection.php#L290-L311 | train |
hiqdev/yii2-hiart | src/Collection.php | Collection.collectData | public function collectData($attributes = null)
{
$data = [];
foreach ($this->models as $model) {
if ($this->dataCollector instanceof Closure) {
list($key, $row) = call_user_func($this->dataCollector, $model, $this);
} else {
$key = $model->getPrimaryKey();
$row = $model->getAttributes($attributes);
}
if ($key) {
$data[$key] = $row;
} else {
$data[] = $row;
}
}
return $data;
} | php | public function collectData($attributes = null)
{
$data = [];
foreach ($this->models as $model) {
if ($this->dataCollector instanceof Closure) {
list($key, $row) = call_user_func($this->dataCollector, $model, $this);
} else {
$key = $model->getPrimaryKey();
$row = $model->getAttributes($attributes);
}
if ($key) {
$data[$key] = $row;
} else {
$data[] = $row;
}
}
return $data;
} | [
"public",
"function",
"collectData",
"(",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"models",
"as",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dataCollector",
"instanceof... | Collects data from the stored models.
@param string|array $attributes list of attributes names
@return array | [
"Collects",
"data",
"from",
"the",
"stored",
"models",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/Collection.php#L441-L460 | train |
hiqdev/yii2-hiart | src/Collection.php | Collection.getFirstError | public function getFirstError()
{
foreach ($this->models as $model) {
if ($model->hasErrors()) {
$errors = $model->getFirstErrors();
return array_shift($errors);
}
}
return false;
} | php | public function getFirstError()
{
foreach ($this->models as $model) {
if ($model->hasErrors()) {
$errors = $model->getFirstErrors();
return array_shift($errors);
}
}
return false;
} | [
"public",
"function",
"getFirstError",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"models",
"as",
"$",
"model",
")",
"{",
"if",
"(",
"$",
"model",
"->",
"hasErrors",
"(",
")",
")",
"{",
"$",
"errors",
"=",
"$",
"model",
"->",
"getFirstErrors",... | Returns the first error of the collection.
@return bool|mixed | [
"Returns",
"the",
"first",
"error",
"of",
"the",
"collection",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/Collection.php#L481-L492 | train |
hiqdev/yii2-hiart | src/Collection.php | Collection.triggerModels | public function triggerModels($name, ModelEvent $event = null)
{
if ($event === null) {
$event = new ModelEvent();
}
foreach ($this->models as $model) {
$model->trigger($name, $event);
}
return $event->isValid;
} | php | public function triggerModels($name, ModelEvent $event = null)
{
if ($event === null) {
$event = new ModelEvent();
}
foreach ($this->models as $model) {
$model->trigger($name, $event);
}
return $event->isValid;
} | [
"public",
"function",
"triggerModels",
"(",
"$",
"name",
",",
"ModelEvent",
"$",
"event",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"event",
"===",
"null",
")",
"{",
"$",
"event",
"=",
"new",
"ModelEvent",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"thi... | Iterates over all of the models and triggers some event.
@param string $name the event name
@param ModelEvent $event
@return bool whether is valid | [
"Iterates",
"over",
"all",
"of",
"the",
"models",
"and",
"triggers",
"some",
"event",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/Collection.php#L579-L589 | train |
hiqdev/yii2-hiart | src/AbstractQueryBuilder.php | AbstractQueryBuilder.update | public function update($table, $columns, $condition = [], array $options = [])
{
$query = $this->createQuery('update', $table, $options)->body($columns)->where($condition);
return $this->createRequest($query);
} | php | public function update($table, $columns, $condition = [], array $options = [])
{
$query = $this->createQuery('update', $table, $options)->body($columns)->where($condition);
return $this->createRequest($query);
} | [
"public",
"function",
"update",
"(",
"$",
"table",
",",
"$",
"columns",
",",
"$",
"condition",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQuery",
"(",
"'update'",
",",
"$",
"... | Creates update request.
@param string $table
@param array $columns
@param array $condition
@param array $options
@return AbstractRequest | [
"Creates",
"update",
"request",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/AbstractQueryBuilder.php#L104-L109 | train |
hiqdev/yii2-hiart | src/AbstractQueryBuilder.php | AbstractQueryBuilder.delete | public function delete($table, $condition = [], array $options = [])
{
$query = $this->createQuery('delete', $table, $options)->where($condition);
return $this->createRequest($query);
} | php | public function delete($table, $condition = [], array $options = [])
{
$query = $this->createQuery('delete', $table, $options)->where($condition);
return $this->createRequest($query);
} | [
"public",
"function",
"delete",
"(",
"$",
"table",
",",
"$",
"condition",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQuery",
"(",
"'delete'",
",",
"$",
"table",
",",
"$",
"op... | Creates delete request.
@param string $table
@param array $condition
@param array $options
@return AbstractRequest | [
"Creates",
"delete",
"request",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/AbstractQueryBuilder.php#L118-L123 | train |
hiqdev/yii2-hiart | src/AbstractQueryBuilder.php | AbstractQueryBuilder.perform | public function perform($action, $table, $body, $options = [])
{
$query = $this->createQuery($action, $table, $options)->body($body);
return $this->createRequest($query);
} | php | public function perform($action, $table, $body, $options = [])
{
$query = $this->createQuery($action, $table, $options)->body($body);
return $this->createRequest($query);
} | [
"public",
"function",
"perform",
"(",
"$",
"action",
",",
"$",
"table",
",",
"$",
"body",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"createQuery",
"(",
"$",
"action",
",",
"$",
"table",
",",
"$",
"options... | Creates request for given action.
@param string $action
@param string $table
@param mixed $body
@param array $options
@return AbstractRequest | [
"Creates",
"request",
"for",
"given",
"action",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/AbstractQueryBuilder.php#L133-L138 | train |
hiqdev/yii2-hiart | src/AbstractConnection.php | AbstractConnection.getAuth | public function getAuth()
{
if ($this->_disabledAuth) {
return [];
}
if ($this->_auth instanceof Closure) {
$this->_auth = call_user_func($this->_auth, $this);
}
return $this->_auth;
} | php | public function getAuth()
{
if ($this->_disabledAuth) {
return [];
}
if ($this->_auth instanceof Closure) {
$this->_auth = call_user_func($this->_auth, $this);
}
return $this->_auth;
} | [
"public",
"function",
"getAuth",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_disabledAuth",
")",
"{",
"return",
"[",
"]",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"_auth",
"instanceof",
"Closure",
")",
"{",
"$",
"this",
"->",
"_auth",
"=",
"call_... | Returns auth settings.
@return array | [
"Returns",
"auth",
"settings",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/AbstractConnection.php#L105-L115 | train |
hiqdev/yii2-hiart | src/AbstractConnection.php | AbstractConnection.checkResponse | public function checkResponse(ResponseInterface $response)
{
if (isset($this->_errorChecker)) {
$error = call_user_func($this->_errorChecker, $response);
} else {
$error = $this->getResponseError($response);
}
if ($error) {
throw new ResponseErrorException($error, $response);
}
} | php | public function checkResponse(ResponseInterface $response)
{
if (isset($this->_errorChecker)) {
$error = call_user_func($this->_errorChecker, $response);
} else {
$error = $this->getResponseError($response);
}
if ($error) {
throw new ResponseErrorException($error, $response);
}
} | [
"public",
"function",
"checkResponse",
"(",
"ResponseInterface",
"$",
"response",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_errorChecker",
")",
")",
"{",
"$",
"error",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"_errorChecker",
",",
"$",
... | Checks response method and raises exception if error found.
@param ResponseInterface $response response data from API
@throws ResponseErrorException when response is invalid | [
"Checks",
"response",
"method",
"and",
"raises",
"exception",
"if",
"error",
"found",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/AbstractConnection.php#L259-L270 | train |
hiqdev/yii2-hiart | src/AbstractConnection.php | AbstractConnection.getBaseUri | public function getBaseUri()
{
if (empty($this->baseUriChecked)) {
if (preg_match('#^https?://[^/]+$#', $this->baseUri)) {
$this->baseUri .= '/';
}
$this->baseUriChecked = true;
}
return $this->baseUri;
} | php | public function getBaseUri()
{
if (empty($this->baseUriChecked)) {
if (preg_match('#^https?://[^/]+$#', $this->baseUri)) {
$this->baseUri .= '/';
}
$this->baseUriChecked = true;
}
return $this->baseUri;
} | [
"public",
"function",
"getBaseUri",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"baseUriChecked",
")",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'#^https?://[^/]+$#'",
",",
"$",
"this",
"->",
"baseUri",
")",
")",
"{",
"$",
"this",
"->",
... | Return API base uri.
Adds trailing slash if uri is domain only.
@return string | [
"Return",
"API",
"base",
"uri",
".",
"Adds",
"trailing",
"slash",
"if",
"uri",
"is",
"domain",
"only",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/AbstractConnection.php#L287-L297 | train |
hiqdev/yii2-hiart | src/AbstractResponse.php | AbstractResponse.isJson | public function isJson()
{
$value = $this->getHeader('Content-Type');
if ($value === null) {
return false;
}
return !empty(preg_grep('|application/json|i', $value));
} | php | public function isJson()
{
$value = $this->getHeader('Content-Type');
if ($value === null) {
return false;
}
return !empty(preg_grep('|application/json|i', $value));
} | [
"public",
"function",
"isJson",
"(",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"getHeader",
"(",
"'Content-Type'",
")",
";",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"false",
";",
"}",
"return",
"!",
"empty",
"(",
"preg_grep"... | Method checks whether response is a JSON response.
@return bool | [
"Method",
"checks",
"whether",
"response",
"is",
"a",
"JSON",
"response",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/AbstractResponse.php#L88-L96 | train |
hiqdev/yii2-hiart | src/curl/Response.php | Response.parseRawResponse | protected function parseRawResponse($data, $info)
{
$result = [];
$headerSize = $info['header_size'];
$result['data'] = substr($data, $headerSize);
$rawHeaders = explode("\r\n", substr($data, 0, $headerSize));
// First line is status-code HTTP/1.1 200 OK
list(, $result['statusCode'], $result['reasonPhrase']) = explode(' ', array_shift($rawHeaders), 3);
foreach ($rawHeaders as $line) {
if ($line === '') {
continue;
}
list($key, $value) = explode(': ', $line);
$result['headers'][strtolower($key)][] = $value;
}
return $result;
} | php | protected function parseRawResponse($data, $info)
{
$result = [];
$headerSize = $info['header_size'];
$result['data'] = substr($data, $headerSize);
$rawHeaders = explode("\r\n", substr($data, 0, $headerSize));
// First line is status-code HTTP/1.1 200 OK
list(, $result['statusCode'], $result['reasonPhrase']) = explode(' ', array_shift($rawHeaders), 3);
foreach ($rawHeaders as $line) {
if ($line === '') {
continue;
}
list($key, $value) = explode(': ', $line);
$result['headers'][strtolower($key)][] = $value;
}
return $result;
} | [
"protected",
"function",
"parseRawResponse",
"(",
"$",
"data",
",",
"$",
"info",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"$",
"headerSize",
"=",
"$",
"info",
"[",
"'header_size'",
"]",
";",
"$",
"result",
"[",
"'data'",
"]",
"=",
"substr",
"(",
... | Parses raw response and returns parsed information.
@param string $data the raw response
@param array $info the curl information (result of `gurl_getinfo` call)
@return array array with the following keys will be returned:
- data: string, response data;
- headers: array, response headers;
- statusCode: string, the response status-code;
- reasonPhrase: string, the response reason phrase (OK, NOT FOUND, etc) | [
"Parses",
"raw",
"response",
"and",
"returns",
"parsed",
"information",
"."
] | fca300caa9284b9bd6f6fc1519427eaac9640b6f | https://github.com/hiqdev/yii2-hiart/blob/fca300caa9284b9bd6f6fc1519427eaac9640b6f/src/curl/Response.php#L109-L129 | train |
silverstripe/silverstripe-siteconfig | code/SiteConfig.php | SiteConfig.requireDefaultRecords | public function requireDefaultRecords()
{
parent::requireDefaultRecords();
$config = DataObject::get_one(SiteConfig::class);
if (!$config) {
self::make_site_config();
DB::alteration_message("Added default site config", "created");
}
} | php | public function requireDefaultRecords()
{
parent::requireDefaultRecords();
$config = DataObject::get_one(SiteConfig::class);
if (!$config) {
self::make_site_config();
DB::alteration_message("Added default site config", "created");
}
} | [
"public",
"function",
"requireDefaultRecords",
"(",
")",
"{",
"parent",
"::",
"requireDefaultRecords",
"(",
")",
";",
"$",
"config",
"=",
"DataObject",
"::",
"get_one",
"(",
"SiteConfig",
"::",
"class",
")",
";",
"if",
"(",
"!",
"$",
"config",
")",
"{",
... | Setup a default SiteConfig record if none exists. | [
"Setup",
"a",
"default",
"SiteConfig",
"record",
"if",
"none",
"exists",
"."
] | b501eceefc4a7b40ec3deb119778cb5d3eacaaf8 | https://github.com/silverstripe/silverstripe-siteconfig/blob/b501eceefc4a7b40ec3deb119778cb5d3eacaaf8/code/SiteConfig.php#L284-L295 | train |
silverstripe/silverstripe-siteconfig | code/SiteConfig.php | SiteConfig.canView | public function canView($member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
$extended = $this->extendedCan('canView', $member);
if ($extended !== null) {
return $extended;
}
// Assuming all that can edit this object can also view it
return $this->canEdit($member);
} | php | public function canView($member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
$extended = $this->extendedCan('canView', $member);
if ($extended !== null) {
return $extended;
}
// Assuming all that can edit this object can also view it
return $this->canEdit($member);
} | [
"public",
"function",
"canView",
"(",
"$",
"member",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"$",
"member",
"=",
"Security",
"::",
"getCurrentUser",
"(",
")",
";",
"}",
"$",
"extended",
"=",
"$",
"this",
"->",
"extendedCan",
... | Can a user view this SiteConfig instance?
@param Member $member
@return boolean | [
"Can",
"a",
"user",
"view",
"this",
"SiteConfig",
"instance?"
] | b501eceefc4a7b40ec3deb119778cb5d3eacaaf8 | https://github.com/silverstripe/silverstripe-siteconfig/blob/b501eceefc4a7b40ec3deb119778cb5d3eacaaf8/code/SiteConfig.php#L316-L329 | train |
silverstripe/silverstripe-siteconfig | code/SiteConfig.php | SiteConfig.canViewPages | public function canViewPages($member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
if ($member && Permission::checkMember($member, "ADMIN")) {
return true;
}
$extended = $this->extendedCan('canViewPages', $member);
if ($extended !== null) {
return $extended;
}
if (!$this->CanViewType || $this->CanViewType == 'Anyone') {
return true;
}
// check for any logged-in users
if ($this->CanViewType === 'LoggedInUsers' && $member) {
return true;
}
// check for specific groups
if ($this->CanViewType === 'OnlyTheseUsers' && $member && $member->inGroups($this->ViewerGroups())) {
return true;
}
return false;
} | php | public function canViewPages($member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
if ($member && Permission::checkMember($member, "ADMIN")) {
return true;
}
$extended = $this->extendedCan('canViewPages', $member);
if ($extended !== null) {
return $extended;
}
if (!$this->CanViewType || $this->CanViewType == 'Anyone') {
return true;
}
// check for any logged-in users
if ($this->CanViewType === 'LoggedInUsers' && $member) {
return true;
}
// check for specific groups
if ($this->CanViewType === 'OnlyTheseUsers' && $member && $member->inGroups($this->ViewerGroups())) {
return true;
}
return false;
} | [
"public",
"function",
"canViewPages",
"(",
"$",
"member",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"$",
"member",
"=",
"Security",
"::",
"getCurrentUser",
"(",
")",
";",
"}",
"if",
"(",
"$",
"member",
"&&",
"Permission",
"::",
... | Can a user view pages on this site? This method is only
called if a page is set to Inherit, but there is nothing
to inherit from.
@param Member $member
@return boolean | [
"Can",
"a",
"user",
"view",
"pages",
"on",
"this",
"site?",
"This",
"method",
"is",
"only",
"called",
"if",
"a",
"page",
"is",
"set",
"to",
"Inherit",
"but",
"there",
"is",
"nothing",
"to",
"inherit",
"from",
"."
] | b501eceefc4a7b40ec3deb119778cb5d3eacaaf8 | https://github.com/silverstripe/silverstripe-siteconfig/blob/b501eceefc4a7b40ec3deb119778cb5d3eacaaf8/code/SiteConfig.php#L339-L369 | train |
silverstripe/silverstripe-siteconfig | code/SiteConfig.php | SiteConfig.canEditPages | public function canEditPages($member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
if ($member && Permission::checkMember($member, "ADMIN")) {
return true;
}
$extended = $this->extendedCan('canEditPages', $member);
if ($extended !== null) {
return $extended;
}
// check for any logged-in users with CMS access
if ($this->CanEditType === 'LoggedInUsers'
&& Permission::checkMember($member, $this->config()->get('required_permission'))
) {
return true;
}
// check for specific groups
if ($this->CanEditType === 'OnlyTheseUsers' && $member && $member->inGroups($this->EditorGroups())) {
return true;
}
return false;
} | php | public function canEditPages($member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
if ($member && Permission::checkMember($member, "ADMIN")) {
return true;
}
$extended = $this->extendedCan('canEditPages', $member);
if ($extended !== null) {
return $extended;
}
// check for any logged-in users with CMS access
if ($this->CanEditType === 'LoggedInUsers'
&& Permission::checkMember($member, $this->config()->get('required_permission'))
) {
return true;
}
// check for specific groups
if ($this->CanEditType === 'OnlyTheseUsers' && $member && $member->inGroups($this->EditorGroups())) {
return true;
}
return false;
} | [
"public",
"function",
"canEditPages",
"(",
"$",
"member",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"$",
"member",
"=",
"Security",
"::",
"getCurrentUser",
"(",
")",
";",
"}",
"if",
"(",
"$",
"member",
"&&",
"Permission",
"::",
... | Can a user edit pages on this site? This method is only
called if a page is set to Inherit, but there is nothing
to inherit from, or on new records without a parent.
@param Member $member
@return boolean | [
"Can",
"a",
"user",
"edit",
"pages",
"on",
"this",
"site?",
"This",
"method",
"is",
"only",
"called",
"if",
"a",
"page",
"is",
"set",
"to",
"Inherit",
"but",
"there",
"is",
"nothing",
"to",
"inherit",
"from",
"or",
"on",
"new",
"records",
"without",
"a... | b501eceefc4a7b40ec3deb119778cb5d3eacaaf8 | https://github.com/silverstripe/silverstripe-siteconfig/blob/b501eceefc4a7b40ec3deb119778cb5d3eacaaf8/code/SiteConfig.php#L379-L407 | train |
silverstripe/silverstripe-siteconfig | code/SiteConfig.php | SiteConfig.canCreateTopLevel | public function canCreateTopLevel($member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
if ($member && Permission::checkMember($member, "ADMIN")) {
return true;
}
$extended = $this->extendedCan('canCreateTopLevel', $member);
if ($extended !== null) {
return $extended;
}
// check for any logged-in users with CMS permission
if ($this->CanCreateTopLevelType === 'LoggedInUsers'
&& Permission::checkMember($member, $this->config()->get('required_permission'))
) {
return true;
}
// check for specific groups
if ($this->CanCreateTopLevelType === 'OnlyTheseUsers'
&& $member
&& $member->inGroups($this->CreateTopLevelGroups())
) {
return true;
}
return false;
} | php | public function canCreateTopLevel($member = null)
{
if (!$member) {
$member = Security::getCurrentUser();
}
if ($member && Permission::checkMember($member, "ADMIN")) {
return true;
}
$extended = $this->extendedCan('canCreateTopLevel', $member);
if ($extended !== null) {
return $extended;
}
// check for any logged-in users with CMS permission
if ($this->CanCreateTopLevelType === 'LoggedInUsers'
&& Permission::checkMember($member, $this->config()->get('required_permission'))
) {
return true;
}
// check for specific groups
if ($this->CanCreateTopLevelType === 'OnlyTheseUsers'
&& $member
&& $member->inGroups($this->CreateTopLevelGroups())
) {
return true;
}
return false;
} | [
"public",
"function",
"canCreateTopLevel",
"(",
"$",
"member",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"member",
")",
"{",
"$",
"member",
"=",
"Security",
"::",
"getCurrentUser",
"(",
")",
";",
"}",
"if",
"(",
"$",
"member",
"&&",
"Permission",
"... | Can a user create pages in the root of this site?
@param Member $member
@return boolean | [
"Can",
"a",
"user",
"create",
"pages",
"in",
"the",
"root",
"of",
"this",
"site?"
] | b501eceefc4a7b40ec3deb119778cb5d3eacaaf8 | https://github.com/silverstripe/silverstripe-siteconfig/blob/b501eceefc4a7b40ec3deb119778cb5d3eacaaf8/code/SiteConfig.php#L450-L481 | train |
doctrine/skeleton-mapper | lib/Doctrine/SkeletonMapper/Persister/BasicObjectPersister.php | BasicObjectPersister.preparePersistChangeSet | public function preparePersistChangeSet($object) : array
{
if (! $object instanceof PersistableInterface) {
throw new InvalidArgumentException(
sprintf('%s must implement PersistableInterface.', get_class($object))
);
}
return $object->preparePersistChangeSet();
} | php | public function preparePersistChangeSet($object) : array
{
if (! $object instanceof PersistableInterface) {
throw new InvalidArgumentException(
sprintf('%s must implement PersistableInterface.', get_class($object))
);
}
return $object->preparePersistChangeSet();
} | [
"public",
"function",
"preparePersistChangeSet",
"(",
"$",
"object",
")",
":",
"array",
"{",
"if",
"(",
"!",
"$",
"object",
"instanceof",
"PersistableInterface",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'%s must implement Persistab... | Prepares an object changeset for persistence.
@param object $object
@return mixed[] | [
"Prepares",
"an",
"object",
"changeset",
"for",
"persistence",
"."
] | 478c0fafcdc2df37159193b74fedaf89643891eb | https://github.com/doctrine/skeleton-mapper/blob/478c0fafcdc2df37159193b74fedaf89643891eb/lib/Doctrine/SkeletonMapper/Persister/BasicObjectPersister.php#L52-L61 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.