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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
timmcleod/turtlecoin-rpc-php | src/TurtleCoin/TurtleService.php | TurtleService.reset | public function reset(int $scanHeight = null):JsonResponse
{
$params = [];
if (!is_null($scanHeight)) $params['scanHeight'] = $scanHeight;
return $this->rpcPost('reset', $params);
} | php | public function reset(int $scanHeight = null):JsonResponse
{
$params = [];
if (!is_null($scanHeight)) $params['scanHeight'] = $scanHeight;
return $this->rpcPost('reset', $params);
} | [
"public",
"function",
"reset",
"(",
"int",
"$",
"scanHeight",
"=",
"null",
")",
":",
"JsonResponse",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"scanHeight",
")",
")",
"$",
"params",
"[",
"'scanHeight'",
"]",
"=",
... | Re-syncs the wallet.
@param int|null $scanHeight The scan height to start scanning for transactions. Optional.
@return JsonResponse | [
"Re",
"-",
"syncs",
"the",
"wallet",
"."
] | 0e4c37cc580db8f51174dc10afb845c1f278afea | https://github.com/timmcleod/turtlecoin-rpc-php/blob/0e4c37cc580db8f51174dc10afb845c1f278afea/src/TurtleCoin/TurtleService.php#L30-L37 | train |
timmcleod/turtlecoin-rpc-php | src/TurtleCoin/TurtleService.php | TurtleService.createAddress | public function createAddress(string $secretSpendKey = null, string $publicSpendKey = null):JsonResponse
{
$params = [];
if (!is_null($secretSpendKey)) $params['secretSpendKey'] = $secretSpendKey;
if (!is_null($publicSpendKey)) $params['publicSpendKey'] = $publicSpendKey;
return $this->rpcPost('createAddress', $params);
} | php | public function createAddress(string $secretSpendKey = null, string $publicSpendKey = null):JsonResponse
{
$params = [];
if (!is_null($secretSpendKey)) $params['secretSpendKey'] = $secretSpendKey;
if (!is_null($publicSpendKey)) $params['publicSpendKey'] = $publicSpendKey;
return $this->rpcPost('createAddress', $params);
} | [
"public",
"function",
"createAddress",
"(",
"string",
"$",
"secretSpendKey",
"=",
"null",
",",
"string",
"$",
"publicSpendKey",
"=",
"null",
")",
":",
"JsonResponse",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"secretSpe... | Creates an additional address in your wallet.
@param string|null $secretSpendKey Private spend key. If secretSpendKey was specified,
RPC Wallet creates spend address. Optional.
@param string|null $publicSpendKey Public spend key. If publicSpendKey was specified,
RPC Wallet creates view address. Optional.
@return JsonResponse | [
"Creates",
"an",
"additional",
"address",
"in",
"your",
"wallet",
"."
] | 0e4c37cc580db8f51174dc10afb845c1f278afea | https://github.com/timmcleod/turtlecoin-rpc-php/blob/0e4c37cc580db8f51174dc10afb845c1f278afea/src/TurtleCoin/TurtleService.php#L104-L112 | train |
timmcleod/turtlecoin-rpc-php | src/TurtleCoin/TurtleService.php | TurtleService.getBalance | public function getBalance(string $address = null):JsonResponse
{
$params = [];
if (!is_null($address)) $params['address'] = $address;
return $this->rpcPost('getBalance', $params);
} | php | public function getBalance(string $address = null):JsonResponse
{
$params = [];
if (!is_null($address)) $params['address'] = $address;
return $this->rpcPost('getBalance', $params);
} | [
"public",
"function",
"getBalance",
"(",
"string",
"$",
"address",
"=",
"null",
")",
":",
"JsonResponse",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"address",
")",
")",
"$",
"params",
"[",
"'address'",
"]",
"=",
"... | Method returns a balance for a specified address.
@param string|null $address Valid and existing address in this wallet. Optional.
@return JsonResponse | [
"Method",
"returns",
"a",
"balance",
"for",
"a",
"specified",
"address",
"."
] | 0e4c37cc580db8f51174dc10afb845c1f278afea | https://github.com/timmcleod/turtlecoin-rpc-php/blob/0e4c37cc580db8f51174dc10afb845c1f278afea/src/TurtleCoin/TurtleService.php#L135-L142 | train |
timmcleod/turtlecoin-rpc-php | src/TurtleCoin/TurtleService.php | TurtleService.getBlockHashes | public function getBlockHashes(int $firstBlockIndex, int $blockCount):JsonResponse
{
$params = [
'firstBlockIndex' => $firstBlockIndex,
'blockCount' => $blockCount,
];
return $this->rpcPost('getBlockHashes', $params);
} | php | public function getBlockHashes(int $firstBlockIndex, int $blockCount):JsonResponse
{
$params = [
'firstBlockIndex' => $firstBlockIndex,
'blockCount' => $blockCount,
];
return $this->rpcPost('getBlockHashes', $params);
} | [
"public",
"function",
"getBlockHashes",
"(",
"int",
"$",
"firstBlockIndex",
",",
"int",
"$",
"blockCount",
")",
":",
"JsonResponse",
"{",
"$",
"params",
"=",
"[",
"'firstBlockIndex'",
"=>",
"$",
"firstBlockIndex",
",",
"'blockCount'",
"=>",
"$",
"blockCount",
... | Returns an array of block hashes for a specified block range.
@param int $firstBlockIndex Starting height. Required.
@param int $blockCount Number of blocks to process. Required.
@return JsonResponse | [
"Returns",
"an",
"array",
"of",
"block",
"hashes",
"for",
"a",
"specified",
"block",
"range",
"."
] | 0e4c37cc580db8f51174dc10afb845c1f278afea | https://github.com/timmcleod/turtlecoin-rpc-php/blob/0e4c37cc580db8f51174dc10afb845c1f278afea/src/TurtleCoin/TurtleService.php#L151-L159 | train |
timmcleod/turtlecoin-rpc-php | src/TurtleCoin/TurtleService.php | TurtleService.getTransactionHashes | public function getTransactionHashes(
int $blockCount,
int $firstBlockIndex = null,
string $blockHash = null,
array $addresses = null,
string $paymentId = null
):JsonResponse {
$params = [
'blockCount' => $blockCount,
];
if (!is_null($firstBlockIndex)) $params['firstBlockIndex'] = $firstBlockIndex;
if (!is_null($blockHash)) $params['blockHash'] = $blockHash;
if (!is_null($addresses)) $params['addresses'] = $addresses;
if (!is_null($paymentId)) $params['paymentId'] = $paymentId;
return $this->rpcPost('getTransactionHashes', $params);
} | php | public function getTransactionHashes(
int $blockCount,
int $firstBlockIndex = null,
string $blockHash = null,
array $addresses = null,
string $paymentId = null
):JsonResponse {
$params = [
'blockCount' => $blockCount,
];
if (!is_null($firstBlockIndex)) $params['firstBlockIndex'] = $firstBlockIndex;
if (!is_null($blockHash)) $params['blockHash'] = $blockHash;
if (!is_null($addresses)) $params['addresses'] = $addresses;
if (!is_null($paymentId)) $params['paymentId'] = $paymentId;
return $this->rpcPost('getTransactionHashes', $params);
} | [
"public",
"function",
"getTransactionHashes",
"(",
"int",
"$",
"blockCount",
",",
"int",
"$",
"firstBlockIndex",
"=",
"null",
",",
"string",
"$",
"blockHash",
"=",
"null",
",",
"array",
"$",
"addresses",
"=",
"null",
",",
"string",
"$",
"paymentId",
"=",
"... | Returns an array of block and transaction hashes. Transaction consists of transfers.
Transfer is an amount-address pair. There could be several transfers in a single transaction.
@param int $blockCount Number of blocks to return transaction hashes from. Required.
@param int|null $firstBlockIndex Starting height. Only allowed without $blockHash.
@param string|null $blockHash Hash of the starting block. Only allowed without $firstBlockIndex.
@param array|null $addresses Array of strings, where each string is an address. Optional.
@param string|null $paymentId Valid payment_id. Optional.
@return JsonResponse | [
"Returns",
"an",
"array",
"of",
"block",
"and",
"transaction",
"hashes",
".",
"Transaction",
"consists",
"of",
"transfers",
".",
"Transfer",
"is",
"an",
"amount",
"-",
"address",
"pair",
".",
"There",
"could",
"be",
"several",
"transfers",
"in",
"a",
"single... | 0e4c37cc580db8f51174dc10afb845c1f278afea | https://github.com/timmcleod/turtlecoin-rpc-php/blob/0e4c37cc580db8f51174dc10afb845c1f278afea/src/TurtleCoin/TurtleService.php#L172-L189 | train |
timmcleod/turtlecoin-rpc-php | src/TurtleCoin/TurtleService.php | TurtleService.getUnconfirmedTransactionHashes | public function getUnconfirmedTransactionHashes(array $addresses = null):JsonResponse
{
$params = [];
if (!is_null($addresses)) $params['addresses'] = $addresses;
return $this->rpcPost('getUnconfirmedTransactionHashes', $params);
} | php | public function getUnconfirmedTransactionHashes(array $addresses = null):JsonResponse
{
$params = [];
if (!is_null($addresses)) $params['addresses'] = $addresses;
return $this->rpcPost('getUnconfirmedTransactionHashes', $params);
} | [
"public",
"function",
"getUnconfirmedTransactionHashes",
"(",
"array",
"$",
"addresses",
"=",
"null",
")",
":",
"JsonResponse",
"{",
"$",
"params",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"addresses",
")",
")",
"$",
"params",
"[",
"'addr... | Returns information about the current unconfirmed transaction pool or for a specified addresses.
Transaction consists of transfers. Transfer is an amount-address pair. There could be several
transfers in a single transaction.
@param array|null $addresses Array of strings, where each string is a valid address. Optional.
@return JsonResponse | [
"Returns",
"information",
"about",
"the",
"current",
"unconfirmed",
"transaction",
"pool",
"or",
"for",
"a",
"specified",
"addresses",
".",
"Transaction",
"consists",
"of",
"transfers",
".",
"Transfer",
"is",
"an",
"amount",
"-",
"address",
"pair",
".",
"There",... | 0e4c37cc580db8f51174dc10afb845c1f278afea | https://github.com/timmcleod/turtlecoin-rpc-php/blob/0e4c37cc580db8f51174dc10afb845c1f278afea/src/TurtleCoin/TurtleService.php#L229-L236 | train |
timmcleod/turtlecoin-rpc-php | src/TurtleCoin/TurtleService.php | TurtleService.sendTransaction | public function sendTransaction(
int $anonymity,
array $transfers,
int $fee,
array $addresses = null,
int $unlockTime = null,
string $extra = null,
string $paymentId = null,
string $changeAddress = null
):JsonResponse {
$params = [
'anonymity' => $anonymity,
'transfers' => $transfers,
'fee' => $fee,
];
if (!is_null($addresses)) $params['addresses'] = $addresses;
if (!is_null($unlockTime)) $params['unlockTime'] = $unlockTime;
if (!is_null($extra)) $params['extra'] = $extra;
if (!is_null($paymentId)) $params['paymentId'] = $paymentId;
if (!is_null($changeAddress)) $params['changeAddress'] = $changeAddress;
return $this->rpcPost('sendTransaction', $params);
} | php | public function sendTransaction(
int $anonymity,
array $transfers,
int $fee,
array $addresses = null,
int $unlockTime = null,
string $extra = null,
string $paymentId = null,
string $changeAddress = null
):JsonResponse {
$params = [
'anonymity' => $anonymity,
'transfers' => $transfers,
'fee' => $fee,
];
if (!is_null($addresses)) $params['addresses'] = $addresses;
if (!is_null($unlockTime)) $params['unlockTime'] = $unlockTime;
if (!is_null($extra)) $params['extra'] = $extra;
if (!is_null($paymentId)) $params['paymentId'] = $paymentId;
if (!is_null($changeAddress)) $params['changeAddress'] = $changeAddress;
return $this->rpcPost('sendTransaction', $params);
} | [
"public",
"function",
"sendTransaction",
"(",
"int",
"$",
"anonymity",
",",
"array",
"$",
"transfers",
",",
"int",
"$",
"fee",
",",
"array",
"$",
"addresses",
"=",
"null",
",",
"int",
"$",
"unlockTime",
"=",
"null",
",",
"string",
"$",
"extra",
"=",
"n... | Allows you to send transaction to one or several addresses. Also, it allows you to use a payment_id for a
transaction to a single address.
@param int $anonymity Privacy level (a discrete number from 1 to infinity).
6+ recommended. Required.
@param array $transfers Array that contains: address as string, amount as integer. Required.
@param int $fee Transaction fee. Required.
@param array|null $addresses Array of strings, where each string is an address to take the funds
from. Optional.
@param int|null $unlockTime Height of the block until which transaction is going to be locked for
spending. Optional.
@param string|null $extra String of variable length. Can contain A-Z, 0-9 characters. Optional.
@param string|null $paymentId Optional.
@param string|null $changeAddress Valid and existing in this container address. If container contains only
1 address, $changeAddress field can be left empty and the change is going to
be sent to this address. If $addresses field contains only 1 address,
$changeAddress can be left empty and the change is going to be sent to this
address. In the rest of the cases, $changeAddress field is mandatory and
must contain an address.
@return JsonResponse | [
"Allows",
"you",
"to",
"send",
"transaction",
"to",
"one",
"or",
"several",
"addresses",
".",
"Also",
"it",
"allows",
"you",
"to",
"use",
"a",
"payment_id",
"for",
"a",
"transaction",
"to",
"a",
"single",
"address",
"."
] | 0e4c37cc580db8f51174dc10afb845c1f278afea | https://github.com/timmcleod/turtlecoin-rpc-php/blob/0e4c37cc580db8f51174dc10afb845c1f278afea/src/TurtleCoin/TurtleService.php#L276-L299 | train |
timmcleod/turtlecoin-rpc-php | src/TurtleCoin/TurtleService.php | TurtleService.sendFusionTransaction | public function sendFusionTransaction(
int $threshold,
int $anonymity,
array $addresses = null,
string $destinationAddress = null
):JsonResponse {
$params = [
'threshold' => $threshold,
'anonymity' => $anonymity,
];
if (!is_null($addresses)) $params['addresses'] = $addresses;
if (!is_null($destinationAddress)) $params['destinationAddress'] = $destinationAddress;
return $this->rpcPost('sendFusionTransaction', $params);
} | php | public function sendFusionTransaction(
int $threshold,
int $anonymity,
array $addresses = null,
string $destinationAddress = null
):JsonResponse {
$params = [
'threshold' => $threshold,
'anonymity' => $anonymity,
];
if (!is_null($addresses)) $params['addresses'] = $addresses;
if (!is_null($destinationAddress)) $params['destinationAddress'] = $destinationAddress;
return $this->rpcPost('sendFusionTransaction', $params);
} | [
"public",
"function",
"sendFusionTransaction",
"(",
"int",
"$",
"threshold",
",",
"int",
"$",
"anonymity",
",",
"array",
"$",
"addresses",
"=",
"null",
",",
"string",
"$",
"destinationAddress",
"=",
"null",
")",
":",
"JsonResponse",
"{",
"$",
"params",
"=",
... | Allows you to send a fusion transaction, by taking funds from selected
addresses and transferring them to the destination address.
@param int $threshold Value that determines which outputs will be optimized. Only the outputs,
lesser than the threshold value, will be included into a fusion
transaction. Required.
@param int $anonymity Privacy level (a discrete number from 1 to infinity). Level 6 and higher
is recommended. Required.
@param array|null $addresses Array of strings, where each string is an address to take the funds from.
Optional.
@param string|null $destinationAddress An address that the optimized funds will be sent to. Valid and existing
in this container address. If container contains only 1 address,
$destinationAddress field can be left empty and the funds are going to be
sent to this address. If $addresses field contains only 1 address,
$destinationAddress can be left empty and the funds are going to be sent
to this address. In the rest of the cases, $destinationAddress field is
mandatory and must contain an address.
@return JsonResponse | [
"Allows",
"you",
"to",
"send",
"a",
"fusion",
"transaction",
"by",
"taking",
"funds",
"from",
"selected",
"addresses",
"and",
"transferring",
"them",
"to",
"the",
"destination",
"address",
"."
] | 0e4c37cc580db8f51174dc10afb845c1f278afea | https://github.com/timmcleod/turtlecoin-rpc-php/blob/0e4c37cc580db8f51174dc10afb845c1f278afea/src/TurtleCoin/TurtleService.php#L408-L423 | train |
timmcleod/turtlecoin-rpc-php | src/TurtleCoin/TurtleService.php | TurtleService.estimateFusion | public function estimateFusion(int $threshold, array $addresses = null):JsonResponse
{
$params = [
'threshold' => $threshold,
];
if (!is_null($addresses)) $params['addresses'] = $addresses;
return $this->rpcPost('sendFusionTransaction', $params);
} | php | public function estimateFusion(int $threshold, array $addresses = null):JsonResponse
{
$params = [
'threshold' => $threshold,
];
if (!is_null($addresses)) $params['addresses'] = $addresses;
return $this->rpcPost('sendFusionTransaction', $params);
} | [
"public",
"function",
"estimateFusion",
"(",
"int",
"$",
"threshold",
",",
"array",
"$",
"addresses",
"=",
"null",
")",
":",
"JsonResponse",
"{",
"$",
"params",
"=",
"[",
"'threshold'",
"=>",
"$",
"threshold",
",",
"]",
";",
"if",
"(",
"!",
"is_null",
... | Counts the number of unspent outputs of the specified addresses and returns how many of those outputs can be
optimized. This method is used to understand if a fusion transaction can be created. If fusionReadyCount returns
a value = 0, then a fusion transaction cannot be created.
@param int $threshold Value that determines which outputs will be optimized. Only the outputs, lesser
than the threshold value, will be included into a fusion transaction. Required.
@param array|null $addresses Array of strings, where each string is an address to take the funds from. Optional.
@return JsonResponse | [
"Counts",
"the",
"number",
"of",
"unspent",
"outputs",
"of",
"the",
"specified",
"addresses",
"and",
"returns",
"how",
"many",
"of",
"those",
"outputs",
"can",
"be",
"optimized",
".",
"This",
"method",
"is",
"used",
"to",
"understand",
"if",
"a",
"fusion",
... | 0e4c37cc580db8f51174dc10afb845c1f278afea | https://github.com/timmcleod/turtlecoin-rpc-php/blob/0e4c37cc580db8f51174dc10afb845c1f278afea/src/TurtleCoin/TurtleService.php#L435-L444 | train |
timmcleod/turtlecoin-rpc-php | src/TurtleCoin/TurtleService.php | TurtleService.createIntegratedAddress | public function createIntegratedAddress(string $address, string $paymentId):JsonResponse
{
$params = [
'address' => $address,
'paymentId' => $paymentId,
];
return $this->rpcPost('createIntegratedAddress', $params);
} | php | public function createIntegratedAddress(string $address, string $paymentId):JsonResponse
{
$params = [
'address' => $address,
'paymentId' => $paymentId,
];
return $this->rpcPost('createIntegratedAddress', $params);
} | [
"public",
"function",
"createIntegratedAddress",
"(",
"string",
"$",
"address",
",",
"string",
"$",
"paymentId",
")",
":",
"JsonResponse",
"{",
"$",
"params",
"=",
"[",
"'address'",
"=>",
"$",
"address",
",",
"'paymentId'",
"=>",
"$",
"paymentId",
",",
"]",
... | Combines an address and a paymentId into an 'integrated' address, which contains both in an encoded form.
This allows users to not have to supply a payment Id in their transfer, and hence cannot forget it.
@param string $address Required.
@param string $paymentId Required.
@return JsonResponse | [
"Combines",
"an",
"address",
"and",
"a",
"paymentId",
"into",
"an",
"integrated",
"address",
"which",
"contains",
"both",
"in",
"an",
"encoded",
"form",
".",
"This",
"allows",
"users",
"to",
"not",
"have",
"to",
"supply",
"a",
"payment",
"Id",
"in",
"their... | 0e4c37cc580db8f51174dc10afb845c1f278afea | https://github.com/timmcleod/turtlecoin-rpc-php/blob/0e4c37cc580db8f51174dc10afb845c1f278afea/src/TurtleCoin/TurtleService.php#L471-L479 | train |
krystal-framework/krystal.framework | src/Krystal/Paginate/Style/SlideStyle.php | SlideStyle.getPageNumbers | public function getPageNumbers(array $pages, $current)
{
$offset = $current * $this->step;
return array_slice($pages, $offset, $this->step);
} | php | public function getPageNumbers(array $pages, $current)
{
$offset = $current * $this->step;
return array_slice($pages, $offset, $this->step);
} | [
"public",
"function",
"getPageNumbers",
"(",
"array",
"$",
"pages",
",",
"$",
"current",
")",
"{",
"$",
"offset",
"=",
"$",
"current",
"*",
"$",
"this",
"->",
"step",
";",
"return",
"array_slice",
"(",
"$",
"pages",
",",
"$",
"offset",
",",
"$",
"thi... | Filter page numbers via current style adapter
@param array $page Array of page numbers
@param integer $current Current page number
@return array | [
"Filter",
"page",
"numbers",
"via",
"current",
"style",
"adapter"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Paginate/Style/SlideStyle.php#L41-L45 | train |
droath/project-x | src/Deploy/DeployBase.php | DeployBase.isVersionNumeric | protected function isVersionNumeric($version)
{
foreach (explode('.', $version) as $part) {
if (!is_numeric($part)) {
return false;
}
}
return true;
} | php | protected function isVersionNumeric($version)
{
foreach (explode('.', $version) as $part) {
if (!is_numeric($part)) {
return false;
}
}
return true;
} | [
"protected",
"function",
"isVersionNumeric",
"(",
"$",
"version",
")",
"{",
"foreach",
"(",
"explode",
"(",
"'.'",
",",
"$",
"version",
")",
"as",
"$",
"part",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"part",
")",
")",
"{",
"return",
"false"... | Compute if version is numeric.
@param $version
@return bool | [
"Compute",
"if",
"version",
"is",
"numeric",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Deploy/DeployBase.php#L93-L102 | train |
droath/project-x | src/Deploy/DeployBase.php | DeployBase.incrementVersion | protected function incrementVersion($version, $patch_limit = 20, $minor_limit = 50)
{
if (!$this->isVersionNumeric($version)) {
throw new DeploymentRuntimeException(
'Unable to increment semantic version.'
);
}
list($major, $minor, $patch) = explode('.', $version);
if ($patch < $patch_limit) {
++$patch;
} else if ($minor < $minor_limit) {
++$minor;
$patch = 0;
} else {
++$major;
$patch = 0;
$minor = 0;
}
return "{$major}.{$minor}.{$patch}";
} | php | protected function incrementVersion($version, $patch_limit = 20, $minor_limit = 50)
{
if (!$this->isVersionNumeric($version)) {
throw new DeploymentRuntimeException(
'Unable to increment semantic version.'
);
}
list($major, $minor, $patch) = explode('.', $version);
if ($patch < $patch_limit) {
++$patch;
} else if ($minor < $minor_limit) {
++$minor;
$patch = 0;
} else {
++$major;
$patch = 0;
$minor = 0;
}
return "{$major}.{$minor}.{$patch}";
} | [
"protected",
"function",
"incrementVersion",
"(",
"$",
"version",
",",
"$",
"patch_limit",
"=",
"20",
",",
"$",
"minor_limit",
"=",
"50",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isVersionNumeric",
"(",
"$",
"version",
")",
")",
"{",
"throw",
"new... | Increment the semantic version number.
@param $version
@param int $patch_limit
@param int $minor_limit
@return string | [
"Increment",
"the",
"semantic",
"version",
"number",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Deploy/DeployBase.php#L113-L134 | train |
krystal-framework/krystal.framework | src/Krystal/Image/Tool/ImageManager.php | ImageManager.getUploader | private function getUploader()
{
if (is_null($this->uploader)) {
$this->uploader = UploaderFactory::build($this->rootDir.$this->path, $this->plugins);
}
return $this->uploader;
} | php | private function getUploader()
{
if (is_null($this->uploader)) {
$this->uploader = UploaderFactory::build($this->rootDir.$this->path, $this->plugins);
}
return $this->uploader;
} | [
"private",
"function",
"getUploader",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"uploader",
")",
")",
"{",
"$",
"this",
"->",
"uploader",
"=",
"UploaderFactory",
"::",
"build",
"(",
"$",
"this",
"->",
"rootDir",
".",
"$",
"this",
"... | Returns prepared upload chain
@return \Krystal\Http\FileTransfer\UploadChain | [
"Returns",
"prepared",
"upload",
"chain"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Tool/ImageManager.php#L89-L96 | train |
krystal-framework/krystal.framework | src/Krystal/Image/Tool/ImageManager.php | ImageManager.getFileHandler | private function getFileHandler()
{
if (is_null($this->fileHandler)) {
$path = rtrim($this->path, '/');
$this->fileHandler = new FileHandler($this->rootDir.$path);
}
return $this->fileHandler;
} | php | private function getFileHandler()
{
if (is_null($this->fileHandler)) {
$path = rtrim($this->path, '/');
$this->fileHandler = new FileHandler($this->rootDir.$path);
}
return $this->fileHandler;
} | [
"private",
"function",
"getFileHandler",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"fileHandler",
")",
")",
"{",
"$",
"path",
"=",
"rtrim",
"(",
"$",
"this",
"->",
"path",
",",
"'/'",
")",
";",
"$",
"this",
"->",
"fileHandler",
"... | Returns prepared FileHandler instance
@return \Krystal\Image\FileHandler | [
"Returns",
"prepared",
"FileHandler",
"instance"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Tool/ImageManager.php#L103-L111 | train |
krystal-framework/krystal.framework | src/Krystal/Image/Tool/ImageManager.php | ImageManager.getImageBag | public function getImageBag()
{
if ($this->imageBag == null) {
$this->imageBag = new ImageBag(new LocationBuilder($this->rootDir, $this->rootUrl, $this->path));
}
return $this->imageBag;
} | php | public function getImageBag()
{
if ($this->imageBag == null) {
$this->imageBag = new ImageBag(new LocationBuilder($this->rootDir, $this->rootUrl, $this->path));
}
return $this->imageBag;
} | [
"public",
"function",
"getImageBag",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"imageBag",
"==",
"null",
")",
"{",
"$",
"this",
"->",
"imageBag",
"=",
"new",
"ImageBag",
"(",
"new",
"LocationBuilder",
"(",
"$",
"this",
"->",
"rootDir",
",",
"$",
"... | Returns prepared ImageBag instance
@return \Krystal\Image\ImageBag | [
"Returns",
"prepared",
"ImageBag",
"instance"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Image/Tool/ImageManager.php#L118-L125 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/Relations/ManyToMany.php | ManyToMany.merge | public function merge($masterPk, $alias, array $rows, $junction, $column, $table, $pk, $columns)
{
foreach ($rows as &$row) {
$value = $row[$masterPk];
$row[$alias] = $this->getSlaveData($table, $pk, $junction, $column, $value, $columns);
}
return $rows;
} | php | public function merge($masterPk, $alias, array $rows, $junction, $column, $table, $pk, $columns)
{
foreach ($rows as &$row) {
$value = $row[$masterPk];
$row[$alias] = $this->getSlaveData($table, $pk, $junction, $column, $value, $columns);
}
return $rows;
} | [
"public",
"function",
"merge",
"(",
"$",
"masterPk",
",",
"$",
"alias",
",",
"array",
"$",
"rows",
",",
"$",
"junction",
",",
"$",
"column",
",",
"$",
"table",
",",
"$",
"pk",
",",
"$",
"columns",
")",
"{",
"foreach",
"(",
"$",
"rows",
"as",
"&",... | Merges as many-to-many
@param string $masterPk Primary key name from the master table
@param string $alias Virtual column to be appended
@param string $junction Junction table name
@param string $column Column name from junction table to be selected
@param string $table Slave table name table
@param string $pk PK column name in slave table
@return array | [
"Merges",
"as",
"many",
"-",
"to",
"-",
"many"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Relations/ManyToMany.php#L27-L35 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/Relations/ManyToMany.php | ManyToMany.getSlaveData | private function getSlaveData($slaveTable, $slavePk, $junction, $column, $value, $columns)
{
$ids = $this->queryJunctionTable($junction, $column, $value, '*');
if (empty($ids)) {
return array();
} else {
// Query only in case there attached IDs found
return $this->queryTable($slaveTable, $slavePk, $ids, $columns);
}
} | php | private function getSlaveData($slaveTable, $slavePk, $junction, $column, $value, $columns)
{
$ids = $this->queryJunctionTable($junction, $column, $value, '*');
if (empty($ids)) {
return array();
} else {
// Query only in case there attached IDs found
return $this->queryTable($slaveTable, $slavePk, $ids, $columns);
}
} | [
"private",
"function",
"getSlaveData",
"(",
"$",
"slaveTable",
",",
"$",
"slavePk",
",",
"$",
"junction",
",",
"$",
"column",
",",
"$",
"value",
",",
"$",
"columns",
")",
"{",
"$",
"ids",
"=",
"$",
"this",
"->",
"queryJunctionTable",
"(",
"$",
"junctio... | Returns slave data from associated table
@param string $slaveTable Slave (second) table name
@param string $slavePk Primary column name in slave table
@param string $junction Junction table name
@param string $column Column in junction table to be queried
@param string $value Value for the column being queried
@param mixed $columns Columns to be selected in slave table
@return array | [
"Returns",
"slave",
"data",
"from",
"associated",
"table"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Relations/ManyToMany.php#L48-L58 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/Relations/ManyToMany.php | ManyToMany.leaveOnlyCurrent | private function leaveOnlyCurrent(array $row, $target)
{
$result = array();
foreach ($row as $column => $value) {
if ($column != $target) {
$result[$column] = $value;
}
}
return $result;
} | php | private function leaveOnlyCurrent(array $row, $target)
{
$result = array();
foreach ($row as $column => $value) {
if ($column != $target) {
$result[$column] = $value;
}
}
return $result;
} | [
"private",
"function",
"leaveOnlyCurrent",
"(",
"array",
"$",
"row",
",",
"$",
"target",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"row",
"as",
"$",
"column",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"column",
... | Removes all columns leaving only target one
@param array $row Current row
@param string $target Current column name
@return array | [
"Removes",
"all",
"columns",
"leaving",
"only",
"target",
"one"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Relations/ManyToMany.php#L86-L97 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/Relations/ManyToMany.php | ManyToMany.queryJunctionTable | private function queryJunctionTable($table, $column, $value, $columns)
{
$rows = $this->queryTable($table, $column, array($value), $columns);
foreach ($rows as &$row) {
$row = $this->leaveOnlyCurrent($row, $column);
}
return $this->extractValues($rows);
} | php | private function queryJunctionTable($table, $column, $value, $columns)
{
$rows = $this->queryTable($table, $column, array($value), $columns);
foreach ($rows as &$row) {
$row = $this->leaveOnlyCurrent($row, $column);
}
return $this->extractValues($rows);
} | [
"private",
"function",
"queryJunctionTable",
"(",
"$",
"table",
",",
"$",
"column",
",",
"$",
"value",
",",
"$",
"columns",
")",
"{",
"$",
"rows",
"=",
"$",
"this",
"->",
"queryTable",
"(",
"$",
"table",
",",
"$",
"column",
",",
"array",
"(",
"$",
... | Queries junction table
@param string $table Junction table name
@param string $column
@param string $value
@param mixed $columns Columns to be selected in slave table
@return array | [
"Queries",
"junction",
"table"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/Relations/ManyToMany.php#L108-L117 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/SqlDbConnectorFactory.php | SqlDbConnectorFactory.createPdo | private function createPdo($vendor, array $options)
{
// First of all, make sure it's possible to instantiate PDO instance by vendor name
if (isset($this->map[$vendor])) {
$connector = $this->map[$vendor];
$driver = new $connector();
$builder = new InstanceBuilder();
return $builder->build('\Krystal\Db\Sql\LazyPDO', $driver->getArgs($options));
} else {
throw new RuntimeException(sprintf('Unknown database vendor name supplied "%s"', $vendor));
}
} | php | private function createPdo($vendor, array $options)
{
// First of all, make sure it's possible to instantiate PDO instance by vendor name
if (isset($this->map[$vendor])) {
$connector = $this->map[$vendor];
$driver = new $connector();
$builder = new InstanceBuilder();
return $builder->build('\Krystal\Db\Sql\LazyPDO', $driver->getArgs($options));
} else {
throw new RuntimeException(sprintf('Unknown database vendor name supplied "%s"', $vendor));
}
} | [
"private",
"function",
"createPdo",
"(",
"$",
"vendor",
",",
"array",
"$",
"options",
")",
"{",
"// First of all, make sure it's possible to instantiate PDO instance by vendor name",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"map",
"[",
"$",
"vendor",
"]",
")",
... | Returns PDO instance
@param string $connector Driver name
@param array $options Options for connection, such as username and password
@throws \RuntimeException If unknown vendor name supplied
@return \Krystal\Db\Sql\LazyPDO | [
"Returns",
"PDO",
"instance"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/SqlDbConnectorFactory.php#L62-L76 | train |
krystal-framework/krystal.framework | src/Krystal/Db/Sql/SqlDbConnectorFactory.php | SqlDbConnectorFactory.build | public function build($vendor, array $options)
{
return new Db(new QueryBuilder(), $this->createPdo($vendor, $options), $this->paginator, new QueryLogger());
} | php | public function build($vendor, array $options)
{
return new Db(new QueryBuilder(), $this->createPdo($vendor, $options), $this->paginator, new QueryLogger());
} | [
"public",
"function",
"build",
"(",
"$",
"vendor",
",",
"array",
"$",
"options",
")",
"{",
"return",
"new",
"Db",
"(",
"new",
"QueryBuilder",
"(",
")",
",",
"$",
"this",
"->",
"createPdo",
"(",
"$",
"vendor",
",",
"$",
"options",
")",
",",
"$",
"th... | Builds database service instance
@param string $vendor Database vendor name
@param array $options Options for connection, such as username and password
@return \Krystal\Db\Sql\DbInterface | [
"Builds",
"database",
"service",
"instance"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Db/Sql/SqlDbConnectorFactory.php#L85-L88 | train |
phpinnacle/domain | src/Saga.php | Saga.transition | public function transition($event): void
{
$this->apply($event, self::HANDLE_PREFIX);
$this->version++;
} | php | public function transition($event): void
{
$this->apply($event, self::HANDLE_PREFIX);
$this->version++;
} | [
"public",
"function",
"transition",
"(",
"$",
"event",
")",
":",
"void",
"{",
"$",
"this",
"->",
"apply",
"(",
"$",
"event",
",",
"self",
"::",
"HANDLE_PREFIX",
")",
";",
"$",
"this",
"->",
"version",
"++",
";",
"}"
] | Transition saga to new state
Store event data internally and
try to call corresponding `when` method
@param object $event
@return void
@throws Exception\InvalidEvent
@throws Exception\UndefinedTransition | [
"Transition",
"saga",
"to",
"new",
"state"
] | 1b49ca1b706b67a10f1a848ca6aa3117f3561429 | https://github.com/phpinnacle/domain/blob/1b49ca1b706b67a10f1a848ca6aa3117f3561429/src/Saga.php#L75-L80 | train |
wpfulcrum/extender | src/Extender/WP/FrontPageDisplays.php | FrontPageDisplays.getOption | protected static function getOption($optionName, $castToInt = true)
{
$optionValue = isset(self::$options[$optionName])
? self::$options[$optionName]
: get_option($optionName);
return $castToInt === true ? (int) $optionValue : $optionValue;
} | php | protected static function getOption($optionName, $castToInt = true)
{
$optionValue = isset(self::$options[$optionName])
? self::$options[$optionName]
: get_option($optionName);
return $castToInt === true ? (int) $optionValue : $optionValue;
} | [
"protected",
"static",
"function",
"getOption",
"(",
"$",
"optionName",
",",
"$",
"castToInt",
"=",
"true",
")",
"{",
"$",
"optionValue",
"=",
"isset",
"(",
"self",
"::",
"$",
"options",
"[",
"$",
"optionName",
"]",
")",
"?",
"self",
"::",
"$",
"option... | Get the specified option.
@since 3.1.0
@param string $optionName Key for the option.
@param bool $castToInt When true, cast the option's value to integer before returning.
@return mixed | [
"Get",
"the",
"specified",
"option",
"."
] | 96c9170d94959c0513c1d487bae2a67de6a20348 | https://github.com/wpfulcrum/extender/blob/96c9170d94959c0513c1d487bae2a67de6a20348/src/Extender/WP/FrontPageDisplays.php#L165-L172 | train |
droath/project-x | src/Deploy/GitDeploy.php | GitDeploy.hasGitBranch | protected function hasGitBranch($branch_name)
{
$task = $this->getGitBuildStack()
->exec("rev-parse -q --verify {$branch_name}");
$result = $this->runSilentCommand($task);
return !empty($result->getMessage());
} | php | protected function hasGitBranch($branch_name)
{
$task = $this->getGitBuildStack()
->exec("rev-parse -q --verify {$branch_name}");
$result = $this->runSilentCommand($task);
return !empty($result->getMessage());
} | [
"protected",
"function",
"hasGitBranch",
"(",
"$",
"branch_name",
")",
"{",
"$",
"task",
"=",
"$",
"this",
"->",
"getGitBuildStack",
"(",
")",
"->",
"exec",
"(",
"\"rev-parse -q --verify {$branch_name}\"",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"ru... | Has git branch.
@param $branch_name
@return bool | [
"Has",
"git",
"branch",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Deploy/GitDeploy.php#L65-L73 | train |
droath/project-x | src/Deploy/GitDeploy.php | GitDeploy.hasGitTrackedFilesChanged | protected function hasGitTrackedFilesChanged()
{
$task = $this->getGitBuildStack()
->exec("status --untracked-files=no --porcelain");
/** @var Result $result */
$result = $this->runSilentCommand($task);
$changes = array_filter(
explode("\n", $result->getMessage())
);
return (bool) count($changes) != 0;
} | php | protected function hasGitTrackedFilesChanged()
{
$task = $this->getGitBuildStack()
->exec("status --untracked-files=no --porcelain");
/** @var Result $result */
$result = $this->runSilentCommand($task);
$changes = array_filter(
explode("\n", $result->getMessage())
);
return (bool) count($changes) != 0;
} | [
"protected",
"function",
"hasGitTrackedFilesChanged",
"(",
")",
"{",
"$",
"task",
"=",
"$",
"this",
"->",
"getGitBuildStack",
"(",
")",
"->",
"exec",
"(",
"\"status --untracked-files=no --porcelain\"",
")",
";",
"/** @var Result $result */",
"$",
"result",
"=",
"$",... | Has git tracked files changed.
@return bool | [
"Has",
"git",
"tracked",
"files",
"changed",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Deploy/GitDeploy.php#L80-L93 | train |
droath/project-x | src/Deploy/GitDeploy.php | GitDeploy.askBuildVersion | protected function askBuildVersion()
{
$last_version = $this->gitLatestVersionTag();
$next_version = $this->incrementVersion($last_version);
$question = (new Question("Set build version [{$next_version}]: ", $next_version))
->setValidator(function ($input_version) use ($last_version) {
$input_version = trim($input_version);
if (version_compare($input_version, $last_version, '==')) {
throw new \RuntimeException(
'Build version has already been used.'
);
}
if (!$this->isVersionNumeric($input_version)) {
throw new \RuntimeException(
'Build version is not numeric.'
);
}
return $input_version;
});
return $this->doAsk($question);
} | php | protected function askBuildVersion()
{
$last_version = $this->gitLatestVersionTag();
$next_version = $this->incrementVersion($last_version);
$question = (new Question("Set build version [{$next_version}]: ", $next_version))
->setValidator(function ($input_version) use ($last_version) {
$input_version = trim($input_version);
if (version_compare($input_version, $last_version, '==')) {
throw new \RuntimeException(
'Build version has already been used.'
);
}
if (!$this->isVersionNumeric($input_version)) {
throw new \RuntimeException(
'Build version is not numeric.'
);
}
return $input_version;
});
return $this->doAsk($question);
} | [
"protected",
"function",
"askBuildVersion",
"(",
")",
"{",
"$",
"last_version",
"=",
"$",
"this",
"->",
"gitLatestVersionTag",
"(",
")",
";",
"$",
"next_version",
"=",
"$",
"this",
"->",
"incrementVersion",
"(",
"$",
"last_version",
")",
";",
"$",
"question"... | Ask build version.
@return string | [
"Ask",
"build",
"version",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Deploy/GitDeploy.php#L100-L125 | train |
droath/project-x | src/Deploy/GitDeploy.php | GitDeploy.runGitInitAdd | protected function runGitInitAdd()
{
$repo = $this->gitRepo();
$origin = $this->gitOrigin();
$branch = $this->gitBranch();
$stack = $this->getGitBuildStack();
if (!$this->buildHasGit()) {
$stack
->exec('init')
->exec("remote add {$origin} {$repo}");
if ($this->gitRemoteBranchExist()) {
$stack
->exec('fetch --all')
->exec("reset --soft {$origin}/{$branch}");
}
} else {
$stack
->checkout($branch)
->pull($origin, $branch);
}
$result = $stack
->add('.')
->run();
$this->validateTaskResult($result);
return $this;
} | php | protected function runGitInitAdd()
{
$repo = $this->gitRepo();
$origin = $this->gitOrigin();
$branch = $this->gitBranch();
$stack = $this->getGitBuildStack();
if (!$this->buildHasGit()) {
$stack
->exec('init')
->exec("remote add {$origin} {$repo}");
if ($this->gitRemoteBranchExist()) {
$stack
->exec('fetch --all')
->exec("reset --soft {$origin}/{$branch}");
}
} else {
$stack
->checkout($branch)
->pull($origin, $branch);
}
$result = $stack
->add('.')
->run();
$this->validateTaskResult($result);
return $this;
} | [
"protected",
"function",
"runGitInitAdd",
"(",
")",
"{",
"$",
"repo",
"=",
"$",
"this",
"->",
"gitRepo",
"(",
")",
";",
"$",
"origin",
"=",
"$",
"this",
"->",
"gitOrigin",
"(",
")",
";",
"$",
"branch",
"=",
"$",
"this",
"->",
"gitBranch",
"(",
")",... | Run git initialize add.
@return self | [
"Run",
"git",
"initialize",
"add",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Deploy/GitDeploy.php#L132-L161 | train |
droath/project-x | src/Deploy/GitDeploy.php | GitDeploy.gitRemoteBranchExist | protected function gitRemoteBranchExist()
{
$task = $this->getGitBuildStack()
->exec("ls-remote --exit-code --heads {$this->gitRepo()} {$this->gitBranch()}");
/** @var Result $result */
$result = $this->runSilentCommand($task);
return $result->getExitCode() === 0;
} | php | protected function gitRemoteBranchExist()
{
$task = $this->getGitBuildStack()
->exec("ls-remote --exit-code --heads {$this->gitRepo()} {$this->gitBranch()}");
/** @var Result $result */
$result = $this->runSilentCommand($task);
return $result->getExitCode() === 0;
} | [
"protected",
"function",
"gitRemoteBranchExist",
"(",
")",
"{",
"$",
"task",
"=",
"$",
"this",
"->",
"getGitBuildStack",
"(",
")",
"->",
"exec",
"(",
"\"ls-remote --exit-code --heads {$this->gitRepo()} {$this->gitBranch()}\"",
")",
";",
"/** @var Result $result */",
"$",
... | Deployment git remote branch exist.
@return bool | [
"Deployment",
"git",
"remote",
"branch",
"exist",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Deploy/GitDeploy.php#L186-L195 | train |
droath/project-x | src/Deploy/GitDeploy.php | GitDeploy.gitRepo | protected function gitRepo($throw_exception = true)
{
$options = $this->getOptions();
$repo = isset($options['repo_url'])
? $options['repo_url']
: null;
if (!isset($repo) && $throw_exception) {
throw new DeploymentRuntimeException(
'Missing Git repository in deploy options.'
);
}
return $repo;
} | php | protected function gitRepo($throw_exception = true)
{
$options = $this->getOptions();
$repo = isset($options['repo_url'])
? $options['repo_url']
: null;
if (!isset($repo) && $throw_exception) {
throw new DeploymentRuntimeException(
'Missing Git repository in deploy options.'
);
}
return $repo;
} | [
"protected",
"function",
"gitRepo",
"(",
"$",
"throw_exception",
"=",
"true",
")",
"{",
"$",
"options",
"=",
"$",
"this",
"->",
"getOptions",
"(",
")",
";",
"$",
"repo",
"=",
"isset",
"(",
"$",
"options",
"[",
"'repo_url'",
"]",
")",
"?",
"$",
"optio... | Deployment git build repo.
@param bool $throw_exception
@return string | [
"Deployment",
"git",
"build",
"repo",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Deploy/GitDeploy.php#L218-L233 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.verifySelectQuery | protected function verifySelectQuery(SelectQuery $query) {
$this->verifyScope($query);
$this->verifyRequiredFields($query);
$this->verifyFields($query);
$this->verifyLimits($query);
} | php | protected function verifySelectQuery(SelectQuery $query) {
$this->verifyScope($query);
$this->verifyRequiredFields($query);
$this->verifyFields($query);
$this->verifyLimits($query);
} | [
"protected",
"function",
"verifySelectQuery",
"(",
"SelectQuery",
"$",
"query",
")",
"{",
"$",
"this",
"->",
"verifyScope",
"(",
"$",
"query",
")",
";",
"$",
"this",
"->",
"verifyRequiredFields",
"(",
"$",
"query",
")",
";",
"$",
"this",
"->",
"verifyField... | Verifica la validez del query a ejecutar
@param SelectQuery $query consulta a ejecutar | [
"Verifica",
"la",
"validez",
"del",
"query",
"a",
"ejecutar"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L155-L160 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.verifyRequiredFields | protected function verifyRequiredFields(SelectQuery $query, array $requiredFields = null) {
if ($requiredFields == null) {
$requiredFields = $this->getRequiredFields();
}
if (!empty($requiredFields)) {
foreach ($requiredFields as $requiredField) {
if (empty($query->getWhereCondition($requiredField, null, false, true))) {
throw new RuntimeException("Condition required: $requiredField");
}
}
}
} | php | protected function verifyRequiredFields(SelectQuery $query, array $requiredFields = null) {
if ($requiredFields == null) {
$requiredFields = $this->getRequiredFields();
}
if (!empty($requiredFields)) {
foreach ($requiredFields as $requiredField) {
if (empty($query->getWhereCondition($requiredField, null, false, true))) {
throw new RuntimeException("Condition required: $requiredField");
}
}
}
} | [
"protected",
"function",
"verifyRequiredFields",
"(",
"SelectQuery",
"$",
"query",
",",
"array",
"$",
"requiredFields",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"requiredFields",
"==",
"null",
")",
"{",
"$",
"requiredFields",
"=",
"$",
"this",
"->",
"getRequir... | Valida que el query contenga los campos requeridos
@param SelectQuery $query
@param array|null $requiredFields | [
"Valida",
"que",
"el",
"query",
"contenga",
"los",
"campos",
"requeridos"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L177-L188 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.verifyFields | protected function verifyFields(SelectQuery $query) {
$foundField = null;
if ($this->hasOtherFields($query, null, false, $foundField)) {
throw new RuntimeException("Invalid fields on query : $foundField");
}
} | php | protected function verifyFields(SelectQuery $query) {
$foundField = null;
if ($this->hasOtherFields($query, null, false, $foundField)) {
throw new RuntimeException("Invalid fields on query : $foundField");
}
} | [
"protected",
"function",
"verifyFields",
"(",
"SelectQuery",
"$",
"query",
")",
"{",
"$",
"foundField",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"hasOtherFields",
"(",
"$",
"query",
",",
"null",
",",
"false",
",",
"$",
"foundField",
")",
")",
"{... | Valida que el query no invoque campos no definidos en el recurso y no tenga joins
@param SelectQuery $query | [
"Valida",
"que",
"el",
"query",
"no",
"invoque",
"campos",
"no",
"definidos",
"en",
"el",
"recurso",
"y",
"no",
"tenga",
"joins"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L194-L199 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.verifyLimits | protected function verifyLimits (SelectQuery $query) {
if (empty($query->getLimit())) {
$query->limit($this->getDefaultLimit());
} else if ($query->getLimit() > $this->getMaxLimit()) {
$query->limit($this->getMaxLimit());
}
} | php | protected function verifyLimits (SelectQuery $query) {
if (empty($query->getLimit())) {
$query->limit($this->getDefaultLimit());
} else if ($query->getLimit() > $this->getMaxLimit()) {
$query->limit($this->getMaxLimit());
}
} | [
"protected",
"function",
"verifyLimits",
"(",
"SelectQuery",
"$",
"query",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"query",
"->",
"getLimit",
"(",
")",
")",
")",
"{",
"$",
"query",
"->",
"limit",
"(",
"$",
"this",
"->",
"getDefaultLimit",
"(",
")",
"... | Verifica que se hayan establecido los limites de la consulta
@param SelectQuery $query | [
"Verifica",
"que",
"se",
"hayan",
"establecido",
"los",
"limites",
"de",
"la",
"consulta"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L205-L212 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.renameSource | private function renameSource(Query $query, string $tableName = null):string {
if($tableName == null) {
$tableName = $this->getTableName();
}
$previusSource = $query->getTable();
if(!empty($tableName)) {
$query->table($tableName);
}
return $previusSource;
} | php | private function renameSource(Query $query, string $tableName = null):string {
if($tableName == null) {
$tableName = $this->getTableName();
}
$previusSource = $query->getTable();
if(!empty($tableName)) {
$query->table($tableName);
}
return $previusSource;
} | [
"private",
"function",
"renameSource",
"(",
"Query",
"$",
"query",
",",
"string",
"$",
"tableName",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"$",
"tableName",
"==",
"null",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"getTableName",
"("... | Renombra la fuente de datos por el nombre de la tabla indicada
@param Query $query
@param string $tableName
@return string | [
"Renombra",
"la",
"fuente",
"de",
"datos",
"por",
"el",
"nombre",
"de",
"la",
"tabla",
"indicada"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L332-L341 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.renameConditionFields | private function renameConditionFields(ConditionGroup $conditionGroup, $namesMap = null, $originalSource = null, $newSource = null) {
if (!$conditionGroup->isEmpty()) {
if($namesMap == null) {
$namesMap = $this->getColumnNames();
}
$conditions = &$conditionGroup->getConditions();
foreach ($conditions as $key=>&$condition) {
switch ($condition->type) {
case ConditionType::GROUP:
$this->renameConditionFields($condition->group, $namesMap, $originalSource, $newSource);
break;
case ConditionType::BASIC:
$newName = $this->getFieldNewName($condition->field, $namesMap, $originalSource, $newSource);
if($newName != null) {
$condition->field = $newName;
}
if ($condition->operator == ConditionOperator::EQUALS_FIELD) {
$newName = $this->getFieldNewName($condition->value, $namesMap, $originalSource, $newSource);
if($newName != null) {
$condition->value = $newName;
}
}
break;
case ConditionType::RAW:
foreach ($namesMap as $fieldName => $dbName) {
$condition->sql = preg_replace('/\b' . $fieldName . '(?=$|\s)/', $dbName, $condition->sql);
$condition->sql = preg_replace('/\b' . $originalSource.$fieldName . '(?=$|\s)/', "$newSource.$dbName", $condition->sql);
}
break;
}
}
}
} | php | private function renameConditionFields(ConditionGroup $conditionGroup, $namesMap = null, $originalSource = null, $newSource = null) {
if (!$conditionGroup->isEmpty()) {
if($namesMap == null) {
$namesMap = $this->getColumnNames();
}
$conditions = &$conditionGroup->getConditions();
foreach ($conditions as $key=>&$condition) {
switch ($condition->type) {
case ConditionType::GROUP:
$this->renameConditionFields($condition->group, $namesMap, $originalSource, $newSource);
break;
case ConditionType::BASIC:
$newName = $this->getFieldNewName($condition->field, $namesMap, $originalSource, $newSource);
if($newName != null) {
$condition->field = $newName;
}
if ($condition->operator == ConditionOperator::EQUALS_FIELD) {
$newName = $this->getFieldNewName($condition->value, $namesMap, $originalSource, $newSource);
if($newName != null) {
$condition->value = $newName;
}
}
break;
case ConditionType::RAW:
foreach ($namesMap as $fieldName => $dbName) {
$condition->sql = preg_replace('/\b' . $fieldName . '(?=$|\s)/', $dbName, $condition->sql);
$condition->sql = preg_replace('/\b' . $originalSource.$fieldName . '(?=$|\s)/', "$newSource.$dbName", $condition->sql);
}
break;
}
}
}
} | [
"private",
"function",
"renameConditionFields",
"(",
"ConditionGroup",
"$",
"conditionGroup",
",",
"$",
"namesMap",
"=",
"null",
",",
"$",
"originalSource",
"=",
"null",
",",
"$",
"newSource",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"conditionGroup",
"->... | Renombra los campos involucrados en condiciones where segun el mapa indicado
@param ConditionGroup $conditionGroup
@param $namesMap
@param null $originalSource
@param null $newSource | [
"Renombra",
"los",
"campos",
"involucrados",
"en",
"condiciones",
"where",
"segun",
"el",
"mapa",
"indicado"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L350-L382 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.renameSetFields | private function renameSetFields(Query $query, $columnNames, $originalSource, $newSource) {
$renamedFields = [];
foreach ($query->getFields() as $field => $value) {
$newName = $this->getFieldNewName($field, $columnNames, $originalSource, $newSource);
if($newName != null) {
$renamedFields[$newName] = $value;
}
}
$query->fields($renamedFields);
} | php | private function renameSetFields(Query $query, $columnNames, $originalSource, $newSource) {
$renamedFields = [];
foreach ($query->getFields() as $field => $value) {
$newName = $this->getFieldNewName($field, $columnNames, $originalSource, $newSource);
if($newName != null) {
$renamedFields[$newName] = $value;
}
}
$query->fields($renamedFields);
} | [
"private",
"function",
"renameSetFields",
"(",
"Query",
"$",
"query",
",",
"$",
"columnNames",
",",
"$",
"originalSource",
",",
"$",
"newSource",
")",
"{",
"$",
"renamedFields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"query",
"->",
"getFields",
"(",
")... | Renombra los campos set de la sentencia update
@param Query $query
@param $columnNames
@param $originalSource
@param $newSource | [
"Renombra",
"los",
"campos",
"set",
"de",
"la",
"sentencia",
"update"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L391-L400 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.fieldInList | protected function fieldInList($field, array $list) : bool {
$result = in_array($field, $list);
if (!$result && !$this->isFieldCaseSensitive()) {
$result = in_array(strtolower($field), $list);
}
return $result;
} | php | protected function fieldInList($field, array $list) : bool {
$result = in_array($field, $list);
if (!$result && !$this->isFieldCaseSensitive()) {
$result = in_array(strtolower($field), $list);
}
return $result;
} | [
"protected",
"function",
"fieldInList",
"(",
"$",
"field",
",",
"array",
"$",
"list",
")",
":",
"bool",
"{",
"$",
"result",
"=",
"in_array",
"(",
"$",
"field",
",",
"$",
"list",
")",
";",
"if",
"(",
"!",
"$",
"result",
"&&",
"!",
"$",
"this",
"->... | Indica si el field indicado se encuentra en la lista indicada como segundo argumento,
considerando que se indique caseSensitive en false
@param $field
@param $list
@return bool true si field es encontrado en list, false en caso contrario | [
"Indica",
"si",
"el",
"field",
"indicado",
"se",
"encuentra",
"en",
"la",
"lista",
"indicada",
"como",
"segundo",
"argumento",
"considerando",
"que",
"se",
"indique",
"caseSensitive",
"en",
"false"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L409-L415 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.fieldInMap | private function fieldInMap($field, array $map) {
$result = null;
if (array_key_exists($field, $map)) {
$result = $map[$field];
} else if (!$this->isFieldCaseSensitive()) {
$field = strtolower($field);
//$map = array_map('strtolower', $map);
if (array_key_exists($field, $map)) {
$result = $map[$field];
}
}
return $result;
} | php | private function fieldInMap($field, array $map) {
$result = null;
if (array_key_exists($field, $map)) {
$result = $map[$field];
} else if (!$this->isFieldCaseSensitive()) {
$field = strtolower($field);
//$map = array_map('strtolower', $map);
if (array_key_exists($field, $map)) {
$result = $map[$field];
}
}
return $result;
} | [
"private",
"function",
"fieldInMap",
"(",
"$",
"field",
",",
"array",
"$",
"map",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"field",
",",
"$",
"map",
")",
")",
"{",
"$",
"result",
"=",
"$",
"map",
"[",
"$... | Retorna el valor correspondiente al field indicado segun el map indicado como segundo argumento,
considerando que se indique caseSensitive en false
@param $field
@param array $map
@return mixed null si no hay entrada en el mapa para el field, el valor correspondiente si lo hay. | [
"Retorna",
"el",
"valor",
"correspondiente",
"al",
"field",
"indicado",
"segun",
"el",
"map",
"indicado",
"como",
"segundo",
"argumento",
"considerando",
"que",
"se",
"indique",
"caseSensitive",
"en",
"false"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L424-L437 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.getFieldNewName | private function getFieldNewName($field, $namesMap = null, $originalSource = null, $newSource = null) {
$newName = null;
if ($namesMap == null) {
$namesMap = $this->getColumnNames();
}
//primero busca una entrada en el mapa para el nombre del campo indicado
$newName = $this->fieldInMap($field, $namesMap);
if (empty($newName) && $this->fieldInList($field, $namesMap)) {
$newName = $field;
}
if (empty($newName)) {
//si el field indicado comienza con nombre de tabla seguido de punto
$fieldPos = strpos($field, "$originalSource.");
if($fieldPos === 0) {
$searchField = substr($field, strlen($originalSource)+1);
$newName = $this->fieldInMap($searchField, $namesMap);
if(!empty($newName) && !empty($newSource) && strpos($newName, '.') === false) {
$newName = "$newSource.$newName";
}
}
}
if (empty($newName)) {
if (preg_match ( "/\w+\s*\(\s*(\w+)\s*\)/", $field, $matches)) {
$newName = str_replace($matches[1], $this->getFieldNewName($matches[1]), $matches[0]);
}
}
return empty($newName) ? null : $newName;
} | php | private function getFieldNewName($field, $namesMap = null, $originalSource = null, $newSource = null) {
$newName = null;
if ($namesMap == null) {
$namesMap = $this->getColumnNames();
}
//primero busca una entrada en el mapa para el nombre del campo indicado
$newName = $this->fieldInMap($field, $namesMap);
if (empty($newName) && $this->fieldInList($field, $namesMap)) {
$newName = $field;
}
if (empty($newName)) {
//si el field indicado comienza con nombre de tabla seguido de punto
$fieldPos = strpos($field, "$originalSource.");
if($fieldPos === 0) {
$searchField = substr($field, strlen($originalSource)+1);
$newName = $this->fieldInMap($searchField, $namesMap);
if(!empty($newName) && !empty($newSource) && strpos($newName, '.') === false) {
$newName = "$newSource.$newName";
}
}
}
if (empty($newName)) {
if (preg_match ( "/\w+\s*\(\s*(\w+)\s*\)/", $field, $matches)) {
$newName = str_replace($matches[1], $this->getFieldNewName($matches[1]), $matches[0]);
}
}
return empty($newName) ? null : $newName;
} | [
"private",
"function",
"getFieldNewName",
"(",
"$",
"field",
",",
"$",
"namesMap",
"=",
"null",
",",
"$",
"originalSource",
"=",
"null",
",",
"$",
"newSource",
"=",
"null",
")",
"{",
"$",
"newName",
"=",
"null",
";",
"if",
"(",
"$",
"namesMap",
"==",
... | Busca el posible remplazo de nombre
@param $field
@param $namesMap
@param mixed $originalSource
@param mixed $newSource
@return mixed|string | [
"Busca",
"el",
"posible",
"remplazo",
"de",
"nombre"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L447-L475 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.renameSelectFields | private function renameSelectFields(SelectQuery $query, $namesMap = null, $originalSource = null) {
if($namesMap == null) {
$namesMap = $this->getColumnNames();
}
$selectFields = &$query->getSelectFields();
//en el caso que no se indique nada en el select, pongo los del mapa
if (empty($selectFields)) {
foreach ($namesMap as $aliasName => $columnName) {
if (is_numeric($aliasName)) {
$selectItem = $columnName;
} else if (empty($columnName) || $aliasName === $columnName) {
$selectItem = $aliasName;
} else {
$selectItem = [$columnName, $aliasName];
}
$query->select($selectItem);
}
} else {
//primer for para busqueda de * o tabla.* y agregado de campos
$newSelectFields = [];
foreach ($selectFields as $selectField) {
$aliasName = $selectField instanceof stdClass ? trim($selectField->expression) : trim($selectField);
if ($aliasName == '*') {
foreach ($namesMap as $aliasName => $columnName) {
if (is_numeric($aliasName)) {
$newSelectFields[$columnName] = $columnName;
} else {
$newSelectFields[$aliasName] = $aliasName;
}
}
continue;
} else if (!empty($originalSource) && $aliasName == "$originalSource.*") {
foreach ($namesMap as $aliasName => $columnName) {
if (is_numeric($aliasName)) {
$newSelectFields["$originalSource.$columnName"] = "$originalSource.$columnName";
} else {
$newSelectFields["$originalSource.$aliasName"] = "$originalSource.$aliasName";
}
}
continue;
} else {
$newSelectFields[$aliasName] = $selectField;
}
}
if (!empty($newSelectFields)) {
$query->selectFields(array_values($newSelectFields));
}
//segundo for para reemplazo de nombres
foreach ($selectFields as &$field) {
if ($field instanceof stdClass) {
$aliasName = $field->alias;
$columnName = $this->getFieldNewName($field->expression, $namesMap, $originalSource, $query->getTable());
} else {
$aliasName = $field;
$columnName = $this->getFieldNewName($field, $namesMap, $originalSource, $query->getTable());
}
if($columnName != null) {
if ($columnName == $aliasName) {
$field = $columnName;
} else {
$field = new stdClass();
$field->expression = $columnName;
$field->alias = $aliasName;
}
}
}
}
} | php | private function renameSelectFields(SelectQuery $query, $namesMap = null, $originalSource = null) {
if($namesMap == null) {
$namesMap = $this->getColumnNames();
}
$selectFields = &$query->getSelectFields();
//en el caso que no se indique nada en el select, pongo los del mapa
if (empty($selectFields)) {
foreach ($namesMap as $aliasName => $columnName) {
if (is_numeric($aliasName)) {
$selectItem = $columnName;
} else if (empty($columnName) || $aliasName === $columnName) {
$selectItem = $aliasName;
} else {
$selectItem = [$columnName, $aliasName];
}
$query->select($selectItem);
}
} else {
//primer for para busqueda de * o tabla.* y agregado de campos
$newSelectFields = [];
foreach ($selectFields as $selectField) {
$aliasName = $selectField instanceof stdClass ? trim($selectField->expression) : trim($selectField);
if ($aliasName == '*') {
foreach ($namesMap as $aliasName => $columnName) {
if (is_numeric($aliasName)) {
$newSelectFields[$columnName] = $columnName;
} else {
$newSelectFields[$aliasName] = $aliasName;
}
}
continue;
} else if (!empty($originalSource) && $aliasName == "$originalSource.*") {
foreach ($namesMap as $aliasName => $columnName) {
if (is_numeric($aliasName)) {
$newSelectFields["$originalSource.$columnName"] = "$originalSource.$columnName";
} else {
$newSelectFields["$originalSource.$aliasName"] = "$originalSource.$aliasName";
}
}
continue;
} else {
$newSelectFields[$aliasName] = $selectField;
}
}
if (!empty($newSelectFields)) {
$query->selectFields(array_values($newSelectFields));
}
//segundo for para reemplazo de nombres
foreach ($selectFields as &$field) {
if ($field instanceof stdClass) {
$aliasName = $field->alias;
$columnName = $this->getFieldNewName($field->expression, $namesMap, $originalSource, $query->getTable());
} else {
$aliasName = $field;
$columnName = $this->getFieldNewName($field, $namesMap, $originalSource, $query->getTable());
}
if($columnName != null) {
if ($columnName == $aliasName) {
$field = $columnName;
} else {
$field = new stdClass();
$field->expression = $columnName;
$field->alias = $aliasName;
}
}
}
}
} | [
"private",
"function",
"renameSelectFields",
"(",
"SelectQuery",
"$",
"query",
",",
"$",
"namesMap",
"=",
"null",
",",
"$",
"originalSource",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"namesMap",
"==",
"null",
")",
"{",
"$",
"namesMap",
"=",
"$",
"this",
... | Modifica el select con los alias correspondientes
Nota: si la tabla tiene algunos campos a cambiar y otros no, en el mapa debemos poner todos para el caso de select *.
Es por ello que sumo una validacion para que en el caso que el mapa contenga una entrada donde clave y valor
son iguales no ponga el alias, o bien que tenga solo valor, en ese caso la clave es un autonumerico y por eso
pregunto por is_numeric
@param SelectQuery $query
@param $namesMap
@param mixed $originalSource | [
"Modifica",
"el",
"select",
"con",
"los",
"alias",
"correspondientes"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L488-L557 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.renameOrderByFields | private function renameOrderByFields(SelectQuery $query, $namesMap = null, $originalSource = null) {
if($namesMap == null) {
$namesMap = $this->getColumnNames();
}
$orderByFields = &$query->getOrderByFields();
if (!empty($orderByFields)) {
foreach ($orderByFields as &$orderByField) {
$newName = $this->getFieldNewName($orderByField->field, $namesMap, $originalSource, $query->getTable());
if($newName != null) {
$orderByField->field = $newName;
}
}
}
} | php | private function renameOrderByFields(SelectQuery $query, $namesMap = null, $originalSource = null) {
if($namesMap == null) {
$namesMap = $this->getColumnNames();
}
$orderByFields = &$query->getOrderByFields();
if (!empty($orderByFields)) {
foreach ($orderByFields as &$orderByField) {
$newName = $this->getFieldNewName($orderByField->field, $namesMap, $originalSource, $query->getTable());
if($newName != null) {
$orderByField->field = $newName;
}
}
}
} | [
"private",
"function",
"renameOrderByFields",
"(",
"SelectQuery",
"$",
"query",
",",
"$",
"namesMap",
"=",
"null",
",",
"$",
"originalSource",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"namesMap",
"==",
"null",
")",
"{",
"$",
"namesMap",
"=",
"$",
"this",
... | Renombra los campos involucrados en ordenamiento segun el mapa indicado
@param SelectQuery $query
@param $namesMap
@param mixed $originalSource | [
"Renombra",
"los",
"campos",
"involucrados",
"en",
"ordenamiento",
"segun",
"el",
"mapa",
"indicado"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L565-L578 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.renameGroupByFields | private function renameGroupByFields(SelectQuery $query, $namesMap = null, $originalSource = null) {
if($namesMap == null) {
$namesMap = $this->getColumnNames();
}
$groupByFields = &$query->getGroupByFields();
if (!empty($groupByFields)) {
$source = $query->getTable();
$newGroupByFields = [];
foreach ($groupByFields as $field) {
if ($field == '*') {
foreach ($namesMap as $aliasName => $columnName) {
$newGroupByFields[$columnName] = 1;
}
continue;
} else if (!empty($originalSource) && $field == "$originalSource.*") {
foreach ($namesMap as $aliasName => $columnName) {
$newGroupByFields["$source.$columnName"] = 1;
}
continue;
} else {
$newName = $this->getFieldNewName($field, $namesMap, $originalSource, $source);
if($newName != null) {
$newGroupByFields[$newName] = 1;
}
}
}
if (!empty($newGroupByFields)) {
$query->groupByFields(array_keys($newGroupByFields));
}
}
} | php | private function renameGroupByFields(SelectQuery $query, $namesMap = null, $originalSource = null) {
if($namesMap == null) {
$namesMap = $this->getColumnNames();
}
$groupByFields = &$query->getGroupByFields();
if (!empty($groupByFields)) {
$source = $query->getTable();
$newGroupByFields = [];
foreach ($groupByFields as $field) {
if ($field == '*') {
foreach ($namesMap as $aliasName => $columnName) {
$newGroupByFields[$columnName] = 1;
}
continue;
} else if (!empty($originalSource) && $field == "$originalSource.*") {
foreach ($namesMap as $aliasName => $columnName) {
$newGroupByFields["$source.$columnName"] = 1;
}
continue;
} else {
$newName = $this->getFieldNewName($field, $namesMap, $originalSource, $source);
if($newName != null) {
$newGroupByFields[$newName] = 1;
}
}
}
if (!empty($newGroupByFields)) {
$query->groupByFields(array_keys($newGroupByFields));
}
}
} | [
"private",
"function",
"renameGroupByFields",
"(",
"SelectQuery",
"$",
"query",
",",
"$",
"namesMap",
"=",
"null",
",",
"$",
"originalSource",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"namesMap",
"==",
"null",
")",
"{",
"$",
"namesMap",
"=",
"$",
"this",
... | Renombra los campos involucrados en agrupamiento segun el mapa indicado
@param SelectQuery $query
@param $namesMap
@param mixed $originalSource | [
"Renombra",
"los",
"campos",
"involucrados",
"en",
"agrupamiento",
"segun",
"el",
"mapa",
"indicado"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L586-L619 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.renameJoinFields | private function renameJoinFields(SelectQuery $query, $namesMap = null, $originalSource = null) {
if($namesMap == null) {
$namesMap = $this->getColumnNames();
}
$joins = &$query->getJoins();
if(!empty($joins)) {
foreach ($joins as &$join) {
$this->renameConditionFields($join, $namesMap, $originalSource, $query->getTable());
}
}
} | php | private function renameJoinFields(SelectQuery $query, $namesMap = null, $originalSource = null) {
if($namesMap == null) {
$namesMap = $this->getColumnNames();
}
$joins = &$query->getJoins();
if(!empty($joins)) {
foreach ($joins as &$join) {
$this->renameConditionFields($join, $namesMap, $originalSource, $query->getTable());
}
}
} | [
"private",
"function",
"renameJoinFields",
"(",
"SelectQuery",
"$",
"query",
",",
"$",
"namesMap",
"=",
"null",
",",
"$",
"originalSource",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"namesMap",
"==",
"null",
")",
"{",
"$",
"namesMap",
"=",
"$",
"this",
"-... | Renombra los campos involucrados en joins segun el mapa indicado
@param SelectQuery $query
@param $namesMap
@param mixed $originalSource | [
"Renombra",
"los",
"campos",
"involucrados",
"en",
"joins",
"segun",
"el",
"mapa",
"indicado"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L627-L637 | train |
luismanuelamengual/NeoPHP | src/NeoPHP/Resources/DBResourceManager.php | DBResourceManager.hasOtherConditionField | private function hasOtherConditionField(ConditionGroup $conditionGroup, string $source, array $fieldNames, &$foundField = null) : bool {
$result = false;
$conditions = &$conditionGroup->getConditions();
foreach ($conditions as $key=>&$condition) {
if ($condition->type == ConditionType::GROUP) {
$result = $this->hasOtherConditionField($condition->group, $source, $fieldNames, $foundField);
if ($result) {
break;
}
} else if ($condition->type == ConditionType::RAW) {
$result = true;
$foundField = 'RAW';
break;
} else {
$field = $condition->field;
$tablePos = stripos($field, "$source.");
if($tablePos === 0) {
$field = substr($field, strlen($source)+1);
}
if (!$this->fieldInList($field, $fieldNames)) {
$result = true;
$foundField = $field;
break;
}
if ($condition->operator == ConditionOperator::EQUALS_FIELD) {
$field = $condition->value;
$tablePos = stripos($field, "$source.");
if($tablePos === 0) {
$field = substr($field, strlen($source)+1);
}
if (!$this->fieldInList($field, $fieldNames)) {
$result = true;
$foundField = $field;
break;
}
}
}
}
return $result;
} | php | private function hasOtherConditionField(ConditionGroup $conditionGroup, string $source, array $fieldNames, &$foundField = null) : bool {
$result = false;
$conditions = &$conditionGroup->getConditions();
foreach ($conditions as $key=>&$condition) {
if ($condition->type == ConditionType::GROUP) {
$result = $this->hasOtherConditionField($condition->group, $source, $fieldNames, $foundField);
if ($result) {
break;
}
} else if ($condition->type == ConditionType::RAW) {
$result = true;
$foundField = 'RAW';
break;
} else {
$field = $condition->field;
$tablePos = stripos($field, "$source.");
if($tablePos === 0) {
$field = substr($field, strlen($source)+1);
}
if (!$this->fieldInList($field, $fieldNames)) {
$result = true;
$foundField = $field;
break;
}
if ($condition->operator == ConditionOperator::EQUALS_FIELD) {
$field = $condition->value;
$tablePos = stripos($field, "$source.");
if($tablePos === 0) {
$field = substr($field, strlen($source)+1);
}
if (!$this->fieldInList($field, $fieldNames)) {
$result = true;
$foundField = $field;
break;
}
}
}
}
return $result;
} | [
"private",
"function",
"hasOtherConditionField",
"(",
"ConditionGroup",
"$",
"conditionGroup",
",",
"string",
"$",
"source",
",",
"array",
"$",
"fieldNames",
",",
"&",
"$",
"foundField",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"result",
"=",
"false",
";",
... | Retorna verdadero si en entre las codiciones encuentra otro field distinto a los indicados
@param ConditionGroup $conditionGroup
@param $source
@param array $fieldNames
@param null $foundField : referencia donde se coloca el nombre del primer field encontrado distinto de los indicados
@return bool | [
"Retorna",
"verdadero",
"si",
"en",
"entre",
"las",
"codiciones",
"encuentra",
"otro",
"field",
"distinto",
"a",
"los",
"indicados"
] | da7c5831974b37dd4b0b170d9aa64e61404d819b | https://github.com/luismanuelamengual/NeoPHP/blob/da7c5831974b37dd4b0b170d9aa64e61404d819b/src/NeoPHP/Resources/DBResourceManager.php#L780-L820 | train |
krystal-framework/krystal.framework | src/Krystal/Validate/DefinitionParser.php | DefinitionParser.processData | private function processData($target, array $rules, $required, &$result)
{
foreach ($rules as $constraintName => $options) {
// Step first: Build constraint instance
if (isset($options['value'])) {
// When an array is provided then we should merge values and dynamically call a method
if (is_array($options['value'])) {
// Quick trick
$args = array_merge(array($constraintName), $options['value']);
$constraint = call_user_func_array(array($this->constraintFactory, 'build'), $args);
} else {
$constraint = $this->constraintFactory->build($constraintName, $options['value']);
}
} else {
$constraint = $this->constraintFactory->build($constraintName);
}
// Start tweaking the instance
if (isset($options['break'])) {
$constraint->setBreakable($options['break']);
} else {
// By default it should break the chain
$constraint->setBreakable(true);
}
// If additional message specified, then use it
// Otherwise a default constraint message is used by default
if (isset($options['message'])) {
$constraint->setMessage($options['message']);
}
$constraint->setRequired((bool) $required);
// If a $target name was not provided before
if (!isset($result[$target])) {
$result[$target] = array();
}
// Finally add prepared constraint
array_push($result[$target], $constraint);
}
} | php | private function processData($target, array $rules, $required, &$result)
{
foreach ($rules as $constraintName => $options) {
// Step first: Build constraint instance
if (isset($options['value'])) {
// When an array is provided then we should merge values and dynamically call a method
if (is_array($options['value'])) {
// Quick trick
$args = array_merge(array($constraintName), $options['value']);
$constraint = call_user_func_array(array($this->constraintFactory, 'build'), $args);
} else {
$constraint = $this->constraintFactory->build($constraintName, $options['value']);
}
} else {
$constraint = $this->constraintFactory->build($constraintName);
}
// Start tweaking the instance
if (isset($options['break'])) {
$constraint->setBreakable($options['break']);
} else {
// By default it should break the chain
$constraint->setBreakable(true);
}
// If additional message specified, then use it
// Otherwise a default constraint message is used by default
if (isset($options['message'])) {
$constraint->setMessage($options['message']);
}
$constraint->setRequired((bool) $required);
// If a $target name was not provided before
if (!isset($result[$target])) {
$result[$target] = array();
}
// Finally add prepared constraint
array_push($result[$target], $constraint);
}
} | [
"private",
"function",
"processData",
"(",
"$",
"target",
",",
"array",
"$",
"rules",
",",
"$",
"required",
",",
"&",
"$",
"result",
")",
"{",
"foreach",
"(",
"$",
"rules",
"as",
"$",
"constraintName",
"=>",
"$",
"options",
")",
"{",
"// Step first: Buil... | Process an array of configuration
@param string $target
@param array $rules
@param boolean $required
@param mixed $result
@return void | [
"Process",
"an",
"array",
"of",
"configuration"
] | a5ff72384f3efbe74f390538793feb7d522b9c39 | https://github.com/krystal-framework/krystal.framework/blob/a5ff72384f3efbe74f390538793feb7d522b9c39/src/Krystal/Validate/DefinitionParser.php#L106-L153 | train |
fxpio/fxp-form-extensions | Form/ChoiceList/Loader/DynamicChoiceLoader.php | DynamicChoiceLoader.addNewValues | protected function addNewValues(array $selections, array $values)
{
if ($this->isAllowAdd()) {
foreach ($values as $value) {
if (!\in_array($value, $selections) && !\in_array((string) $value, $selections)) {
$selections[] = (string) $value;
}
}
}
return $selections;
} | php | protected function addNewValues(array $selections, array $values)
{
if ($this->isAllowAdd()) {
foreach ($values as $value) {
if (!\in_array($value, $selections) && !\in_array((string) $value, $selections)) {
$selections[] = (string) $value;
}
}
}
return $selections;
} | [
"protected",
"function",
"addNewValues",
"(",
"array",
"$",
"selections",
",",
"array",
"$",
"values",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isAllowAdd",
"(",
")",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"if",
"(",
... | Add new values.
@param array $selections The list of selection
@param array $values The list of value
@return array The list of new selection | [
"Add",
"new",
"values",
"."
] | ef09edf557b109187d38248b0976df31e5583b5b | https://github.com/fxpio/fxp-form-extensions/blob/ef09edf557b109187d38248b0976df31e5583b5b/Form/ChoiceList/Loader/DynamicChoiceLoader.php#L123-L134 | train |
fxpio/fxp-form-extensions | Form/ChoiceList/Loader/DynamicChoiceLoader.php | DynamicChoiceLoader.getSelectedChoices | protected function getSelectedChoices(array $values, $value = null)
{
$structuredValues = $this->loadChoiceList($value)->getStructuredValues();
$values = $this->forceStringValues($values);
$allChoices = [];
$choices = [];
$isGrouped = false;
foreach ($structuredValues as $group => $choice) {
// group
if (\is_array($choice)) {
$isGrouped = true;
foreach ($choice as $choiceKey => $choiceValue) {
if ($this->allChoices || \in_array($choiceValue, $values)) {
$choices[$group][$choiceKey] = $choiceValue;
$allChoices[$choiceKey] = $choiceValue;
}
}
} elseif ($this->allChoices || \in_array($choice, $values)) {
$choices[$group] = $choice;
$allChoices[$group] = $choice;
}
}
if ($this->isAllowAdd()) {
$choices = $this->addNewTagsInChoices($choices, $allChoices, $values, $isGrouped);
}
return (array) $choices;
} | php | protected function getSelectedChoices(array $values, $value = null)
{
$structuredValues = $this->loadChoiceList($value)->getStructuredValues();
$values = $this->forceStringValues($values);
$allChoices = [];
$choices = [];
$isGrouped = false;
foreach ($structuredValues as $group => $choice) {
// group
if (\is_array($choice)) {
$isGrouped = true;
foreach ($choice as $choiceKey => $choiceValue) {
if ($this->allChoices || \in_array($choiceValue, $values)) {
$choices[$group][$choiceKey] = $choiceValue;
$allChoices[$choiceKey] = $choiceValue;
}
}
} elseif ($this->allChoices || \in_array($choice, $values)) {
$choices[$group] = $choice;
$allChoices[$group] = $choice;
}
}
if ($this->isAllowAdd()) {
$choices = $this->addNewTagsInChoices($choices, $allChoices, $values, $isGrouped);
}
return (array) $choices;
} | [
"protected",
"function",
"getSelectedChoices",
"(",
"array",
"$",
"values",
",",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"structuredValues",
"=",
"$",
"this",
"->",
"loadChoiceList",
"(",
"$",
"value",
")",
"->",
"getStructuredValues",
"(",
")",
";",
"$"... | Keep only the selected values in choices.
@param array $values The selected values
@param null|callable $value The callable function
@return array The selected choices | [
"Keep",
"only",
"the",
"selected",
"values",
"in",
"choices",
"."
] | ef09edf557b109187d38248b0976df31e5583b5b | https://github.com/fxpio/fxp-form-extensions/blob/ef09edf557b109187d38248b0976df31e5583b5b/Form/ChoiceList/Loader/DynamicChoiceLoader.php#L161-L190 | train |
fxpio/fxp-form-extensions | Form/ChoiceList/Loader/DynamicChoiceLoader.php | DynamicChoiceLoader.forceStringValues | protected function forceStringValues(array $values)
{
foreach ($values as $key => $value) {
$values[$key] = (string) $value;
}
return $values;
} | php | protected function forceStringValues(array $values)
{
foreach ($values as $key => $value) {
$values[$key] = (string) $value;
}
return $values;
} | [
"protected",
"function",
"forceStringValues",
"(",
"array",
"$",
"values",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"values",
"[",
"$",
"key",
"]",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}"... | Force value with string type.
@param array $values
@return string[] | [
"Force",
"value",
"with",
"string",
"type",
"."
] | ef09edf557b109187d38248b0976df31e5583b5b | https://github.com/fxpio/fxp-form-extensions/blob/ef09edf557b109187d38248b0976df31e5583b5b/Form/ChoiceList/Loader/DynamicChoiceLoader.php#L199-L206 | train |
fxpio/fxp-form-extensions | Form/ChoiceList/Loader/DynamicChoiceLoader.php | DynamicChoiceLoader.addNewTagsInChoices | protected function addNewTagsInChoices(array $choices, array $allChoices, array $values, $isGrouped)
{
foreach ($values as $value) {
if (!\in_array($value, $allChoices)) {
if ($isGrouped) {
$choices['-------'][$value] = $value;
} else {
$choices[$value] = $value;
}
}
}
return $choices;
} | php | protected function addNewTagsInChoices(array $choices, array $allChoices, array $values, $isGrouped)
{
foreach ($values as $value) {
if (!\in_array($value, $allChoices)) {
if ($isGrouped) {
$choices['-------'][$value] = $value;
} else {
$choices[$value] = $value;
}
}
}
return $choices;
} | [
"protected",
"function",
"addNewTagsInChoices",
"(",
"array",
"$",
"choices",
",",
"array",
"$",
"allChoices",
",",
"array",
"$",
"values",
",",
"$",
"isGrouped",
")",
"{",
"foreach",
"(",
"$",
"values",
"as",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"\... | Add new tags in choices.
@param array $choices The choices
@param array $allChoices The all choices
@param string[] $values The values
@param bool $isGrouped Check if the choices is grouped
@return array The choice with new tags | [
"Add",
"new",
"tags",
"in",
"choices",
"."
] | ef09edf557b109187d38248b0976df31e5583b5b | https://github.com/fxpio/fxp-form-extensions/blob/ef09edf557b109187d38248b0976df31e5583b5b/Form/ChoiceList/Loader/DynamicChoiceLoader.php#L218-L231 | train |
manusreload/GLFramework | src/View.php | View.render | public function render($data = array(), $params = array())
{
if ($this->controller->getTemplate() !== null) {
foreach ($this->controller->filters as $filter) {
$this->twig->addFilter($filter);
}
$this->twig->addGlobal('params', $params);
$key = "twig" . microtime(true);
// Debugbar::timer($key, $this->controller->getTemplate());
$template = $this->twig->load($this->controller->getTemplate());
$data = $template->render($this->getData($data));
// Debugbar::stopTimer($key);
}
return $data;
} | php | public function render($data = array(), $params = array())
{
if ($this->controller->getTemplate() !== null) {
foreach ($this->controller->filters as $filter) {
$this->twig->addFilter($filter);
}
$this->twig->addGlobal('params', $params);
$key = "twig" . microtime(true);
// Debugbar::timer($key, $this->controller->getTemplate());
$template = $this->twig->load($this->controller->getTemplate());
$data = $template->render($this->getData($data));
// Debugbar::stopTimer($key);
}
return $data;
} | [
"public",
"function",
"render",
"(",
"$",
"data",
"=",
"array",
"(",
")",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"controller",
"->",
"getTemplate",
"(",
")",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$... | Devuelve la vista renderizada
@param null $data
@param array $params
@return array|null|string | [
"Devuelve",
"la",
"vista",
"renderizada"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/View.php#L92-L106 | train |
manusreload/GLFramework | src/View.php | View.mail | public function mail($template, $data = array(), &$css = array())
{
$this->twig->addFunction(new \Twig_SimpleFunction('css', function ($file) use (&$css) {
$css[] = $file;
}));
$template = $this->twig->loadTemplate($template);
return $template->render($data);
} | php | public function mail($template, $data = array(), &$css = array())
{
$this->twig->addFunction(new \Twig_SimpleFunction('css', function ($file) use (&$css) {
$css[] = $file;
}));
$template = $this->twig->loadTemplate($template);
return $template->render($data);
} | [
"public",
"function",
"mail",
"(",
"$",
"template",
",",
"$",
"data",
"=",
"array",
"(",
")",
",",
"&",
"$",
"css",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"twig",
"->",
"addFunction",
"(",
"new",
"\\",
"Twig_SimpleFunction",
"(",
"'cs... | Devulve una vista compatible con los clientes de correo
@param $template
@param array $data
@param array $css
@return string | [
"Devulve",
"una",
"vista",
"compatible",
"con",
"los",
"clientes",
"de",
"correo"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/View.php#L174-L181 | train |
Mihai-P/yii2theme-brain | widgets/ActionColumn.php | ActionColumn.getCompatibilityId | protected function getCompatibilityId() {
$controller = $this->controller ? $this->controller : Yii::$app->controller->id;
if(strpos($controller, "/")) {
$controller = substr($controller, strpos($controller, "/") + 1);
}
return str_replace(' ', '', ucwords(str_replace('-', ' ', $controller)));
} | php | protected function getCompatibilityId() {
$controller = $this->controller ? $this->controller : Yii::$app->controller->id;
if(strpos($controller, "/")) {
$controller = substr($controller, strpos($controller, "/") + 1);
}
return str_replace(' ', '', ucwords(str_replace('-', ' ', $controller)));
} | [
"protected",
"function",
"getCompatibilityId",
"(",
")",
"{",
"$",
"controller",
"=",
"$",
"this",
"->",
"controller",
"?",
"$",
"this",
"->",
"controller",
":",
"Yii",
"::",
"$",
"app",
"->",
"controller",
"->",
"id",
";",
"if",
"(",
"strpos",
"(",
"$... | Get the simpler access privileges name from the current controller
@return string | [
"Get",
"the",
"simpler",
"access",
"privileges",
"name",
"from",
"the",
"current",
"controller"
] | 3dedfda461ad55d5152d593b148022b58587fedd | https://github.com/Mihai-P/yii2theme-brain/blob/3dedfda461ad55d5152d593b148022b58587fedd/widgets/ActionColumn.php#L50-L56 | train |
Mihai-P/yii2theme-brain | widgets/ActionColumn.php | ActionColumn.initDefaultButtons | protected function initDefaultButtons()
{
$controller = $this->getCompatibilityId();
if(\Yii::$app->user->checkAccess('read::' . $controller)) {
if (!isset($this->buttons['view'])) {
$this->buttons['view'] = function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, [
'title' => Yii::t('yii', 'View'),
'class' => 'btn btn-xs btn-primary hidden-xs button-status-deactivate',
'data-pjax' => '0',
]);
};
}
}
if(\Yii::$app->user->checkAccess('update::' . $controller)) {
if (!isset($this->buttons['status'])) {
$this->buttons['status'] = function ($url, $model) {
if($model->status == 'active')
return Html::a('<span class="glyphicon glyphicon-remove"></span>', $url, [
'title' => Yii::t('yii', 'Deactivate'),
'onclick' => 'javascript: if(confirm("Are you sure you want to deactivate this item?")) myGrid.status($(this)); return false;',
'class' => 'btn btn-xs btn-warning hidden-xs button-status-deactivate',
'data-pjax' => '0',
]);
else
return Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [
'title' => Yii::t('yii', 'Activate'),
'onclick' => 'javascript: if(confirm("Are you sure you want to activate this item?")) myGrid.status($(this)); return false;',
'class' => 'btn btn-xs btn-success hidden-xs button-status-activate',
'data-pjax' => '0',
]);
};
}
if (!isset($this->buttons['update'])) {
$this->buttons['update'] = function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
'title' => Yii::t('yii', 'Update'),
'class' => 'btn btn-xs btn-default',
'data-pjax' => '0',
]);
};
}
}
if(\Yii::$app->user->checkAccess('delete::' . $controller)) {
if (!isset($this->buttons['delete'])) {
$this->buttons['delete'] = function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
'title' => Yii::t('yii', 'Delete'),
'onclick' => 'javascript: if(confirm("Are you sure you want to delete this item?")) myGrid.status($(this)); return false;',
'class' => 'btn btn-xs btn-danger button-delete',
'data-pjax' => '0',
]);
};
}
}
} | php | protected function initDefaultButtons()
{
$controller = $this->getCompatibilityId();
if(\Yii::$app->user->checkAccess('read::' . $controller)) {
if (!isset($this->buttons['view'])) {
$this->buttons['view'] = function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, [
'title' => Yii::t('yii', 'View'),
'class' => 'btn btn-xs btn-primary hidden-xs button-status-deactivate',
'data-pjax' => '0',
]);
};
}
}
if(\Yii::$app->user->checkAccess('update::' . $controller)) {
if (!isset($this->buttons['status'])) {
$this->buttons['status'] = function ($url, $model) {
if($model->status == 'active')
return Html::a('<span class="glyphicon glyphicon-remove"></span>', $url, [
'title' => Yii::t('yii', 'Deactivate'),
'onclick' => 'javascript: if(confirm("Are you sure you want to deactivate this item?")) myGrid.status($(this)); return false;',
'class' => 'btn btn-xs btn-warning hidden-xs button-status-deactivate',
'data-pjax' => '0',
]);
else
return Html::a('<span class="glyphicon glyphicon-ok"></span>', $url, [
'title' => Yii::t('yii', 'Activate'),
'onclick' => 'javascript: if(confirm("Are you sure you want to activate this item?")) myGrid.status($(this)); return false;',
'class' => 'btn btn-xs btn-success hidden-xs button-status-activate',
'data-pjax' => '0',
]);
};
}
if (!isset($this->buttons['update'])) {
$this->buttons['update'] = function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
'title' => Yii::t('yii', 'Update'),
'class' => 'btn btn-xs btn-default',
'data-pjax' => '0',
]);
};
}
}
if(\Yii::$app->user->checkAccess('delete::' . $controller)) {
if (!isset($this->buttons['delete'])) {
$this->buttons['delete'] = function ($url, $model) {
return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
'title' => Yii::t('yii', 'Delete'),
'onclick' => 'javascript: if(confirm("Are you sure you want to delete this item?")) myGrid.status($(this)); return false;',
'class' => 'btn btn-xs btn-danger button-delete',
'data-pjax' => '0',
]);
};
}
}
} | [
"protected",
"function",
"initDefaultButtons",
"(",
")",
"{",
"$",
"controller",
"=",
"$",
"this",
"->",
"getCompatibilityId",
"(",
")",
";",
"if",
"(",
"\\",
"Yii",
"::",
"$",
"app",
"->",
"user",
"->",
"checkAccess",
"(",
"'read::'",
".",
"$",
"control... | Initializes the default button rendering callbacks | [
"Initializes",
"the",
"default",
"button",
"rendering",
"callbacks"
] | 3dedfda461ad55d5152d593b148022b58587fedd | https://github.com/Mihai-P/yii2theme-brain/blob/3dedfda461ad55d5152d593b148022b58587fedd/widgets/ActionColumn.php#L61-L116 | train |
droath/project-x | src/Engine/DockerService.php | DockerService.asArray | public function asArray()
{
$array = [];
foreach (get_object_vars($this) as $property => $value) {
if (empty($value)) {
continue;
}
$array[$property] = $value;
}
return $array;
} | php | public function asArray()
{
$array = [];
foreach (get_object_vars($this) as $property => $value) {
if (empty($value)) {
continue;
}
$array[$property] = $value;
}
return $array;
} | [
"public",
"function",
"asArray",
"(",
")",
"{",
"$",
"array",
"=",
"[",
"]",
";",
"foreach",
"(",
"get_object_vars",
"(",
"$",
"this",
")",
"as",
"$",
"property",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",... | Get an array representation of the object.
@return array
An array of all properties that have values. | [
"Get",
"an",
"array",
"representation",
"of",
"the",
"object",
"."
] | 85a7a4879bd041f4c5cb565356646e5f5e2435b7 | https://github.com/droath/project-x/blob/85a7a4879bd041f4c5cb565356646e5f5e2435b7/src/Engine/DockerService.php#L141-L152 | train |
manusreload/GLFramework | src/Model.php | Model.insert | public function insert($data = null)
{
$currentIndex = $this->getFieldValue($this->getIndex());
$fields = $this->getFields();
$sql1 = '';
$sql2 = '';
$args = array();
foreach ($fields as $field) {
// if($this->getFieldValue($field, $data) !== NULL)
if (in_array($field, $this->created_at_fileds)) {
$this->{$field} = now();
}
$value = $this->getFieldValue($field, $data);
$args[$field] = $value;
$sql1 .= "`$field`, ";
$sql2 .= ":$field, ";
}
if (!empty($sql1)) {
$sql1 = substr($sql1, 0, -2);
$sql2 = substr($sql2, 0, -2);
if($currentIndex) {
$this->db->removeCache($this->getCacheId($currentIndex));
}
return $this->db->insert('INSERT INTO `'.$this->table_name.'` ('.$sql1.') VALUES ('.$sql2.')', $args);
}
return false;
} | php | public function insert($data = null)
{
$currentIndex = $this->getFieldValue($this->getIndex());
$fields = $this->getFields();
$sql1 = '';
$sql2 = '';
$args = array();
foreach ($fields as $field) {
// if($this->getFieldValue($field, $data) !== NULL)
if (in_array($field, $this->created_at_fileds)) {
$this->{$field} = now();
}
$value = $this->getFieldValue($field, $data);
$args[$field] = $value;
$sql1 .= "`$field`, ";
$sql2 .= ":$field, ";
}
if (!empty($sql1)) {
$sql1 = substr($sql1, 0, -2);
$sql2 = substr($sql2, 0, -2);
if($currentIndex) {
$this->db->removeCache($this->getCacheId($currentIndex));
}
return $this->db->insert('INSERT INTO `'.$this->table_name.'` ('.$sql1.') VALUES ('.$sql2.')', $args);
}
return false;
} | [
"public",
"function",
"insert",
"(",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"currentIndex",
"=",
"$",
"this",
"->",
"getFieldValue",
"(",
"$",
"this",
"->",
"getIndex",
"(",
")",
")",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"getFields",
"(",
... | Inserta el modelo en la tabla
@param null $data
@return bool | [
"Inserta",
"el",
"modelo",
"en",
"la",
"tabla"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L165-L191 | train |
manusreload/GLFramework | src/Model.php | Model.update | public function update($data = null)
{
$fields = $this->getFields();
$sql1 = '';
$args = array();
foreach ($fields as $field) {
if (in_array($field, $this->updated_at_fileds)) {
$this->{$field} = now();
}
$value = $this->getFieldValue($field, $data);
if (isset($value) && !$this->isIndex($field)) {
$args[] = $value;
$sql1 .= "`$field` = ?, ";
}
}
if (!empty($sql1)) {
$sql1 = substr($sql1, 0, -2);
$index = $this->getIndex();
$indexValue = $this->db->escape_string($this->getFieldValue($index, $data));
if (!$indexValue) {
return false;
}
$args[] = $indexValue;
return $this->db->exec("UPDATE `{$this->table_name}` SET $sql1 WHERE `$index` = ?", $args, $this->getCacheId($indexValue));
}
return false;
} | php | public function update($data = null)
{
$fields = $this->getFields();
$sql1 = '';
$args = array();
foreach ($fields as $field) {
if (in_array($field, $this->updated_at_fileds)) {
$this->{$field} = now();
}
$value = $this->getFieldValue($field, $data);
if (isset($value) && !$this->isIndex($field)) {
$args[] = $value;
$sql1 .= "`$field` = ?, ";
}
}
if (!empty($sql1)) {
$sql1 = substr($sql1, 0, -2);
$index = $this->getIndex();
$indexValue = $this->db->escape_string($this->getFieldValue($index, $data));
if (!$indexValue) {
return false;
}
$args[] = $indexValue;
return $this->db->exec("UPDATE `{$this->table_name}` SET $sql1 WHERE `$index` = ?", $args, $this->getCacheId($indexValue));
}
return false;
} | [
"public",
"function",
"update",
"(",
"$",
"data",
"=",
"null",
")",
"{",
"$",
"fields",
"=",
"$",
"this",
"->",
"getFields",
"(",
")",
";",
"$",
"sql1",
"=",
"''",
";",
"$",
"args",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"fields",
"a... | Si el modelo tiene indice actualiza el modelo con los datos
@param null $data
@return bool
@throws \Exception | [
"Si",
"el",
"modelo",
"tiene",
"indice",
"actualiza",
"el",
"modelo",
"con",
"los",
"datos"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L200-L226 | train |
manusreload/GLFramework | src/Model.php | Model.delete | public function delete($cache = null)
{
$index = $this->getIndex();
$value = $this->getFieldValue($index);
if ($value) {
if($cache) {
$this->db->removeCache($this->getCacheId($cache));
}
return $this->db->exec("DELETE FROM {$this->table_name} WHERE `$index` = ?", array($value), $this->getCacheId($value));
}
return false;
} | php | public function delete($cache = null)
{
$index = $this->getIndex();
$value = $this->getFieldValue($index);
if ($value) {
if($cache) {
$this->db->removeCache($this->getCacheId($cache));
}
return $this->db->exec("DELETE FROM {$this->table_name} WHERE `$index` = ?", array($value), $this->getCacheId($value));
}
return false;
} | [
"public",
"function",
"delete",
"(",
"$",
"cache",
"=",
"null",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndex",
"(",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"getFieldValue",
"(",
"$",
"index",
")",
";",
"if",
"(",
"$",
"value"... | Eliminar el modelo de la base de datos
@param null $cache
@return bool | [
"Eliminar",
"el",
"modelo",
"de",
"la",
"base",
"de",
"datos"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L234-L245 | train |
manusreload/GLFramework | src/Model.php | Model.get_or | public function get_or($fields)
{
$args = array();
$fieldsValue = $fields;
$fields = $this->getFields();
$sql = '';
foreach ($fields as $field) {
if (isset($fieldsValue[$field])) {
$value = $fieldsValue[$field];
if (is_array($value)) {
foreach ($value as $subvalue) {
$sql .= '`' . $field . '` = ? OR ';
$args[] = $subvalue;
}
} else {
$sql .= '`' . $field . '` = ? OR ';
$args[] = $value;
}
}
}
if (!empty($sql)) {
$sql = substr($sql, 0, -4);
return $this->build($this->db->select('SELECT * FROM `' . $this->table_name . '` WHERE ' . $sql, $args));
}
return $this->build(array());
} | php | public function get_or($fields)
{
$args = array();
$fieldsValue = $fields;
$fields = $this->getFields();
$sql = '';
foreach ($fields as $field) {
if (isset($fieldsValue[$field])) {
$value = $fieldsValue[$field];
if (is_array($value)) {
foreach ($value as $subvalue) {
$sql .= '`' . $field . '` = ? OR ';
$args[] = $subvalue;
}
} else {
$sql .= '`' . $field . '` = ? OR ';
$args[] = $value;
}
}
}
if (!empty($sql)) {
$sql = substr($sql, 0, -4);
return $this->build($this->db->select('SELECT * FROM `' . $this->table_name . '` WHERE ' . $sql, $args));
}
return $this->build(array());
} | [
"public",
"function",
"get_or",
"(",
"$",
"fields",
")",
"{",
"$",
"args",
"=",
"array",
"(",
")",
";",
"$",
"fieldsValue",
"=",
"$",
"fields",
";",
"$",
"fields",
"=",
"$",
"this",
"->",
"getFields",
"(",
")",
";",
"$",
"sql",
"=",
"''",
";",
... | Obtener el modelo de la base de datos con condiciones disyuntivas
@param $fields
@return ModelResult
@throws \Exception | [
"Obtener",
"el",
"modelo",
"de",
"la",
"base",
"de",
"datos",
"con",
"condiciones",
"disyuntivas"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L321-L346 | train |
manusreload/GLFramework | src/Model.php | Model.get_all | public function get_all()
{
return $this->build($this->db->select('SELECT * FROM `' . $this->table_name . '` WHERE 1', [], $this->getCacheId('all')));
} | php | public function get_all()
{
return $this->build($this->db->select('SELECT * FROM `' . $this->table_name . '` WHERE 1', [], $this->getCacheId('all')));
} | [
"public",
"function",
"get_all",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"build",
"(",
"$",
"this",
"->",
"db",
"->",
"select",
"(",
"'SELECT * FROM `'",
".",
"$",
"this",
"->",
"table_name",
".",
"'` WHERE 1'",
",",
"[",
"]",
",",
"$",
"this",
"... | Obtener todos los modelos de la tabla
@return ModelResult | [
"Obtener",
"todos",
"los",
"modelos",
"de",
"la",
"tabla"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L353-L356 | train |
manusreload/GLFramework | src/Model.php | Model.get_others | public function get_others()
{
$index = $this->getIndex();
$value = $this->getFieldValue($index);
if (is_string($value) && strlen($value) > 0) {
return $this->build($this->db->select('SELECT * FROM `' . $this->table_name . '` WHERE `' . $index . '` != ?', array((string)$value), $this->getCacheId("not_" . $value)));
}
return $this->get_all();
} | php | public function get_others()
{
$index = $this->getIndex();
$value = $this->getFieldValue($index);
if (is_string($value) && strlen($value) > 0) {
return $this->build($this->db->select('SELECT * FROM `' . $this->table_name . '` WHERE `' . $index . '` != ?', array((string)$value), $this->getCacheId("not_" . $value)));
}
return $this->get_all();
} | [
"public",
"function",
"get_others",
"(",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"getIndex",
"(",
")",
";",
"$",
"value",
"=",
"$",
"this",
"->",
"getFieldValue",
"(",
"$",
"index",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
... | Obtener los modelos que no sean este.
@return ModelResult
@throws \Exception | [
"Obtener",
"los",
"modelos",
"que",
"no",
"sean",
"este",
"."
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L364-L372 | train |
manusreload/GLFramework | src/Model.php | Model.search | public function search($fields, $limit = -1)
{
if (!is_array($fields)) {
$fields = array($this->getIndex() => $fields);
}
$fieldsValue = $fields;
$fields = $this->getFields();
$sql = '';
$args = array();
foreach ($fields as $field) {
if (isset($fieldsValue[$field])) {
$value = $fieldsValue[$field];
if ($this->isString($field)) {
$sql .= '`' . $field . '` LIKE ? OR ';
$args[] = '%' . $value . '%';
} else {
$sql .= '`' . $field . '` = ? OR ';
$args[] = $value;
}
}
}
if (!empty($sql)) {
$sql = substr($sql, 0, -4);
if($limit > 0) {
$sql .= " LIMIT $limit";
}
return $this->build($this->db->select('SELECT * FROM `' . $this->table_name . '` WHERE ' . $sql, $args));
}
return $this->build(array());
} | php | public function search($fields, $limit = -1)
{
if (!is_array($fields)) {
$fields = array($this->getIndex() => $fields);
}
$fieldsValue = $fields;
$fields = $this->getFields();
$sql = '';
$args = array();
foreach ($fields as $field) {
if (isset($fieldsValue[$field])) {
$value = $fieldsValue[$field];
if ($this->isString($field)) {
$sql .= '`' . $field . '` LIKE ? OR ';
$args[] = '%' . $value . '%';
} else {
$sql .= '`' . $field . '` = ? OR ';
$args[] = $value;
}
}
}
if (!empty($sql)) {
$sql = substr($sql, 0, -4);
if($limit > 0) {
$sql .= " LIMIT $limit";
}
return $this->build($this->db->select('SELECT * FROM `' . $this->table_name . '` WHERE ' . $sql, $args));
}
return $this->build(array());
} | [
"public",
"function",
"search",
"(",
"$",
"fields",
",",
"$",
"limit",
"=",
"-",
"1",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"fields",
")",
")",
"{",
"$",
"fields",
"=",
"array",
"(",
"$",
"this",
"->",
"getIndex",
"(",
")",
"=>",
"$",... | Busca en forma de texto en la tabla
@param $fields
@param int $limit
@return ModelResult | [
"Busca",
"en",
"forma",
"de",
"texto",
"en",
"la",
"tabla"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L381-L411 | train |
manusreload/GLFramework | src/Model.php | Model.save | public function save($updateIndex = false)
{
$this->clearCacheTableIndex();
if ($this->exists()) {
return $this->update();
}
$result = $this->insert();
if ($result && $updateIndex) {
$this->setToIndex($result);
}
return $result;
} | php | public function save($updateIndex = false)
{
$this->clearCacheTableIndex();
if ($this->exists()) {
return $this->update();
}
$result = $this->insert();
if ($result && $updateIndex) {
$this->setToIndex($result);
}
return $result;
} | [
"public",
"function",
"save",
"(",
"$",
"updateIndex",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"clearCacheTableIndex",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"exists",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"update",
"(",
")",
";... | Actualiza si ya existe, en otro caso inserta
@param bool $updateIndex
@return bool | [
"Actualiza",
"si",
"ya",
"existe",
"en",
"otro",
"caso",
"inserta"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L419-L431 | train |
manusreload/GLFramework | src/Model.php | Model.exists | public function exists()
{
$indexValue = $this->getFieldValue($this->getIndex());
if ($indexValue) {
return $this->get($indexValue)->count() > 0;
}
return false;
} | php | public function exists()
{
$indexValue = $this->getFieldValue($this->getIndex());
if ($indexValue) {
return $this->get($indexValue)->count() > 0;
}
return false;
} | [
"public",
"function",
"exists",
"(",
")",
"{",
"$",
"indexValue",
"=",
"$",
"this",
"->",
"getFieldValue",
"(",
"$",
"this",
"->",
"getIndex",
"(",
")",
")",
";",
"if",
"(",
"$",
"indexValue",
")",
"{",
"return",
"$",
"this",
"->",
"get",
"(",
"$",... | Devuelve true si existe el modelo en la tabla
@return bool | [
"Devuelve",
"true",
"si",
"existe",
"el",
"modelo",
"en",
"la",
"tabla"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L438-L445 | train |
manusreload/GLFramework | src/Model.php | Model.getFieldValue | public function getFieldValue($field, $data = null)
{
if ($data !== null && isset($data[$field])) {
return $data[$field];
}
if (isset($this->{$field})) {
return $this->{$field};
}
return null;
} | php | public function getFieldValue($field, $data = null)
{
if ($data !== null && isset($data[$field])) {
return $data[$field];
}
if (isset($this->{$field})) {
return $this->{$field};
}
return null;
} | [
"public",
"function",
"getFieldValue",
"(",
"$",
"field",
",",
"$",
"data",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"data",
"!==",
"null",
"&&",
"isset",
"(",
"$",
"data",
"[",
"$",
"field",
"]",
")",
")",
"{",
"return",
"$",
"data",
"[",
"$",
"... | Obtiene el valor del campo especificado, null si no existe el campo
@param $field
@param null $data
@return null | [
"Obtiene",
"el",
"valor",
"del",
"campo",
"especificado",
"null",
"si",
"no",
"existe",
"el",
"campo"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L454-L463 | train |
manusreload/GLFramework | src/Model.php | Model.getFields | public function getFields()
{
$fields = array();
if (isset($this->definition['index'])) {
$fields[] = $this->getIndex();
}
if (isset($this->definition['fields'])) {
foreach ($this->definition['fields'] as $key => $value) {
if (!is_numeric($key)) {
$fields[] = $key;
} else {
$fields[] = $value;
}
}
}
return $fields;
} | php | public function getFields()
{
$fields = array();
if (isset($this->definition['index'])) {
$fields[] = $this->getIndex();
}
if (isset($this->definition['fields'])) {
foreach ($this->definition['fields'] as $key => $value) {
if (!is_numeric($key)) {
$fields[] = $key;
} else {
$fields[] = $value;
}
}
}
return $fields;
} | [
"public",
"function",
"getFields",
"(",
")",
"{",
"$",
"fields",
"=",
"array",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"definition",
"[",
"'index'",
"]",
")",
")",
"{",
"$",
"fields",
"[",
"]",
"=",
"$",
"this",
"->",
"getIndex... | Apartir de la definicion devuelve los campos disponibles para el modelo
@return array | [
"Apartir",
"de",
"la",
"definicion",
"devuelve",
"los",
"campos",
"disponibles",
"para",
"el",
"modelo"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L470-L486 | train |
manusreload/GLFramework | src/Model.php | Model.build | public function build($result)
{
$modelResult = new ModelResult($this);
$modelResult->models = $result;
if (count($result) > 0) {
$modelResult->model = $result[0];
}
if ($this->order !== '') {
$modelResult->order($this->order);
}
return $modelResult;
} | php | public function build($result)
{
$modelResult = new ModelResult($this);
$modelResult->models = $result;
if (count($result) > 0) {
$modelResult->model = $result[0];
}
if ($this->order !== '') {
$modelResult->order($this->order);
}
return $modelResult;
} | [
"public",
"function",
"build",
"(",
"$",
"result",
")",
"{",
"$",
"modelResult",
"=",
"new",
"ModelResult",
"(",
"$",
"this",
")",
";",
"$",
"modelResult",
"->",
"models",
"=",
"$",
"result",
";",
"if",
"(",
"count",
"(",
"$",
"result",
")",
">",
"... | Genera un resultado de modelos a partir de la lista develta por la consulta
@param $result
@return ModelResult | [
"Genera",
"un",
"resultado",
"de",
"modelos",
"a",
"partir",
"de",
"la",
"lista",
"develta",
"por",
"la",
"consulta"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L544-L555 | train |
manusreload/GLFramework | src/Model.php | Model.setData | public function setData($data, $allowEmpty = true, $allowUnset = false)
{
if ($data != null) {
if (is_array($data)) {
$fileds = $this->getFields();
foreach ($fileds as $field) {
if (isset($data[$field]) && ($allowEmpty || $data[$field] !== '')) {
if (strpos($this->getFieldType($field), 'varchar') !== false || $this->getFieldType($field) === 'text') {
$encoding = mb_detect_encoding($data[$field]);
if ($encoding !== 'utf8') {
$this->{$field} = mb_convert_encoding($data[$field], 'utf8', $encoding);
} else {
$this->{$field} = $data[$field];
}
} else {
$this->{$field} = $data[$field];
}
} elseif ($allowUnset) {
$this->{$field} = false;
}
}
} else {
$result = $this->get($data);
$this->setData($result->model);
if (empty($result->model)) {
$this->asDefault();
}
}
}
if (empty($data)) {
$this->asDefault();
}
return $this;
} | php | public function setData($data, $allowEmpty = true, $allowUnset = false)
{
if ($data != null) {
if (is_array($data)) {
$fileds = $this->getFields();
foreach ($fileds as $field) {
if (isset($data[$field]) && ($allowEmpty || $data[$field] !== '')) {
if (strpos($this->getFieldType($field), 'varchar') !== false || $this->getFieldType($field) === 'text') {
$encoding = mb_detect_encoding($data[$field]);
if ($encoding !== 'utf8') {
$this->{$field} = mb_convert_encoding($data[$field], 'utf8', $encoding);
} else {
$this->{$field} = $data[$field];
}
} else {
$this->{$field} = $data[$field];
}
} elseif ($allowUnset) {
$this->{$field} = false;
}
}
} else {
$result = $this->get($data);
$this->setData($result->model);
if (empty($result->model)) {
$this->asDefault();
}
}
}
if (empty($data)) {
$this->asDefault();
}
return $this;
} | [
"public",
"function",
"setData",
"(",
"$",
"data",
",",
"$",
"allowEmpty",
"=",
"true",
",",
"$",
"allowUnset",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"data",
"!=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
")",
"{",
"$",
... | Establecer estos datos al modelo, en funcion de la definicion, si no esta en la definicion no
se asigna al modelo.
@param $data
@param bool $allowEmpty
@param bool $allowUnset
@return $this | [
"Establecer",
"estos",
"datos",
"al",
"modelo",
"en",
"funcion",
"de",
"la",
"definicion",
"si",
"no",
"esta",
"en",
"la",
"definicion",
"no",
"se",
"asigna",
"al",
"modelo",
"."
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L591-L624 | train |
manusreload/GLFramework | src/Model.php | Model.getFieldDefinition | public function getFieldDefinition($field)
{
if (isset($this->definition[$field])) {
return $this->definition[$field];
}
if (isset($this->definition['fields'][$field])) {
return $this->definition['fields'][$field];
}
return null;
} | php | public function getFieldDefinition($field)
{
if (isset($this->definition[$field])) {
return $this->definition[$field];
}
if (isset($this->definition['fields'][$field])) {
return $this->definition['fields'][$field];
}
return null;
} | [
"public",
"function",
"getFieldDefinition",
"(",
"$",
"field",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"definition",
"[",
"$",
"field",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"definition",
"[",
"$",
"field",
"]",
";",
"}",
"... | Obtiene la definicion para este campo
@param $field
@return mixed|null | [
"Obtiene",
"la",
"definicion",
"para",
"este",
"campo"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L642-L651 | train |
manusreload/GLFramework | src/Model.php | Model.getFieldType | public function getFieldType($field)
{
$definition = $this->getFieldDefinition($field);
if ($definition && isset($definition['type'])) {
return $definition['type'];
}
} | php | public function getFieldType($field)
{
$definition = $this->getFieldDefinition($field);
if ($definition && isset($definition['type'])) {
return $definition['type'];
}
} | [
"public",
"function",
"getFieldType",
"(",
"$",
"field",
")",
"{",
"$",
"definition",
"=",
"$",
"this",
"->",
"getFieldDefinition",
"(",
"$",
"field",
")",
";",
"if",
"(",
"$",
"definition",
"&&",
"isset",
"(",
"$",
"definition",
"[",
"'type'",
"]",
")... | Obtiene el tipo para el campo
@param $field
@return mixed | [
"Obtiene",
"el",
"tipo",
"para",
"el",
"campo"
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L659-L665 | train |
manusreload/GLFramework | src/Model.php | Model.getStructureDifferences | public function getStructureDifferences($db, $drop = false)
{
$diff = new DBStructure();
$excepted = $diff->getDefinition($this);
return $diff->getStructureDifferences($db, $excepted, $drop);
} | php | public function getStructureDifferences($db, $drop = false)
{
$diff = new DBStructure();
$excepted = $diff->getDefinition($this);
return $diff->getStructureDifferences($db, $excepted, $drop);
} | [
"public",
"function",
"getStructureDifferences",
"(",
"$",
"db",
",",
"$",
"drop",
"=",
"false",
")",
"{",
"$",
"diff",
"=",
"new",
"DBStructure",
"(",
")",
";",
"$",
"excepted",
"=",
"$",
"diff",
"->",
"getDefinition",
"(",
"$",
"this",
")",
";",
"r... | Genera las diferencias entre este modelo y lo que hay
en la base de datos.
@param $db DatabaseManager
@param $drop bool
@return array | [
"Genera",
"las",
"diferencias",
"entre",
"este",
"modelo",
"y",
"lo",
"que",
"hay",
"en",
"la",
"base",
"de",
"datos",
"."
] | 6867bdf22482cff4e92adbba6849818860228104 | https://github.com/manusreload/GLFramework/blob/6867bdf22482cff4e92adbba6849818860228104/src/Model.php#L685-L690 | train |
Innodite/laravel5-scaffold | src/Innodite/Generator/Utils/ResponseManager.php | ResponseManager.makeResult | public static function makeResult($data, $message)
{
$result = array();
$result['flag'] = true;
$result['message'] = $message;
$result['data'] = $data;
return $result;
} | php | public static function makeResult($data, $message)
{
$result = array();
$result['flag'] = true;
$result['message'] = $message;
$result['data'] = $data;
return $result;
} | [
"public",
"static",
"function",
"makeResult",
"(",
"$",
"data",
",",
"$",
"message",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"$",
"result",
"[",
"'flag'",
"]",
"=",
"true",
";",
"$",
"result",
"[",
"'message'",
"]",
"=",
"$",
"message... | Generates result response object
@param mixed $data
@param string $message
@return array | [
"Generates",
"result",
"response",
"object"
] | fa6a0664674e176d1f170005b236fd03c73e868c | https://github.com/Innodite/laravel5-scaffold/blob/fa6a0664674e176d1f170005b236fd03c73e868c/src/Innodite/Generator/Utils/ResponseManager.php#L31-L39 | train |
googleapis/gax-php | src/Transport/RestTransport.php | RestTransport.build | public static function build($serviceAddress, $restConfigPath, array $config = [])
{
$config += [
'httpHandler' => null,
];
list($baseUri, $port) = self::normalizeServiceAddress($serviceAddress);
$requestBuilder = new RequestBuilder("$baseUri:$port", $restConfigPath);
$httpHandler = $config['httpHandler'] ?: self::buildHttpHandlerAsync();
return new RestTransport($requestBuilder, $httpHandler);
} | php | public static function build($serviceAddress, $restConfigPath, array $config = [])
{
$config += [
'httpHandler' => null,
];
list($baseUri, $port) = self::normalizeServiceAddress($serviceAddress);
$requestBuilder = new RequestBuilder("$baseUri:$port", $restConfigPath);
$httpHandler = $config['httpHandler'] ?: self::buildHttpHandlerAsync();
return new RestTransport($requestBuilder, $httpHandler);
} | [
"public",
"static",
"function",
"build",
"(",
"$",
"serviceAddress",
",",
"$",
"restConfigPath",
",",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"$",
"config",
"+=",
"[",
"'httpHandler'",
"=>",
"null",
",",
"]",
";",
"list",
"(",
"$",
"baseUri",
... | Builds a RestTransport.
@param string $serviceAddress
The address of the API remote host, for example "example.googleapis.com".
@param string $restConfigPath
Path to rest config file.
@param array $config {
Config options used to construct the gRPC transport.
@type callable $httpHandler A handler used to deliver PSR-7 requests.
}
@return RestTransport
@throws ValidationException | [
"Builds",
"a",
"RestTransport",
"."
] | 48387fb818c6882296710a2302a0aa973b99afb2 | https://github.com/googleapis/gax-php/blob/48387fb818c6882296710a2302a0aa973b99afb2/src/Transport/RestTransport.php#L85-L94 | train |
googleapis/gax-php | src/FixedSizeCollection.php | FixedSizeCollection.getCollectionSize | public function getCollectionSize()
{
$size = 0;
foreach ($this->pageList as $page) {
$size += $page->getPageElementCount();
}
return $size;
} | php | public function getCollectionSize()
{
$size = 0;
foreach ($this->pageList as $page) {
$size += $page->getPageElementCount();
}
return $size;
} | [
"public",
"function",
"getCollectionSize",
"(",
")",
"{",
"$",
"size",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"pageList",
"as",
"$",
"page",
")",
"{",
"$",
"size",
"+=",
"$",
"page",
"->",
"getPageElementCount",
"(",
")",
";",
"}",
"return... | Returns the number of elements in the collection. This will be
equal to the collectionSize parameter used at construction
unless there are no elements remaining to be retrieved.
@return int | [
"Returns",
"the",
"number",
"of",
"elements",
"in",
"the",
"collection",
".",
"This",
"will",
"be",
"equal",
"to",
"the",
"collectionSize",
"parameter",
"used",
"at",
"construction",
"unless",
"there",
"are",
"no",
"elements",
"remaining",
"to",
"be",
"retriev... | 48387fb818c6882296710a2302a0aa973b99afb2 | https://github.com/googleapis/gax-php/blob/48387fb818c6882296710a2302a0aa973b99afb2/src/FixedSizeCollection.php#L82-L89 | train |
googleapis/gax-php | src/FixedSizeCollection.php | FixedSizeCollection.getNextCollection | public function getNextCollection()
{
$lastPage = $this->getLastPage();
$nextPage = $lastPage->getNextPage($this->collectionSize);
return new FixedSizeCollection($nextPage, $this->collectionSize);
} | php | public function getNextCollection()
{
$lastPage = $this->getLastPage();
$nextPage = $lastPage->getNextPage($this->collectionSize);
return new FixedSizeCollection($nextPage, $this->collectionSize);
} | [
"public",
"function",
"getNextCollection",
"(",
")",
"{",
"$",
"lastPage",
"=",
"$",
"this",
"->",
"getLastPage",
"(",
")",
";",
"$",
"nextPage",
"=",
"$",
"lastPage",
"->",
"getNextPage",
"(",
"$",
"this",
"->",
"collectionSize",
")",
";",
"return",
"ne... | Retrieves the next FixedSizeCollection using one or more API calls.
@return FixedSizeCollection | [
"Retrieves",
"the",
"next",
"FixedSizeCollection",
"using",
"one",
"or",
"more",
"API",
"calls",
"."
] | 48387fb818c6882296710a2302a0aa973b99afb2 | https://github.com/googleapis/gax-php/blob/48387fb818c6882296710a2302a0aa973b99afb2/src/FixedSizeCollection.php#L118-L123 | train |
googleapis/gax-php | src/FixedSizeCollection.php | FixedSizeCollection.iterateCollections | public function iterateCollections()
{
$currentCollection = $this;
yield $this;
while ($currentCollection->hasNextCollection()) {
$currentCollection = $currentCollection->getNextCollection();
yield $currentCollection;
}
} | php | public function iterateCollections()
{
$currentCollection = $this;
yield $this;
while ($currentCollection->hasNextCollection()) {
$currentCollection = $currentCollection->getNextCollection();
yield $currentCollection;
}
} | [
"public",
"function",
"iterateCollections",
"(",
")",
"{",
"$",
"currentCollection",
"=",
"$",
"this",
";",
"yield",
"$",
"this",
";",
"while",
"(",
"$",
"currentCollection",
"->",
"hasNextCollection",
"(",
")",
")",
"{",
"$",
"currentCollection",
"=",
"$",
... | Returns an iterator over FixedSizeCollections, starting with this
and making API calls as required until all of the elements have
been retrieved.
@return Generator|FixedSizeCollection[] | [
"Returns",
"an",
"iterator",
"over",
"FixedSizeCollections",
"starting",
"with",
"this",
"and",
"making",
"API",
"calls",
"as",
"required",
"until",
"all",
"of",
"the",
"elements",
"have",
"been",
"retrieved",
"."
] | 48387fb818c6882296710a2302a0aa973b99afb2 | https://github.com/googleapis/gax-php/blob/48387fb818c6882296710a2302a0aa973b99afb2/src/FixedSizeCollection.php#L146-L154 | train |
googleapis/gax-php | src/LongRunning/Gapic/OperationsGapicClient.php | OperationsGapicClient.getOperation | public function getOperation($name, $optionalArgs = [])
{
$request = new GetOperationRequest();
$request->setName($name);
return $this->startCall(
'GetOperation',
Operation::class,
$optionalArgs,
$request
)->wait();
} | php | public function getOperation($name, $optionalArgs = [])
{
$request = new GetOperationRequest();
$request->setName($name);
return $this->startCall(
'GetOperation',
Operation::class,
$optionalArgs,
$request
)->wait();
} | [
"public",
"function",
"getOperation",
"(",
"$",
"name",
",",
"$",
"optionalArgs",
"=",
"[",
"]",
")",
"{",
"$",
"request",
"=",
"new",
"GetOperationRequest",
"(",
")",
";",
"$",
"request",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"return",
"$",
"... | Gets the latest state of a long-running operation. Clients can use this
method to poll the operation result at intervals as recommended by the API
service.
Sample code:
```
$options = [
'serviceAddress' => 'my-service-address',
'scopes' => ['my-service-scope'],
];
$operationsClient = new OperationsClient($options);
try {
$name = '';
$response = $operationsClient->getOperation($name);
} finally {
if (isset($operationsClient)) {
$operationsClient->close();
}
}
```
@param string $name The name of the operation resource.
@param array $optionalArgs {
Optional.
@type RetrySettings|array $retrySettings
Retry settings to use for this call. Can be a
{@see Google\ApiCore\RetrySettings} object, or an associative array
of retry settings parameters. See the documentation on
{@see Google\ApiCore\RetrySettings} for example usage.
}
@return \Google\LongRunning\Operation
@throws ApiException if the remote call fails
@experimental | [
"Gets",
"the",
"latest",
"state",
"of",
"a",
"long",
"-",
"running",
"operation",
".",
"Clients",
"can",
"use",
"this",
"method",
"to",
"poll",
"the",
"operation",
"result",
"at",
"intervals",
"as",
"recommended",
"by",
"the",
"API",
"service",
"."
] | 48387fb818c6882296710a2302a0aa973b99afb2 | https://github.com/googleapis/gax-php/blob/48387fb818c6882296710a2302a0aa973b99afb2/src/LongRunning/Gapic/OperationsGapicClient.php#L224-L235 | train |
googleapis/gax-php | src/LongRunning/Gapic/OperationsGapicClient.php | OperationsGapicClient.deleteOperation | public function deleteOperation($name, $optionalArgs = [])
{
$request = new DeleteOperationRequest();
$request->setName($name);
return $this->startCall(
'DeleteOperation',
GPBEmpty::class,
$optionalArgs,
$request
)->wait();
} | php | public function deleteOperation($name, $optionalArgs = [])
{
$request = new DeleteOperationRequest();
$request->setName($name);
return $this->startCall(
'DeleteOperation',
GPBEmpty::class,
$optionalArgs,
$request
)->wait();
} | [
"public",
"function",
"deleteOperation",
"(",
"$",
"name",
",",
"$",
"optionalArgs",
"=",
"[",
"]",
")",
"{",
"$",
"request",
"=",
"new",
"DeleteOperationRequest",
"(",
")",
";",
"$",
"request",
"->",
"setName",
"(",
"$",
"name",
")",
";",
"return",
"$... | Deletes a long-running operation. This method indicates that the client is
no longer interested in the operation result. It does not cancel the
operation. If the server doesn't support this method, it returns
`google.rpc.Code.UNIMPLEMENTED`.
Sample code:
```
$options = [
'serviceAddress' => 'my-service-address',
'scopes' => ['my-service-scope'],
];
$operationsClient = new OperationsClient($options);
try {
$name = '';
$operationsClient->deleteOperation($name);
} finally {
if (isset($operationsClient)) {
$operationsClient->close();
}
}
```
@param string $name The name of the operation resource to be deleted.
@param array $optionalArgs {
Optional.
@type RetrySettings|array $retrySettings
Retry settings to use for this call. Can be a
{@see Google\ApiCore\RetrySettings} object, or an associative array
of retry settings parameters. See the documentation on
{@see Google\ApiCore\RetrySettings} for example usage.
}
@throws ApiException if the remote call fails
@experimental | [
"Deletes",
"a",
"long",
"-",
"running",
"operation",
".",
"This",
"method",
"indicates",
"that",
"the",
"client",
"is",
"no",
"longer",
"interested",
"in",
"the",
"operation",
"result",
".",
"It",
"does",
"not",
"cancel",
"the",
"operation",
".",
"If",
"th... | 48387fb818c6882296710a2302a0aa973b99afb2 | https://github.com/googleapis/gax-php/blob/48387fb818c6882296710a2302a0aa973b99afb2/src/LongRunning/Gapic/OperationsGapicClient.php#L413-L424 | train |
googleapis/gax-php | src/ApiException.php | ApiException.create | private static function create($basicMessage, $rpcCode, $metadata, array $decodedMetadata, $previous = null)
{
$rpcStatus = ApiStatus::statusFromRpcCode($rpcCode);
$messageData = [
'message' => $basicMessage,
'code' => $rpcCode,
'status' => $rpcStatus,
'details' => $decodedMetadata
];
$message = json_encode($messageData, JSON_PRETTY_PRINT);
return new ApiException($message, $rpcCode, $rpcStatus, [
'previous' => $previous,
'metadata' => $metadata,
'basicMessage' => $basicMessage,
]);
} | php | private static function create($basicMessage, $rpcCode, $metadata, array $decodedMetadata, $previous = null)
{
$rpcStatus = ApiStatus::statusFromRpcCode($rpcCode);
$messageData = [
'message' => $basicMessage,
'code' => $rpcCode,
'status' => $rpcStatus,
'details' => $decodedMetadata
];
$message = json_encode($messageData, JSON_PRETTY_PRINT);
return new ApiException($message, $rpcCode, $rpcStatus, [
'previous' => $previous,
'metadata' => $metadata,
'basicMessage' => $basicMessage,
]);
} | [
"private",
"static",
"function",
"create",
"(",
"$",
"basicMessage",
",",
"$",
"rpcCode",
",",
"$",
"metadata",
",",
"array",
"$",
"decodedMetadata",
",",
"$",
"previous",
"=",
"null",
")",
"{",
"$",
"rpcStatus",
"=",
"ApiStatus",
"::",
"statusFromRpcCode",
... | Construct an ApiException with a useful message, including decoded metadata.
@param string $basicMessage
@param int $rpcCode
@param mixed[]|RepeatedField $metadata
@param array $decodedMetadata
@param \Exception|null $previous
@return ApiException | [
"Construct",
"an",
"ApiException",
"with",
"a",
"useful",
"message",
"including",
"decoded",
"metadata",
"."
] | 48387fb818c6882296710a2302a0aa973b99afb2 | https://github.com/googleapis/gax-php/blob/48387fb818c6882296710a2302a0aa973b99afb2/src/ApiException.php#L127-L144 | train |
googleapis/gax-php | src/Transport/GrpcTransport.php | GrpcTransport.build | public static function build($serviceAddress, array $config = [])
{
self::validateGrpcSupport();
$config += [
'stubOpts' => [],
'channel' => null,
'interceptors' => [],
];
list($addr, $port) = self::normalizeServiceAddress($serviceAddress);
$host = "$addr:$port";
$stubOpts = $config['stubOpts'];
// Set the required 'credentials' key in stubOpts if it is not already set. Use
// array_key_exists because null is a valid value.
if (!array_key_exists('credentials', $stubOpts)) {
$stubOpts['credentials'] = ChannelCredentials::createSsl();
}
$channel = $config['channel'];
if (!is_null($channel) && !($channel instanceof Channel)) {
throw new ValidationException(
"Channel argument to GrpcTransport must be of type \Grpc\Channel, " .
"instead got: " . print_r($channel, true)
);
}
try {
return new GrpcTransport($host, $stubOpts, $channel, $config['interceptors']);
} catch (Exception $ex) {
throw new ValidationException(
"Failed to build GrpcTransport: " . $ex->getMessage(),
$ex->getCode(),
$ex
);
}
} | php | public static function build($serviceAddress, array $config = [])
{
self::validateGrpcSupport();
$config += [
'stubOpts' => [],
'channel' => null,
'interceptors' => [],
];
list($addr, $port) = self::normalizeServiceAddress($serviceAddress);
$host = "$addr:$port";
$stubOpts = $config['stubOpts'];
// Set the required 'credentials' key in stubOpts if it is not already set. Use
// array_key_exists because null is a valid value.
if (!array_key_exists('credentials', $stubOpts)) {
$stubOpts['credentials'] = ChannelCredentials::createSsl();
}
$channel = $config['channel'];
if (!is_null($channel) && !($channel instanceof Channel)) {
throw new ValidationException(
"Channel argument to GrpcTransport must be of type \Grpc\Channel, " .
"instead got: " . print_r($channel, true)
);
}
try {
return new GrpcTransport($host, $stubOpts, $channel, $config['interceptors']);
} catch (Exception $ex) {
throw new ValidationException(
"Failed to build GrpcTransport: " . $ex->getMessage(),
$ex->getCode(),
$ex
);
}
} | [
"public",
"static",
"function",
"build",
"(",
"$",
"serviceAddress",
",",
"array",
"$",
"config",
"=",
"[",
"]",
")",
"{",
"self",
"::",
"validateGrpcSupport",
"(",
")",
";",
"$",
"config",
"+=",
"[",
"'stubOpts'",
"=>",
"[",
"]",
",",
"'channel'",
"=>... | Builds a GrpcTransport.
@param string $serviceAddress
The address of the API remote host, for example "example.googleapis.com. May also
include the port, for example "example.googleapis.com:443"
@param array $config {
Config options used to construct the gRPC transport.
@type array $stubOpts Options used to construct the gRPC stub.
@type Channel $channel Grpc channel to be used.
@type UnaryInterceptorInterface[] $interceptors *EXPERIMENTAL* Interceptor support, required until
gRPC interceptors are available.
}
@return GrpcTransport
@throws ValidationException | [
"Builds",
"a",
"GrpcTransport",
"."
] | 48387fb818c6882296710a2302a0aa973b99afb2 | https://github.com/googleapis/gax-php/blob/48387fb818c6882296710a2302a0aa973b99afb2/src/Transport/GrpcTransport.php#L98-L130 | train |
jolicode/JoliNotif | src/Notifier/CliBasedNotifier.php | CliBasedNotifier.isBinaryAvailable | protected function isBinaryAvailable(): bool
{
if (OsHelper::isUnix()) {
// Do not use the 'which' program to check if a binary exists.
// See also http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
$process = new Process([
'sh',
'-c',
'command -v $0',
$this->getBinary(),
]);
} else {
// 'where' is available on Windows since Server 2003
$process = new Process([
'where',
$this->getBinary(),
]);
}
$process->run();
return $process->isSuccessful();
} | php | protected function isBinaryAvailable(): bool
{
if (OsHelper::isUnix()) {
// Do not use the 'which' program to check if a binary exists.
// See also http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script
$process = new Process([
'sh',
'-c',
'command -v $0',
$this->getBinary(),
]);
} else {
// 'where' is available on Windows since Server 2003
$process = new Process([
'where',
$this->getBinary(),
]);
}
$process->run();
return $process->isSuccessful();
} | [
"protected",
"function",
"isBinaryAvailable",
"(",
")",
":",
"bool",
"{",
"if",
"(",
"OsHelper",
"::",
"isUnix",
"(",
")",
")",
"{",
"// Do not use the 'which' program to check if a binary exists.",
"// See also http://stackoverflow.com/questions/592620/check-if-a-program-exists-... | Check whether a binary is available. | [
"Check",
"whether",
"a",
"binary",
"is",
"available",
"."
] | 0b5f786c5f181b3916df616ca191892713257662 | https://github.com/jolicode/JoliNotif/blob/0b5f786c5f181b3916df616ca191892713257662/src/Notifier/CliBasedNotifier.php#L106-L128 | train |
jolicode/JoliNotif | src/Util/PharExtractor.php | PharExtractor.extractFile | public static function extractFile(string $filePath, bool $overwrite = false): string
{
$pharPath = \Phar::running(false);
if (empty($pharPath)) {
return '';
}
$relativeFilePath = substr($filePath, strpos($filePath, $pharPath) + strlen($pharPath) + 1);
$tmpDir = sys_get_temp_dir().'/jolinotif';
$extractedFilePath = $tmpDir.'/'.$relativeFilePath;
if (!file_exists($extractedFilePath) || $overwrite) {
$phar = new \Phar($pharPath);
$phar->extractTo($tmpDir, $relativeFilePath, $overwrite);
}
return $extractedFilePath;
} | php | public static function extractFile(string $filePath, bool $overwrite = false): string
{
$pharPath = \Phar::running(false);
if (empty($pharPath)) {
return '';
}
$relativeFilePath = substr($filePath, strpos($filePath, $pharPath) + strlen($pharPath) + 1);
$tmpDir = sys_get_temp_dir().'/jolinotif';
$extractedFilePath = $tmpDir.'/'.$relativeFilePath;
if (!file_exists($extractedFilePath) || $overwrite) {
$phar = new \Phar($pharPath);
$phar->extractTo($tmpDir, $relativeFilePath, $overwrite);
}
return $extractedFilePath;
} | [
"public",
"static",
"function",
"extractFile",
"(",
"string",
"$",
"filePath",
",",
"bool",
"$",
"overwrite",
"=",
"false",
")",
":",
"string",
"{",
"$",
"pharPath",
"=",
"\\",
"Phar",
"::",
"running",
"(",
"false",
")",
";",
"if",
"(",
"empty",
"(",
... | Extract the file from the phar archive to make it accessible for native commands.
The absolute file path to extract should be passed in the first argument. | [
"Extract",
"the",
"file",
"from",
"the",
"phar",
"archive",
"to",
"make",
"it",
"accessible",
"for",
"native",
"commands",
"."
] | 0b5f786c5f181b3916df616ca191892713257662 | https://github.com/jolicode/JoliNotif/blob/0b5f786c5f181b3916df616ca191892713257662/src/Util/PharExtractor.php#L29-L47 | train |
kahlan/kahlan | src/Jit/TokenStream.php | TokenStream._getToken | protected function _getToken($index, $type)
{
if ($index === null) {
$index = $this->_current;
}
return isset($this->_data[$index]) ? $this->_data[$index][$type] : null;
} | php | protected function _getToken($index, $type)
{
if ($index === null) {
$index = $this->_current;
}
return isset($this->_data[$index]) ? $this->_data[$index][$type] : null;
} | [
"protected",
"function",
"_getToken",
"(",
"$",
"index",
",",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"index",
"===",
"null",
")",
"{",
"$",
"index",
"=",
"$",
"this",
"->",
"_current",
";",
"}",
"return",
"isset",
"(",
"$",
"this",
"->",
"_data",
... | Returns the current token value.
@param integer $index Token position, if none given, consider the current iteration position.
@return string|null | [
"Returns",
"the",
"current",
"token",
"value",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Jit/TokenStream.php#L108-L114 | train |
kahlan/kahlan | src/Jit/TokenStream.php | TokenStream.getName | public function getName($index = null)
{
$type = $this->getType($index);
return is_int($type) ? token_name($type) : null;
} | php | public function getName($index = null)
{
$type = $this->getType($index);
return is_int($type) ? token_name($type) : null;
} | [
"public",
"function",
"getName",
"(",
"$",
"index",
"=",
"null",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"getType",
"(",
"$",
"index",
")",
";",
"return",
"is_int",
"(",
"$",
"type",
")",
"?",
"token_name",
"(",
"$",
"type",
")",
":",
"nul... | Returns the token type name.
@param integer $index Token position, if none given, consider the current iteration position.
@return string|null | [
"Returns",
"the",
"token",
"type",
"name",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Jit/TokenStream.php#L122-L126 | train |
kahlan/kahlan | src/Jit/TokenStream.php | TokenStream.current | public function current($token = false)
{
if (!$this->valid()) {
return null;
}
return $token ? $this->_data[$this->_current] : $this->_data[$this->_current][1];
} | php | public function current($token = false)
{
if (!$this->valid()) {
return null;
}
return $token ? $this->_data[$this->_current] : $this->_data[$this->_current][1];
} | [
"public",
"function",
"current",
"(",
"$",
"token",
"=",
"false",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"token",
"?",
"$",
"this",
"->",
"_data",
"[",
"$",
"this",
"... | Returns the current token or the token value.
@param boolean If `true` returns the token array. Returns the token value otherwise.
@return array|string | [
"Returns",
"the",
"current",
"token",
"or",
"the",
"token",
"value",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Jit/TokenStream.php#L176-L182 | train |
kahlan/kahlan | src/Jit/TokenStream.php | TokenStream.next | public function next($type = false)
{
if ($type === false || $type === true) {
$this->_current++;
return $this->current($type);
}
$content = '';
$start = $this->_current++;
$count = $this->count();
$list = array_fill_keys((array) $type, true);
while ($this->_current < $count) {
$content .= $this->_data[$this->_current][1];
if (isset($list[$this->_data[$this->_current][0]])) {
return $content;
}
$this->_current++;
}
$this->_current = $start;
} | php | public function next($type = false)
{
if ($type === false || $type === true) {
$this->_current++;
return $this->current($type);
}
$content = '';
$start = $this->_current++;
$count = $this->count();
$list = array_fill_keys((array) $type, true);
while ($this->_current < $count) {
$content .= $this->_data[$this->_current][1];
if (isset($list[$this->_data[$this->_current][0]])) {
return $content;
}
$this->_current++;
}
$this->_current = $start;
} | [
"public",
"function",
"next",
"(",
"$",
"type",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"type",
"===",
"false",
"||",
"$",
"type",
"===",
"true",
")",
"{",
"$",
"this",
"->",
"_current",
"++",
";",
"return",
"$",
"this",
"->",
"current",
"(",
"$"... | Move to the next token of a given type.
@param mixed $type Token type to search for.
@return string|null Returns the skipped text content (the current is not saved). | [
"Move",
"to",
"the",
"next",
"token",
"of",
"a",
"given",
"type",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Jit/TokenStream.php#L190-L210 | train |
kahlan/kahlan | src/Jit/TokenStream.php | TokenStream.nextSequence | public function nextSequence($sequence)
{
$start = $this->_current;
$result = '';
$len = strlen($sequence);
$lastToken = substr($sequence, -1);
while (($content = $this->next($lastToken)) !== null) {
$result .= $content;
if (strlen($result) >= $len && substr_compare($result, $sequence, -$len, $len) === 0) {
return $result;
}
}
$this->_current = $start;
} | php | public function nextSequence($sequence)
{
$start = $this->_current;
$result = '';
$len = strlen($sequence);
$lastToken = substr($sequence, -1);
while (($content = $this->next($lastToken)) !== null) {
$result .= $content;
if (strlen($result) >= $len && substr_compare($result, $sequence, -$len, $len) === 0) {
return $result;
}
}
$this->_current = $start;
} | [
"public",
"function",
"nextSequence",
"(",
"$",
"sequence",
")",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"_current",
";",
"$",
"result",
"=",
"''",
";",
"$",
"len",
"=",
"strlen",
"(",
"$",
"sequence",
")",
";",
"$",
"lastToken",
"=",
"substr",
... | Moves to the next sequence of tokens.
@param string $type Tokens sequence to search for.
@return array|null Returns the skipped text content (the current is not saved). | [
"Moves",
"to",
"the",
"next",
"sequence",
"of",
"tokens",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Jit/TokenStream.php#L218-L232 | train |
kahlan/kahlan | src/Jit/TokenStream.php | TokenStream.nextMatchingBracket | public function nextMatchingBracket()
{
if (!$this->valid()) {
return;
}
$matches = ['(' => ')', '{' => '}', '[' => ']'];
$token = $this->current();
$content = $open = $token[0];
if (!isset($matches[$open])) {
return;
}
$level = 1;
$close = $matches[$open];
$start = $this->_current;
$count = $this->count();
$this->_current++;
while ($this->_current < $count) {
$type = $this->_data[$this->_current][0];
if ($type === $close) {
$level--;
} elseif ($type === $open) {
$level++;
}
$content .= $this->_data[$this->_current][1];
if ($level === 0) {
return $content;
}
$this->_current++;
}
$this->_current = $start;
} | php | public function nextMatchingBracket()
{
if (!$this->valid()) {
return;
}
$matches = ['(' => ')', '{' => '}', '[' => ']'];
$token = $this->current();
$content = $open = $token[0];
if (!isset($matches[$open])) {
return;
}
$level = 1;
$close = $matches[$open];
$start = $this->_current;
$count = $this->count();
$this->_current++;
while ($this->_current < $count) {
$type = $this->_data[$this->_current][0];
if ($type === $close) {
$level--;
} elseif ($type === $open) {
$level++;
}
$content .= $this->_data[$this->_current][1];
if ($level === 0) {
return $content;
}
$this->_current++;
}
$this->_current = $start;
} | [
"public",
"function",
"nextMatchingBracket",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"valid",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
"matches",
"=",
"[",
"'('",
"=>",
"')'",
",",
"'{'",
"=>",
"'}'",
",",
"'['",
"=>",
"']'",
"]",
... | Move to the next matching bracket.
@return string|null Returns the skipped text content. | [
"Move",
"to",
"the",
"next",
"matching",
"bracket",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Jit/TokenStream.php#L239-L274 | train |
kahlan/kahlan | src/Jit/TokenStream.php | TokenStream.skipWhitespaces | public function skipWhitespaces($skipComment = false)
{
$skips = [T_WHITESPACE => true];
if (!$skipComment) {
$skips += [T_COMMENT => true, T_DOC_COMMENT => true];
}
$this->_current++;
return $this->_skip($skips);
} | php | public function skipWhitespaces($skipComment = false)
{
$skips = [T_WHITESPACE => true];
if (!$skipComment) {
$skips += [T_COMMENT => true, T_DOC_COMMENT => true];
}
$this->_current++;
return $this->_skip($skips);
} | [
"public",
"function",
"skipWhitespaces",
"(",
"$",
"skipComment",
"=",
"false",
")",
"{",
"$",
"skips",
"=",
"[",
"T_WHITESPACE",
"=>",
"true",
"]",
";",
"if",
"(",
"!",
"$",
"skipComment",
")",
"{",
"$",
"skips",
"+=",
"[",
"T_COMMENT",
"=>",
"true",
... | Skips whitespaces and comments next to the current position.
@param boolean $skipComment Skip docblocks as well.
@return string The skipped string. | [
"Skips",
"whitespaces",
"and",
"comments",
"next",
"to",
"the",
"current",
"position",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Jit/TokenStream.php#L282-L292 | train |
kahlan/kahlan | src/Jit/TokenStream.php | TokenStream._skip | protected function _skip($skips)
{
$skipped = '';
$count = $this->count();
while ($this->_current < $count) {
if (!isset($skips[$this->_data[$this->_current][0]])) {
break;
}
$skipped .= $this->_data[$this->_current][1];
$this->_current++;
}
return $skipped;
} | php | protected function _skip($skips)
{
$skipped = '';
$count = $this->count();
while ($this->_current < $count) {
if (!isset($skips[$this->_data[$this->_current][0]])) {
break;
}
$skipped .= $this->_data[$this->_current][1];
$this->_current++;
}
return $skipped;
} | [
"protected",
"function",
"_skip",
"(",
"$",
"skips",
")",
"{",
"$",
"skipped",
"=",
"''",
";",
"$",
"count",
"=",
"$",
"this",
"->",
"count",
"(",
")",
";",
"while",
"(",
"$",
"this",
"->",
"_current",
"<",
"$",
"count",
")",
"{",
"if",
"(",
"!... | Skips elements until an element doesn't match the elements in the passed array.
@param array $skips The elements array to skip.
@return string The skipped string. | [
"Skips",
"elements",
"until",
"an",
"element",
"doesn",
"t",
"match",
"the",
"elements",
"in",
"the",
"passed",
"array",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Jit/TokenStream.php#L312-L324 | train |
kahlan/kahlan | src/Jit/TokenStream.php | TokenStream.seek | public function seek($index, $token = false)
{
$this->_current = (int) $index;
return $this->current($token);
} | php | public function seek($index, $token = false)
{
$this->_current = (int) $index;
return $this->current($token);
} | [
"public",
"function",
"seek",
"(",
"$",
"index",
",",
"$",
"token",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"_current",
"=",
"(",
"int",
")",
"$",
"index",
";",
"return",
"$",
"this",
"->",
"current",
"(",
"$",
"token",
")",
";",
"}"
] | Move to a specific index.
@param integer $index New position
@param boolean If `true` returns the token array. Returns the token value otherwise.
@return array|string | [
"Move",
"to",
"a",
"specific",
"index",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Jit/TokenStream.php#L345-L349 | train |
kahlan/kahlan | src/Jit/TokenStream.php | TokenStream.source | public function source($start = null, $end = null)
{
$source = '';
$start = (int) $start;
$end = $end === null ? ($this->count() - 1) : (int) $end;
for ($i = $start; $i <= $end; $i++) {
$source .= $this->_data[$i][1];
}
return $source;
} | php | public function source($start = null, $end = null)
{
$source = '';
$start = (int) $start;
$end = $end === null ? ($this->count() - 1) : (int) $end;
for ($i = $start; $i <= $end; $i++) {
$source .= $this->_data[$i][1];
}
return $source;
} | [
"public",
"function",
"source",
"(",
"$",
"start",
"=",
"null",
",",
"$",
"end",
"=",
"null",
")",
"{",
"$",
"source",
"=",
"''",
";",
"$",
"start",
"=",
"(",
"int",
")",
"$",
"start",
";",
"$",
"end",
"=",
"$",
"end",
"===",
"null",
"?",
"("... | Returns the stream content.
@param mixed $start Start offset
@param mixed $end End offset
@return string | [
"Returns",
"the",
"stream",
"content",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Jit/TokenStream.php#L358-L367 | train |
kahlan/kahlan | src/Allow.php | Allow.toReceive | public function toReceive()
{
if (!$this->_isClass) {
throw new Exception("Error `toReceive()` are only available on classes/instances not functions.");
}
return $this->_method = $this->_stub->method(func_get_args());
} | php | public function toReceive()
{
if (!$this->_isClass) {
throw new Exception("Error `toReceive()` are only available on classes/instances not functions.");
}
return $this->_method = $this->_stub->method(func_get_args());
} | [
"public",
"function",
"toReceive",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_isClass",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Error `toReceive()` are only available on classes/instances not functions.\"",
")",
";",
"}",
"return",
"$",
"this",
"->... | Stub a chain of methods.
@param string $expected the method to be stubbed or a chain of methods.
@return self. | [
"Stub",
"a",
"chain",
"of",
"methods",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Allow.php#L64-L70 | train |
kahlan/kahlan | src/Reporter/Coverage/Exporter/Clover.php | Clover.write | public static function write($options)
{
$defaults = [
'file' => null
];
$options += $defaults;
if (!$options['file']) {
throw new RuntimeException("Missing file name");
}
return file_put_contents($options['file'], static::export($options));
} | php | public static function write($options)
{
$defaults = [
'file' => null
];
$options += $defaults;
if (!$options['file']) {
throw new RuntimeException("Missing file name");
}
return file_put_contents($options['file'], static::export($options));
} | [
"public",
"static",
"function",
"write",
"(",
"$",
"options",
")",
"{",
"$",
"defaults",
"=",
"[",
"'file'",
"=>",
"null",
"]",
";",
"$",
"options",
"+=",
"$",
"defaults",
";",
"if",
"(",
"!",
"$",
"options",
"[",
"'file'",
"]",
")",
"{",
"throw",
... | Writes a coverage to an ouput file.
@param array $options The option where the possible values are:
-`'file'` _string_: The output file name.
@return boolean | [
"Writes",
"a",
"coverage",
"to",
"an",
"ouput",
"file",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Reporter/Coverage/Exporter/Clover.php#L16-L28 | train |
kahlan/kahlan | src/Reporter/Coverage/Exporter/Clover.php | Clover._exportFile | protected static function _exportFile($xmlDocument, $file, $data)
{
$xmlFile = $xmlDocument->createElement('file');
$xmlFile->setAttribute('name', $file);
foreach ($data as $line => $node) {
$xmlLine = $xmlDocument->createElement('line');
$xmlLine->setAttribute('num', $line + 1);
$xmlLine->setAttribute('type', 'stmt');
$xmlLine->setAttribute('count', $data[$line]);
$xmlFile->appendChild($xmlLine);
}
return $xmlFile;
} | php | protected static function _exportFile($xmlDocument, $file, $data)
{
$xmlFile = $xmlDocument->createElement('file');
$xmlFile->setAttribute('name', $file);
foreach ($data as $line => $node) {
$xmlLine = $xmlDocument->createElement('line');
$xmlLine->setAttribute('num', $line + 1);
$xmlLine->setAttribute('type', 'stmt');
$xmlLine->setAttribute('count', $data[$line]);
$xmlFile->appendChild($xmlLine);
}
return $xmlFile;
} | [
"protected",
"static",
"function",
"_exportFile",
"(",
"$",
"xmlDocument",
",",
"$",
"file",
",",
"$",
"data",
")",
"{",
"$",
"xmlFile",
"=",
"$",
"xmlDocument",
"->",
"createElement",
"(",
"'file'",
")",
";",
"$",
"xmlFile",
"->",
"setAttribute",
"(",
"... | Export the coverage of a file.
@return object The XML file node. | [
"Export",
"the",
"coverage",
"of",
"a",
"file",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Reporter/Coverage/Exporter/Clover.php#L74-L86 | train |
kahlan/kahlan | src/Reporter/Coverage/Exporter/Clover.php | Clover._exportMetrics | protected static function _exportMetrics($xmlDocument, $metrics)
{
$data = $metrics->data();
$xmlMetrics = $xmlDocument->createElement('metrics');
$xmlMetrics->setAttribute('loc', $data['loc']);
$xmlMetrics->setAttribute('ncloc', $data['nlloc']);
$xmlMetrics->setAttribute('statements', $data['lloc']);
$xmlMetrics->setAttribute('coveredstatements', $data['cloc']);
return $xmlMetrics;
} | php | protected static function _exportMetrics($xmlDocument, $metrics)
{
$data = $metrics->data();
$xmlMetrics = $xmlDocument->createElement('metrics');
$xmlMetrics->setAttribute('loc', $data['loc']);
$xmlMetrics->setAttribute('ncloc', $data['nlloc']);
$xmlMetrics->setAttribute('statements', $data['lloc']);
$xmlMetrics->setAttribute('coveredstatements', $data['cloc']);
return $xmlMetrics;
} | [
"protected",
"static",
"function",
"_exportMetrics",
"(",
"$",
"xmlDocument",
",",
"$",
"metrics",
")",
"{",
"$",
"data",
"=",
"$",
"metrics",
"->",
"data",
"(",
")",
";",
"$",
"xmlMetrics",
"=",
"$",
"xmlDocument",
"->",
"createElement",
"(",
"'metrics'",... | Export the coverage of a metrics.
@param object $xmlDocument The DOMDocument root node instance.
@return object The XML file node. | [
"Export",
"the",
"coverage",
"of",
"a",
"metrics",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Reporter/Coverage/Exporter/Clover.php#L94-L103 | train |
kahlan/kahlan | src/Code/Code.php | Code.run | public static function run($callable, $timeout = 0)
{
if (!is_callable($callable)) {
throw new InvalidArgumentException();
}
$timeout = (integer) $timeout;
if (!function_exists('pcntl_signal')) {
throw new Exception("PCNTL threading is not supported by your system.");
}
pcntl_signal(SIGALRM, function ($signal) use ($timeout) {
throw new TimeoutException("Timeout reached, execution aborted after {$timeout} second(s).");
}, true);
pcntl_alarm($timeout);
$result = null;
try {
$result = $callable();
pcntl_alarm(0);
} catch (Throwable $e) {
pcntl_alarm(0);
throw $e;
} catch (Exception $e) {
pcntl_alarm(0);
throw $e;
}
return $result;
} | php | public static function run($callable, $timeout = 0)
{
if (!is_callable($callable)) {
throw new InvalidArgumentException();
}
$timeout = (integer) $timeout;
if (!function_exists('pcntl_signal')) {
throw new Exception("PCNTL threading is not supported by your system.");
}
pcntl_signal(SIGALRM, function ($signal) use ($timeout) {
throw new TimeoutException("Timeout reached, execution aborted after {$timeout} second(s).");
}, true);
pcntl_alarm($timeout);
$result = null;
try {
$result = $callable();
pcntl_alarm(0);
} catch (Throwable $e) {
pcntl_alarm(0);
throw $e;
} catch (Exception $e) {
pcntl_alarm(0);
throw $e;
}
return $result;
} | [
"public",
"static",
"function",
"run",
"(",
"$",
"callable",
",",
"$",
"timeout",
"=",
"0",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callable",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
")",
";",
"}",
"$",
"timeout",
... | Executes a callable until a timeout is reached or the callable returns `true`.
@param Callable $callable The callable to execute.
@param integer $timeout The timeout value.
@return mixed | [
"Executes",
"a",
"callable",
"until",
"a",
"timeout",
"is",
"reached",
"or",
"the",
"callable",
"returns",
"true",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Code/Code.php#L17-L49 | train |
kahlan/kahlan | src/Code/Code.php | Code.spin | public static function spin($callable, $timeout = 0, $delay = 100000)
{
if (!is_callable($callable)) {
throw new InvalidArgumentException();
}
$closure = function () use ($callable, $timeout, $delay) {
$timeout = (float) $timeout;
$start = microtime(true);
do {
if ($result = $callable()) {
return $result;
}
usleep($delay);
$current = microtime(true);
} while ($current - $start < $timeout);
throw new TimeoutException("Timeout reached, execution aborted after {$timeout} second(s).");
};
if (!function_exists('pcntl_signal')) {
return $closure();
}
return static::run($closure, $timeout);
} | php | public static function spin($callable, $timeout = 0, $delay = 100000)
{
if (!is_callable($callable)) {
throw new InvalidArgumentException();
}
$closure = function () use ($callable, $timeout, $delay) {
$timeout = (float) $timeout;
$start = microtime(true);
do {
if ($result = $callable()) {
return $result;
}
usleep($delay);
$current = microtime(true);
} while ($current - $start < $timeout);
throw new TimeoutException("Timeout reached, execution aborted after {$timeout} second(s).");
};
if (!function_exists('pcntl_signal')) {
return $closure();
}
return static::run($closure, $timeout);
} | [
"public",
"static",
"function",
"spin",
"(",
"$",
"callable",
",",
"$",
"timeout",
"=",
"0",
",",
"$",
"delay",
"=",
"100000",
")",
"{",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"callable",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"("... | Executes a callable in a loop until a timeout is reached or the callable returns `true`.
@param Callable $callable The callable to execute.
@param integer $timeout The timeout value.
@return mixed | [
"Executes",
"a",
"callable",
"in",
"a",
"loop",
"until",
"a",
"timeout",
"is",
"reached",
"or",
"the",
"callable",
"returns",
"true",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Code/Code.php#L58-L83 | train |
kahlan/kahlan | src/Plugin/Quit.php | Quit.quit | public static function quit($status = 0)
{
if (static::enabled()) {
exit($status);
}
if (!is_numeric($status)) {
throw new QuitException('Exit statement occurred with message: ' . $status, 0);
}
throw new QuitException('Exit statement occurred', $status);
} | php | public static function quit($status = 0)
{
if (static::enabled()) {
exit($status);
}
if (!is_numeric($status)) {
throw new QuitException('Exit statement occurred with message: ' . $status, 0);
}
throw new QuitException('Exit statement occurred', $status);
} | [
"public",
"static",
"function",
"quit",
"(",
"$",
"status",
"=",
"0",
")",
"{",
"if",
"(",
"static",
"::",
"enabled",
"(",
")",
")",
"{",
"exit",
"(",
"$",
"status",
")",
";",
"}",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"status",
")",
")",
"{"... | Run a controlled quit statement.
@param integer|string $status Use 0 for a successful exit.
@throws Kahlan\QuitException Only if disableed is `true`. | [
"Run",
"a",
"controlled",
"quit",
"statement",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Plugin/Quit.php#L45-L54 | train |
kahlan/kahlan | src/Block.php | Block.process | public function process(&$return = null)
{
if ($this->_passed === null) {
$this->_process();
}
$return = $this->_return;
return $this->_passed;
} | php | public function process(&$return = null)
{
if ($this->_passed === null) {
$this->_process();
}
$return = $this->_return;
return $this->_passed;
} | [
"public",
"function",
"process",
"(",
"&",
"$",
"return",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_passed",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"_process",
"(",
")",
";",
"}",
"$",
"return",
"=",
"$",
"this",
"->",
"_return"... | Checks if all test passed.
@return boolean Returns `true` if no error occurred, `false` otherwise. | [
"Checks",
"if",
"all",
"test",
"passed",
"."
] | b0341a59cefd2697f6e104bbcf045ee36a189ea2 | https://github.com/kahlan/kahlan/blob/b0341a59cefd2697f6e104bbcf045ee36a189ea2/src/Block.php#L205-L212 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.