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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
QoboLtd/qobo-robo | src/Command/Mysql/Schema.php | Schema.mysqlSchema | public function mysqlSchema($db, $file = 'etc/mysql.sql', $user = 'root', $pass = null, $host = null, $port = null, $opts = ['format' => 'table', 'fields' => ''])
{
$result = $this->taskMysqlSchema()
->db($db)
->file($file)
->user($user)
->pass($pass)
->host($host)
->port($port)
->hide($pass)
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
return true;
} | php | public function mysqlSchema($db, $file = 'etc/mysql.sql', $user = 'root', $pass = null, $host = null, $port = null, $opts = ['format' => 'table', 'fields' => ''])
{
$result = $this->taskMysqlSchema()
->db($db)
->file($file)
->user($user)
->pass($pass)
->host($host)
->port($port)
->hide($pass)
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
return true;
} | [
"public",
"function",
"mysqlSchema",
"(",
"$",
"db",
",",
"$",
"file",
"=",
"'etc/mysql.sql'",
",",
"$",
"user",
"=",
"'root'",
",",
"$",
"pass",
"=",
"null",
",",
"$",
"host",
"=",
"null",
",",
"$",
"port",
"=",
"null",
",",
"$",
"opts",
"=",
"[... | Dump mysql database schema
@param string $db Database name
@param string $file Destination file for a dump
@param string $user MySQL user to bind with
@param string $pass (Optional) MySQL user password
@param string $host (Optional) MySQL server host
@param string $port (Optional) MySQL server port
@option string $format Output format (table, list, csv, json, xml)
@option string $fields Limit output to given fields, comma-separated
@return PropertyList result | [
"Dump",
"mysql",
"database",
"schema"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/Command/Mysql/Schema.php#L33-L50 | train |
QoboLtd/qobo-robo | src/AbstractCmdTask.php | AbstractCmdTask.checkPath | public static function checkPath($path)
{
if (!is_string($path)) {
throw new InvalidArgumentException(sprintf("String expected as path, got '%s' instead", gettype($path)));
}
if (!file_exists($path)) {
throw new InvalidArgumentException(sprintf("'%s' does not exist", $path));
}
if (!is_dir($path)) {
throw new InvalidArgumentException(sprintf("'%s' is not a directory", $path));
}
if (!is_readable($path)) {
throw new InvalidArgumentException(sprintf("'%s' is not readable", $path));
}
return true;
} | php | public static function checkPath($path)
{
if (!is_string($path)) {
throw new InvalidArgumentException(sprintf("String expected as path, got '%s' instead", gettype($path)));
}
if (!file_exists($path)) {
throw new InvalidArgumentException(sprintf("'%s' does not exist", $path));
}
if (!is_dir($path)) {
throw new InvalidArgumentException(sprintf("'%s' is not a directory", $path));
}
if (!is_readable($path)) {
throw new InvalidArgumentException(sprintf("'%s' is not readable", $path));
}
return true;
} | [
"public",
"static",
"function",
"checkPath",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"\"String expected as path, got '%s' instead\"",
",",
"gettype... | Check if path is readable | [
"Check",
"if",
"path",
"is",
"readable"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/AbstractCmdTask.php#L130-L148 | train |
QoboLtd/qobo-robo | src/AbstractCmdTask.php | AbstractCmdTask.checkCmd | public static function checkCmd($cmd)
{
// cut out the actual executable part only
// and leave args away
$cmdParts = preg_split("/\s+/", $cmd);
$cmd = $cmdParts[0];
// try to find a command if not absolute path is given
if (!preg_match('/^\.?\/.*$/', $cmd)) {
$retval = null;
$ouput = [];
$fullCmd = exec("which $cmd", $output, $retval);
if ($retval) {
throw new InvalidArgumentException(sprintf("Failed to find full path for '%s'", $cmd));
}
$cmd = trim($fullCmd);
}
if (!file_exists($cmd)) {
throw new InvalidArgumentException(sprintf("'%s' does not exist", $cmd));
}
if (!is_file($cmd)) {
throw new InvalidArgumentException(sprintf("'%s' is not a file", $cmd));
}
if (!is_executable($cmd)) {
throw new InvalidArgumentException(sprintf("'%s' is not executable", $cmd));
}
return true;
} | php | public static function checkCmd($cmd)
{
// cut out the actual executable part only
// and leave args away
$cmdParts = preg_split("/\s+/", $cmd);
$cmd = $cmdParts[0];
// try to find a command if not absolute path is given
if (!preg_match('/^\.?\/.*$/', $cmd)) {
$retval = null;
$ouput = [];
$fullCmd = exec("which $cmd", $output, $retval);
if ($retval) {
throw new InvalidArgumentException(sprintf("Failed to find full path for '%s'", $cmd));
}
$cmd = trim($fullCmd);
}
if (!file_exists($cmd)) {
throw new InvalidArgumentException(sprintf("'%s' does not exist", $cmd));
}
if (!is_file($cmd)) {
throw new InvalidArgumentException(sprintf("'%s' is not a file", $cmd));
}
if (!is_executable($cmd)) {
throw new InvalidArgumentException(sprintf("'%s' is not executable", $cmd));
}
return true;
} | [
"public",
"static",
"function",
"checkCmd",
"(",
"$",
"cmd",
")",
"{",
"// cut out the actual executable part only",
"// and leave args away",
"$",
"cmdParts",
"=",
"preg_split",
"(",
"\"/\\s+/\"",
",",
"$",
"cmd",
")",
";",
"$",
"cmd",
"=",
"$",
"cmdParts",
"["... | Check if cmd exists and is an executable file | [
"Check",
"if",
"cmd",
"exists",
"and",
"is",
"an",
"executable",
"file"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/AbstractCmdTask.php#L153-L183 | train |
orchestral/support | src/Support/Nesty.php | Nesty.addParent | protected function addParent(string $id): Fluent
{
return $this->items[$id] = $this->toFluent($id);
} | php | protected function addParent(string $id): Fluent
{
return $this->items[$id] = $this->toFluent($id);
} | [
"protected",
"function",
"addParent",
"(",
"string",
"$",
"id",
")",
":",
"Fluent",
"{",
"return",
"$",
"this",
"->",
"items",
"[",
"$",
"id",
"]",
"=",
"$",
"this",
"->",
"toFluent",
"(",
"$",
"id",
")",
";",
"}"
] | Add item as parent.
@param string $id
@return \Orchestra\Support\Fluent | [
"Add",
"item",
"as",
"parent",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Support/Nesty.php#L149-L152 | train |
anomalylabs/variables-module | src/VariablesModulePlugin.php | VariablesModulePlugin.getFunctions | public function getFunctions()
{
return [
new \Twig_SimpleFunction(
'variable',
function ($group, $field) {
return $this->dispatch(new GetValuePresenter($group, $field));
}
),
new \Twig_SimpleFunction(
'variable_value',
function ($group, $field, $default = null) {
return $this->dispatch(new GetVariableValue($group, $field, $default));
}
),
new \Twig_SimpleFunction(
'variable_group',
function ($group) {
return (new Decorator())->decorate($this->dispatch(new GetVariableGroup($group)));
}
),
];
} | php | public function getFunctions()
{
return [
new \Twig_SimpleFunction(
'variable',
function ($group, $field) {
return $this->dispatch(new GetValuePresenter($group, $field));
}
),
new \Twig_SimpleFunction(
'variable_value',
function ($group, $field, $default = null) {
return $this->dispatch(new GetVariableValue($group, $field, $default));
}
),
new \Twig_SimpleFunction(
'variable_group',
function ($group) {
return (new Decorator())->decorate($this->dispatch(new GetVariableGroup($group)));
}
),
];
} | [
"public",
"function",
"getFunctions",
"(",
")",
"{",
"return",
"[",
"new",
"\\",
"Twig_SimpleFunction",
"(",
"'variable'",
",",
"function",
"(",
"$",
"group",
",",
"$",
"field",
")",
"{",
"return",
"$",
"this",
"->",
"dispatch",
"(",
"new",
"GetValuePresen... | Get the functions.
@return array | [
"Get",
"the",
"functions",
"."
] | bcd903670471a175f07aba3123693cb3a3c07d0b | https://github.com/anomalylabs/variables-module/blob/bcd903670471a175f07aba3123693cb3a3c07d0b/src/VariablesModulePlugin.php#L24-L46 | train |
nails/module-invoice | src/Factory/RequestBase.php | RequestBase.setDriver | public function setDriver($sDriverSlug)
{
// Validate the driver
$aDrivers = $this->oDriverService->getEnabled();
$oDriver = null;
foreach ($aDrivers as $oDriverConfig) {
if ($oDriverConfig->slug == $sDriverSlug) {
$oDriver = $this->oDriverService->getInstance($oDriverConfig->slug);
break;
}
}
if (empty($oDriver)) {
throw new RequestException('"' . $sDriverSlug . '" is not a valid payment driver.');
}
$this->oDriver = $oDriver;
return $this;
} | php | public function setDriver($sDriverSlug)
{
// Validate the driver
$aDrivers = $this->oDriverService->getEnabled();
$oDriver = null;
foreach ($aDrivers as $oDriverConfig) {
if ($oDriverConfig->slug == $sDriverSlug) {
$oDriver = $this->oDriverService->getInstance($oDriverConfig->slug);
break;
}
}
if (empty($oDriver)) {
throw new RequestException('"' . $sDriverSlug . '" is not a valid payment driver.');
}
$this->oDriver = $oDriver;
return $this;
} | [
"public",
"function",
"setDriver",
"(",
"$",
"sDriverSlug",
")",
"{",
"// Validate the driver",
"$",
"aDrivers",
"=",
"$",
"this",
"->",
"oDriverService",
"->",
"getEnabled",
"(",
")",
";",
"$",
"oDriver",
"=",
"null",
";",
"foreach",
"(",
"$",
"aDrivers",
... | Set the driver to be used for the request
@param string $sDriverSlug The driver's slug
@return $this
@throws RequestException | [
"Set",
"the",
"driver",
"to",
"be",
"used",
"for",
"the",
"request"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Factory/RequestBase.php#L52-L71 | train |
nails/module-invoice | src/Factory/RequestBase.php | RequestBase.setInvoice | public function setInvoice($iInvoiceId)
{
// Validate
$oModel = $this->oInvoiceModel;
$oInvoice = $oModel->getById(
$iInvoiceId,
['expand' => $oModel::EXPAND_ALL]
);
if (empty($oInvoice)) {
throw new RequestException('Invalid invoice ID.');
}
$this->oInvoice = $oInvoice;
return $this;
} | php | public function setInvoice($iInvoiceId)
{
// Validate
$oModel = $this->oInvoiceModel;
$oInvoice = $oModel->getById(
$iInvoiceId,
['expand' => $oModel::EXPAND_ALL]
);
if (empty($oInvoice)) {
throw new RequestException('Invalid invoice ID.');
}
$this->oInvoice = $oInvoice;
return $this;
} | [
"public",
"function",
"setInvoice",
"(",
"$",
"iInvoiceId",
")",
"{",
"// Validate",
"$",
"oModel",
"=",
"$",
"this",
"->",
"oInvoiceModel",
";",
"$",
"oInvoice",
"=",
"$",
"oModel",
"->",
"getById",
"(",
"$",
"iInvoiceId",
",",
"[",
"'expand'",
"=>",
"... | Set the invoice object
@param integer $iInvoiceId The invoice to use for the request
@return $this
@throws RequestException | [
"Set",
"the",
"invoice",
"object"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Factory/RequestBase.php#L83-L98 | train |
nails/module-invoice | src/Factory/RequestBase.php | RequestBase.setPayment | public function setPayment($iPaymentId)
{
// Validate
$oPayment = $this->oPaymentModel->getById(
$iPaymentId,
['expand' => ['invoice']]
);
if (empty($oPayment)) {
throw new RequestException('Invalid payment ID.');
}
$this->oPayment = $oPayment;
return $this;
} | php | public function setPayment($iPaymentId)
{
// Validate
$oPayment = $this->oPaymentModel->getById(
$iPaymentId,
['expand' => ['invoice']]
);
if (empty($oPayment)) {
throw new RequestException('Invalid payment ID.');
}
$this->oPayment = $oPayment;
return $this;
} | [
"public",
"function",
"setPayment",
"(",
"$",
"iPaymentId",
")",
"{",
"// Validate",
"$",
"oPayment",
"=",
"$",
"this",
"->",
"oPaymentModel",
"->",
"getById",
"(",
"$",
"iPaymentId",
",",
"[",
"'expand'",
"=>",
"[",
"'invoice'",
"]",
"]",
")",
";",
"if... | Set the payment object
@param integer $iPaymentId The payment to use for the request
@return $this
@throws RequestException | [
"Set",
"the",
"payment",
"object"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Factory/RequestBase.php#L110-L124 | train |
nails/module-invoice | src/Factory/RequestBase.php | RequestBase.setRefund | public function setRefund($iRefundId)
{
// Validate
$oRefund = $this->oRefundModel->getById($iRefundId);
if (empty($oRefund)) {
throw new RequestException('Invalid refund ID.');
}
$this->oRefund = $oRefund;
return $this;
} | php | public function setRefund($iRefundId)
{
// Validate
$oRefund = $this->oRefundModel->getById($iRefundId);
if (empty($oRefund)) {
throw new RequestException('Invalid refund ID.');
}
$this->oRefund = $oRefund;
return $this;
} | [
"public",
"function",
"setRefund",
"(",
"$",
"iRefundId",
")",
"{",
"// Validate",
"$",
"oRefund",
"=",
"$",
"this",
"->",
"oRefundModel",
"->",
"getById",
"(",
"$",
"iRefundId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"oRefund",
")",
")",
"{",
"throw... | Set the refund object
@param integer $iRefundId The refund to use for the request
@return $this
@throws RequestException | [
"Set",
"the",
"refund",
"object"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Factory/RequestBase.php#L136-L147 | train |
nails/module-invoice | src/Factory/RequestBase.php | RequestBase.setPaymentComplete | protected function setPaymentComplete($sTxnId = null, $iFee = null)
{
// Ensure we have a payment
if (empty($this->oPayment)) {
throw new RequestException('No payment selected.');
}
// Ensure we have an invoice
if (empty($this->oInvoice)) {
throw new RequestException('No invoice selected.');
}
// Update the payment
$aData = ['txn_id' => $sTxnId ? $sTxnId : null];
if (!is_null($iFee)) {
$aData['fee'] = $iFee;
}
if (!$this->oPaymentModel->setComplete($this->oPayment->id, $aData)) {
throw new RequestException('Failed to update existing payment.');
}
// Has the invoice been paid in full? If so, mark it as paid and fire the invoice.paid event
if ($this->oInvoiceModel->isPaid($this->oInvoice->id)) {
// Mark Invoice as PAID
if (!$this->oInvoiceModel->setPaid($this->oInvoice->id)) {
throw new RequestException('Failed to mark invoice as paid.');
}
}
// Send receipt email
$this->oPaymentModel->sendReceipt($this->oPayment->id);
return $this;
} | php | protected function setPaymentComplete($sTxnId = null, $iFee = null)
{
// Ensure we have a payment
if (empty($this->oPayment)) {
throw new RequestException('No payment selected.');
}
// Ensure we have an invoice
if (empty($this->oInvoice)) {
throw new RequestException('No invoice selected.');
}
// Update the payment
$aData = ['txn_id' => $sTxnId ? $sTxnId : null];
if (!is_null($iFee)) {
$aData['fee'] = $iFee;
}
if (!$this->oPaymentModel->setComplete($this->oPayment->id, $aData)) {
throw new RequestException('Failed to update existing payment.');
}
// Has the invoice been paid in full? If so, mark it as paid and fire the invoice.paid event
if ($this->oInvoiceModel->isPaid($this->oInvoice->id)) {
// Mark Invoice as PAID
if (!$this->oInvoiceModel->setPaid($this->oInvoice->id)) {
throw new RequestException('Failed to mark invoice as paid.');
}
}
// Send receipt email
$this->oPaymentModel->sendReceipt($this->oPayment->id);
return $this;
} | [
"protected",
"function",
"setPaymentComplete",
"(",
"$",
"sTxnId",
"=",
"null",
",",
"$",
"iFee",
"=",
"null",
")",
"{",
"// Ensure we have a payment",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"oPayment",
")",
")",
"{",
"throw",
"new",
"RequestException"... | Set a payment as COMPLETE, and mark the invoice as paid if so
@param string $sTxnId The payment's transaction ID
@param integer $iFee The fee charged by the processor, if known
@return $this
@throws RequestException | [
"Set",
"a",
"payment",
"as",
"COMPLETE",
"and",
"mark",
"the",
"invoice",
"as",
"paid",
"if",
"so"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Factory/RequestBase.php#L203-L239 | train |
doganoo/PHPUtil | src/FileSystem/FileHandler.php | FileHandler.forceCreate | public function forceCreate(): bool {
if (!$this->isFile()) {
return \mkdir($this->path, 0744, true);
}
if ($this->isFile() && !$this->isWritable()) {
$user = \get_current_user();
return \chown($this->path, $user);
}
return false;
} | php | public function forceCreate(): bool {
if (!$this->isFile()) {
return \mkdir($this->path, 0744, true);
}
if ($this->isFile() && !$this->isWritable()) {
$user = \get_current_user();
return \chown($this->path, $user);
}
return false;
} | [
"public",
"function",
"forceCreate",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isFile",
"(",
")",
")",
"{",
"return",
"\\",
"mkdir",
"(",
"$",
"this",
"->",
"path",
",",
"0744",
",",
"true",
")",
";",
"}",
"if",
"(",
"$",
... | forces a file creation
@return bool
@deprecated Use create() instead | [
"forces",
"a",
"file",
"creation"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/FileSystem/FileHandler.php#L111-L120 | train |
doganoo/PHPUtil | src/FileSystem/FileHandler.php | FileHandler.getContent | public function getContent(): ?string {
if (null !== $this->content) return $this->content;
if (!$this->isFile()) return null;
$content = \file_get_contents($this->path);
if (false === $content) return null;
return $content;
} | php | public function getContent(): ?string {
if (null !== $this->content) return $this->content;
if (!$this->isFile()) return null;
$content = \file_get_contents($this->path);
if (false === $content) return null;
return $content;
} | [
"public",
"function",
"getContent",
"(",
")",
":",
"?",
"string",
"{",
"if",
"(",
"null",
"!==",
"$",
"this",
"->",
"content",
")",
"return",
"$",
"this",
"->",
"content",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"isFile",
"(",
")",
")",
"return",
... | returns the file content if file is available. Otherwise null
@return null|string | [
"returns",
"the",
"file",
"content",
"if",
"file",
"is",
"available",
".",
"Otherwise",
"null"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/FileSystem/FileHandler.php#L136-L142 | train |
nails/module-invoice | src/Model/Invoice/Item.php | Item.getUnits | public function getUnits()
{
return [
self::UNIT_NONE => 'None',
self::UNIT_MINUTE => 'Minutes',
self::UNIT_HOUR => 'Hours',
self::UNIT_DAY => 'Days',
self::UNIT_WEEK => 'Weeks',
self::UNIT_MONTH => 'Months',
self::UNIT_YEAR => 'Years',
];
} | php | public function getUnits()
{
return [
self::UNIT_NONE => 'None',
self::UNIT_MINUTE => 'Minutes',
self::UNIT_HOUR => 'Hours',
self::UNIT_DAY => 'Days',
self::UNIT_WEEK => 'Weeks',
self::UNIT_MONTH => 'Months',
self::UNIT_YEAR => 'Years',
];
} | [
"public",
"function",
"getUnits",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"UNIT_NONE",
"=>",
"'None'",
",",
"self",
"::",
"UNIT_MINUTE",
"=>",
"'Minutes'",
",",
"self",
"::",
"UNIT_HOUR",
"=>",
"'Hours'",
",",
"self",
"::",
"UNIT_DAY",
"=>",
"'Days'",
... | Returns the item quantity units with human friendly names
@return array | [
"Returns",
"the",
"item",
"quantity",
"units",
"with",
"human",
"friendly",
"names"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Invoice/Item.php#L71-L82 | train |
doganoo/PHPUtil | src/Datatype/StringClass.php | StringClass.replace | public function replace($search, $value) {
$this->value = str_replace($search, $value, $this->value);
} | php | public function replace($search, $value) {
$this->value = str_replace($search, $value, $this->value);
} | [
"public",
"function",
"replace",
"(",
"$",
"search",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"str_replace",
"(",
"$",
"search",
",",
"$",
"value",
",",
"$",
"this",
"->",
"value",
")",
";",
"}"
] | replaces search by value
@param $search
@param $value | [
"replaces",
"search",
"by",
"value"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Datatype/StringClass.php#L129-L131 | train |
doganoo/PHPUtil | src/Datatype/StringClass.php | StringClass.replaceIgnoreCase | public function replaceIgnoreCase($search, $value) {
$this->value = str_ireplace($search, $value, $this->value);
} | php | public function replaceIgnoreCase($search, $value) {
$this->value = str_ireplace($search, $value, $this->value);
} | [
"public",
"function",
"replaceIgnoreCase",
"(",
"$",
"search",
",",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"str_ireplace",
"(",
"$",
"search",
",",
"$",
"value",
",",
"$",
"this",
"->",
"value",
")",
";",
"}"
] | replaces search by value and is case insensitive
@param $search
@param $value | [
"replaces",
"search",
"by",
"value",
"and",
"is",
"case",
"insensitive"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Datatype/StringClass.php#L139-L141 | train |
doganoo/PHPUtil | src/Datatype/StringClass.php | StringClass.hasPrefix | public function hasPrefix(string $prefix):bool {
if (0 !== $this->getLength() && "" === $prefix) return false;
return true === (substr( $this->getValue(), 0, strlen($prefix)) === $prefix);
} | php | public function hasPrefix(string $prefix):bool {
if (0 !== $this->getLength() && "" === $prefix) return false;
return true === (substr( $this->getValue(), 0, strlen($prefix)) === $prefix);
} | [
"public",
"function",
"hasPrefix",
"(",
"string",
"$",
"prefix",
")",
":",
"bool",
"{",
"if",
"(",
"0",
"!==",
"$",
"this",
"->",
"getLength",
"(",
")",
"&&",
"\"\"",
"===",
"$",
"prefix",
")",
"return",
"false",
";",
"return",
"true",
"===",
"(",
... | checks a prefix
have a look here: https://stackoverflow.com/a/2790919
@param string $prefix
@return bool | [
"checks",
"a",
"prefix"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Datatype/StringClass.php#L198-L201 | train |
doganoo/PHPUtil | src/Datatype/StringClass.php | StringClass.hasSuffix | public function hasSuffix(string $suffix):bool {
if (0 !== $this->getLength() && "" === $suffix) return false;
return (substr($this->getValue(), -1 * strlen($suffix), strlen($suffix)) === $suffix);
} | php | public function hasSuffix(string $suffix):bool {
if (0 !== $this->getLength() && "" === $suffix) return false;
return (substr($this->getValue(), -1 * strlen($suffix), strlen($suffix)) === $suffix);
} | [
"public",
"function",
"hasSuffix",
"(",
"string",
"$",
"suffix",
")",
":",
"bool",
"{",
"if",
"(",
"0",
"!==",
"$",
"this",
"->",
"getLength",
"(",
")",
"&&",
"\"\"",
"===",
"$",
"suffix",
")",
"return",
"false",
";",
"return",
"(",
"substr",
"(",
... | checks a suffix
@param string $suffix
@return bool | [
"checks",
"a",
"suffix"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Datatype/StringClass.php#L209-L212 | train |
nails/module-invoice | invoice/controllers/Invoice.php | Invoice.download | protected function download($oInvoice)
{
// Business details
$this->data['business'] = (object) [
'name' => appSetting('business_name', 'nails/module-invoice'),
'address' => appSetting('business_address', 'nails/module-invoice'),
'telephone' => appSetting('business_telephone', 'nails/module-invoice'),
'email' => appSetting('business_email', 'nails/module-invoice'),
'vat_number' => appSetting('business_vat_number', 'nails/module-invoice'),
];
$oInvoiceSkinService = Factory::service('InvoiceSkin', 'nails/module-invoice');
$sEnabledSkin = $oInvoiceSkinService->getEnabledSlug() ?: self::DEFAULT_INVOICE_SKIN;
$this->data['invoice'] = $oInvoice;
$this->data['isPdf'] = true;
$sHtml = $oInvoiceSkinService->view($sEnabledSkin, 'render', $this->data, true);
$oPdf = Factory::service('Pdf', 'nails/module-pdf');
$oPdf->setPaperSize('A4', 'portrait');
$oPdf->load_html($sHtml);
$oPdf->download('INVOICE-' . $oInvoice->ref . '.pdf');
} | php | protected function download($oInvoice)
{
// Business details
$this->data['business'] = (object) [
'name' => appSetting('business_name', 'nails/module-invoice'),
'address' => appSetting('business_address', 'nails/module-invoice'),
'telephone' => appSetting('business_telephone', 'nails/module-invoice'),
'email' => appSetting('business_email', 'nails/module-invoice'),
'vat_number' => appSetting('business_vat_number', 'nails/module-invoice'),
];
$oInvoiceSkinService = Factory::service('InvoiceSkin', 'nails/module-invoice');
$sEnabledSkin = $oInvoiceSkinService->getEnabledSlug() ?: self::DEFAULT_INVOICE_SKIN;
$this->data['invoice'] = $oInvoice;
$this->data['isPdf'] = true;
$sHtml = $oInvoiceSkinService->view($sEnabledSkin, 'render', $this->data, true);
$oPdf = Factory::service('Pdf', 'nails/module-pdf');
$oPdf->setPaperSize('A4', 'portrait');
$oPdf->load_html($sHtml);
$oPdf->download('INVOICE-' . $oInvoice->ref . '.pdf');
} | [
"protected",
"function",
"download",
"(",
"$",
"oInvoice",
")",
"{",
"// Business details",
"$",
"this",
"->",
"data",
"[",
"'business'",
"]",
"=",
"(",
"object",
")",
"[",
"'name'",
"=>",
"appSetting",
"(",
"'business_name'",
",",
"'nails/module-invoice'",
"... | Download a single invoice
@param \stdClass $oInvoice The invoice object
@return void | [
"Download",
"a",
"single",
"invoice"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/invoice/controllers/Invoice.php#L36-L58 | train |
nails/module-invoice | invoice/controllers/Invoice.php | Invoice.view | protected function view($oInvoice)
{
// Business details
$this->data['business'] = (object) [
'name' => appSetting('business_name', 'nails/module-invoice'),
'address' => appSetting('business_address', 'nails/module-invoice'),
'telephone' => appSetting('business_telephone', 'nails/module-invoice'),
'email' => appSetting('business_email', 'nails/module-invoice'),
'vat_number' => appSetting('business_vat_number', 'nails/module-invoice'),
];
$oInvoiceSkinService = Factory::service('InvoiceSkin', 'nails/module-invoice');
$sEnabledSkin = $oInvoiceSkinService->getEnabledSlug() ?: self::DEFAULT_INVOICE_SKIN;
$this->data['invoice'] = $oInvoice;
$this->data['isPdf'] = false;
$oInvoiceSkinService->view($sEnabledSkin, 'render', $this->data);
} | php | protected function view($oInvoice)
{
// Business details
$this->data['business'] = (object) [
'name' => appSetting('business_name', 'nails/module-invoice'),
'address' => appSetting('business_address', 'nails/module-invoice'),
'telephone' => appSetting('business_telephone', 'nails/module-invoice'),
'email' => appSetting('business_email', 'nails/module-invoice'),
'vat_number' => appSetting('business_vat_number', 'nails/module-invoice'),
];
$oInvoiceSkinService = Factory::service('InvoiceSkin', 'nails/module-invoice');
$sEnabledSkin = $oInvoiceSkinService->getEnabledSlug() ?: self::DEFAULT_INVOICE_SKIN;
$this->data['invoice'] = $oInvoice;
$this->data['isPdf'] = false;
$oInvoiceSkinService->view($sEnabledSkin, 'render', $this->data);
} | [
"protected",
"function",
"view",
"(",
"$",
"oInvoice",
")",
"{",
"// Business details",
"$",
"this",
"->",
"data",
"[",
"'business'",
"]",
"=",
"(",
"object",
")",
"[",
"'name'",
"=>",
"appSetting",
"(",
"'business_name'",
",",
"'nails/module-invoice'",
")",
... | View a single invoice
@param \stdClass $oInvoice The invoice object
@return void | [
"View",
"a",
"single",
"invoice"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/invoice/controllers/Invoice.php#L69-L86 | train |
QoboLtd/qobo-robo | src/DataAwareTrait.php | DataAwareTrait.setData | public function setData($name, $value)
{
if (!isset($this->data)) {
throw new RuntimeException("Data property is required for DataAwareTrait to work");
}
// we use snake_case field keys
// but camelCase setters
$name = $this->decamelize($name);
// only set values for predefined data keys
if (array_key_exists($name, $this->data)) {
$this->data[$name] = $value[0];
}
return $this;
} | php | public function setData($name, $value)
{
if (!isset($this->data)) {
throw new RuntimeException("Data property is required for DataAwareTrait to work");
}
// we use snake_case field keys
// but camelCase setters
$name = $this->decamelize($name);
// only set values for predefined data keys
if (array_key_exists($name, $this->data)) {
$this->data[$name] = $value[0];
}
return $this;
} | [
"public",
"function",
"setData",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Data property is required for DataAwareTrait to work\"",
")",
... | Data setter
Make sure only valid data passes through
@param string $name data key name
@param mixed $value data value name | [
"Data",
"setter",
"Make",
"sure",
"only",
"valid",
"data",
"passes",
"through"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/DataAwareTrait.php#L29-L45 | train |
QoboLtd/qobo-robo | src/DataAwareTrait.php | DataAwareTrait.checkRequiredData | protected function checkRequiredData()
{
if (!isset($this->data)) {
throw new RuntimeException("'data' property is required for DataAwareTrait to work");
}
if (!isset($this->requiredData)) {
throw new RuntimeException("'requiredData' property is required for DataAwareTrait to work");
}
$missing = [];
foreach ($this->requiredData as $key) {
if (!isset($this->data[$key])) {
$missing []= $key;
}
}
if (!count($missing)) {
return true;
}
throw new RuntimeException(
sprintf("Missing required data field(s) [%s]", implode(",", array_map([$this,"camelize"], $missing)))
);
} | php | protected function checkRequiredData()
{
if (!isset($this->data)) {
throw new RuntimeException("'data' property is required for DataAwareTrait to work");
}
if (!isset($this->requiredData)) {
throw new RuntimeException("'requiredData' property is required for DataAwareTrait to work");
}
$missing = [];
foreach ($this->requiredData as $key) {
if (!isset($this->data[$key])) {
$missing []= $key;
}
}
if (!count($missing)) {
return true;
}
throw new RuntimeException(
sprintf("Missing required data field(s) [%s]", implode(",", array_map([$this,"camelize"], $missing)))
);
} | [
"protected",
"function",
"checkRequiredData",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"'data' property is required for DataAwareTrait to work\"",
")",
";",
"}",
"if",
"(",
... | Check that all required data present
@return \Robo\Result | [
"Check",
"that",
"all",
"required",
"data",
"present"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/DataAwareTrait.php#L52-L75 | train |
canihavesomecoffee/theTVDbAPI | src/MultiLanguageWrapper/Route/SeriesRouteLanguageFallback.php | SeriesRouteLanguageFallback.getClosureById | public function getClosureById(int $seriesId): Closure
{
return function ($language) use ($seriesId) {
$json = $this->parent->performAPICallWithJsonResponse(
'get',
'/series/'.$seriesId,
[
'headers' => ['Accept-Language' => $language]
]
);
return DataParser::parseData($json, Series::class);
};
} | php | public function getClosureById(int $seriesId): Closure
{
return function ($language) use ($seriesId) {
$json = $this->parent->performAPICallWithJsonResponse(
'get',
'/series/'.$seriesId,
[
'headers' => ['Accept-Language' => $language]
]
);
return DataParser::parseData($json, Series::class);
};
} | [
"public",
"function",
"getClosureById",
"(",
"int",
"$",
"seriesId",
")",
":",
"Closure",
"{",
"return",
"function",
"(",
"$",
"language",
")",
"use",
"(",
"$",
"seriesId",
")",
"{",
"$",
"json",
"=",
"$",
"this",
"->",
"parent",
"->",
"performAPICallWit... | Returns the closure used to retrieve a series with a given id for a single language.
@param int $seriesId The ID of the series to retrieve.
@return Closure | [
"Returns",
"the",
"closure",
"used",
"to",
"retrieve",
"a",
"series",
"with",
"a",
"given",
"id",
"for",
"a",
"single",
"language",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/MultiLanguageWrapper/Route/SeriesRouteLanguageFallback.php#L74-L87 | train |
canihavesomecoffee/theTVDbAPI | src/MultiLanguageWrapper/Route/SeriesRouteLanguageFallback.php | SeriesRouteLanguageFallback.getClosureForEpisodes | public function getClosureForEpisodes(int $seriesId, array $options): Closure
{
return function ($language) use ($seriesId, $options) {
$options['headers'] = ['Accept-Language' => $language];
$json = $this->parent->performAPICallWithJsonResponse(
'get',
'/series/'.$seriesId.'/episodes',
$options
);
return DataParser::parseDataArray($json, BasicEpisode::class);
};
} | php | public function getClosureForEpisodes(int $seriesId, array $options): Closure
{
return function ($language) use ($seriesId, $options) {
$options['headers'] = ['Accept-Language' => $language];
$json = $this->parent->performAPICallWithJsonResponse(
'get',
'/series/'.$seriesId.'/episodes',
$options
);
return DataParser::parseDataArray($json, BasicEpisode::class);
};
} | [
"public",
"function",
"getClosureForEpisodes",
"(",
"int",
"$",
"seriesId",
",",
"array",
"$",
"options",
")",
":",
"Closure",
"{",
"return",
"function",
"(",
"$",
"language",
")",
"use",
"(",
"$",
"seriesId",
",",
"$",
"options",
")",
"{",
"$",
"options... | Returns the closure used to retrieve a set of episodes for a series for a single language.
@param int $seriesId The series id
@param array $options The options (pagination, ...)
@return Closure | [
"Returns",
"the",
"closure",
"used",
"to",
"retrieve",
"a",
"set",
"of",
"episodes",
"for",
"a",
"series",
"for",
"a",
"single",
"language",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/MultiLanguageWrapper/Route/SeriesRouteLanguageFallback.php#L117-L129 | train |
canihavesomecoffee/theTVDbAPI | src/MultiLanguageWrapper/Route/SeriesRouteLanguageFallback.php | SeriesRouteLanguageFallback.getClosureForImagesWithQuery | public function getClosureForImagesWithQuery(int $seriesId, array $options): Closure
{
return function ($language) use ($seriesId, $options) {
$options['headers'] = ['Accept-Language' => $language];
$json = $this->parent->performAPICallWithJsonResponse(
'get',
'/series/'.$seriesId.'/images/query',
$options
);
return DataParser::parseDataArray($json, Image::class);
};
} | php | public function getClosureForImagesWithQuery(int $seriesId, array $options): Closure
{
return function ($language) use ($seriesId, $options) {
$options['headers'] = ['Accept-Language' => $language];
$json = $this->parent->performAPICallWithJsonResponse(
'get',
'/series/'.$seriesId.'/images/query',
$options
);
return DataParser::parseDataArray($json, Image::class);
};
} | [
"public",
"function",
"getClosureForImagesWithQuery",
"(",
"int",
"$",
"seriesId",
",",
"array",
"$",
"options",
")",
":",
"Closure",
"{",
"return",
"function",
"(",
"$",
"language",
")",
"use",
"(",
"$",
"seriesId",
",",
"$",
"options",
")",
"{",
"$",
"... | Returns the closure used to retrieve search images for a series with a certain query for a single language.
@param int $seriesId The series id
@param array $options The options (pagination, ...)
@return Closure | [
"Returns",
"the",
"closure",
"used",
"to",
"retrieve",
"search",
"images",
"for",
"a",
"series",
"with",
"a",
"certain",
"query",
"for",
"a",
"single",
"language",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/MultiLanguageWrapper/Route/SeriesRouteLanguageFallback.php#L204-L216 | train |
hiqdev/hipanel-module-domain | src/cart/DomainRenewalProduct.php | DomainRenewalProduct.daysBeforeExpireValidator | public function daysBeforeExpireValidator($attribute)
{
if (isset($this->daysBeforeExpire[$this->getZone()])) {
$minDays = $this->daysBeforeExpire[$this->getZone()];
$interval = (new DateTime())->diff(new DateTime($this->_model->expires));
$diff = $interval->format('%a') - $minDays;
if ($diff > 0) {
$date = Yii::$app->formatter->asDate((new DateTime())->add(new \DateInterval("P{$diff}D")));
$this->addError('id', Yii::t('hipanel:domain', 'Domains in zone {zone} could be renewed only in last {min, plural, one{# day} other{# days}} before the expiration date. You are able to renew domain {domain} only after {date} (in {days, plural, one{# day} other{# days}})', ['zone' => (string) $this->getZone(), 'min' => (int) $minDays, 'date' => (string) $date, 'days' => (int) $diff, 'domain' => (string) $this->name]));
return false;
}
}
return true;
} | php | public function daysBeforeExpireValidator($attribute)
{
if (isset($this->daysBeforeExpire[$this->getZone()])) {
$minDays = $this->daysBeforeExpire[$this->getZone()];
$interval = (new DateTime())->diff(new DateTime($this->_model->expires));
$diff = $interval->format('%a') - $minDays;
if ($diff > 0) {
$date = Yii::$app->formatter->asDate((new DateTime())->add(new \DateInterval("P{$diff}D")));
$this->addError('id', Yii::t('hipanel:domain', 'Domains in zone {zone} could be renewed only in last {min, plural, one{# day} other{# days}} before the expiration date. You are able to renew domain {domain} only after {date} (in {days, plural, one{# day} other{# days}})', ['zone' => (string) $this->getZone(), 'min' => (int) $minDays, 'date' => (string) $date, 'days' => (int) $diff, 'domain' => (string) $this->name]));
return false;
}
}
return true;
} | [
"public",
"function",
"daysBeforeExpireValidator",
"(",
"$",
"attribute",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"daysBeforeExpire",
"[",
"$",
"this",
"->",
"getZone",
"(",
")",
"]",
")",
")",
"{",
"$",
"minDays",
"=",
"$",
"this",
"->",... | Checks whether domain reached the limit of days before expiration date and can be renewed.
@param $attribute
@return bool | [
"Checks",
"whether",
"domain",
"reached",
"the",
"limit",
"of",
"days",
"before",
"expiration",
"date",
"and",
"can",
"be",
"renewed",
"."
] | b1b02782fcb69970cacafe6c6ead238b14b54209 | https://github.com/hiqdev/hipanel-module-domain/blob/b1b02782fcb69970cacafe6c6ead238b14b54209/src/cart/DomainRenewalProduct.php#L90-L105 | train |
QoboLtd/qobo-robo | src/Command/Project/Changelog.php | Changelog.projectChangelog | public function projectChangelog($opts = ['format' => 'table', 'fields' => ''])
{
$result = $this->taskProjectChangelog()
->format('--reverse --no-merges --pretty=format:"* %<(72,trunc)%s (%ad, %an)" --date=short')
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
$data = $result->getData();
$data = array_map(
function ($str) {
if (!preg_match("/^\*\s+(.*?)\((\d{4}-\d{2}-\d{2}), (.*?)\).*$/", $str, $matches)) {
return $str;
}
return [
'message' => trim($matches[1]),
'data' => $matches[2],
'author' => $matches[3]
];
},
$data['data'][0]['output']
);
return new RowsOfFields($data);
} | php | public function projectChangelog($opts = ['format' => 'table', 'fields' => ''])
{
$result = $this->taskProjectChangelog()
->format('--reverse --no-merges --pretty=format:"* %<(72,trunc)%s (%ad, %an)" --date=short')
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
$data = $result->getData();
$data = array_map(
function ($str) {
if (!preg_match("/^\*\s+(.*?)\((\d{4}-\d{2}-\d{2}), (.*?)\).*$/", $str, $matches)) {
return $str;
}
return [
'message' => trim($matches[1]),
'data' => $matches[2],
'author' => $matches[3]
];
},
$data['data'][0]['output']
);
return new RowsOfFields($data);
} | [
"public",
"function",
"projectChangelog",
"(",
"$",
"opts",
"=",
"[",
"'format'",
"=>",
"'table'",
",",
"'fields'",
"=>",
"''",
"]",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"taskProjectChangelog",
"(",
")",
"->",
"format",
"(",
"'--reverse --no-me... | Get project changelog
@return \Qobo\Robo\Formatter\RowsOfFields | [
"Get",
"project",
"changelog"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/Command/Project/Changelog.php#L24-L52 | train |
anomalylabs/variables-module | src/VariablesModuleServiceProvider.php | VariablesModuleServiceProvider.map | public function map(FieldRouter $fields, VersionRouter $versions, AssignmentRouter $assignments)
{
$fields->route($this->addon, FieldsController::class);
$versions->route($this->addon, VersionsController::class);
$assignments->route($this->addon, AssignmentsController::class, 'admin/variables/groups');
} | php | public function map(FieldRouter $fields, VersionRouter $versions, AssignmentRouter $assignments)
{
$fields->route($this->addon, FieldsController::class);
$versions->route($this->addon, VersionsController::class);
$assignments->route($this->addon, AssignmentsController::class, 'admin/variables/groups');
} | [
"public",
"function",
"map",
"(",
"FieldRouter",
"$",
"fields",
",",
"VersionRouter",
"$",
"versions",
",",
"AssignmentRouter",
"$",
"assignments",
")",
"{",
"$",
"fields",
"->",
"route",
"(",
"$",
"this",
"->",
"addon",
",",
"FieldsController",
"::",
"class... | Map the addon.
@param FieldRouter $fields
@param VersionRouter $versions
@param AssignmentRouter $assignments | [
"Map",
"the",
"addon",
"."
] | bcd903670471a175f07aba3123693cb3a3c07d0b | https://github.com/anomalylabs/variables-module/blob/bcd903670471a175f07aba3123693cb3a3c07d0b/src/VariablesModuleServiceProvider.php#L48-L53 | train |
nails/module-invoice | src/Factory/ChargeResponse.php | ChargeResponse.setRedirectUrl | public function setRedirectUrl($sRedirectUrl)
{
if (!$this->bIsLocked) {
$this->sRedirectUrl = $sRedirectUrl;
$this->setIsRedirect(!empty($sRedirectUrl));
}
return $this;
} | php | public function setRedirectUrl($sRedirectUrl)
{
if (!$this->bIsLocked) {
$this->sRedirectUrl = $sRedirectUrl;
$this->setIsRedirect(!empty($sRedirectUrl));
}
return $this;
} | [
"public",
"function",
"setRedirectUrl",
"(",
"$",
"sRedirectUrl",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"bIsLocked",
")",
"{",
"$",
"this",
"->",
"sRedirectUrl",
"=",
"$",
"sRedirectUrl",
";",
"$",
"this",
"->",
"setIsRedirect",
"(",
"!",
"empty",... | Set the redirectUrl value
@param string $sRedirectUrl The Redirect URL
@return $this | [
"Set",
"the",
"redirectUrl",
"value"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Factory/ChargeResponse.php#L75-L82 | train |
nails/module-invoice | src/Factory/ChargeResponse.php | ChargeResponse.setRedirectPostData | public function setRedirectPostData($aRedirectPostData)
{
if (!$this->bIsLocked) {
$this->aRedirectPostData = $aRedirectPostData;
$this->setIsRedirect(!empty($aRedirectPostData));
}
return $this;
} | php | public function setRedirectPostData($aRedirectPostData)
{
if (!$this->bIsLocked) {
$this->aRedirectPostData = $aRedirectPostData;
$this->setIsRedirect(!empty($aRedirectPostData));
}
return $this;
} | [
"public",
"function",
"setRedirectPostData",
"(",
"$",
"aRedirectPostData",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"bIsLocked",
")",
"{",
"$",
"this",
"->",
"aRedirectPostData",
"=",
"$",
"aRedirectPostData",
";",
"$",
"this",
"->",
"setIsRedirect",
"(... | Set any data which should be POST'ed to the endpoint
@param array $aRedirectPostData The data to post
@return $this | [
"Set",
"any",
"data",
"which",
"should",
"be",
"POST",
"ed",
"to",
"the",
"endpoint"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Factory/ChargeResponse.php#L188-L195 | train |
nails/module-invoice | src/Driver/PaymentBase.php | PaymentBase.charge | public function charge(
$iAmount,
$sCurrency,
$oData,
$oCustomData,
$sDescription,
$oPayment,
$oInvoice,
$sSuccessUrl,
$sFailUrl,
$sContinueUrl
) {
throw new DriverException('Driver must implement the charge() method', 1);
} | php | public function charge(
$iAmount,
$sCurrency,
$oData,
$oCustomData,
$sDescription,
$oPayment,
$oInvoice,
$sSuccessUrl,
$sFailUrl,
$sContinueUrl
) {
throw new DriverException('Driver must implement the charge() method', 1);
} | [
"public",
"function",
"charge",
"(",
"$",
"iAmount",
",",
"$",
"sCurrency",
",",
"$",
"oData",
",",
"$",
"oCustomData",
",",
"$",
"sDescription",
",",
"$",
"oPayment",
",",
"$",
"oInvoice",
",",
"$",
"sSuccessUrl",
",",
"$",
"sFailUrl",
",",
"$",
"sCon... | Initiate a payment
@param integer $iAmount The payment amount
@param string $sCurrency The payment currency
@param \stdClass $oData An array of driver data
@param \stdClass $oCustomData The custom data object
@param string $sDescription The charge description
@param \stdClass $oPayment The payment object
@param \stdClass $oInvoice The invoice object
@param string $sSuccessUrl The URL to go to after successful payment
@param string $sFailUrl The URL to go to after failed payment
@param string $sContinueUrl The URL to go to after payment is completed
@throws DriverException
@return \Nails\Invoice\Factory\ChargeResponse | [
"Initiate",
"a",
"payment"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Driver/PaymentBase.php#L87-L100 | train |
canihavesomecoffee/theTVDbAPI | src/MultiLanguageWrapper/MultiLanguageFallbackGenerator.php | MultiLanguageFallbackGenerator.create | public function create(
Closure $performRequest,
string $returnTypeClass,
array $languages,
bool $merge = false
) {
$languageIdx = 0;
$returnValue = null;
$langLength = sizeof($languages);
do {
$result = $performRequest($languages[$languageIdx]);
$languageIdx++;
if ($languageIdx > 0 && $merge) {
$returnValue = $this->validator->merge($returnTypeClass, $returnValue, $result);
} else {
$returnValue = $result;
}
} while ($this->validator->isValid($returnTypeClass, $result) === false && $languageIdx < $langLength);
return $returnValue;
} | php | public function create(
Closure $performRequest,
string $returnTypeClass,
array $languages,
bool $merge = false
) {
$languageIdx = 0;
$returnValue = null;
$langLength = sizeof($languages);
do {
$result = $performRequest($languages[$languageIdx]);
$languageIdx++;
if ($languageIdx > 0 && $merge) {
$returnValue = $this->validator->merge($returnTypeClass, $returnValue, $result);
} else {
$returnValue = $result;
}
} while ($this->validator->isValid($returnTypeClass, $result) === false && $languageIdx < $langLength);
return $returnValue;
} | [
"public",
"function",
"create",
"(",
"Closure",
"$",
"performRequest",
",",
"string",
"$",
"returnTypeClass",
",",
"array",
"$",
"languages",
",",
"bool",
"$",
"merge",
"=",
"false",
")",
"{",
"$",
"languageIdx",
"=",
"0",
";",
"$",
"returnValue",
"=",
"... | Creates an object using the provided closure, and keeps using fallback languages while the object isn't valid.
@param Closure $performRequest The closure that calls the API and returns an object of the provided class. The
function call must accept only one parameter: the language for the request.
@param string $returnTypeClass The type of class instance that should be returned.
@param array $languages The languages that should be tried.
@param bool $merge Merge the results in different languages together?
@return mixed | [
"Creates",
"an",
"object",
"using",
"the",
"provided",
"closure",
"and",
"keeps",
"using",
"fallback",
"languages",
"while",
"the",
"object",
"isn",
"t",
"valid",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/MultiLanguageWrapper/MultiLanguageFallbackGenerator.php#L70-L89 | train |
orchestral/support | src/Support/Concerns/Observable.php | Observable.fireObservableEvent | protected function fireObservableEvent(string $event, bool $halt)
{
if (! isset(static::$dispatcher)) {
return true;
}
$className = \get_class($this);
$event = $this->getObservableKey($event);
$method = $halt ? 'until' : 'handle';
return static::$dispatcher->$method("{$event}: {$className}", $this);
} | php | protected function fireObservableEvent(string $event, bool $halt)
{
if (! isset(static::$dispatcher)) {
return true;
}
$className = \get_class($this);
$event = $this->getObservableKey($event);
$method = $halt ? 'until' : 'handle';
return static::$dispatcher->$method("{$event}: {$className}", $this);
} | [
"protected",
"function",
"fireObservableEvent",
"(",
"string",
"$",
"event",
",",
"bool",
"$",
"halt",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"dispatcher",
")",
")",
"{",
"return",
"true",
";",
"}",
"$",
"className",
"=",
"\\",
... | Fire the given event.
@param string $event
@param bool $halt
@return mixed | [
"Fire",
"the",
"given",
"event",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Support/Concerns/Observable.php#L85-L97 | train |
orchestral/support | src/Support/Concerns/Observable.php | Observable.flushEventListeners | public static function flushEventListeners(): void
{
if (! isset(static::$dispatcher)) {
return;
}
$instance = new static();
$className = static::class;
foreach ($instance->getObservableEvents() as $event) {
$event = $instance->getObservableKey($event);
static::$dispatcher->forget("{$event}: {$className}");
}
} | php | public static function flushEventListeners(): void
{
if (! isset(static::$dispatcher)) {
return;
}
$instance = new static();
$className = static::class;
foreach ($instance->getObservableEvents() as $event) {
$event = $instance->getObservableKey($event);
static::$dispatcher->forget("{$event}: {$className}");
}
} | [
"public",
"static",
"function",
"flushEventListeners",
"(",
")",
":",
"void",
"{",
"if",
"(",
"!",
"isset",
"(",
"static",
"::",
"$",
"dispatcher",
")",
")",
"{",
"return",
";",
"}",
"$",
"instance",
"=",
"new",
"static",
"(",
")",
";",
"$",
"classNa... | Remove all of the event listeners for the observers.
@return void | [
"Remove",
"all",
"of",
"the",
"event",
"listeners",
"for",
"the",
"observers",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Support/Concerns/Observable.php#L104-L118 | train |
canihavesomecoffee/theTVDbAPI | src/TheTVDbAPI.php | TheTVDbAPI.getDefaultHttpClientOptions | private function getDefaultHttpClientOptions(array $options = []): array
{
$headers = [];
if ($this->token !== null) {
$headers['Authorization'] = 'Bearer '.$this->token;
}
$languagesInOptions = (array_key_exists('headers', $options) &&
array_key_exists('Accept-Language', $options['headers']));
if ($this->languages !== null && $languagesInOptions === false) {
$headers['Accept-Language'] = join(', ', $this->languages);
}
if ($this->version !== null) {
$headers['Accept'] = 'application/vnd.thetvdb.v'.$this->version;
}
$options['http_errors'] = false;
return array_merge_recursive(['headers' => $headers], $options);
} | php | private function getDefaultHttpClientOptions(array $options = []): array
{
$headers = [];
if ($this->token !== null) {
$headers['Authorization'] = 'Bearer '.$this->token;
}
$languagesInOptions = (array_key_exists('headers', $options) &&
array_key_exists('Accept-Language', $options['headers']));
if ($this->languages !== null && $languagesInOptions === false) {
$headers['Accept-Language'] = join(', ', $this->languages);
}
if ($this->version !== null) {
$headers['Accept'] = 'application/vnd.thetvdb.v'.$this->version;
}
$options['http_errors'] = false;
return array_merge_recursive(['headers' => $headers], $options);
} | [
"private",
"function",
"getDefaultHttpClientOptions",
"(",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"headers",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"this",
"->",
"token",
"!==",
"null",
")",
"{",
"$",
"headers",
"[",
"'Auth... | Returns the default client options.
@param array $options A list of options to start with (optional)
@return array An array containing the passed in options, as well as the added ones | [
"Returns",
"the",
"default",
"client",
"options",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/TheTVDbAPI.php#L254-L275 | train |
canihavesomecoffee/theTVDbAPI | src/TheTVDbAPI.php | TheTVDbAPI.requestHeaders | public function requestHeaders($method, $path, array $options = []): array
{
$options = $this->getDefaultHttpClientOptions($options);
/* @type Response $response */
$response = $this->httpClient->{$method}($path, $options);
if ($response->getStatusCode() === 401) {
throw UnauthorizedException::invalidToken();
} elseif ($response->getStatusCode() === 404) {
throw ResourceNotFoundException::notFound($path, $options);
}
return $response->getHeaders();
} | php | public function requestHeaders($method, $path, array $options = []): array
{
$options = $this->getDefaultHttpClientOptions($options);
/* @type Response $response */
$response = $this->httpClient->{$method}($path, $options);
if ($response->getStatusCode() === 401) {
throw UnauthorizedException::invalidToken();
} elseif ($response->getStatusCode() === 404) {
throw ResourceNotFoundException::notFound($path, $options);
}
return $response->getHeaders();
} | [
"public",
"function",
"requestHeaders",
"(",
"$",
"method",
",",
"$",
"path",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"getDefaultHttpClientOptions",
"(",
"$",
"options",
")",
";",
"/*... | Makes a call to the API and return headers only.
@param string $method HTTP Method (post, getUserData, put, etc.)
@param string $path Path to the API call
@param array $options HTTP Client options
@return array
@throws ResourceNotFoundException
@throws UnauthorizedException | [
"Makes",
"a",
"call",
"to",
"the",
"API",
"and",
"return",
"headers",
"only",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/TheTVDbAPI.php#L288-L302 | train |
canihavesomecoffee/theTVDbAPI | src/TheTVDbAPI.php | TheTVDbAPI.performAPICall | public function performAPICall($method, $path, array $options = []): Response
{
$options = $this->getDefaultHttpClientOptions($options);
// Reset JSON errors.
$this->jsonErrors = [];
// Reset Link section.
$this->links = [];
/* @type Response $response */
$response = $this->httpClient->{$method}($path, $options);
if ($response->getStatusCode() === 401) {
throw UnauthorizedException::invalidToken();
} elseif ($response->getStatusCode() === 404) {
throw ResourceNotFoundException::notFound($path, $options);
}
return $response;
} | php | public function performAPICall($method, $path, array $options = []): Response
{
$options = $this->getDefaultHttpClientOptions($options);
// Reset JSON errors.
$this->jsonErrors = [];
// Reset Link section.
$this->links = [];
/* @type Response $response */
$response = $this->httpClient->{$method}($path, $options);
if ($response->getStatusCode() === 401) {
throw UnauthorizedException::invalidToken();
} elseif ($response->getStatusCode() === 404) {
throw ResourceNotFoundException::notFound($path, $options);
}
return $response;
} | [
"public",
"function",
"performAPICall",
"(",
"$",
"method",
",",
"$",
"path",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
":",
"Response",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"getDefaultHttpClientOptions",
"(",
"$",
"options",
")",
";",
... | Perform an API call to theTVDb.
@param string $method HTTP Method (post, getUserData, put, etc.)
@param string $path Path to the API call
@param array $options HTTP Client options
@return Response
@throws UnauthorizedException
@throws ResourceNotFoundException | [
"Perform",
"an",
"API",
"call",
"to",
"theTVDb",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/TheTVDbAPI.php#L315-L333 | train |
canihavesomecoffee/theTVDbAPI | src/TheTVDbAPI.php | TheTVDbAPI.performAPICallWithJsonResponse | public function performAPICallWithJsonResponse($method, $path, array $options = [])
{
$response = $this->performAPICall($method, $path, $options);
if ($response->getStatusCode() === 200) {
$contents = $response->getBody()->getContents();
$json = json_decode($contents, true);
if ($json === null) {
throw ParseException::decode();
}
// Parse errors first, if any.
if (array_key_exists('errors', $json)) {
// Parse error and throw appropriate exception.
$this->parseErrorSection($json['errors']);
}
// Parse links, if any.
if (array_key_exists('links', $json)) {
$this->links = $json['links'];
}
if (array_key_exists('data', $json) === false) {
return $json;
}
return $json['data'];
}
throw new Exception(
sprintf(
'Got status code %d from service at path %s',
$response->getStatusCode(),
$path
)
);
} | php | public function performAPICallWithJsonResponse($method, $path, array $options = [])
{
$response = $this->performAPICall($method, $path, $options);
if ($response->getStatusCode() === 200) {
$contents = $response->getBody()->getContents();
$json = json_decode($contents, true);
if ($json === null) {
throw ParseException::decode();
}
// Parse errors first, if any.
if (array_key_exists('errors', $json)) {
// Parse error and throw appropriate exception.
$this->parseErrorSection($json['errors']);
}
// Parse links, if any.
if (array_key_exists('links', $json)) {
$this->links = $json['links'];
}
if (array_key_exists('data', $json) === false) {
return $json;
}
return $json['data'];
}
throw new Exception(
sprintf(
'Got status code %d from service at path %s',
$response->getStatusCode(),
$path
)
);
} | [
"public",
"function",
"performAPICallWithJsonResponse",
"(",
"$",
"method",
",",
"$",
"path",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"performAPICall",
"(",
"$",
"method",
",",
"$",
"path",
",",
"... | Perform an API call to theTVDb and return a JSON response
@param string $method HTTP Method (post, getUserData, put, etc.)
@param string $path Path to the API call
@param array $options HTTP Client options
@return mixed
@throws ResourceNotFoundException
@throws UnauthorizedException
@throws Exception | [
"Perform",
"an",
"API",
"call",
"to",
"theTVDb",
"and",
"return",
"a",
"JSON",
"response"
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/TheTVDbAPI.php#L347-L379 | train |
canihavesomecoffee/theTVDbAPI | src/TheTVDbAPI.php | TheTVDbAPI.parseErrorSection | private function parseErrorSection(array $errors)
{
if (array_key_exists('invalidFilters', $errors)) {
$this->jsonErrors[] = new JSONError(JSONError::INVALID_FILTER, $errors['invalidFilters']);
}
if (array_key_exists('invalidQueryParams', $errors)) {
$this->jsonErrors[] = new JSONError(JSONError::INVALID_QUERYPARAMS, $errors['invalidQueryParams']);
}
if (array_key_exists('invalidLanguage', $errors)) {
$this->jsonErrors[] = new JSONError();
}
} | php | private function parseErrorSection(array $errors)
{
if (array_key_exists('invalidFilters', $errors)) {
$this->jsonErrors[] = new JSONError(JSONError::INVALID_FILTER, $errors['invalidFilters']);
}
if (array_key_exists('invalidQueryParams', $errors)) {
$this->jsonErrors[] = new JSONError(JSONError::INVALID_QUERYPARAMS, $errors['invalidQueryParams']);
}
if (array_key_exists('invalidLanguage', $errors)) {
$this->jsonErrors[] = new JSONError();
}
} | [
"private",
"function",
"parseErrorSection",
"(",
"array",
"$",
"errors",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"'invalidFilters'",
",",
"$",
"errors",
")",
")",
"{",
"$",
"this",
"->",
"jsonErrors",
"[",
"]",
"=",
"new",
"JSONError",
"(",
"JSONErro... | Parses the errors and stores them in lastJSONErrors.
@param array $errors The JSON errors.
@return void | [
"Parses",
"the",
"errors",
"and",
"stores",
"them",
"in",
"lastJSONErrors",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/TheTVDbAPI.php#L408-L419 | train |
orchestral/support | src/Support/Keyword.php | Keyword.searchIn | public function searchIn(array $items = [])
{
if (\is_null($slug = $this->slug)) {
return \array_search($this->value, $items);
}
return \array_search($slug, $items);
} | php | public function searchIn(array $items = [])
{
if (\is_null($slug = $this->slug)) {
return \array_search($this->value, $items);
}
return \array_search($slug, $items);
} | [
"public",
"function",
"searchIn",
"(",
"array",
"$",
"items",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"slug",
"=",
"$",
"this",
"->",
"slug",
")",
")",
"{",
"return",
"\\",
"array_search",
"(",
"$",
"this",
"->",
"value",
"... | Search slug in given items and return the key.
@param array $items
@return mixed | [
"Search",
"slug",
"in",
"given",
"items",
"and",
"return",
"the",
"key",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Support/Keyword.php#L78-L85 | train |
orchestral/support | src/Support/Keyword.php | Keyword.hasIn | public function hasIn(array $items = [])
{
if (\is_null($slug = $this->slug)) {
return isset($items[$this->value]);
}
return isset($items[$slug]);
} | php | public function hasIn(array $items = [])
{
if (\is_null($slug = $this->slug)) {
return isset($items[$this->value]);
}
return isset($items[$slug]);
} | [
"public",
"function",
"hasIn",
"(",
"array",
"$",
"items",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"slug",
"=",
"$",
"this",
"->",
"slug",
")",
")",
"{",
"return",
"isset",
"(",
"$",
"items",
"[",
"$",
"this",
"->",
"valu... | Search slug in given items and return if the key exist.
@param array $items
@return bool | [
"Search",
"slug",
"in",
"given",
"items",
"and",
"return",
"if",
"the",
"key",
"exist",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Support/Keyword.php#L94-L101 | train |
doganoo/PHPUtil | src/Util/ClassUtil.php | ClassUtil.getClassName | public static function getClassName($object): ?string {
$validObject = ClassUtil::isValidObject($object);
if (!$validObject) {
return null;
}
return (new \ReflectionClass($object))->getName();
} | php | public static function getClassName($object): ?string {
$validObject = ClassUtil::isValidObject($object);
if (!$validObject) {
return null;
}
return (new \ReflectionClass($object))->getName();
} | [
"public",
"static",
"function",
"getClassName",
"(",
"$",
"object",
")",
":",
"?",
"string",
"{",
"$",
"validObject",
"=",
"ClassUtil",
"::",
"isValidObject",
"(",
"$",
"object",
")",
";",
"if",
"(",
"!",
"$",
"validObject",
")",
"{",
"return",
"null",
... | returns the name of an object
@param $object
@return null|string
@throws \ReflectionException | [
"returns",
"the",
"name",
"of",
"an",
"object"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Util/ClassUtil.php#L51-L57 | train |
doganoo/PHPUtil | src/Util/ClassUtil.php | ClassUtil.isSerialized | public static function isSerialized(string $string): bool {
$data = @unserialize($string);
if (false === $data) {
return false;
} else {
return true;
}
} | php | public static function isSerialized(string $string): bool {
$data = @unserialize($string);
if (false === $data) {
return false;
} else {
return true;
}
} | [
"public",
"static",
"function",
"isSerialized",
"(",
"string",
"$",
"string",
")",
":",
"bool",
"{",
"$",
"data",
"=",
"@",
"unserialize",
"(",
"$",
"string",
")",
";",
"if",
"(",
"false",
"===",
"$",
"data",
")",
"{",
"return",
"false",
";",
"}",
... | whether the string is an serialized object or not
@param string $string
@return bool | [
"whether",
"the",
"string",
"is",
"an",
"serialized",
"object",
"or",
"not"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Util/ClassUtil.php#L99-L106 | train |
doganoo/PHPUtil | src/Util/ClassUtil.php | ClassUtil.getAllProperties | public static function getAllProperties($object, bool $asString = true) {
$validObject = ClassUtil::isValidObject($object);
if (!$validObject) {
return null;
}
$reflectionClass = new \ReflectionClass($object);
$properties = $reflectionClass->getProperties();
if ($asString) {
return ArrayUtil::arrayToString($properties);
} else {
return $properties;
}
} | php | public static function getAllProperties($object, bool $asString = true) {
$validObject = ClassUtil::isValidObject($object);
if (!$validObject) {
return null;
}
$reflectionClass = new \ReflectionClass($object);
$properties = $reflectionClass->getProperties();
if ($asString) {
return ArrayUtil::arrayToString($properties);
} else {
return $properties;
}
} | [
"public",
"static",
"function",
"getAllProperties",
"(",
"$",
"object",
",",
"bool",
"$",
"asString",
"=",
"true",
")",
"{",
"$",
"validObject",
"=",
"ClassUtil",
"::",
"isValidObject",
"(",
"$",
"object",
")",
";",
"if",
"(",
"!",
"$",
"validObject",
")... | returns all properties of an object
TODO let caller define the visibility
@param $object
@param bool $asString
@return null|\ReflectionProperty[]|string
@throws \ReflectionException | [
"returns",
"all",
"properties",
"of",
"an",
"object"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Util/ClassUtil.php#L118-L131 | train |
canihavesomecoffee/theTVDbAPI | src/Route/RouteFactory.php | RouteFactory.getRouteInstance | public static function getRouteInstance(TheTVDbAPIInterface $parent, string $routeClassName)
{
if (array_key_exists($routeClassName, static::$routeInstances) === false) {
$classImplements = class_implements($routeClassName);
if (in_array('CanIHaveSomeCoffee\TheTVDbAPI\Route\RouteInterface', $classImplements) === false) {
throw new InvalidArgumentException('Class does not implement the RouteInterface!');
}
$args = [$parent];
static::$routeInstances[$routeClassName] = new $routeClassName(...$args);
}
return static::$routeInstances[$routeClassName];
} | php | public static function getRouteInstance(TheTVDbAPIInterface $parent, string $routeClassName)
{
if (array_key_exists($routeClassName, static::$routeInstances) === false) {
$classImplements = class_implements($routeClassName);
if (in_array('CanIHaveSomeCoffee\TheTVDbAPI\Route\RouteInterface', $classImplements) === false) {
throw new InvalidArgumentException('Class does not implement the RouteInterface!');
}
$args = [$parent];
static::$routeInstances[$routeClassName] = new $routeClassName(...$args);
}
return static::$routeInstances[$routeClassName];
} | [
"public",
"static",
"function",
"getRouteInstance",
"(",
"TheTVDbAPIInterface",
"$",
"parent",
",",
"string",
"$",
"routeClassName",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"routeClassName",
",",
"static",
"::",
"$",
"routeInstances",
")",
"===",
"fal... | Retrieves an instance of the given routeClassName.
@param TheTVDbAPIInterface $parent The parent object that is needed for constructing a new object.
@param string $routeClassName The name of the instance to retrieve.
@return mixed The requested instance
@throws InvalidArgumentException If the given class name does not implement the RouteInterface | [
"Retrieves",
"an",
"instance",
"of",
"the",
"given",
"routeClassName",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/Route/RouteFactory.php#L59-L70 | train |
nails/module-invoice | src/Factory/CompleteRequest.php | CompleteRequest.execute | public function execute($aGetVars, $aPostVars)
{
// Ensure we have a driver
if (empty($this->oDriver)) {
throw new CompleteRequestException('No driver selected.', 1);
}
// Ensure we have a payment
if (empty($this->oPayment)) {
throw new CompleteRequestException('No payment selected.', 1);
}
if (empty($this->oInvoice)) {
throw new CompleteRequestException('No invoice selected.', 1);
}
// Execute the completion
$oCompleteResponse = $this->oDriver->complete(
$this->oPayment,
$this->oInvoice,
$aGetVars,
$aPostVars
);
// Validate driver response
if (empty($oCompleteResponse)) {
throw new CompleteRequestException('Response from driver was empty.', 1);
}
if (!($oCompleteResponse instanceof CompleteResponse)) {
throw new CompleteRequestException(
'Response from driver must be an instance of \Nails\Invoice\Factory\CompleteResponse.',
1
);
}
// Handle the response
if ($oCompleteResponse->isProcessing()) {
// Driver has started processing the charge, but it hasn't been confirmed yet
$this->setPaymentProcessing(
$oCompleteResponse->getTxnId(),
$oCompleteResponse->getFee()
);
} elseif ($oCompleteResponse->isComplete()) {
// Driver has confirmed that payment has been taken.
$this->setPaymentComplete(
$oCompleteResponse->getTxnId(),
$oCompleteResponse->getFee()
);
} elseif ($oCompleteResponse->isFailed()) {
/**
* Payment failed
*/
// Update the payment
$sPaymentClass = get_class($this->oPaymentModel);
$bResult = $this->oPaymentModel->update(
$this->oPayment->id,
[
'status' => $sPaymentClass::STATUS_FAILED,
'fail_msg' => $oCompleteResponse->getError()->msg,
'fail_code' => $oCompleteResponse->getError()->code,
]
);
if (empty($bResult)) {
throw new CompleteRequestException('Failed to update existing payment.', 1);
}
}
// Lock the response so it cannot be altered
$oCompleteResponse->lock();
return $oCompleteResponse;
} | php | public function execute($aGetVars, $aPostVars)
{
// Ensure we have a driver
if (empty($this->oDriver)) {
throw new CompleteRequestException('No driver selected.', 1);
}
// Ensure we have a payment
if (empty($this->oPayment)) {
throw new CompleteRequestException('No payment selected.', 1);
}
if (empty($this->oInvoice)) {
throw new CompleteRequestException('No invoice selected.', 1);
}
// Execute the completion
$oCompleteResponse = $this->oDriver->complete(
$this->oPayment,
$this->oInvoice,
$aGetVars,
$aPostVars
);
// Validate driver response
if (empty($oCompleteResponse)) {
throw new CompleteRequestException('Response from driver was empty.', 1);
}
if (!($oCompleteResponse instanceof CompleteResponse)) {
throw new CompleteRequestException(
'Response from driver must be an instance of \Nails\Invoice\Factory\CompleteResponse.',
1
);
}
// Handle the response
if ($oCompleteResponse->isProcessing()) {
// Driver has started processing the charge, but it hasn't been confirmed yet
$this->setPaymentProcessing(
$oCompleteResponse->getTxnId(),
$oCompleteResponse->getFee()
);
} elseif ($oCompleteResponse->isComplete()) {
// Driver has confirmed that payment has been taken.
$this->setPaymentComplete(
$oCompleteResponse->getTxnId(),
$oCompleteResponse->getFee()
);
} elseif ($oCompleteResponse->isFailed()) {
/**
* Payment failed
*/
// Update the payment
$sPaymentClass = get_class($this->oPaymentModel);
$bResult = $this->oPaymentModel->update(
$this->oPayment->id,
[
'status' => $sPaymentClass::STATUS_FAILED,
'fail_msg' => $oCompleteResponse->getError()->msg,
'fail_code' => $oCompleteResponse->getError()->code,
]
);
if (empty($bResult)) {
throw new CompleteRequestException('Failed to update existing payment.', 1);
}
}
// Lock the response so it cannot be altered
$oCompleteResponse->lock();
return $oCompleteResponse;
} | [
"public",
"function",
"execute",
"(",
"$",
"aGetVars",
",",
"$",
"aPostVars",
")",
"{",
"// Ensure we have a driver",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"oDriver",
")",
")",
"{",
"throw",
"new",
"CompleteRequestException",
"(",
"'No driver selected.'",... | Complete the payment
@param array $aGetVars Any $_GET variables passed from the redirect flow
@param array $aPostVars Any $_POST variables passed from the redirect flow
@return \Nails\Invoice\Factory\CompleteResponse
@throws CompleteRequestException | [
"Complete",
"the",
"payment"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Factory/CompleteRequest.php#L58-L137 | train |
orchestral/support | src/Support/Str.php | Str.humanize | public static function humanize(string $text): string
{
$text = \str_replace(['-', '_'], ' ', $text);
return Stringy::create($text)->humanize()->titleize();
} | php | public static function humanize(string $text): string
{
$text = \str_replace(['-', '_'], ' ', $text);
return Stringy::create($text)->humanize()->titleize();
} | [
"public",
"static",
"function",
"humanize",
"(",
"string",
"$",
"text",
")",
":",
"string",
"{",
"$",
"text",
"=",
"\\",
"str_replace",
"(",
"[",
"'-'",
",",
"'_'",
"]",
",",
"' '",
",",
"$",
"text",
")",
";",
"return",
"Stringy",
"::",
"create",
"... | Convert slug type text to human readable text.
@param string $text
@return string | [
"Convert",
"slug",
"type",
"text",
"to",
"human",
"readable",
"text",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Support/Str.php#L17-L22 | train |
orchestral/support | src/Support/Str.php | Str.streamGetContents | public static function streamGetContents($data): string
{
// check if it's actually a resource, we can directly convert
// string without any issue.
if (! \is_resource($data)) {
return $data;
}
// Get the content from stream.
$hex = \stream_get_contents($data);
// For some reason hex would always start with 'x' and if we
// don't filter out this char, it would mess up hex to string
// conversion.
if (\preg_match('/^x(.*)$/', $hex, $matches)) {
$hex = $matches[1];
}
// Check if it's actually a hex string before trying to convert.
if (! \ctype_xdigit($hex)) {
return $hex;
}
return static::fromHex($hex);
} | php | public static function streamGetContents($data): string
{
// check if it's actually a resource, we can directly convert
// string without any issue.
if (! \is_resource($data)) {
return $data;
}
// Get the content from stream.
$hex = \stream_get_contents($data);
// For some reason hex would always start with 'x' and if we
// don't filter out this char, it would mess up hex to string
// conversion.
if (\preg_match('/^x(.*)$/', $hex, $matches)) {
$hex = $matches[1];
}
// Check if it's actually a hex string before trying to convert.
if (! \ctype_xdigit($hex)) {
return $hex;
}
return static::fromHex($hex);
} | [
"public",
"static",
"function",
"streamGetContents",
"(",
"$",
"data",
")",
":",
"string",
"{",
"// check if it's actually a resource, we can directly convert",
"// string without any issue.",
"if",
"(",
"!",
"\\",
"is_resource",
"(",
"$",
"data",
")",
")",
"{",
"retu... | Convert filter to string, this process is required to filter stream
data return from Postgres where blob type schema would actually use
BYTEA and convert the string to stream.
@param mixed $data
@return string | [
"Convert",
"filter",
"to",
"string",
"this",
"process",
"is",
"required",
"to",
"filter",
"stream",
"data",
"return",
"from",
"Postgres",
"where",
"blob",
"type",
"schema",
"would",
"actually",
"use",
"BYTEA",
"and",
"convert",
"the",
"string",
"to",
"stream",... | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Support/Str.php#L113-L137 | train |
orchestral/support | src/Support/Str.php | Str.fromHex | protected static function fromHex(string $hex): string
{
$data = '';
// Convert hex to string.
for ($i = 0; $i < \strlen($hex) - 1; $i += 2) {
$data .= \chr(\hexdec($hex[$i].$hex[$i + 1]));
}
return $data;
} | php | protected static function fromHex(string $hex): string
{
$data = '';
// Convert hex to string.
for ($i = 0; $i < \strlen($hex) - 1; $i += 2) {
$data .= \chr(\hexdec($hex[$i].$hex[$i + 1]));
}
return $data;
} | [
"protected",
"static",
"function",
"fromHex",
"(",
"string",
"$",
"hex",
")",
":",
"string",
"{",
"$",
"data",
"=",
"''",
";",
"// Convert hex to string.",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"i",
"<",
"\\",
"strlen",
"(",
"$",
"hex",
")",
"-... | Convert hex to string.
@param string $hex
@return string | [
"Convert",
"hex",
"to",
"string",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Support/Str.php#L146-L156 | train |
QoboLtd/qobo-robo | src/Command/Mysql/Import.php | Import.mysqlImport | public function mysqlImport($db, $file = 'etc/mysql.sql', $user = 'root', $pass = null, $host = null, $port = null, $opts = ['format' => 'table', 'fields' => ''])
{
$result = $this->taskMysqlImport()
->db($db)
->file($file)
->user($user)
->pass($pass)
->host($host)
->port($port)
->hide($pass)
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
return true;
} | php | public function mysqlImport($db, $file = 'etc/mysql.sql', $user = 'root', $pass = null, $host = null, $port = null, $opts = ['format' => 'table', 'fields' => ''])
{
$result = $this->taskMysqlImport()
->db($db)
->file($file)
->user($user)
->pass($pass)
->host($host)
->port($port)
->hide($pass)
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
return true;
} | [
"public",
"function",
"mysqlImport",
"(",
"$",
"db",
",",
"$",
"file",
"=",
"'etc/mysql.sql'",
",",
"$",
"user",
"=",
"'root'",
",",
"$",
"pass",
"=",
"null",
",",
"$",
"host",
"=",
"null",
",",
"$",
"port",
"=",
"null",
",",
"$",
"opts",
"=",
"[... | Import mysql dump
@param string $db Database name
@param string $file Destination file for a dump
@param string $user MySQL user to bind with
@param string $pass (Optional) MySQL user password
@param string $host (Optional) MySQL server host
@param string $port (Optional) MySQL server port
@option string $format Output format (table, list, csv, json, xml)
@option string $fields Limit output to given fields, comma-separated
@return PropertyList result | [
"Import",
"mysql",
"dump"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/Command/Mysql/Import.php#L33-L50 | train |
nails/module-invoice | src/Model/Payment.php | Payment.getStatuses | public function getStatuses()
{
return [
self::STATUS_PENDING,
self::STATUS_PROCESSING,
self::STATUS_COMPLETE,
self::STATUS_FAILED,
self::STATUS_REFUNDED,
self::STATUS_REFUNDED_PARTIAL,
];
} | php | public function getStatuses()
{
return [
self::STATUS_PENDING,
self::STATUS_PROCESSING,
self::STATUS_COMPLETE,
self::STATUS_FAILED,
self::STATUS_REFUNDED,
self::STATUS_REFUNDED_PARTIAL,
];
} | [
"public",
"function",
"getStatuses",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"STATUS_PENDING",
",",
"self",
"::",
"STATUS_PROCESSING",
",",
"self",
"::",
"STATUS_COMPLETE",
",",
"self",
"::",
"STATUS_FAILED",
",",
"self",
"::",
"STATUS_REFUNDED",
",",
"sel... | Returns all the statuses as an array
@return array | [
"Returns",
"all",
"the",
"statuses",
"as",
"an",
"array"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Payment.php#L82-L92 | train |
nails/module-invoice | src/Model/Payment.php | Payment.getStatusesHuman | public function getStatusesHuman()
{
return [
self::STATUS_PENDING => 'Pending',
self::STATUS_PROCESSING => 'Processing',
self::STATUS_COMPLETE => 'Complete',
self::STATUS_FAILED => 'Failed',
self::STATUS_REFUNDED => 'Refunded',
self::STATUS_REFUNDED_PARTIAL => 'Partially Refunded',
];
} | php | public function getStatusesHuman()
{
return [
self::STATUS_PENDING => 'Pending',
self::STATUS_PROCESSING => 'Processing',
self::STATUS_COMPLETE => 'Complete',
self::STATUS_FAILED => 'Failed',
self::STATUS_REFUNDED => 'Refunded',
self::STATUS_REFUNDED_PARTIAL => 'Partially Refunded',
];
} | [
"public",
"function",
"getStatusesHuman",
"(",
")",
"{",
"return",
"[",
"self",
"::",
"STATUS_PENDING",
"=>",
"'Pending'",
",",
"self",
"::",
"STATUS_PROCESSING",
"=>",
"'Processing'",
",",
"self",
"::",
"STATUS_COMPLETE",
"=>",
"'Complete'",
",",
"self",
"::",
... | Returns an array of statsues with human friendly labels
@return array | [
"Returns",
"an",
"array",
"of",
"statsues",
"with",
"human",
"friendly",
"labels"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Payment.php#L101-L111 | train |
nails/module-invoice | src/Model/Payment.php | Payment.create | public function create(array $aData = [], $bReturnObject = false)
{
$oDb = Factory::service('Database');
try {
$oDb->trans_begin();
if (empty($aData['ref'])) {
$aData['ref'] = $this->generateValidRef();
}
$aData['token'] = $this->generateToken();
if (array_key_exists('custom_data', $aData)) {
$aData['custom_data'] = json_encode($aData['custom_data']);
}
$mPayment = parent::create($aData, $bReturnObject);
if (!$mPayment) {
throw new PaymentException('Failed to create payment.');
}
$oDb->trans_commit();
$this->triggerEvent(
Events::PAYMENT_CREATED,
[$this->getPaymentForEvent($bReturnObject ? $mPayment->id : $mPayment)]
);
return $mPayment;
} catch (\Exception $e) {
$oDb->trans_rollback();
$this->setError($e->getMessage());
return false;
}
} | php | public function create(array $aData = [], $bReturnObject = false)
{
$oDb = Factory::service('Database');
try {
$oDb->trans_begin();
if (empty($aData['ref'])) {
$aData['ref'] = $this->generateValidRef();
}
$aData['token'] = $this->generateToken();
if (array_key_exists('custom_data', $aData)) {
$aData['custom_data'] = json_encode($aData['custom_data']);
}
$mPayment = parent::create($aData, $bReturnObject);
if (!$mPayment) {
throw new PaymentException('Failed to create payment.');
}
$oDb->trans_commit();
$this->triggerEvent(
Events::PAYMENT_CREATED,
[$this->getPaymentForEvent($bReturnObject ? $mPayment->id : $mPayment)]
);
return $mPayment;
} catch (\Exception $e) {
$oDb->trans_rollback();
$this->setError($e->getMessage());
return false;
}
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"aData",
"=",
"[",
"]",
",",
"$",
"bReturnObject",
"=",
"false",
")",
"{",
"$",
"oDb",
"=",
"Factory",
"::",
"service",
"(",
"'Database'",
")",
";",
"try",
"{",
"$",
"oDb",
"->",
"trans_begin",
"(",
... | Create a new payment
@param array $aData The data to create the payment with
@param boolean $bReturnObject Whether to return the complete payment object
@return bool|mixed
@throws \Nails\Common\Exception\FactoryException | [
"Create",
"a",
"new",
"payment"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Payment.php#L195-L232 | train |
nails/module-invoice | src/Model/Payment.php | Payment.setPending | public function setPending($iPaymentId, $aData = []): bool
{
$aData['status'] = self::STATUS_PENDING;
return $this->update($iPaymentId, $aData);
} | php | public function setPending($iPaymentId, $aData = []): bool
{
$aData['status'] = self::STATUS_PENDING;
return $this->update($iPaymentId, $aData);
} | [
"public",
"function",
"setPending",
"(",
"$",
"iPaymentId",
",",
"$",
"aData",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"$",
"aData",
"[",
"'status'",
"]",
"=",
"self",
"::",
"STATUS_PENDING",
";",
"return",
"$",
"this",
"->",
"update",
"(",
"$",
"iPaym... | Set a payment as PENDING
@param integer $iPaymentId The payment to update
@param array $aData Any additional data to save to the transaction
@return bool
@throws \Nails\Common\Exception\FactoryException | [
"Set",
"a",
"payment",
"as",
"PENDING"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Payment.php#L318-L322 | train |
nails/module-invoice | src/Model/Payment.php | Payment.setComplete | public function setComplete($iPaymentId, $aData = []): bool
{
$aData['status'] = self::STATUS_COMPLETE;
return $this->update($iPaymentId, $aData);
} | php | public function setComplete($iPaymentId, $aData = []): bool
{
$aData['status'] = self::STATUS_COMPLETE;
return $this->update($iPaymentId, $aData);
} | [
"public",
"function",
"setComplete",
"(",
"$",
"iPaymentId",
",",
"$",
"aData",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"$",
"aData",
"[",
"'status'",
"]",
"=",
"self",
"::",
"STATUS_COMPLETE",
";",
"return",
"$",
"this",
"->",
"update",
"(",
"$",
"iPa... | Set a payment as COMPLETE
@param integer $iPaymentId The payment to update
@param array $aData Any additional data to save to the transaction
@return bool
@throws \Nails\Common\Exception\FactoryException | [
"Set",
"a",
"payment",
"as",
"COMPLETE"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Payment.php#L352-L356 | train |
nails/module-invoice | src/Model/Payment.php | Payment.setFailed | public function setFailed($iPaymentId, $aData = []): bool
{
$aData['status'] = self::STATUS_FAILED;
return $this->update($iPaymentId, $aData);
} | php | public function setFailed($iPaymentId, $aData = []): bool
{
$aData['status'] = self::STATUS_FAILED;
return $this->update($iPaymentId, $aData);
} | [
"public",
"function",
"setFailed",
"(",
"$",
"iPaymentId",
",",
"$",
"aData",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"$",
"aData",
"[",
"'status'",
"]",
"=",
"self",
"::",
"STATUS_FAILED",
";",
"return",
"$",
"this",
"->",
"update",
"(",
"$",
"iPaymen... | Set a payment as FAILED
@param integer $iPaymentId The payment to update
@param array $aData Any additional data to save to the transaction
@return bool
@throws \Nails\Common\Exception\FactoryException | [
"Set",
"a",
"payment",
"as",
"FAILED"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Payment.php#L369-L373 | train |
nails/module-invoice | src/Model/Payment.php | Payment.setRefunded | public function setRefunded($iPaymentId, $aData = []): bool
{
$aData['status'] = self::STATUS_REFUNDED;
return $this->update($iPaymentId, $aData);
} | php | public function setRefunded($iPaymentId, $aData = []): bool
{
$aData['status'] = self::STATUS_REFUNDED;
return $this->update($iPaymentId, $aData);
} | [
"public",
"function",
"setRefunded",
"(",
"$",
"iPaymentId",
",",
"$",
"aData",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"$",
"aData",
"[",
"'status'",
"]",
"=",
"self",
"::",
"STATUS_REFUNDED",
";",
"return",
"$",
"this",
"->",
"update",
"(",
"$",
"iPa... | Set a payment as REFUNDED
@param integer $iPaymentId The payment to update
@param array $aData Any additional data to save to the transaction
@return bool
@throws \Nails\Common\Exception\FactoryException | [
"Set",
"a",
"payment",
"as",
"REFUNDED"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Payment.php#L386-L390 | train |
nails/module-invoice | src/Model/Payment.php | Payment.setRefundedPartial | public function setRefundedPartial($iPaymentId, $aData = []): bool
{
$aData['status'] = self::STATUS_REFUNDED_PARTIAL;
return $this->update($iPaymentId, $aData);
} | php | public function setRefundedPartial($iPaymentId, $aData = []): bool
{
$aData['status'] = self::STATUS_REFUNDED_PARTIAL;
return $this->update($iPaymentId, $aData);
} | [
"public",
"function",
"setRefundedPartial",
"(",
"$",
"iPaymentId",
",",
"$",
"aData",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"$",
"aData",
"[",
"'status'",
"]",
"=",
"self",
"::",
"STATUS_REFUNDED_PARTIAL",
";",
"return",
"$",
"this",
"->",
"update",
"("... | Set a payment as REFUNDED_PARTIAL
@param integer $iPaymentId The payment to update
@param array $aData Any additional data to save to the transaction
@return bool
@throws \Nails\Common\Exception\FactoryException | [
"Set",
"a",
"payment",
"as",
"REFUNDED_PARTIAL"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Payment.php#L403-L407 | train |
nails/module-invoice | src/Model/Payment.php | Payment.refund | public function refund(int $iPaymentId, int $iAmount = null, string $sReason = null): bool
{
try {
// Validate payment
$oPayment = $this->getById($iPaymentId, ['expand' => ['invoice']]);
if (!$oPayment) {
throw new PaymentException('Invalid payment ID.');
}
// Set up RefundRequest object
/** @var RefundRequest $oRefundRequest */
$oRefundRequest = Factory::factory('RefundRequest', 'nails/module-invoice');
// Set the driver to use for the request
$oRefundRequest->setDriver($oPayment->driver->slug);
// Describe the charge
$oRefundRequest->setReason($sReason);
// Set the payment we're refunding against
$oRefundRequest->setPayment($oPayment->id);
// Attempt the refund
/** @var RefundResponse $oRefundResponse */
$oRefundResponse = $oRefundRequest->execute($iAmount);
if ($oRefundResponse->isProcessing() || $oRefundResponse->isComplete()) {
// It's all good
} elseif ($oRefundResponse->isFailed()) {
// Refund failed, throw an error which will be caught and displayed to the user
throw new PaymentException('Refund failed: ' . $oRefundResponse->getError()->user);
} else {
//Something which we've not accounted for went wrong.
throw new PaymentException('Refund failed.');
}
return true;
} catch (PaymentException $e) {
$this->setError($e->getMessage());
return false;
}
} | php | public function refund(int $iPaymentId, int $iAmount = null, string $sReason = null): bool
{
try {
// Validate payment
$oPayment = $this->getById($iPaymentId, ['expand' => ['invoice']]);
if (!$oPayment) {
throw new PaymentException('Invalid payment ID.');
}
// Set up RefundRequest object
/** @var RefundRequest $oRefundRequest */
$oRefundRequest = Factory::factory('RefundRequest', 'nails/module-invoice');
// Set the driver to use for the request
$oRefundRequest->setDriver($oPayment->driver->slug);
// Describe the charge
$oRefundRequest->setReason($sReason);
// Set the payment we're refunding against
$oRefundRequest->setPayment($oPayment->id);
// Attempt the refund
/** @var RefundResponse $oRefundResponse */
$oRefundResponse = $oRefundRequest->execute($iAmount);
if ($oRefundResponse->isProcessing() || $oRefundResponse->isComplete()) {
// It's all good
} elseif ($oRefundResponse->isFailed()) {
// Refund failed, throw an error which will be caught and displayed to the user
throw new PaymentException('Refund failed: ' . $oRefundResponse->getError()->user);
} else {
//Something which we've not accounted for went wrong.
throw new PaymentException('Refund failed.');
}
return true;
} catch (PaymentException $e) {
$this->setError($e->getMessage());
return false;
}
} | [
"public",
"function",
"refund",
"(",
"int",
"$",
"iPaymentId",
",",
"int",
"$",
"iAmount",
"=",
"null",
",",
"string",
"$",
"sReason",
"=",
"null",
")",
":",
"bool",
"{",
"try",
"{",
"// Validate payment",
"$",
"oPayment",
"=",
"$",
"this",
"->",
"get... | Perform a refund
@param int $iPaymentId
@param int $iAmount
@param string $sReason
@return bool
@throws ModelException
@throws \Nails\Common\Exception\FactoryException
@throws \Nails\Invoice\Exception\RefundRequestException
@throws \Nails\Invoice\Exception\RequestException | [
"Perform",
"a",
"refund"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Payment.php#L523-L566 | train |
nails/module-invoice | src/Model/Payment.php | Payment.getPaymentForEvent | protected function getPaymentForEvent(int $iPaymentId): Resource
{
$oPayment = $this->getById($iPaymentId);
if (empty($oPayment)) {
throw new ModelException('Invalid payment ID');
}
return $oPayment;
} | php | protected function getPaymentForEvent(int $iPaymentId): Resource
{
$oPayment = $this->getById($iPaymentId);
if (empty($oPayment)) {
throw new ModelException('Invalid payment ID');
}
return $oPayment;
} | [
"protected",
"function",
"getPaymentForEvent",
"(",
"int",
"$",
"iPaymentId",
")",
":",
"Resource",
"{",
"$",
"oPayment",
"=",
"$",
"this",
"->",
"getById",
"(",
"$",
"iPaymentId",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"oPayment",
")",
")",
"{",
"thr... | Get a payment in a suitable format for the event triggers
@param int $iPaymentId The payment ID
@return Resource
@throws \Nails\Common\Exception\ModelException | [
"Get",
"a",
"payment",
"in",
"a",
"suitable",
"format",
"for",
"the",
"event",
"triggers"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Payment.php#L578-L585 | train |
canihavesomecoffee/theTVDbAPI | src/Route/SeriesRoute.php | SeriesRoute.getLastModified | public function getLastModified(int $id): DateTimeImmutable
{
$headers = $this->parent->requestHeaders('head', '/series/'.$id);
if (array_key_exists('Last-Modified', $headers) && array_key_exists(0, $headers['Last-Modified'])) {
$lastModified = DateTimeImmutable::createFromFormat(
static::LAST_MODIFIED_FORMAT,
$headers['Last-Modified'][0]
);
if ($lastModified === false) {
throw ParseException::lastModified($headers['Last-Modified'][0]);
}
return $lastModified;
}
throw ParseException::missingHeader('Last-Modified');
} | php | public function getLastModified(int $id): DateTimeImmutable
{
$headers = $this->parent->requestHeaders('head', '/series/'.$id);
if (array_key_exists('Last-Modified', $headers) && array_key_exists(0, $headers['Last-Modified'])) {
$lastModified = DateTimeImmutable::createFromFormat(
static::LAST_MODIFIED_FORMAT,
$headers['Last-Modified'][0]
);
if ($lastModified === false) {
throw ParseException::lastModified($headers['Last-Modified'][0]);
}
return $lastModified;
}
throw ParseException::missingHeader('Last-Modified');
} | [
"public",
"function",
"getLastModified",
"(",
"int",
"$",
"id",
")",
":",
"DateTimeImmutable",
"{",
"$",
"headers",
"=",
"$",
"this",
"->",
"parent",
"->",
"requestHeaders",
"(",
"'head'",
",",
"'/series/'",
".",
"$",
"id",
")",
";",
"if",
"(",
"array_ke... | Fetches the last modified parameter for a series through a HEAD request.
@param int $id The id of the series.
@return DateTimeImmutable The datetime for when the series was last modified.
@throws ParseException is thrown when the header is missing or couldn't be parsed. | [
"Fetches",
"the",
"last",
"modified",
"parameter",
"for",
"a",
"series",
"through",
"a",
"HEAD",
"request",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/Route/SeriesRoute.php#L78-L96 | train |
canihavesomecoffee/theTVDbAPI | src/Route/SeriesRoute.php | SeriesRoute.getEpisodesSummary | public function getEpisodesSummary(int $id): SeriesStatistics
{
$json = $this->parent->performAPICallWithJsonResponse('get', '/series/'.$id.'/episodes/summary');
return DataParser::parseData($json, SeriesStatistics::class);
} | php | public function getEpisodesSummary(int $id): SeriesStatistics
{
$json = $this->parent->performAPICallWithJsonResponse('get', '/series/'.$id.'/episodes/summary');
return DataParser::parseData($json, SeriesStatistics::class);
} | [
"public",
"function",
"getEpisodesSummary",
"(",
"int",
"$",
"id",
")",
":",
"SeriesStatistics",
"{",
"$",
"json",
"=",
"$",
"this",
"->",
"parent",
"->",
"performAPICallWithJsonResponse",
"(",
"'get'",
",",
"'/series/'",
".",
"$",
"id",
".",
"'/episodes/summa... | Returns statistics about how many seasons & episodes were aired.
@param int $id The series id.
@return SeriesStatistics Statistics on the given series. | [
"Returns",
"statistics",
"about",
"how",
"many",
"seasons",
"&",
"episodes",
"were",
"aired",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/Route/SeriesRoute.php#L172-L177 | train |
canihavesomecoffee/theTVDbAPI | src/Route/SeriesRoute.php | SeriesRoute.getWithFilter | public function getWithFilter(int $id, array $keys): array
{
return $this->parent->performAPICallWithJsonResponse(
'get',
'/series/'.$id.'/filter',
[
'query' => ['keys' => join(',', $keys)]
]
);
} | php | public function getWithFilter(int $id, array $keys): array
{
return $this->parent->performAPICallWithJsonResponse(
'get',
'/series/'.$id.'/filter',
[
'query' => ['keys' => join(',', $keys)]
]
);
} | [
"public",
"function",
"getWithFilter",
"(",
"int",
"$",
"id",
",",
"array",
"$",
"keys",
")",
":",
"array",
"{",
"return",
"$",
"this",
"->",
"parent",
"->",
"performAPICallWithJsonResponse",
"(",
"'get'",
",",
"'/series/'",
".",
"$",
"id",
".",
"'/filter'... | Fetches the data for a series, but only with the attributes that are provided.
@param int $id The series id.
@param array $keys The keys that should be returned.
@return array A key -> value list with the retrieved data. | [
"Fetches",
"the",
"data",
"for",
"a",
"series",
"but",
"only",
"with",
"the",
"attributes",
"that",
"are",
"provided",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/Route/SeriesRoute.php#L199-L208 | train |
canihavesomecoffee/theTVDbAPI | src/Route/SeriesRoute.php | SeriesRoute.getImages | public function getImages(int $id): ImageStatistics
{
$json = $this->parent->performAPICallWithJsonResponse('get', '/series/'.$id.'/images');
return DataParser::parseData($json, ImageStatistics::class);
} | php | public function getImages(int $id): ImageStatistics
{
$json = $this->parent->performAPICallWithJsonResponse('get', '/series/'.$id.'/images');
return DataParser::parseData($json, ImageStatistics::class);
} | [
"public",
"function",
"getImages",
"(",
"int",
"$",
"id",
")",
":",
"ImageStatistics",
"{",
"$",
"json",
"=",
"$",
"this",
"->",
"parent",
"->",
"performAPICallWithJsonResponse",
"(",
"'get'",
",",
"'/series/'",
".",
"$",
"id",
".",
"'/images'",
")",
";",
... | Fetches statistics on the submitted images.
@param int $id The id of the series.
@return ImageStatistics An instance with series statistics. | [
"Fetches",
"statistics",
"on",
"the",
"submitted",
"images",
"."
] | f23f544029269fe2a244818209b060d08654eca6 | https://github.com/canihavesomecoffee/theTVDbAPI/blob/f23f544029269fe2a244818209b060d08654eca6/src/Route/SeriesRoute.php#L217-L222 | train |
orchestral/support | src/Support/Concerns/QueryFilter.php | QueryFilter.buildWildcardQueryFilters | protected function buildWildcardQueryFilters($query, array $fields, array $keyword = [])
{
foreach ($fields as $field) {
$this->buildWildcardForField($query, $field, $keyword);
}
return $query;
} | php | protected function buildWildcardQueryFilters($query, array $fields, array $keyword = [])
{
foreach ($fields as $field) {
$this->buildWildcardForField($query, $field, $keyword);
}
return $query;
} | [
"protected",
"function",
"buildWildcardQueryFilters",
"(",
"$",
"query",
",",
"array",
"$",
"fields",
",",
"array",
"$",
"keyword",
"=",
"[",
"]",
")",
"{",
"foreach",
"(",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"this",
"->",
"buildWildcardFor... | Build wildcard query filters.
@param \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder $query
@param array $fields
@param array $keyword
@param string $group
@return \Illuminate\Database\Eloquent\Builder|\Illuminate\Database\Query\Builder | [
"Build",
"wildcard",
"query",
"filters",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Support/Concerns/QueryFilter.php#L119-L126 | train |
orchestral/support | src/Providers/Concerns/PackageProvider.php | PackageProvider.addLanguageComponent | public function addLanguageComponent(string $package, string $namespace, string $path): void
{
$this->app->make('translator')->addNamespace($namespace, $path);
} | php | public function addLanguageComponent(string $package, string $namespace, string $path): void
{
$this->app->make('translator')->addNamespace($namespace, $path);
} | [
"public",
"function",
"addLanguageComponent",
"(",
"string",
"$",
"package",
",",
"string",
"$",
"namespace",
",",
"string",
"$",
"path",
")",
":",
"void",
"{",
"$",
"this",
"->",
"app",
"->",
"make",
"(",
"'translator'",
")",
"->",
"addNamespace",
"(",
... | Register the package's language component namespaces.
@param string $package
@param string $namespace
@param string $path
@return void | [
"Register",
"the",
"package",
"s",
"language",
"component",
"namespaces",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Providers/Concerns/PackageProvider.php#L35-L38 | train |
orchestral/support | src/Providers/Concerns/PackageProvider.php | PackageProvider.getAppViewPaths | protected function getAppViewPaths(string $package): array
{
return \array_map(function ($path) use ($package) {
return "{$path}/packages/{$package}";
}, $this->app->make('config')->get('view.paths', []));
} | php | protected function getAppViewPaths(string $package): array
{
return \array_map(function ($path) use ($package) {
return "{$path}/packages/{$package}";
}, $this->app->make('config')->get('view.paths', []));
} | [
"protected",
"function",
"getAppViewPaths",
"(",
"string",
"$",
"package",
")",
":",
"array",
"{",
"return",
"\\",
"array_map",
"(",
"function",
"(",
"$",
"path",
")",
"use",
"(",
"$",
"package",
")",
"{",
"return",
"\"{$path}/packages/{$package}\"",
";",
"}... | Get the application package view paths.
@param string $package
@return array | [
"Get",
"the",
"application",
"package",
"view",
"paths",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Providers/Concerns/PackageProvider.php#L143-L148 | train |
nails/module-invoice | src/Api/Controller/Customer.php | Customer.getSearch | public function getSearch()
{
if (!userHasPermission('admin:invoice:customer:manage')) {
throw new ApiException('You are not authorised to search customers.', 401);
}
$oInput = Factory::service('Input');
$sKeywords = $oInput->get('keywords');
$oCustomerModel = Factory::model('Customer', 'nails/module-invoice');
if (strlen($sKeywords) < 3) {
throw new ApiException('Search term must be 3 characters or longer.', 400);
}
$oResult = $oCustomerModel->search($sKeywords);
$aOut = [];
foreach ($oResult->data as $oCustomer) {
$aOut[] = $this->formatCustomer($oCustomer);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($aOut);
} | php | public function getSearch()
{
if (!userHasPermission('admin:invoice:customer:manage')) {
throw new ApiException('You are not authorised to search customers.', 401);
}
$oInput = Factory::service('Input');
$sKeywords = $oInput->get('keywords');
$oCustomerModel = Factory::model('Customer', 'nails/module-invoice');
if (strlen($sKeywords) < 3) {
throw new ApiException('Search term must be 3 characters or longer.', 400);
}
$oResult = $oCustomerModel->search($sKeywords);
$aOut = [];
foreach ($oResult->data as $oCustomer) {
$aOut[] = $this->formatCustomer($oCustomer);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($aOut);
} | [
"public",
"function",
"getSearch",
"(",
")",
"{",
"if",
"(",
"!",
"userHasPermission",
"(",
"'admin:invoice:customer:manage'",
")",
")",
"{",
"throw",
"new",
"ApiException",
"(",
"'You are not authorised to search customers.'",
",",
"401",
")",
";",
"}",
"$",
"oIn... | Search for a customer | [
"Search",
"for",
"a",
"customer"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Api/Controller/Customer.php#L24-L47 | train |
nails/module-invoice | src/Api/Controller/Customer.php | Customer.getId | public function getId($iId = null)
{
$oInput = Factory::service('Input');
$iId = (int) $iId ?: (int) $oInput->get('id');
if (empty($iId)) {
throw new ApiException('Invalid Customer ID', 404);
}
$oCustomerModel = Factory::model('Customer', 'nails/module-invoice');
$oCustomer = $oCustomerModel->getById($iId);
if (empty($oCustomer)) {
throw new ApiException('Invalid Customer ID', 404);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($this->formatCustomer($oCustomer));
} | php | public function getId($iId = null)
{
$oInput = Factory::service('Input');
$iId = (int) $iId ?: (int) $oInput->get('id');
if (empty($iId)) {
throw new ApiException('Invalid Customer ID', 404);
}
$oCustomerModel = Factory::model('Customer', 'nails/module-invoice');
$oCustomer = $oCustomerModel->getById($iId);
if (empty($oCustomer)) {
throw new ApiException('Invalid Customer ID', 404);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($this->formatCustomer($oCustomer));
} | [
"public",
"function",
"getId",
"(",
"$",
"iId",
"=",
"null",
")",
"{",
"$",
"oInput",
"=",
"Factory",
"::",
"service",
"(",
"'Input'",
")",
";",
"$",
"iId",
"=",
"(",
"int",
")",
"$",
"iId",
"?",
":",
"(",
"int",
")",
"$",
"oInput",
"->",
"get"... | Returns a customer by their ID
@param string $iId The customer's ID
@return array | [
"Returns",
"a",
"customer",
"by",
"their",
"ID"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Api/Controller/Customer.php#L58-L76 | train |
emgiezet/errbitPHP | src/Errbit/Handlers/ErrorHandlers.php | ErrorHandlers.onShutdown | public function onShutdown()
{
if (($error = error_get_last()) && $error['type'] & error_reporting()) {
$this->errbit->notify(new Fatal($error['message'], $error['file'], $error['line']));
}
} | php | public function onShutdown()
{
if (($error = error_get_last()) && $error['type'] & error_reporting()) {
$this->errbit->notify(new Fatal($error['message'], $error['file'], $error['line']));
}
} | [
"public",
"function",
"onShutdown",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"error",
"=",
"error_get_last",
"(",
")",
")",
"&&",
"$",
"error",
"[",
"'type'",
"]",
"&",
"error_reporting",
"(",
")",
")",
"{",
"$",
"this",
"->",
"errbit",
"->",
"notify",
... | On shut down | [
"On",
"shut",
"down"
] | cc634f8d6b0d2cd4a29648662119310afc73fa7b | https://github.com/emgiezet/errbitPHP/blob/cc634f8d6b0d2cd4a29648662119310afc73fa7b/src/Errbit/Handlers/ErrorHandlers.php#L96-L101 | train |
nails/module-invoice | src/Api/Controller/Invoice.php | Invoice.getSearch | public function getSearch()
{
if (!userHasPermission('admin:invoice:invoice:manage')) {
throw new ApiException('You are not authorised to search invoices.', 401);
}
$oInput = Factory::service('Input');
$sKeywords = $oInput->get('keywords');
$oInvoiceModel = Factory::model('Invoice', 'nails/module-invoice');
if (strlen($sKeywords) >= 3) {
throw new ApiException('Search term must be 3 characters or longer.', 400);
}
$oResult = $oInvoiceModel->search($sKeywords, null, null, ['expand' => ['customer']]);
$aOut = [];
foreach ($oResult->data as $oInvoice) {
$aOut[] = $this->formatInvoice($oInvoice);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($aOut);
} | php | public function getSearch()
{
if (!userHasPermission('admin:invoice:invoice:manage')) {
throw new ApiException('You are not authorised to search invoices.', 401);
}
$oInput = Factory::service('Input');
$sKeywords = $oInput->get('keywords');
$oInvoiceModel = Factory::model('Invoice', 'nails/module-invoice');
if (strlen($sKeywords) >= 3) {
throw new ApiException('Search term must be 3 characters or longer.', 400);
}
$oResult = $oInvoiceModel->search($sKeywords, null, null, ['expand' => ['customer']]);
$aOut = [];
foreach ($oResult->data as $oInvoice) {
$aOut[] = $this->formatInvoice($oInvoice);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($aOut);
} | [
"public",
"function",
"getSearch",
"(",
")",
"{",
"if",
"(",
"!",
"userHasPermission",
"(",
"'admin:invoice:invoice:manage'",
")",
")",
"{",
"throw",
"new",
"ApiException",
"(",
"'You are not authorised to search invoices.'",
",",
"401",
")",
";",
"}",
"$",
"oInpu... | Search for an invoice | [
"Search",
"for",
"an",
"invoice"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Api/Controller/Invoice.php#L24-L47 | train |
nails/module-invoice | src/Api/Controller/Invoice.php | Invoice.getId | public function getId($iId = null)
{
$oInput = Factory::service('Input');
$iId = (int) $iId ?: (int) $oInput->get('id');
if (empty($iId)) {
throw new ApiException('Invalid Invoice ID', 404);
}
$oInvoiceModel = Factory::model('Invoice', 'nails/module-invoice');
$oInvoice = $oInvoiceModel->getById($iId, ['expand' => ['customer']]);
if (empty($oInvoice)) {
throw new ApiException('Invalid Invoice ID', 404);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($this->formatInvoice($oInvoice));
} | php | public function getId($iId = null)
{
$oInput = Factory::service('Input');
$iId = (int) $iId ?: (int) $oInput->get('id');
if (empty($iId)) {
throw new ApiException('Invalid Invoice ID', 404);
}
$oInvoiceModel = Factory::model('Invoice', 'nails/module-invoice');
$oInvoice = $oInvoiceModel->getById($iId, ['expand' => ['customer']]);
if (empty($oInvoice)) {
throw new ApiException('Invalid Invoice ID', 404);
}
return Factory::factory('ApiResponse', 'nails/module-api')
->setData($this->formatInvoice($oInvoice));
} | [
"public",
"function",
"getId",
"(",
"$",
"iId",
"=",
"null",
")",
"{",
"$",
"oInput",
"=",
"Factory",
"::",
"service",
"(",
"'Input'",
")",
";",
"$",
"iId",
"=",
"(",
"int",
")",
"$",
"iId",
"?",
":",
"(",
"int",
")",
"$",
"oInput",
"->",
"get"... | Returns an invoice by its ID
@param string $iId The invoice's ID
@return array | [
"Returns",
"an",
"invoice",
"by",
"its",
"ID"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Api/Controller/Invoice.php#L58-L76 | train |
pxgamer/arionum-php | src/Transaction.php | Transaction.makeAliasSendInstance | public static function makeAliasSendInstance(string $alias, float $value, string $message = ''): self
{
$transaction = new self();
$transaction->setVersion(Version::ALIAS_SEND);
$transaction->setDestinationAddress($alias);
$transaction->setValue($value);
$transaction->setMessage($message);
return $transaction;
} | php | public static function makeAliasSendInstance(string $alias, float $value, string $message = ''): self
{
$transaction = new self();
$transaction->setVersion(Version::ALIAS_SEND);
$transaction->setDestinationAddress($alias);
$transaction->setValue($value);
$transaction->setMessage($message);
return $transaction;
} | [
"public",
"static",
"function",
"makeAliasSendInstance",
"(",
"string",
"$",
"alias",
",",
"float",
"$",
"value",
",",
"string",
"$",
"message",
"=",
"''",
")",
":",
"self",
"{",
"$",
"transaction",
"=",
"new",
"self",
"(",
")",
";",
"$",
"transaction",
... | Retrieve a pre-populated Transaction instance for sending to an alias.
@param string $alias
@param float $value
@param string $message
@return self
@api | [
"Retrieve",
"a",
"pre",
"-",
"populated",
"Transaction",
"instance",
"for",
"sending",
"to",
"an",
"alias",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L132-L142 | train |
pxgamer/arionum-php | src/Transaction.php | Transaction.makeAliasSetInstance | public static function makeAliasSetInstance(string $address, string $alias): self
{
$transaction = new self();
$transaction->setVersion(Version::ALIAS_SET);
$transaction->setDestinationAddress($address);
$transaction->setValue(self::VALUE_ALIAS_SET);
$transaction->setFee(self::FEE_ALIAS_SET);
$transaction->setMessage($alias);
return $transaction;
} | php | public static function makeAliasSetInstance(string $address, string $alias): self
{
$transaction = new self();
$transaction->setVersion(Version::ALIAS_SET);
$transaction->setDestinationAddress($address);
$transaction->setValue(self::VALUE_ALIAS_SET);
$transaction->setFee(self::FEE_ALIAS_SET);
$transaction->setMessage($alias);
return $transaction;
} | [
"public",
"static",
"function",
"makeAliasSetInstance",
"(",
"string",
"$",
"address",
",",
"string",
"$",
"alias",
")",
":",
"self",
"{",
"$",
"transaction",
"=",
"new",
"self",
"(",
")",
";",
"$",
"transaction",
"->",
"setVersion",
"(",
"Version",
"::",
... | Retrieve a pre-populated Transaction instance for setting an alias.
@param string $address
@param string $alias
@return self
@api | [
"Retrieve",
"a",
"pre",
"-",
"populated",
"Transaction",
"instance",
"for",
"setting",
"an",
"alias",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L152-L163 | train |
pxgamer/arionum-php | src/Transaction.php | Transaction.makeMasternodeCreateInstance | public static function makeMasternodeCreateInstance(string $ipAddress, string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_CREATE);
$transaction->setDestinationAddress($address);
$transaction->setValue(self::VALUE_MASTERNODE_CREATE);
$transaction->setFee(self::FEE_MASTERNODE_CREATE);
$transaction->setMessage($ipAddress);
return $transaction;
} | php | public static function makeMasternodeCreateInstance(string $ipAddress, string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_CREATE);
$transaction->setDestinationAddress($address);
$transaction->setValue(self::VALUE_MASTERNODE_CREATE);
$transaction->setFee(self::FEE_MASTERNODE_CREATE);
$transaction->setMessage($ipAddress);
return $transaction;
} | [
"public",
"static",
"function",
"makeMasternodeCreateInstance",
"(",
"string",
"$",
"ipAddress",
",",
"string",
"$",
"address",
")",
":",
"self",
"{",
"$",
"transaction",
"=",
"new",
"self",
"(",
")",
";",
"$",
"transaction",
"->",
"setVersion",
"(",
"Versio... | Retrieve a pre-populated Transaction instance for creating a masternode.
@param string $ipAddress
@param string $address
@return self
@api | [
"Retrieve",
"a",
"pre",
"-",
"populated",
"Transaction",
"instance",
"for",
"creating",
"a",
"masternode",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L173-L184 | train |
pxgamer/arionum-php | src/Transaction.php | Transaction.makeMasternodePauseInstance | public static function makeMasternodePauseInstance(string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_PAUSE);
return self::setMasternodeCommandDefaults($address, $transaction);
} | php | public static function makeMasternodePauseInstance(string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_PAUSE);
return self::setMasternodeCommandDefaults($address, $transaction);
} | [
"public",
"static",
"function",
"makeMasternodePauseInstance",
"(",
"string",
"$",
"address",
")",
":",
"self",
"{",
"$",
"transaction",
"=",
"new",
"self",
"(",
")",
";",
"$",
"transaction",
"->",
"setVersion",
"(",
"Version",
"::",
"MASTERNODE_PAUSE",
")",
... | Retrieve a pre-populated Transaction instance for pausing a masternode.
@param string $address
@return self
@api | [
"Retrieve",
"a",
"pre",
"-",
"populated",
"Transaction",
"instance",
"for",
"pausing",
"a",
"masternode",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L193-L199 | train |
pxgamer/arionum-php | src/Transaction.php | Transaction.makeMasternodeResumeInstance | public static function makeMasternodeResumeInstance(string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_RESUME);
return self::setMasternodeCommandDefaults($address, $transaction);
} | php | public static function makeMasternodeResumeInstance(string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_RESUME);
return self::setMasternodeCommandDefaults($address, $transaction);
} | [
"public",
"static",
"function",
"makeMasternodeResumeInstance",
"(",
"string",
"$",
"address",
")",
":",
"self",
"{",
"$",
"transaction",
"=",
"new",
"self",
"(",
")",
";",
"$",
"transaction",
"->",
"setVersion",
"(",
"Version",
"::",
"MASTERNODE_RESUME",
")",... | Retrieve a pre-populated Transaction instance for resuming a masternode.
@param string $address
@return self
@api | [
"Retrieve",
"a",
"pre",
"-",
"populated",
"Transaction",
"instance",
"for",
"resuming",
"a",
"masternode",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L208-L214 | train |
pxgamer/arionum-php | src/Transaction.php | Transaction.makeMasternodeReleaseInstance | public static function makeMasternodeReleaseInstance(string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_RELEASE);
return self::setMasternodeCommandDefaults($address, $transaction);
} | php | public static function makeMasternodeReleaseInstance(string $address): self
{
$transaction = new self();
$transaction->setVersion(Version::MASTERNODE_RELEASE);
return self::setMasternodeCommandDefaults($address, $transaction);
} | [
"public",
"static",
"function",
"makeMasternodeReleaseInstance",
"(",
"string",
"$",
"address",
")",
":",
"self",
"{",
"$",
"transaction",
"=",
"new",
"self",
"(",
")",
";",
"$",
"transaction",
"->",
"setVersion",
"(",
"Version",
"::",
"MASTERNODE_RELEASE",
")... | Retrieve a pre-populated Transaction instance for releasing a masternode.
@param string $address
@return self
@api | [
"Retrieve",
"a",
"pre",
"-",
"populated",
"Transaction",
"instance",
"for",
"releasing",
"a",
"masternode",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L223-L229 | train |
pxgamer/arionum-php | src/Transaction.php | Transaction.setMasternodeCommandDefaults | private static function setMasternodeCommandDefaults(string $address, Transaction $transaction): self
{
$transaction->setDestinationAddress($address);
$transaction->setValue(self::VALUE_MASTERNODE_COMMAND);
$transaction->setFee(self::FEE_MASTERNODE_COMMAND);
return $transaction;
} | php | private static function setMasternodeCommandDefaults(string $address, Transaction $transaction): self
{
$transaction->setDestinationAddress($address);
$transaction->setValue(self::VALUE_MASTERNODE_COMMAND);
$transaction->setFee(self::FEE_MASTERNODE_COMMAND);
return $transaction;
} | [
"private",
"static",
"function",
"setMasternodeCommandDefaults",
"(",
"string",
"$",
"address",
",",
"Transaction",
"$",
"transaction",
")",
":",
"self",
"{",
"$",
"transaction",
"->",
"setDestinationAddress",
"(",
"$",
"address",
")",
";",
"$",
"transaction",
"... | Set the default fee and value for masternode commands.
@param string $address
@param self $transaction
@return self
@internal | [
"Set",
"the",
"default",
"fee",
"and",
"value",
"for",
"masternode",
"commands",
"."
] | 1d3e73f7b661878b864b3a910faad540e6af47bb | https://github.com/pxgamer/arionum-php/blob/1d3e73f7b661878b864b3a910faad540e6af47bb/src/Transaction.php#L338-L345 | train |
byjg/restserver | src/ServerRequestHandler.php | ServerRequestHandler.mimeContentType | public function mimeContentType($filename)
{
$mimeTypes = array(
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// images
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
// archives
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',
// audio/video
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
// adobe
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
// ms office
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// open office
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
);
if (!file_exists($filename)) {
throw new Error404Exception();
}
$ext = substr(strrchr($filename, "."), 1);
if (array_key_exists($ext, $mimeTypes)) {
return $mimeTypes[$ext];
} elseif (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_file($finfo, $filename);
finfo_close($finfo);
return $mimetype;
} else {
return 'application/octet-stream';
}
} | php | public function mimeContentType($filename)
{
$mimeTypes = array(
'txt' => 'text/plain',
'htm' => 'text/html',
'html' => 'text/html',
'php' => 'text/html',
'css' => 'text/css',
'js' => 'application/javascript',
'json' => 'application/json',
'xml' => 'application/xml',
'swf' => 'application/x-shockwave-flash',
'flv' => 'video/x-flv',
// images
'png' => 'image/png',
'jpe' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'jpg' => 'image/jpeg',
'gif' => 'image/gif',
'bmp' => 'image/bmp',
'ico' => 'image/vnd.microsoft.icon',
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'svg' => 'image/svg+xml',
'svgz' => 'image/svg+xml',
// archives
'zip' => 'application/zip',
'rar' => 'application/x-rar-compressed',
'exe' => 'application/x-msdownload',
'msi' => 'application/x-msdownload',
'cab' => 'application/vnd.ms-cab-compressed',
// audio/video
'mp3' => 'audio/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
// adobe
'pdf' => 'application/pdf',
'psd' => 'image/vnd.adobe.photoshop',
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
// ms office
'doc' => 'application/msword',
'rtf' => 'application/rtf',
'xls' => 'application/vnd.ms-excel',
'ppt' => 'application/vnd.ms-powerpoint',
// open office
'odt' => 'application/vnd.oasis.opendocument.text',
'ods' => 'application/vnd.oasis.opendocument.spreadsheet',
);
if (!file_exists($filename)) {
throw new Error404Exception();
}
$ext = substr(strrchr($filename, "."), 1);
if (array_key_exists($ext, $mimeTypes)) {
return $mimeTypes[$ext];
} elseif (function_exists('finfo_open')) {
$finfo = finfo_open(FILEINFO_MIME);
$mimetype = finfo_file($finfo, $filename);
finfo_close($finfo);
return $mimetype;
} else {
return 'application/octet-stream';
}
} | [
"public",
"function",
"mimeContentType",
"(",
"$",
"filename",
")",
"{",
"$",
"mimeTypes",
"=",
"array",
"(",
"'txt'",
"=>",
"'text/plain'",
",",
"'htm'",
"=>",
"'text/html'",
",",
"'html'",
"=>",
"'text/html'",
",",
"'php'",
"=>",
"'text/html'",
",",
"'css'... | Get the Mime Type based on the filename
@param string $filename
@return string
@throws Error404Exception | [
"Get",
"the",
"Mime",
"Type",
"based",
"on",
"the",
"filename"
] | 1fdbd58f414f5d9958de0873d67eea961dc52fda | https://github.com/byjg/restserver/blob/1fdbd58f414f5d9958de0873d67eea961dc52fda/src/ServerRequestHandler.php#L261-L328 | train |
QoboLtd/qobo-robo | src/Command/Mysql/DbCreate.php | DbCreate.mysqlDbCreate | public function mysqlDbCreate(
$db,
$user = 'root',
$pass = null,
$host = null,
$port = null,
$opts = ['format' => 'table', 'fields' => '']
) {
$result = $this->taskMysqlDbCreate()
->db($db)
->user($user)
->pass($pass)
->host($host)
->port($port)
->hide($pass)
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
return true;
} | php | public function mysqlDbCreate(
$db,
$user = 'root',
$pass = null,
$host = null,
$port = null,
$opts = ['format' => 'table', 'fields' => '']
) {
$result = $this->taskMysqlDbCreate()
->db($db)
->user($user)
->pass($pass)
->host($host)
->port($port)
->hide($pass)
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
return true;
} | [
"public",
"function",
"mysqlDbCreate",
"(",
"$",
"db",
",",
"$",
"user",
"=",
"'root'",
",",
"$",
"pass",
"=",
"null",
",",
"$",
"host",
"=",
"null",
",",
"$",
"port",
"=",
"null",
",",
"$",
"opts",
"=",
"[",
"'format'",
"=>",
"'table'",
",",
"'f... | Create mysql database
@param string $db Database name
@param string $user MySQL user to bind with
@param string $pass (Optional) MySQL user password
@param string $host (Optional) MySQL server host
@param string $port (Optional) MySQL server port
@option string $format Output format (table, list, csv, json, xml)
@option string $fields Limit output to given fields, comma-separated
@return bool | [
"Create",
"mysql",
"database"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/Command/Mysql/DbCreate.php#L32-L54 | train |
orchestral/support | src/Support/Manager.php | Manager.checkNameIsNotBlacklisted | protected function checkNameIsNotBlacklisted(string $name): void
{
if (Str::contains($name, $this->blacklisted)) {
throw new InvalidArgumentException("Invalid character in driver name [{$name}].");
}
} | php | protected function checkNameIsNotBlacklisted(string $name): void
{
if (Str::contains($name, $this->blacklisted)) {
throw new InvalidArgumentException("Invalid character in driver name [{$name}].");
}
} | [
"protected",
"function",
"checkNameIsNotBlacklisted",
"(",
"string",
"$",
"name",
")",
":",
"void",
"{",
"if",
"(",
"Str",
"::",
"contains",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"blacklisted",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
... | Check if name is not blacklisted.
@param string $name
@throws \InvalidArgumentException
@return void | [
"Check",
"if",
"name",
"is",
"not",
"blacklisted",
"."
] | b56f0469f967737e39fc9a33d40ae7439f4f6884 | https://github.com/orchestral/support/blob/b56f0469f967737e39fc9a33d40ae7439f4f6884/src/Support/Manager.php#L98-L103 | train |
doganoo/PHPUtil | src/Storage/PDOConnector.php | PDOConnector.startTransaction | public function startTransaction(): bool {
if ($this->transactionExists) {
return false;
}
$started = $this->pdo->beginTransaction();
$this->transactionExists = $started;
return $started;
} | php | public function startTransaction(): bool {
if ($this->transactionExists) {
return false;
}
$started = $this->pdo->beginTransaction();
$this->transactionExists = $started;
return $started;
} | [
"public",
"function",
"startTransaction",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"transactionExists",
")",
"{",
"return",
"false",
";",
"}",
"$",
"started",
"=",
"$",
"this",
"->",
"pdo",
"->",
"beginTransaction",
"(",
")",
";",
"$",... | starts a database transaction
@return bool | [
"starts",
"a",
"database",
"transaction"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Storage/PDOConnector.php#L68-L75 | train |
doganoo/PHPUtil | src/Storage/PDOConnector.php | PDOConnector.commit | public function commit(): bool {
if ($this->transactionExists) {
$commited = $this->pdo->commit();
$this->transactionExists = !$commited;
return $commited;
}
return false;
} | php | public function commit(): bool {
if ($this->transactionExists) {
$commited = $this->pdo->commit();
$this->transactionExists = !$commited;
return $commited;
}
return false;
} | [
"public",
"function",
"commit",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"transactionExists",
")",
"{",
"$",
"commited",
"=",
"$",
"this",
"->",
"pdo",
"->",
"commit",
"(",
")",
";",
"$",
"this",
"->",
"transactionExists",
"=",
"!",
... | commits a started database transaction
@return bool | [
"commits",
"a",
"started",
"database",
"transaction"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Storage/PDOConnector.php#L81-L88 | train |
doganoo/PHPUtil | src/Storage/PDOConnector.php | PDOConnector.rollback | public function rollback(): bool {
if ($this->transactionExists) {
$rolledBack = $this->pdo->rollBack();
$this->transactionExists = !$rolledBack;
return $rolledBack;
}
return false;
} | php | public function rollback(): bool {
if ($this->transactionExists) {
$rolledBack = $this->pdo->rollBack();
$this->transactionExists = !$rolledBack;
return $rolledBack;
}
return false;
} | [
"public",
"function",
"rollback",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"transactionExists",
")",
"{",
"$",
"rolledBack",
"=",
"$",
"this",
"->",
"pdo",
"->",
"rollBack",
"(",
")",
";",
"$",
"this",
"->",
"transactionExists",
"=",
... | rolls a started transaction back
@return bool | [
"rolls",
"a",
"started",
"transaction",
"back"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Storage/PDOConnector.php#L94-L101 | train |
doganoo/PHPUtil | src/Storage/PDOConnector.php | PDOConnector.connect | public function connect(): bool {
if (!$this->hasMinimumCredentials()) {
throw new InvalidCredentialsException();
}
$host = $this->credentials["servername"];
$db = $this->credentials["dbname"];
$dsn = "mysql:host=$host;dbname=$db;charset=utf8";
$this->pdo = new \PDO($dsn,
$this->credentials["username"],
$this->credentials["password"]
);
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
return $this->pdo !== null;
} | php | public function connect(): bool {
if (!$this->hasMinimumCredentials()) {
throw new InvalidCredentialsException();
}
$host = $this->credentials["servername"];
$db = $this->credentials["dbname"];
$dsn = "mysql:host=$host;dbname=$db;charset=utf8";
$this->pdo = new \PDO($dsn,
$this->credentials["username"],
$this->credentials["password"]
);
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
return $this->pdo !== null;
} | [
"public",
"function",
"connect",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasMinimumCredentials",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidCredentialsException",
"(",
")",
";",
"}",
"$",
"host",
"=",
"$",
"this",
"->",
"creden... | connects to the database
@return bool
@throws InvalidCredentialsException | [
"connects",
"to",
"the",
"database"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Storage/PDOConnector.php#L109-L122 | train |
doganoo/PHPUtil | src/Storage/PDOConnector.php | PDOConnector.hasMinimumCredentials | private function hasMinimumCredentials(): bool {
if (!isset($this->credentials["servername"])) {
return false;
}
if (!isset($this->credentials["username"])) {
return false;
}
if (!isset($this->credentials["password"])) {
return false;
}
if (!isset($this->credentials["dbname"])) {
return false;
}
return true;
} | php | private function hasMinimumCredentials(): bool {
if (!isset($this->credentials["servername"])) {
return false;
}
if (!isset($this->credentials["username"])) {
return false;
}
if (!isset($this->credentials["password"])) {
return false;
}
if (!isset($this->credentials["dbname"])) {
return false;
}
return true;
} | [
"private",
"function",
"hasMinimumCredentials",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"credentials",
"[",
"\"servername\"",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"th... | checks for the minimum required credentials
@return bool | [
"checks",
"for",
"the",
"minimum",
"required",
"credentials"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Storage/PDOConnector.php#L129-L143 | train |
doganoo/PHPUtil | src/Storage/PDOConnector.php | PDOConnector.prepare | public function prepare(string $sql): ?\PDOStatement {
$statement = $this->getConnection()->prepare($sql);
if ($statement === false) {
return null;
}
$this->statement = $statement;
return $statement;
} | php | public function prepare(string $sql): ?\PDOStatement {
$statement = $this->getConnection()->prepare($sql);
if ($statement === false) {
return null;
}
$this->statement = $statement;
return $statement;
} | [
"public",
"function",
"prepare",
"(",
"string",
"$",
"sql",
")",
":",
"?",
"\\",
"PDOStatement",
"{",
"$",
"statement",
"=",
"$",
"this",
"->",
"getConnection",
"(",
")",
"->",
"prepare",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"$",
"statement",
"===",... | prepares a SQL statement
@param string $sql
@return null|\PDOStatement | [
"prepares",
"a",
"SQL",
"statement"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Storage/PDOConnector.php#L151-L158 | train |
nails/module-invoice | src/Model/Customer.php | Customer.update | public function update($iCustomerId, array $aData = []): bool
{
try {
$sKeyExistsLabel = array_key_exists('label', $aData);
$sKeyExistsOrg = array_key_exists('organisation', $aData);
$sKeyExistsFirst = array_key_exists('first_name', $aData);
$sKeyExistsLast = array_key_exists('last_name', $aData);
if ($sKeyExistsOrg && $sKeyExistsFirst && $sKeyExistsLast) {
if (empty($aData['organisation']) && empty($aData['first_name']) && empty($aData['last_name'])) {
throw new InvoiceException('"organisation", "first_name" and "last_name" cannot all be empty.', 1);
}
}
// Only compile the label if the label isn't defined and any of the other fields are present
if (!$sKeyExistsLabel && ($sKeyExistsOrg || $sKeyExistsFirst || $sKeyExistsLast)) {
$aData['label'] = $this->compileLabel($aData);
}
return parent::update($iCustomerId, $aData);
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
} | php | public function update($iCustomerId, array $aData = []): bool
{
try {
$sKeyExistsLabel = array_key_exists('label', $aData);
$sKeyExistsOrg = array_key_exists('organisation', $aData);
$sKeyExistsFirst = array_key_exists('first_name', $aData);
$sKeyExistsLast = array_key_exists('last_name', $aData);
if ($sKeyExistsOrg && $sKeyExistsFirst && $sKeyExistsLast) {
if (empty($aData['organisation']) && empty($aData['first_name']) && empty($aData['last_name'])) {
throw new InvoiceException('"organisation", "first_name" and "last_name" cannot all be empty.', 1);
}
}
// Only compile the label if the label isn't defined and any of the other fields are present
if (!$sKeyExistsLabel && ($sKeyExistsOrg || $sKeyExistsFirst || $sKeyExistsLast)) {
$aData['label'] = $this->compileLabel($aData);
}
return parent::update($iCustomerId, $aData);
} catch (\Exception $e) {
$this->setError($e->getMessage());
return false;
}
} | [
"public",
"function",
"update",
"(",
"$",
"iCustomerId",
",",
"array",
"$",
"aData",
"=",
"[",
"]",
")",
":",
"bool",
"{",
"try",
"{",
"$",
"sKeyExistsLabel",
"=",
"array_key_exists",
"(",
"'label'",
",",
"$",
"aData",
")",
";",
"$",
"sKeyExistsOrg",
"... | Update an existing customer
@param integer $iCustomerId The ID of the customer to update
@param array $aData The data to update the customer with
@return mixed | [
"Update",
"an",
"existing",
"customer"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Customer.php#L123-L149 | train |
nails/module-invoice | src/Model/Customer.php | Customer.compileLabel | protected function compileLabel($aData)
{
if (!empty($aData['organisation'])) {
return trim($aData['organisation']);
} else {
return implode(
' ',
array_filter([
!empty($aData['first_name']) ? trim($aData['first_name']) : '',
!empty($aData['last_name']) ? trim($aData['last_name']) : '',
])
);
}
} | php | protected function compileLabel($aData)
{
if (!empty($aData['organisation'])) {
return trim($aData['organisation']);
} else {
return implode(
' ',
array_filter([
!empty($aData['first_name']) ? trim($aData['first_name']) : '',
!empty($aData['last_name']) ? trim($aData['last_name']) : '',
])
);
}
} | [
"protected",
"function",
"compileLabel",
"(",
"$",
"aData",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"aData",
"[",
"'organisation'",
"]",
")",
")",
"{",
"return",
"trim",
"(",
"$",
"aData",
"[",
"'organisation'",
"]",
")",
";",
"}",
"else",
"{",
... | Compile the customer label
@param array $aData The data passed to create() or update()
@return string | [
"Compile",
"the",
"customer",
"label"
] | 3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716 | https://github.com/nails/module-invoice/blob/3e62067f9de1b0ddb6b0ce0eddeb3eea4ee85716/src/Model/Customer.php#L160-L173 | train |
doganoo/PHPUtil | src/Datatype/PasswordClass.php | PasswordClass.verify | public function verify($password): bool {
if ($password instanceof StringClass || $password instanceof PasswordClass) {
return password_verify($password->getValue(), $this->getValue());
}
return password_verify($password, $this->getValue());
} | php | public function verify($password): bool {
if ($password instanceof StringClass || $password instanceof PasswordClass) {
return password_verify($password->getValue(), $this->getValue());
}
return password_verify($password, $this->getValue());
} | [
"public",
"function",
"verify",
"(",
"$",
"password",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"password",
"instanceof",
"StringClass",
"||",
"$",
"password",
"instanceof",
"PasswordClass",
")",
"{",
"return",
"password_verify",
"(",
"$",
"password",
"->",
"ge... | verifies the password
@param $password
@return bool | [
"verifies",
"the",
"password"
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Datatype/PasswordClass.php#L60-L65 | train |
QoboLtd/qobo-robo | src/Command/Project/DotenvDelete.php | DotenvDelete.projectDotenvDelete | public function projectDotenvDelete($envPath = '.env', $opts = ['force' => false])
{
if (!$opts['force']) {
$this->say(static::MSG_NO_DELETE);
return false;
}
if (!file_exists($envPath)) {
return true;
}
$result = $this->taskFilesystemStack()
->remove($envPath)
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
return true;
} | php | public function projectDotenvDelete($envPath = '.env', $opts = ['force' => false])
{
if (!$opts['force']) {
$this->say(static::MSG_NO_DELETE);
return false;
}
if (!file_exists($envPath)) {
return true;
}
$result = $this->taskFilesystemStack()
->remove($envPath)
->run();
if (!$result->wasSuccessful()) {
$this->exitError("Failed to run command");
}
return true;
} | [
"public",
"function",
"projectDotenvDelete",
"(",
"$",
"envPath",
"=",
"'.env'",
",",
"$",
"opts",
"=",
"[",
"'force'",
"=>",
"false",
"]",
")",
"{",
"if",
"(",
"!",
"$",
"opts",
"[",
"'force'",
"]",
")",
"{",
"$",
"this",
"->",
"say",
"(",
"static... | Delete dotenv file
@param string $envPath Path to dotenv file
@option $force Force deletion
@return bool true on success or false on failure | [
"Delete",
"dotenv",
"file"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/Command/Project/DotenvDelete.php#L26-L45 | train |
QoboLtd/qobo-robo | src/Utility/Dotenv.php | Dotenv.parse | public static function parse($dotenv, $data = [], $flags = self::FLAG_STRICT)
{
if (!is_array($dotenv)) {
$dotenv = explode("\n", $dotenv);
}
$result = (!empty($data)) ? $data : [];
// nothing to do with empty dotenv
if (empty($dotenv)) {
return $result;
}
// FLAG_REPLACE_DUPLICATES and FLAG_STRICT are mutually exclusive
if (($flags & static::FLAG_REPLACE_DUPLICATES) && ($flags & static::FLAG_STRICT)) {
throw new InvalidArgumentException("Can't use FLAG_REPLACE_DUPLICATES and FLAG_STRICT together");
}
foreach ($dotenv as $line) {
$line = trim($line);
// Disregard comments
if (strpos($line, '#') === 0) {
continue;
}
// Only use nont-empty lines that look like setters
if (!preg_match('#^\s*(.+?)=(.*)?$#', $line, $matches)) {
continue;
}
$name = static::normalizeName($matches[1]);
$value = static::normalizeValue(trim($matches[2]));
$value = static::resolveNested($value, $result);
if ($value === "" && ($flags & static::FLAG_SKIP_EMPTY)) {
continue;
}
if (!isset($result[$name]) || ($flags & static::FLAG_REPLACE_DUPLICATES)) {
$result[$name] = $value;
continue;
}
if ($flags & static::FLAG_STRICT) {
throw new RuntimeException("Duplicate value found for variable '$name'");
}
}
return $result;
} | php | public static function parse($dotenv, $data = [], $flags = self::FLAG_STRICT)
{
if (!is_array($dotenv)) {
$dotenv = explode("\n", $dotenv);
}
$result = (!empty($data)) ? $data : [];
// nothing to do with empty dotenv
if (empty($dotenv)) {
return $result;
}
// FLAG_REPLACE_DUPLICATES and FLAG_STRICT are mutually exclusive
if (($flags & static::FLAG_REPLACE_DUPLICATES) && ($flags & static::FLAG_STRICT)) {
throw new InvalidArgumentException("Can't use FLAG_REPLACE_DUPLICATES and FLAG_STRICT together");
}
foreach ($dotenv as $line) {
$line = trim($line);
// Disregard comments
if (strpos($line, '#') === 0) {
continue;
}
// Only use nont-empty lines that look like setters
if (!preg_match('#^\s*(.+?)=(.*)?$#', $line, $matches)) {
continue;
}
$name = static::normalizeName($matches[1]);
$value = static::normalizeValue(trim($matches[2]));
$value = static::resolveNested($value, $result);
if ($value === "" && ($flags & static::FLAG_SKIP_EMPTY)) {
continue;
}
if (!isset($result[$name]) || ($flags & static::FLAG_REPLACE_DUPLICATES)) {
$result[$name] = $value;
continue;
}
if ($flags & static::FLAG_STRICT) {
throw new RuntimeException("Duplicate value found for variable '$name'");
}
}
return $result;
} | [
"public",
"static",
"function",
"parse",
"(",
"$",
"dotenv",
",",
"$",
"data",
"=",
"[",
"]",
",",
"$",
"flags",
"=",
"self",
"::",
"FLAG_STRICT",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"dotenv",
")",
")",
"{",
"$",
"dotenv",
"=",
"explo... | Parse dotenv content
@param string|array string $dotenv Dotenv content
@param array $data Any preset env variables
@param int $flags Additianal flags for parsing
@return array List of dotenv variables with their values | [
"Parse",
"dotenv",
"content"
] | ea10f778bb046ad41324d22b27fce5a2fb8915ce | https://github.com/QoboLtd/qobo-robo/blob/ea10f778bb046ad41324d22b27fce5a2fb8915ce/src/Utility/Dotenv.php#L50-L100 | train |
doganoo/PHPUtil | src/Util/AppContainer.php | AppContainer.getInstance | private static function getInstance(): HashMap {
if (null === self::$map) {
self::$map = new HashMap();
}
return self::$map;
} | php | private static function getInstance(): HashMap {
if (null === self::$map) {
self::$map = new HashMap();
}
return self::$map;
} | [
"private",
"static",
"function",
"getInstance",
"(",
")",
":",
"HashMap",
"{",
"if",
"(",
"null",
"===",
"self",
"::",
"$",
"map",
")",
"{",
"self",
"::",
"$",
"map",
"=",
"new",
"HashMap",
"(",
")",
";",
"}",
"return",
"self",
"::",
"$",
"map",
... | returning the Map instance.
@return HashMap | [
"returning",
"the",
"Map",
"instance",
"."
] | 4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5 | https://github.com/doganoo/PHPUtil/blob/4415a014b4448b1ddf6d2e3f0f0d39cd1a83b8f5/src/Util/AppContainer.php#L74-L79 | train |
hackzilla/TicketBundle | Entity/Traits/TicketTrait.php | TicketTrait.setStatusString | public function setStatusString($status)
{
$status = \array_search(\strtolower($status), TicketMessageInterface::STATUSES);
if ($status > 0) {
$this->setStatus($status);
}
return $this;
} | php | public function setStatusString($status)
{
$status = \array_search(\strtolower($status), TicketMessageInterface::STATUSES);
if ($status > 0) {
$this->setStatus($status);
}
return $this;
} | [
"public",
"function",
"setStatusString",
"(",
"$",
"status",
")",
"{",
"$",
"status",
"=",
"\\",
"array_search",
"(",
"\\",
"strtolower",
"(",
"$",
"status",
")",
",",
"TicketMessageInterface",
"::",
"STATUSES",
")",
";",
"if",
"(",
"$",
"status",
">",
"... | Set status string.
@param string $status
@return $this | [
"Set",
"status",
"string",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Entity/Traits/TicketTrait.php#L91-L100 | train |
hackzilla/TicketBundle | Entity/Traits/TicketTrait.php | TicketTrait.setPriorityString | public function setPriorityString($priority)
{
$priority = \array_search(\strtolower($priority), TicketMessageInterface::PRIORITIES);
if ($priority > 0) {
$this->setPriority($priority);
}
return $this;
} | php | public function setPriorityString($priority)
{
$priority = \array_search(\strtolower($priority), TicketMessageInterface::PRIORITIES);
if ($priority > 0) {
$this->setPriority($priority);
}
return $this;
} | [
"public",
"function",
"setPriorityString",
"(",
"$",
"priority",
")",
"{",
"$",
"priority",
"=",
"\\",
"array_search",
"(",
"\\",
"strtolower",
"(",
"$",
"priority",
")",
",",
"TicketMessageInterface",
"::",
"PRIORITIES",
")",
";",
"if",
"(",
"$",
"priority"... | Set priority string.
@param string $priority
@return $this | [
"Set",
"priority",
"string",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Entity/Traits/TicketTrait.php#L147-L156 | train |
hackzilla/TicketBundle | Entity/Traits/TicketTrait.php | TicketTrait.setUserCreated | public function setUserCreated($userCreated)
{
if (\is_object($userCreated)) {
$this->userCreatedObject = $userCreated;
$this->userCreated = $userCreated->getId();
} else {
$this->userCreatedObject = null;
$this->userCreated = $userCreated;
}
return $this;
} | php | public function setUserCreated($userCreated)
{
if (\is_object($userCreated)) {
$this->userCreatedObject = $userCreated;
$this->userCreated = $userCreated->getId();
} else {
$this->userCreatedObject = null;
$this->userCreated = $userCreated;
}
return $this;
} | [
"public",
"function",
"setUserCreated",
"(",
"$",
"userCreated",
")",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"userCreated",
")",
")",
"{",
"$",
"this",
"->",
"userCreatedObject",
"=",
"$",
"userCreated",
";",
"$",
"this",
"->",
"userCreated",
"=",
... | Set userCreated.
@param int|object $userCreated
@return $this | [
"Set",
"userCreated",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Entity/Traits/TicketTrait.php#L189-L200 | train |
hackzilla/TicketBundle | Entity/Traits/TicketTrait.php | TicketTrait.setLastUser | public function setLastUser($lastUser)
{
if (\is_object($lastUser)) {
$this->lastUserObject = $lastUser;
$this->lastUser = $lastUser->getId();
} else {
$this->lastUserObject = null;
$this->lastUser = $lastUser;
}
return $this;
} | php | public function setLastUser($lastUser)
{
if (\is_object($lastUser)) {
$this->lastUserObject = $lastUser;
$this->lastUser = $lastUser->getId();
} else {
$this->lastUserObject = null;
$this->lastUser = $lastUser;
}
return $this;
} | [
"public",
"function",
"setLastUser",
"(",
"$",
"lastUser",
")",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"lastUser",
")",
")",
"{",
"$",
"this",
"->",
"lastUserObject",
"=",
"$",
"lastUser",
";",
"$",
"this",
"->",
"lastUser",
"=",
"$",
"lastUser",... | Set lastUser.
@param int|object $lastUser
@return $this | [
"Set",
"lastUser",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Entity/Traits/TicketTrait.php#L229-L240 | train |
hackzilla/TicketBundle | Controller/TicketAttachmentController.php | TicketAttachmentController.downloadAction | public function downloadAction($ticketMessageId)
{
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticketMessage = $ticketManager->getMessageById($ticketMessageId);
if (!$ticketMessage || !$ticketMessage instanceof TicketMessageWithAttachment) {
throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY', [], 'HackzillaTicketBundle'));
}
// check permissions
$userManager = $this->get('hackzilla_ticket.user_manager');
$userManager->hasPermission($userManager->getCurrentUser(), $ticketMessage->getTicket());
$downloadHandler = $this->get('vich_uploader.download_handler');
return $downloadHandler->downloadObject($ticketMessage, 'attachmentFile');
} | php | public function downloadAction($ticketMessageId)
{
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticketMessage = $ticketManager->getMessageById($ticketMessageId);
if (!$ticketMessage || !$ticketMessage instanceof TicketMessageWithAttachment) {
throw $this->createNotFoundException($this->get('translator')->trans('ERROR_FIND_TICKET_ENTITY', [], 'HackzillaTicketBundle'));
}
// check permissions
$userManager = $this->get('hackzilla_ticket.user_manager');
$userManager->hasPermission($userManager->getCurrentUser(), $ticketMessage->getTicket());
$downloadHandler = $this->get('vich_uploader.download_handler');
return $downloadHandler->downloadObject($ticketMessage, 'attachmentFile');
} | [
"public",
"function",
"downloadAction",
"(",
"$",
"ticketMessageId",
")",
"{",
"$",
"ticketManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'hackzilla_ticket.ticket_manager'",
")",
";",
"$",
"ticketMessage",
"=",
"$",
"ticketManager",
"->",
"getMessageById",
"(",
... | Download attachment on message.
@param int $ticketMessageId
@return \Symfony\Component\HttpFoundation\Response | [
"Download",
"attachment",
"on",
"message",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Controller/TicketAttachmentController.php#L22-L38 | train |
hackzilla/TicketBundle | Controller/TicketController.php | TicketController.indexAction | public function indexAction(Request $request)
{
$userManager = $this->getUserManager();
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticketState = $request->get('state', $this->get('translator')->trans('STATUS_OPEN', [], 'HackzillaTicketBundle'));
$ticketPriority = $request->get('priority', null);
$query = $ticketManager->getTicketListQuery(
$userManager,
$ticketManager->getTicketStatus($ticketState),
$ticketManager->getTicketPriority($ticketPriority)
);
$pagination = $this->get('knp_paginator')->paginate(
$query->getQuery(),
$request->query->get('page', 1)/*page number*/,
10/*limit per page*/
);
return $this->render(
$this->container->getParameter('hackzilla_ticket.templates')['index'],
[
'pagination' => $pagination,
'ticketState' => $ticketState,
'ticketPriority' => $ticketPriority,
]
);
} | php | public function indexAction(Request $request)
{
$userManager = $this->getUserManager();
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticketState = $request->get('state', $this->get('translator')->trans('STATUS_OPEN', [], 'HackzillaTicketBundle'));
$ticketPriority = $request->get('priority', null);
$query = $ticketManager->getTicketListQuery(
$userManager,
$ticketManager->getTicketStatus($ticketState),
$ticketManager->getTicketPriority($ticketPriority)
);
$pagination = $this->get('knp_paginator')->paginate(
$query->getQuery(),
$request->query->get('page', 1)/*page number*/,
10/*limit per page*/
);
return $this->render(
$this->container->getParameter('hackzilla_ticket.templates')['index'],
[
'pagination' => $pagination,
'ticketState' => $ticketState,
'ticketPriority' => $ticketPriority,
]
);
} | [
"public",
"function",
"indexAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"userManager",
"=",
"$",
"this",
"->",
"getUserManager",
"(",
")",
";",
"$",
"ticketManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'hackzilla_ticket.ticket_manager'",
")",
";... | Lists all Ticket entities.
@param Request $request
@return \Symfony\Component\HttpFoundation\Response | [
"Lists",
"all",
"Ticket",
"entities",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Controller/TicketController.php#L28-L56 | train |
hackzilla/TicketBundle | Controller/TicketController.php | TicketController.createAction | public function createAction(Request $request)
{
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticket = $ticketManager->createTicket();
$form = $this->createForm(TicketType::class, $ticket);
$form->handleRequest($request);
if ($form->isValid()) {
$message = $ticket->getMessages()->current();
$message->setStatus(TicketMessageInterface::STATUS_OPEN)
->setUser($this->getUserManager()->getCurrentUser());
$ticketManager->updateTicket($ticket, $message);
$this->dispatchTicketEvent(TicketEvents::TICKET_CREATE, $ticket);
return $this->redirect($this->generateUrl('hackzilla_ticket_show', ['ticketId' => $ticket->getId()]));
}
return $this->render(
$this->container->getParameter('hackzilla_ticket.templates')['new'],
[
'entity' => $ticket,
'form' => $form->createView(),
]
);
} | php | public function createAction(Request $request)
{
$ticketManager = $this->get('hackzilla_ticket.ticket_manager');
$ticket = $ticketManager->createTicket();
$form = $this->createForm(TicketType::class, $ticket);
$form->handleRequest($request);
if ($form->isValid()) {
$message = $ticket->getMessages()->current();
$message->setStatus(TicketMessageInterface::STATUS_OPEN)
->setUser($this->getUserManager()->getCurrentUser());
$ticketManager->updateTicket($ticket, $message);
$this->dispatchTicketEvent(TicketEvents::TICKET_CREATE, $ticket);
return $this->redirect($this->generateUrl('hackzilla_ticket_show', ['ticketId' => $ticket->getId()]));
}
return $this->render(
$this->container->getParameter('hackzilla_ticket.templates')['new'],
[
'entity' => $ticket,
'form' => $form->createView(),
]
);
} | [
"public",
"function",
"createAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"ticketManager",
"=",
"$",
"this",
"->",
"get",
"(",
"'hackzilla_ticket.ticket_manager'",
")",
";",
"$",
"ticket",
"=",
"$",
"ticketManager",
"->",
"createTicket",
"(",
")",
... | Creates a new Ticket entity.
@param Request $request
@return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response | [
"Creates",
"a",
"new",
"Ticket",
"entity",
"."
] | 7bfd6c513979272a32bae582b7f96948605af459 | https://github.com/hackzilla/TicketBundle/blob/7bfd6c513979272a32bae582b7f96948605af459/Controller/TicketController.php#L65-L91 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.