id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
44,100 | OXID-eSales/paypal | Core/PayPalService.php | PayPalService.getExpressCheckoutDetails | public function getExpressCheckoutDetails($request)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseGetExpressCheckoutDetails::class);
$response->setData($caller->call('GetExpressCheckoutDetails'));
return $response;
} | php | public function getExpressCheckoutDetails($request)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseGetExpressCheckoutDetails::class);
$response->setData($caller->call('GetExpressCheckoutDetails'));
return $response;
} | [
"public",
"function",
"getExpressCheckoutDetails",
"(",
"$",
"request",
")",
"{",
"$",
"caller",
"=",
"$",
"this",
"->",
"getCaller",
"(",
")",
";",
"$",
"caller",
"->",
"setRequest",
"(",
"$",
"request",
")",
";",
"$",
"response",
"=",
"oxNew",
"(",
"... | Executes "GetExpressCheckoutDetails". Returns response object from PayPal.
@param \OxidEsales\PayPalModule\Model\PayPalRequest\PayPalRequest $request
@return \OxidEsales\PayPalModule\Model\Response\ResponseGetExpressCheckoutDetails | [
"Executes",
"GetExpressCheckoutDetails",
".",
"Returns",
"response",
"object",
"from",
"PayPal",
"."
] | ca9adba6e8312062449b53e7bda4a513c6b8c250 | https://github.com/OXID-eSales/paypal/blob/ca9adba6e8312062449b53e7bda4a513c6b8c250/Core/PayPalService.php#L173-L182 |
44,101 | OXID-eSales/paypal | Core/PayPalService.php | PayPalService.doExpressCheckoutPayment | public function doExpressCheckoutPayment($request)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoExpressCheckoutPayment::class);
$response->setData($caller->call('DoExpressCheckoutPayment'));
return $response;
} | php | public function doExpressCheckoutPayment($request)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoExpressCheckoutPayment::class);
$response->setData($caller->call('DoExpressCheckoutPayment'));
return $response;
} | [
"public",
"function",
"doExpressCheckoutPayment",
"(",
"$",
"request",
")",
"{",
"$",
"caller",
"=",
"$",
"this",
"->",
"getCaller",
"(",
")",
";",
"$",
"caller",
"->",
"setRequest",
"(",
"$",
"request",
")",
";",
"$",
"response",
"=",
"oxNew",
"(",
"\... | Executes "DoExpressCheckoutPayment". Returns response object from PayPal.
@param \OxidEsales\PayPalModule\Model\PayPalRequest\PayPalRequest $request
@return \OxidEsales\PayPalModule\Model\Response\ResponseDoExpressCheckoutPayment | [
"Executes",
"DoExpressCheckoutPayment",
".",
"Returns",
"response",
"object",
"from",
"PayPal",
"."
] | ca9adba6e8312062449b53e7bda4a513c6b8c250 | https://github.com/OXID-eSales/paypal/blob/ca9adba6e8312062449b53e7bda4a513c6b8c250/Core/PayPalService.php#L191-L200 |
44,102 | OXID-eSales/paypal | Core/PayPalService.php | PayPalService.callbackResponse | public function callbackResponse()
{
// cleanup
$this->getCaller()->setParameter("VERSION", null);
$this->getCaller()->setParameter("PWD", null);
$this->getCaller()->setParameter("USER", null);
$this->getCaller()->setParameter("SIGNATURE", null);
return $this->getCaller()->getCallBackResponse("CallbackResponse");
} | php | public function callbackResponse()
{
// cleanup
$this->getCaller()->setParameter("VERSION", null);
$this->getCaller()->setParameter("PWD", null);
$this->getCaller()->setParameter("USER", null);
$this->getCaller()->setParameter("SIGNATURE", null);
return $this->getCaller()->getCallBackResponse("CallbackResponse");
} | [
"public",
"function",
"callbackResponse",
"(",
")",
"{",
"// cleanup",
"$",
"this",
"->",
"getCaller",
"(",
")",
"->",
"setParameter",
"(",
"\"VERSION\"",
",",
"null",
")",
";",
"$",
"this",
"->",
"getCaller",
"(",
")",
"->",
"setParameter",
"(",
"\"PWD\""... | Executes PayPal callback request
@return string | [
"Executes",
"PayPal",
"callback",
"request"
] | ca9adba6e8312062449b53e7bda4a513c6b8c250 | https://github.com/OXID-eSales/paypal/blob/ca9adba6e8312062449b53e7bda4a513c6b8c250/Core/PayPalService.php#L207-L216 |
44,103 | OXID-eSales/paypal | Core/PayPalService.php | PayPalService.doVoid | public function doVoid($request)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoVoid::class);
$response->setData($caller->call('DoVoid'));
return $response;
} | php | public function doVoid($request)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoVoid::class);
$response->setData($caller->call('DoVoid'));
return $response;
} | [
"public",
"function",
"doVoid",
"(",
"$",
"request",
")",
"{",
"$",
"caller",
"=",
"$",
"this",
"->",
"getCaller",
"(",
")",
";",
"$",
"caller",
"->",
"setRequest",
"(",
"$",
"request",
")",
";",
"$",
"response",
"=",
"oxNew",
"(",
"\\",
"OxidEsales"... | Executes "DoVoid". Returns response array from PayPal
@param \OxidEsales\PayPalModule\Model\PayPalRequest\PayPalRequest $request
@return \OxidEsales\PayPalModule\Model\Response\Response | [
"Executes",
"DoVoid",
".",
"Returns",
"response",
"array",
"from",
"PayPal"
] | ca9adba6e8312062449b53e7bda4a513c6b8c250 | https://github.com/OXID-eSales/paypal/blob/ca9adba6e8312062449b53e7bda4a513c6b8c250/Core/PayPalService.php#L225-L234 |
44,104 | OXID-eSales/paypal | Core/PayPalService.php | PayPalService.refundTransaction | public function refundTransaction($request)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoRefund::class);
$response->setData($caller->call('RefundTransaction'));
return $response;
} | php | public function refundTransaction($request)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoRefund::class);
$response->setData($caller->call('RefundTransaction'));
return $response;
} | [
"public",
"function",
"refundTransaction",
"(",
"$",
"request",
")",
"{",
"$",
"caller",
"=",
"$",
"this",
"->",
"getCaller",
"(",
")",
";",
"$",
"caller",
"->",
"setRequest",
"(",
"$",
"request",
")",
";",
"$",
"response",
"=",
"oxNew",
"(",
"\\",
"... | Executes "RefundTransaction". Returns response array from PayPal
@param \OxidEsales\PayPalModule\Model\PayPalRequest\PayPalRequest $request
@return \OxidEsales\PayPalModule\Model\Response\Response | [
"Executes",
"RefundTransaction",
".",
"Returns",
"response",
"array",
"from",
"PayPal"
] | ca9adba6e8312062449b53e7bda4a513c6b8c250 | https://github.com/OXID-eSales/paypal/blob/ca9adba6e8312062449b53e7bda4a513c6b8c250/Core/PayPalService.php#L243-L252 |
44,105 | OXID-eSales/paypal | Core/PayPalService.php | PayPalService.doCapture | public function doCapture($request)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoCapture::class);
$response->setData($caller->call('DoCapture'));
return $response;
} | php | public function doCapture($request)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoCapture::class);
$response->setData($caller->call('DoCapture'));
return $response;
} | [
"public",
"function",
"doCapture",
"(",
"$",
"request",
")",
"{",
"$",
"caller",
"=",
"$",
"this",
"->",
"getCaller",
"(",
")",
";",
"$",
"caller",
"->",
"setRequest",
"(",
"$",
"request",
")",
";",
"$",
"response",
"=",
"oxNew",
"(",
"\\",
"OxidEsal... | Executes "DoCapture". Returns response array from PayPal
@param \OxidEsales\PayPalModule\Model\PayPalRequest\PayPalRequest $request request
@return \OxidEsales\PayPalModule\Model\Response\Response | [
"Executes",
"DoCapture",
".",
"Returns",
"response",
"array",
"from",
"PayPal"
] | ca9adba6e8312062449b53e7bda4a513c6b8c250 | https://github.com/OXID-eSales/paypal/blob/ca9adba6e8312062449b53e7bda4a513c6b8c250/Core/PayPalService.php#L261-L270 |
44,106 | OXID-eSales/paypal | Core/PayPalService.php | PayPalService.doReAuthorization | public function doReAuthorization($request)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoReAuthorize::class);
$response->setData($caller->call('DoReauthorization'));
return $response;
} | php | public function doReAuthorization($request)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoReAuthorize::class);
$response->setData($caller->call('DoReauthorization'));
return $response;
} | [
"public",
"function",
"doReAuthorization",
"(",
"$",
"request",
")",
"{",
"$",
"caller",
"=",
"$",
"this",
"->",
"getCaller",
"(",
")",
";",
"$",
"caller",
"->",
"setRequest",
"(",
"$",
"request",
")",
";",
"$",
"response",
"=",
"oxNew",
"(",
"\\",
"... | Executes "DoReauthorization". Returns response array from PayPal.
@param \OxidEsales\PayPalModule\Model\PayPalRequest\PayPalRequest $request
@return \OxidEsales\PayPalModule\Model\Response\Response | [
"Executes",
"DoReauthorization",
".",
"Returns",
"response",
"array",
"from",
"PayPal",
"."
] | ca9adba6e8312062449b53e7bda4a513c6b8c250 | https://github.com/OXID-eSales/paypal/blob/ca9adba6e8312062449b53e7bda4a513c6b8c250/Core/PayPalService.php#L279-L288 |
44,107 | OXID-eSales/paypal | Core/PayPalService.php | PayPalService.doVerifyWithPayPal | public function doVerifyWithPayPal($request, $charset)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$caller = $this->getCaller();
$curl = $caller->getCurl();
$curl->setConnectionCharset($charset);
$curl->setDataCharset($charset);
$curl->setHost($this->getPayPalIpnConfig()->getIpnHost());
$curl->setUrlToCall($this->getPayPalIpnConfig()->getIPNResponseUrl());
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoVerifyWithPayPal::class);
$response->setData($caller->call());
return $response;
} | php | public function doVerifyWithPayPal($request, $charset)
{
$caller = $this->getCaller();
$caller->setRequest($request);
$caller = $this->getCaller();
$curl = $caller->getCurl();
$curl->setConnectionCharset($charset);
$curl->setDataCharset($charset);
$curl->setHost($this->getPayPalIpnConfig()->getIpnHost());
$curl->setUrlToCall($this->getPayPalIpnConfig()->getIPNResponseUrl());
$response = oxNew(\OxidEsales\PayPalModule\Model\Response\ResponseDoVerifyWithPayPal::class);
$response->setData($caller->call());
return $response;
} | [
"public",
"function",
"doVerifyWithPayPal",
"(",
"$",
"request",
",",
"$",
"charset",
")",
"{",
"$",
"caller",
"=",
"$",
"this",
"->",
"getCaller",
"(",
")",
";",
"$",
"caller",
"->",
"setRequest",
"(",
"$",
"request",
")",
";",
"$",
"caller",
"=",
"... | Executes call to PayPal IPN.
@param \OxidEsales\PayPalModule\Model\PayPalRequest\PayPalRequest $request
@param string $charset
@return \OxidEsales\PayPalModule\Model\Response\Response | [
"Executes",
"call",
"to",
"PayPal",
"IPN",
"."
] | ca9adba6e8312062449b53e7bda4a513c6b8c250 | https://github.com/OXID-eSales/paypal/blob/ca9adba6e8312062449b53e7bda4a513c6b8c250/Core/PayPalService.php#L298-L314 |
44,108 | pdffiller/pdffiller-php-api-client | src/FillableForm.php | FillableForm.forms | public function forms()
{
$response = static::query($this->client, [$this->fillable_form_id, self::FORMS_URI]);
$forms = new ModelsList();
if (isset($response['items'])) {
foreach ($response['items'] as $item) {
$forms[] = new FilledForm($this->client, $this->fillable_form_id, $item);
}
}
return $forms;
} | php | public function forms()
{
$response = static::query($this->client, [$this->fillable_form_id, self::FORMS_URI]);
$forms = new ModelsList();
if (isset($response['items'])) {
foreach ($response['items'] as $item) {
$forms[] = new FilledForm($this->client, $this->fillable_form_id, $item);
}
}
return $forms;
} | [
"public",
"function",
"forms",
"(",
")",
"{",
"$",
"response",
"=",
"static",
"::",
"query",
"(",
"$",
"this",
"->",
"client",
",",
"[",
"$",
"this",
"->",
"fillable_form_id",
",",
"self",
"::",
"FORMS_URI",
"]",
")",
";",
"$",
"forms",
"=",
"new",
... | Returns filled forms
@return array|ModelsList
@throws Exceptions\InvalidQueryException
@throws Exceptions\InvalidRequestException
@throws \ReflectionException | [
"Returns",
"filled",
"forms"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/FillableForm.php#L65-L77 |
44,109 | pdffiller/pdffiller-php-api-client | src/FillableForm.php | FillableForm.download | public function download(string $callback = "")
{
$parameters = [];
if (!empty($callback) && is_string($callback)) {
$parameters['callback_url'] = $callback;
}
return static::query($this->client, [$this->fillable_form_id, self::DOWNLOAD_URI], $parameters);
} | php | public function download(string $callback = "")
{
$parameters = [];
if (!empty($callback) && is_string($callback)) {
$parameters['callback_url'] = $callback;
}
return static::query($this->client, [$this->fillable_form_id, self::DOWNLOAD_URI], $parameters);
} | [
"public",
"function",
"download",
"(",
"string",
"$",
"callback",
"=",
"\"\"",
")",
"{",
"$",
"parameters",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"callback",
")",
"&&",
"is_string",
"(",
"$",
"callback",
")",
")",
"{",
"$",
"parame... | Downloads filled forms as a ZIP archive
@param string $callback
@return mixed
@throws Exceptions\InvalidQueryException
@throws Exceptions\InvalidRequestException | [
"Downloads",
"filled",
"forms",
"as",
"a",
"ZIP",
"archive"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/FillableForm.php#L97-L106 |
44,110 | pdffiller/pdffiller-php-api-client | src/DTO/FillableFieldsList.php | FillableFieldsList.getFields | private function getFields()
{
$fields = [];
foreach ($this->items as $name => $field) {
if (is_array($field) && isset($field['name'])) {
$fields[] = $field['name'];
} else if ($field instanceof FillableField){
$fields[] = $field->name;
} else if (is_string($name)){
$fields[] = $name;
} else {
$fields[] = '';
}
}
return $fields;
} | php | private function getFields()
{
$fields = [];
foreach ($this->items as $name => $field) {
if (is_array($field) && isset($field['name'])) {
$fields[] = $field['name'];
} else if ($field instanceof FillableField){
$fields[] = $field->name;
} else if (is_string($name)){
$fields[] = $name;
} else {
$fields[] = '';
}
}
return $fields;
} | [
"private",
"function",
"getFields",
"(",
")",
"{",
"$",
"fields",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"name",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"field",
")",
"&&",
"isset",
"(",
... | Returns the fields names in simple array
@return array | [
"Returns",
"the",
"fields",
"names",
"in",
"simple",
"array"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/DTO/FillableFieldsList.php#L42-L59 |
44,111 | pdffiller/pdffiller-php-api-client | src/DTO/FillableFieldsList.php | FillableFieldsList.eachFillable | public function eachFillable(Closure $closure)
{
/** @var FillableField $item */
foreach ($this->items as $item) {
if ($item->fillable) {
$closure($item);
}
}
} | php | public function eachFillable(Closure $closure)
{
/** @var FillableField $item */
foreach ($this->items as $item) {
if ($item->fillable) {
$closure($item);
}
}
} | [
"public",
"function",
"eachFillable",
"(",
"Closure",
"$",
"closure",
")",
"{",
"/** @var FillableField $item */",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"fillable",
")",
"{",
"$",
"closure",
... | Walks through the list and calls the closure on each field that can be filled.
@param Closure $closure | [
"Walks",
"through",
"the",
"list",
"and",
"calls",
"the",
"closure",
"on",
"each",
"field",
"that",
"can",
"be",
"filled",
"."
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/DTO/FillableFieldsList.php#L138-L146 |
44,112 | pdffiller/pdffiller-php-api-client | src/DTO/FillableFieldsList.php | FillableFieldsList.getOnlyFillable | public function getOnlyFillable()
{
$list = [];
foreach ($this->items as $item) {
if ($item->fillable) {
$list[] = $item;
}
}
return new static($list);
} | php | public function getOnlyFillable()
{
$list = [];
foreach ($this->items as $item) {
if ($item->fillable) {
$list[] = $item;
}
}
return new static($list);
} | [
"public",
"function",
"getOnlyFillable",
"(",
")",
"{",
"$",
"list",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"fillable",
")",
"{",
"$",
"list",
"[",
"]",
"=",
"$... | Returns a new list containing only fields that can be filled
@return FillableFieldsList | [
"Returns",
"a",
"new",
"list",
"containing",
"only",
"fields",
"that",
"can",
"be",
"filled"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/DTO/FillableFieldsList.php#L153-L164 |
44,113 | pdffiller/pdffiller-php-api-client | examples/ExampleFabric.php | ExampleFabric.getProvider | public function getProvider($accessTokenParams = [], $useCache = true)
{
if (!$useCache) {
$this->provider->getAccessToken($this->type, $accessTokenParams);
return $this->provider;
}
return $this->provider->setAccessToken($this->getToken($accessTokenParams));
} | php | public function getProvider($accessTokenParams = [], $useCache = true)
{
if (!$useCache) {
$this->provider->getAccessToken($this->type, $accessTokenParams);
return $this->provider;
}
return $this->provider->setAccessToken($this->getToken($accessTokenParams));
} | [
"public",
"function",
"getProvider",
"(",
"$",
"accessTokenParams",
"=",
"[",
"]",
",",
"$",
"useCache",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"$",
"useCache",
")",
"{",
"$",
"this",
"->",
"provider",
"->",
"getAccessToken",
"(",
"$",
"this",
"->",
... | Returns the provider ready to use
@param array $accessTokenParams
@param bool $useCache
@return PDFfiller | [
"Returns",
"the",
"provider",
"ready",
"to",
"use"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/examples/ExampleFabric.php#L44-L52 |
44,114 | pdffiller/pdffiller-php-api-client | examples/ExampleFabric.php | ExampleFabric.cacheToken | private function cacheToken(AccessToken $accessToken)
{
$tz = self::TIME_ZONE;
$kvs = $this->getKeyValueStorage();
$liveTimeInSec = Carbon::createFromTimestamp($accessToken->getExpires(), $tz)->diffInSeconds(Carbon::now($tz));
$kvs->set(self::ACCESS_TOKEN_KEY, $accessToken->getToken());
$kvs->expire(self::ACCESS_TOKEN_KEY, $liveTimeInSec);
$kvs->set(self::REFRESH_TOKEN_KEY, $accessToken->getRefreshToken());
} | php | private function cacheToken(AccessToken $accessToken)
{
$tz = self::TIME_ZONE;
$kvs = $this->getKeyValueStorage();
$liveTimeInSec = Carbon::createFromTimestamp($accessToken->getExpires(), $tz)->diffInSeconds(Carbon::now($tz));
$kvs->set(self::ACCESS_TOKEN_KEY, $accessToken->getToken());
$kvs->expire(self::ACCESS_TOKEN_KEY, $liveTimeInSec);
$kvs->set(self::REFRESH_TOKEN_KEY, $accessToken->getRefreshToken());
} | [
"private",
"function",
"cacheToken",
"(",
"AccessToken",
"$",
"accessToken",
")",
"{",
"$",
"tz",
"=",
"self",
"::",
"TIME_ZONE",
";",
"$",
"kvs",
"=",
"$",
"this",
"->",
"getKeyValueStorage",
"(",
")",
";",
"$",
"liveTimeInSec",
"=",
"Carbon",
"::",
"cr... | Puts the given access token to the local cache
@param AccessToken $accessToken | [
"Puts",
"the",
"given",
"access",
"token",
"to",
"the",
"local",
"cache"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/examples/ExampleFabric.php#L59-L69 |
44,115 | pdffiller/pdffiller-php-api-client | examples/ExampleFabric.php | ExampleFabric.getToken | private function getToken($accessTokenParams)
{
$kvs = $this->getKeyValueStorage();
if ($kvs->has(self::ACCESS_TOKEN_KEY) && $kvs->has(self::REFRESH_TOKEN_KEY)) {
return new AccessToken([
'access_token' => $kvs->get(self::ACCESS_TOKEN_KEY),
'expires_in' => $kvs->getTtl(self::ACCESS_TOKEN_KEY),
'refresh_token' => $kvs->get(self::REFRESH_TOKEN_KEY),
]);
}
$accessToken = $this->provider->getAccessToken($this->type, $accessTokenParams);
$this->cacheToken($accessToken);
return $accessToken;
} | php | private function getToken($accessTokenParams)
{
$kvs = $this->getKeyValueStorage();
if ($kvs->has(self::ACCESS_TOKEN_KEY) && $kvs->has(self::REFRESH_TOKEN_KEY)) {
return new AccessToken([
'access_token' => $kvs->get(self::ACCESS_TOKEN_KEY),
'expires_in' => $kvs->getTtl(self::ACCESS_TOKEN_KEY),
'refresh_token' => $kvs->get(self::REFRESH_TOKEN_KEY),
]);
}
$accessToken = $this->provider->getAccessToken($this->type, $accessTokenParams);
$this->cacheToken($accessToken);
return $accessToken;
} | [
"private",
"function",
"getToken",
"(",
"$",
"accessTokenParams",
")",
"{",
"$",
"kvs",
"=",
"$",
"this",
"->",
"getKeyValueStorage",
"(",
")",
";",
"if",
"(",
"$",
"kvs",
"->",
"has",
"(",
"self",
"::",
"ACCESS_TOKEN_KEY",
")",
"&&",
"$",
"kvs",
"->",... | Gets the access token from the cache if it exists there
or requests the new one with given credentials.
@param $accessTokenParams
@return AccessToken | [
"Gets",
"the",
"access",
"token",
"from",
"the",
"cache",
"if",
"it",
"exists",
"there",
"or",
"requests",
"the",
"new",
"one",
"with",
"given",
"credentials",
"."
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/examples/ExampleFabric.php#L78-L94 |
44,116 | pdffiller/pdffiller-php-api-client | src/Template.php | Template.createConstructor | public function createConstructor(array $params)
{
$url = self::resolveFullUrl([$this->id, 'constructor']);
$options = [
'json' => $params,
];
return static::post($this->client, $url, $options);
} | php | public function createConstructor(array $params)
{
$url = self::resolveFullUrl([$this->id, 'constructor']);
$options = [
'json' => $params,
];
return static::post($this->client, $url, $options);
} | [
"public",
"function",
"createConstructor",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"resolveFullUrl",
"(",
"[",
"$",
"this",
"->",
"id",
",",
"'constructor'",
"]",
")",
";",
"$",
"options",
"=",
"[",
"'json'",
"=>",
"$",
... | Create link to edit a specific template
@param array $params
@return mixed
@throws Exceptions\InvalidQueryException
@throws Exceptions\InvalidRequestException | [
"Create",
"link",
"to",
"edit",
"a",
"specific",
"template"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Template.php#L83-L92 |
44,117 | pdffiller/pdffiller-php-api-client | src/Template.php | Template.fill | public function fill($fields = [])
{
$url = self::resolveFullUrl([$this->id]);
if(isset($this->properties['fillable_fields'])) {
$fields = $this->properties['fillable_fields'];
}
foreach ($fields as $index => $field) {
if (!is_array($field)) {
continue;
}
unset($fields[$index]);
if (!isset($field['name']) || !isset($field['value'])) {
continue;
}
$name = $field['name'];
$value = $field['value'];
$type = isset($field['type']) ? $field['type'] : '';
if ($type === self::TYPE_CHECKBOX) {
$value = intval(boolval($value));
}
$fields[$name] = $value;
}
return static::post($this->client, $url, [
'json' => [
'fillable_fields' => $fields
]
]);
} | php | public function fill($fields = [])
{
$url = self::resolveFullUrl([$this->id]);
if(isset($this->properties['fillable_fields'])) {
$fields = $this->properties['fillable_fields'];
}
foreach ($fields as $index => $field) {
if (!is_array($field)) {
continue;
}
unset($fields[$index]);
if (!isset($field['name']) || !isset($field['value'])) {
continue;
}
$name = $field['name'];
$value = $field['value'];
$type = isset($field['type']) ? $field['type'] : '';
if ($type === self::TYPE_CHECKBOX) {
$value = intval(boolval($value));
}
$fields[$name] = $value;
}
return static::post($this->client, $url, [
'json' => [
'fillable_fields' => $fields
]
]);
} | [
"public",
"function",
"fill",
"(",
"$",
"fields",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"resolveFullUrl",
"(",
"[",
"$",
"this",
"->",
"id",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"properties",
"[",
"'fillabl... | Fill template with named fields
@param array $fields
@return mixed
@throws Exceptions\InvalidQueryException
@throws Exceptions\InvalidRequestException | [
"Fill",
"template",
"with",
"named",
"fields"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Template.php#L130-L165 |
44,118 | pdffiller/pdffiller-php-api-client | src/Template.php | Template.watermark | public function watermark($watermarkText)
{
$url = self::resolveFullUrl([$this->id, self::WATERMARK], ['text' => $watermarkText]);
return static::post($this->client, $url);
} | php | public function watermark($watermarkText)
{
$url = self::resolveFullUrl([$this->id, self::WATERMARK], ['text' => $watermarkText]);
return static::post($this->client, $url);
} | [
"public",
"function",
"watermark",
"(",
"$",
"watermarkText",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"resolveFullUrl",
"(",
"[",
"$",
"this",
"->",
"id",
",",
"self",
"::",
"WATERMARK",
"]",
",",
"[",
"'text'",
"=>",
"$",
"watermarkText",
"]",
")",
... | Get template meta
@param $watermarkText
@return mixed
@throws Exceptions\InvalidQueryException
@throws Exceptions\InvalidRequestException | [
"Get",
"template",
"meta"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Template.php#L231-L236 |
44,119 | pdffiller/pdffiller-php-api-client | src/Core/Enum.php | Enum.getConstants | public function getConstants(bool $includeDefault = false): array
{
$constants = (new \ReflectionClass($this))->getConstants();
if (!$includeDefault) {
unset($constants['__default']);
}
return $constants;
} | php | public function getConstants(bool $includeDefault = false): array
{
$constants = (new \ReflectionClass($this))->getConstants();
if (!$includeDefault) {
unset($constants['__default']);
}
return $constants;
} | [
"public",
"function",
"getConstants",
"(",
"bool",
"$",
"includeDefault",
"=",
"false",
")",
":",
"array",
"{",
"$",
"constants",
"=",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this",
")",
")",
"->",
"getConstants",
"(",
")",
";",
"if",
"(",
"!",... | Returns an array of possible class values.
@param bool $includeDefault
@return array | [
"Returns",
"an",
"array",
"of",
"possible",
"class",
"values",
"."
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Enum.php#L39-L48 |
44,120 | pdffiller/pdffiller-php-api-client | src/Traits/CastsTrait.php | CastsTrait.castField | private function castField($option, $value)
{
$casts = $this->casts;
if (!isset($casts[$option])) {
return $value;
}
$cast = $casts[$option];
if (is_null($value) || is_null($cast)) {
return $value;
}
if (is_array($cast)) {
return $this->complexListCast($value, $cast);
}
switch ($cast) {
case 'int':
case 'integer':
return (int) $value;
case 'real':
case 'float':
case 'double':
return (float) $value;
case 'string':
return (string) $value;
case 'bool':
case 'boolean':
return (bool) $value;
case 'list':
return $this->castToList($value);
default:
return $this->castToObject($value, $cast);
}
} | php | private function castField($option, $value)
{
$casts = $this->casts;
if (!isset($casts[$option])) {
return $value;
}
$cast = $casts[$option];
if (is_null($value) || is_null($cast)) {
return $value;
}
if (is_array($cast)) {
return $this->complexListCast($value, $cast);
}
switch ($cast) {
case 'int':
case 'integer':
return (int) $value;
case 'real':
case 'float':
case 'double':
return (float) $value;
case 'string':
return (string) $value;
case 'bool':
case 'boolean':
return (bool) $value;
case 'list':
return $this->castToList($value);
default:
return $this->castToObject($value, $cast);
}
} | [
"private",
"function",
"castField",
"(",
"$",
"option",
",",
"$",
"value",
")",
"{",
"$",
"casts",
"=",
"$",
"this",
"->",
"casts",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"casts",
"[",
"$",
"option",
"]",
")",
")",
"{",
"return",
"$",
"value",
... | Casts the field
@param $option
@param $value
@return bool|float|mixed|ListObject|string | [
"Casts",
"the",
"field"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Traits/CastsTrait.php#L22-L58 |
44,121 | pdffiller/pdffiller-php-api-client | src/Traits/CastsTrait.php | CastsTrait.castToObject | private function castToObject($value, $class)
{
if (!class_exists($class) || $value instanceof $class) {
return $value;
}
$parentClasses = class_parents($class);
if (in_array(Enum::class, $parentClasses) || in_array(AbstractObject::class, $parentClasses)) {
return new $class($value);
}
if (in_array(Model::class, $parentClasses)) {
return new $class($this->getClient(), $value);
}
if (in_array(ListObject::class, $parentClasses)) {
return new $class($value);
}
return $value;
} | php | private function castToObject($value, $class)
{
if (!class_exists($class) || $value instanceof $class) {
return $value;
}
$parentClasses = class_parents($class);
if (in_array(Enum::class, $parentClasses) || in_array(AbstractObject::class, $parentClasses)) {
return new $class($value);
}
if (in_array(Model::class, $parentClasses)) {
return new $class($this->getClient(), $value);
}
if (in_array(ListObject::class, $parentClasses)) {
return new $class($value);
}
return $value;
} | [
"private",
"function",
"castToObject",
"(",
"$",
"value",
",",
"$",
"class",
")",
"{",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
"||",
"$",
"value",
"instanceof",
"$",
"class",
")",
"{",
"return",
"$",
"value",
";",
"}",
"$",
"parentCla... | Casts value to the given class
@param $value
@param $class
@return mixed | [
"Casts",
"value",
"to",
"the",
"given",
"class"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Traits/CastsTrait.php#L87-L108 |
44,122 | pdffiller/pdffiller-php-api-client | src/Core/ExceptionsMessages.php | ExceptionsMessages.getMessages | protected function getMessages(string $locale = "en"):array
{
$path = __DIR__ . "/../Messages/" . $locale . "/messages.json";
if (file_exists($path)) {
$jsonMessages = file_get_contents($path);
return json_decode($jsonMessages, true);
}
return [];
} | php | protected function getMessages(string $locale = "en"):array
{
$path = __DIR__ . "/../Messages/" . $locale . "/messages.json";
if (file_exists($path)) {
$jsonMessages = file_get_contents($path);
return json_decode($jsonMessages, true);
}
return [];
} | [
"protected",
"function",
"getMessages",
"(",
"string",
"$",
"locale",
"=",
"\"en\"",
")",
":",
"array",
"{",
"$",
"path",
"=",
"__DIR__",
".",
"\"/../Messages/\"",
".",
"$",
"locale",
".",
"\"/messages.json\"",
";",
"if",
"(",
"file_exists",
"(",
"$",
"pat... | Returns an array of possible exceptions messages
@param string $locale
@return array | [
"Returns",
"an",
"array",
"of",
"possible",
"exceptions",
"messages"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/ExceptionsMessages.php#L57-L68 |
44,123 | pdffiller/pdffiller-php-api-client | src/SignatureRequest.php | SignatureRequest.getInbox | public static function getInbox(PDFfiller $provider, $parameters = [])
{
$paramsArray = self::query($provider, [self::INBOX], $parameters);
$paramsArray['items'] = array_map(function ($entry) {
$entry['recipients'] = [$entry['recipients']];
$entry['except'] = ['callbacks'];
return $entry;
}, $paramsArray['items']);
$paramsArray['items'] = static::formItems($provider, $paramsArray);
return new ModelsList($paramsArray);
} | php | public static function getInbox(PDFfiller $provider, $parameters = [])
{
$paramsArray = self::query($provider, [self::INBOX], $parameters);
$paramsArray['items'] = array_map(function ($entry) {
$entry['recipients'] = [$entry['recipients']];
$entry['except'] = ['callbacks'];
return $entry;
}, $paramsArray['items']);
$paramsArray['items'] = static::formItems($provider, $paramsArray);
return new ModelsList($paramsArray);
} | [
"public",
"static",
"function",
"getInbox",
"(",
"PDFfiller",
"$",
"provider",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"paramsArray",
"=",
"self",
"::",
"query",
"(",
"$",
"provider",
",",
"[",
"self",
"::",
"INBOX",
"]",
",",
"$",
"par... | Return signatures request list in inbox
@param PDFfiller $provider
@param array $parameters
@return ModelsList | [
"Return",
"signatures",
"request",
"list",
"in",
"inbox"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/SignatureRequest.php#L75-L87 |
44,124 | pdffiller/pdffiller-php-api-client | src/SignatureRequest.php | SignatureRequest.inboxDownload | public static function inboxDownload($provider, $params = [])
{
if (isset($params['status']) && $params['status'] instanceof SignatureRequestStatus) {
$params['status'] = mb_strtolower($params['status']->getValue());
}
return self::query($provider, [self::INBOX, self::DOWNLOAD], $params);
} | php | public static function inboxDownload($provider, $params = [])
{
if (isset($params['status']) && $params['status'] instanceof SignatureRequestStatus) {
$params['status'] = mb_strtolower($params['status']->getValue());
}
return self::query($provider, [self::INBOX, self::DOWNLOAD], $params);
} | [
"public",
"static",
"function",
"inboxDownload",
"(",
"$",
"provider",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"params",
"[",
"'status'",
"]",
")",
"&&",
"$",
"params",
"[",
"'status'",
"]",
"instanceof",
"SignatureRe... | Returns zip-archive of SendToSign inbox documents.
Supports a filter parameters such as 'status', 'perpage', 'datefrom',
'dateto', 'order', 'orderby'. Status can be only 'signed', 'in_progress' and 'sent'
@param $provider
@param array $params
@return string | [
"Returns",
"zip",
"-",
"archive",
"of",
"SendToSign",
"inbox",
"documents",
".",
"Supports",
"a",
"filter",
"parameters",
"such",
"as",
"status",
"perpage",
"datefrom",
"dateto",
"order",
"orderby",
".",
"Status",
"can",
"be",
"only",
"signed",
"in_progress",
... | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/SignatureRequest.php#L98-L105 |
44,125 | pdffiller/pdffiller-php-api-client | src/SignatureRequest.php | SignatureRequest.formRecipients | protected static function formRecipients($inputRecipients, PDFfiller $provider, $signatureRequestId)
{
$recipients = [];
foreach ($inputRecipients as $recipient) {
$recipients[$recipient['id']] = new SignatureRequestRecipient($provider, $recipient, $signatureRequestId);
}
return $recipients;
} | php | protected static function formRecipients($inputRecipients, PDFfiller $provider, $signatureRequestId)
{
$recipients = [];
foreach ($inputRecipients as $recipient) {
$recipients[$recipient['id']] = new SignatureRequestRecipient($provider, $recipient, $signatureRequestId);
}
return $recipients;
} | [
"protected",
"static",
"function",
"formRecipients",
"(",
"$",
"inputRecipients",
",",
"PDFfiller",
"$",
"provider",
",",
"$",
"signatureRequestId",
")",
"{",
"$",
"recipients",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"inputRecipients",
"as",
"$",
"recipient"... | Prepares recipients array
@param $inputRecipients
@param PDFfiller $provider
@param $signatureRequestId
@return array | [
"Prepares",
"recipients",
"array"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/SignatureRequest.php#L120-L129 |
44,126 | pdffiller/pdffiller-php-api-client | src/SignatureRequest.php | SignatureRequest.recipients | public static function recipients(PDFfiller $provider, $signatureRequestId)
{
$recipients = self::query($provider, [$signatureRequestId, SignatureRequestRecipient::RECIPIENT]);
return new ListObject(self::formRecipients($recipients['items'], $provider, $signatureRequestId));
} | php | public static function recipients(PDFfiller $provider, $signatureRequestId)
{
$recipients = self::query($provider, [$signatureRequestId, SignatureRequestRecipient::RECIPIENT]);
return new ListObject(self::formRecipients($recipients['items'], $provider, $signatureRequestId));
} | [
"public",
"static",
"function",
"recipients",
"(",
"PDFfiller",
"$",
"provider",
",",
"$",
"signatureRequestId",
")",
"{",
"$",
"recipients",
"=",
"self",
"::",
"query",
"(",
"$",
"provider",
",",
"[",
"$",
"signatureRequestId",
",",
"SignatureRequestRecipient",... | Returns signature request recipients list.
@param PDFfiller $provider
@param integer $signatureRequestId
@return ListObject | [
"Returns",
"signature",
"request",
"recipients",
"list",
"."
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/SignatureRequest.php#L204-L209 |
44,127 | pdffiller/pdffiller-php-api-client | src/SignatureRequest.php | SignatureRequest.recipient | public static function recipient(PDFfiller $provider, $signatureRequestId, $recipientId)
{
$recipient = self::query($provider, [$signatureRequestId, SignatureRequestRecipient::RECIPIENT, $recipientId]);
return new SignatureRequestRecipient($provider, $recipient, $signatureRequestId);
} | php | public static function recipient(PDFfiller $provider, $signatureRequestId, $recipientId)
{
$recipient = self::query($provider, [$signatureRequestId, SignatureRequestRecipient::RECIPIENT, $recipientId]);
return new SignatureRequestRecipient($provider, $recipient, $signatureRequestId);
} | [
"public",
"static",
"function",
"recipient",
"(",
"PDFfiller",
"$",
"provider",
",",
"$",
"signatureRequestId",
",",
"$",
"recipientId",
")",
"{",
"$",
"recipient",
"=",
"self",
"::",
"query",
"(",
"$",
"provider",
",",
"[",
"$",
"signatureRequestId",
",",
... | Returns current signature request recipient by id.
@param PDFfiller $provider
@param $signatureRequestId
@param $recipientId
@return SignatureRequestRecipient | [
"Returns",
"current",
"signature",
"request",
"recipient",
"by",
"id",
"."
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/SignatureRequest.php#L219-L224 |
44,128 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.initArrayFields | protected function initArrayFields(array $except = [])
{
$reflection = new ReflectionClass(static::class);
$docs = ($reflection->getDocComment());
$docs = preg_replace("~[*/]+~", ' ', $docs);
preg_match_all("~@property\s+(array|mixed|ListObject|FillableFieldsList)\s+\\$(.*)\r?\n+~", $docs, $result);
if ($result) {
$fields = array_diff($result[2], $except);
foreach ($fields as $field) {
$this->properties[$field] = new ListObject();
}
}
} | php | protected function initArrayFields(array $except = [])
{
$reflection = new ReflectionClass(static::class);
$docs = ($reflection->getDocComment());
$docs = preg_replace("~[*/]+~", ' ', $docs);
preg_match_all("~@property\s+(array|mixed|ListObject|FillableFieldsList)\s+\\$(.*)\r?\n+~", $docs, $result);
if ($result) {
$fields = array_diff($result[2], $except);
foreach ($fields as $field) {
$this->properties[$field] = new ListObject();
}
}
} | [
"protected",
"function",
"initArrayFields",
"(",
"array",
"$",
"except",
"=",
"[",
"]",
")",
"{",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"static",
"::",
"class",
")",
";",
"$",
"docs",
"=",
"(",
"$",
"reflection",
"->",
"getDocComment",
"... | Initializes the object's arrays and lists
@param array $except
@throws \ReflectionException | [
"Initializes",
"the",
"object",
"s",
"arrays",
"and",
"lists"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L74-L88 |
44,129 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.save | public function save($options = [])
{
if (!isset($options['except'])) {
$options['except'] = [];
}
$options['except'] = array_merge($options['except'], $this->readOnly);
if (!$this->exists) {
return $this->create($options);
}
return $this->update($options);
} | php | public function save($options = [])
{
if (!isset($options['except'])) {
$options['except'] = [];
}
$options['except'] = array_merge($options['except'], $this->readOnly);
if (!$this->exists) {
return $this->create($options);
}
return $this->update($options);
} | [
"public",
"function",
"save",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'except'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'except'",
"]",
"=",
"[",
"]",
";",
"}",
"$",
"options",
"[",
... | Creates or updates model
@param array $options
@return mixed
@throws InvalidRequestException
@throws ResponseException | [
"Creates",
"or",
"updates",
"model"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L107-L120 |
44,130 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.parseArray | public function parseArray($array, $options = [])
{
// default options
$options['except'] = $options['except'] ?? [];
foreach ($options['except'] as $value) {
unset($array[$value]);
}
foreach ($array as $key => $value) {
$this->properties[$key] = $this->castField($key, $value);
}
return $this;
} | php | public function parseArray($array, $options = [])
{
// default options
$options['except'] = $options['except'] ?? [];
foreach ($options['except'] as $value) {
unset($array[$value]);
}
foreach ($array as $key => $value) {
$this->properties[$key] = $this->castField($key, $value);
}
return $this;
} | [
"public",
"function",
"parseArray",
"(",
"$",
"array",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"// default options",
"$",
"options",
"[",
"'except'",
"]",
"=",
"$",
"options",
"[",
"'except'",
"]",
"??",
"[",
"]",
";",
"foreach",
"(",
"$",
"opt... | Extracts properties from array
@param $array
@param array $options
@return $this | [
"Extracts",
"properties",
"from",
"array"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L147-L161 |
44,131 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.apiCall | protected static function apiCall($provider, $method, $uri, $params = [])
{
$methodName = $method . 'ApiCall';
if (method_exists($provider, $methodName)) {
return $provider->{$methodName}($uri, $params);
}
throw new InvalidRequestException();
} | php | protected static function apiCall($provider, $method, $uri, $params = [])
{
$methodName = $method . 'ApiCall';
if (method_exists($provider, $methodName)) {
return $provider->{$methodName}($uri, $params);
}
throw new InvalidRequestException();
} | [
"protected",
"static",
"function",
"apiCall",
"(",
"$",
"provider",
",",
"$",
"method",
",",
"$",
"uri",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"methodName",
"=",
"$",
"method",
".",
"'ApiCall'",
";",
"if",
"(",
"method_exists",
"(",
"$",
... | Sends request by given type, uri and options
@param PDFfiller $provider
@param $method
@param $uri
@param array $params
@return mixed
@throws InvalidRequestException | [
"Sends",
"request",
"by",
"given",
"type",
"uri",
"and",
"options"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L181-L188 |
44,132 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.resolveFullUrl | protected static function resolveFullUrl($entities = [], $params = [])
{
$uri = static::getUri();
if (!empty($entities)) {
if (is_array($entities)) {
$entities = implode('/', $entities) . '/';
}
if (!is_scalar($entities)) {
throw new InvalidQueryException();
}
$uri .= $entities;
}
if (!empty($params)) {
$uri .= '?' . http_build_query($params);
}
return $uri;
} | php | protected static function resolveFullUrl($entities = [], $params = [])
{
$uri = static::getUri();
if (!empty($entities)) {
if (is_array($entities)) {
$entities = implode('/', $entities) . '/';
}
if (!is_scalar($entities)) {
throw new InvalidQueryException();
}
$uri .= $entities;
}
if (!empty($params)) {
$uri .= '?' . http_build_query($params);
}
return $uri;
} | [
"protected",
"static",
"function",
"resolveFullUrl",
"(",
"$",
"entities",
"=",
"[",
"]",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"uri",
"=",
"static",
"::",
"getUri",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"entities",
")",
"... | Builds the full url
@param array $entities
@param array $params
@return string
@throws InvalidQueryException | [
"Builds",
"the",
"full",
"url"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L198-L219 |
44,133 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.query | public static function query($provider, $entities = [], $params = [])
{
$url = self::resolveFullUrl($entities, $params);
return static::apiCall($provider, 'query', $url);
} | php | public static function query($provider, $entities = [], $params = [])
{
$url = self::resolveFullUrl($entities, $params);
return static::apiCall($provider, 'query', $url);
} | [
"public",
"static",
"function",
"query",
"(",
"$",
"provider",
",",
"$",
"entities",
"=",
"[",
"]",
",",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"$",
"url",
"=",
"self",
"::",
"resolveFullUrl",
"(",
"$",
"entities",
",",
"$",
"params",
")",
";",
... | Returns entity properties as a result of get request.
@param $provider
@param array $entities
@param array $params
@return mixed
@throws InvalidQueryException
@throws InvalidRequestException | [
"Returns",
"entity",
"properties",
"as",
"a",
"result",
"of",
"get",
"request",
"."
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L230-L235 |
44,134 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.remove | public function remove()
{
if (isset($this->properties[$this->primaryKey])) {
$this->exists = false;
return static::deleteOne($this->client, $this->{$this->primaryKey});
}
throw new IdMissingException();
} | php | public function remove()
{
if (isset($this->properties[$this->primaryKey])) {
$this->exists = false;
return static::deleteOne($this->client, $this->{$this->primaryKey});
}
throw new IdMissingException();
} | [
"public",
"function",
"remove",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"properties",
"[",
"$",
"this",
"->",
"primaryKey",
"]",
")",
")",
"{",
"$",
"this",
"->",
"exists",
"=",
"false",
";",
"return",
"static",
"::",
"deleteOne",
... | Removes current instance entity if it has an id property
@return mixed
@throws IdMissingException
@throws InvalidRequestException | [
"Removes",
"current",
"instance",
"entity",
"if",
"it",
"has",
"an",
"id",
"property"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L340-L348 |
44,135 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.one | public static function one(PDFfiller $provider, $id)
{
$params = static::query($provider, $id);
$instance = new static($provider, array_merge($params, ['exists' => true]));
$instance->cacheFields($params);
return $instance;
} | php | public static function one(PDFfiller $provider, $id)
{
$params = static::query($provider, $id);
$instance = new static($provider, array_merge($params, ['exists' => true]));
$instance->cacheFields($params);
return $instance;
} | [
"public",
"static",
"function",
"one",
"(",
"PDFfiller",
"$",
"provider",
",",
"$",
"id",
")",
"{",
"$",
"params",
"=",
"static",
"::",
"query",
"(",
"$",
"provider",
",",
"$",
"id",
")",
";",
"$",
"instance",
"=",
"new",
"static",
"(",
"$",
"provi... | Returns model instance
@param PDFfiller $provider
@param $id
@return static
@throws InvalidQueryException
@throws InvalidRequestException
@throws \ReflectionException | [
"Returns",
"model",
"instance"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L373-L380 |
44,136 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.all | public static function all(PDFfiller $provider, array $queryParams = [])
{
$paramsArray = static::query($provider, null, $queryParams);
$paramsArray['items'] = static::formItems($provider, $paramsArray);
return new ModelsList($paramsArray);
} | php | public static function all(PDFfiller $provider, array $queryParams = [])
{
$paramsArray = static::query($provider, null, $queryParams);
$paramsArray['items'] = static::formItems($provider, $paramsArray);
return new ModelsList($paramsArray);
} | [
"public",
"static",
"function",
"all",
"(",
"PDFfiller",
"$",
"provider",
",",
"array",
"$",
"queryParams",
"=",
"[",
"]",
")",
"{",
"$",
"paramsArray",
"=",
"static",
"::",
"query",
"(",
"$",
"provider",
",",
"null",
",",
"$",
"queryParams",
")",
";",... | Returns a list of entities
@param PDFfiller $provider
@param array $queryParams
@return ModelsList
@throws InvalidQueryException
@throws InvalidRequestException
@throws \ReflectionException | [
"Returns",
"a",
"list",
"of",
"entities"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L391-L397 |
44,137 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.formItems | protected static function formItems($provider, $array)
{
$set = [];
foreach ($array['items'] as $params) {
$instance = new static($provider, array_merge($params, ['exists' => true]));
$instance->cacheFields($params);
if (isset($instance->id)) {
$set[$instance->id] = $instance;
} else {
$set[] = $instance;
}
}
return $set;
} | php | protected static function formItems($provider, $array)
{
$set = [];
foreach ($array['items'] as $params) {
$instance = new static($provider, array_merge($params, ['exists' => true]));
$instance->cacheFields($params);
if (isset($instance->id)) {
$set[$instance->id] = $instance;
} else {
$set[] = $instance;
}
}
return $set;
} | [
"protected",
"static",
"function",
"formItems",
"(",
"$",
"provider",
",",
"$",
"array",
")",
"{",
"$",
"set",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"array",
"[",
"'items'",
"]",
"as",
"$",
"params",
")",
"{",
"$",
"instance",
"=",
"new",
"stati... | Unwrap the instances from response
@param $provider
@param $array
@return array
@throws \ReflectionException | [
"Unwrap",
"the",
"instances",
"from",
"response"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L406-L421 |
44,138 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.findDiff | private function findDiff($new)
{
$old = $this->oldValues;
$diff = [];
foreach ($new as $key => $value) {
if (!isset($old[$key]) || $old[$key] !== $new[$key]) {
$diff[$key] = $value;
}
}
return $diff;
} | php | private function findDiff($new)
{
$old = $this->oldValues;
$diff = [];
foreach ($new as $key => $value) {
if (!isset($old[$key]) || $old[$key] !== $new[$key]) {
$diff[$key] = $value;
}
}
return $diff;
} | [
"private",
"function",
"findDiff",
"(",
"$",
"new",
")",
"{",
"$",
"old",
"=",
"$",
"this",
"->",
"oldValues",
";",
"$",
"diff",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"new",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"... | Find changed properties
@param array $new new values
@return array all new or changed values | [
"Find",
"changed",
"properties"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L472-L484 |
44,139 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.snakeToCamelCase | protected function snakeToCamelCase($string, $smallFirst = false)
{
$parts = explode('_', $string);
array_walk($parts, function(&$element) {
$element = ucfirst($element);
});
$result = implode('', $parts);
return $smallFirst ? lcfirst($result) : $result;
} | php | protected function snakeToCamelCase($string, $smallFirst = false)
{
$parts = explode('_', $string);
array_walk($parts, function(&$element) {
$element = ucfirst($element);
});
$result = implode('', $parts);
return $smallFirst ? lcfirst($result) : $result;
} | [
"protected",
"function",
"snakeToCamelCase",
"(",
"$",
"string",
",",
"$",
"smallFirst",
"=",
"false",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'_'",
",",
"$",
"string",
")",
";",
"array_walk",
"(",
"$",
"parts",
",",
"function",
"(",
"&",
"$",
... | Converts snake_cased string to camelCase
@param string $string
@param bool $smallFirst
@return string | [
"Converts",
"snake_cased",
"string",
"to",
"camelCase"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L526-L537 |
44,140 | pdffiller/pdffiller-php-api-client | src/Core/Model.php | Model.prepareFields | protected function prepareFields($options = [])
{
$params = $this->toArray($options);
if (empty($this->mapper)) {
return $params;
}
foreach ($this->mapper as $modelKey => $apiKey) {
if(array_key_exists($modelKey,$params)) {
$params[$apiKey] = $params[$modelKey];
unset($params[$modelKey]);
}
}
return $params;
} | php | protected function prepareFields($options = [])
{
$params = $this->toArray($options);
if (empty($this->mapper)) {
return $params;
}
foreach ($this->mapper as $modelKey => $apiKey) {
if(array_key_exists($modelKey,$params)) {
$params[$apiKey] = $params[$modelKey];
unset($params[$modelKey]);
}
}
return $params;
} | [
"protected",
"function",
"prepareFields",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"toArray",
"(",
"$",
"options",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"mapper",
")",
")",
"{",
"return",
... | Prepares fields with incorrect property name format
@param array $options
@return array | [
"Prepares",
"fields",
"with",
"incorrect",
"property",
"name",
"format"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Core/Model.php#L545-L561 |
44,141 | pdffiller/pdffiller-php-api-client | src/PDFfiller.php | PDFfiller.getAuthenticatedRequest | public function getAuthenticatedRequest($method, $url, $token, array $options = [])
{
$baseUri = new Psr7\Uri($this->urlApiDomain);
$relativeUri = new Psr7\Uri($url);
$newUri = Psr7\Uri::resolve($baseUri, $relativeUri);
return parent::getAuthenticatedRequest($method, $newUri, $token, $options);
} | php | public function getAuthenticatedRequest($method, $url, $token, array $options = [])
{
$baseUri = new Psr7\Uri($this->urlApiDomain);
$relativeUri = new Psr7\Uri($url);
$newUri = Psr7\Uri::resolve($baseUri, $relativeUri);
return parent::getAuthenticatedRequest($method, $newUri, $token, $options);
} | [
"public",
"function",
"getAuthenticatedRequest",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"token",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"baseUri",
"=",
"new",
"Psr7",
"\\",
"Uri",
"(",
"$",
"this",
"->",
"urlApiDomain",
"... | Returns request with authentication credentials
@param string $method
@param string $url
@param AccessToken|string $token
@param array $options
@return RequestInterface | [
"Returns",
"request",
"with",
"authentication",
"credentials"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/PDFfiller.php#L68-L75 |
44,142 | pdffiller/pdffiller-php-api-client | src/PDFfiller.php | PDFfiller.apiCall | public function apiCall($method, $url, $options = [])
{
if($this->accessToken === null) {
throw new TokenMissingException();
}
$options['headers']['User-Agent'] = self::USER_AGENT . '/' . self::VERSION;
$request = $this->getAuthenticatedRequest($method, $url, $this->getAccessToken()->getToken(), $options);
$request = $this->applyOptions($request, $options);
return $this->getResponse($request);
} | php | public function apiCall($method, $url, $options = [])
{
if($this->accessToken === null) {
throw new TokenMissingException();
}
$options['headers']['User-Agent'] = self::USER_AGENT . '/' . self::VERSION;
$request = $this->getAuthenticatedRequest($method, $url, $this->getAccessToken()->getToken(), $options);
$request = $this->applyOptions($request, $options);
return $this->getResponse($request);
} | [
"public",
"function",
"apiCall",
"(",
"$",
"method",
",",
"$",
"url",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"accessToken",
"===",
"null",
")",
"{",
"throw",
"new",
"TokenMissingException",
"(",
")",
";",
"}",
"... | Performs a request and returns the response
@param $method
@param $url
@param array $options
@return array
@throws TokenMissingException | [
"Performs",
"a",
"request",
"and",
"returns",
"the",
"response"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/PDFfiller.php#L199-L210 |
44,143 | pdffiller/pdffiller-php-api-client | src/PDFfiller.php | PDFfiller.getAccessToken | public function getAccessToken($grant = 'client_credentials', array $options = [])
{
if($this->accessToken !== null) {
return $this->accessToken;
}
return $this->accessToken = $this->issueAccessToken($grant, $options);
} | php | public function getAccessToken($grant = 'client_credentials', array $options = [])
{
if($this->accessToken !== null) {
return $this->accessToken;
}
return $this->accessToken = $this->issueAccessToken($grant, $options);
} | [
"public",
"function",
"getAccessToken",
"(",
"$",
"grant",
"=",
"'client_credentials'",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"accessToken",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"accessToken... | Returns an access token object
@param string $grant
@param array $options
@return AccessToken | [
"Returns",
"an",
"access",
"token",
"object"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/PDFfiller.php#L312-L319 |
44,144 | pdffiller/pdffiller-php-api-client | src/PDFfiller.php | PDFfiller.issueAccessToken | public function issueAccessToken($grant, array $options = [])
{
if ($grant instanceof GrantType) {
$grant = $grant->getValue();
}
return parent::getAccessToken($grant, $options);
} | php | public function issueAccessToken($grant, array $options = [])
{
if ($grant instanceof GrantType) {
$grant = $grant->getValue();
}
return parent::getAccessToken($grant, $options);
} | [
"public",
"function",
"issueAccessToken",
"(",
"$",
"grant",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"grant",
"instanceof",
"GrantType",
")",
"{",
"$",
"grant",
"=",
"$",
"grant",
"->",
"getValue",
"(",
")",
";",
"}",
... | Requests a new access token
@param $grant
@param array $options
@return AccessToken | [
"Requests",
"a",
"new",
"access",
"token"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/PDFfiller.php#L328-L335 |
44,145 | pdffiller/pdffiller-php-api-client | src/SignatureRequestRecipient.php | SignatureRequestRecipient.remind | public function remind()
{
$uri = $this->uri() . $this->id . '/' . self::REMIND;
return static::put($this->client, $uri);
} | php | public function remind()
{
$uri = $this->uri() . $this->id . '/' . self::REMIND;
return static::put($this->client, $uri);
} | [
"public",
"function",
"remind",
"(",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"uri",
"(",
")",
".",
"$",
"this",
"->",
"id",
".",
"'/'",
".",
"self",
"::",
"REMIND",
";",
"return",
"static",
"::",
"put",
"(",
"$",
"this",
"->",
"client",
"... | Send the remind email to recipient
@return mixed | [
"Send",
"the",
"remind",
"email",
"to",
"recipient"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/SignatureRequestRecipient.php#L93-L98 |
44,146 | pdffiller/pdffiller-php-api-client | src/SignatureRequestRecipient.php | SignatureRequestRecipient.create | public function create($options = [])
{
$params = $this->toArray($options);
$recipients['recipients'] = [$params];
$uri = $this->uri();
$createResult = static::post($this->client, $uri, [
'json' => $recipients,
]);
if (isset($createResult['errors'])) {
throw new ResponseException($createResult['errors']);
}
$recipientData = array_filter($createResult['recipients'], function ($recipient) use ($params) {
return $recipient['email'] == $params['email'];
});
return $this->parseArray(array_pop($recipientData));
} | php | public function create($options = [])
{
$params = $this->toArray($options);
$recipients['recipients'] = [$params];
$uri = $this->uri();
$createResult = static::post($this->client, $uri, [
'json' => $recipients,
]);
if (isset($createResult['errors'])) {
throw new ResponseException($createResult['errors']);
}
$recipientData = array_filter($createResult['recipients'], function ($recipient) use ($params) {
return $recipient['email'] == $params['email'];
});
return $this->parseArray(array_pop($recipientData));
} | [
"public",
"function",
"create",
"(",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"toArray",
"(",
"$",
"options",
")",
";",
"$",
"recipients",
"[",
"'recipients'",
"]",
"=",
"[",
"$",
"params",
"]",
";",
"$",
"u... | Returns created recipient info.
@param array $options
@return mixed
@throws ResponseException | [
"Returns",
"created",
"recipient",
"info",
"."
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/SignatureRequestRecipient.php#L126-L145 |
44,147 | pdffiller/pdffiller-php-api-client | src/Uploader.php | Uploader.getUploadParams | public function getUploadParams()
{
if ($this->type === self::TYPE_URL) {
return [
'json' => array_merge($this->getAdditionalAttributes(), ['file' => $this->file]),
];
}
if ($this->type === self::TYPE_MULTIPART) {
$params[] = [
'name' => 'file',
'contents' => fopen($this->file, 'r'),
];
foreach ($this->getAdditionalAttributes() as $key => $value) {
$params[] = [
'name' => $key,
'contents' => $value,
];
}
return [
'multipart' => $params
];
}
return null;
} | php | public function getUploadParams()
{
if ($this->type === self::TYPE_URL) {
return [
'json' => array_merge($this->getAdditionalAttributes(), ['file' => $this->file]),
];
}
if ($this->type === self::TYPE_MULTIPART) {
$params[] = [
'name' => 'file',
'contents' => fopen($this->file, 'r'),
];
foreach ($this->getAdditionalAttributes() as $key => $value) {
$params[] = [
'name' => $key,
'contents' => $value,
];
}
return [
'multipart' => $params
];
}
return null;
} | [
"public",
"function",
"getUploadParams",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"type",
"===",
"self",
"::",
"TYPE_URL",
")",
"{",
"return",
"[",
"'json'",
"=>",
"array_merge",
"(",
"$",
"this",
"->",
"getAdditionalAttributes",
"(",
")",
",",
"[",
... | Prepares upload request parameters
@return array|null | [
"Prepares",
"upload",
"request",
"parameters"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Uploader.php#L75-L102 |
44,148 | pdffiller/pdffiller-php-api-client | src/Uploader.php | Uploader.upload | public function upload()
{
$params = $this->getUploadParams();
if ($params) {
$class = $this->class;
$uri = $class::getUri();
$document = static::post($this->client, $uri, $params);
/** @var Model $instance */
$instance = new $this->class($this->client, $document);
$instance->exists = true;
$instance->cacheFields($document);
return $instance;
}
return null;
} | php | public function upload()
{
$params = $this->getUploadParams();
if ($params) {
$class = $this->class;
$uri = $class::getUri();
$document = static::post($this->client, $uri, $params);
/** @var Model $instance */
$instance = new $this->class($this->client, $document);
$instance->exists = true;
$instance->cacheFields($document);
return $instance;
}
return null;
} | [
"public",
"function",
"upload",
"(",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"getUploadParams",
"(",
")",
";",
"if",
"(",
"$",
"params",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"class",
";",
"$",
"uri",
"=",
"$",
"class",
"::",
... | Uploads file and returns the model
@return null|Model | [
"Uploads",
"file",
"and",
"returns",
"the",
"model"
] | 162729d6084a8a508a2283831ddc53a29a978199 | https://github.com/pdffiller/pdffiller-php-api-client/blob/162729d6084a8a508a2283831ddc53a29a978199/src/Uploader.php#L117-L134 |
44,149 | wp-cli/wp-config-transformer | src/WPConfigTransformer.php | WPConfigTransformer.exists | public function exists( $type, $name ) {
$wp_config_src = file_get_contents( $this->wp_config_path );
if ( ! trim( $wp_config_src ) ) {
throw new Exception( 'Config file is empty.' );
}
// Normalize the newline to prevent an issue coming from OSX.
$this->wp_config_src = str_replace( array( "\n\r", "\r" ), "\n", $wp_config_src );
$this->wp_configs = $this->parse_wp_config( $this->wp_config_src );
if ( ! isset( $this->wp_configs[ $type ] ) ) {
throw new Exception( "Config type '{$type}' does not exist." );
}
return isset( $this->wp_configs[ $type ][ $name ] );
} | php | public function exists( $type, $name ) {
$wp_config_src = file_get_contents( $this->wp_config_path );
if ( ! trim( $wp_config_src ) ) {
throw new Exception( 'Config file is empty.' );
}
// Normalize the newline to prevent an issue coming from OSX.
$this->wp_config_src = str_replace( array( "\n\r", "\r" ), "\n", $wp_config_src );
$this->wp_configs = $this->parse_wp_config( $this->wp_config_src );
if ( ! isset( $this->wp_configs[ $type ] ) ) {
throw new Exception( "Config type '{$type}' does not exist." );
}
return isset( $this->wp_configs[ $type ][ $name ] );
} | [
"public",
"function",
"exists",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"$",
"wp_config_src",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"wp_config_path",
")",
";",
"if",
"(",
"!",
"trim",
"(",
"$",
"wp_config_src",
")",
")",
"{",
"throw",... | Checks if a config exists in the wp-config.php file.
@throws Exception If the wp-config.php file is empty.
@throws Exception If the requested config type is invalid.
@param string $type Config type (constant or variable).
@param string $name Config name.
@return bool | [
"Checks",
"if",
"a",
"config",
"exists",
"in",
"the",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | c56eb037182c907529d8ac69762d8b63343c3cce | https://github.com/wp-cli/wp-config-transformer/blob/c56eb037182c907529d8ac69762d8b63343c3cce/src/WPConfigTransformer.php#L62-L77 |
44,150 | wp-cli/wp-config-transformer | src/WPConfigTransformer.php | WPConfigTransformer.get_value | public function get_value( $type, $name ) {
$wp_config_src = file_get_contents( $this->wp_config_path );
if ( ! trim( $wp_config_src ) ) {
throw new Exception( 'Config file is empty.' );
}
$this->wp_config_src = $wp_config_src;
$this->wp_configs = $this->parse_wp_config( $this->wp_config_src );
if ( ! isset( $this->wp_configs[ $type ] ) ) {
throw new Exception( "Config type '{$type}' does not exist." );
}
return $this->wp_configs[ $type ][ $name ]['value'];
} | php | public function get_value( $type, $name ) {
$wp_config_src = file_get_contents( $this->wp_config_path );
if ( ! trim( $wp_config_src ) ) {
throw new Exception( 'Config file is empty.' );
}
$this->wp_config_src = $wp_config_src;
$this->wp_configs = $this->parse_wp_config( $this->wp_config_src );
if ( ! isset( $this->wp_configs[ $type ] ) ) {
throw new Exception( "Config type '{$type}' does not exist." );
}
return $this->wp_configs[ $type ][ $name ]['value'];
} | [
"public",
"function",
"get_value",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"$",
"wp_config_src",
"=",
"file_get_contents",
"(",
"$",
"this",
"->",
"wp_config_path",
")",
";",
"if",
"(",
"!",
"trim",
"(",
"$",
"wp_config_src",
")",
")",
"{",
"thro... | Get the value of a config in the wp-config.php file.
@throws Exception If the wp-config.php file is empty.
@throws Exception If the requested config type is invalid.
@param string $type Config type (constant or variable).
@param string $name Config name.
@return array | [
"Get",
"the",
"value",
"of",
"a",
"config",
"in",
"the",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | c56eb037182c907529d8ac69762d8b63343c3cce | https://github.com/wp-cli/wp-config-transformer/blob/c56eb037182c907529d8ac69762d8b63343c3cce/src/WPConfigTransformer.php#L90-L105 |
44,151 | wp-cli/wp-config-transformer | src/WPConfigTransformer.php | WPConfigTransformer.add | public function add( $type, $name, $value, array $options = array() ) {
if ( ! is_string( $value ) ) {
throw new Exception( 'Config value must be a string.' );
}
if ( $this->exists( $type, $name ) ) {
return false;
}
$defaults = array(
'raw' => false, // Display value in raw format without quotes.
'anchor' => "/* That's all, stop editing!", // Config placement anchor string.
'separator' => PHP_EOL, // Separator between config definition and anchor string.
'placement' => 'before', // Config placement direction (insert before or after).
);
list( $raw, $anchor, $separator, $placement ) = array_values( array_merge( $defaults, $options ) );
$raw = (bool) $raw;
$anchor = (string) $anchor;
$separator = (string) $separator;
$placement = (string) $placement;
if ( false === strpos( $this->wp_config_src, $anchor ) ) {
throw new Exception( 'Unable to locate placement anchor.' );
}
$new_src = $this->normalize( $type, $name, $this->format_value( $value, $raw ) );
$new_src = ( 'after' === $placement ) ? $anchor . $separator . $new_src : $new_src . $separator . $anchor;
$contents = str_replace( $anchor, $new_src, $this->wp_config_src );
return $this->save( $contents );
} | php | public function add( $type, $name, $value, array $options = array() ) {
if ( ! is_string( $value ) ) {
throw new Exception( 'Config value must be a string.' );
}
if ( $this->exists( $type, $name ) ) {
return false;
}
$defaults = array(
'raw' => false, // Display value in raw format without quotes.
'anchor' => "/* That's all, stop editing!", // Config placement anchor string.
'separator' => PHP_EOL, // Separator between config definition and anchor string.
'placement' => 'before', // Config placement direction (insert before or after).
);
list( $raw, $anchor, $separator, $placement ) = array_values( array_merge( $defaults, $options ) );
$raw = (bool) $raw;
$anchor = (string) $anchor;
$separator = (string) $separator;
$placement = (string) $placement;
if ( false === strpos( $this->wp_config_src, $anchor ) ) {
throw new Exception( 'Unable to locate placement anchor.' );
}
$new_src = $this->normalize( $type, $name, $this->format_value( $value, $raw ) );
$new_src = ( 'after' === $placement ) ? $anchor . $separator . $new_src : $new_src . $separator . $anchor;
$contents = str_replace( $anchor, $new_src, $this->wp_config_src );
return $this->save( $contents );
} | [
"public",
"function",
"add",
"(",
"$",
"type",
",",
"$",
"name",
",",
"$",
"value",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
... | Adds a config to the wp-config.php file.
@throws Exception If the config value provided is not a string.
@throws Exception If the config placement anchor could not be located.
@param string $type Config type (constant or variable).
@param string $name Config name.
@param string $value Config value.
@param array $options (optional) Array of special behavior options.
@return bool | [
"Adds",
"a",
"config",
"to",
"the",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | c56eb037182c907529d8ac69762d8b63343c3cce | https://github.com/wp-cli/wp-config-transformer/blob/c56eb037182c907529d8ac69762d8b63343c3cce/src/WPConfigTransformer.php#L120-L152 |
44,152 | wp-cli/wp-config-transformer | src/WPConfigTransformer.php | WPConfigTransformer.update | public function update( $type, $name, $value, array $options = array() ) {
if ( ! is_string( $value ) ) {
throw new Exception( 'Config value must be a string.' );
}
$defaults = array(
'add' => true, // Add the config if missing.
'raw' => false, // Display value in raw format without quotes.
'normalize' => false, // Normalize config output using WP Coding Standards.
);
list( $add, $raw, $normalize ) = array_values( array_merge( $defaults, $options ) );
$add = (bool) $add;
$raw = (bool) $raw;
$normalize = (bool) $normalize;
if ( ! $this->exists( $type, $name ) ) {
return ( $add ) ? $this->add( $type, $name, $value, $options ) : false;
}
$old_src = $this->wp_configs[ $type ][ $name ]['src'];
$old_value = $this->wp_configs[ $type ][ $name ]['value'];
$new_value = $this->format_value( $value, $raw );
if ( $normalize ) {
$new_src = $this->normalize( $type, $name, $new_value );
} else {
$new_parts = $this->wp_configs[ $type ][ $name ]['parts'];
$new_parts[1] = str_replace( $old_value, $new_value, $new_parts[1] ); // Only edit the value part.
$new_src = implode( '', $new_parts );
}
$contents = preg_replace(
sprintf( '/(?<=^|;|<\?php\s|<\?\s)(\s*?)%s/m', preg_quote( trim( $old_src ), '/' ) ),
'$1' . str_replace( '$', '\$', trim( $new_src ) ),
$this->wp_config_src
);
return $this->save( $contents );
} | php | public function update( $type, $name, $value, array $options = array() ) {
if ( ! is_string( $value ) ) {
throw new Exception( 'Config value must be a string.' );
}
$defaults = array(
'add' => true, // Add the config if missing.
'raw' => false, // Display value in raw format without quotes.
'normalize' => false, // Normalize config output using WP Coding Standards.
);
list( $add, $raw, $normalize ) = array_values( array_merge( $defaults, $options ) );
$add = (bool) $add;
$raw = (bool) $raw;
$normalize = (bool) $normalize;
if ( ! $this->exists( $type, $name ) ) {
return ( $add ) ? $this->add( $type, $name, $value, $options ) : false;
}
$old_src = $this->wp_configs[ $type ][ $name ]['src'];
$old_value = $this->wp_configs[ $type ][ $name ]['value'];
$new_value = $this->format_value( $value, $raw );
if ( $normalize ) {
$new_src = $this->normalize( $type, $name, $new_value );
} else {
$new_parts = $this->wp_configs[ $type ][ $name ]['parts'];
$new_parts[1] = str_replace( $old_value, $new_value, $new_parts[1] ); // Only edit the value part.
$new_src = implode( '', $new_parts );
}
$contents = preg_replace(
sprintf( '/(?<=^|;|<\?php\s|<\?\s)(\s*?)%s/m', preg_quote( trim( $old_src ), '/' ) ),
'$1' . str_replace( '$', '\$', trim( $new_src ) ),
$this->wp_config_src
);
return $this->save( $contents );
} | [
"public",
"function",
"update",
"(",
"$",
"type",
",",
"$",
"name",
",",
"$",
"value",
",",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"Exception",
"("... | Updates an existing config in the wp-config.php file.
@throws Exception If the config value provided is not a string.
@param string $type Config type (constant or variable).
@param string $name Config name.
@param string $value Config value.
@param array $options (optional) Array of special behavior options.
@return bool | [
"Updates",
"an",
"existing",
"config",
"in",
"the",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | c56eb037182c907529d8ac69762d8b63343c3cce | https://github.com/wp-cli/wp-config-transformer/blob/c56eb037182c907529d8ac69762d8b63343c3cce/src/WPConfigTransformer.php#L166-L206 |
44,153 | wp-cli/wp-config-transformer | src/WPConfigTransformer.php | WPConfigTransformer.remove | public function remove( $type, $name ) {
if ( ! $this->exists( $type, $name ) ) {
return false;
}
$pattern = sprintf( '/(?<=^|;|<\?php\s|<\?\s)%s\s*(\S|$)/m', preg_quote( $this->wp_configs[ $type ][ $name ]['src'], '/' ) );
$contents = preg_replace( $pattern, '$1', $this->wp_config_src );
return $this->save( $contents );
} | php | public function remove( $type, $name ) {
if ( ! $this->exists( $type, $name ) ) {
return false;
}
$pattern = sprintf( '/(?<=^|;|<\?php\s|<\?\s)%s\s*(\S|$)/m', preg_quote( $this->wp_configs[ $type ][ $name ]['src'], '/' ) );
$contents = preg_replace( $pattern, '$1', $this->wp_config_src );
return $this->save( $contents );
} | [
"public",
"function",
"remove",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"exists",
"(",
"$",
"type",
",",
"$",
"name",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"pattern",
"=",
"sprintf",
"(",
"'/(... | Removes a config from the wp-config.php file.
@param string $type Config type (constant or variable).
@param string $name Config name.
@return bool | [
"Removes",
"a",
"config",
"from",
"the",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | c56eb037182c907529d8ac69762d8b63343c3cce | https://github.com/wp-cli/wp-config-transformer/blob/c56eb037182c907529d8ac69762d8b63343c3cce/src/WPConfigTransformer.php#L216-L225 |
44,154 | wp-cli/wp-config-transformer | src/WPConfigTransformer.php | WPConfigTransformer.format_value | protected function format_value( $value, $raw ) {
if ( $raw && '' === trim( $value ) ) {
throw new Exception( 'Raw value for empty string not supported.' );
}
return ( $raw ) ? $value : var_export( $value, true );
} | php | protected function format_value( $value, $raw ) {
if ( $raw && '' === trim( $value ) ) {
throw new Exception( 'Raw value for empty string not supported.' );
}
return ( $raw ) ? $value : var_export( $value, true );
} | [
"protected",
"function",
"format_value",
"(",
"$",
"value",
",",
"$",
"raw",
")",
"{",
"if",
"(",
"$",
"raw",
"&&",
"''",
"===",
"trim",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Raw value for empty string not supported.'",
")",... | Applies formatting to a config value.
@throws Exception When a raw value is requested for an empty string.
@param string $value Config value.
@param bool $raw Display value in raw format without quotes.
@return mixed | [
"Applies",
"formatting",
"to",
"a",
"config",
"value",
"."
] | c56eb037182c907529d8ac69762d8b63343c3cce | https://github.com/wp-cli/wp-config-transformer/blob/c56eb037182c907529d8ac69762d8b63343c3cce/src/WPConfigTransformer.php#L237-L243 |
44,155 | wp-cli/wp-config-transformer | src/WPConfigTransformer.php | WPConfigTransformer.parse_wp_config | protected function parse_wp_config( $src ) {
$configs = array();
$configs['constant'] = array();
$configs['variable'] = array();
// Strip comments.
foreach ( token_get_all( $src ) as $token ) {
if ( in_array( $token[0], array( T_COMMENT, T_DOC_COMMENT ), true ) ) {
$src = str_replace( $token[1], '', $src );
}
}
preg_match_all( '/(?<=^|;|<\?php\s|<\?\s)(\h*define\s*\(\s*[\'"](\w*?)[\'"]\s*)(,\s*(\'\'|""|\'.*?[^\\\\]\'|".*?[^\\\\]"|.*?)\s*)((?:,\s*(?:true|false)\s*)?\)\s*;)/ims', $src, $constants );
preg_match_all( '/(?<=^|;|<\?php\s|<\?\s)(\h*\$(\w+)\s*=)(\s*(\'\'|""|\'.*?[^\\\\]\'|".*?[^\\\\]"|.*?)\s*;)/ims', $src, $variables );
if ( ! empty( $constants[0] ) && ! empty( $constants[1] ) && ! empty( $constants[2] ) && ! empty( $constants[3] ) && ! empty( $constants[4] ) && ! empty( $constants[5] ) ) {
foreach ( $constants[2] as $index => $name ) {
$configs['constant'][ $name ] = array(
'src' => $constants[0][ $index ],
'value' => $constants[4][ $index ],
'parts' => array(
$constants[1][ $index ],
$constants[3][ $index ],
$constants[5][ $index ],
),
);
}
}
if ( ! empty( $variables[0] ) && ! empty( $variables[1] ) && ! empty( $variables[2] ) && ! empty( $variables[3] ) && ! empty( $variables[4] ) ) {
// Remove duplicate(s), last definition wins.
$variables[2] = array_reverse( array_unique( array_reverse( $variables[2], true ) ), true );
foreach ( $variables[2] as $index => $name ) {
$configs['variable'][ $name ] = array(
'src' => $variables[0][ $index ],
'value' => $variables[4][ $index ],
'parts' => array(
$variables[1][ $index ],
$variables[3][ $index ],
),
);
}
}
return $configs;
} | php | protected function parse_wp_config( $src ) {
$configs = array();
$configs['constant'] = array();
$configs['variable'] = array();
// Strip comments.
foreach ( token_get_all( $src ) as $token ) {
if ( in_array( $token[0], array( T_COMMENT, T_DOC_COMMENT ), true ) ) {
$src = str_replace( $token[1], '', $src );
}
}
preg_match_all( '/(?<=^|;|<\?php\s|<\?\s)(\h*define\s*\(\s*[\'"](\w*?)[\'"]\s*)(,\s*(\'\'|""|\'.*?[^\\\\]\'|".*?[^\\\\]"|.*?)\s*)((?:,\s*(?:true|false)\s*)?\)\s*;)/ims', $src, $constants );
preg_match_all( '/(?<=^|;|<\?php\s|<\?\s)(\h*\$(\w+)\s*=)(\s*(\'\'|""|\'.*?[^\\\\]\'|".*?[^\\\\]"|.*?)\s*;)/ims', $src, $variables );
if ( ! empty( $constants[0] ) && ! empty( $constants[1] ) && ! empty( $constants[2] ) && ! empty( $constants[3] ) && ! empty( $constants[4] ) && ! empty( $constants[5] ) ) {
foreach ( $constants[2] as $index => $name ) {
$configs['constant'][ $name ] = array(
'src' => $constants[0][ $index ],
'value' => $constants[4][ $index ],
'parts' => array(
$constants[1][ $index ],
$constants[3][ $index ],
$constants[5][ $index ],
),
);
}
}
if ( ! empty( $variables[0] ) && ! empty( $variables[1] ) && ! empty( $variables[2] ) && ! empty( $variables[3] ) && ! empty( $variables[4] ) ) {
// Remove duplicate(s), last definition wins.
$variables[2] = array_reverse( array_unique( array_reverse( $variables[2], true ) ), true );
foreach ( $variables[2] as $index => $name ) {
$configs['variable'][ $name ] = array(
'src' => $variables[0][ $index ],
'value' => $variables[4][ $index ],
'parts' => array(
$variables[1][ $index ],
$variables[3][ $index ],
),
);
}
}
return $configs;
} | [
"protected",
"function",
"parse_wp_config",
"(",
"$",
"src",
")",
"{",
"$",
"configs",
"=",
"array",
"(",
")",
";",
"$",
"configs",
"[",
"'constant'",
"]",
"=",
"array",
"(",
")",
";",
"$",
"configs",
"[",
"'variable'",
"]",
"=",
"array",
"(",
")",
... | Parses the source of a wp-config.php file.
@param string $src Config file source.
@return array | [
"Parses",
"the",
"source",
"of",
"a",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | c56eb037182c907529d8ac69762d8b63343c3cce | https://github.com/wp-cli/wp-config-transformer/blob/c56eb037182c907529d8ac69762d8b63343c3cce/src/WPConfigTransformer.php#L275-L320 |
44,156 | wp-cli/wp-config-transformer | src/WPConfigTransformer.php | WPConfigTransformer.save | protected function save( $contents ) {
if ( ! trim( $contents ) ) {
throw new Exception( 'Cannot save the config file with empty contents.' );
}
if ( $contents === $this->wp_config_src ) {
return false;
}
$result = file_put_contents( $this->wp_config_path, $contents, LOCK_EX );
if ( false === $result ) {
throw new Exception( 'Failed to update the config file.' );
}
return true;
} | php | protected function save( $contents ) {
if ( ! trim( $contents ) ) {
throw new Exception( 'Cannot save the config file with empty contents.' );
}
if ( $contents === $this->wp_config_src ) {
return false;
}
$result = file_put_contents( $this->wp_config_path, $contents, LOCK_EX );
if ( false === $result ) {
throw new Exception( 'Failed to update the config file.' );
}
return true;
} | [
"protected",
"function",
"save",
"(",
"$",
"contents",
")",
"{",
"if",
"(",
"!",
"trim",
"(",
"$",
"contents",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot save the config file with empty contents.'",
")",
";",
"}",
"if",
"(",
"$",
"contents",
... | Saves new contents to the wp-config.php file.
@throws Exception If the config file content provided is empty.
@throws Exception If there is a failure when saving the wp-config.php file.
@param string $contents New config contents.
@return bool | [
"Saves",
"new",
"contents",
"to",
"the",
"wp",
"-",
"config",
".",
"php",
"file",
"."
] | c56eb037182c907529d8ac69762d8b63343c3cce | https://github.com/wp-cli/wp-config-transformer/blob/c56eb037182c907529d8ac69762d8b63343c3cce/src/WPConfigTransformer.php#L332-L348 |
44,157 | rchouinard/phpass | src/Phpass/Hash/Adapter/Sha1Crypt.php | Sha1Crypt.verifyHash | public function verifyHash($input)
{
$salt = substr($input, 0, strrpos($input, '$') + 1);
$checksum = substr($input, strrpos($input, '$') + 1);
return ($this->verifySalt($salt) && 1 === preg_match('/^[\.\/0-9A-Za-z]{28}$/', $checksum));
} | php | public function verifyHash($input)
{
$salt = substr($input, 0, strrpos($input, '$') + 1);
$checksum = substr($input, strrpos($input, '$') + 1);
return ($this->verifySalt($salt) && 1 === preg_match('/^[\.\/0-9A-Za-z]{28}$/', $checksum));
} | [
"public",
"function",
"verifyHash",
"(",
"$",
"input",
")",
"{",
"$",
"salt",
"=",
"substr",
"(",
"$",
"input",
",",
"0",
",",
"strrpos",
"(",
"$",
"input",
",",
"'$'",
")",
"+",
"1",
")",
";",
"$",
"checksum",
"=",
"substr",
"(",
"$",
"input",
... | Check if a hash string is valid for the current adapter.
@since 2.1.0
@param string $input
Hash string to verify.
@return boolean
Returns true if the input string is a valid hash value, false
otherwise. | [
"Check",
"if",
"a",
"hash",
"string",
"is",
"valid",
"for",
"the",
"current",
"adapter",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Hash/Adapter/Sha1Crypt.php#L180-L186 |
44,158 | rchouinard/phpass | src/Phpass/Hash/Adapter/Sha1Crypt.php | Sha1Crypt._getSettings | protected function _getSettings($input)
{
$parts = array ();
$matches = array ();
if (1 === preg_match('/^\$sha1\$(\d+)\$([\.\/0-9A-Za-z]{0,64})(?:\$([\.\/0-9A-Za-z]{28}))?$/', rtrim($input, '$'), $matches)) {
$parts['rounds'] = $matches[1];
$parts['salt'] = $matches[2];
$parts['checksum'] = $matches[3] ?: null;
}
return $parts;
} | php | protected function _getSettings($input)
{
$parts = array ();
$matches = array ();
if (1 === preg_match('/^\$sha1\$(\d+)\$([\.\/0-9A-Za-z]{0,64})(?:\$([\.\/0-9A-Za-z]{28}))?$/', rtrim($input, '$'), $matches)) {
$parts['rounds'] = $matches[1];
$parts['salt'] = $matches[2];
$parts['checksum'] = $matches[3] ?: null;
}
return $parts;
} | [
"protected",
"function",
"_getSettings",
"(",
"$",
"input",
")",
"{",
"$",
"parts",
"=",
"array",
"(",
")",
";",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"if",
"(",
"1",
"===",
"preg_match",
"(",
"'/^\\$sha1\\$(\\d+)\\$([\\.\\/0-9A-Za-z]{0,64})(?:\\$([\\.\... | Return an array of hash settings from a given salt string.
@param unknown_type $input | [
"Return",
"an",
"array",
"of",
"hash",
"settings",
"from",
"a",
"given",
"salt",
"string",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Hash/Adapter/Sha1Crypt.php#L221-L232 |
44,159 | rchouinard/phpass | src/Phpass/Strength/Adapter/Wolfram.php | Wolfram._calculateLetterScore | protected function _calculateLetterScore()
{
$score = 0;
foreach (array (self::CLASS_UPPER, self::CLASS_LOWER) as $class) {
$letterCount = $this->_getClassCount($class);
if ($letterCount != $this->_length) {
if ($letterCount > 0) {
$score += ($this->_length - $letterCount) * 2;
}
}
}
return $score;
} | php | protected function _calculateLetterScore()
{
$score = 0;
foreach (array (self::CLASS_UPPER, self::CLASS_LOWER) as $class) {
$letterCount = $this->_getClassCount($class);
if ($letterCount != $this->_length) {
if ($letterCount > 0) {
$score += ($this->_length - $letterCount) * 2;
}
}
}
return $score;
} | [
"protected",
"function",
"_calculateLetterScore",
"(",
")",
"{",
"$",
"score",
"=",
"0",
";",
"foreach",
"(",
"array",
"(",
"self",
"::",
"CLASS_UPPER",
",",
"self",
"::",
"CLASS_LOWER",
")",
"as",
"$",
"class",
")",
"{",
"$",
"letterCount",
"=",
"$",
... | Return the score for letter tokens.
@return integer | [
"Return",
"the",
"score",
"for",
"letter",
"tokens",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Strength/Adapter/Wolfram.php#L78-L93 |
44,160 | rchouinard/phpass | src/Phpass/Strength/Adapter/Wolfram.php | Wolfram._calculateNumberScore | protected function _calculateNumberScore()
{
$score = 0;
$numberCount = $this->_getClassCount(self::CLASS_NUMBER);
if ($numberCount > 0 && $numberCount != $this->_length) {
$score += $numberCount * 4;
}
return $score;
} | php | protected function _calculateNumberScore()
{
$score = 0;
$numberCount = $this->_getClassCount(self::CLASS_NUMBER);
if ($numberCount > 0 && $numberCount != $this->_length) {
$score += $numberCount * 4;
}
return $score;
} | [
"protected",
"function",
"_calculateNumberScore",
"(",
")",
"{",
"$",
"score",
"=",
"0",
";",
"$",
"numberCount",
"=",
"$",
"this",
"->",
"_getClassCount",
"(",
"self",
"::",
"CLASS_NUMBER",
")",
";",
"if",
"(",
"$",
"numberCount",
">",
"0",
"&&",
"$",
... | Return the score for numeric tokens.
@return integer | [
"Return",
"the",
"score",
"for",
"numeric",
"tokens",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Strength/Adapter/Wolfram.php#L100-L110 |
44,161 | rchouinard/phpass | src/Phpass/Strength/Adapter/Wolfram.php | Wolfram._calculateSymbolScore | protected function _calculateSymbolScore()
{
$score = 0;
$symbolCount = $this->_getClassCount(self::CLASS_SYMBOL);
if ($symbolCount > 0) {
$score += $symbolCount * 6;
}
return $score;
} | php | protected function _calculateSymbolScore()
{
$score = 0;
$symbolCount = $this->_getClassCount(self::CLASS_SYMBOL);
if ($symbolCount > 0) {
$score += $symbolCount * 6;
}
return $score;
} | [
"protected",
"function",
"_calculateSymbolScore",
"(",
")",
"{",
"$",
"score",
"=",
"0",
";",
"$",
"symbolCount",
"=",
"$",
"this",
"->",
"_getClassCount",
"(",
"self",
"::",
"CLASS_SYMBOL",
")",
";",
"if",
"(",
"$",
"symbolCount",
">",
"0",
")",
"{",
... | Return the score for symbol tokens.
@return integer | [
"Return",
"the",
"score",
"for",
"symbol",
"tokens",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Strength/Adapter/Wolfram.php#L117-L127 |
44,162 | rchouinard/phpass | src/Phpass/Strength/Adapter/Wolfram.php | Wolfram._calculateMiddleNumberOrSymbolScore | protected function _calculateMiddleNumberOrSymbolScore()
{
$score = 0;
// The Wolfram algorithm actually only accounts for numbers, despite
// what the rule name implies and others have documented.
//
// I've decided to account for both numbers and symbols as the rule
// implies, and treat the Wolfram calculator as bugged. This will mean
// that the calculations of this class and the Wolfram calculator may
// not always match.
foreach (array (self::CLASS_NUMBER, self::CLASS_SYMBOL) as $class) {
$indices = $this->_getClassIndices($class);
foreach ($indices as $key => $index) {
if ($index == 0 || $index == $this->_length - 1) {
unset ($indices[$key]);
}
}
$score += count($indices) * 2;
}
return $score;
} | php | protected function _calculateMiddleNumberOrSymbolScore()
{
$score = 0;
// The Wolfram algorithm actually only accounts for numbers, despite
// what the rule name implies and others have documented.
//
// I've decided to account for both numbers and symbols as the rule
// implies, and treat the Wolfram calculator as bugged. This will mean
// that the calculations of this class and the Wolfram calculator may
// not always match.
foreach (array (self::CLASS_NUMBER, self::CLASS_SYMBOL) as $class) {
$indices = $this->_getClassIndices($class);
foreach ($indices as $key => $index) {
if ($index == 0 || $index == $this->_length - 1) {
unset ($indices[$key]);
}
}
$score += count($indices) * 2;
}
return $score;
} | [
"protected",
"function",
"_calculateMiddleNumberOrSymbolScore",
"(",
")",
"{",
"$",
"score",
"=",
"0",
";",
"// The Wolfram algorithm actually only accounts for numbers, despite",
"// what the rule name implies and others have documented.",
"//",
"// I've decided to account for both numb... | Return the score for special tokens in the middle of the string.
@return integer | [
"Return",
"the",
"score",
"for",
"special",
"tokens",
"in",
"the",
"middle",
"of",
"the",
"string",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Strength/Adapter/Wolfram.php#L134-L156 |
44,163 | rchouinard/phpass | src/Phpass/Strength/Adapter/Wolfram.php | Wolfram._calculateRepeatTokenScore | protected function _calculateRepeatTokenScore()
{
$score = 0;
$repeats = 0;
foreach ($this->_tokens as $tokenCount) {
if ($tokenCount > 1) {
$repeats += $tokenCount - 1;
}
}
if ($repeats > 0) {
$score -= (int) ($repeats / ($this->_length - $repeats)) + 1;
}
return $score;
} | php | protected function _calculateRepeatTokenScore()
{
$score = 0;
$repeats = 0;
foreach ($this->_tokens as $tokenCount) {
if ($tokenCount > 1) {
$repeats += $tokenCount - 1;
}
}
if ($repeats > 0) {
$score -= (int) ($repeats / ($this->_length - $repeats)) + 1;
}
return $score;
} | [
"protected",
"function",
"_calculateRepeatTokenScore",
"(",
")",
"{",
"$",
"score",
"=",
"0",
";",
"$",
"repeats",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"_tokens",
"as",
"$",
"tokenCount",
")",
"{",
"if",
"(",
"$",
"tokenCount",
">",
"1",
... | Return the score for repeated characters.
@return integer | [
"Return",
"the",
"score",
"for",
"repeated",
"characters",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Strength/Adapter/Wolfram.php#L163-L179 |
44,164 | rchouinard/phpass | src/Phpass/Strength/Adapter/Wolfram.php | Wolfram._calculateConsecutiveTokenScore | protected function _calculateConsecutiveTokenScore($class)
{
$score = 0;
$pattern = '/[^a-zA-Z0-9]{2,}/';
if ($class == self::CLASS_LETTER) {
$pattern = '/[a-zA-Z]{2,}/';
}
if ($class == self::CLASS_UPPER) {
$pattern = '/[A-Z]{2,}/';
}
if ($class == self::CLASS_LOWER) {
$pattern = '/[a-z]{2,}/';
}
if ($class == self::CLASS_NUMBER) {
$pattern = '/[0-9]{2,}/';
}
$matches = array ();
preg_match_all($pattern, $this->_password, $matches);
foreach ($matches[0] as $match) {
$score -= (strlen($match) - 1) * 2;
}
return $score;
} | php | protected function _calculateConsecutiveTokenScore($class)
{
$score = 0;
$pattern = '/[^a-zA-Z0-9]{2,}/';
if ($class == self::CLASS_LETTER) {
$pattern = '/[a-zA-Z]{2,}/';
}
if ($class == self::CLASS_UPPER) {
$pattern = '/[A-Z]{2,}/';
}
if ($class == self::CLASS_LOWER) {
$pattern = '/[a-z]{2,}/';
}
if ($class == self::CLASS_NUMBER) {
$pattern = '/[0-9]{2,}/';
}
$matches = array ();
preg_match_all($pattern, $this->_password, $matches);
foreach ($matches[0] as $match) {
$score -= (strlen($match) - 1) * 2;
}
return $score;
} | [
"protected",
"function",
"_calculateConsecutiveTokenScore",
"(",
"$",
"class",
")",
"{",
"$",
"score",
"=",
"0",
";",
"$",
"pattern",
"=",
"'/[^a-zA-Z0-9]{2,}/'",
";",
"if",
"(",
"$",
"class",
"==",
"self",
"::",
"CLASS_LETTER",
")",
"{",
"$",
"pattern",
"... | Return the score for consectutive tokens of the same class.
@param string $class
The token class on which to base the calculation.
@return integer | [
"Return",
"the",
"score",
"for",
"consectutive",
"tokens",
"of",
"the",
"same",
"class",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Strength/Adapter/Wolfram.php#L188-L216 |
44,165 | rchouinard/phpass | src/Phpass/Strength/Adapter/Wolfram.php | Wolfram._calculateSequentialTokenScore | protected function _calculateSequentialTokenScore($class)
{
$score = 0;
$indices = array ();
$password = $this->_password;
$sequences = array ();
$indices = $this->_getClassIndices($class);
if ($class == self::CLASS_LETTER) {
$password = strtolower($password);
}
$sequence = '';
for ($index = 0; $index < count($indices); ++$index) {
if (isset ($indices[$index + 1]) && $indices[$index + 1] - $indices[$index] == 1 && ord($password[$indices[$index + 1]]) - ord($password[$indices[$index]]) == 1) {
if ($sequence == '') {
$sequence = $password[$indices[$index]] . $password[$indices[$index + 1]];
} else {
$sequence .= $password[$indices[$index + 1]];
}
} else {
if ($sequence != '') {
$sequences[] = $sequence;
$sequence = '';
}
}
}
foreach ($sequences as $sequence) {
if (strlen($sequence) > 2) {
$score -= (strlen($sequence) - 2) *2;
}
}
return $score;
} | php | protected function _calculateSequentialTokenScore($class)
{
$score = 0;
$indices = array ();
$password = $this->_password;
$sequences = array ();
$indices = $this->_getClassIndices($class);
if ($class == self::CLASS_LETTER) {
$password = strtolower($password);
}
$sequence = '';
for ($index = 0; $index < count($indices); ++$index) {
if (isset ($indices[$index + 1]) && $indices[$index + 1] - $indices[$index] == 1 && ord($password[$indices[$index + 1]]) - ord($password[$indices[$index]]) == 1) {
if ($sequence == '') {
$sequence = $password[$indices[$index]] . $password[$indices[$index + 1]];
} else {
$sequence .= $password[$indices[$index + 1]];
}
} else {
if ($sequence != '') {
$sequences[] = $sequence;
$sequence = '';
}
}
}
foreach ($sequences as $sequence) {
if (strlen($sequence) > 2) {
$score -= (strlen($sequence) - 2) *2;
}
}
return $score;
} | [
"protected",
"function",
"_calculateSequentialTokenScore",
"(",
"$",
"class",
")",
"{",
"$",
"score",
"=",
"0",
";",
"$",
"indices",
"=",
"array",
"(",
")",
";",
"$",
"password",
"=",
"$",
"this",
"->",
"_password",
";",
"$",
"sequences",
"=",
"array",
... | Return the score for sequential tokens of the same class.
@param string $class
The token class on which to base the calculation.
@return integer | [
"Return",
"the",
"score",
"for",
"sequential",
"tokens",
"of",
"the",
"same",
"class",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Strength/Adapter/Wolfram.php#L225-L260 |
44,166 | rchouinard/phpass | src/Phpass/Loader.php | Loader.load | public static function load($class)
{
if (stripos($class, 'Phpass') === 0) {
$file = str_replace('\\', '/', $class);
if (file_exists(dirname(__FILE__) . '/../' . $file . '.php')) {
require_once(dirname(__FILE__) . '/../' . $file . '.php');
}
}
} | php | public static function load($class)
{
if (stripos($class, 'Phpass') === 0) {
$file = str_replace('\\', '/', $class);
if (file_exists(dirname(__FILE__) . '/../' . $file . '.php')) {
require_once(dirname(__FILE__) . '/../' . $file . '.php');
}
}
} | [
"public",
"static",
"function",
"load",
"(",
"$",
"class",
")",
"{",
"if",
"(",
"stripos",
"(",
"$",
"class",
",",
"'Phpass'",
")",
"===",
"0",
")",
"{",
"$",
"file",
"=",
"str_replace",
"(",
"'\\\\'",
",",
"'/'",
",",
"$",
"class",
")",
";",
"if... | Load a library class.
Performs checks to make sure only local library classes are loaded, and
the class file exists within the library path.
@param string $class
The fully qualified class name to load.
@return void | [
"Load",
"a",
"library",
"class",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Loader.php#L47-L56 |
44,167 | rchouinard/phpass | src/Phpass/Hash/Adapter/Base.php | Base._getRandomBytes | protected function _getRandomBytes($count)
{
if (!is_int($count) || $count < 1) {
throw new InvalidArgumentException('Argument must be a positive integer');
}
// Try OpenSSL's random generator
if (function_exists('openssl_random_pseudo_bytes')) {
$strongCrypto = false;
$output = openssl_random_pseudo_bytes($count, $strongCrypto);
if ($strongCrypto && strlen($output) == $count) {
return $output;
}
}
// Try reading from /dev/urandom, if present
$output = '';
if (is_readable('/dev/urandom') && ($fh = fopen('/dev/urandom', 'rb'))) {
$output = fread($fh, $count);
fclose($fh);
}
// Fall back to a locally generated "random" string
if (strlen($output) < $count) {
$output = '';
for ($i = 0; $i < $count; $i += 16) {
$this->_randomState = md5(microtime() . $this->_randomState);
$output .= md5($this->_randomState, true);
}
$output = substr($output, 0, $count);
}
return $output;
} | php | protected function _getRandomBytes($count)
{
if (!is_int($count) || $count < 1) {
throw new InvalidArgumentException('Argument must be a positive integer');
}
// Try OpenSSL's random generator
if (function_exists('openssl_random_pseudo_bytes')) {
$strongCrypto = false;
$output = openssl_random_pseudo_bytes($count, $strongCrypto);
if ($strongCrypto && strlen($output) == $count) {
return $output;
}
}
// Try reading from /dev/urandom, if present
$output = '';
if (is_readable('/dev/urandom') && ($fh = fopen('/dev/urandom', 'rb'))) {
$output = fread($fh, $count);
fclose($fh);
}
// Fall back to a locally generated "random" string
if (strlen($output) < $count) {
$output = '';
for ($i = 0; $i < $count; $i += 16) {
$this->_randomState = md5(microtime() . $this->_randomState);
$output .= md5($this->_randomState, true);
}
$output = substr($output, 0, $count);
}
return $output;
} | [
"protected",
"function",
"_getRandomBytes",
"(",
"$",
"count",
")",
"{",
"if",
"(",
"!",
"is_int",
"(",
"$",
"count",
")",
"||",
"$",
"count",
"<",
"1",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Argument must be a positive integer'",
")",
... | Generate a pseudo-random string of bytes.
@param integer $count
The length of the desired string of bytes. Must be a positive integer.
@return string
Returns the generated string of bytes.
@throws InvalidArgumentException
Thows an InvalidArgumentException if the $count parameter is not a
positive integer. | [
"Generate",
"a",
"pseudo",
"-",
"random",
"string",
"of",
"bytes",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Hash/Adapter/Base.php#L204-L237 |
44,168 | rchouinard/phpass | src/Phpass/Strength/Adapter/Base.php | Base._analyze | protected function _analyze($password)
{
// Reset the class
$this->_password = $password;
$this->_score = 0;
$this->_length = strlen($password);
$this->_tokens = array ();
$this->_tokenCounts = array (
self::CLASS_LETTER => 0,
self::CLASS_UPPER => 0,
self::CLASS_LOWER => 0,
self::CLASS_NUMBER => 0,
self::CLASS_SYMBOL => 0
);
$this->_tokenIndices = array (
self::CLASS_LETTER => array (),
self::CLASS_UPPER => array (),
self::CLASS_LOWER => array (),
self::CLASS_NUMBER => array (),
self::CLASS_SYMBOL => array ()
);
$this->_parseTokens();
} | php | protected function _analyze($password)
{
// Reset the class
$this->_password = $password;
$this->_score = 0;
$this->_length = strlen($password);
$this->_tokens = array ();
$this->_tokenCounts = array (
self::CLASS_LETTER => 0,
self::CLASS_UPPER => 0,
self::CLASS_LOWER => 0,
self::CLASS_NUMBER => 0,
self::CLASS_SYMBOL => 0
);
$this->_tokenIndices = array (
self::CLASS_LETTER => array (),
self::CLASS_UPPER => array (),
self::CLASS_LOWER => array (),
self::CLASS_NUMBER => array (),
self::CLASS_SYMBOL => array ()
);
$this->_parseTokens();
} | [
"protected",
"function",
"_analyze",
"(",
"$",
"password",
")",
"{",
"// Reset the class",
"$",
"this",
"->",
"_password",
"=",
"$",
"password",
";",
"$",
"this",
"->",
"_score",
"=",
"0",
";",
"$",
"this",
"->",
"_length",
"=",
"strlen",
"(",
"$",
"pa... | Analyze a string and store relevant metadata.
@param string $password
The string to analyze.
@return void | [
"Analyze",
"a",
"string",
"and",
"store",
"relevant",
"metadata",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Strength/Adapter/Base.php#L82-L105 |
44,169 | rchouinard/phpass | src/Phpass/Strength/Adapter/Base.php | Base._parseTokens | protected function _parseTokens()
{
for ($index = 0; $index < $this->_length; ++$index) {
$token = $this->_password[$index];
$tokenAsciiValue = ord($token);
if ($tokenAsciiValue >= 48 && $tokenAsciiValue <= 57) {
$tokenClass = self::CLASS_NUMBER;
} elseif ($tokenAsciiValue >= 65 && $tokenAsciiValue <= 90) {
$tokenClass = self::CLASS_UPPER;
} elseif ($tokenAsciiValue >= 97 && $tokenAsciiValue <= 122) {
$tokenClass = self::CLASS_LOWER;
} else {
$tokenClass = self::CLASS_SYMBOL;
}
// Track the number and index of tokens belonging to class
++$this->_tokenCounts[$tokenClass];
$this->_tokenIndices[$tokenClass][] = $index;
// Members of UPPER and LOWER also belong to LETTER
if ($tokenClass == self::CLASS_UPPER || $tokenClass == self::CLASS_LOWER) {
++$this->_tokenCounts[self::CLASS_LETTER];
$this->_tokenIndices[self::CLASS_LETTER][] = $index;
}
// Track the number of times this token appears
if (array_key_exists($token, $this->_tokens)) {
$this->_tokens[$token] += 1;
} else {
$this->_tokens[$token] = 1;
}
}
} | php | protected function _parseTokens()
{
for ($index = 0; $index < $this->_length; ++$index) {
$token = $this->_password[$index];
$tokenAsciiValue = ord($token);
if ($tokenAsciiValue >= 48 && $tokenAsciiValue <= 57) {
$tokenClass = self::CLASS_NUMBER;
} elseif ($tokenAsciiValue >= 65 && $tokenAsciiValue <= 90) {
$tokenClass = self::CLASS_UPPER;
} elseif ($tokenAsciiValue >= 97 && $tokenAsciiValue <= 122) {
$tokenClass = self::CLASS_LOWER;
} else {
$tokenClass = self::CLASS_SYMBOL;
}
// Track the number and index of tokens belonging to class
++$this->_tokenCounts[$tokenClass];
$this->_tokenIndices[$tokenClass][] = $index;
// Members of UPPER and LOWER also belong to LETTER
if ($tokenClass == self::CLASS_UPPER || $tokenClass == self::CLASS_LOWER) {
++$this->_tokenCounts[self::CLASS_LETTER];
$this->_tokenIndices[self::CLASS_LETTER][] = $index;
}
// Track the number of times this token appears
if (array_key_exists($token, $this->_tokens)) {
$this->_tokens[$token] += 1;
} else {
$this->_tokens[$token] = 1;
}
}
} | [
"protected",
"function",
"_parseTokens",
"(",
")",
"{",
"for",
"(",
"$",
"index",
"=",
"0",
";",
"$",
"index",
"<",
"$",
"this",
"->",
"_length",
";",
"++",
"$",
"index",
")",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"_password",
"[",
"$",
"ind... | Tokenize the password string.
@return void | [
"Tokenize",
"the",
"password",
"string",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Strength/Adapter/Base.php#L112-L145 |
44,170 | rchouinard/phpass | src/Phpass/Strength/Adapter/Base.php | Base._getClassIndices | protected function _getClassIndices($class)
{
$indices = array ();
if ($class == self::CLASS_LETTER) {
$indices = array_merge(
$this->_getClassIndices(self::CLASS_LOWER),
$this->_getClassIndices(self::CLASS_UPPER)
);
sort($indices);
} else {
if (isset ($this->_tokenIndices[$class])) {
$indices = $this->_tokenIndices[$class];
}
}
return $indices;
} | php | protected function _getClassIndices($class)
{
$indices = array ();
if ($class == self::CLASS_LETTER) {
$indices = array_merge(
$this->_getClassIndices(self::CLASS_LOWER),
$this->_getClassIndices(self::CLASS_UPPER)
);
sort($indices);
} else {
if (isset ($this->_tokenIndices[$class])) {
$indices = $this->_tokenIndices[$class];
}
}
return $indices;
} | [
"protected",
"function",
"_getClassIndices",
"(",
"$",
"class",
")",
"{",
"$",
"indices",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"class",
"==",
"self",
"::",
"CLASS_LETTER",
")",
"{",
"$",
"indices",
"=",
"array_merge",
"(",
"$",
"this",
"->",
... | Return a map of token indices within the string for a given class.
@param string $class
Token class to map.
@return array
Returns a numerically indexed array of indicies where members of a
given class may be found in the string. | [
"Return",
"a",
"map",
"of",
"token",
"indices",
"within",
"the",
"string",
"for",
"a",
"given",
"class",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Strength/Adapter/Base.php#L156-L172 |
44,171 | rchouinard/phpass | src/Phpass/Strength/Adapter/Base.php | Base._getClassCount | protected function _getClassCount($class)
{
$count = 0;
if ($class == self::CLASS_LETTER) {
$count = $this->_getClassCount(self::CLASS_LOWER)
+ $this->_getClassCount(self::CLASS_UPPER);
} else {
if (isset ($this->_tokenCounts[$class])) {
$count = $this->_tokenCounts[$class];
}
}
return $count;
} | php | protected function _getClassCount($class)
{
$count = 0;
if ($class == self::CLASS_LETTER) {
$count = $this->_getClassCount(self::CLASS_LOWER)
+ $this->_getClassCount(self::CLASS_UPPER);
} else {
if (isset ($this->_tokenCounts[$class])) {
$count = $this->_tokenCounts[$class];
}
}
return $count;
} | [
"protected",
"function",
"_getClassCount",
"(",
"$",
"class",
")",
"{",
"$",
"count",
"=",
"0",
";",
"if",
"(",
"$",
"class",
"==",
"self",
"::",
"CLASS_LETTER",
")",
"{",
"$",
"count",
"=",
"$",
"this",
"->",
"_getClassCount",
"(",
"self",
"::",
"CL... | Return the number of times members of a token class appear in the string.
@param string $class
Token class to count.
@return integer
Returns the number of times members of the token class appear in the
string. | [
"Return",
"the",
"number",
"of",
"times",
"members",
"of",
"a",
"token",
"class",
"appear",
"in",
"the",
"string",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Strength/Adapter/Base.php#L183-L196 |
44,172 | rchouinard/phpass | src/Phpass/Hash.php | Hash.checkPassword | public function checkPassword($password, $storedHash)
{
$hash = $this->_crypt($password, $storedHash);
return ($hash == $storedHash);
} | php | public function checkPassword($password, $storedHash)
{
$hash = $this->_crypt($password, $storedHash);
return ($hash == $storedHash);
} | [
"public",
"function",
"checkPassword",
"(",
"$",
"password",
",",
"$",
"storedHash",
")",
"{",
"$",
"hash",
"=",
"$",
"this",
"->",
"_crypt",
"(",
"$",
"password",
",",
"$",
"storedHash",
")",
";",
"return",
"(",
"$",
"hash",
"==",
"$",
"storedHash",
... | Check if a string matches a given hash value.
@param string $password
The string to check.
@param string $storedHash
The hash string to check against.
@return boolean
Returns true if the string matches the hash string, and false
otherwise. | [
"Check",
"if",
"a",
"string",
"matches",
"a",
"given",
"hash",
"value",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Hash.php#L213-L218 |
44,173 | rchouinard/phpass | src/Phpass/Hash.php | Hash._crypt | protected function _crypt($password, $salt = null)
{
if (isset($this->_hmacKey)) {
$password = hash_hmac($this->_hmacAlgo, $password, $this->_hmacKey);
}
$adapter = $this->getAdapter();
$hash = $adapter->crypt($password, $salt);
return $hash;
} | php | protected function _crypt($password, $salt = null)
{
if (isset($this->_hmacKey)) {
$password = hash_hmac($this->_hmacAlgo, $password, $this->_hmacKey);
}
$adapter = $this->getAdapter();
$hash = $adapter->crypt($password, $salt);
return $hash;
} | [
"protected",
"function",
"_crypt",
"(",
"$",
"password",
",",
"$",
"salt",
"=",
"null",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_hmacKey",
")",
")",
"{",
"$",
"password",
"=",
"hash_hmac",
"(",
"$",
"this",
"->",
"_hmacAlgo",
",",
"$... | Return a hashed string, optionally using a pre-calculated salt.
If Hash::$_hmacKey is set, this method will generate the HMAC hash of
the password string before passing the value to the adapter.
@param string $password
The string to be hashed.
@param string $salt
An optional salt string to base the hashing on. If not provided, the
adapter will generate a new secure salt value.
@return string
Returns the hashed string. | [
"Return",
"a",
"hashed",
"string",
"optionally",
"using",
"a",
"pre",
"-",
"calculated",
"salt",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Hash.php#L247-L256 |
44,174 | rchouinard/phpass | src/Phpass/Hash/Adapter/ExtDes.php | ExtDes._encodeInt24 | protected function _encodeInt24($integer)
{
$integer = (int) $integer;
if ($integer < 0 || $integer > 0xffffff) {
throw new InvalidArgumentException('Integer is out of range');
}
$string = $this->_itoa64[$integer & 0x3f];
$string .= $this->_itoa64[($integer >> 0x06) & 0x3f];
$string .= $this->_itoa64[($integer >> 0x0c) & 0x3f];
$string .= $this->_itoa64[($integer >> 0x12) & 0x3f];
return $string;
} | php | protected function _encodeInt24($integer)
{
$integer = (int) $integer;
if ($integer < 0 || $integer > 0xffffff) {
throw new InvalidArgumentException('Integer is out of range');
}
$string = $this->_itoa64[$integer & 0x3f];
$string .= $this->_itoa64[($integer >> 0x06) & 0x3f];
$string .= $this->_itoa64[($integer >> 0x0c) & 0x3f];
$string .= $this->_itoa64[($integer >> 0x12) & 0x3f];
return $string;
} | [
"protected",
"function",
"_encodeInt24",
"(",
"$",
"integer",
")",
"{",
"$",
"integer",
"=",
"(",
"int",
")",
"$",
"integer",
";",
"if",
"(",
"$",
"integer",
"<",
"0",
"||",
"$",
"integer",
">",
"0xffffff",
")",
"{",
"throw",
"new",
"InvalidArgumentExc... | Encode a 24-bit integer as a 4-byte string.
@param integer $integer
The integer to encode. Must be between 0 and 16777215.
@return string
Returns the encoded string.
@throws InvalidArgumentException
Throws an InvalidArgumentException if the integer is outside of the
range 0 - 16777215. | [
"Encode",
"a",
"24",
"-",
"bit",
"integer",
"as",
"a",
"4",
"-",
"byte",
"string",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Hash/Adapter/ExtDes.php#L161-L174 |
44,175 | rchouinard/phpass | src/Phpass/Hash/Adapter/ExtDes.php | ExtDes._decodeInt24 | protected function _decodeInt24($source)
{
if (strlen($source) != 4) {
throw new InvalidArgumentException('Source must be exactly 4 bytes');
}
$integer = strpos($this->_itoa64, $source{0});
$integer += (strpos($this->_itoa64, $source{1}) << 0x06);
$integer += (strpos($this->_itoa64, $source{2}) << 0x0c);
$integer += (strpos($this->_itoa64, $source{3}) << 0x12);
return $integer;
} | php | protected function _decodeInt24($source)
{
if (strlen($source) != 4) {
throw new InvalidArgumentException('Source must be exactly 4 bytes');
}
$integer = strpos($this->_itoa64, $source{0});
$integer += (strpos($this->_itoa64, $source{1}) << 0x06);
$integer += (strpos($this->_itoa64, $source{2}) << 0x0c);
$integer += (strpos($this->_itoa64, $source{3}) << 0x12);
return $integer;
} | [
"protected",
"function",
"_decodeInt24",
"(",
"$",
"source",
")",
"{",
"if",
"(",
"strlen",
"(",
"$",
"source",
")",
"!=",
"4",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Source must be exactly 4 bytes'",
")",
";",
"}",
"$",
"integer",
"=",... | Decode a 24-bit integer encoded as a 4-byte string.
@param string $source
The source string to decode.
@return integer
Returns the decoded integer.
@throws InvalidArgumentException
Throws an InvalidArgumentException if the source string is not exactly
4 bytes. | [
"Decode",
"a",
"24",
"-",
"bit",
"integer",
"encoded",
"as",
"a",
"4",
"-",
"byte",
"string",
"."
] | 9519feb5aaece801cfb32f15dc2ddeb30ccacc65 | https://github.com/rchouinard/phpass/blob/9519feb5aaece801cfb32f15dc2ddeb30ccacc65/src/Phpass/Hash/Adapter/ExtDes.php#L187-L199 |
44,176 | jcrowe206/BadWordFilter | src/JCrowe/BadWordFilter/BadWordFilter.php | BadWordFilter.getBadWords | private function getBadWords()
{
if (!$this->badWords) {
switch ($this->config['source']) {
case 'file':
$this->badWords = $this->getBadWordsFromConfigFile();
break;
case 'array':
$this->badWords = $this->getBadWordsFromArray();
break;
case 'database':
$this->badWords = $this->getBadWordsFromDB();
break;
default:
throw new \Exception('Config source was not a valid type. Valid types are: file, database, cache');
break;
}
if (!$this->isUsingCustomDefinedWordList()) {
switch ($this->config['strictness']) {
case 'permissive':
$this->badWords = $this->getBadWordsByKey(['permissive']);
break;
case 'lenient':
$this->badWords = $this->getBadWordsByKey(['permissive', 'lenient']);
break;
case 'strict':
$this->badWords = $this->getBadWordsByKey(['permissive', 'lenient', 'strict']);
break;
case 'very_strict':
$this->badWords = $this->getBadWordsByKey(['permissive', 'lenient', 'strict', 'very_strict']);
break;
case 'strictest':
$this->badWords = $this->getBadWordsByKey([
'permissive',
'lenient',
'strict',
'very_strict',
'strictest'
]);
break;
case 'misspellings':
case 'all':
$this->badWords = $this->getBadWordsByKey([
'permissive',
'lenient',
'strict',
'very_strict',
'strictest',
'misspellings'
]);
break;
default:
$this->badWords = $this->getBadWordsByKey(['permissive', 'lenient', 'strict', 'very_strict']);
break;
}
}
if (!empty($this->config['also_check'])) {
if (!is_array($this->config['also_check'])) {
$this->config['also_check'] = [$this->config['also_check']];
}
$this->badWords = array_merge($this->badWords, $this->config['also_check']);
}
}
return $this->badWords;
} | php | private function getBadWords()
{
if (!$this->badWords) {
switch ($this->config['source']) {
case 'file':
$this->badWords = $this->getBadWordsFromConfigFile();
break;
case 'array':
$this->badWords = $this->getBadWordsFromArray();
break;
case 'database':
$this->badWords = $this->getBadWordsFromDB();
break;
default:
throw new \Exception('Config source was not a valid type. Valid types are: file, database, cache');
break;
}
if (!$this->isUsingCustomDefinedWordList()) {
switch ($this->config['strictness']) {
case 'permissive':
$this->badWords = $this->getBadWordsByKey(['permissive']);
break;
case 'lenient':
$this->badWords = $this->getBadWordsByKey(['permissive', 'lenient']);
break;
case 'strict':
$this->badWords = $this->getBadWordsByKey(['permissive', 'lenient', 'strict']);
break;
case 'very_strict':
$this->badWords = $this->getBadWordsByKey(['permissive', 'lenient', 'strict', 'very_strict']);
break;
case 'strictest':
$this->badWords = $this->getBadWordsByKey([
'permissive',
'lenient',
'strict',
'very_strict',
'strictest'
]);
break;
case 'misspellings':
case 'all':
$this->badWords = $this->getBadWordsByKey([
'permissive',
'lenient',
'strict',
'very_strict',
'strictest',
'misspellings'
]);
break;
default:
$this->badWords = $this->getBadWordsByKey(['permissive', 'lenient', 'strict', 'very_strict']);
break;
}
}
if (!empty($this->config['also_check'])) {
if (!is_array($this->config['also_check'])) {
$this->config['also_check'] = [$this->config['also_check']];
}
$this->badWords = array_merge($this->badWords, $this->config['also_check']);
}
}
return $this->badWords;
} | [
"private",
"function",
"getBadWords",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"badWords",
")",
"{",
"switch",
"(",
"$",
"this",
"->",
"config",
"[",
"'source'",
"]",
")",
"{",
"case",
"'file'",
":",
"$",
"this",
"->",
"badWords",
"=",
"$"... | Set the bad words array to the model if not already set and return it
@return array|void
@throws \Exception | [
"Set",
"the",
"bad",
"words",
"array",
"to",
"the",
"model",
"if",
"not",
"already",
"set",
"and",
"return",
"it"
] | cd6ce8243b46ead2e71480ad7a17b425c41eaa39 | https://github.com/jcrowe206/BadWordFilter/blob/cd6ce8243b46ead2e71480ad7a17b425c41eaa39/src/JCrowe/BadWordFilter/BadWordFilter.php#L359-L443 |
44,177 | jcrowe206/BadWordFilter | src/JCrowe/BadWordFilter/BadWordFilter.php | BadWordFilter.getBadWordsFromArray | private function getBadWordsFromArray()
{
if (!empty($this->config['bad_words_array']) && is_array($this->config['bad_words_array'])) {
return $this->config['bad_words_array'];
}
throw new \Exception('Source is set to "array" but bad_words_array is either empty or not an array.');
} | php | private function getBadWordsFromArray()
{
if (!empty($this->config['bad_words_array']) && is_array($this->config['bad_words_array'])) {
return $this->config['bad_words_array'];
}
throw new \Exception('Source is set to "array" but bad_words_array is either empty or not an array.');
} | [
"private",
"function",
"getBadWordsFromArray",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"config",
"[",
"'bad_words_array'",
"]",
")",
"&&",
"is_array",
"(",
"$",
"this",
"->",
"config",
"[",
"'bad_words_array'",
"]",
")",
")",
"{",... | Get the bad words from the array in the config
@return array
@throws \Exception | [
"Get",
"the",
"bad",
"words",
"from",
"the",
"array",
"in",
"the",
"config"
] | cd6ce8243b46ead2e71480ad7a17b425c41eaa39 | https://github.com/jcrowe206/BadWordFilter/blob/cd6ce8243b46ead2e71480ad7a17b425c41eaa39/src/JCrowe/BadWordFilter/BadWordFilter.php#L488-L495 |
44,178 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/user/user.php | ComKoowaUser.getRoles | public function getRoles()
{
$data = $this->getData();
$roles = KObjectConfig::unbox($data->roles);
if(empty($roles)) {
$this->getSession()->set('user.roles', JAccess::getAuthorisedViewLevels($this->getId()));
}
return parent::getRoles();
} | php | public function getRoles()
{
$data = $this->getData();
$roles = KObjectConfig::unbox($data->roles);
if(empty($roles)) {
$this->getSession()->set('user.roles', JAccess::getAuthorisedViewLevels($this->getId()));
}
return parent::getRoles();
} | [
"public",
"function",
"getRoles",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"$",
"roles",
"=",
"KObjectConfig",
"::",
"unbox",
"(",
"$",
"data",
"->",
"roles",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"roles",
"... | Returns the roles of the user
@return int The role id | [
"Returns",
"the",
"roles",
"of",
"the",
"user"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/user/user.php#L67-L77 |
44,179 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/user/user.php | ComKoowaUser.getGroups | public function getGroups()
{
$data = $this->getData();
$groups = KObjectConfig::unbox($data->groups);
if(empty($groups)) {
$this->getSession()->set('user.groups', JAccess::getGroupsByUser($this->getId()));
}
return parent::getGroups();
} | php | public function getGroups()
{
$data = $this->getData();
$groups = KObjectConfig::unbox($data->groups);
if(empty($groups)) {
$this->getSession()->set('user.groups', JAccess::getGroupsByUser($this->getId()));
}
return parent::getGroups();
} | [
"public",
"function",
"getGroups",
"(",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"getData",
"(",
")",
";",
"$",
"groups",
"=",
"KObjectConfig",
"::",
"unbox",
"(",
"$",
"data",
"->",
"groups",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"groups",... | Returns the groups the user is part of
@return array An array of group id's | [
"Returns",
"the",
"groups",
"the",
"user",
"is",
"part",
"of"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/user/user.php#L84-L94 |
44,180 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/translator/locator/factory.php | KTranslatorLocatorFactory.registerLocator | public function registerLocator($identifier)
{
$result = false;
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KTranslatorLocatorInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Locator: '.$identifier.' does not implement KTranslatorLocatorInterface'
);
}
$name = $class::getName();
if (!empty($name) && !$this->isRegistered($name)) {
$this->__locators[$name] = $identifier;
}
return $result;
} | php | public function registerLocator($identifier)
{
$result = false;
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KTranslatorLocatorInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Locator: '.$identifier.' does not implement KTranslatorLocatorInterface'
);
}
$name = $class::getName();
if (!empty($name) && !$this->isRegistered($name)) {
$this->__locators[$name] = $identifier;
}
return $result;
} | [
"public",
"function",
"registerLocator",
"(",
"$",
"identifier",
")",
"{",
"$",
"result",
"=",
"false",
";",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"identifier",
")",
";",
"$",
"class",
"=",
"$",
"this",
"->",
"getObject",
... | Register a locator
Function prevents from registering the locator twice
@param string $identifier A locator identifier string
@throws UnexpectedValueException
@return bool Returns TRUE on success, FALSE on failure. | [
"Register",
"a",
"locator"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/translator/locator/factory.php#L117-L138 |
44,181 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/translator/locator/factory.php | KTranslatorLocatorFactory.getLocator | public function getLocator($name)
{
$locator = false;
if($this->isRegistered($name)) {
$locator = $this->__locators[$name];
}
return $locator;
} | php | public function getLocator($name)
{
$locator = false;
if($this->isRegistered($name)) {
$locator = $this->__locators[$name];
}
return $locator;
} | [
"public",
"function",
"getLocator",
"(",
"$",
"name",
")",
"{",
"$",
"locator",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"isRegistered",
"(",
"$",
"name",
")",
")",
"{",
"$",
"locator",
"=",
"$",
"this",
"->",
"__locators",
"[",
"$",
"name"... | Get a registered locator identifier
@param string $name The locator name
@return string|false The locator identifier | [
"Get",
"a",
"registered",
"locator",
"identifier"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/translator/locator/factory.php#L181-L190 |
44,182 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/translator/locator/factory.php | KTranslatorLocatorFactory.getLocators | public function getLocators()
{
$result = array();
if(is_array($this->__locators)) {
$result = array_keys($this->__locators);
}
return $result;
} | php | public function getLocators()
{
$result = array();
if(is_array($this->__locators)) {
$result = array_keys($this->__locators);
}
return $result;
} | [
"public",
"function",
"getLocators",
"(",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"__locators",
")",
")",
"{",
"$",
"result",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"__locators",
")",
... | Get a list of all the registered locators
@return array | [
"Get",
"a",
"list",
"of",
"all",
"the",
"registered",
"locators"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/translator/locator/factory.php#L197-L205 |
44,183 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/translator/locator/factory.php | KTranslatorLocatorFactory.isRegistered | public function isRegistered($identifier)
{
if(strpos($identifier, '.') !== false )
{
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KTranslatorLocatorInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Locator: '.$identifier.' does not implement KTranslatorLocatorInterface'
);
}
$name = $class::getName();
}
else $name = $identifier;
$result = in_array($name, $this->getLocators());
return $result;
} | php | public function isRegistered($identifier)
{
if(strpos($identifier, '.') !== false )
{
$identifier = $this->getIdentifier($identifier);
$class = $this->getObject('manager')->getClass($identifier);
if(!$class || !array_key_exists('KTranslatorLocatorInterface', class_implements($class)))
{
throw new UnexpectedValueException(
'Locator: '.$identifier.' does not implement KTranslatorLocatorInterface'
);
}
$name = $class::getName();
}
else $name = $identifier;
$result = in_array($name, $this->getLocators());
return $result;
} | [
"public",
"function",
"isRegistered",
"(",
"$",
"identifier",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"identifier",
",",
"'.'",
")",
"!==",
"false",
")",
"{",
"$",
"identifier",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
"$",
"identifier",
")",
";"... | Check if the locator is registered
@param string $identifier A locator object identifier string or locator name
@return bool TRUE if the locator is a registered, FALSE otherwise. | [
"Check",
"if",
"the",
"locator",
"is",
"registered"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/translator/locator/factory.php#L213-L233 |
44,184 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/template/helper/bootstrap.php | ComKoowaTemplateHelperBootstrap.javascript | public function javascript($config = array())
{
return $this->getTemplate()->helper('behavior.bootstrap', array(
'debug' => JFactory::getApplication()->getCfg('debug'),
'css' => false,
'javascript' => true
));
} | php | public function javascript($config = array())
{
return $this->getTemplate()->helper('behavior.bootstrap', array(
'debug' => JFactory::getApplication()->getCfg('debug'),
'css' => false,
'javascript' => true
));
} | [
"public",
"function",
"javascript",
"(",
"$",
"config",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"getTemplate",
"(",
")",
"->",
"helper",
"(",
"'behavior.bootstrap'",
",",
"array",
"(",
"'debug'",
"=>",
"JFactory",
"::",
"getApplicati... | Load Bootstrap JavaScript files, from Joomla if possible
@param array|KObjectConfig $config
@return string | [
"Load",
"Bootstrap",
"JavaScript",
"files",
"from",
"Joomla",
"if",
"possible"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/template/helper/bootstrap.php#L24-L31 |
44,185 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/view/rss.php | KViewRss.getRoute | public function getRoute($route = '', $fqr = true, $escape = true)
{
return parent::getRoute($route, $fqr, $escape);
} | php | public function getRoute($route = '', $fqr = true, $escape = true)
{
return parent::getRoute($route, $fqr, $escape);
} | [
"public",
"function",
"getRoute",
"(",
"$",
"route",
"=",
"''",
",",
"$",
"fqr",
"=",
"true",
",",
"$",
"escape",
"=",
"true",
")",
"{",
"return",
"parent",
"::",
"getRoute",
"(",
"$",
"route",
",",
"$",
"fqr",
",",
"$",
"escape",
")",
";",
"}"
] | Force the route to fully qualified and escaped by default
@param string $route The query string used to create the route
@param boolean $fqr If TRUE create a fully qualified route. Default TRUE.
@param boolean $escape If TRUE escapes the route for xml compliance. Default TRUE.
@return KDispatcherRouterRoute The route | [
"Force",
"the",
"route",
"to",
"fully",
"qualified",
"and",
"escaped",
"by",
"default"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/view/rss.php#L56-L59 |
44,186 | joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/controller/toolbar/menubar.php | ComKoowaControllerToolbarMenubar.getCommands | public function getCommands()
{
$name = $this->getController()->getIdentifier()->name;
$package = $this->getIdentifier()->package;
$manifest = JPATH_ADMINISTRATOR.'/components/com_'.$package.'/'.$package.'.xml';
if(file_exists($manifest))
{
$xml = simplexml_load_file($manifest);
if(isset($xml->administration->submenu))
{
foreach($xml->administration->submenu->children() as $menu)
{
$view = (string)$menu['view'];
$this->addCommand((string)$menu, array(
'href' => 'option=com_'.$package.'&view='.$view,
'active' => ($name == KStringInflector::singularize($view))
));
}
}
}
return parent::getCommands();
} | php | public function getCommands()
{
$name = $this->getController()->getIdentifier()->name;
$package = $this->getIdentifier()->package;
$manifest = JPATH_ADMINISTRATOR.'/components/com_'.$package.'/'.$package.'.xml';
if(file_exists($manifest))
{
$xml = simplexml_load_file($manifest);
if(isset($xml->administration->submenu))
{
foreach($xml->administration->submenu->children() as $menu)
{
$view = (string)$menu['view'];
$this->addCommand((string)$menu, array(
'href' => 'option=com_'.$package.'&view='.$view,
'active' => ($name == KStringInflector::singularize($view))
));
}
}
}
return parent::getCommands();
} | [
"public",
"function",
"getCommands",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"getController",
"(",
")",
"->",
"getIdentifier",
"(",
")",
"->",
"name",
";",
"$",
"package",
"=",
"$",
"this",
"->",
"getIdentifier",
"(",
")",
"->",
"package",
... | Get the list of commands
Will attempt to use information from the xml manifest if possible
@return array | [
"Get",
"the",
"list",
"of",
"commands"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/controller/toolbar/menubar.php#L64-L89 |
44,187 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/registry/cache.php | KObjectRegistryCache.offsetExists | public function offsetExists($offset)
{
if(false === $result = parent::offsetExists($offset)) {
$result = apc_exists($this->getNamespace().'-object_'.$offset);
}
return $result;
} | php | public function offsetExists($offset)
{
if(false === $result = parent::offsetExists($offset)) {
$result = apc_exists($this->getNamespace().'-object_'.$offset);
}
return $result;
} | [
"public",
"function",
"offsetExists",
"(",
"$",
"offset",
")",
"{",
"if",
"(",
"false",
"===",
"$",
"result",
"=",
"parent",
"::",
"offsetExists",
"(",
"$",
"offset",
")",
")",
"{",
"$",
"result",
"=",
"apc_exists",
"(",
"$",
"this",
"->",
"getNamespac... | Check if the offset exists
@param int $offset The offset
@return bool | [
"Check",
"if",
"the",
"offset",
"exists"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/registry/cache.php#L147-L154 |
44,188 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/view/template.php | KViewTemplate.setTemplate | public function setTemplate($template)
{
if (!($template instanceof KTemplateInterface))
{
if (is_string($template) && strpos($template, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('template');
$identifier['name'] = $template;
$identifier = $this->getIdentifier($identifier);
}
else $identifier = $this->getIdentifier($template);
$template = $identifier;
}
$this->_template = $template;
return $this;
} | php | public function setTemplate($template)
{
if (!($template instanceof KTemplateInterface))
{
if (is_string($template) && strpos($template, '.') === false)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('template');
$identifier['name'] = $template;
$identifier = $this->getIdentifier($identifier);
}
else $identifier = $this->getIdentifier($template);
$template = $identifier;
}
$this->_template = $template;
return $this;
} | [
"public",
"function",
"setTemplate",
"(",
"$",
"template",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"template",
"instanceof",
"KTemplateInterface",
")",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"template",
")",
"&&",
"strpos",
"(",
"$",
"template",
",",
... | Method to set a template object attached to the view
@param mixed $template An object that implements KObjectInterface, an object that implements
KObjectIdentifierInterface or valid identifier string
@throws UnexpectedValueException If the identifier is not a table identifier
@return KViewAbstract | [
"Method",
"to",
"set",
"a",
"template",
"object",
"attached",
"to",
"the",
"view"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/view/template.php#L202-L222 |
44,189 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/view/template.php | KViewTemplate.getRoute | public function getRoute($route = '', $fqr = true, $escape = true)
{
if(is_string($route)) {
parse_str(trim($route), $parts);
} else {
$parts = $route;
}
//Check to see if there is component information in the route if not add it
if (!isset($parts['component'])) {
$parts['component'] = $this->getIdentifier()->package;
}
//Add the view information to the route if it's not set
if (!isset($parts['view'])) {
$parts['view'] = $this->getName();
}
if (!isset($parts['layout']) && !empty($this->_layout))
{
if (($parts['component'] == $this->getIdentifier()->package) && ($parts['view'] == $this->getName())) {
$parts['layout'] = $this->getLayout();
}
}
return parent::getRoute($parts, $fqr, $escape);
} | php | public function getRoute($route = '', $fqr = true, $escape = true)
{
if(is_string($route)) {
parse_str(trim($route), $parts);
} else {
$parts = $route;
}
//Check to see if there is component information in the route if not add it
if (!isset($parts['component'])) {
$parts['component'] = $this->getIdentifier()->package;
}
//Add the view information to the route if it's not set
if (!isset($parts['view'])) {
$parts['view'] = $this->getName();
}
if (!isset($parts['layout']) && !empty($this->_layout))
{
if (($parts['component'] == $this->getIdentifier()->package) && ($parts['view'] == $this->getName())) {
$parts['layout'] = $this->getLayout();
}
}
return parent::getRoute($parts, $fqr, $escape);
} | [
"public",
"function",
"getRoute",
"(",
"$",
"route",
"=",
"''",
",",
"$",
"fqr",
"=",
"true",
",",
"$",
"escape",
"=",
"true",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"route",
")",
")",
"{",
"parse_str",
"(",
"trim",
"(",
"$",
"route",
")",
... | Creates a route based on a full or partial query string.
This function adds the layout information to the route if a layout has been set
@param string|array $route The query string used to create the route
@param boolean $fqr If TRUE create a fully qualified route. Default TRUE.
@param boolean $escape If TRUE escapes the route for xml compliance. Default TRUE.
@return KDispatcherRouterRoute The route | [
"Creates",
"a",
"route",
"based",
"on",
"a",
"full",
"or",
"partial",
"query",
"string",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/view/template.php#L256-L282 |
44,190 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/engine/abstract.php | KTemplateEngineAbstract.cache | public function cache($name, $source)
{
if($this->_cache)
{
$path = $this->_cache_path;
if(!is_dir($path) && (false === @mkdir($path, 0755, true) && !is_dir($path)))
{
if($this->isDebug()) {
throw new RuntimeException(sprintf('The template cache path "%s" does not exist', $path));
} else {
return false;
}
}
if(!is_writable($path))
{
if($this->isDebug()) {
throw new RuntimeException(sprintf('The template cache path "%s" is not writable', $path));
} else {
return false;
}
}
$hash = crc32($name.PHP_VERSION);
$file = $path.'/template_'.$hash.'.php';
if(@file_put_contents($file, $source) === false)
{
if($this->isDebug()) {
throw new RuntimeException(sprintf('The template cannot be cached in "%s"', $file));
} else {
return false;
}
}
//Override default permissions for cache files
@chmod($file, 0666 & ~umask());
return $file;
}
return false;
} | php | public function cache($name, $source)
{
if($this->_cache)
{
$path = $this->_cache_path;
if(!is_dir($path) && (false === @mkdir($path, 0755, true) && !is_dir($path)))
{
if($this->isDebug()) {
throw new RuntimeException(sprintf('The template cache path "%s" does not exist', $path));
} else {
return false;
}
}
if(!is_writable($path))
{
if($this->isDebug()) {
throw new RuntimeException(sprintf('The template cache path "%s" is not writable', $path));
} else {
return false;
}
}
$hash = crc32($name.PHP_VERSION);
$file = $path.'/template_'.$hash.'.php';
if(@file_put_contents($file, $source) === false)
{
if($this->isDebug()) {
throw new RuntimeException(sprintf('The template cannot be cached in "%s"', $file));
} else {
return false;
}
}
//Override default permissions for cache files
@chmod($file, 0666 & ~umask());
return $file;
}
return false;
} | [
"public",
"function",
"cache",
"(",
"$",
"name",
",",
"$",
"source",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_cache",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"_cache_path",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
"&&",
"("... | Cache the template source in a file
Write the template source to a file cache. Requires cache to be enabled. This method will throw exceptions if
caching fails and debug is enabled. If debug is disabled FALSE will be returned.
@param string $name The file name
@param string $source The template source
@throws \RuntimeException If the file path does not exist
@throws \RuntimeException If the file path is not writable
@throws \RuntimeException If template cannot be written to the cache
@return string|false The cached file path. FALSE if the file cannot be stored in the cache | [
"Cache",
"the",
"template",
"source",
"in",
"a",
"file"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/abstract.php#L116-L159 |
44,191 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/engine/abstract.php | KTemplateEngineAbstract.isCached | public function isCached($file)
{
$result = false;
if($this->_cache)
{
$hash = crc32($file.PHP_VERSION);
$cache = $this->_cache_path.'/template_'.$hash.'.php';
$result = is_file($cache) ? $cache : false;
if($result && $this->_cache_reload && is_file($file))
{
if(filemtime($cache) < filemtime($file)) {
$result = false;
}
}
}
return $result;
} | php | public function isCached($file)
{
$result = false;
if($this->_cache)
{
$hash = crc32($file.PHP_VERSION);
$cache = $this->_cache_path.'/template_'.$hash.'.php';
$result = is_file($cache) ? $cache : false;
if($result && $this->_cache_reload && is_file($file))
{
if(filemtime($cache) < filemtime($file)) {
$result = false;
}
}
}
return $result;
} | [
"public",
"function",
"isCached",
"(",
"$",
"file",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"_cache",
")",
"{",
"$",
"hash",
"=",
"crc32",
"(",
"$",
"file",
".",
"PHP_VERSION",
")",
";",
"$",
"cache",
"=",
"$",
... | Check if a file exists in the cache
@param string $file The file name
@return string|false The cache file path. FALSE if the file cannot be found in the cache | [
"Check",
"if",
"a",
"file",
"exists",
"in",
"the",
"cache"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/abstract.php#L224-L243 |
44,192 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/message/message.php | KHttpMessage.setContentType | public function setContentType($type)
{
if($type)
{
$this->_content_type = $type;
$this->_headers->set('Content-Type', array($type => array('charset' => 'utf-8')));
}
return $this;
} | php | public function setContentType($type)
{
if($type)
{
$this->_content_type = $type;
$this->_headers->set('Content-Type', array($type => array('charset' => 'utf-8')));
}
return $this;
} | [
"public",
"function",
"setContentType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"$",
"type",
")",
"{",
"$",
"this",
"->",
"_content_type",
"=",
"$",
"type",
";",
"$",
"this",
"->",
"_headers",
"->",
"set",
"(",
"'Content-Type'",
",",
"array",
"(",
"$"... | Sets the response content type
@see http://tools.ietf.org/html/rfc2616#section-14.17
@param string $type Content type
@return KHttpMessage | [
"Sets",
"the",
"response",
"content",
"type"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/message/message.php#L206-L215 |
44,193 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/message/message.php | KHttpMessage.getContentType | public function getContentType()
{
if (empty($this->_content_type) && $this->_headers->has('Content-Type'))
{
$type = $this->_headers->get('Content-Type');
//Strip parameters from content-type like "; charset=UTF-8"
if (is_string($type))
{
if (preg_match('/^([^,\;]*)/', $type, $matches)) {
$type = $matches[1];
}
}
$this->_content_type = $type;
}
return $this->_content_type;
} | php | public function getContentType()
{
if (empty($this->_content_type) && $this->_headers->has('Content-Type'))
{
$type = $this->_headers->get('Content-Type');
//Strip parameters from content-type like "; charset=UTF-8"
if (is_string($type))
{
if (preg_match('/^([^,\;]*)/', $type, $matches)) {
$type = $matches[1];
}
}
$this->_content_type = $type;
}
return $this->_content_type;
} | [
"public",
"function",
"getContentType",
"(",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"_content_type",
")",
"&&",
"$",
"this",
"->",
"_headers",
"->",
"has",
"(",
"'Content-Type'",
")",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"_he... | Retrieves the message content type
@link http://tools.ietf.org/html/rfc2616#section-14.17
@return string The content type | [
"Retrieves",
"the",
"message",
"content",
"type"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/message/message.php#L224-L242 |
44,194 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/message/message.php | KHttpMessage.getFormat | public function getFormat()
{
$result = null;
foreach (static::$_formats as $value => $media_types)
{
$media_type = $this->getContentType();
if (in_array($media_type, (array)$media_types))
{
$result = $value;
break;
}
}
return $result;
} | php | public function getFormat()
{
$result = null;
foreach (static::$_formats as $value => $media_types)
{
$media_type = $this->getContentType();
if (in_array($media_type, (array)$media_types))
{
$result = $value;
break;
}
}
return $result;
} | [
"public",
"function",
"getFormat",
"(",
")",
"{",
"$",
"result",
"=",
"null",
";",
"foreach",
"(",
"static",
"::",
"$",
"_formats",
"as",
"$",
"value",
"=>",
"$",
"media_types",
")",
"{",
"$",
"media_type",
"=",
"$",
"this",
"->",
"getContentType",
"("... | Return the message format
@return string The message format NULL if no format could be found | [
"Return",
"the",
"message",
"format"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/message/message.php#L249-L265 |
44,195 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/buffer.php | KFilesystemStreamBuffer.eof | public function eof()
{
if($this->getType() == 'memory') {
$result = $this->_position >= $this->_length;
} else {
$result = parent::eof();
}
return $result;
} | php | public function eof()
{
if($this->getType() == 'memory') {
$result = $this->_position >= $this->_length;
} else {
$result = parent::eof();
}
return $result;
} | [
"public",
"function",
"eof",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"==",
"'memory'",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_position",
">=",
"$",
"this",
"->",
"_length",
";",
"}",
"else",
"{",
"$",
"result... | Indicates whether the current position is the end-of-stream
@return boolean Should return TRUE if the read/write position is at the end of the stream and if no more data is
available to be read, or FALSE otherwise. | [
"Indicates",
"whether",
"the",
"current",
"position",
"is",
"the",
"end",
"-",
"of",
"-",
"stream"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/buffer.php#L236-L245 |
44,196 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/buffer.php | KFilesystemStreamBuffer.getPath | public function getPath()
{
if($this->getType() == 'memory') {
$this->_path = parse_url($this->_path, PHP_URL_PATH);
}
if($this->getType() == 'temp')
{
if(!$this->getResource()) {
$this->_path = $this->getTemporaryFile();
}
}
return parent::getPath();
} | php | public function getPath()
{
if($this->getType() == 'memory') {
$this->_path = parse_url($this->_path, PHP_URL_PATH);
}
if($this->getType() == 'temp')
{
if(!$this->getResource()) {
$this->_path = $this->getTemporaryFile();
}
}
return parent::getPath();
} | [
"public",
"function",
"getPath",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getType",
"(",
")",
"==",
"'memory'",
")",
"{",
"$",
"this",
"->",
"_path",
"=",
"parse_url",
"(",
"$",
"this",
"->",
"_path",
",",
"PHP_URL_PATH",
")",
";",
"}",
"if",
... | Get the stream path
@return string he URI/filename associated with this stream | [
"Get",
"the",
"stream",
"path"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/buffer.php#L367-L381 |
44,197 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/filesystem/stream/buffer.php | KFilesystemStreamBuffer.getTemporaryFile | public function getTemporaryFile($directory = null)
{
if ($directory === null) {
$directory = $this->getTemporaryDirectory();
}
$name = str_replace('.', '', uniqid('buffer', true));
$path = $directory.'/'.$name;
touch($path);
return $path;
} | php | public function getTemporaryFile($directory = null)
{
if ($directory === null) {
$directory = $this->getTemporaryDirectory();
}
$name = str_replace('.', '', uniqid('buffer', true));
$path = $directory.'/'.$name;
touch($path);
return $path;
} | [
"public",
"function",
"getTemporaryFile",
"(",
"$",
"directory",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"directory",
"===",
"null",
")",
"{",
"$",
"directory",
"=",
"$",
"this",
"->",
"getTemporaryDirectory",
"(",
")",
";",
"}",
"$",
"name",
"=",
"str_... | Creates a file with a unique file name
@param string|null $directory Uses the result of getTemporaryDirectory() by default
@return string File path | [
"Creates",
"a",
"file",
"with",
"a",
"unique",
"file",
"name"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/filesystem/stream/buffer.php#L438-L450 |
44,198 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/entity/composite.php | KModelEntityComposite.insert | public function insert(KObjectHandlable $entity)
{
if (!$entity instanceof KModelEntityInterface) {
throw new InvalidArgumentException('Entity needs to implement KModelEntityInterface');
}
$this->offsetSet($entity, null);
return true;
} | php | public function insert(KObjectHandlable $entity)
{
if (!$entity instanceof KModelEntityInterface) {
throw new InvalidArgumentException('Entity needs to implement KModelEntityInterface');
}
$this->offsetSet($entity, null);
return true;
} | [
"public",
"function",
"insert",
"(",
"KObjectHandlable",
"$",
"entity",
")",
"{",
"if",
"(",
"!",
"$",
"entity",
"instanceof",
"KModelEntityInterface",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Entity needs to implement KModelEntityInterface'",
")",
... | Insert an entity into the collection
The entity will be stored by it's identity_key if set or otherwise by it's object handle.
@param KObjectHandlable|KModelEntityInterface $entity
@throws InvalidArgumentException if the object doesn't implement KModelEntity
@return boolean TRUE on success FALSE on failure | [
"Insert",
"an",
"entity",
"into",
"the",
"collection"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/entity/composite.php#L92-L101 |
44,199 | joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/entity/composite.php | KModelEntityComposite.create | public function create(array $properties = array(), $status = null)
{
if($this->_prototypable)
{
if(!$this->_prototype instanceof KModelEntityInterface)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('model', 'entity');
$identifier['name'] = KStringInflector::singularize($this->getIdentifier()->name);
//The entity default options
$options = array(
'identity_key' => $this->getIdentityKey()
);
$this->_prototype = $this->getObject($identifier, $options);
}
$entity = clone $this->_prototype;
$entity->setStatus($status);
$entity->setProperties($properties, $entity->isNew());
}
else
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('model', 'entity');
$identifier['name'] = KStringInflector::singularize($this->getIdentifier()->name);
//The entity default options
$options = array(
'data' => $properties,
'status' => $status,
'identity_key' => $this->getIdentityKey()
);
$entity = $this->getObject($identifier, $options);
}
//Insert the entity into the collection
$this->insert($entity);
return $entity;
} | php | public function create(array $properties = array(), $status = null)
{
if($this->_prototypable)
{
if(!$this->_prototype instanceof KModelEntityInterface)
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('model', 'entity');
$identifier['name'] = KStringInflector::singularize($this->getIdentifier()->name);
//The entity default options
$options = array(
'identity_key' => $this->getIdentityKey()
);
$this->_prototype = $this->getObject($identifier, $options);
}
$entity = clone $this->_prototype;
$entity->setStatus($status);
$entity->setProperties($properties, $entity->isNew());
}
else
{
$identifier = $this->getIdentifier()->toArray();
$identifier['path'] = array('model', 'entity');
$identifier['name'] = KStringInflector::singularize($this->getIdentifier()->name);
//The entity default options
$options = array(
'data' => $properties,
'status' => $status,
'identity_key' => $this->getIdentityKey()
);
$entity = $this->getObject($identifier, $options);
}
//Insert the entity into the collection
$this->insert($entity);
return $entity;
} | [
"public",
"function",
"create",
"(",
"array",
"$",
"properties",
"=",
"array",
"(",
")",
",",
"$",
"status",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_prototypable",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_prototype",
"instanceof"... | Create a new entity and insert it
This function will either clone the entity object, or create a new instance of the entity object for each entity
being inserted. By default the entity will be cloned.
@param array $properties The entity properties
@param string $status The entity status
@return KModelEntityComposite | [
"Create",
"a",
"new",
"entity",
"and",
"insert",
"it"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/entity/composite.php#L147-L190 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.