repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
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 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/entity/composite.php | KModelEntityComposite.save | public function save()
{
$result = false;
if (count($this))
{
$result = true;
foreach ($this as $entity)
{
if (!$entity->save())
{
// Set current entity status message as collection status message.
$this->setStatusMessage($entity->getStatusMessage());
$result = false;
}
}
}
return $result;
} | php | public function save()
{
$result = false;
if (count($this))
{
$result = true;
foreach ($this as $entity)
{
if (!$entity->save())
{
// Set current entity status message as collection status message.
$this->setStatusMessage($entity->getStatusMessage());
$result = false;
}
}
}
return $result;
} | [
"public",
"function",
"save",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"count",
"(",
"$",
"this",
")",
")",
"{",
"$",
"result",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"as",
"$",
"entity",
")",
"{",
"if",
"(",
"!",
"... | Store all entities in the collection to the data store
@return boolean If successful return TRUE, otherwise FALSE | [
"Store",
"all",
"entities",
"in",
"the",
"collection",
"to",
"the",
"data",
"store"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/entity/composite.php#L231-L251 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/entity/composite.php | KModelEntityComposite.getStatus | public function getStatus()
{
$status = null;
if($entity = $this->getIterator()->current()) {
$status = $entity->getStatus();
}
return $status;
} | php | public function getStatus()
{
$status = null;
if($entity = $this->getIterator()->current()) {
$status = $entity->getStatus();
}
return $status;
} | [
"public",
"function",
"getStatus",
"(",
")",
"{",
"$",
"status",
"=",
"null",
";",
"if",
"(",
"$",
"entity",
"=",
"$",
"this",
"->",
"getIterator",
"(",
")",
"->",
"current",
"(",
")",
")",
"{",
"$",
"status",
"=",
"$",
"entity",
"->",
"getStatus",... | Returns the status
@return string The status | [
"Returns",
"the",
"status"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/entity/composite.php#L424-L433 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/entity/composite.php | KModelEntityComposite.isNew | public function isNew()
{
$result = true;
if($entity = $this->getIterator()->current()) {
$result = $entity->isNew();
}
return $result;
} | php | public function isNew()
{
$result = true;
if($entity = $this->getIterator()->current()) {
$result = $entity->isNew();
}
return $result;
} | [
"public",
"function",
"isNew",
"(",
")",
"{",
"$",
"result",
"=",
"true",
";",
"if",
"(",
"$",
"entity",
"=",
"$",
"this",
"->",
"getIterator",
"(",
")",
"->",
"current",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"entity",
"->",
"isNew",
"(",
... | Checks if the current entity is new or not
@return boolean | [
"Checks",
"if",
"the",
"current",
"entity",
"is",
"new",
"or",
"not"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/entity/composite.php#L486-L494 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/entity/composite.php | KModelEntityComposite.isConnected | public function isConnected()
{
$result = false;
if($entity = $this->getIterator()->current()) {
$result = $entity->isConnected();
}
return $result;
} | php | public function isConnected()
{
$result = false;
if($entity = $this->getIterator()->current()) {
$result = $entity->isConnected();
}
return $result;
} | [
"public",
"function",
"isConnected",
"(",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"$",
"entity",
"=",
"$",
"this",
"->",
"getIterator",
"(",
")",
"->",
"current",
"(",
")",
")",
"{",
"$",
"result",
"=",
"$",
"entity",
"->",
"isConnec... | Test if the entity is connected to a data store
@return bool | [
"Test",
"if",
"the",
"entity",
"is",
"connected",
"to",
"a",
"data",
"store"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/entity/composite.php#L519-L527 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/user.php | KUser.isAuthentic | public function isAuthentic($strict = false)
{
$result = $this->getSession()->get('user.authentic');
if ($strict) {
$result = $result && $this->_authentic;
}
return $result;
} | php | public function isAuthentic($strict = false)
{
$result = $this->getSession()->get('user.authentic');
if ($strict) {
$result = $result && $this->_authentic;
}
return $result;
} | [
"public",
"function",
"isAuthentic",
"(",
"$",
"strict",
"=",
"false",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"get",
"(",
"'user.authentic'",
")",
";",
"if",
"(",
"$",
"strict",
")",
"{",
"$",
"result",
"=",
... | Checks whether the user is not logged in
@param boolean $strict If true, checks if the user has been authenticated for this request explicitly
@return Boolean true if the user is not logged in, false otherwise | [
"Checks",
"whether",
"the",
"user",
"is",
"not",
"logged",
"in"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/user.php#L122-L131 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/user/user.php | KUser.setData | public function setData($data)
{
parent::setData($data);
//Set the user data
$this->getSession()->set('user', KObjectConfig::unbox($data));
return $this;
} | php | public function setData($data)
{
parent::setData($data);
//Set the user data
$this->getSession()->set('user', KObjectConfig::unbox($data));
return $this;
} | [
"public",
"function",
"setData",
"(",
"$",
"data",
")",
"{",
"parent",
"::",
"setData",
"(",
"$",
"data",
")",
";",
"//Set the user data",
"$",
"this",
"->",
"getSession",
"(",
")",
"->",
"set",
"(",
"'user'",
",",
"KObjectConfig",
"::",
"unbox",
"(",
... | Set the user data from an array
@param array $data An associative array of data
@return KUser | [
"Set",
"the",
"user",
"data",
"from",
"an",
"array"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/user/user.php#L183-L191 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/exception/handler/abstract.php | KExceptionHandlerAbstract.enable | public function enable($type = self::TYPE_ALL)
{
if($type & self::TYPE_EXCEPTION && !($this->_exception_type & self::TYPE_EXCEPTION))
{
set_exception_handler(array($this, '_handleException'));
$this->_exception_type |= self::TYPE_EXCEPTION;
}
if($type & self::TYPE_ERROR && !($this->_exception_type & self::TYPE_ERROR))
{
set_error_handler(array($this, '_handleError'));
$this->_exception_type |= self::TYPE_ERROR;
}
if($type & self::TYPE_FAILURE && !($this->_exception_type & self::TYPE_FAILURE))
{
if (!$this->__shutdown_registered)
{
register_shutdown_function(array($this, '_handleFailure'));
$this->__shutdown_registered = true;
}
$this->_exception_type |= self::TYPE_FAILURE;
}
return $this;
} | php | public function enable($type = self::TYPE_ALL)
{
if($type & self::TYPE_EXCEPTION && !($this->_exception_type & self::TYPE_EXCEPTION))
{
set_exception_handler(array($this, '_handleException'));
$this->_exception_type |= self::TYPE_EXCEPTION;
}
if($type & self::TYPE_ERROR && !($this->_exception_type & self::TYPE_ERROR))
{
set_error_handler(array($this, '_handleError'));
$this->_exception_type |= self::TYPE_ERROR;
}
if($type & self::TYPE_FAILURE && !($this->_exception_type & self::TYPE_FAILURE))
{
if (!$this->__shutdown_registered)
{
register_shutdown_function(array($this, '_handleFailure'));
$this->__shutdown_registered = true;
}
$this->_exception_type |= self::TYPE_FAILURE;
}
return $this;
} | [
"public",
"function",
"enable",
"(",
"$",
"type",
"=",
"self",
"::",
"TYPE_ALL",
")",
"{",
"if",
"(",
"$",
"type",
"&",
"self",
"::",
"TYPE_EXCEPTION",
"&&",
"!",
"(",
"$",
"this",
"->",
"_exception_type",
"&",
"self",
"::",
"TYPE_EXCEPTION",
")",
")",... | Enable exception handling
@param integer $type The type of exceptions to enable
@return $this | [
"Enable",
"exception",
"handling"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/exception/handler/abstract.php#L130-L156 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/exception/handler/abstract.php | KExceptionHandlerAbstract.disable | public function disable($type = self::TYPE_ALL)
{
if(($type & self::TYPE_EXCEPTION) && ($this->_exception_type & self::TYPE_EXCEPTION))
{
restore_exception_handler();
$this->_exception_type ^= self::TYPE_EXCEPTION;
}
if(($type & self::TYPE_ERROR) && ($this->_exception_type & self::TYPE_ERROR))
{
restore_error_handler();
$this->_exception_type ^= self::TYPE_ERROR;
}
if(($type & self::TYPE_FAILURE) && ($this->_exception_type & self::TYPE_FAILURE))
{
//Cannot unregister shutdown functions. Check in handler to see if it's enabled.
$this->_exception_type ^= self::TYPE_FAILURE;
}
return $this;
} | php | public function disable($type = self::TYPE_ALL)
{
if(($type & self::TYPE_EXCEPTION) && ($this->_exception_type & self::TYPE_EXCEPTION))
{
restore_exception_handler();
$this->_exception_type ^= self::TYPE_EXCEPTION;
}
if(($type & self::TYPE_ERROR) && ($this->_exception_type & self::TYPE_ERROR))
{
restore_error_handler();
$this->_exception_type ^= self::TYPE_ERROR;
}
if(($type & self::TYPE_FAILURE) && ($this->_exception_type & self::TYPE_FAILURE))
{
//Cannot unregister shutdown functions. Check in handler to see if it's enabled.
$this->_exception_type ^= self::TYPE_FAILURE;
}
return $this;
} | [
"public",
"function",
"disable",
"(",
"$",
"type",
"=",
"self",
"::",
"TYPE_ALL",
")",
"{",
"if",
"(",
"(",
"$",
"type",
"&",
"self",
"::",
"TYPE_EXCEPTION",
")",
"&&",
"(",
"$",
"this",
"->",
"_exception_type",
"&",
"self",
"::",
"TYPE_EXCEPTION",
")"... | Disable exception handling
@param integer $type The type of exceptions to disable
@return $this | [
"Disable",
"exception",
"handling"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/exception/handler/abstract.php#L164-L185 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/exception/handler/abstract.php | KExceptionHandlerAbstract.addExceptionCallback | public function addExceptionCallback(callable $callback, $prepend = false )
{
if($prepend) {
array_unshift($this->__exception_callbacks, $callback);
} else {
array_push($this->__exception_callbacks, $callback);
}
return $this;
} | php | public function addExceptionCallback(callable $callback, $prepend = false )
{
if($prepend) {
array_unshift($this->__exception_callbacks, $callback);
} else {
array_push($this->__exception_callbacks, $callback);
}
return $this;
} | [
"public",
"function",
"addExceptionCallback",
"(",
"callable",
"$",
"callback",
",",
"$",
"prepend",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"prepend",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
"__exception_callbacks",
",",
"$",
"callback",
")",
"... | Add an exception callback
@param callable $callback
@param bool $prepend If true, the callback will be prepended instead of appended.
@throws \InvalidArgumentException If the callback is not a callable
@return KExceptionHandlerAbstract | [
"Add",
"an",
"exception",
"callback"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/exception/handler/abstract.php#L195-L204 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/exception/handler/abstract.php | KExceptionHandlerAbstract.removeExceptionCallback | public function removeExceptionCallback(callable $callback)
{
foreach ($this->__exception_callbacks as $key => $exception_callback)
{
if ($exception_callback === $callback)
{
unset($this->__exception_callbacks[$key]);
break;
}
}
return $this;
} | php | public function removeExceptionCallback(callable $callback)
{
foreach ($this->__exception_callbacks as $key => $exception_callback)
{
if ($exception_callback === $callback)
{
unset($this->__exception_callbacks[$key]);
break;
}
}
return $this;
} | [
"public",
"function",
"removeExceptionCallback",
"(",
"callable",
"$",
"callback",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"__exception_callbacks",
"as",
"$",
"key",
"=>",
"$",
"exception_callback",
")",
"{",
"if",
"(",
"$",
"exception_callback",
"===",
"... | Remove an exception callback
@param callable $callback
@throws \InvalidArgumentException If the callback is not a callable
@return KExceptionHandlerAbstract | [
"Remove",
"an",
"exception",
"callback"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/exception/handler/abstract.php#L213-L225 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/exception/handler/abstract.php | KExceptionHandlerAbstract.handleException | public function handleException(\Exception $exception)
{
try
{
//Try to handle the exception
foreach($this->getExceptionCallbacks() as $handler)
{
if(call_user_func_array($handler, array(&$exception)) === true)
{
$this->__exceptions->push($exception);
return true;
};
}
}
catch (Exception $e)
{
$message = "<p><strong>%s</strong>: '%s' thrown in <strong>%s</strong> on line <strong>%s</strong></p>";
$message .= "<p>while handling exception</p>";
$message .= "<p><strong>%s</strong>: '%s' thrown in <strong>%s</strong> on line <strong>%s</strong></p>";
$message .= "<h3>Stacktrace</h3><pre>%s</pre>";
$message = sprintf($message,
get_class($e),
$e->getMessage(),
$e->getFile(),
$e->getLine(),
get_class($exception),
$exception->getMessage(),
$exception->getFile(),
$exception->getLine(),
$exception->getTraceAsString()
);
//Make sure the output buffers are cleared
$level = ob_get_level();
while($level > 0) {
ob_end_clean();
$level--;
}
if (ini_get('display_errors')) {
echo $message;
}
if (ini_get('log_errors')) {
error_log($message);
}
exit(0);
}
return false;
} | php | public function handleException(\Exception $exception)
{
try
{
//Try to handle the exception
foreach($this->getExceptionCallbacks() as $handler)
{
if(call_user_func_array($handler, array(&$exception)) === true)
{
$this->__exceptions->push($exception);
return true;
};
}
}
catch (Exception $e)
{
$message = "<p><strong>%s</strong>: '%s' thrown in <strong>%s</strong> on line <strong>%s</strong></p>";
$message .= "<p>while handling exception</p>";
$message .= "<p><strong>%s</strong>: '%s' thrown in <strong>%s</strong> on line <strong>%s</strong></p>";
$message .= "<h3>Stacktrace</h3><pre>%s</pre>";
$message = sprintf($message,
get_class($e),
$e->getMessage(),
$e->getFile(),
$e->getLine(),
get_class($exception),
$exception->getMessage(),
$exception->getFile(),
$exception->getLine(),
$exception->getTraceAsString()
);
//Make sure the output buffers are cleared
$level = ob_get_level();
while($level > 0) {
ob_end_clean();
$level--;
}
if (ini_get('display_errors')) {
echo $message;
}
if (ini_get('log_errors')) {
error_log($message);
}
exit(0);
}
return false;
} | [
"public",
"function",
"handleException",
"(",
"\\",
"Exception",
"$",
"exception",
")",
"{",
"try",
"{",
"//Try to handle the exception",
"foreach",
"(",
"$",
"this",
"->",
"getExceptionCallbacks",
"(",
")",
"as",
"$",
"handler",
")",
"{",
"if",
"(",
"call_use... | Handle an exception by calling all callbacks that have registered to receive it.
If an exception callback returns TRUE the exception handling will be aborted, otherwise the next callback will be
called, until all callbacks have gotten a change to handle the exception.
@param \Exception $exception The exception to be handled
@return bool If the exception was handled return TRUE, otherwise false | [
"Handle",
"an",
"exception",
"by",
"calling",
"all",
"callbacks",
"that",
"have",
"registered",
"to",
"receive",
"it",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/exception/handler/abstract.php#L276-L328 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/view/json.php | KViewJson._getCollection | protected function _getCollection(KModelEntityInterface $collection)
{
$result = array();
foreach ($collection as $entity) {
$result[] = $this->_getEntity($entity);
}
return $result;
} | php | protected function _getCollection(KModelEntityInterface $collection)
{
$result = array();
foreach ($collection as $entity) {
$result[] = $this->_getEntity($entity);
}
return $result;
} | [
"protected",
"function",
"_getCollection",
"(",
"KModelEntityInterface",
"$",
"collection",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"collection",
"as",
"$",
"entity",
")",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"this",... | Returns the JSON representation of a collection
@param KModelEntityInterface $collection
@return array | [
"Returns",
"the",
"JSON",
"representation",
"of",
"a",
"collection"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/view/json.php#L186-L195 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/view/json.php | KViewJson._getEntity | protected function _getEntity(KModelEntityInterface $entity)
{
$method = '_get'.ucfirst($entity->getIdentifier()->name);
if ($method !== '_getEntity' && method_exists($this, $method)) {
$data = $this->$method($entity);
} else {
$data = $entity->toArray();
}
if (!empty($this->_fields)) {
$data = array_intersect_key($data, array_merge(array('links' => 'links'), array_flip($this->_fields)));
}
if (!isset($data['links'])) {
$data['links'] = array();
}
if (!isset($data['links']['self']))
{
$data['links']['self'] = array(
'href' => (string) $this->_getEntityRoute($entity),
'type' => 'application/json; version=1.0',
);
}
return $data;
} | php | protected function _getEntity(KModelEntityInterface $entity)
{
$method = '_get'.ucfirst($entity->getIdentifier()->name);
if ($method !== '_getEntity' && method_exists($this, $method)) {
$data = $this->$method($entity);
} else {
$data = $entity->toArray();
}
if (!empty($this->_fields)) {
$data = array_intersect_key($data, array_merge(array('links' => 'links'), array_flip($this->_fields)));
}
if (!isset($data['links'])) {
$data['links'] = array();
}
if (!isset($data['links']['self']))
{
$data['links']['self'] = array(
'href' => (string) $this->_getEntityRoute($entity),
'type' => 'application/json; version=1.0',
);
}
return $data;
} | [
"protected",
"function",
"_getEntity",
"(",
"KModelEntityInterface",
"$",
"entity",
")",
"{",
"$",
"method",
"=",
"'_get'",
".",
"ucfirst",
"(",
"$",
"entity",
"->",
"getIdentifier",
"(",
")",
"->",
"name",
")",
";",
"if",
"(",
"$",
"method",
"!==",
"'_g... | Get the item data
@param KModelEntityInterface $entity Document row
@return array The array with data to be encoded to json | [
"Get",
"the",
"item",
"data"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/view/json.php#L203-L230 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/view/json.php | KViewJson._getPageUrl | protected function _getPageUrl(array $query = array())
{
$url = $this->getUrl();
if ($query) {
$url->setQuery(array_merge($url->getQuery(true), $query));
}
return (string) $url;
} | php | protected function _getPageUrl(array $query = array())
{
$url = $this->getUrl();
if ($query) {
$url->setQuery(array_merge($url->getQuery(true), $query));
}
return (string) $url;
} | [
"protected",
"function",
"_getPageUrl",
"(",
"array",
"$",
"query",
"=",
"array",
"(",
")",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getUrl",
"(",
")",
";",
"if",
"(",
"$",
"query",
")",
"{",
"$",
"url",
"->",
"setQuery",
"(",
"array_merge",
... | Get the page link
@param array $query Additional query parameters to merge
@return string | [
"Get",
"the",
"page",
"link"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/view/json.php#L252-L261 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/view/json.php | KViewJson._processLinks | protected function _processLinks(array &$array)
{
$base = $this->getUrl()->toString(KHttpUrl::AUTHORITY);
foreach ($array as $key => &$value)
{
if (is_array($value)) {
$this->_processLinks($value);
}
elseif ($key === 'href')
{
if (substr($value, 0, 4) !== 'http') {
$array[$key] = $base.$value;
}
}
elseif (in_array($key, $this->_text_fields)) {
$array[$key] = $this->_processText($value);
}
}
} | php | protected function _processLinks(array &$array)
{
$base = $this->getUrl()->toString(KHttpUrl::AUTHORITY);
foreach ($array as $key => &$value)
{
if (is_array($value)) {
$this->_processLinks($value);
}
elseif ($key === 'href')
{
if (substr($value, 0, 4) !== 'http') {
$array[$key] = $base.$value;
}
}
elseif (in_array($key, $this->_text_fields)) {
$array[$key] = $this->_processText($value);
}
}
} | [
"protected",
"function",
"_processLinks",
"(",
"array",
"&",
"$",
"array",
")",
"{",
"$",
"base",
"=",
"$",
"this",
"->",
"getUrl",
"(",
")",
"->",
"toString",
"(",
"KHttpUrl",
"::",
"AUTHORITY",
")",
";",
"foreach",
"(",
"$",
"array",
"as",
"$",
"ke... | Converts links in an array from relative to absolute
@param array $array Source array | [
"Converts",
"links",
"in",
"an",
"array",
"from",
"relative",
"to",
"absolute"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/view/json.php#L268-L287 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/view/json.php | KViewJson._processText | protected function _processText($text)
{
$matches = array();
preg_match_all("/(href|src)=\"(?!http|ftp|https|mailto|data)([^\"]*)\"/", $text, $matches, PREG_SET_ORDER);
foreach ($matches as $match)
{
$route = $this->getObject('lib:dispatcher.router.route', array(
'url' => $match[2],
'escape' => false
));
//Add the host and the schema
$route->scheme = $this->getUrl()->scheme;
$route->host = $this->getUrl()->host;
$text = str_replace($match[0], $match[1].'="'.$route.'"', $text);
}
return $text;
} | php | protected function _processText($text)
{
$matches = array();
preg_match_all("/(href|src)=\"(?!http|ftp|https|mailto|data)([^\"]*)\"/", $text, $matches, PREG_SET_ORDER);
foreach ($matches as $match)
{
$route = $this->getObject('lib:dispatcher.router.route', array(
'url' => $match[2],
'escape' => false
));
//Add the host and the schema
$route->scheme = $this->getUrl()->scheme;
$route->host = $this->getUrl()->host;
$text = str_replace($match[0], $match[1].'="'.$route.'"', $text);
}
return $text;
} | [
"protected",
"function",
"_processText",
"(",
"$",
"text",
")",
"{",
"$",
"matches",
"=",
"array",
"(",
")",
";",
"preg_match_all",
"(",
"\"/(href|src)=\\\"(?!http|ftp|https|mailto|data)([^\\\"]*)\\\"/\"",
",",
"$",
"text",
",",
"$",
"matches",
",",
"PREG_SET_ORDER"... | Convert links in a text from relative to absolute and runs them through JRoute
@param string $text The text processed
@return string Text with converted links | [
"Convert",
"links",
"in",
"a",
"text",
"from",
"relative",
"to",
"absolute",
"and",
"runs",
"them",
"through",
"JRoute"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/view/json.php#L295-L316 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/identifier/identifier.php | KObjectIdentifier.getMixins | public function getMixins()
{
if(!isset($this->getConfig()->mixins)) {
$this->getConfig()->append(array('mixins' => array()));
}
return $this->getConfig()->mixins;
} | php | public function getMixins()
{
if(!isset($this->getConfig()->mixins)) {
$this->getConfig()->append(array('mixins' => array()));
}
return $this->getConfig()->mixins;
} | [
"public",
"function",
"getMixins",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"mixins",
")",
")",
"{",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"append",
"(",
"array",
"(",
"'mixins'",
"=>",
... | Get the mixin registry
@return KObjectConfig | [
"Get",
"the",
"mixin",
"registry"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/identifier/identifier.php#L232-L239 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/identifier/identifier.php | KObjectIdentifier.getDecorators | public function getDecorators()
{
if(!isset($this->getConfig()->decorators)) {
$this->getConfig()->append(array('decorators' => array()));
}
return $this->getConfig()->decorators;
} | php | public function getDecorators()
{
if(!isset($this->getConfig()->decorators)) {
$this->getConfig()->append(array('decorators' => array()));
}
return $this->getConfig()->decorators;
} | [
"public",
"function",
"getDecorators",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"decorators",
")",
")",
"{",
"$",
"this",
"->",
"getConfig",
"(",
")",
"->",
"append",
"(",
"array",
"(",
"'decorators... | Get the decorators
@return KObjectConfig | [
"Get",
"the",
"decorators"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/identifier/identifier.php#L246-L253 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/identifier/identifier.php | KObjectIdentifier.toArray | public function toArray()
{
$data = array(
'domain' => $this->_domain,
'type' => $this->_type,
'package' => $this->_package,
'path' => $this->_path,
'name' => $this->_name,
);
return $data;
} | php | public function toArray()
{
$data = array(
'domain' => $this->_domain,
'type' => $this->_type,
'package' => $this->_package,
'path' => $this->_path,
'name' => $this->_name,
);
return $data;
} | [
"public",
"function",
"toArray",
"(",
")",
"{",
"$",
"data",
"=",
"array",
"(",
"'domain'",
"=>",
"$",
"this",
"->",
"_domain",
",",
"'type'",
"=>",
"$",
"this",
"->",
"_type",
",",
"'package'",
"=>",
"$",
"this",
"->",
"_package",
",",
"'path'",
"=>... | Formats the identifier as an associative array
@return array | [
"Formats",
"the",
"identifier",
"as",
"an",
"associative",
"array"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/identifier/identifier.php#L298-L309 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/identifier/identifier.php | KObjectIdentifier.__isset | public function __isset($property)
{
$name = ltrim($property, '_');
$vars = get_object_vars($this);
return isset($vars['_'.$name]);
} | php | public function __isset($property)
{
$name = ltrim($property, '_');
$vars = get_object_vars($this);
return isset($vars['_'.$name]);
} | [
"public",
"function",
"__isset",
"(",
"$",
"property",
")",
"{",
"$",
"name",
"=",
"ltrim",
"(",
"$",
"property",
",",
"'_'",
")",
";",
"$",
"vars",
"=",
"get_object_vars",
"(",
"$",
"this",
")",
";",
"return",
"isset",
"(",
"$",
"vars",
"[",
"'_'"... | This function checks if a virtual property is set.
@param string $property The virtual property to return.
@return boolean True if it exists otherwise false. | [
"This",
"function",
"checks",
"if",
"a",
"virtual",
"property",
"is",
"set",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/identifier/identifier.php#L333-L339 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/controller/behavior/persistable.php | KControllerBehaviorPersistable._afterBrowse | protected function _afterBrowse(KControllerContextInterface $context)
{
$state = $this->getModel()->getState();
$vars = array();
foreach($state->toArray() as $var)
{
if(!$var->unique && !$var->internal) {
$vars[$var->name] = $var->value;
}
}
$context->user->set($this->_getStateKey($context), $vars);
} | php | protected function _afterBrowse(KControllerContextInterface $context)
{
$state = $this->getModel()->getState();
$vars = array();
foreach($state->toArray() as $var)
{
if(!$var->unique && !$var->internal) {
$vars[$var->name] = $var->value;
}
}
$context->user->set($this->_getStateKey($context), $vars);
} | [
"protected",
"function",
"_afterBrowse",
"(",
"KControllerContextInterface",
"$",
"context",
")",
"{",
"$",
"state",
"=",
"$",
"this",
"->",
"getModel",
"(",
")",
"->",
"getState",
"(",
")",
";",
"$",
"vars",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
... | Saves the model state in the session
@param KControllerContextInterface $context The active controller context
@return void | [
"Saves",
"the",
"model",
"state",
"in",
"the",
"session"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/controller/behavior/persistable.php#L77-L90 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/object/config/factory.php | KObjectConfigFactory.fromString | public function fromString($format, $config, $object = true)
{
$config = $this->createFormat($format)->fromString($config, $object);
return $config;
} | php | public function fromString($format, $config, $object = true)
{
$config = $this->createFormat($format)->fromString($config, $object);
return $config;
} | [
"public",
"function",
"fromString",
"(",
"$",
"format",
",",
"$",
"config",
",",
"$",
"object",
"=",
"true",
")",
"{",
"$",
"config",
"=",
"$",
"this",
"->",
"createFormat",
"(",
"$",
"format",
")",
"->",
"fromString",
"(",
"$",
"config",
",",
"$",
... | Read a config from a string
@param string $format
@param string $config
@param bool $object If TRUE return a ConfigObject, if FALSE return an array. Default TRUE.
@throws InvalidArgumentException
@throws RuntimeException
@return KObjectConfigInterface|array | [
"Read",
"a",
"config",
"from",
"a",
"string"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/object/config/factory.php#L139-L143 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/dispatcher/request/request.php | ComKoowaDispatcherRequest.getSiteUrl | public function getSiteUrl()
{
$url = clone $this->getBaseUrl();
if(JFactory::getApplication()->getName() == 'administrator')
{
// Replace the application name only once since it's possible that
// we can run from http://localhost/administrator/administrator
$i = 1;
$path = str_ireplace('/administrator', '', $url->getPath(), $i);
$url->setPath($path);
}
return $url;
} | php | public function getSiteUrl()
{
$url = clone $this->getBaseUrl();
if(JFactory::getApplication()->getName() == 'administrator')
{
// Replace the application name only once since it's possible that
// we can run from http://localhost/administrator/administrator
$i = 1;
$path = str_ireplace('/administrator', '', $url->getPath(), $i);
$url->setPath($path);
}
return $url;
} | [
"public",
"function",
"getSiteUrl",
"(",
")",
"{",
"$",
"url",
"=",
"clone",
"$",
"this",
"->",
"getBaseUrl",
"(",
")",
";",
"if",
"(",
"JFactory",
"::",
"getApplication",
"(",
")",
"->",
"getName",
"(",
")",
"==",
"'administrator'",
")",
"{",
"// Repl... | Returns the site URL from which this request is executed.
@return KHttpUrl A HttpUrl object | [
"Returns",
"the",
"site",
"URL",
"from",
"which",
"this",
"request",
"is",
"executed",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/request/request.php#L23-L37 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/dispatcher/request/request.php | ComKoowaDispatcherRequest.setFormat | public function setFormat($format)
{
if (JFactory::getApplication()->getCfg('sef_suffix') && $format === 'feed') {
$format = 'rss';
}
return parent::setFormat($format);
} | php | public function setFormat($format)
{
if (JFactory::getApplication()->getCfg('sef_suffix') && $format === 'feed') {
$format = 'rss';
}
return parent::setFormat($format);
} | [
"public",
"function",
"setFormat",
"(",
"$",
"format",
")",
"{",
"if",
"(",
"JFactory",
"::",
"getApplication",
"(",
")",
"->",
"getCfg",
"(",
"'sef_suffix'",
")",
"&&",
"$",
"format",
"===",
"'feed'",
")",
"{",
"$",
"format",
"=",
"'rss'",
";",
"}",
... | Forces format to "rss" if it comes in as "feed" per Joomla conventions if SEF suffixes are enabled
{@inheritdoc} | [
"Forces",
"format",
"to",
"rss",
"if",
"it",
"comes",
"in",
"as",
"feed",
"per",
"Joomla",
"conventions",
"if",
"SEF",
"suffixes",
"are",
"enabled"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/request/request.php#L44-L51 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/dispatcher/request/request.php | ComKoowaDispatcherRequest.getPort | public function getPort()
{
$port = parent::getPort();
if (JUri::getInstance()->isSsl() || ($this->isSecure() && in_array($port, ['80', '8080']))) {
$port = '443';
}
return $port;
} | php | public function getPort()
{
$port = parent::getPort();
if (JUri::getInstance()->isSsl() || ($this->isSecure() && in_array($port, ['80', '8080']))) {
$port = '443';
}
return $port;
} | [
"public",
"function",
"getPort",
"(",
")",
"{",
"$",
"port",
"=",
"parent",
"::",
"getPort",
"(",
")",
";",
"if",
"(",
"JUri",
"::",
"getInstance",
"(",
")",
"->",
"isSsl",
"(",
")",
"||",
"(",
"$",
"this",
"->",
"isSecure",
"(",
")",
"&&",
"in_a... | If the current Joomla URI is on https or PHP is on a secure connection always return 443 instead of 80
{@inheritdoc} | [
"If",
"the",
"current",
"Joomla",
"URI",
"is",
"on",
"https",
"or",
"PHP",
"is",
"on",
"a",
"secure",
"connection",
"always",
"return",
"443",
"instead",
"of",
"80"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/dispatcher/request/request.php#L58-L67 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/component/koowa/class/locator/plugin.php | ComKoowaClassLocatorPlugin.locate | public function locate($classname, $basepath = null)
{
if (substr($classname, 0, 3) === 'Plg')
{
/*
* Exception rule for Exception classes
*
* Transform class to lower case to always load the exception class from the /exception/ folder.
*/
if ($pos = strpos($classname, 'Exception'))
{
$filename = substr($classname, $pos + strlen('Exception'));
$classname = str_replace($filename, ucfirst(strtolower($filename)), $classname);
}
$word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', ' \\1', $classname));
$parts = explode(' ', $word);
array_shift($parts);
$package = array_shift($parts);
$namespace = ucfirst($package);
if(count($parts)) {
$file = array_pop($parts);
} else {
$file = $package;
}
//Switch basepath
if(!$this->getNamespace($namespace)) {
$basepath = $this->getNamespace('\\');
} else {
$basepath = $this->getNamespace($namespace);
}
$path = '';
if (!empty($parts)) {
$path = implode('/', $parts) . '/';
}
$result = $basepath.'/'.$package.'/'.$path . $file.'.php';
if(!is_file($result)) {
$result = $basepath.'/'.$package.'/'.$path . $file.'/'.$file.'.php';
}
return $result;
}
return false;
} | php | public function locate($classname, $basepath = null)
{
if (substr($classname, 0, 3) === 'Plg')
{
/*
* Exception rule for Exception classes
*
* Transform class to lower case to always load the exception class from the /exception/ folder.
*/
if ($pos = strpos($classname, 'Exception'))
{
$filename = substr($classname, $pos + strlen('Exception'));
$classname = str_replace($filename, ucfirst(strtolower($filename)), $classname);
}
$word = strtolower(preg_replace('/(?<=\\w)([A-Z])/', ' \\1', $classname));
$parts = explode(' ', $word);
array_shift($parts);
$package = array_shift($parts);
$namespace = ucfirst($package);
if(count($parts)) {
$file = array_pop($parts);
} else {
$file = $package;
}
//Switch basepath
if(!$this->getNamespace($namespace)) {
$basepath = $this->getNamespace('\\');
} else {
$basepath = $this->getNamespace($namespace);
}
$path = '';
if (!empty($parts)) {
$path = implode('/', $parts) . '/';
}
$result = $basepath.'/'.$package.'/'.$path . $file.'.php';
if(!is_file($result)) {
$result = $basepath.'/'.$package.'/'.$path . $file.'/'.$file.'.php';
}
return $result;
}
return false;
} | [
"public",
"function",
"locate",
"(",
"$",
"classname",
",",
"$",
"basepath",
"=",
"null",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"classname",
",",
"0",
",",
"3",
")",
"===",
"'Plg'",
")",
"{",
"/*\n * Exception rule for Exception classes\n ... | Get a fully qualified based on a class name
@param string $classname The class name
@param string $basepath The base path
@return string|boolean Returns the path on success FALSE on failure | [
"Get",
"a",
"fully",
"qualified",
"based",
"on",
"a",
"class",
"name"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/component/koowa/class/locator/plugin.php#L50-L102 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/engine/koowa.php | KTemplateEngineKoowa.loadString | public function loadString($source, $url = null)
{
$name = crc32($url ?: $source);
if(!$file = $this->isCached($name))
{
//Compile the template
$source = $this->_compile($source);
if($source === false) {
throw new RuntimeException(sprintf('The template content cannot be compiled.'));
}
$file = $this->cache($name, $source);
}
$this->_source = $file;
//Push the template on the stack
array_push($this->_stack, $url);
//Store the location
if($url) {
$this->_locations[$url] = $file;
}
return $this;
} | php | public function loadString($source, $url = null)
{
$name = crc32($url ?: $source);
if(!$file = $this->isCached($name))
{
//Compile the template
$source = $this->_compile($source);
if($source === false) {
throw new RuntimeException(sprintf('The template content cannot be compiled.'));
}
$file = $this->cache($name, $source);
}
$this->_source = $file;
//Push the template on the stack
array_push($this->_stack, $url);
//Store the location
if($url) {
$this->_locations[$url] = $file;
}
return $this;
} | [
"public",
"function",
"loadString",
"(",
"$",
"source",
",",
"$",
"url",
"=",
"null",
")",
"{",
"$",
"name",
"=",
"crc32",
"(",
"$",
"url",
"?",
":",
"$",
"source",
")",
";",
"if",
"(",
"!",
"$",
"file",
"=",
"$",
"this",
"->",
"isCached",
"(",... | Set the template source from a string
@param string $source The template source
@throws RuntimeException If the template could not be compiled
@return KTemplateEngineKoowa | [
"Set",
"the",
"template",
"source",
"from",
"a",
"string"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/koowa.php#L128-L155 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/template/engine/koowa.php | KTemplateEngineKoowa.handleException | public function handleException(Exception &$exception)
{
if($template = end($this->_stack))
{
if($this->_source == $exception->getFile())
{
//Prevents any partial templates from leaking.
ob_get_clean();
//Re-create the exception and set the real file path
if($exception instanceof ErrorException)
{
$class = get_class($exception);
$file = $this->getObject('template.locator.factory')->locate($template) ?: $this->_source;
$exception = new KTemplateExceptionError(
$exception->getMessage(),
$exception->getCode(),
$exception->getSeverity(),
$file,
$exception->getLine(),
$exception
);
}
}
}
} | php | public function handleException(Exception &$exception)
{
if($template = end($this->_stack))
{
if($this->_source == $exception->getFile())
{
//Prevents any partial templates from leaking.
ob_get_clean();
//Re-create the exception and set the real file path
if($exception instanceof ErrorException)
{
$class = get_class($exception);
$file = $this->getObject('template.locator.factory')->locate($template) ?: $this->_source;
$exception = new KTemplateExceptionError(
$exception->getMessage(),
$exception->getCode(),
$exception->getSeverity(),
$file,
$exception->getLine(),
$exception
);
}
}
}
} | [
"public",
"function",
"handleException",
"(",
"Exception",
"&",
"$",
"exception",
")",
"{",
"if",
"(",
"$",
"template",
"=",
"end",
"(",
"$",
"this",
"->",
"_stack",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_source",
"==",
"$",
"exception",
"->"... | Handle template exceptions
If an ErrorException is thrown create a new exception and set the file location to the real template file.
@param \Exception $exception
@return void | [
"Handle",
"template",
"exceptions"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/template/engine/koowa.php#L216-L242 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/event/subscriber/abstract.php | KEventSubscriberAbstract.getEventListeners | public static function getEventListeners()
{
$listeners = array();
$reflection = new ReflectionClass(get_called_class());
foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method)
{
if(substr($method->name, 0, 2) == 'on') {
$listeners[] = $method->name;
}
}
return $listeners;
} | php | public static function getEventListeners()
{
$listeners = array();
$reflection = new ReflectionClass(get_called_class());
foreach ($reflection->getMethods(ReflectionMethod::IS_PUBLIC) as $method)
{
if(substr($method->name, 0, 2) == 'on') {
$listeners[] = $method->name;
}
}
return $listeners;
} | [
"public",
"static",
"function",
"getEventListeners",
"(",
")",
"{",
"$",
"listeners",
"=",
"array",
"(",
")",
";",
"$",
"reflection",
"=",
"new",
"ReflectionClass",
"(",
"get_called_class",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"reflection",
"->",
"getM... | Get the event listeners
@return array | [
"Get",
"the",
"event",
"listeners"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/event/subscriber/abstract.php#L97-L110 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/state/state.php | KModelState.insert | public function insert($name, $filter, $default = null, $unique = false, $required = array(), $internal = false)
{
//Create the state
$state = new stdClass();
$state->name = $name;
$state->filter = $filter;
$state->value = null;
$state->unique = $unique;
$state->required = $required;
$state->default = $default;
$state->internal = $internal;
$this->_data[$name] = $state;
//Set the value to default
if(isset($default)) {
$this->offsetSet($name, $default);
}
return $this;
} | php | public function insert($name, $filter, $default = null, $unique = false, $required = array(), $internal = false)
{
//Create the state
$state = new stdClass();
$state->name = $name;
$state->filter = $filter;
$state->value = null;
$state->unique = $unique;
$state->required = $required;
$state->default = $default;
$state->internal = $internal;
$this->_data[$name] = $state;
//Set the value to default
if(isset($default)) {
$this->offsetSet($name, $default);
}
return $this;
} | [
"public",
"function",
"insert",
"(",
"$",
"name",
",",
"$",
"filter",
",",
"$",
"default",
"=",
"null",
",",
"$",
"unique",
"=",
"false",
",",
"$",
"required",
"=",
"array",
"(",
")",
",",
"$",
"internal",
"=",
"false",
")",
"{",
"//Create the state"... | Insert a new state
@param string $name The name of the state
@param mixed $filter Filter(s), can be a FilterInterface object, a filter name or an array of filter names
@param mixed $default The default value of the state
@param boolean $unique TRUE if the state uniquely identifies an entity, FALSE otherwise. Default FALSE.
@param array $required Array of required states to determine if the state is unique. Only applicable if the
state is unqiue.
@param boolean $internal If TRUE the state will be considered internal and should not be included in a routes.
Default FALSE.
@return KModelState | [
"Insert",
"a",
"new",
"state"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/state/state.php#L88-L107 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/state/state.php | KModelState.setValues | public function setValues(array $data)
{
foreach($data as $key => $value) {
$this->set($key, $value);
}
return $this;
} | php | public function setValues(array $data)
{
foreach($data as $key => $value) {
$this->set($key, $value);
}
return $this;
} | [
"public",
"function",
"setValues",
"(",
"array",
"$",
"data",
")",
"{",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"this",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"th... | Set the state values from an array
@param array $data An associative array of state values by name
@return KModelState | [
"Set",
"the",
"state",
"values",
"from",
"an",
"array"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/state/state.php#L204-L211 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/state/state.php | KModelState.getProperty | public function getProperty($name, $property)
{
$result = null;
if($this->has($name))
{
if(isset($this->_data[$name]->$property)) {
$result = $this->_data[$name]->$property;
}
}
return $result;
} | php | public function getProperty($name, $property)
{
$result = null;
if($this->has($name))
{
if(isset($this->_data[$name]->$property)) {
$result = $this->_data[$name]->$property;
}
}
return $result;
} | [
"public",
"function",
"getProperty",
"(",
"$",
"name",
",",
"$",
"property",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_data",
"... | Get a state property
@param string $name The name of the state
@param string $property The name of the property
@return mixed|null Return the property value or NULL if the property does not exist | [
"Get",
"a",
"state",
"property"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/state/state.php#L292-L303 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/state/state.php | KModelState.hasProperty | public function hasProperty($name, $property)
{
$result = false;
if($this->has($name)) {
$result = property_exists($this->_data[$name], $property);
}
return $result;
} | php | public function hasProperty($name, $property)
{
$result = false;
if($this->has($name)) {
$result = property_exists($this->_data[$name], $property);
}
return $result;
} | [
"public",
"function",
"hasProperty",
"(",
"$",
"name",
",",
"$",
"property",
")",
"{",
"$",
"result",
"=",
"false",
";",
"if",
"(",
"$",
"this",
"->",
"has",
"(",
"$",
"name",
")",
")",
"{",
"$",
"result",
"=",
"property_exists",
"(",
"$",
"this",
... | Check if a state property exists
@param string $name The name of the state
@param string $property The name of the property
@return boolean Return TRUE if the the property exists, FALSE otherwise | [
"Check",
"if",
"a",
"state",
"property",
"exists"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/state/state.php#L312-L320 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/state/state.php | KModelState.isEmpty | public function isEmpty(array $exclude = array())
{
$states = $this->getValues();
foreach($exclude as $state) {
unset($states[$state]);
}
return (bool) (count($states) == 0);
} | php | public function isEmpty(array $exclude = array())
{
$states = $this->getValues();
foreach($exclude as $state) {
unset($states[$state]);
}
return (bool) (count($states) == 0);
} | [
"public",
"function",
"isEmpty",
"(",
"array",
"$",
"exclude",
"=",
"array",
"(",
")",
")",
"{",
"$",
"states",
"=",
"$",
"this",
"->",
"getValues",
"(",
")",
";",
"foreach",
"(",
"$",
"exclude",
"as",
"$",
"state",
")",
"{",
"unset",
"(",
"$",
"... | Check if the state information is empty
@param array $exclude An array of states names to exclude.
@return boolean TRUE if the state is empty, otherwise FALSE. | [
"Check",
"if",
"the",
"state",
"information",
"is",
"empty"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/state/state.php#L358-L367 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/state/state.php | KModelState.offsetGet | public function offsetGet($name)
{
$result = null;
if (isset($this->_data[$name])) {
$result = $this->_data[$name]->value;
}
return $result;
} | php | public function offsetGet($name)
{
$result = null;
if (isset($this->_data[$name])) {
$result = $this->_data[$name]->value;
}
return $result;
} | [
"public",
"function",
"offsetGet",
"(",
"$",
"name",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_data",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_data",
"[",
"$",... | Get an state value
@param string $name
@return mixed The state value | [
"Get",
"an",
"state",
"value"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/state/state.php#L375-L384 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/model/state/state.php | KModelState.offsetSet | public function offsetSet($name, $value)
{
if($this->offsetExists($name))
{
//Only filter if we have a value
if($value !== null)
{
if($value !== '')
{
//Only accepts scalar values and array
if(!is_scalar($value) && !is_array($value))
{
throw new UnexpectedValueException(
'Value needs to be an array or a scalar, "'.gettype($value).'" given'
);
}
$filter = $this->_data[$name]->filter;
if(!($filter instanceof KFilterInterface)) {
$filter = $this->getObject('filter.factory')->createChain($filter);
}
$value = $filter->sanitize($value);
}
else $value = null;
}
$this->_data[$name]->value = $value;
}
} | php | public function offsetSet($name, $value)
{
if($this->offsetExists($name))
{
//Only filter if we have a value
if($value !== null)
{
if($value !== '')
{
//Only accepts scalar values and array
if(!is_scalar($value) && !is_array($value))
{
throw new UnexpectedValueException(
'Value needs to be an array or a scalar, "'.gettype($value).'" given'
);
}
$filter = $this->_data[$name]->filter;
if(!($filter instanceof KFilterInterface)) {
$filter = $this->getObject('filter.factory')->createChain($filter);
}
$value = $filter->sanitize($value);
}
else $value = null;
}
$this->_data[$name]->value = $value;
}
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"name",
")",
")",
"{",
"//Only filter if we have a value",
"if",
"(",
"$",
"value",
"!==",
"null",
")",
"{",
"if",... | Set an state value
This function only accepts scalar or array values. Values are only filtered if not NULL. If the value is an empty
string it will be filtered to NULL. Values will only be set if the state exists. Function will not create new
states. Use the insert() function instead.
@param string $name
@param mixed|array $value
@throws UnexpectedValueException If the value is not a scalar or an array
@return void | [
"Set",
"an",
"state",
"value"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/model/state/state.php#L398-L428 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/token/token.php | KHttpToken.setAlgorithm | public function setAlgorithm($algorithm)
{
$algorithms = array(
'HS256' => 'sha256',
'HS384' => 'sha384',
'HS512' => 'sha512',
'none' => false
);
if (!isset($algorithms[$algorithm])) {
throw new DomainException('Algorithm not supported');
}
$this->_header['alg'] = $algorithm;
$this->_algorithm = $algorithms[$algorithm];
return $this;
} | php | public function setAlgorithm($algorithm)
{
$algorithms = array(
'HS256' => 'sha256',
'HS384' => 'sha384',
'HS512' => 'sha512',
'none' => false
);
if (!isset($algorithms[$algorithm])) {
throw new DomainException('Algorithm not supported');
}
$this->_header['alg'] = $algorithm;
$this->_algorithm = $algorithms[$algorithm];
return $this;
} | [
"public",
"function",
"setAlgorithm",
"(",
"$",
"algorithm",
")",
"{",
"$",
"algorithms",
"=",
"array",
"(",
"'HS256'",
"=>",
"'sha256'",
",",
"'HS384'",
"=>",
"'sha384'",
",",
"'HS512'",
"=>",
"'sha512'",
",",
"'none'",
"=>",
"false",
")",
";",
"if",
"(... | Sets cryptographic algorithm used to secure the token.
@param string $algorithm The signing algorithm. Supported algorithms are 'HS256', 'HS384' and 'HS512' or none
@throws DomainException If an unsupported algorithm was specified
@return KHttpToken | [
"Sets",
"cryptographic",
"algorithm",
"used",
"to",
"secure",
"the",
"token",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/token/token.php#L146-L163 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/token/token.php | KHttpToken.getIssueTime | public function getIssueTime()
{
$date = null;
if(isset($this->_claims['iat']))
{
$value = $this->_claims['iat'];
$date = new DateTime('@'.$value);
if ($date === false) {
throw new RuntimeException(sprintf('The token issue time is not parseable (%s).', $value));
}
};
return $date;
} | php | public function getIssueTime()
{
$date = null;
if(isset($this->_claims['iat']))
{
$value = $this->_claims['iat'];
$date = new DateTime('@'.$value);
if ($date === false) {
throw new RuntimeException(sprintf('The token issue time is not parseable (%s).', $value));
}
};
return $date;
} | [
"public",
"function",
"getIssueTime",
"(",
")",
"{",
"$",
"date",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_claims",
"[",
"'iat'",
"]",
")",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"_claims",
"[",
"'iat'",
"]",
";",
... | Get the issue time of the token.
The value of the claim parameter 'iat' as DateTime.
@return DateTime A \DateTime instance
@throws RuntimeException If the data could not be parsed
@return DateTime|null A DateTime instance or NULL if the token doesn't contain and expiration time | [
"Get",
"the",
"issue",
"time",
"of",
"the",
"token",
"."
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/token/token.php#L283-L297 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/token/token.php | KHttpToken.getClaim | public function getClaim($name)
{
$result = null;
if(isset($this->_claims[$name])) {
$result = $this->_claims[$name];
}
return $result;
} | php | public function getClaim($name)
{
$result = null;
if(isset($this->_claims[$name])) {
$result = $this->_claims[$name];
}
return $result;
} | [
"public",
"function",
"getClaim",
"(",
"$",
"name",
")",
"{",
"$",
"result",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"_claims",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"_claims",
"[",
"... | Get a claim
@param string $name The name if the claim
@return mixed | [
"Get",
"a",
"claim"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/token/token.php#L322-L330 | train |
joomlatools/joomlatools-framework | code/libraries/joomlatools/library/http/token/token.php | KHttpToken.getSignature | public function getSignature($secret = null)
{
$signature = '';
if($this->_algorithm)
{
$header = $this->_toBase64url($this->_toJson($this->_header));
$payload = $this->_toBase64url($this->_toJson($this->_claims));
$message = sprintf("%s.%s", $header, $payload);
$signature = hash_hmac($this->_algorithm, $message, $secret, true);
}
return $signature;
} | php | public function getSignature($secret = null)
{
$signature = '';
if($this->_algorithm)
{
$header = $this->_toBase64url($this->_toJson($this->_header));
$payload = $this->_toBase64url($this->_toJson($this->_claims));
$message = sprintf("%s.%s", $header, $payload);
$signature = hash_hmac($this->_algorithm, $message, $secret, true);
}
return $signature;
} | [
"public",
"function",
"getSignature",
"(",
"$",
"secret",
"=",
"null",
")",
"{",
"$",
"signature",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"_algorithm",
")",
"{",
"$",
"header",
"=",
"$",
"this",
"->",
"_toBase64url",
"(",
"$",
"this",
"->",
... | Get the token signature
@param string|null $secret The secret key
@return string | [
"Get",
"the",
"token",
"signature"
] | 5ea3cc6b48b68fd8899a573b191de983e768d56e | https://github.com/joomlatools/joomlatools-framework/blob/5ea3cc6b48b68fd8899a573b191de983e768d56e/code/libraries/joomlatools/library/http/token/token.php#L361-L375 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.