id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
|---|---|---|---|---|---|---|---|---|---|---|---|
227,600
|
authlete/authlete-php
|
src/Web/HttpHeaders.php
|
HttpHeaders.get
|
public function get($name)
{
if (is_null($name) || empty($name))
{
return null;
}
$loweredKey = strtolower($name);
if (array_key_exists($loweredKey, $this->keyMap) === false)
{
return null;
}
$originalKey = $this->keyMap[$loweredKey];
return $this->headerMap[$originalKey];
}
|
php
|
public function get($name)
{
if (is_null($name) || empty($name))
{
return null;
}
$loweredKey = strtolower($name);
if (array_key_exists($loweredKey, $this->keyMap) === false)
{
return null;
}
$originalKey = $this->keyMap[$loweredKey];
return $this->headerMap[$originalKey];
}
|
[
"public",
"function",
"get",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"name",
")",
"||",
"empty",
"(",
"$",
"name",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"loweredKey",
"=",
"strtolower",
"(",
"$",
"name",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"loweredKey",
",",
"$",
"this",
"->",
"keyMap",
")",
"===",
"false",
")",
"{",
"return",
"null",
";",
"}",
"$",
"originalKey",
"=",
"$",
"this",
"->",
"keyMap",
"[",
"$",
"loweredKey",
"]",
";",
"return",
"$",
"this",
"->",
"headerMap",
"[",
"$",
"originalKey",
"]",
";",
"}"
] |
Get the values of an HTTP header.
@param string $name
HTTP header name. For example, `Location`. Case-insensitive.
@return array
Values of the HTTP header.
|
[
"Get",
"the",
"values",
"of",
"an",
"HTTP",
"header",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Web/HttpHeaders.php#L100-L117
|
227,601
|
authlete/authlete-php
|
src/Web/HttpHeaders.php
|
HttpHeaders.parse
|
public static function parse($input)
{
$headers = new HttpHeaders();
if (is_null($input) || empty($input))
{
return $headers;
}
$lines = preg_split('/\R/', $input);
foreach ($lines as $header)
{
$elements = explode(':', $header, 2);
if (count($elements) === 2)
{
$name = trim($elements[0]);
$value = trim($elements[1]);
$headers->add($name, $value);
}
}
return $headers;
}
|
php
|
public static function parse($input)
{
$headers = new HttpHeaders();
if (is_null($input) || empty($input))
{
return $headers;
}
$lines = preg_split('/\R/', $input);
foreach ($lines as $header)
{
$elements = explode(':', $header, 2);
if (count($elements) === 2)
{
$name = trim($elements[0]);
$value = trim($elements[1]);
$headers->add($name, $value);
}
}
return $headers;
}
|
[
"public",
"static",
"function",
"parse",
"(",
"$",
"input",
")",
"{",
"$",
"headers",
"=",
"new",
"HttpHeaders",
"(",
")",
";",
"if",
"(",
"is_null",
"(",
"$",
"input",
")",
"||",
"empty",
"(",
"$",
"input",
")",
")",
"{",
"return",
"$",
"headers",
";",
"}",
"$",
"lines",
"=",
"preg_split",
"(",
"'/\\R/'",
",",
"$",
"input",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"$",
"header",
")",
"{",
"$",
"elements",
"=",
"explode",
"(",
"':'",
",",
"$",
"header",
",",
"2",
")",
";",
"if",
"(",
"count",
"(",
"$",
"elements",
")",
"===",
"2",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"$",
"elements",
"[",
"0",
"]",
")",
";",
"$",
"value",
"=",
"trim",
"(",
"$",
"elements",
"[",
"1",
"]",
")",
";",
"$",
"headers",
"->",
"add",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"headers",
";",
"}"
] |
Parse HTTP headers and generate an instance of HttpHeaders that
represents the HTTP headers.
```
$input = "Fruits: Apple\r\n"
. "fruits: Banana\r\n"
. "FRUITS: Cherry\r\n"
. "Animals: Cat\r\n"
;
$headers = HttpHeaders::parse($input);
```
@param string $input
HTTP headers delimited by newlines (CRLF or LF).
@return HttpHeaders
An HttpHeaders instance that represents the given HTTP headers.
|
[
"Parse",
"HTTP",
"headers",
"and",
"generate",
"an",
"instance",
"of",
"HttpHeaders",
"that",
"represents",
"the",
"HTTP",
"headers",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Web/HttpHeaders.php#L173-L197
|
227,602
|
movim/moxl
|
src/Moxl/Utils.php
|
Utils.cleanXML
|
public static function cleanXML($xml)
{
if($xml != '') {
$doc = new \DOMDocument();
$doc->loadXML($xml);
$doc->formatOutput = true;
return $doc->saveXML();
} else {
return '';
}
}
|
php
|
public static function cleanXML($xml)
{
if($xml != '') {
$doc = new \DOMDocument();
$doc->loadXML($xml);
$doc->formatOutput = true;
return $doc->saveXML();
} else {
return '';
}
}
|
[
"public",
"static",
"function",
"cleanXML",
"(",
"$",
"xml",
")",
"{",
"if",
"(",
"$",
"xml",
"!=",
"''",
")",
"{",
"$",
"doc",
"=",
"new",
"\\",
"DOMDocument",
"(",
")",
";",
"$",
"doc",
"->",
"loadXML",
"(",
"$",
"xml",
")",
";",
"$",
"doc",
"->",
"formatOutput",
"=",
"true",
";",
"return",
"$",
"doc",
"->",
"saveXML",
"(",
")",
";",
"}",
"else",
"{",
"return",
"''",
";",
"}",
"}"
] |
A simple function which clean and reindent an XML string
|
[
"A",
"simple",
"function",
"which",
"clean",
"and",
"reindent",
"an",
"XML",
"string"
] |
bfe3e1d83ef3bbbd270150f2f1164e8a662ef716
|
https://github.com/movim/moxl/blob/bfe3e1d83ef3bbbd270150f2f1164e8a662ef716/src/Moxl/Utils.php#L18-L28
|
227,603
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedRevocationAuthMethods
|
public function setSupportedRevocationAuthMethods(array $methods = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$methods', $methods, '\Authlete\Types\ClientAuthMethod');
$this->supportedRevocationAuthMethods = $methods;
return $this;
}
|
php
|
public function setSupportedRevocationAuthMethods(array $methods = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$methods', $methods, '\Authlete\Types\ClientAuthMethod');
$this->supportedRevocationAuthMethods = $methods;
return $this;
}
|
[
"public",
"function",
"setSupportedRevocationAuthMethods",
"(",
"array",
"$",
"methods",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$methods'",
",",
"$",
"methods",
",",
"'\\Authlete\\Types\\ClientAuthMethod'",
")",
";",
"$",
"this",
"->",
"supportedRevocationAuthMethods",
"=",
"$",
"methods",
";",
"return",
"$",
"this",
";",
"}"
] |
Set client authentication methods at the revocation endpoint
supported by this service.
This corresponds to the `revocation_endpoint_auth_methods_supported`
metadata defined in "OAuth 2.0 Authorization Server Metadata".
@param ClientAuthMethod[] $methods
Supported client authentication methods at the revocation endpoint.
@return Service
`$this` object.
|
[
"Set",
"client",
"authentication",
"methods",
"at",
"the",
"revocation",
"endpoint",
"supported",
"by",
"this",
"service",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L415-L423
|
227,604
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedScopes
|
public function setSupportedScopes(array $scopes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$scopes', $scopes, __NAMESPACE__ . '\Scope');
$this->supportedScopes = $scopes;
return $this;
}
|
php
|
public function setSupportedScopes(array $scopes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$scopes', $scopes, __NAMESPACE__ . '\Scope');
$this->supportedScopes = $scopes;
return $this;
}
|
[
"public",
"function",
"setSupportedScopes",
"(",
"array",
"$",
"scopes",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$scopes'",
",",
"$",
"scopes",
",",
"__NAMESPACE__",
".",
"'\\Scope'",
")",
";",
"$",
"this",
"->",
"supportedScopes",
"=",
"$",
"scopes",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the scopes supported by this service.
This corresponds to the `scopes_supported` metadata defined in
[3. OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata)
of [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html).
@param Scope[] $scopes
Supported scopes.
@return Service
`$this` object.
|
[
"Set",
"the",
"scopes",
"supported",
"by",
"this",
"service",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L611-L619
|
227,605
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedResponseTypes
|
public function setSupportedResponseTypes(array $responseTypes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$responseTypes', $responseTypes, '\Authlete\Types\ResponseType');
$this->supportedResponseTypes = $responseTypes;
return $this;
}
|
php
|
public function setSupportedResponseTypes(array $responseTypes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$responseTypes', $responseTypes, '\Authlete\Types\ResponseType');
$this->supportedResponseTypes = $responseTypes;
return $this;
}
|
[
"public",
"function",
"setSupportedResponseTypes",
"(",
"array",
"$",
"responseTypes",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$responseTypes'",
",",
"$",
"responseTypes",
",",
"'\\Authlete\\Types\\ResponseType'",
")",
";",
"$",
"this",
"->",
"supportedResponseTypes",
"=",
"$",
"responseTypes",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the response types supported by this service.
This corresponds to the `response_types_supported` metadata defined in
[3. OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata)
of [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html).
@param ResponseType[] $responseTypes
Supported response types.
@return Service
`$this` object.
@see https://openid.net/specs/oauth-v2-multiple-response-types-1_0.html OAuth 2.0 Multiple Response Type Encoding Practices
|
[
"Set",
"the",
"response",
"types",
"supported",
"by",
"this",
"service",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L655-L663
|
227,606
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedGrantTypes
|
public function setSupportedGrantTypes(array $grantTypes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$grantTypes', $grantTypes, '\Authlete\Types\GrantType');
$this->supportedGrantTypes = $grantTypes;
return $this;
}
|
php
|
public function setSupportedGrantTypes(array $grantTypes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$grantTypes', $grantTypes, '\Authlete\Types\GrantType');
$this->supportedGrantTypes = $grantTypes;
return $this;
}
|
[
"public",
"function",
"setSupportedGrantTypes",
"(",
"array",
"$",
"grantTypes",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$grantTypes'",
",",
"$",
"grantTypes",
",",
"'\\Authlete\\Types\\GrantType'",
")",
";",
"$",
"this",
"->",
"supportedGrantTypes",
"=",
"$",
"grantTypes",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the grant types supported by this service.
This corresponds to the `grant_types_supported` metadata defined in
[3. OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata)
of [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html).
@param GrantType[] $grantTypes
Supported grant types.
@return Service
`$this` object.
|
[
"Set",
"the",
"grant",
"types",
"supported",
"by",
"this",
"service",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L695-L703
|
227,607
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedTokenAuthMethods
|
public function setSupportedTokenAuthMethods(array $methods = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$methods', $methods, '\Authlete\Types\ClientAuthMethod');
$this->supportedTokenAuthMethods = $methods;
return $this;
}
|
php
|
public function setSupportedTokenAuthMethods(array $methods = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$methods', $methods, '\Authlete\Types\ClientAuthMethod');
$this->supportedTokenAuthMethods = $methods;
return $this;
}
|
[
"public",
"function",
"setSupportedTokenAuthMethods",
"(",
"array",
"$",
"methods",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$methods'",
",",
"$",
"methods",
",",
"'\\Authlete\\Types\\ClientAuthMethod'",
")",
";",
"$",
"this",
"->",
"supportedTokenAuthMethods",
"=",
"$",
"methods",
";",
"return",
"$",
"this",
";",
"}"
] |
Set client authentication methods at the token endpoint supported
by this service.
This corresponds to the `token_endpoint_auth_methods_supported`
metadata defined in
[3. OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata)
of [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html).
@param ClientAuthMethod[] $methods
Supported client authentication methods at the token endpoint.
@return Service
`$this` object.
|
[
"Set",
"client",
"authentication",
"methods",
"at",
"the",
"token",
"endpoint",
"supported",
"by",
"this",
"service",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L780-L788
|
227,608
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedDisplays
|
public function setSupportedDisplays(array $displays = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$displays', $displays, '\Authlete\Types\Display');
$this->supportedDisplays = $displays;
return $this;
}
|
php
|
public function setSupportedDisplays(array $displays = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$displays', $displays, '\Authlete\Types\Display');
$this->supportedDisplays = $displays;
return $this;
}
|
[
"public",
"function",
"setSupportedDisplays",
"(",
"array",
"$",
"displays",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$displays'",
",",
"$",
"displays",
",",
"'\\Authlete\\Types\\Display'",
")",
";",
"$",
"this",
"->",
"supportedDisplays",
"=",
"$",
"displays",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the values of the "display" request parameter supported by
this service.
This corresponds to the `display_values_supported` metadata defined in
[3. OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata)
of [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html).
@param Display[] $displays
Supported client authentication methods at the token endpoint.
@return Service
`$this` object.
|
[
"Set",
"the",
"values",
"of",
"the",
"display",
"request",
"parameter",
"supported",
"by",
"this",
"service",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L822-L830
|
227,609
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedClaimTypes
|
public function setSupportedClaimTypes(array $claimTypes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$claimTypes', $claimTypes, '\Authlete\Types\ClaimType');
$this->supportedClaimTypes = $claimTypes;
return $this;
}
|
php
|
public function setSupportedClaimTypes(array $claimTypes = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$claimTypes', $claimTypes, '\Authlete\Types\ClaimType');
$this->supportedClaimTypes = $claimTypes;
return $this;
}
|
[
"public",
"function",
"setSupportedClaimTypes",
"(",
"array",
"$",
"claimTypes",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$claimTypes'",
",",
"$",
"claimTypes",
",",
"'\\Authlete\\Types\\ClaimType'",
")",
";",
"$",
"this",
"->",
"supportedClaimTypes",
"=",
"$",
"claimTypes",
";",
"return",
"$",
"this",
";",
"}"
] |
Set claim types supported by this service.
This corresponds to the `claim_types_supported` metadata defined in
[3. OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata)
of [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html).
@param ClaimType[] $claimTypes
Supported claim types.
@return Service
`$this` object.
|
[
"Set",
"claim",
"types",
"supported",
"by",
"this",
"service",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L862-L870
|
227,610
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedClaims
|
public function setSupportedClaims(array $claims = null)
{
ValidationUtility::ensureNullOrArrayOfString('$claims', $claims);
$this->supportedClaims = $claims;
return $this;
}
|
php
|
public function setSupportedClaims(array $claims = null)
{
ValidationUtility::ensureNullOrArrayOfString('$claims', $claims);
$this->supportedClaims = $claims;
return $this;
}
|
[
"public",
"function",
"setSupportedClaims",
"(",
"array",
"$",
"claims",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfString",
"(",
"'$claims'",
",",
"$",
"claims",
")",
";",
"$",
"this",
"->",
"supportedClaims",
"=",
"$",
"claims",
";",
"return",
"$",
"this",
";",
"}"
] |
Set claims supported by this service.
This corresponds to the `claims_supported` metadata defined in
[3. OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata)
of [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html).
@param string[] $claims
Supported claims.
@return Service
`$this` object.
|
[
"Set",
"claims",
"supported",
"by",
"this",
"service",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L902-L909
|
227,611
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedClaimLocales
|
public function setSupportedClaimLocales(array $locales = null)
{
ValidationUtility::ensureNullOrArrayOfString('$locales', $locales);
$this->supportedClaimLocales = $locales;
return $this;
}
|
php
|
public function setSupportedClaimLocales(array $locales = null)
{
ValidationUtility::ensureNullOrArrayOfString('$locales', $locales);
$this->supportedClaimLocales = $locales;
return $this;
}
|
[
"public",
"function",
"setSupportedClaimLocales",
"(",
"array",
"$",
"locales",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfString",
"(",
"'$locales'",
",",
"$",
"locales",
")",
";",
"$",
"this",
"->",
"supportedClaimLocales",
"=",
"$",
"locales",
";",
"return",
"$",
"this",
";",
"}"
] |
Set language and scripts for claim values supported by this service.
This corresponds to the `claims_locales_supported` metadata defined in
[3. OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata)
of [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html).
@param string[] $locales
Supported language and scripts for claim values.
@return Service
`$this` object.
|
[
"Set",
"language",
"and",
"scripts",
"for",
"claim",
"values",
"supported",
"by",
"this",
"service",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L982-L989
|
227,612
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedUiLocales
|
public function setSupportedUiLocales(array $locales = null)
{
ValidationUtility::ensureNullOrArrayOfString('$locales', $locales);
$this->supportedUiLocales = $locales;
return $this;
}
|
php
|
public function setSupportedUiLocales(array $locales = null)
{
ValidationUtility::ensureNullOrArrayOfString('$locales', $locales);
$this->supportedUiLocales = $locales;
return $this;
}
|
[
"public",
"function",
"setSupportedUiLocales",
"(",
"array",
"$",
"locales",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfString",
"(",
"'$locales'",
",",
"$",
"locales",
")",
";",
"$",
"this",
"->",
"supportedUiLocales",
"=",
"$",
"locales",
";",
"return",
"$",
"this",
";",
"}"
] |
Set language and scripts for the user interface supported by this
service.
This corresponds to the `ui_locales_supported` metadata defined in
[3. OpenID Provider Metadata](https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata)
of [OpenID Connect Discovery 1.0](https://openid.net/specs/openid-connect-discovery-1_0.html).
@param string[] $locales
Supported language and scripts for the user interface.
@return Service
`$this` object.
|
[
"Set",
"language",
"and",
"scripts",
"for",
"the",
"user",
"interface",
"supported",
"by",
"this",
"service",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L1023-L1030
|
227,613
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedSnses
|
public function setSupportedSnses(array $snses = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$snses', $snses, '\Authlete\Types\Sns');
$this->supportedSnses = $snses;
return $this;
}
|
php
|
public function setSupportedSnses(array $snses = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$snses', $snses, '\Authlete\Types\Sns');
$this->supportedSnses = $snses;
return $this;
}
|
[
"public",
"function",
"setSupportedSnses",
"(",
"array",
"$",
"snses",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$snses'",
",",
"$",
"snses",
",",
"'\\Authlete\\Types\\Sns'",
")",
";",
"$",
"this",
"->",
"supportedSnses",
"=",
"$",
"snses",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the list of supported SNSes for social login at the direct
authorization endpoint.
@param Sns[] $snses
Supported SNSes for social login at the direct authorization
endpoint.
@return Service
`$this` object.
|
[
"Set",
"the",
"list",
"of",
"supported",
"SNSes",
"for",
"social",
"login",
"at",
"the",
"direct",
"authorization",
"endpoint",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L1456-L1464
|
227,614
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSnsCredentials
|
public function setSnsCredentials(array $credentials = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$credentials', $credentials, __NAMESPACE__ . '\SnsCredentials');
$this->snsCredentials = $credentials;
return $this;
}
|
php
|
public function setSnsCredentials(array $credentials = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$credentials', $credentials, __NAMESPACE__ . '\SnsCredentials');
$this->snsCredentials = $credentials;
return $this;
}
|
[
"public",
"function",
"setSnsCredentials",
"(",
"array",
"$",
"credentials",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$credentials'",
",",
"$",
"credentials",
",",
"__NAMESPACE__",
".",
"'\\SnsCredentials'",
")",
";",
"$",
"this",
"->",
"snsCredentials",
"=",
"$",
"credentials",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the list of SNS credentials used for social login.
@param SnsCredentials[] $credentials
The list of SNS credentials.
@return Service
`$this` object.
|
[
"Set",
"the",
"list",
"of",
"SNS",
"credentials",
"used",
"for",
"social",
"login",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L1488-L1496
|
227,615
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedDeveloperSnses
|
public function setSupportedDeveloperSnses(array $snses = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$snses', $snses, '\Authlete\Types\Sns');
$this->supportedDeveloperSnses = $snses;
return $this;
}
|
php
|
public function setSupportedDeveloperSnses(array $snses = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$snses', $snses, '\Authlete\Types\Sns');
$this->supportedDeveloperSnses = $snses;
return $this;
}
|
[
"public",
"function",
"setSupportedDeveloperSnses",
"(",
"array",
"$",
"snses",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$snses'",
",",
"$",
"snses",
",",
"'\\Authlete\\Types\\Sns'",
")",
";",
"$",
"this",
"->",
"supportedDeveloperSnses",
"=",
"$",
"snses",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the list of supported SNSes used for social login at the developer
console.
NOTE: This feature is not implemented yet.
@param Sns[] $snses
Supported SNSes for social login at the developer console.
@return Service
`$this` object.
|
[
"Set",
"the",
"list",
"of",
"supported",
"SNSes",
"used",
"for",
"social",
"login",
"at",
"the",
"developer",
"console",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L1693-L1701
|
227,616
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setDeveloperSnsCredentials
|
public function setDeveloperSnsCredentials(array $credentials = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$credentials', $credentials, __NAMESPACE__ . '\SnsCredentials');
$this->developerSnsCredentials = $credentials;
return $this;
}
|
php
|
public function setDeveloperSnsCredentials(array $credentials = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$credentials', $credentials, __NAMESPACE__ . '\SnsCredentials');
$this->developerSnsCredentials = $credentials;
return $this;
}
|
[
"public",
"function",
"setDeveloperSnsCredentials",
"(",
"array",
"$",
"credentials",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$credentials'",
",",
"$",
"credentials",
",",
"__NAMESPACE__",
".",
"'\\SnsCredentials'",
")",
";",
"$",
"this",
"->",
"developerSnsCredentials",
"=",
"$",
"credentials",
";",
"return",
"$",
"this",
";",
"}"
] |
Get the list of SNS credentials used for social login at the developer
console.
NOTE: This feature is not implemented yet.
@param SnsCredentials[] $credentials
The list of SNS credentials used for social login at the developer
console.
@return Service
`$this` object.
|
[
"Get",
"the",
"list",
"of",
"SNS",
"credentials",
"used",
"for",
"social",
"login",
"at",
"the",
"developer",
"console",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L1733-L1741
|
227,617
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedServiceProfiles
|
public function setSupportedServiceProfiles(array $serviceProfiles = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$serviceProfiles', $serviceProfiles, '\Authlete\Types\ServiceProfile');
$this->supportedServiceProfiles = $serviceProfiles;
return $this;
}
|
php
|
public function setSupportedServiceProfiles(array $serviceProfiles = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$serviceProfiles', $serviceProfiles, '\Authlete\Types\ServiceProfile');
$this->supportedServiceProfiles = $serviceProfiles;
return $this;
}
|
[
"public",
"function",
"setSupportedServiceProfiles",
"(",
"array",
"$",
"serviceProfiles",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$serviceProfiles'",
",",
"$",
"serviceProfiles",
",",
"'\\Authlete\\Types\\ServiceProfile'",
")",
";",
"$",
"this",
"->",
"supportedServiceProfiles",
"=",
"$",
"serviceProfiles",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the service profile supported by this service.
@param ServiceProfile[] $serviceProfiles
Supported service profiles.
@return Service
`$this` object.
|
[
"Set",
"the",
"service",
"profile",
"supported",
"by",
"this",
"service",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L2392-L2400
|
227,618
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setSupportedIntrospectionAuthMethods
|
public function setSupportedIntrospectionAuthMethods(array $methods = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$methods', $methods, '\Authlete\Types\ClientAuthMethod');
$this->supportedIntrospectionAuthMethods = $methods;
return $this;
}
|
php
|
public function setSupportedIntrospectionAuthMethods(array $methods = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$methods', $methods, '\Authlete\Types\ClientAuthMethod');
$this->supportedIntrospectionAuthMethods = $methods;
return $this;
}
|
[
"public",
"function",
"setSupportedIntrospectionAuthMethods",
"(",
"array",
"$",
"methods",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$methods'",
",",
"$",
"methods",
",",
"'\\Authlete\\Types\\ClientAuthMethod'",
")",
";",
"$",
"this",
"->",
"supportedIntrospectionAuthMethods",
"=",
"$",
"methods",
";",
"return",
"$",
"this",
";",
"}"
] |
Set client authentication methods at the introspection endpoint
supported by this service.
This corresponds to the `introspection_endpoint_auth_methods_supported`
metadata defined in "OAuth 2.0 Authorization Server Metadata".
@param ClientAuthMethod[] $methods
Supported client authentication methods at the introspection
endpoint.
@return Service
`$this` object.
|
[
"Set",
"client",
"authentication",
"methods",
"at",
"the",
"introspection",
"endpoint",
"supported",
"by",
"this",
"service",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L2555-L2563
|
227,619
|
authlete/authlete-php
|
src/Dto/Service.php
|
Service.setTrustedRootCertificates
|
public function setTrustedRootCertificates(array $certificates = null)
{
ValidationUtility::ensureNullOrArrayOfString('$certificates', $certificates);
$this->trustedRootCertificates = $certificates;
return $this;
}
|
php
|
public function setTrustedRootCertificates(array $certificates = null)
{
ValidationUtility::ensureNullOrArrayOfString('$certificates', $certificates);
$this->trustedRootCertificates = $certificates;
return $this;
}
|
[
"public",
"function",
"setTrustedRootCertificates",
"(",
"array",
"$",
"certificates",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfString",
"(",
"'$certificates'",
",",
"$",
"certificates",
")",
";",
"$",
"this",
"->",
"trustedRootCertificates",
"=",
"$",
"certificates",
";",
"return",
"$",
"this",
";",
"}"
] |
Set trusted root certificates.
If `isMutualTlsValidatePkiCertChain()` returns `true`, pre-registered
trusted root certificates are used to validate client certificates.
@param string[] $certificates
Trusted root certificates.
@return Service
`$this` object.
@since 1.3
|
[
"Set",
"trusted",
"root",
"certificates",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/Service.php#L2597-L2604
|
227,620
|
TimeToogo/RapidRoute
|
src/Router.php
|
Router.clearCompiled
|
public function clearCompiled()
{
if(file_exists($this->compiledRouterPath)) {
@unlink($this->compiledRouterPath);
}
$this->compiledRouter = null;
}
|
php
|
public function clearCompiled()
{
if(file_exists($this->compiledRouterPath)) {
@unlink($this->compiledRouterPath);
}
$this->compiledRouter = null;
}
|
[
"public",
"function",
"clearCompiled",
"(",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"compiledRouterPath",
")",
")",
"{",
"@",
"unlink",
"(",
"$",
"this",
"->",
"compiledRouterPath",
")",
";",
"}",
"$",
"this",
"->",
"compiledRouter",
"=",
"null",
";",
"}"
] |
Clears the compiled router, it will be recompiled when next requested.
@return void
|
[
"Clears",
"the",
"compiled",
"router",
"it",
"will",
"be",
"recompiled",
"when",
"next",
"requested",
"."
] |
5ef2c90a1ab5f02565c4a22bc0bf979c98f15292
|
https://github.com/TimeToogo/RapidRoute/blob/5ef2c90a1ab5f02565c4a22bc0bf979c98f15292/src/Router.php#L125-L132
|
227,621
|
Vinelab/api-manager
|
src/Vinelab/Api/Api.php
|
Api.readConfigFile
|
private function readConfigFile()
{
// reading the config file to be stored in the 'configurations' variable below
$configurations = $this->config_reader->get('api');
$this->mappers_base_namespace = $configurations['mappers'];
$this->limit = $configurations['limit'];
}
|
php
|
private function readConfigFile()
{
// reading the config file to be stored in the 'configurations' variable below
$configurations = $this->config_reader->get('api');
$this->mappers_base_namespace = $configurations['mappers'];
$this->limit = $configurations['limit'];
}
|
[
"private",
"function",
"readConfigFile",
"(",
")",
"{",
"// reading the config file to be stored in the 'configurations' variable below",
"$",
"configurations",
"=",
"$",
"this",
"->",
"config_reader",
"->",
"get",
"(",
"'api'",
")",
";",
"$",
"this",
"->",
"mappers_base_namespace",
"=",
"$",
"configurations",
"[",
"'mappers'",
"]",
";",
"$",
"this",
"->",
"limit",
"=",
"$",
"configurations",
"[",
"'limit'",
"]",
";",
"}"
] |
get config file values and store them in attributes.
|
[
"get",
"config",
"file",
"values",
"and",
"store",
"them",
"in",
"attributes",
"."
] |
c48576e47db9863fca4c634df1ff7558957c90f5
|
https://github.com/Vinelab/api-manager/blob/c48576e47db9863fca4c634df1ff7558957c90f5/src/Vinelab/Api/Api.php#L67-L73
|
227,622
|
Vinelab/api-manager
|
src/Vinelab/Api/Api.php
|
Api.respond
|
public function respond($mapper, $data)
{
$arguments = [];
// if data is instance of Paginator then get the values of the total and the page from the paginator,
// and add them to the arguments array (total, page)
if ($this->isPaginatorInstance($data)) {
$arguments[0] = $data->total();
$arguments[1] = $data->currentPage();
$arguments[2] = $data->perPage();
}
// skip the first 2 arguments and save the rest to the 'arguments array':
// > in case data is instance of Paginator then this will append all the arguments to the 'arguments array'
// starting by the third arguments which should be the 'status'.
// > in case data is is not instance of Paginator (means total and page and per_page are added manually as
// arguments) then this will add all the arguments to the 'arguments array' starting by the third arguments
// which should be the 'page'.
foreach (array_slice(func_get_args(), 2) as $arg) {
$arguments[count($arguments)] = $arg;
}
$result[] = $this->data($mapper, $data);
return call_user_func_array([$this->response_handler, 'respond'], array_merge($result, $arguments));
}
|
php
|
public function respond($mapper, $data)
{
$arguments = [];
// if data is instance of Paginator then get the values of the total and the page from the paginator,
// and add them to the arguments array (total, page)
if ($this->isPaginatorInstance($data)) {
$arguments[0] = $data->total();
$arguments[1] = $data->currentPage();
$arguments[2] = $data->perPage();
}
// skip the first 2 arguments and save the rest to the 'arguments array':
// > in case data is instance of Paginator then this will append all the arguments to the 'arguments array'
// starting by the third arguments which should be the 'status'.
// > in case data is is not instance of Paginator (means total and page and per_page are added manually as
// arguments) then this will add all the arguments to the 'arguments array' starting by the third arguments
// which should be the 'page'.
foreach (array_slice(func_get_args(), 2) as $arg) {
$arguments[count($arguments)] = $arg;
}
$result[] = $this->data($mapper, $data);
return call_user_func_array([$this->response_handler, 'respond'], array_merge($result, $arguments));
}
|
[
"public",
"function",
"respond",
"(",
"$",
"mapper",
",",
"$",
"data",
")",
"{",
"$",
"arguments",
"=",
"[",
"]",
";",
"// if data is instance of Paginator then get the values of the total and the page from the paginator,",
"// and add them to the arguments array (total, page)",
"if",
"(",
"$",
"this",
"->",
"isPaginatorInstance",
"(",
"$",
"data",
")",
")",
"{",
"$",
"arguments",
"[",
"0",
"]",
"=",
"$",
"data",
"->",
"total",
"(",
")",
";",
"$",
"arguments",
"[",
"1",
"]",
"=",
"$",
"data",
"->",
"currentPage",
"(",
")",
";",
"$",
"arguments",
"[",
"2",
"]",
"=",
"$",
"data",
"->",
"perPage",
"(",
")",
";",
"}",
"// skip the first 2 arguments and save the rest to the 'arguments array':",
"// > in case data is instance of Paginator then this will append all the arguments to the 'arguments array'",
"// starting by the third arguments which should be the 'status'.",
"// > in case data is is not instance of Paginator (means total and page and per_page are added manually as",
"// arguments) then this will add all the arguments to the 'arguments array' starting by the third arguments",
"// which should be the 'page'.",
"foreach",
"(",
"array_slice",
"(",
"func_get_args",
"(",
")",
",",
"2",
")",
"as",
"$",
"arg",
")",
"{",
"$",
"arguments",
"[",
"count",
"(",
"$",
"arguments",
")",
"]",
"=",
"$",
"arg",
";",
"}",
"$",
"result",
"[",
"]",
"=",
"$",
"this",
"->",
"data",
"(",
"$",
"mapper",
",",
"$",
"data",
")",
";",
"return",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"response_handler",
",",
"'respond'",
"]",
",",
"array_merge",
"(",
"$",
"result",
",",
"$",
"arguments",
")",
")",
";",
"}"
] |
Map and respond.
@param string|mixed $mapper
@param mixed $data
@throws ApiException
@return Illuminate\Http\JsonResponse
|
[
"Map",
"and",
"respond",
"."
] |
c48576e47db9863fca4c634df1ff7558957c90f5
|
https://github.com/Vinelab/api-manager/blob/c48576e47db9863fca4c634df1ff7558957c90f5/src/Vinelab/Api/Api.php#L85-L107
|
227,623
|
Vinelab/api-manager
|
src/Vinelab/Api/Api.php
|
Api.data
|
public function data($mapper, $data)
{
// we won't deal with empty data
if (is_array($data) && empty($data)
|| (($this->isPaginatorInstance($data)) && $data->isEmpty())
|| ($data instanceof Collection && $data->isEmpty())
) {
return [];
}
// First we check whether we've been passed an array in which case we consider the array to be ['mapper',
// 'method'] where 'mapper' can either be the mapper class name as a string or the actual instance.
$method = 'map';
if (is_array($mapper) && count($mapper) == 2) {
$instance = $mapper[0];
$method = $mapper[1];
$mapper = $instance;
}
// check whether $mapper is an actual mapper instance, otherwise
// resolve the mapper class name into a mapper instance.
if (!is_object($mapper)) {
$mapper = $this->resolveMapperClassName($mapper);
}
// In the case of a Collection or Paginator all we need is the data as a
// Traversable so that we iterate and map each item.
if ($data instanceof Collection) {
$data = $data->all();
} elseif ($this->isPaginatorInstance($data)) {
$data = $data->items();
}
// call the map function of the mapper for each data in the $data array
return (is_array($data) && !$this->isAssocArray($data)) ?
array_map([$mapper, $method], $data) : $mapper->$method($data);
}
|
php
|
public function data($mapper, $data)
{
// we won't deal with empty data
if (is_array($data) && empty($data)
|| (($this->isPaginatorInstance($data)) && $data->isEmpty())
|| ($data instanceof Collection && $data->isEmpty())
) {
return [];
}
// First we check whether we've been passed an array in which case we consider the array to be ['mapper',
// 'method'] where 'mapper' can either be the mapper class name as a string or the actual instance.
$method = 'map';
if (is_array($mapper) && count($mapper) == 2) {
$instance = $mapper[0];
$method = $mapper[1];
$mapper = $instance;
}
// check whether $mapper is an actual mapper instance, otherwise
// resolve the mapper class name into a mapper instance.
if (!is_object($mapper)) {
$mapper = $this->resolveMapperClassName($mapper);
}
// In the case of a Collection or Paginator all we need is the data as a
// Traversable so that we iterate and map each item.
if ($data instanceof Collection) {
$data = $data->all();
} elseif ($this->isPaginatorInstance($data)) {
$data = $data->items();
}
// call the map function of the mapper for each data in the $data array
return (is_array($data) && !$this->isAssocArray($data)) ?
array_map([$mapper, $method], $data) : $mapper->$method($data);
}
|
[
"public",
"function",
"data",
"(",
"$",
"mapper",
",",
"$",
"data",
")",
"{",
"// we won't deal with empty data",
"if",
"(",
"is_array",
"(",
"$",
"data",
")",
"&&",
"empty",
"(",
"$",
"data",
")",
"||",
"(",
"(",
"$",
"this",
"->",
"isPaginatorInstance",
"(",
"$",
"data",
")",
")",
"&&",
"$",
"data",
"->",
"isEmpty",
"(",
")",
")",
"||",
"(",
"$",
"data",
"instanceof",
"Collection",
"&&",
"$",
"data",
"->",
"isEmpty",
"(",
")",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"// First we check whether we've been passed an array in which case we consider the array to be ['mapper',",
"// 'method'] where 'mapper' can either be the mapper class name as a string or the actual instance.",
"$",
"method",
"=",
"'map'",
";",
"if",
"(",
"is_array",
"(",
"$",
"mapper",
")",
"&&",
"count",
"(",
"$",
"mapper",
")",
"==",
"2",
")",
"{",
"$",
"instance",
"=",
"$",
"mapper",
"[",
"0",
"]",
";",
"$",
"method",
"=",
"$",
"mapper",
"[",
"1",
"]",
";",
"$",
"mapper",
"=",
"$",
"instance",
";",
"}",
"// check whether $mapper is an actual mapper instance, otherwise",
"// resolve the mapper class name into a mapper instance.",
"if",
"(",
"!",
"is_object",
"(",
"$",
"mapper",
")",
")",
"{",
"$",
"mapper",
"=",
"$",
"this",
"->",
"resolveMapperClassName",
"(",
"$",
"mapper",
")",
";",
"}",
"// In the case of a Collection or Paginator all we need is the data as a",
"// Traversable so that we iterate and map each item.",
"if",
"(",
"$",
"data",
"instanceof",
"Collection",
")",
"{",
"$",
"data",
"=",
"$",
"data",
"->",
"all",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"isPaginatorInstance",
"(",
"$",
"data",
")",
")",
"{",
"$",
"data",
"=",
"$",
"data",
"->",
"items",
"(",
")",
";",
"}",
"// call the map function of the mapper for each data in the $data array",
"return",
"(",
"is_array",
"(",
"$",
"data",
")",
"&&",
"!",
"$",
"this",
"->",
"isAssocArray",
"(",
"$",
"data",
")",
")",
"?",
"array_map",
"(",
"[",
"$",
"mapper",
",",
"$",
"method",
"]",
",",
"$",
"data",
")",
":",
"$",
"mapper",
"->",
"$",
"method",
"(",
"$",
"data",
")",
";",
"}"
] |
Get the formatted data out of the given mapper and data.
@param string|mixed $mapper
@param mixed $data
@return array
|
[
"Get",
"the",
"formatted",
"data",
"out",
"of",
"the",
"given",
"mapper",
"and",
"data",
"."
] |
c48576e47db9863fca4c634df1ff7558957c90f5
|
https://github.com/Vinelab/api-manager/blob/c48576e47db9863fca4c634df1ff7558957c90f5/src/Vinelab/Api/Api.php#L129-L162
|
227,624
|
Vinelab/api-manager
|
src/Vinelab/Api/Api.php
|
Api.content
|
public function content($mapper, $data)
{
$response = call_user_func_array([$this, 'respond'], func_get_args());
return $response->getData(true);
}
|
php
|
public function content($mapper, $data)
{
$response = call_user_func_array([$this, 'respond'], func_get_args());
return $response->getData(true);
}
|
[
"public",
"function",
"content",
"(",
"$",
"mapper",
",",
"$",
"data",
")",
"{",
"$",
"response",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"'respond'",
"]",
",",
"func_get_args",
"(",
")",
")",
";",
"return",
"$",
"response",
"->",
"getData",
"(",
"true",
")",
";",
"}"
] |
Get the content only from the response.
@param mixed $mapper
@param mixed $data
@return array
|
[
"Get",
"the",
"content",
"only",
"from",
"the",
"response",
"."
] |
c48576e47db9863fca4c634df1ff7558957c90f5
|
https://github.com/Vinelab/api-manager/blob/c48576e47db9863fca4c634df1ff7558957c90f5/src/Vinelab/Api/Api.php#L206-L211
|
227,625
|
Vinelab/api-manager
|
src/Vinelab/Api/Api.php
|
Api.limit
|
public function limit()
{
// get limit from config file
$limit = $this->getMaximumLimit();
// get the limit from the request if available else get the the default predefined limit from the config file
if (Input::get('limit') && is_numeric(Input::get('limit'))) {
$limit = Input::get('limit');
}
// validate the limit does not exceed the allowed value
return $this->validateRequestedLimitValue($limit);
}
|
php
|
public function limit()
{
// get limit from config file
$limit = $this->getMaximumLimit();
// get the limit from the request if available else get the the default predefined limit from the config file
if (Input::get('limit') && is_numeric(Input::get('limit'))) {
$limit = Input::get('limit');
}
// validate the limit does not exceed the allowed value
return $this->validateRequestedLimitValue($limit);
}
|
[
"public",
"function",
"limit",
"(",
")",
"{",
"// get limit from config file",
"$",
"limit",
"=",
"$",
"this",
"->",
"getMaximumLimit",
"(",
")",
";",
"// get the limit from the request if available else get the the default predefined limit from the config file",
"if",
"(",
"Input",
"::",
"get",
"(",
"'limit'",
")",
"&&",
"is_numeric",
"(",
"Input",
"::",
"get",
"(",
"'limit'",
")",
")",
")",
"{",
"$",
"limit",
"=",
"Input",
"::",
"get",
"(",
"'limit'",
")",
";",
"}",
"// validate the limit does not exceed the allowed value",
"return",
"$",
"this",
"->",
"validateRequestedLimitValue",
"(",
"$",
"limit",
")",
";",
"}"
] |
this function will be accessed as facade from anywhere to get the limit number of data for the endpoint call.
@return int
|
[
"this",
"function",
"will",
"be",
"accessed",
"as",
"facade",
"from",
"anywhere",
"to",
"get",
"the",
"limit",
"number",
"of",
"data",
"for",
"the",
"endpoint",
"call",
"."
] |
c48576e47db9863fca4c634df1ff7558957c90f5
|
https://github.com/Vinelab/api-manager/blob/c48576e47db9863fca4c634df1ff7558957c90f5/src/Vinelab/Api/Api.php#L228-L239
|
227,626
|
jumilla/laravel-versionia
|
sources/Commands/DatabaseRollbackCommand.php
|
DatabaseRollbackCommand.doRollback
|
protected function doRollback(Migrator $migrator, $target_group, $target_version)
{
$installed_migrations = $migrator->installedMigrationsByDesc();
if (!isset($installed_migrations[$target_group])) {
$this->info("Nothing migrations for group '$target_group'.");
return;
}
foreach ($installed_migrations[$target_group] as $data) {
// check version
if ($migrator->compareMigrationVersion($data->version, $target_version) < 0) {
continue;
}
$this->infoDowngrade($target_group, $data->version, $data->class);
$migrator->doDowngrade($target_group, $data->version);
}
}
|
php
|
protected function doRollback(Migrator $migrator, $target_group, $target_version)
{
$installed_migrations = $migrator->installedMigrationsByDesc();
if (!isset($installed_migrations[$target_group])) {
$this->info("Nothing migrations for group '$target_group'.");
return;
}
foreach ($installed_migrations[$target_group] as $data) {
// check version
if ($migrator->compareMigrationVersion($data->version, $target_version) < 0) {
continue;
}
$this->infoDowngrade($target_group, $data->version, $data->class);
$migrator->doDowngrade($target_group, $data->version);
}
}
|
[
"protected",
"function",
"doRollback",
"(",
"Migrator",
"$",
"migrator",
",",
"$",
"target_group",
",",
"$",
"target_version",
")",
"{",
"$",
"installed_migrations",
"=",
"$",
"migrator",
"->",
"installedMigrationsByDesc",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"installed_migrations",
"[",
"$",
"target_group",
"]",
")",
")",
"{",
"$",
"this",
"->",
"info",
"(",
"\"Nothing migrations for group '$target_group'.\"",
")",
";",
"return",
";",
"}",
"foreach",
"(",
"$",
"installed_migrations",
"[",
"$",
"target_group",
"]",
"as",
"$",
"data",
")",
"{",
"// check version",
"if",
"(",
"$",
"migrator",
"->",
"compareMigrationVersion",
"(",
"$",
"data",
"->",
"version",
",",
"$",
"target_version",
")",
"<",
"0",
")",
"{",
"continue",
";",
"}",
"$",
"this",
"->",
"infoDowngrade",
"(",
"$",
"target_group",
",",
"$",
"data",
"->",
"version",
",",
"$",
"data",
"->",
"class",
")",
";",
"$",
"migrator",
"->",
"doDowngrade",
"(",
"$",
"target_group",
",",
"$",
"data",
"->",
"version",
")",
";",
"}",
"}"
] |
Execute rollback.
@param \Jumilla\Versionia\Laravel\Migrator $migrator
@param string $target_group
@param string $target_version
|
[
"Execute",
"rollback",
"."
] |
08ca0081c856c658d8b235c758c242b80b25da13
|
https://github.com/jumilla/laravel-versionia/blob/08ca0081c856c658d8b235c758c242b80b25da13/sources/Commands/DatabaseRollbackCommand.php#L67-L87
|
227,627
|
TimeToogo/RapidRoute
|
src/Compilation/VarExporter.php
|
VarExporter.export
|
public static function export($value)
{
if (is_array($value)) {
if(empty($value)) {
return '[]';
} elseif(count($value) === 1) {
reset($value);
return '[' . self::export(key($value)) . ' => ' . self::export(current($value)) . ']';
}
$code = '[' . PHP_EOL;
$indent = ' ';
foreach ($value as $key => $element) {
$code .= $indent;
$code .= self::export($key);
$code .= ' => ';
$code .= str_replace(PHP_EOL, PHP_EOL . $indent, self::export($element));
$code .= ',' . PHP_EOL;
}
$code .= ']';
return $code;
} elseif (is_object($value) && get_class($value) === 'stdClass') {
return '(object)' . self::export((array)$value);
}
if($value === null) {
return 'null';
}
if (is_scalar($value)) {
return var_export($value, true);
}
return 'unserialize(' . var_export(serialize($value), true) . ')';
}
|
php
|
public static function export($value)
{
if (is_array($value)) {
if(empty($value)) {
return '[]';
} elseif(count($value) === 1) {
reset($value);
return '[' . self::export(key($value)) . ' => ' . self::export(current($value)) . ']';
}
$code = '[' . PHP_EOL;
$indent = ' ';
foreach ($value as $key => $element) {
$code .= $indent;
$code .= self::export($key);
$code .= ' => ';
$code .= str_replace(PHP_EOL, PHP_EOL . $indent, self::export($element));
$code .= ',' . PHP_EOL;
}
$code .= ']';
return $code;
} elseif (is_object($value) && get_class($value) === 'stdClass') {
return '(object)' . self::export((array)$value);
}
if($value === null) {
return 'null';
}
if (is_scalar($value)) {
return var_export($value, true);
}
return 'unserialize(' . var_export(serialize($value), true) . ')';
}
|
[
"public",
"static",
"function",
"export",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"return",
"'[]'",
";",
"}",
"elseif",
"(",
"count",
"(",
"$",
"value",
")",
"===",
"1",
")",
"{",
"reset",
"(",
"$",
"value",
")",
";",
"return",
"'['",
".",
"self",
"::",
"export",
"(",
"key",
"(",
"$",
"value",
")",
")",
".",
"' => '",
".",
"self",
"::",
"export",
"(",
"current",
"(",
"$",
"value",
")",
")",
".",
"']'",
";",
"}",
"$",
"code",
"=",
"'['",
".",
"PHP_EOL",
";",
"$",
"indent",
"=",
"' '",
";",
"foreach",
"(",
"$",
"value",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"$",
"code",
".=",
"$",
"indent",
";",
"$",
"code",
".=",
"self",
"::",
"export",
"(",
"$",
"key",
")",
";",
"$",
"code",
".=",
"' => '",
";",
"$",
"code",
".=",
"str_replace",
"(",
"PHP_EOL",
",",
"PHP_EOL",
".",
"$",
"indent",
",",
"self",
"::",
"export",
"(",
"$",
"element",
")",
")",
";",
"$",
"code",
".=",
"','",
".",
"PHP_EOL",
";",
"}",
"$",
"code",
".=",
"']'",
";",
"return",
"$",
"code",
";",
"}",
"elseif",
"(",
"is_object",
"(",
"$",
"value",
")",
"&&",
"get_class",
"(",
"$",
"value",
")",
"===",
"'stdClass'",
")",
"{",
"return",
"'(object)'",
".",
"self",
"::",
"export",
"(",
"(",
"array",
")",
"$",
"value",
")",
";",
"}",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"'null'",
";",
"}",
"if",
"(",
"is_scalar",
"(",
"$",
"value",
")",
")",
"{",
"return",
"var_export",
"(",
"$",
"value",
",",
"true",
")",
";",
"}",
"return",
"'unserialize('",
".",
"var_export",
"(",
"serialize",
"(",
"$",
"value",
")",
",",
"true",
")",
".",
"')'",
";",
"}"
] |
Converts the supplied value into a valid PHP representation.
@param mixed $value
@return string
|
[
"Converts",
"the",
"supplied",
"value",
"into",
"a",
"valid",
"PHP",
"representation",
"."
] |
5ef2c90a1ab5f02565c4a22bc0bf979c98f15292
|
https://github.com/TimeToogo/RapidRoute/blob/5ef2c90a1ab5f02565c4a22bc0bf979c98f15292/src/Compilation/VarExporter.php#L20-L57
|
227,628
|
authlete/authlete-php
|
src/Dto/TokenRequest.php
|
TokenRequest.setClientCertificatePath
|
public function setClientCertificatePath(array $path = null)
{
ValidationUtility::ensureNullOrArrayOfString('$path', $path);
$this->clientCertificatePath = $path;
return $this;
}
|
php
|
public function setClientCertificatePath(array $path = null)
{
ValidationUtility::ensureNullOrArrayOfString('$path', $path);
$this->clientCertificatePath = $path;
return $this;
}
|
[
"public",
"function",
"setClientCertificatePath",
"(",
"array",
"$",
"path",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfString",
"(",
"'$path'",
",",
"$",
"path",
")",
";",
"$",
"this",
"->",
"clientCertificatePath",
"=",
"$",
"path",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the certificate path presented by the client during client
authentication.
@param string[] $path
Certificates in PEM format.
@return TokenRequest
`$this` object.
@since 1.3
|
[
"Set",
"the",
"certificate",
"path",
"presented",
"by",
"the",
"client",
"during",
"client",
"authentication",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/TokenRequest.php#L241-L248
|
227,629
|
TimeToogo/RapidRoute
|
src/Compilation/RouteTree/RouteTreeOptimizer.php
|
RouteTreeOptimizer.optimize
|
public function optimize(RouteTree $routeTree)
{
$segmentDepthNodeMap = $routeTree->getSegmentDepthNodesMap();
foreach ($segmentDepthNodeMap as $segmentDepth => $nodes) {
$segmentDepthNodeMap[$segmentDepth] = $this->optimizeNodes($nodes);
}
return new RouteTree($routeTree->getRootRouteData(), $segmentDepthNodeMap);
}
|
php
|
public function optimize(RouteTree $routeTree)
{
$segmentDepthNodeMap = $routeTree->getSegmentDepthNodesMap();
foreach ($segmentDepthNodeMap as $segmentDepth => $nodes) {
$segmentDepthNodeMap[$segmentDepth] = $this->optimizeNodes($nodes);
}
return new RouteTree($routeTree->getRootRouteData(), $segmentDepthNodeMap);
}
|
[
"public",
"function",
"optimize",
"(",
"RouteTree",
"$",
"routeTree",
")",
"{",
"$",
"segmentDepthNodeMap",
"=",
"$",
"routeTree",
"->",
"getSegmentDepthNodesMap",
"(",
")",
";",
"foreach",
"(",
"$",
"segmentDepthNodeMap",
"as",
"$",
"segmentDepth",
"=>",
"$",
"nodes",
")",
"{",
"$",
"segmentDepthNodeMap",
"[",
"$",
"segmentDepth",
"]",
"=",
"$",
"this",
"->",
"optimizeNodes",
"(",
"$",
"nodes",
")",
";",
"}",
"return",
"new",
"RouteTree",
"(",
"$",
"routeTree",
"->",
"getRootRouteData",
"(",
")",
",",
"$",
"segmentDepthNodeMap",
")",
";",
"}"
] |
Optimizes the supplied route tree
@param RouteTree $routeTree
@return RouteTree
|
[
"Optimizes",
"the",
"supplied",
"route",
"tree"
] |
5ef2c90a1ab5f02565c4a22bc0bf979c98f15292
|
https://github.com/TimeToogo/RapidRoute/blob/5ef2c90a1ab5f02565c4a22bc0bf979c98f15292/src/Compilation/RouteTree/RouteTreeOptimizer.php#L28-L37
|
227,630
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Identifier.php
|
Identifier.identify
|
public static function identify($str)
{
$minAr = 55436;
$maxAr = 55698;
$probAr = false;
$arFlag = false;
$arRef = array();
$max = strlen($str);
$i = -1;
while (++$i < $max) {
$cDec = ord($str[$i]);
// ignore ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 :
// If it come in the Arabic context
if ($cDec >= 33 && $cDec <= 58) {
continue;
}
if (!$probAr && ($cDec == 216 || $cDec == 217)) {
$probAr = true;
continue;
}
if ($i > 0) {
$pDec = ord($str[$i - 1]);
} else {
$pDec = null;
}
if ($probAr) {
$utfDecCode = ($pDec << 8) + $cDec;
if ($utfDecCode >= $minAr && $utfDecCode <= $maxAr) {
if (!$arFlag) {
$arFlag = true;
$arRef[] = $i - 1;
}
} else {
if ($arFlag) {
$arFlag = false;
$arRef[] = $i - 1;
}
}
$probAr = false;
continue;
}
if ($arFlag && !preg_match("/^\s$/", $str[$i])) {
$arFlag = false;
$arRef[] = $i;
}
}
return $arRef;
}
|
php
|
public static function identify($str)
{
$minAr = 55436;
$maxAr = 55698;
$probAr = false;
$arFlag = false;
$arRef = array();
$max = strlen($str);
$i = -1;
while (++$i < $max) {
$cDec = ord($str[$i]);
// ignore ! " # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 :
// If it come in the Arabic context
if ($cDec >= 33 && $cDec <= 58) {
continue;
}
if (!$probAr && ($cDec == 216 || $cDec == 217)) {
$probAr = true;
continue;
}
if ($i > 0) {
$pDec = ord($str[$i - 1]);
} else {
$pDec = null;
}
if ($probAr) {
$utfDecCode = ($pDec << 8) + $cDec;
if ($utfDecCode >= $minAr && $utfDecCode <= $maxAr) {
if (!$arFlag) {
$arFlag = true;
$arRef[] = $i - 1;
}
} else {
if ($arFlag) {
$arFlag = false;
$arRef[] = $i - 1;
}
}
$probAr = false;
continue;
}
if ($arFlag && !preg_match("/^\s$/", $str[$i])) {
$arFlag = false;
$arRef[] = $i;
}
}
return $arRef;
}
|
[
"public",
"static",
"function",
"identify",
"(",
"$",
"str",
")",
"{",
"$",
"minAr",
"=",
"55436",
";",
"$",
"maxAr",
"=",
"55698",
";",
"$",
"probAr",
"=",
"false",
";",
"$",
"arFlag",
"=",
"false",
";",
"$",
"arRef",
"=",
"array",
"(",
")",
";",
"$",
"max",
"=",
"strlen",
"(",
"$",
"str",
")",
";",
"$",
"i",
"=",
"-",
"1",
";",
"while",
"(",
"++",
"$",
"i",
"<",
"$",
"max",
")",
"{",
"$",
"cDec",
"=",
"ord",
"(",
"$",
"str",
"[",
"$",
"i",
"]",
")",
";",
"// ignore ! \" # $ % & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 :",
"// If it come in the Arabic context ",
"if",
"(",
"$",
"cDec",
">=",
"33",
"&&",
"$",
"cDec",
"<=",
"58",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"$",
"probAr",
"&&",
"(",
"$",
"cDec",
"==",
"216",
"||",
"$",
"cDec",
"==",
"217",
")",
")",
"{",
"$",
"probAr",
"=",
"true",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"i",
">",
"0",
")",
"{",
"$",
"pDec",
"=",
"ord",
"(",
"$",
"str",
"[",
"$",
"i",
"-",
"1",
"]",
")",
";",
"}",
"else",
"{",
"$",
"pDec",
"=",
"null",
";",
"}",
"if",
"(",
"$",
"probAr",
")",
"{",
"$",
"utfDecCode",
"=",
"(",
"$",
"pDec",
"<<",
"8",
")",
"+",
"$",
"cDec",
";",
"if",
"(",
"$",
"utfDecCode",
">=",
"$",
"minAr",
"&&",
"$",
"utfDecCode",
"<=",
"$",
"maxAr",
")",
"{",
"if",
"(",
"!",
"$",
"arFlag",
")",
"{",
"$",
"arFlag",
"=",
"true",
";",
"$",
"arRef",
"[",
"]",
"=",
"$",
"i",
"-",
"1",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"arFlag",
")",
"{",
"$",
"arFlag",
"=",
"false",
";",
"$",
"arRef",
"[",
"]",
"=",
"$",
"i",
"-",
"1",
";",
"}",
"}",
"$",
"probAr",
"=",
"false",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"arFlag",
"&&",
"!",
"preg_match",
"(",
"\"/^\\s$/\"",
",",
"$",
"str",
"[",
"$",
"i",
"]",
")",
")",
"{",
"$",
"arFlag",
"=",
"false",
";",
"$",
"arRef",
"[",
"]",
"=",
"$",
"i",
";",
"}",
"}",
"return",
"$",
"arRef",
";",
"}"
] |
Identify Arabic text in a given UTF-8 multi language string
@param string $str UTF-8 multi language string
@return array Offset of the beginning and end of each Arabic segment in
sequence in the given UTF-8 multi language string
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Identify",
"Arabic",
"text",
"in",
"a",
"given",
"UTF",
"-",
"8",
"multi",
"language",
"string"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Identifier.php#L124-L180
|
227,631
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Identifier.php
|
Identifier.isArabic
|
public static function isArabic($str)
{
$isArabic = false;
$arr = self::identify($str);
if (count($arr) == 1 && $arr[0] == 0) {
$isArabic = true;
}
return $isArabic;
}
|
php
|
public static function isArabic($str)
{
$isArabic = false;
$arr = self::identify($str);
if (count($arr) == 1 && $arr[0] == 0) {
$isArabic = true;
}
return $isArabic;
}
|
[
"public",
"static",
"function",
"isArabic",
"(",
"$",
"str",
")",
"{",
"$",
"isArabic",
"=",
"false",
";",
"$",
"arr",
"=",
"self",
"::",
"identify",
"(",
"$",
"str",
")",
";",
"if",
"(",
"count",
"(",
"$",
"arr",
")",
"==",
"1",
"&&",
"$",
"arr",
"[",
"0",
"]",
"==",
"0",
")",
"{",
"$",
"isArabic",
"=",
"true",
";",
"}",
"return",
"$",
"isArabic",
";",
"}"
] |
Find out if given string is Arabic text or not
@param string $str String
@return boolean True if given string is UTF-8 Arabic, else will return False
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Find",
"out",
"if",
"given",
"string",
"is",
"Arabic",
"text",
"or",
"not"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Identifier.php#L190-L200
|
227,632
|
slince/smartqq
|
src/Credential.php
|
Credential.fromArray
|
public static function fromArray(array $data)
{
$cookieJar = null;
if (isset($data['cookies'])) {
$cookieJar = new CookieJar();
foreach ($data['cookies'] as $cookie) {
$cookieJar->setCookie(new SetCookie($cookie));
}
}
return new static($data['ptWebQQ'], $data['vfWebQQ'],
$data['pSessionId'], $data['uin'], $data['clientId'],
$cookieJar
);
}
|
php
|
public static function fromArray(array $data)
{
$cookieJar = null;
if (isset($data['cookies'])) {
$cookieJar = new CookieJar();
foreach ($data['cookies'] as $cookie) {
$cookieJar->setCookie(new SetCookie($cookie));
}
}
return new static($data['ptWebQQ'], $data['vfWebQQ'],
$data['pSessionId'], $data['uin'], $data['clientId'],
$cookieJar
);
}
|
[
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"cookieJar",
"=",
"null",
";",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'cookies'",
"]",
")",
")",
"{",
"$",
"cookieJar",
"=",
"new",
"CookieJar",
"(",
")",
";",
"foreach",
"(",
"$",
"data",
"[",
"'cookies'",
"]",
"as",
"$",
"cookie",
")",
"{",
"$",
"cookieJar",
"->",
"setCookie",
"(",
"new",
"SetCookie",
"(",
"$",
"cookie",
")",
")",
";",
"}",
"}",
"return",
"new",
"static",
"(",
"$",
"data",
"[",
"'ptWebQQ'",
"]",
",",
"$",
"data",
"[",
"'vfWebQQ'",
"]",
",",
"$",
"data",
"[",
"'pSessionId'",
"]",
",",
"$",
"data",
"[",
"'uin'",
"]",
",",
"$",
"data",
"[",
"'clientId'",
"]",
",",
"$",
"cookieJar",
")",
";",
"}"
] |
Create from a array data.
@param array $data
@return static
|
[
"Create",
"from",
"a",
"array",
"data",
"."
] |
06ad056d47f2324f81e7118b47cc492529325252
|
https://github.com/slince/smartqq/blob/06ad056d47f2324f81e7118b47cc492529325252/src/Credential.php#L189-L203
|
227,633
|
JimmDiGrizli/phalcon-bootstrap
|
src/Bootstrap.php
|
Bootstrap.run
|
public function run($hide = false)
{
$this->boot();
$this->initNamespace();
$this->initModules();
$this->initServices();
if ($hide === false) {
return $this->handle()->getContent();
} else {
return 'true';
}
}
|
php
|
public function run($hide = false)
{
$this->boot();
$this->initNamespace();
$this->initModules();
$this->initServices();
if ($hide === false) {
return $this->handle()->getContent();
} else {
return 'true';
}
}
|
[
"public",
"function",
"run",
"(",
"$",
"hide",
"=",
"false",
")",
"{",
"$",
"this",
"->",
"boot",
"(",
")",
";",
"$",
"this",
"->",
"initNamespace",
"(",
")",
";",
"$",
"this",
"->",
"initModules",
"(",
")",
";",
"$",
"this",
"->",
"initServices",
"(",
")",
";",
"if",
"(",
"$",
"hide",
"===",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"handle",
"(",
")",
"->",
"getContent",
"(",
")",
";",
"}",
"else",
"{",
"return",
"'true'",
";",
"}",
"}"
] |
Running the application
@param bool $hide
@return string
|
[
"Running",
"the",
"application"
] |
e165150644e908f62c20a12539d380152dd74232
|
https://github.com/JimmDiGrizli/phalcon-bootstrap/blob/e165150644e908f62c20a12539d380152dd74232/src/Bootstrap.php#L80-L91
|
227,634
|
JimmDiGrizli/phalcon-bootstrap
|
src/Bootstrap.php
|
Bootstrap.boot
|
protected function boot()
{
$configLoader = new ConfigLoader($this->environment);
$this->di->setShared('config-loader', $configLoader);
$id = Bootstrap::CONFIG . '_' . $this->name . '_' . $this->environment;
$cache = null;
if ($this->cacheable === true) {
$cache = apc_fetch($id);
}
if ($cache === false || $cache === null) {
$this->config = $configLoader->create($this->pathConfig);
$this->config->merge(
new Config(['environment' => $this->environment])
);
if ($cache === false) {
apc_add($id, $this->config);
}
} else {
$this->config = $cache;
}
}
|
php
|
protected function boot()
{
$configLoader = new ConfigLoader($this->environment);
$this->di->setShared('config-loader', $configLoader);
$id = Bootstrap::CONFIG . '_' . $this->name . '_' . $this->environment;
$cache = null;
if ($this->cacheable === true) {
$cache = apc_fetch($id);
}
if ($cache === false || $cache === null) {
$this->config = $configLoader->create($this->pathConfig);
$this->config->merge(
new Config(['environment' => $this->environment])
);
if ($cache === false) {
apc_add($id, $this->config);
}
} else {
$this->config = $cache;
}
}
|
[
"protected",
"function",
"boot",
"(",
")",
"{",
"$",
"configLoader",
"=",
"new",
"ConfigLoader",
"(",
"$",
"this",
"->",
"environment",
")",
";",
"$",
"this",
"->",
"di",
"->",
"setShared",
"(",
"'config-loader'",
",",
"$",
"configLoader",
")",
";",
"$",
"id",
"=",
"Bootstrap",
"::",
"CONFIG",
".",
"'_'",
".",
"$",
"this",
"->",
"name",
".",
"'_'",
".",
"$",
"this",
"->",
"environment",
";",
"$",
"cache",
"=",
"null",
";",
"if",
"(",
"$",
"this",
"->",
"cacheable",
"===",
"true",
")",
"{",
"$",
"cache",
"=",
"apc_fetch",
"(",
"$",
"id",
")",
";",
"}",
"if",
"(",
"$",
"cache",
"===",
"false",
"||",
"$",
"cache",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"config",
"=",
"$",
"configLoader",
"->",
"create",
"(",
"$",
"this",
"->",
"pathConfig",
")",
";",
"$",
"this",
"->",
"config",
"->",
"merge",
"(",
"new",
"Config",
"(",
"[",
"'environment'",
"=>",
"$",
"this",
"->",
"environment",
"]",
")",
")",
";",
"if",
"(",
"$",
"cache",
"===",
"false",
")",
"{",
"apc_add",
"(",
"$",
"id",
",",
"$",
"this",
"->",
"config",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"config",
"=",
"$",
"cache",
";",
"}",
"}"
] |
Loads the settings option and a list of services for the application
|
[
"Loads",
"the",
"settings",
"option",
"and",
"a",
"list",
"of",
"services",
"for",
"the",
"application"
] |
e165150644e908f62c20a12539d380152dd74232
|
https://github.com/JimmDiGrizli/phalcon-bootstrap/blob/e165150644e908f62c20a12539d380152dd74232/src/Bootstrap.php#L96-L118
|
227,635
|
JimmDiGrizli/phalcon-bootstrap
|
src/Bootstrap.php
|
Bootstrap.initNamespace
|
protected function initNamespace()
{
$namespaces = $this->config->get('namespaces', null);
if ($namespaces !== null) {
foreach ($namespaces as $namespace => $path) {
$this->loader->registerNamespaces([$namespace => $path], true);
}
$this->loader->register();
$this->di->set('loader', $this->loader);
}
}
|
php
|
protected function initNamespace()
{
$namespaces = $this->config->get('namespaces', null);
if ($namespaces !== null) {
foreach ($namespaces as $namespace => $path) {
$this->loader->registerNamespaces([$namespace => $path], true);
}
$this->loader->register();
$this->di->set('loader', $this->loader);
}
}
|
[
"protected",
"function",
"initNamespace",
"(",
")",
"{",
"$",
"namespaces",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'namespaces'",
",",
"null",
")",
";",
"if",
"(",
"$",
"namespaces",
"!==",
"null",
")",
"{",
"foreach",
"(",
"$",
"namespaces",
"as",
"$",
"namespace",
"=>",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"loader",
"->",
"registerNamespaces",
"(",
"[",
"$",
"namespace",
"=>",
"$",
"path",
"]",
",",
"true",
")",
";",
"}",
"$",
"this",
"->",
"loader",
"->",
"register",
"(",
")",
";",
"$",
"this",
"->",
"di",
"->",
"set",
"(",
"'loader'",
",",
"$",
"this",
"->",
"loader",
")",
";",
"}",
"}"
] |
Initializing namespace of application
|
[
"Initializing",
"namespace",
"of",
"application"
] |
e165150644e908f62c20a12539d380152dd74232
|
https://github.com/JimmDiGrizli/phalcon-bootstrap/blob/e165150644e908f62c20a12539d380152dd74232/src/Bootstrap.php#L190-L201
|
227,636
|
JimmDiGrizli/phalcon-bootstrap
|
src/Bootstrap.php
|
Bootstrap.initServices
|
protected function initServices()
{
$dependencies = $this->config->get('dependencies', null);
$this->getDI()->setShared('registrant', new Registrant($dependencies));
$this->getDI()->setShared('config', $this->config);
$this->getDI()->get('registrant')->registration();
}
|
php
|
protected function initServices()
{
$dependencies = $this->config->get('dependencies', null);
$this->getDI()->setShared('registrant', new Registrant($dependencies));
$this->getDI()->setShared('config', $this->config);
$this->getDI()->get('registrant')->registration();
}
|
[
"protected",
"function",
"initServices",
"(",
")",
"{",
"$",
"dependencies",
"=",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'dependencies'",
",",
"null",
")",
";",
"$",
"this",
"->",
"getDI",
"(",
")",
"->",
"setShared",
"(",
"'registrant'",
",",
"new",
"Registrant",
"(",
"$",
"dependencies",
")",
")",
";",
"$",
"this",
"->",
"getDI",
"(",
")",
"->",
"setShared",
"(",
"'config'",
",",
"$",
"this",
"->",
"config",
")",
";",
"$",
"this",
"->",
"getDI",
"(",
")",
"->",
"get",
"(",
"'registrant'",
")",
"->",
"registration",
"(",
")",
";",
"}"
] |
Initializing services in dependency injection
|
[
"Initializing",
"services",
"in",
"dependency",
"injection"
] |
e165150644e908f62c20a12539d380152dd74232
|
https://github.com/JimmDiGrizli/phalcon-bootstrap/blob/e165150644e908f62c20a12539d380152dd74232/src/Bootstrap.php#L206-L212
|
227,637
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Color.getChroma
|
public function getChroma() {
$r = ($this->rgb >> 16) & 0xff;
$g = ($this->rgb >> 8) & 0xff;
$b = $this->rgb & 0xff;
return (max($r, $g, $b) - min($r, $g, $b)) / 255;
}
|
php
|
public function getChroma() {
$r = ($this->rgb >> 16) & 0xff;
$g = ($this->rgb >> 8) & 0xff;
$b = $this->rgb & 0xff;
return (max($r, $g, $b) - min($r, $g, $b)) / 255;
}
|
[
"public",
"function",
"getChroma",
"(",
")",
"{",
"$",
"r",
"=",
"(",
"$",
"this",
"->",
"rgb",
">>",
"16",
")",
"&",
"0xff",
";",
"$",
"g",
"=",
"(",
"$",
"this",
"->",
"rgb",
">>",
"8",
")",
"&",
"0xff",
";",
"$",
"b",
"=",
"$",
"this",
"->",
"rgb",
"&",
"0xff",
";",
"return",
"(",
"max",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
"-",
"min",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
")",
"/",
"255",
";",
"}"
] |
Returns color chroma.
@return float
|
[
"Returns",
"color",
"chroma",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L265-L270
|
227,638
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Color.getHue
|
public function getHue() {
$rgb = $this->rgb;
$r = (($rgb >> 16) & 0xff) / 255;
$g = (($rgb >> 8) & 0xff) / 255;
$b = ($rgb & 0xff) / 255;
$hue = rad2deg(atan2(1.7320508075688 /* = sqrt(3) */ * ($g - $b), 2 * $r - $g - $b));
return $hue >= 0 ? $hue : 360 + $hue;
}
|
php
|
public function getHue() {
$rgb = $this->rgb;
$r = (($rgb >> 16) & 0xff) / 255;
$g = (($rgb >> 8) & 0xff) / 255;
$b = ($rgb & 0xff) / 255;
$hue = rad2deg(atan2(1.7320508075688 /* = sqrt(3) */ * ($g - $b), 2 * $r - $g - $b));
return $hue >= 0 ? $hue : 360 + $hue;
}
|
[
"public",
"function",
"getHue",
"(",
")",
"{",
"$",
"rgb",
"=",
"$",
"this",
"->",
"rgb",
";",
"$",
"r",
"=",
"(",
"(",
"$",
"rgb",
">>",
"16",
")",
"&",
"0xff",
")",
"/",
"255",
";",
"$",
"g",
"=",
"(",
"(",
"$",
"rgb",
">>",
"8",
")",
"&",
"0xff",
")",
"/",
"255",
";",
"$",
"b",
"=",
"(",
"$",
"rgb",
"&",
"0xff",
")",
"/",
"255",
";",
"$",
"hue",
"=",
"rad2deg",
"(",
"atan2",
"(",
"1.7320508075688",
"/* = sqrt(3) */",
"*",
"(",
"$",
"g",
"-",
"$",
"b",
")",
",",
"2",
"*",
"$",
"r",
"-",
"$",
"g",
"-",
"$",
"b",
")",
")",
";",
"return",
"$",
"hue",
">=",
"0",
"?",
"$",
"hue",
":",
"360",
"+",
"$",
"hue",
";",
"}"
] |
Returns color hue.
@return int Value in degrees (0 => 360).
|
[
"Returns",
"color",
"hue",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L276-L283
|
227,639
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Color.getSaturation
|
public function getSaturation($colorMode = self::HSL) {
$r = (($this->rgb >> 16) & 0xff) / 255;
$g = (($this->rgb >> 8) & 0xff) / 255;
$b = ($this->rgb & 0xff) / 255;
$max = max($r, $g, $b);
$min = min($r, $g, $b);
if($max === 0) {
return 0;
}
if($colorMode === self::HSL) {
$diff = $max - $min;
//$luminance = ($max + $min) / 2;
if($diff < 0.5) {
return $diff / ($max + $min);
} else {
return $diff / (2 - $max - $min);
}
} else if($colorMode === self::HSV) {
return ($max - $min) / $max;
} else if($colorMode === self::HSI) {
if($max - $min === 0) {
return 0;
} else {
return 1 - $min / (($r + $g + $b) / 3);
}
}
throw new Exception('Unknown color mode');
}
|
php
|
public function getSaturation($colorMode = self::HSL) {
$r = (($this->rgb >> 16) & 0xff) / 255;
$g = (($this->rgb >> 8) & 0xff) / 255;
$b = ($this->rgb & 0xff) / 255;
$max = max($r, $g, $b);
$min = min($r, $g, $b);
if($max === 0) {
return 0;
}
if($colorMode === self::HSL) {
$diff = $max - $min;
//$luminance = ($max + $min) / 2;
if($diff < 0.5) {
return $diff / ($max + $min);
} else {
return $diff / (2 - $max - $min);
}
} else if($colorMode === self::HSV) {
return ($max - $min) / $max;
} else if($colorMode === self::HSI) {
if($max - $min === 0) {
return 0;
} else {
return 1 - $min / (($r + $g + $b) / 3);
}
}
throw new Exception('Unknown color mode');
}
|
[
"public",
"function",
"getSaturation",
"(",
"$",
"colorMode",
"=",
"self",
"::",
"HSL",
")",
"{",
"$",
"r",
"=",
"(",
"(",
"$",
"this",
"->",
"rgb",
">>",
"16",
")",
"&",
"0xff",
")",
"/",
"255",
";",
"$",
"g",
"=",
"(",
"(",
"$",
"this",
"->",
"rgb",
">>",
"8",
")",
"&",
"0xff",
")",
"/",
"255",
";",
"$",
"b",
"=",
"(",
"$",
"this",
"->",
"rgb",
"&",
"0xff",
")",
"/",
"255",
";",
"$",
"max",
"=",
"max",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"$",
"min",
"=",
"min",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"if",
"(",
"$",
"max",
"===",
"0",
")",
"{",
"return",
"0",
";",
"}",
"if",
"(",
"$",
"colorMode",
"===",
"self",
"::",
"HSL",
")",
"{",
"$",
"diff",
"=",
"$",
"max",
"-",
"$",
"min",
";",
"//$luminance = ($max + $min) / 2;\r",
"if",
"(",
"$",
"diff",
"<",
"0.5",
")",
"{",
"return",
"$",
"diff",
"/",
"(",
"$",
"max",
"+",
"$",
"min",
")",
";",
"}",
"else",
"{",
"return",
"$",
"diff",
"/",
"(",
"2",
"-",
"$",
"max",
"-",
"$",
"min",
")",
";",
"}",
"}",
"else",
"if",
"(",
"$",
"colorMode",
"===",
"self",
"::",
"HSV",
")",
"{",
"return",
"(",
"$",
"max",
"-",
"$",
"min",
")",
"/",
"$",
"max",
";",
"}",
"else",
"if",
"(",
"$",
"colorMode",
"===",
"self",
"::",
"HSI",
")",
"{",
"if",
"(",
"$",
"max",
"-",
"$",
"min",
"===",
"0",
")",
"{",
"return",
"0",
";",
"}",
"else",
"{",
"return",
"1",
"-",
"$",
"min",
"/",
"(",
"(",
"$",
"r",
"+",
"$",
"g",
"+",
"$",
"b",
")",
"/",
"3",
")",
";",
"}",
"}",
"throw",
"new",
"Exception",
"(",
"'Unknown color mode'",
")",
";",
"}"
] |
Returns color saturation.
@param int $colorMode Color mode for saturation (use Color::HSV, Color::HSI or Color::HSL as the value), default is Color::HSL
@return float
|
[
"Returns",
"color",
"saturation",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L291-L319
|
227,640
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Color.getLuminance
|
public function getLuminance($mode = self::HSL) {
$r = ($this->rgb >> 16) & 0xff;
$g = ($this->rgb >> 8) & 0xff;
$b = $this->rgb & 0xff;
switch ($mode) {
case 0:
// fastest, but less accurate.
return (($r + $r + $r + $b + $g + $g + $g + $g) >> 3) / 255;
break;
case 1:
// Digital CCIR601
return (int)(0.299 * $r + 0.587 * $g + 0.114 * $b) / 255;
break;
case 2:
// Ditigal ITU-R
return (int)(0.2126 * $r + 0.7152 * $g + 0.0722 * $b) / 255;
break;
case 3:
// HSP algorithm
return round(sqrt(0.299 * $r * $r + 0.587 * $g * $g + 0.114 * $b * $b)) / 255;
break;
case self::HSL:
// HSL algorithm
return (max($r, $g, $b) + min($r, $g, $b)) / (2 * 255);
break;
case self::HSV:
// HSV algorithm
return max($r, $g, $b) / 255;
break;
case self::HSI:
// HSI algorithm
return ($r + $g + $b) / (3 * 255);
break;
default:
throw new Exception('Unknown color mode');
break;
}
}
|
php
|
public function getLuminance($mode = self::HSL) {
$r = ($this->rgb >> 16) & 0xff;
$g = ($this->rgb >> 8) & 0xff;
$b = $this->rgb & 0xff;
switch ($mode) {
case 0:
// fastest, but less accurate.
return (($r + $r + $r + $b + $g + $g + $g + $g) >> 3) / 255;
break;
case 1:
// Digital CCIR601
return (int)(0.299 * $r + 0.587 * $g + 0.114 * $b) / 255;
break;
case 2:
// Ditigal ITU-R
return (int)(0.2126 * $r + 0.7152 * $g + 0.0722 * $b) / 255;
break;
case 3:
// HSP algorithm
return round(sqrt(0.299 * $r * $r + 0.587 * $g * $g + 0.114 * $b * $b)) / 255;
break;
case self::HSL:
// HSL algorithm
return (max($r, $g, $b) + min($r, $g, $b)) / (2 * 255);
break;
case self::HSV:
// HSV algorithm
return max($r, $g, $b) / 255;
break;
case self::HSI:
// HSI algorithm
return ($r + $g + $b) / (3 * 255);
break;
default:
throw new Exception('Unknown color mode');
break;
}
}
|
[
"public",
"function",
"getLuminance",
"(",
"$",
"mode",
"=",
"self",
"::",
"HSL",
")",
"{",
"$",
"r",
"=",
"(",
"$",
"this",
"->",
"rgb",
">>",
"16",
")",
"&",
"0xff",
";",
"$",
"g",
"=",
"(",
"$",
"this",
"->",
"rgb",
">>",
"8",
")",
"&",
"0xff",
";",
"$",
"b",
"=",
"$",
"this",
"->",
"rgb",
"&",
"0xff",
";",
"switch",
"(",
"$",
"mode",
")",
"{",
"case",
"0",
":",
"// fastest, but less accurate.\r",
"return",
"(",
"(",
"$",
"r",
"+",
"$",
"r",
"+",
"$",
"r",
"+",
"$",
"b",
"+",
"$",
"g",
"+",
"$",
"g",
"+",
"$",
"g",
"+",
"$",
"g",
")",
">>",
"3",
")",
"/",
"255",
";",
"break",
";",
"case",
"1",
":",
"// Digital CCIR601\r",
"return",
"(",
"int",
")",
"(",
"0.299",
"*",
"$",
"r",
"+",
"0.587",
"*",
"$",
"g",
"+",
"0.114",
"*",
"$",
"b",
")",
"/",
"255",
";",
"break",
";",
"case",
"2",
":",
"// Ditigal ITU-R\r",
"return",
"(",
"int",
")",
"(",
"0.2126",
"*",
"$",
"r",
"+",
"0.7152",
"*",
"$",
"g",
"+",
"0.0722",
"*",
"$",
"b",
")",
"/",
"255",
";",
"break",
";",
"case",
"3",
":",
"// HSP algorithm\r",
"return",
"round",
"(",
"sqrt",
"(",
"0.299",
"*",
"$",
"r",
"*",
"$",
"r",
"+",
"0.587",
"*",
"$",
"g",
"*",
"$",
"g",
"+",
"0.114",
"*",
"$",
"b",
"*",
"$",
"b",
")",
")",
"/",
"255",
";",
"break",
";",
"case",
"self",
"::",
"HSL",
":",
"// HSL algorithm\r",
"return",
"(",
"max",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
"+",
"min",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
")",
"/",
"(",
"2",
"*",
"255",
")",
";",
"break",
";",
"case",
"self",
"::",
"HSV",
":",
"// HSV algorithm\r",
"return",
"max",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
"/",
"255",
";",
"break",
";",
"case",
"self",
"::",
"HSI",
":",
"// HSI algorithm\r",
"return",
"(",
"$",
"r",
"+",
"$",
"g",
"+",
"$",
"b",
")",
"/",
"(",
"3",
"*",
"255",
")",
";",
"break",
";",
"default",
":",
"throw",
"new",
"Exception",
"(",
"'Unknown color mode'",
")",
";",
"break",
";",
"}",
"}"
] |
Returns color luminance.
@param int $mode Luminance mode: 0 = fastest, 1 = Digital CCIR601, 2 = Digital ITU-R, 3 = HSP (best quality), Color::HSL = HSL (default), Color::HSV = HSV
@return float
|
[
"Returns",
"color",
"luminance",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L336-L374
|
227,641
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Dimensions.multiply
|
public function multiply($x, $y) {
$this->width *= $x;
$this->height *= $y;
return $this;
}
|
php
|
public function multiply($x, $y) {
$this->width *= $x;
$this->height *= $y;
return $this;
}
|
[
"public",
"function",
"multiply",
"(",
"$",
"x",
",",
"$",
"y",
")",
"{",
"$",
"this",
"->",
"width",
"*=",
"$",
"x",
";",
"$",
"this",
"->",
"height",
"*=",
"$",
"y",
";",
"return",
"$",
"this",
";",
"}"
] |
Multiplies width and height by a given values.
@param int $x Value to multiply a width dimension.
@param int $y Value to multiply a height dimension.
@return Dimensions
|
[
"Multiplies",
"width",
"and",
"height",
"by",
"a",
"given",
"values",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L424-L428
|
227,642
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Dimensions.add
|
public function add($x = 0, $y = 0) {
$this->width += $x;
$this->height += $y;
return $this;
}
|
php
|
public function add($x = 0, $y = 0) {
$this->width += $x;
$this->height += $y;
return $this;
}
|
[
"public",
"function",
"add",
"(",
"$",
"x",
"=",
"0",
",",
"$",
"y",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"width",
"+=",
"$",
"x",
";",
"$",
"this",
"->",
"height",
"+=",
"$",
"y",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds values to width and height respectively.
@param int $x Value to add to a width dimension.
@param int $y Value to add to a height dimension.
@return Dimensions
|
[
"Adds",
"values",
"to",
"width",
"and",
"height",
"respectively",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L437-L441
|
227,643
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Dimensions.getDiagonalWidth
|
public function getDiagonalWidth() {
return sqrt($this->width * $this->width + $this->height * $this->height);
}
|
php
|
public function getDiagonalWidth() {
return sqrt($this->width * $this->width + $this->height * $this->height);
}
|
[
"public",
"function",
"getDiagonalWidth",
"(",
")",
"{",
"return",
"sqrt",
"(",
"$",
"this",
"->",
"width",
"*",
"$",
"this",
"->",
"width",
"+",
"$",
"this",
"->",
"height",
"*",
"$",
"this",
"->",
"height",
")",
";",
"}"
] |
Returns width of the diagonal line.
@return double
|
[
"Returns",
"width",
"of",
"the",
"diagonal",
"line",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L448-L450
|
227,644
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Vector.addNoise
|
public function addNoise($level) {
$components = array();
foreach($this->components as $component) {
$components[] = $component + rand() * 2 * $level - $level;
}
$this->components = $components;
return $this;
}
|
php
|
public function addNoise($level) {
$components = array();
foreach($this->components as $component) {
$components[] = $component + rand() * 2 * $level - $level;
}
$this->components = $components;
return $this;
}
|
[
"public",
"function",
"addNoise",
"(",
"$",
"level",
")",
"{",
"$",
"components",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"component",
")",
"{",
"$",
"components",
"[",
"]",
"=",
"$",
"component",
"+",
"rand",
"(",
")",
"*",
"2",
"*",
"$",
"level",
"-",
"$",
"level",
";",
"}",
"$",
"this",
"->",
"components",
"=",
"$",
"components",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds noise to this vector.
@param int $level Noise level.
@return Vector
|
[
"Adds",
"noise",
"to",
"this",
"vector",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L526-L533
|
227,645
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Vector.add
|
public function add(Vector $v) {
if($this->dimension != $v->getDimensions()) {
throw new Exception("Both vectors must have the same size");
}
$components = array();
$otherComponents = $v->toArray();
foreach($this->components as $i => $component) {
$components[] = $component + $otherComponents[$i];
}
$this->components = $components;
return $this;
}
|
php
|
public function add(Vector $v) {
if($this->dimension != $v->getDimensions()) {
throw new Exception("Both vectors must have the same size");
}
$components = array();
$otherComponents = $v->toArray();
foreach($this->components as $i => $component) {
$components[] = $component + $otherComponents[$i];
}
$this->components = $components;
return $this;
}
|
[
"public",
"function",
"add",
"(",
"Vector",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dimension",
"!=",
"$",
"v",
"->",
"getDimensions",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Both vectors must have the same size\"",
")",
";",
"}",
"$",
"components",
"=",
"array",
"(",
")",
";",
"$",
"otherComponents",
"=",
"$",
"v",
"->",
"toArray",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"i",
"=>",
"$",
"component",
")",
"{",
"$",
"components",
"[",
"]",
"=",
"$",
"component",
"+",
"$",
"otherComponents",
"[",
"$",
"i",
"]",
";",
"}",
"$",
"this",
"->",
"components",
"=",
"$",
"components",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds two vectors.
@param Vector $v A vector to add.
@return Vector
|
[
"Adds",
"two",
"vectors",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L592-L604
|
227,646
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Vector.multiply
|
public function multiply($v) {
$components = array();
if(is_object($v)) {
if(!($v instanceof Vector)) {
throw new Exception('Unspupported data structure');
}
if($this->dimension != $v->getDimensions()) {
throw new Exception("Both vectors must have the same size");
}
$otherComponents = $v->toArray();
foreach($this->components as $i => $component) {
$components[] = $component * $otherComponents[$i];
}
} else {
foreach($this->components as $i => $component) {
$components[] = $component * $v;
}
}
$this->components = $components;
return $this;
}
|
php
|
public function multiply($v) {
$components = array();
if(is_object($v)) {
if(!($v instanceof Vector)) {
throw new Exception('Unspupported data structure');
}
if($this->dimension != $v->getDimensions()) {
throw new Exception("Both vectors must have the same size");
}
$otherComponents = $v->toArray();
foreach($this->components as $i => $component) {
$components[] = $component * $otherComponents[$i];
}
} else {
foreach($this->components as $i => $component) {
$components[] = $component * $v;
}
}
$this->components = $components;
return $this;
}
|
[
"public",
"function",
"multiply",
"(",
"$",
"v",
")",
"{",
"$",
"components",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"v",
")",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"v",
"instanceof",
"Vector",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Unspupported data structure'",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"dimension",
"!=",
"$",
"v",
"->",
"getDimensions",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Both vectors must have the same size\"",
")",
";",
"}",
"$",
"otherComponents",
"=",
"$",
"v",
"->",
"toArray",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"i",
"=>",
"$",
"component",
")",
"{",
"$",
"components",
"[",
"]",
"=",
"$",
"component",
"*",
"$",
"otherComponents",
"[",
"$",
"i",
"]",
";",
"}",
"}",
"else",
"{",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"i",
"=>",
"$",
"component",
")",
"{",
"$",
"components",
"[",
"]",
"=",
"$",
"component",
"*",
"$",
"v",
";",
"}",
"}",
"$",
"this",
"->",
"components",
"=",
"$",
"components",
";",
"return",
"$",
"this",
";",
"}"
] |
Multiplies two vectors or by a given scalar value.
@param mixed $v A vector or scalar value to multiply.
@return Vector
|
[
"Multiplies",
"two",
"vectors",
"or",
"by",
"a",
"given",
"scalar",
"value",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L612-L632
|
227,647
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Vector.negate
|
public function negate() {
$components = array();
foreach($this->components as $index => $component) {
$components[$index] = -$component;
}
$this->components = $components;
return $this;
}
|
php
|
public function negate() {
$components = array();
foreach($this->components as $index => $component) {
$components[$index] = -$component;
}
$this->components = $components;
return $this;
}
|
[
"public",
"function",
"negate",
"(",
")",
"{",
"$",
"components",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"index",
"=>",
"$",
"component",
")",
"{",
"$",
"components",
"[",
"$",
"index",
"]",
"=",
"-",
"$",
"component",
";",
"}",
"$",
"this",
"->",
"components",
"=",
"$",
"components",
";",
"return",
"$",
"this",
";",
"}"
] |
Negates this vector.
@return Vector
|
[
"Negates",
"this",
"vector",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L639-L647
|
227,648
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Vector.getSubstractedLength
|
public function getSubstractedLength(Vector $v) {
if($this->dimension != $v->getDimensions()) {
throw new Exception("Both vectors must have the same size");
}
$j = 0;
$otherComponents = $v->toArray();
foreach($this->components as $i => $component) {
$value = $component - $otherComponents[$i];
$j += $value * $value;
}
return sqrt($j);
}
|
php
|
public function getSubstractedLength(Vector $v) {
if($this->dimension != $v->getDimensions()) {
throw new Exception("Both vectors must have the same size");
}
$j = 0;
$otherComponents = $v->toArray();
foreach($this->components as $i => $component) {
$value = $component - $otherComponents[$i];
$j += $value * $value;
}
return sqrt($j);
}
|
[
"public",
"function",
"getSubstractedLength",
"(",
"Vector",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dimension",
"!=",
"$",
"v",
"->",
"getDimensions",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Both vectors must have the same size\"",
")",
";",
"}",
"$",
"j",
"=",
"0",
";",
"$",
"otherComponents",
"=",
"$",
"v",
"->",
"toArray",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"i",
"=>",
"$",
"component",
")",
"{",
"$",
"value",
"=",
"$",
"component",
"-",
"$",
"otherComponents",
"[",
"$",
"i",
"]",
";",
"$",
"j",
"+=",
"$",
"value",
"*",
"$",
"value",
";",
"}",
"return",
"sqrt",
"(",
"$",
"j",
")",
";",
"}"
] |
Returns substracted length
@param Vector $v A vector to substract
@return float
|
[
"Returns",
"substracted",
"length"
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L675-L688
|
227,649
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Vector.equals
|
public function equals(Vector $v) {
if($this->dimension != $v->getDimensions()) {
throw new Exception("Both vectors must have the same size");
}
$otherComponents = $v->toArray();
$ret = true;
for($i = 0; $ret && $i < $this->dimension; ++$i) {
$ret = ($this->components[$i] == $otherComponents[$i]);
}
return $ret;
}
|
php
|
public function equals(Vector $v) {
if($this->dimension != $v->getDimensions()) {
throw new Exception("Both vectors must have the same size");
}
$otherComponents = $v->toArray();
$ret = true;
for($i = 0; $ret && $i < $this->dimension; ++$i) {
$ret = ($this->components[$i] == $otherComponents[$i]);
}
return $ret;
}
|
[
"public",
"function",
"equals",
"(",
"Vector",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"dimension",
"!=",
"$",
"v",
"->",
"getDimensions",
"(",
")",
")",
"{",
"throw",
"new",
"Exception",
"(",
"\"Both vectors must have the same size\"",
")",
";",
"}",
"$",
"otherComponents",
"=",
"$",
"v",
"->",
"toArray",
"(",
")",
";",
"$",
"ret",
"=",
"true",
";",
"for",
"(",
"$",
"i",
"=",
"0",
";",
"$",
"ret",
"&&",
"$",
"i",
"<",
"$",
"this",
"->",
"dimension",
";",
"++",
"$",
"i",
")",
"{",
"$",
"ret",
"=",
"(",
"$",
"this",
"->",
"components",
"[",
"$",
"i",
"]",
"==",
"$",
"otherComponents",
"[",
"$",
"i",
"]",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}"
] |
Compares two vectors.
@param Vector $v
@return bool True if vectors are equal, false otherwise.
|
[
"Compares",
"two",
"vectors",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L696-L707
|
227,650
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Vector.normalize
|
public function normalize() {
$j = $this->getLength();
if($j === 0) {
throw new Exception('Cannot normalize zero length vector');
}
$j *= $j;
$components = array();
foreach($this->components as $component) {
$components[] = sqrt(($component * $component) / $j);
}
$this->components = $components;
return $this;
}
|
php
|
public function normalize() {
$j = $this->getLength();
if($j === 0) {
throw new Exception('Cannot normalize zero length vector');
}
$j *= $j;
$components = array();
foreach($this->components as $component) {
$components[] = sqrt(($component * $component) / $j);
}
$this->components = $components;
return $this;
}
|
[
"public",
"function",
"normalize",
"(",
")",
"{",
"$",
"j",
"=",
"$",
"this",
"->",
"getLength",
"(",
")",
";",
"if",
"(",
"$",
"j",
"===",
"0",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Cannot normalize zero length vector'",
")",
";",
"}",
"$",
"j",
"*=",
"$",
"j",
";",
"$",
"components",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"components",
"as",
"$",
"component",
")",
"{",
"$",
"components",
"[",
"]",
"=",
"sqrt",
"(",
"(",
"$",
"component",
"*",
"$",
"component",
")",
"/",
"$",
"j",
")",
";",
"}",
"$",
"this",
"->",
"components",
"=",
"$",
"components",
";",
"return",
"$",
"this",
";",
"}"
] |
Performs Vector normalization.
@return Vector
|
[
"Performs",
"Vector",
"normalization",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L714-L726
|
227,651
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Quantizator.addGlyph
|
public function addGlyph(Vector $v, $identifier = null) {
$v = $v->getCopy();
$v->setIdentifier($identifier);
$this->glyphs[] = $v;
return $this;
}
|
php
|
public function addGlyph(Vector $v, $identifier = null) {
$v = $v->getCopy();
$v->setIdentifier($identifier);
$this->glyphs[] = $v;
return $this;
}
|
[
"public",
"function",
"addGlyph",
"(",
"Vector",
"$",
"v",
",",
"$",
"identifier",
"=",
"null",
")",
"{",
"$",
"v",
"=",
"$",
"v",
"->",
"getCopy",
"(",
")",
";",
"$",
"v",
"->",
"setIdentifier",
"(",
"$",
"identifier",
")",
";",
"$",
"this",
"->",
"glyphs",
"[",
"]",
"=",
"$",
"v",
";",
"return",
"$",
"this",
";",
"}"
] |
Adds vector to the vectors database.
@param Vector $v Vector to add.
@param mixed $identifier Vector identifier.
@return Quantizator
|
[
"Adds",
"vector",
"to",
"the",
"vectors",
"database",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L784-L789
|
227,652
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Quantizator.findNearestEuklid
|
public function findNearestEuklid(Vector $v, $noise = 0) {
$minDimension = 1000000;
foreach($this->glyphs as $index => $w) {
$w = $w->getCopy();
if($noise) {
$w = $w->addNoise($noise);
}
$dimension = $w->getSubstractedLength($v);
if($dimension < $minDimension) {
$ret = $w;
$minDimension = $dimension;
}
}
if(!$ret) {
$ret = $w;
}
return array($ret->getIdentifier(), $minDimension);
}
|
php
|
public function findNearestEuklid(Vector $v, $noise = 0) {
$minDimension = 1000000;
foreach($this->glyphs as $index => $w) {
$w = $w->getCopy();
if($noise) {
$w = $w->addNoise($noise);
}
$dimension = $w->getSubstractedLength($v);
if($dimension < $minDimension) {
$ret = $w;
$minDimension = $dimension;
}
}
if(!$ret) {
$ret = $w;
}
return array($ret->getIdentifier(), $minDimension);
}
|
[
"public",
"function",
"findNearestEuklid",
"(",
"Vector",
"$",
"v",
",",
"$",
"noise",
"=",
"0",
")",
"{",
"$",
"minDimension",
"=",
"1000000",
";",
"foreach",
"(",
"$",
"this",
"->",
"glyphs",
"as",
"$",
"index",
"=>",
"$",
"w",
")",
"{",
"$",
"w",
"=",
"$",
"w",
"->",
"getCopy",
"(",
")",
";",
"if",
"(",
"$",
"noise",
")",
"{",
"$",
"w",
"=",
"$",
"w",
"->",
"addNoise",
"(",
"$",
"noise",
")",
";",
"}",
"$",
"dimension",
"=",
"$",
"w",
"->",
"getSubstractedLength",
"(",
"$",
"v",
")",
";",
"if",
"(",
"$",
"dimension",
"<",
"$",
"minDimension",
")",
"{",
"$",
"ret",
"=",
"$",
"w",
";",
"$",
"minDimension",
"=",
"$",
"dimension",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"ret",
")",
"{",
"$",
"ret",
"=",
"$",
"w",
";",
"}",
"return",
"array",
"(",
"$",
"ret",
"->",
"getIdentifier",
"(",
")",
",",
"$",
"minDimension",
")",
";",
"}"
] |
Finds nearest euklid.
@param Vector $v Vector to compare.
@param int $noise Noise to add (default: 0 for no noise)
@return mixed[] array containing ID of the similar vector, and it's distance to the compared vector.
|
[
"Finds",
"nearest",
"euklid",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L798-L818
|
227,653
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.resize
|
public function resize($widthOrDimensions, $height = null, $useResampling = true) {
if(is_object($widthOrDimensions) && $widthOrDimensions instanceof Dimensions) {
$y = $widthOrDimensions->height;
$x = $widthOrDimensions->width;
} else {
$x = $widthOrDimensions;
$y = $height;
}
$newImage = imagecreatetruecolor($x, $y);
if($useResampling) {
imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $x, $y, $this->width, $this->height);
} else {
imagecopyresized($newImage, $this->image, 0, 0, 0, 0, $x, $y, $this->width, $this->height);
}
$this->image = $newImage;
$this->getSize();
return $this;
}
|
php
|
public function resize($widthOrDimensions, $height = null, $useResampling = true) {
if(is_object($widthOrDimensions) && $widthOrDimensions instanceof Dimensions) {
$y = $widthOrDimensions->height;
$x = $widthOrDimensions->width;
} else {
$x = $widthOrDimensions;
$y = $height;
}
$newImage = imagecreatetruecolor($x, $y);
if($useResampling) {
imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $x, $y, $this->width, $this->height);
} else {
imagecopyresized($newImage, $this->image, 0, 0, 0, 0, $x, $y, $this->width, $this->height);
}
$this->image = $newImage;
$this->getSize();
return $this;
}
|
[
"public",
"function",
"resize",
"(",
"$",
"widthOrDimensions",
",",
"$",
"height",
"=",
"null",
",",
"$",
"useResampling",
"=",
"true",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"widthOrDimensions",
")",
"&&",
"$",
"widthOrDimensions",
"instanceof",
"Dimensions",
")",
"{",
"$",
"y",
"=",
"$",
"widthOrDimensions",
"->",
"height",
";",
"$",
"x",
"=",
"$",
"widthOrDimensions",
"->",
"width",
";",
"}",
"else",
"{",
"$",
"x",
"=",
"$",
"widthOrDimensions",
";",
"$",
"y",
"=",
"$",
"height",
";",
"}",
"$",
"newImage",
"=",
"imagecreatetruecolor",
"(",
"$",
"x",
",",
"$",
"y",
")",
";",
"if",
"(",
"$",
"useResampling",
")",
"{",
"imagecopyresampled",
"(",
"$",
"newImage",
",",
"$",
"this",
"->",
"image",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"height",
")",
";",
"}",
"else",
"{",
"imagecopyresized",
"(",
"$",
"newImage",
",",
"$",
"this",
"->",
"image",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"height",
")",
";",
"}",
"$",
"this",
"->",
"image",
"=",
"$",
"newImage",
";",
"$",
"this",
"->",
"getSize",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Resizes this image.
@param mixed $widthOrDimensions New width (or Dimensions) of the this image.
@param int $height New height of this image (used only if $widthOrDimensions is not an instance of Dimensions class)
@param bool Use resampling? Default: true (slower)
@return Image
|
[
"Resizes",
"this",
"image",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1003-L1020
|
227,654
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.resizeAndKeepAspect
|
public function resizeAndKeepAspect($widthOrDimensions, $height = null, $useResampling = true) {
if(is_object($widthOrDimensions) && $widthOrDimensions instanceof Dimensions) {
$y = $widthOrDimensions->height;
$x = $widthOrDimensions->width;
} else {
$x = $widthOrDimensions;
$y = $height;
}
$originalAspect = $this->width / $this->height;
$newAspect = $x / $y;
if($originalAspect !== $newAspect) {
if($originalAspect > $newAspect) {
$ratio = $x / $this->width;
$y = $ratio * $this->height;
} else {
$ratio = $y / $this->height;
$x = $ratio * $this->width;
}
}
return $this->resize($x, $y, $useResampling);
}
|
php
|
public function resizeAndKeepAspect($widthOrDimensions, $height = null, $useResampling = true) {
if(is_object($widthOrDimensions) && $widthOrDimensions instanceof Dimensions) {
$y = $widthOrDimensions->height;
$x = $widthOrDimensions->width;
} else {
$x = $widthOrDimensions;
$y = $height;
}
$originalAspect = $this->width / $this->height;
$newAspect = $x / $y;
if($originalAspect !== $newAspect) {
if($originalAspect > $newAspect) {
$ratio = $x / $this->width;
$y = $ratio * $this->height;
} else {
$ratio = $y / $this->height;
$x = $ratio * $this->width;
}
}
return $this->resize($x, $y, $useResampling);
}
|
[
"public",
"function",
"resizeAndKeepAspect",
"(",
"$",
"widthOrDimensions",
",",
"$",
"height",
"=",
"null",
",",
"$",
"useResampling",
"=",
"true",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"widthOrDimensions",
")",
"&&",
"$",
"widthOrDimensions",
"instanceof",
"Dimensions",
")",
"{",
"$",
"y",
"=",
"$",
"widthOrDimensions",
"->",
"height",
";",
"$",
"x",
"=",
"$",
"widthOrDimensions",
"->",
"width",
";",
"}",
"else",
"{",
"$",
"x",
"=",
"$",
"widthOrDimensions",
";",
"$",
"y",
"=",
"$",
"height",
";",
"}",
"$",
"originalAspect",
"=",
"$",
"this",
"->",
"width",
"/",
"$",
"this",
"->",
"height",
";",
"$",
"newAspect",
"=",
"$",
"x",
"/",
"$",
"y",
";",
"if",
"(",
"$",
"originalAspect",
"!==",
"$",
"newAspect",
")",
"{",
"if",
"(",
"$",
"originalAspect",
">",
"$",
"newAspect",
")",
"{",
"$",
"ratio",
"=",
"$",
"x",
"/",
"$",
"this",
"->",
"width",
";",
"$",
"y",
"=",
"$",
"ratio",
"*",
"$",
"this",
"->",
"height",
";",
"}",
"else",
"{",
"$",
"ratio",
"=",
"$",
"y",
"/",
"$",
"this",
"->",
"height",
";",
"$",
"x",
"=",
"$",
"ratio",
"*",
"$",
"this",
"->",
"width",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"resize",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"useResampling",
")",
";",
"}"
] |
Resizes this image and keeps the image aspect.
@param mixed $widthOrDimensions New width (or Dimensions) of the this image.
@param int $height New height of this image (used only if $widthOrDimensions is not an instance of Dimensions class)
@param bool Use resampling? Default: true (slower)
@return Image
|
[
"Resizes",
"this",
"image",
"and",
"keeps",
"the",
"image",
"aspect",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1030-L1053
|
227,655
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.rescale
|
public function rescale($x, $y) {
if(is_object($x) && $x instanceof Dimensions) {
$y = $x->height;
$x = $x->width;
}
$newImage = imagecreatetruecolor($this->width * $x, $this->height * $y);
$x = imagesx($newImage);
$y = imagesy($newImage);
imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $x, $y, $this->width, $this->height);
$this->image = $newImage;
$this->getSize();
return $this;
}
|
php
|
public function rescale($x, $y) {
if(is_object($x) && $x instanceof Dimensions) {
$y = $x->height;
$x = $x->width;
}
$newImage = imagecreatetruecolor($this->width * $x, $this->height * $y);
$x = imagesx($newImage);
$y = imagesy($newImage);
imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $x, $y, $this->width, $this->height);
$this->image = $newImage;
$this->getSize();
return $this;
}
|
[
"public",
"function",
"rescale",
"(",
"$",
"x",
",",
"$",
"y",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"x",
")",
"&&",
"$",
"x",
"instanceof",
"Dimensions",
")",
"{",
"$",
"y",
"=",
"$",
"x",
"->",
"height",
";",
"$",
"x",
"=",
"$",
"x",
"->",
"width",
";",
"}",
"$",
"newImage",
"=",
"imagecreatetruecolor",
"(",
"$",
"this",
"->",
"width",
"*",
"$",
"x",
",",
"$",
"this",
"->",
"height",
"*",
"$",
"y",
")",
";",
"$",
"x",
"=",
"imagesx",
"(",
"$",
"newImage",
")",
";",
"$",
"y",
"=",
"imagesy",
"(",
"$",
"newImage",
")",
";",
"imagecopyresampled",
"(",
"$",
"newImage",
",",
"$",
"this",
"->",
"image",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"height",
")",
";",
"$",
"this",
"->",
"image",
"=",
"$",
"newImage",
";",
"$",
"this",
"->",
"getSize",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Scales this image.
@return Image
|
[
"Scales",
"this",
"image",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1060-L1072
|
227,656
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.getPointRgb
|
public function getPointRgb(Point $position) {
return imagecolorat($this->image, $position->x, $position->y);
}
|
php
|
public function getPointRgb(Point $position) {
return imagecolorat($this->image, $position->x, $position->y);
}
|
[
"public",
"function",
"getPointRgb",
"(",
"Point",
"$",
"position",
")",
"{",
"return",
"imagecolorat",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"position",
"->",
"x",
",",
"$",
"position",
"->",
"y",
")",
";",
"}"
] |
Returns a RGB value of the pixel at the coordinates described in the Point object.
@param Point $position Position of the pixel to check.
@return int RGB value of the pixel.
|
[
"Returns",
"a",
"RGB",
"value",
"of",
"the",
"pixel",
"at",
"the",
"coordinates",
"described",
"in",
"the",
"Point",
"object",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1102-L1104
|
227,657
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.getPointColor
|
public function getPointColor(Point $position) {
return new Color(imagecolorat($this->image, $position->x, $position->y));
}
|
php
|
public function getPointColor(Point $position) {
return new Color(imagecolorat($this->image, $position->x, $position->y));
}
|
[
"public",
"function",
"getPointColor",
"(",
"Point",
"$",
"position",
")",
"{",
"return",
"new",
"Color",
"(",
"imagecolorat",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"position",
"->",
"x",
",",
"$",
"position",
"->",
"y",
")",
")",
";",
"}"
] |
Returns a color of the pixel at the coordinates described in the Point object.
@param Point $position Position of the pixel to check.
@return Color Object describing the color of the pixel.
|
[
"Returns",
"a",
"color",
"of",
"the",
"pixel",
"at",
"the",
"coordinates",
"described",
"in",
"the",
"Point",
"object",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1112-L1114
|
227,658
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.setPointColor
|
public function setPointColor(Point $position, Color $color) {
imagesetpixel($this->image, $position->x, $position->y, $color->rgb);
return $this;
}
|
php
|
public function setPointColor(Point $position, Color $color) {
imagesetpixel($this->image, $position->x, $position->y, $color->rgb);
return $this;
}
|
[
"public",
"function",
"setPointColor",
"(",
"Point",
"$",
"position",
",",
"Color",
"$",
"color",
")",
"{",
"imagesetpixel",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"position",
"->",
"x",
",",
"$",
"position",
"->",
"y",
",",
"$",
"color",
"->",
"rgb",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets a color of the pixel at the coordinates described in the Point object.
@param Point $position Position of the pixel to set.
@return Image
|
[
"Sets",
"a",
"color",
"of",
"the",
"pixel",
"at",
"the",
"coordinates",
"described",
"in",
"the",
"Point",
"object",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1122-L1125
|
227,659
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.setPointRgb
|
public function setPointRgb(Point $position, $rgb) {
imagesetpixel($this->image, $position->x, $position->y, $rgb);
return $this;
}
|
php
|
public function setPointRgb(Point $position, $rgb) {
imagesetpixel($this->image, $position->x, $position->y, $rgb);
return $this;
}
|
[
"public",
"function",
"setPointRgb",
"(",
"Point",
"$",
"position",
",",
"$",
"rgb",
")",
"{",
"imagesetpixel",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"position",
"->",
"x",
",",
"$",
"position",
"->",
"y",
",",
"$",
"rgb",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets a RGB value of the pixel at the coordinates described in the Point object.
@param Point $position Position of the pixel to set.
@return Image
|
[
"Sets",
"a",
"RGB",
"value",
"of",
"the",
"pixel",
"at",
"the",
"coordinates",
"described",
"in",
"the",
"Point",
"object",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1133-L1136
|
227,660
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.setPixelColor
|
public function setPixelColor($x, $y, Color $color) {
imagesetpixel($this->image, $x, $y, $color->rgb);
return $this;
}
|
php
|
public function setPixelColor($x, $y, Color $color) {
imagesetpixel($this->image, $x, $y, $color->rgb);
return $this;
}
|
[
"public",
"function",
"setPixelColor",
"(",
"$",
"x",
",",
"$",
"y",
",",
"Color",
"$",
"color",
")",
"{",
"imagesetpixel",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"color",
"->",
"rgb",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets a color of the pixel at the X,Y coordinates.
@param int $x X-coordinate of the pixel to set.
@param int $y Y-coordinate of the pixel to set.
@return Image
|
[
"Sets",
"a",
"color",
"of",
"the",
"pixel",
"at",
"the",
"X",
"Y",
"coordinates",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1145-L1148
|
227,661
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.setPixelRgb
|
public function setPixelRgb($x, $y, $rgb) {
imagesetpixel($this->image, $x, $y, $rgb);
return $this;
}
|
php
|
public function setPixelRgb($x, $y, $rgb) {
imagesetpixel($this->image, $x, $y, $rgb);
return $this;
}
|
[
"public",
"function",
"setPixelRgb",
"(",
"$",
"x",
",",
"$",
"y",
",",
"$",
"rgb",
")",
"{",
"imagesetpixel",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"rgb",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Sets a RGB value of the pixel at the X,Y coordinates.
@param int $x X-coordinate of the pixel to set.
@param int $y Y-coordinate of the pixel to set.
@return Image
|
[
"Sets",
"a",
"RGB",
"value",
"of",
"the",
"pixel",
"at",
"the",
"X",
"Y",
"coordinates",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1157-L1160
|
227,662
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.getSubImage
|
public function getSubImage(Point $position, Dimensions $size) {
return new Image(null, $this->image, $position, $size);
}
|
php
|
public function getSubImage(Point $position, Dimensions $size) {
return new Image(null, $this->image, $position, $size);
}
|
[
"public",
"function",
"getSubImage",
"(",
"Point",
"$",
"position",
",",
"Dimensions",
"$",
"size",
")",
"{",
"return",
"new",
"Image",
"(",
"null",
",",
"$",
"this",
"->",
"image",
",",
"$",
"position",
",",
"$",
"size",
")",
";",
"}"
] |
Returns a sub image of this image.
@param Point $position
@param Dimensions $size
@return Image
|
[
"Returns",
"a",
"sub",
"image",
"of",
"this",
"image",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1188-L1190
|
227,663
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.getVector
|
public function getVector(Point $position = null, Dimensions $size = null, $round = false, $colorMask = 0) {
if($position === null) {
$position = new Point(0, 0);
}
if($size === null) {
$size = $this->getDimensions();
}
$x = $position->x;
$y = $position->y;
$width = $size->width;
$height = $size->height;
$components = array();
$d = 0;
$maxX = $x + $width;
$maxY = $y + $height;
for($i = $y; $i < $maxY && $i < $this->height; ++$i) {
for($j = $x; $j < $maxX && $j < $this->width; ++$j) {
$rgb = imagecolorat($this->image, $j, $i);
if($colorMask === 0) {
$pixel = ($rgb >> 16) & 0xff;
$pixel += ($rgb >> 8) & 0xff;
$pixel += $rgb & 0xff;
$d = $pixel / 768;
} else {
$count = $d = 0;
if(($colorMask & Channel::RED) > 0) {
$d += ($rgb >> 16) & 0xff;
++$count;
}
if(($colorMask & Channel::GREEN) > 0) {
$d += ($rgb >> 8) & 0xff;
++$count;
}
if(($colorMask & Channel::BLUE) > 0) {
$d += $rgb & 0xff;
++$count;
}
$d /= (256 * $count);
}
if($round === false) {
$components[] = 1 - $d;
} else {
$components[] = 1 - round($d);
}
}
}
return new Vector(count($components), -1, $components);
}
|
php
|
public function getVector(Point $position = null, Dimensions $size = null, $round = false, $colorMask = 0) {
if($position === null) {
$position = new Point(0, 0);
}
if($size === null) {
$size = $this->getDimensions();
}
$x = $position->x;
$y = $position->y;
$width = $size->width;
$height = $size->height;
$components = array();
$d = 0;
$maxX = $x + $width;
$maxY = $y + $height;
for($i = $y; $i < $maxY && $i < $this->height; ++$i) {
for($j = $x; $j < $maxX && $j < $this->width; ++$j) {
$rgb = imagecolorat($this->image, $j, $i);
if($colorMask === 0) {
$pixel = ($rgb >> 16) & 0xff;
$pixel += ($rgb >> 8) & 0xff;
$pixel += $rgb & 0xff;
$d = $pixel / 768;
} else {
$count = $d = 0;
if(($colorMask & Channel::RED) > 0) {
$d += ($rgb >> 16) & 0xff;
++$count;
}
if(($colorMask & Channel::GREEN) > 0) {
$d += ($rgb >> 8) & 0xff;
++$count;
}
if(($colorMask & Channel::BLUE) > 0) {
$d += $rgb & 0xff;
++$count;
}
$d /= (256 * $count);
}
if($round === false) {
$components[] = 1 - $d;
} else {
$components[] = 1 - round($d);
}
}
}
return new Vector(count($components), -1, $components);
}
|
[
"public",
"function",
"getVector",
"(",
"Point",
"$",
"position",
"=",
"null",
",",
"Dimensions",
"$",
"size",
"=",
"null",
",",
"$",
"round",
"=",
"false",
",",
"$",
"colorMask",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"position",
"===",
"null",
")",
"{",
"$",
"position",
"=",
"new",
"Point",
"(",
"0",
",",
"0",
")",
";",
"}",
"if",
"(",
"$",
"size",
"===",
"null",
")",
"{",
"$",
"size",
"=",
"$",
"this",
"->",
"getDimensions",
"(",
")",
";",
"}",
"$",
"x",
"=",
"$",
"position",
"->",
"x",
";",
"$",
"y",
"=",
"$",
"position",
"->",
"y",
";",
"$",
"width",
"=",
"$",
"size",
"->",
"width",
";",
"$",
"height",
"=",
"$",
"size",
"->",
"height",
";",
"$",
"components",
"=",
"array",
"(",
")",
";",
"$",
"d",
"=",
"0",
";",
"$",
"maxX",
"=",
"$",
"x",
"+",
"$",
"width",
";",
"$",
"maxY",
"=",
"$",
"y",
"+",
"$",
"height",
";",
"for",
"(",
"$",
"i",
"=",
"$",
"y",
";",
"$",
"i",
"<",
"$",
"maxY",
"&&",
"$",
"i",
"<",
"$",
"this",
"->",
"height",
";",
"++",
"$",
"i",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"$",
"x",
";",
"$",
"j",
"<",
"$",
"maxX",
"&&",
"$",
"j",
"<",
"$",
"this",
"->",
"width",
";",
"++",
"$",
"j",
")",
"{",
"$",
"rgb",
"=",
"imagecolorat",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"j",
",",
"$",
"i",
")",
";",
"if",
"(",
"$",
"colorMask",
"===",
"0",
")",
"{",
"$",
"pixel",
"=",
"(",
"$",
"rgb",
">>",
"16",
")",
"&",
"0xff",
";",
"$",
"pixel",
"+=",
"(",
"$",
"rgb",
">>",
"8",
")",
"&",
"0xff",
";",
"$",
"pixel",
"+=",
"$",
"rgb",
"&",
"0xff",
";",
"$",
"d",
"=",
"$",
"pixel",
"/",
"768",
";",
"}",
"else",
"{",
"$",
"count",
"=",
"$",
"d",
"=",
"0",
";",
"if",
"(",
"(",
"$",
"colorMask",
"&",
"Channel",
"::",
"RED",
")",
">",
"0",
")",
"{",
"$",
"d",
"+=",
"(",
"$",
"rgb",
">>",
"16",
")",
"&",
"0xff",
";",
"++",
"$",
"count",
";",
"}",
"if",
"(",
"(",
"$",
"colorMask",
"&",
"Channel",
"::",
"GREEN",
")",
">",
"0",
")",
"{",
"$",
"d",
"+=",
"(",
"$",
"rgb",
">>",
"8",
")",
"&",
"0xff",
";",
"++",
"$",
"count",
";",
"}",
"if",
"(",
"(",
"$",
"colorMask",
"&",
"Channel",
"::",
"BLUE",
")",
">",
"0",
")",
"{",
"$",
"d",
"+=",
"$",
"rgb",
"&",
"0xff",
";",
"++",
"$",
"count",
";",
"}",
"$",
"d",
"/=",
"(",
"256",
"*",
"$",
"count",
")",
";",
"}",
"if",
"(",
"$",
"round",
"===",
"false",
")",
"{",
"$",
"components",
"[",
"]",
"=",
"1",
"-",
"$",
"d",
";",
"}",
"else",
"{",
"$",
"components",
"[",
"]",
"=",
"1",
"-",
"round",
"(",
"$",
"d",
")",
";",
"}",
"}",
"}",
"return",
"new",
"Vector",
"(",
"count",
"(",
"$",
"components",
")",
",",
"-",
"1",
",",
"$",
"components",
")",
";",
"}"
] |
Creates a vector from a part of an image.
@param Point $position X,Y-coordinates of the left upper-most point of the image.
@param Dimensions $size Width and height of the image.
@param bool $round Round the values?
@param int $colorMask Color bitmask.
@return Vector
|
[
"Creates",
"a",
"vector",
"from",
"a",
"part",
"of",
"an",
"image",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1201-L1255
|
227,664
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.rotate
|
public function rotate($angle, $backgroundColor = -1) {
if($backgroundColor === -1) {
$backgroundColor = hexdec($this->getBackgroundColor()->getHexValue());
}
$this->image = imagerotate($this->image, $angle, (int) $backgroundColor);
$this->getSize();
return $this;
}
|
php
|
public function rotate($angle, $backgroundColor = -1) {
if($backgroundColor === -1) {
$backgroundColor = hexdec($this->getBackgroundColor()->getHexValue());
}
$this->image = imagerotate($this->image, $angle, (int) $backgroundColor);
$this->getSize();
return $this;
}
|
[
"public",
"function",
"rotate",
"(",
"$",
"angle",
",",
"$",
"backgroundColor",
"=",
"-",
"1",
")",
"{",
"if",
"(",
"$",
"backgroundColor",
"===",
"-",
"1",
")",
"{",
"$",
"backgroundColor",
"=",
"hexdec",
"(",
"$",
"this",
"->",
"getBackgroundColor",
"(",
")",
"->",
"getHexValue",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"image",
"=",
"imagerotate",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"angle",
",",
"(",
"int",
")",
"$",
"backgroundColor",
")",
";",
"$",
"this",
"->",
"getSize",
"(",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Rotates image by a given angle.
@param int $angle Angle in degrees (not radians).
@param int $backgroundColor Backround color used to fill empty spaces after rotation (or -1 for autodetection).
@return Image
|
[
"Rotates",
"image",
"by",
"a",
"given",
"angle",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1273-L1280
|
227,665
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.crop
|
public function crop(Point $position, Dimensions $dimensions) {
$newImage = imagecreate($dimensions->width, $dimensions->height);
imagecopy($newImage, $this->image, 0, 0, $position->x, $position->y, $dimensions->width, $dimensions->height);
$this->image = $newImage;
$this->getSize();
$this->position = $position;
return $this;
}
|
php
|
public function crop(Point $position, Dimensions $dimensions) {
$newImage = imagecreate($dimensions->width, $dimensions->height);
imagecopy($newImage, $this->image, 0, 0, $position->x, $position->y, $dimensions->width, $dimensions->height);
$this->image = $newImage;
$this->getSize();
$this->position = $position;
return $this;
}
|
[
"public",
"function",
"crop",
"(",
"Point",
"$",
"position",
",",
"Dimensions",
"$",
"dimensions",
")",
"{",
"$",
"newImage",
"=",
"imagecreate",
"(",
"$",
"dimensions",
"->",
"width",
",",
"$",
"dimensions",
"->",
"height",
")",
";",
"imagecopy",
"(",
"$",
"newImage",
",",
"$",
"this",
"->",
"image",
",",
"0",
",",
"0",
",",
"$",
"position",
"->",
"x",
",",
"$",
"position",
"->",
"y",
",",
"$",
"dimensions",
"->",
"width",
",",
"$",
"dimensions",
"->",
"height",
")",
";",
"$",
"this",
"->",
"image",
"=",
"$",
"newImage",
";",
"$",
"this",
"->",
"getSize",
"(",
")",
";",
"$",
"this",
"->",
"position",
"=",
"$",
"position",
";",
"return",
"$",
"this",
";",
"}"
] |
Crops current image.
@param Point $position Position of the upper left point of the area to crop.
@param Dimensions $dimensions Size of the area to crop.
@return Image
|
[
"Crops",
"current",
"image",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1388-L1395
|
227,666
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.tiltAndCompare
|
private function tiltAndCompare(Image $otherImage, $minAngle = -20, $maxAngle = 20, $backgroundColor = 0xffffff, &$minDimension) {
if($minAngle > $maxAngle) {
$tmp = $maxAngle;
$maxAngle = $minAngle;
$minAngle = $tmp;
}
$quantization = new Quantizator();
$vector = $otherImage->getVector(new Point(0, 0), $otherImage->getDimensions(), false, 0);
//$vector->normalize();
$quantization->addGlyph($vector, 1);
$otherImageDimensions = $otherImage->getDimensions();
$foundObject = $this;
$minDimension = 1000000000000;
for($angle = $minAngle; $angle <= $maxAngle; $angle += 1) {
$copy = $this->getCopy();
$copy->rotate($angle, $backgroundColor);
// find object in object - this is a smart autocropping of binary images.
//$objects = $copy->findObjects();
$objects[0] = $copy;
// we want only the first detected object (only one should be detected anyway!;)
list($width, $height) = $objects[0]->getSize();
// object must be resized before quantization in order to match the other image dimensions.
$objects[0]->resize($otherImageDimensions, null, false)->toBinary();
$vector = $objects[0]->getVector(new Point(0, 0), $otherImageDimensions, false, 0);
//$vector->normalize();
$result = $quantization->findNearestEuklid($vector);
if($result[1] < $minDimension) {
$minDimension = $result[1];
$foundObject = $objects[0];
}
}
return $foundObject;
}
|
php
|
private function tiltAndCompare(Image $otherImage, $minAngle = -20, $maxAngle = 20, $backgroundColor = 0xffffff, &$minDimension) {
if($minAngle > $maxAngle) {
$tmp = $maxAngle;
$maxAngle = $minAngle;
$minAngle = $tmp;
}
$quantization = new Quantizator();
$vector = $otherImage->getVector(new Point(0, 0), $otherImage->getDimensions(), false, 0);
//$vector->normalize();
$quantization->addGlyph($vector, 1);
$otherImageDimensions = $otherImage->getDimensions();
$foundObject = $this;
$minDimension = 1000000000000;
for($angle = $minAngle; $angle <= $maxAngle; $angle += 1) {
$copy = $this->getCopy();
$copy->rotate($angle, $backgroundColor);
// find object in object - this is a smart autocropping of binary images.
//$objects = $copy->findObjects();
$objects[0] = $copy;
// we want only the first detected object (only one should be detected anyway!;)
list($width, $height) = $objects[0]->getSize();
// object must be resized before quantization in order to match the other image dimensions.
$objects[0]->resize($otherImageDimensions, null, false)->toBinary();
$vector = $objects[0]->getVector(new Point(0, 0), $otherImageDimensions, false, 0);
//$vector->normalize();
$result = $quantization->findNearestEuklid($vector);
if($result[1] < $minDimension) {
$minDimension = $result[1];
$foundObject = $objects[0];
}
}
return $foundObject;
}
|
[
"private",
"function",
"tiltAndCompare",
"(",
"Image",
"$",
"otherImage",
",",
"$",
"minAngle",
"=",
"-",
"20",
",",
"$",
"maxAngle",
"=",
"20",
",",
"$",
"backgroundColor",
"=",
"0xffffff",
",",
"&",
"$",
"minDimension",
")",
"{",
"if",
"(",
"$",
"minAngle",
">",
"$",
"maxAngle",
")",
"{",
"$",
"tmp",
"=",
"$",
"maxAngle",
";",
"$",
"maxAngle",
"=",
"$",
"minAngle",
";",
"$",
"minAngle",
"=",
"$",
"tmp",
";",
"}",
"$",
"quantization",
"=",
"new",
"Quantizator",
"(",
")",
";",
"$",
"vector",
"=",
"$",
"otherImage",
"->",
"getVector",
"(",
"new",
"Point",
"(",
"0",
",",
"0",
")",
",",
"$",
"otherImage",
"->",
"getDimensions",
"(",
")",
",",
"false",
",",
"0",
")",
";",
"//$vector->normalize();\r",
"$",
"quantization",
"->",
"addGlyph",
"(",
"$",
"vector",
",",
"1",
")",
";",
"$",
"otherImageDimensions",
"=",
"$",
"otherImage",
"->",
"getDimensions",
"(",
")",
";",
"$",
"foundObject",
"=",
"$",
"this",
";",
"$",
"minDimension",
"=",
"1000000000000",
";",
"for",
"(",
"$",
"angle",
"=",
"$",
"minAngle",
";",
"$",
"angle",
"<=",
"$",
"maxAngle",
";",
"$",
"angle",
"+=",
"1",
")",
"{",
"$",
"copy",
"=",
"$",
"this",
"->",
"getCopy",
"(",
")",
";",
"$",
"copy",
"->",
"rotate",
"(",
"$",
"angle",
",",
"$",
"backgroundColor",
")",
";",
"// find object in object - this is a smart autocropping of binary images.\r",
"//$objects = $copy->findObjects();\r",
"$",
"objects",
"[",
"0",
"]",
"=",
"$",
"copy",
";",
"// we want only the first detected object (only one should be detected anyway!;)\r",
"list",
"(",
"$",
"width",
",",
"$",
"height",
")",
"=",
"$",
"objects",
"[",
"0",
"]",
"->",
"getSize",
"(",
")",
";",
"// object must be resized before quantization in order to match the other image dimensions.\r",
"$",
"objects",
"[",
"0",
"]",
"->",
"resize",
"(",
"$",
"otherImageDimensions",
",",
"null",
",",
"false",
")",
"->",
"toBinary",
"(",
")",
";",
"$",
"vector",
"=",
"$",
"objects",
"[",
"0",
"]",
"->",
"getVector",
"(",
"new",
"Point",
"(",
"0",
",",
"0",
")",
",",
"$",
"otherImageDimensions",
",",
"false",
",",
"0",
")",
";",
"//$vector->normalize();\r",
"$",
"result",
"=",
"$",
"quantization",
"->",
"findNearestEuklid",
"(",
"$",
"vector",
")",
";",
"if",
"(",
"$",
"result",
"[",
"1",
"]",
"<",
"$",
"minDimension",
")",
"{",
"$",
"minDimension",
"=",
"$",
"result",
"[",
"1",
"]",
";",
"$",
"foundObject",
"=",
"$",
"objects",
"[",
"0",
"]",
";",
"}",
"}",
"return",
"$",
"foundObject",
";",
"}"
] |
Experimental functionality, do not use!.
@param Image $otherImage
@param mixed $minAngle
@param mixed $maxAngle
@param mixed $backgroundColor
@param mixed $minDimension
|
[
"Experimental",
"functionality",
"do",
"not",
"use!",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1406-L1441
|
227,667
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.show
|
public function show($die = false) {
header('Content-Type: image/png');
imagepng($this->image);
if($die) {
die();
}
return $this;
}
|
php
|
public function show($die = false) {
header('Content-Type: image/png');
imagepng($this->image);
if($die) {
die();
}
return $this;
}
|
[
"public",
"function",
"show",
"(",
"$",
"die",
"=",
"false",
")",
"{",
"header",
"(",
"'Content-Type: image/png'",
")",
";",
"imagepng",
"(",
"$",
"this",
"->",
"image",
")",
";",
"if",
"(",
"$",
"die",
")",
"{",
"die",
"(",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
] |
Displays the image.
@param bool $die Die after displaying an image? Default: false
@return Image
|
[
"Displays",
"the",
"image",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1473-L1480
|
227,668
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.deskew
|
public function deskew($backgroundColor = -1, $precisionLevel = true, $debugMode = false) {
// detect the background color
if($backgroundColor < 0) {
$backgroundColor = hexdec($this->getBackgroundColor(1, $precisionLevel === true)->getHexValue());
}
// calculate a Hough matrix and get the skew angle
if($precisionLevel === false || $precisionLevel === 2) {
$precisionLevel = 256;
} else if($precisionLevel === 3) {
$precisionLevel = 512;
} else if($precisionLevel === 4) {
$precisionLevel = 1024;
} else {
$precisionLevel = 128;
}
$angles = $this->getSkewAngle($debugMode ? 1 : 8, $precisionLevel, $debugMode);
$this->rotate($angles[0]['degrees'], $backgroundColor);
return $this;
}
|
php
|
public function deskew($backgroundColor = -1, $precisionLevel = true, $debugMode = false) {
// detect the background color
if($backgroundColor < 0) {
$backgroundColor = hexdec($this->getBackgroundColor(1, $precisionLevel === true)->getHexValue());
}
// calculate a Hough matrix and get the skew angle
if($precisionLevel === false || $precisionLevel === 2) {
$precisionLevel = 256;
} else if($precisionLevel === 3) {
$precisionLevel = 512;
} else if($precisionLevel === 4) {
$precisionLevel = 1024;
} else {
$precisionLevel = 128;
}
$angles = $this->getSkewAngle($debugMode ? 1 : 8, $precisionLevel, $debugMode);
$this->rotate($angles[0]['degrees'], $backgroundColor);
return $this;
}
|
[
"public",
"function",
"deskew",
"(",
"$",
"backgroundColor",
"=",
"-",
"1",
",",
"$",
"precisionLevel",
"=",
"true",
",",
"$",
"debugMode",
"=",
"false",
")",
"{",
"// detect the background color\r",
"if",
"(",
"$",
"backgroundColor",
"<",
"0",
")",
"{",
"$",
"backgroundColor",
"=",
"hexdec",
"(",
"$",
"this",
"->",
"getBackgroundColor",
"(",
"1",
",",
"$",
"precisionLevel",
"===",
"true",
")",
"->",
"getHexValue",
"(",
")",
")",
";",
"}",
"// calculate a Hough matrix and get the skew angle\r",
"if",
"(",
"$",
"precisionLevel",
"===",
"false",
"||",
"$",
"precisionLevel",
"===",
"2",
")",
"{",
"$",
"precisionLevel",
"=",
"256",
";",
"}",
"else",
"if",
"(",
"$",
"precisionLevel",
"===",
"3",
")",
"{",
"$",
"precisionLevel",
"=",
"512",
";",
"}",
"else",
"if",
"(",
"$",
"precisionLevel",
"===",
"4",
")",
"{",
"$",
"precisionLevel",
"=",
"1024",
";",
"}",
"else",
"{",
"$",
"precisionLevel",
"=",
"128",
";",
"}",
"$",
"angles",
"=",
"$",
"this",
"->",
"getSkewAngle",
"(",
"$",
"debugMode",
"?",
"1",
":",
"8",
",",
"$",
"precisionLevel",
",",
"$",
"debugMode",
")",
";",
"$",
"this",
"->",
"rotate",
"(",
"$",
"angles",
"[",
"0",
"]",
"[",
"'degrees'",
"]",
",",
"$",
"backgroundColor",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Deskews the image.
@param int $backgroundColor Color of the background to use, or -1 (default) to use auto detection.
@param bool $precisionLevel Set true or 1 to enable turbo mode (may be less accurate) or use 2-4 values to increase the deskew precision.
@param bool $debugMode Set true to enable the debug mode.
@return Image
|
[
"Deskews",
"the",
"image",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1523-L1544
|
227,669
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.getSize
|
public function getSize() {
list($this->width, $this->height) = $result = array(imagesx($this->image), imagesy($this->image));
return $result;
}
|
php
|
public function getSize() {
list($this->width, $this->height) = $result = array(imagesx($this->image), imagesy($this->image));
return $result;
}
|
[
"public",
"function",
"getSize",
"(",
")",
"{",
"list",
"(",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"height",
")",
"=",
"$",
"result",
"=",
"array",
"(",
"imagesx",
"(",
"$",
"this",
"->",
"image",
")",
",",
"imagesy",
"(",
"$",
"this",
"->",
"image",
")",
")",
";",
"return",
"$",
"result",
";",
"}"
] |
Calculates the size of this image.
@return int[] An array containing a width and height of this image.
|
[
"Calculates",
"the",
"size",
"of",
"this",
"image",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1551-L1554
|
227,670
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.drawHoughLine
|
protected function drawHoughLine($distance, $theta, $color = 111111) {
if($theta === 0 || $theta === 360) {
return $this;
}
$theta = deg2rad($theta);
$sizeX2 = $this->width / 2;
$sizeY2 = $this->height / 2;
for($x = 0; $x< $this->width; ++$x) {
$y1 = (int)($distance / sin($theta) - ($x - $sizeX2) * (cos($theta) / sin($theta)) + $sizeY2);
$x1 = (int)($distance / cos($theta) - ($x - $sizeX2) * tan($theta) + $sizeY2);
if($x > 0 && $x < $this->width && $y1 > 0 && $y1 < $this->height) {
imageline($this->image, $x, $y1, $x, $y1, $color);
}
if($x1 > 0 && $x1 < $this->width) {
imageline($this->image, $x1, $x, $x1, $x, $color);
}
}
return $this;
}
|
php
|
protected function drawHoughLine($distance, $theta, $color = 111111) {
if($theta === 0 || $theta === 360) {
return $this;
}
$theta = deg2rad($theta);
$sizeX2 = $this->width / 2;
$sizeY2 = $this->height / 2;
for($x = 0; $x< $this->width; ++$x) {
$y1 = (int)($distance / sin($theta) - ($x - $sizeX2) * (cos($theta) / sin($theta)) + $sizeY2);
$x1 = (int)($distance / cos($theta) - ($x - $sizeX2) * tan($theta) + $sizeY2);
if($x > 0 && $x < $this->width && $y1 > 0 && $y1 < $this->height) {
imageline($this->image, $x, $y1, $x, $y1, $color);
}
if($x1 > 0 && $x1 < $this->width) {
imageline($this->image, $x1, $x, $x1, $x, $color);
}
}
return $this;
}
|
[
"protected",
"function",
"drawHoughLine",
"(",
"$",
"distance",
",",
"$",
"theta",
",",
"$",
"color",
"=",
"111111",
")",
"{",
"if",
"(",
"$",
"theta",
"===",
"0",
"||",
"$",
"theta",
"===",
"360",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"theta",
"=",
"deg2rad",
"(",
"$",
"theta",
")",
";",
"$",
"sizeX2",
"=",
"$",
"this",
"->",
"width",
"/",
"2",
";",
"$",
"sizeY2",
"=",
"$",
"this",
"->",
"height",
"/",
"2",
";",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"this",
"->",
"width",
";",
"++",
"$",
"x",
")",
"{",
"$",
"y1",
"=",
"(",
"int",
")",
"(",
"$",
"distance",
"/",
"sin",
"(",
"$",
"theta",
")",
"-",
"(",
"$",
"x",
"-",
"$",
"sizeX2",
")",
"*",
"(",
"cos",
"(",
"$",
"theta",
")",
"/",
"sin",
"(",
"$",
"theta",
")",
")",
"+",
"$",
"sizeY2",
")",
";",
"$",
"x1",
"=",
"(",
"int",
")",
"(",
"$",
"distance",
"/",
"cos",
"(",
"$",
"theta",
")",
"-",
"(",
"$",
"x",
"-",
"$",
"sizeX2",
")",
"*",
"tan",
"(",
"$",
"theta",
")",
"+",
"$",
"sizeY2",
")",
";",
"if",
"(",
"$",
"x",
">",
"0",
"&&",
"$",
"x",
"<",
"$",
"this",
"->",
"width",
"&&",
"$",
"y1",
">",
"0",
"&&",
"$",
"y1",
"<",
"$",
"this",
"->",
"height",
")",
"{",
"imageline",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"x",
",",
"$",
"y1",
",",
"$",
"x",
",",
"$",
"y1",
",",
"$",
"color",
")",
";",
"}",
"if",
"(",
"$",
"x1",
">",
"0",
"&&",
"$",
"x1",
"<",
"$",
"this",
"->",
"width",
")",
"{",
"imageline",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"x1",
",",
"$",
"x",
",",
"$",
"x1",
",",
"$",
"x",
",",
"$",
"color",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Draws the Hough line.
@param int $distance Distance from the origin.
@param int $theta Angle in degrees.
@return Image
|
[
"Draws",
"the",
"Hough",
"line",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L1980-L2000
|
227,671
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.getBinaryBuffer
|
protected function getBinaryBuffer() {
// catch the GD2 output
ob_start();
// convert a (probably) color/greyscale image to the monochrome counterpart.
imagewbmp($this->image);
// catch contents of the WBMP file.
$wbmp = ob_get_clean();
// ignore 2 bytes of WBMP file header
$i = 2;
// ignore 2 VLQ's (variable-length quantities) describing WBMP resolution.
for($j = 0; $j < 2; ++$j) {
do {
$test = ord($wbmp[$i]) & 0x80;
++$i;
} while($test);
}
// return binary buffer as a string of chars (bytes)
return substr($wbmp, $i);
}
|
php
|
protected function getBinaryBuffer() {
// catch the GD2 output
ob_start();
// convert a (probably) color/greyscale image to the monochrome counterpart.
imagewbmp($this->image);
// catch contents of the WBMP file.
$wbmp = ob_get_clean();
// ignore 2 bytes of WBMP file header
$i = 2;
// ignore 2 VLQ's (variable-length quantities) describing WBMP resolution.
for($j = 0; $j < 2; ++$j) {
do {
$test = ord($wbmp[$i]) & 0x80;
++$i;
} while($test);
}
// return binary buffer as a string of chars (bytes)
return substr($wbmp, $i);
}
|
[
"protected",
"function",
"getBinaryBuffer",
"(",
")",
"{",
"// catch the GD2 output\r",
"ob_start",
"(",
")",
";",
"// convert a (probably) color/greyscale image to the monochrome counterpart.\r",
"imagewbmp",
"(",
"$",
"this",
"->",
"image",
")",
";",
"// catch contents of the WBMP file.\r",
"$",
"wbmp",
"=",
"ob_get_clean",
"(",
")",
";",
"// ignore 2 bytes of WBMP file header\r",
"$",
"i",
"=",
"2",
";",
"// ignore 2 VLQ's (variable-length quantities) describing WBMP resolution.\r",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"2",
";",
"++",
"$",
"j",
")",
"{",
"do",
"{",
"$",
"test",
"=",
"ord",
"(",
"$",
"wbmp",
"[",
"$",
"i",
"]",
")",
"&",
"0x80",
";",
"++",
"$",
"i",
";",
"}",
"while",
"(",
"$",
"test",
")",
";",
"}",
"// return binary buffer as a string of chars (bytes)\r",
"return",
"substr",
"(",
"$",
"wbmp",
",",
"$",
"i",
")",
";",
"}"
] |
Returns binary frame buffer of the current image.
In case of color/grayscale images, use Image::toBinary() first.
@param resource $image Image to binarize.
@return string String of chars.
|
[
"Returns",
"binary",
"frame",
"buffer",
"of",
"the",
"current",
"image",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L2010-L2033
|
227,672
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.isBinaryBufferEmpty
|
public function isBinaryBufferEmpty($threshold = 0.01) {
$bin = $this->getBinaryBuffer();
// delete all empty bytes
if(strlen(trim($bin, chr(255))) / strlen($bin) < $threshold || strlen(trim($bin, chr(0))) / strlen($bin) < $threshold) {
// something is wrong, image is filled (almost) solid color.
return true;
}
return false;
}
|
php
|
public function isBinaryBufferEmpty($threshold = 0.01) {
$bin = $this->getBinaryBuffer();
// delete all empty bytes
if(strlen(trim($bin, chr(255))) / strlen($bin) < $threshold || strlen(trim($bin, chr(0))) / strlen($bin) < $threshold) {
// something is wrong, image is filled (almost) solid color.
return true;
}
return false;
}
|
[
"public",
"function",
"isBinaryBufferEmpty",
"(",
"$",
"threshold",
"=",
"0.01",
")",
"{",
"$",
"bin",
"=",
"$",
"this",
"->",
"getBinaryBuffer",
"(",
")",
";",
"// delete all empty bytes\r",
"if",
"(",
"strlen",
"(",
"trim",
"(",
"$",
"bin",
",",
"chr",
"(",
"255",
")",
")",
")",
"/",
"strlen",
"(",
"$",
"bin",
")",
"<",
"$",
"threshold",
"||",
"strlen",
"(",
"trim",
"(",
"$",
"bin",
",",
"chr",
"(",
"0",
")",
")",
")",
"/",
"strlen",
"(",
"$",
"bin",
")",
"<",
"$",
"threshold",
")",
"{",
"// something is wrong, image is filled (almost) solid color.\r",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
] |
Detects if the binary buffer of this image is empty after conversion to two-colors mode.
Empty buffer may mean that the conversion failed.
@param double $threshold The threshold.
@return bool True if empty, false otherwise.
|
[
"Detects",
"if",
"the",
"binary",
"buffer",
"of",
"this",
"image",
"is",
"empty",
"after",
"conversion",
"to",
"two",
"-",
"colors",
"mode",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L2043-L2051
|
227,673
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.getHistogramData
|
public function getHistogramData($channels, $colorMode = Color::HSL) {
$colors = array_fill(0, 256, 0);
for($y = 0; $y < $this->height; ++$y) {
for($x = 0; $x < $this->width; ++$x) {
$rgb = imagecolorat($this->image, $x, $y);
$r = ($rgb >> 16) & 0xff;
$g = ($rgb >> 8) & 0xff;
$b = $rgb & 0xff;
switch ($channels) {
case Channel::RGB:
switch($colorMode) {
case Color::HSL:
// HSL algorithm
$luminescence = (max($r, $g, $b) + min($r, $g, $b)) / 2;
break;
case Color::HSV:
// HSV algorithm
$luminescence = max($r, $g, $b);
break;
case Color::HSI:
// HSI algorithm
$luminescence = ($r + $g + $b) / 3;
break;
default:
// fastest
$luminescence = ($r + $r + $r + $b + $g + $g + $g + $g) >> 3;
break;
}
break;
case Channel::RED:
$luminescence = $r;
break;
case Channel::GREEN:
$luminescence = $g;
break;
case Channel::BLUE:
$luminescence = $b;
break;
}
++$colors[$luminescence];
}
}
return $colors;
}
|
php
|
public function getHistogramData($channels, $colorMode = Color::HSL) {
$colors = array_fill(0, 256, 0);
for($y = 0; $y < $this->height; ++$y) {
for($x = 0; $x < $this->width; ++$x) {
$rgb = imagecolorat($this->image, $x, $y);
$r = ($rgb >> 16) & 0xff;
$g = ($rgb >> 8) & 0xff;
$b = $rgb & 0xff;
switch ($channels) {
case Channel::RGB:
switch($colorMode) {
case Color::HSL:
// HSL algorithm
$luminescence = (max($r, $g, $b) + min($r, $g, $b)) / 2;
break;
case Color::HSV:
// HSV algorithm
$luminescence = max($r, $g, $b);
break;
case Color::HSI:
// HSI algorithm
$luminescence = ($r + $g + $b) / 3;
break;
default:
// fastest
$luminescence = ($r + $r + $r + $b + $g + $g + $g + $g) >> 3;
break;
}
break;
case Channel::RED:
$luminescence = $r;
break;
case Channel::GREEN:
$luminescence = $g;
break;
case Channel::BLUE:
$luminescence = $b;
break;
}
++$colors[$luminescence];
}
}
return $colors;
}
|
[
"public",
"function",
"getHistogramData",
"(",
"$",
"channels",
",",
"$",
"colorMode",
"=",
"Color",
"::",
"HSL",
")",
"{",
"$",
"colors",
"=",
"array_fill",
"(",
"0",
",",
"256",
",",
"0",
")",
";",
"for",
"(",
"$",
"y",
"=",
"0",
";",
"$",
"y",
"<",
"$",
"this",
"->",
"height",
";",
"++",
"$",
"y",
")",
"{",
"for",
"(",
"$",
"x",
"=",
"0",
";",
"$",
"x",
"<",
"$",
"this",
"->",
"width",
";",
"++",
"$",
"x",
")",
"{",
"$",
"rgb",
"=",
"imagecolorat",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"x",
",",
"$",
"y",
")",
";",
"$",
"r",
"=",
"(",
"$",
"rgb",
">>",
"16",
")",
"&",
"0xff",
";",
"$",
"g",
"=",
"(",
"$",
"rgb",
">>",
"8",
")",
"&",
"0xff",
";",
"$",
"b",
"=",
"$",
"rgb",
"&",
"0xff",
";",
"switch",
"(",
"$",
"channels",
")",
"{",
"case",
"Channel",
"::",
"RGB",
":",
"switch",
"(",
"$",
"colorMode",
")",
"{",
"case",
"Color",
"::",
"HSL",
":",
"// HSL algorithm\r",
"$",
"luminescence",
"=",
"(",
"max",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
"+",
"min",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
")",
"/",
"2",
";",
"break",
";",
"case",
"Color",
"::",
"HSV",
":",
"// HSV algorithm\r",
"$",
"luminescence",
"=",
"max",
"(",
"$",
"r",
",",
"$",
"g",
",",
"$",
"b",
")",
";",
"break",
";",
"case",
"Color",
"::",
"HSI",
":",
"// HSI algorithm\r",
"$",
"luminescence",
"=",
"(",
"$",
"r",
"+",
"$",
"g",
"+",
"$",
"b",
")",
"/",
"3",
";",
"break",
";",
"default",
":",
"// fastest\r",
"$",
"luminescence",
"=",
"(",
"$",
"r",
"+",
"$",
"r",
"+",
"$",
"r",
"+",
"$",
"b",
"+",
"$",
"g",
"+",
"$",
"g",
"+",
"$",
"g",
"+",
"$",
"g",
")",
">>",
"3",
";",
"break",
";",
"}",
"break",
";",
"case",
"Channel",
"::",
"RED",
":",
"$",
"luminescence",
"=",
"$",
"r",
";",
"break",
";",
"case",
"Channel",
"::",
"GREEN",
":",
"$",
"luminescence",
"=",
"$",
"g",
";",
"break",
";",
"case",
"Channel",
"::",
"BLUE",
":",
"$",
"luminescence",
"=",
"$",
"b",
";",
"break",
";",
"}",
"++",
"$",
"colors",
"[",
"$",
"luminescence",
"]",
";",
"}",
"}",
"return",
"$",
"colors",
";",
"}"
] |
Generate histogram data.
@param int $channels Channels to draw, possibilities: Channel::RGB (default), Channel::RED, Channel::GREEN, Channel::BLUE
@param int $colorMode Color mode for saturation (use Color::HSV, Color::HSI or Color::HSL as the value), default is Color::HSL
@return int[] Histogram data
|
[
"Generate",
"histogram",
"data",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L2096-L2140
|
227,674
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.getHistogram
|
public function getHistogram($channels = Channel::RGB, $color = 0, $backgroundColor = 0xffffff, $turboMode = false) {
$colors = $colors2 = $this->getHistogramData($channels, $turboMode ? null : Color::HSL);
sort($colors2, SORT_NUMERIC);
$min = $colors2[0];
$max = $colors2[255];
$diff = $max - $min;
$ratio = 255 / $colors2[255];
$histogram = imagecreatetruecolor(256, 128);
imagefill($histogram, 0, 0, $backgroundColor);
foreach($colors as $gray => $value) {
imageline($histogram, $gray, 255, $gray, 128 - ($colors[$gray] - $min) * 128 / $diff, $color);
}
return new Image(null, $histogram);
}
|
php
|
public function getHistogram($channels = Channel::RGB, $color = 0, $backgroundColor = 0xffffff, $turboMode = false) {
$colors = $colors2 = $this->getHistogramData($channels, $turboMode ? null : Color::HSL);
sort($colors2, SORT_NUMERIC);
$min = $colors2[0];
$max = $colors2[255];
$diff = $max - $min;
$ratio = 255 / $colors2[255];
$histogram = imagecreatetruecolor(256, 128);
imagefill($histogram, 0, 0, $backgroundColor);
foreach($colors as $gray => $value) {
imageline($histogram, $gray, 255, $gray, 128 - ($colors[$gray] - $min) * 128 / $diff, $color);
}
return new Image(null, $histogram);
}
|
[
"public",
"function",
"getHistogram",
"(",
"$",
"channels",
"=",
"Channel",
"::",
"RGB",
",",
"$",
"color",
"=",
"0",
",",
"$",
"backgroundColor",
"=",
"0xffffff",
",",
"$",
"turboMode",
"=",
"false",
")",
"{",
"$",
"colors",
"=",
"$",
"colors2",
"=",
"$",
"this",
"->",
"getHistogramData",
"(",
"$",
"channels",
",",
"$",
"turboMode",
"?",
"null",
":",
"Color",
"::",
"HSL",
")",
";",
"sort",
"(",
"$",
"colors2",
",",
"SORT_NUMERIC",
")",
";",
"$",
"min",
"=",
"$",
"colors2",
"[",
"0",
"]",
";",
"$",
"max",
"=",
"$",
"colors2",
"[",
"255",
"]",
";",
"$",
"diff",
"=",
"$",
"max",
"-",
"$",
"min",
";",
"$",
"ratio",
"=",
"255",
"/",
"$",
"colors2",
"[",
"255",
"]",
";",
"$",
"histogram",
"=",
"imagecreatetruecolor",
"(",
"256",
",",
"128",
")",
";",
"imagefill",
"(",
"$",
"histogram",
",",
"0",
",",
"0",
",",
"$",
"backgroundColor",
")",
";",
"foreach",
"(",
"$",
"colors",
"as",
"$",
"gray",
"=>",
"$",
"value",
")",
"{",
"imageline",
"(",
"$",
"histogram",
",",
"$",
"gray",
",",
"255",
",",
"$",
"gray",
",",
"128",
"-",
"(",
"$",
"colors",
"[",
"$",
"gray",
"]",
"-",
"$",
"min",
")",
"*",
"128",
"/",
"$",
"diff",
",",
"$",
"color",
")",
";",
"}",
"return",
"new",
"Image",
"(",
"null",
",",
"$",
"histogram",
")",
";",
"}"
] |
Creates an image histogram.
@param int $channels Channels to draw, possibilities: Channel::RGB (default), Channel::RED, Channel::GREEN, Channel::BLUE
@param int $color Foreground color.
@param int $backgroundColor Background color.
@param bool $turboMode Use turbo mode (less accurate).
@return Image A histogram image
|
[
"Creates",
"an",
"image",
"histogram",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L2151-L2165
|
227,675
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.changeHsl
|
public function changeHsl($hueAngle = 0, $saturationFactor = 1, $luminanceFactor = 1) {
$hueAngle /= 360;
$this->useShader('
$hue += $args[0];
$saturation *= $args[1];
$luminance *= $args[2];
', array($hueAngle, $saturationFactor, $luminanceFactor));
return $this;
}
|
php
|
public function changeHsl($hueAngle = 0, $saturationFactor = 1, $luminanceFactor = 1) {
$hueAngle /= 360;
$this->useShader('
$hue += $args[0];
$saturation *= $args[1];
$luminance *= $args[2];
', array($hueAngle, $saturationFactor, $luminanceFactor));
return $this;
}
|
[
"public",
"function",
"changeHsl",
"(",
"$",
"hueAngle",
"=",
"0",
",",
"$",
"saturationFactor",
"=",
"1",
",",
"$",
"luminanceFactor",
"=",
"1",
")",
"{",
"$",
"hueAngle",
"/=",
"360",
";",
"$",
"this",
"->",
"useShader",
"(",
"'\r\n\t\t\t$hue += $args[0];\r\n\t\t\t$saturation *= $args[1];\r\n\t\t\t$luminance *= $args[2];\r\n\t\t'",
",",
"array",
"(",
"$",
"hueAngle",
",",
"$",
"saturationFactor",
",",
"$",
"luminanceFactor",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
] |
Changes HSL values.
@param mixed $value
@return Image
|
[
"Changes",
"HSL",
"values",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L2532-L2540
|
227,676
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.useMedian
|
public function useMedian($maskWidth = 3, $maskHeight = 3) {
// initialize scanline buffer
$scanLines = array();
// precalculate some variables for better performance
$maskWidth2 = (int)($maskWidth / 2);
$maskHeight2 = (int)($maskHeight / 2);
$maskMiddle = (int)(($maskWidth * $maskHeight) / 2);
$maxY = $this->height - $maskHeight2;
$maxX = $this->width - $maskWidth2;
// scan every line of the image
for($y = $maskHeight2; $y < $maxY; ++$y) {
$medianY = $y + $maskHeight2;
$maxI = $y + $maskHeight2 + 1;
$minI = $y <= $maskHeight2 ? 0 : $y + 1;
// cache few image lines in advance, to speed up further access.
for($i = $minI; $i < $maxI; ++$i) {
for($j = 0; $j < $this->width; ++$j) {
$scanLines[$i][$j] = imagecolorat($this->image, $j, $i);
}
}
// unset old image lines from the cache.
unset($scanLines[$medianY - $maskHeight]);
for($x = $maskWidth2; $x < $maxX; ++$x) {
$medianX = $x + $maskWidth2;
$median = array();
for($n = 0; $n < $maskHeight; ++$n) {
for($m = 0; $m < $maskWidth; ++$m) {
$median[] = $scanLines[$medianY - $n][$medianX - $m];
}
}
sort($median, SORT_NUMERIC);
imagesetpixel($this->image, $x, $y, $median[$maskMiddle]);
}
}
return $this;
}
|
php
|
public function useMedian($maskWidth = 3, $maskHeight = 3) {
// initialize scanline buffer
$scanLines = array();
// precalculate some variables for better performance
$maskWidth2 = (int)($maskWidth / 2);
$maskHeight2 = (int)($maskHeight / 2);
$maskMiddle = (int)(($maskWidth * $maskHeight) / 2);
$maxY = $this->height - $maskHeight2;
$maxX = $this->width - $maskWidth2;
// scan every line of the image
for($y = $maskHeight2; $y < $maxY; ++$y) {
$medianY = $y + $maskHeight2;
$maxI = $y + $maskHeight2 + 1;
$minI = $y <= $maskHeight2 ? 0 : $y + 1;
// cache few image lines in advance, to speed up further access.
for($i = $minI; $i < $maxI; ++$i) {
for($j = 0; $j < $this->width; ++$j) {
$scanLines[$i][$j] = imagecolorat($this->image, $j, $i);
}
}
// unset old image lines from the cache.
unset($scanLines[$medianY - $maskHeight]);
for($x = $maskWidth2; $x < $maxX; ++$x) {
$medianX = $x + $maskWidth2;
$median = array();
for($n = 0; $n < $maskHeight; ++$n) {
for($m = 0; $m < $maskWidth; ++$m) {
$median[] = $scanLines[$medianY - $n][$medianX - $m];
}
}
sort($median, SORT_NUMERIC);
imagesetpixel($this->image, $x, $y, $median[$maskMiddle]);
}
}
return $this;
}
|
[
"public",
"function",
"useMedian",
"(",
"$",
"maskWidth",
"=",
"3",
",",
"$",
"maskHeight",
"=",
"3",
")",
"{",
"// initialize scanline buffer\r",
"$",
"scanLines",
"=",
"array",
"(",
")",
";",
"// precalculate some variables for better performance\r",
"$",
"maskWidth2",
"=",
"(",
"int",
")",
"(",
"$",
"maskWidth",
"/",
"2",
")",
";",
"$",
"maskHeight2",
"=",
"(",
"int",
")",
"(",
"$",
"maskHeight",
"/",
"2",
")",
";",
"$",
"maskMiddle",
"=",
"(",
"int",
")",
"(",
"(",
"$",
"maskWidth",
"*",
"$",
"maskHeight",
")",
"/",
"2",
")",
";",
"$",
"maxY",
"=",
"$",
"this",
"->",
"height",
"-",
"$",
"maskHeight2",
";",
"$",
"maxX",
"=",
"$",
"this",
"->",
"width",
"-",
"$",
"maskWidth2",
";",
"// scan every line of the image\r",
"for",
"(",
"$",
"y",
"=",
"$",
"maskHeight2",
";",
"$",
"y",
"<",
"$",
"maxY",
";",
"++",
"$",
"y",
")",
"{",
"$",
"medianY",
"=",
"$",
"y",
"+",
"$",
"maskHeight2",
";",
"$",
"maxI",
"=",
"$",
"y",
"+",
"$",
"maskHeight2",
"+",
"1",
";",
"$",
"minI",
"=",
"$",
"y",
"<=",
"$",
"maskHeight2",
"?",
"0",
":",
"$",
"y",
"+",
"1",
";",
"// cache few image lines in advance, to speed up further access.\r",
"for",
"(",
"$",
"i",
"=",
"$",
"minI",
";",
"$",
"i",
"<",
"$",
"maxI",
";",
"++",
"$",
"i",
")",
"{",
"for",
"(",
"$",
"j",
"=",
"0",
";",
"$",
"j",
"<",
"$",
"this",
"->",
"width",
";",
"++",
"$",
"j",
")",
"{",
"$",
"scanLines",
"[",
"$",
"i",
"]",
"[",
"$",
"j",
"]",
"=",
"imagecolorat",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"j",
",",
"$",
"i",
")",
";",
"}",
"}",
"// unset old image lines from the cache.\r",
"unset",
"(",
"$",
"scanLines",
"[",
"$",
"medianY",
"-",
"$",
"maskHeight",
"]",
")",
";",
"for",
"(",
"$",
"x",
"=",
"$",
"maskWidth2",
";",
"$",
"x",
"<",
"$",
"maxX",
";",
"++",
"$",
"x",
")",
"{",
"$",
"medianX",
"=",
"$",
"x",
"+",
"$",
"maskWidth2",
";",
"$",
"median",
"=",
"array",
"(",
")",
";",
"for",
"(",
"$",
"n",
"=",
"0",
";",
"$",
"n",
"<",
"$",
"maskHeight",
";",
"++",
"$",
"n",
")",
"{",
"for",
"(",
"$",
"m",
"=",
"0",
";",
"$",
"m",
"<",
"$",
"maskWidth",
";",
"++",
"$",
"m",
")",
"{",
"$",
"median",
"[",
"]",
"=",
"$",
"scanLines",
"[",
"$",
"medianY",
"-",
"$",
"n",
"]",
"[",
"$",
"medianX",
"-",
"$",
"m",
"]",
";",
"}",
"}",
"sort",
"(",
"$",
"median",
",",
"SORT_NUMERIC",
")",
";",
"imagesetpixel",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"x",
",",
"$",
"y",
",",
"$",
"median",
"[",
"$",
"maskMiddle",
"]",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
] |
Uses median filter to reduce image noise.
@param int $maskWidth Width of the median mask (default: 3)
@param int $maskHeight Height of the median mask (default: 3)
@return Image This image.
|
[
"Uses",
"median",
"filter",
"to",
"reduce",
"image",
"noise",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L2591-L2629
|
227,677
|
artur-graniszewski/tigra-image-library
|
gd2imaging.php
|
Image.createImageMatrix
|
protected function createImageMatrix($size = 0, &$ratio) {
// create two-color image
$this->toBinary(false);
// rescale if necessary (for performance reasons)
if($size > 0 && ($this->width > $size || $this->height > $size)) {
if($this->width > $this->height) {
$ratio = $size / $this->width;
} else {
$ratio = $size / $this->height;
}
$width = (int)($ratio * $this->width);
$height = (int)($ratio * $this->height);
$image = imagecreate($width, $height);
imagecopyresized($image, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height);
} else {
$ratio = 1;
$image = imagecreate($this->width, $this->height);
imagecopy($image, $this->image, 0, 0, 0, 0, $this->width, $this->height);
list($width, $height) = $this->getSize();
}
$this->image = $image;
// find the background color (fast approximation)
$bin = $this->getBinaryBuffer();
$colors = count_chars($bin);
arsort($colors, SORT_NUMERIC);
reset($colors); // HipHop for PHP compatibility.
$backgroundColor = key($colors);
// make colors negation if necessary, 0's should be used for background.
if($backgroundColor === 255) {
imagefilter($this->image, IMG_FILTER_NEGATE);
}
$image = imagecreatetruecolor($size, $size);
imagefill($image, 0, 0, 0);
imagecopy($image, $this->image, ($size - $width) / 2, ($size - $height) / 2, 0, 0, $width, $height);
$this->image = $image;
$bin = $this->getBinaryBuffer();
$this->getSize();
return $bin;
}
|
php
|
protected function createImageMatrix($size = 0, &$ratio) {
// create two-color image
$this->toBinary(false);
// rescale if necessary (for performance reasons)
if($size > 0 && ($this->width > $size || $this->height > $size)) {
if($this->width > $this->height) {
$ratio = $size / $this->width;
} else {
$ratio = $size / $this->height;
}
$width = (int)($ratio * $this->width);
$height = (int)($ratio * $this->height);
$image = imagecreate($width, $height);
imagecopyresized($image, $this->image, 0, 0, 0, 0, $width, $height, $this->width, $this->height);
} else {
$ratio = 1;
$image = imagecreate($this->width, $this->height);
imagecopy($image, $this->image, 0, 0, 0, 0, $this->width, $this->height);
list($width, $height) = $this->getSize();
}
$this->image = $image;
// find the background color (fast approximation)
$bin = $this->getBinaryBuffer();
$colors = count_chars($bin);
arsort($colors, SORT_NUMERIC);
reset($colors); // HipHop for PHP compatibility.
$backgroundColor = key($colors);
// make colors negation if necessary, 0's should be used for background.
if($backgroundColor === 255) {
imagefilter($this->image, IMG_FILTER_NEGATE);
}
$image = imagecreatetruecolor($size, $size);
imagefill($image, 0, 0, 0);
imagecopy($image, $this->image, ($size - $width) / 2, ($size - $height) / 2, 0, 0, $width, $height);
$this->image = $image;
$bin = $this->getBinaryBuffer();
$this->getSize();
return $bin;
}
|
[
"protected",
"function",
"createImageMatrix",
"(",
"$",
"size",
"=",
"0",
",",
"&",
"$",
"ratio",
")",
"{",
"// create two-color image\r",
"$",
"this",
"->",
"toBinary",
"(",
"false",
")",
";",
"// rescale if necessary (for performance reasons)\r",
"if",
"(",
"$",
"size",
">",
"0",
"&&",
"(",
"$",
"this",
"->",
"width",
">",
"$",
"size",
"||",
"$",
"this",
"->",
"height",
">",
"$",
"size",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"width",
">",
"$",
"this",
"->",
"height",
")",
"{",
"$",
"ratio",
"=",
"$",
"size",
"/",
"$",
"this",
"->",
"width",
";",
"}",
"else",
"{",
"$",
"ratio",
"=",
"$",
"size",
"/",
"$",
"this",
"->",
"height",
";",
"}",
"$",
"width",
"=",
"(",
"int",
")",
"(",
"$",
"ratio",
"*",
"$",
"this",
"->",
"width",
")",
";",
"$",
"height",
"=",
"(",
"int",
")",
"(",
"$",
"ratio",
"*",
"$",
"this",
"->",
"height",
")",
";",
"$",
"image",
"=",
"imagecreate",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"imagecopyresized",
"(",
"$",
"image",
",",
"$",
"this",
"->",
"image",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
",",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"height",
")",
";",
"}",
"else",
"{",
"$",
"ratio",
"=",
"1",
";",
"$",
"image",
"=",
"imagecreate",
"(",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"height",
")",
";",
"imagecopy",
"(",
"$",
"image",
",",
"$",
"this",
"->",
"image",
",",
"0",
",",
"0",
",",
"0",
",",
"0",
",",
"$",
"this",
"->",
"width",
",",
"$",
"this",
"->",
"height",
")",
";",
"list",
"(",
"$",
"width",
",",
"$",
"height",
")",
"=",
"$",
"this",
"->",
"getSize",
"(",
")",
";",
"}",
"$",
"this",
"->",
"image",
"=",
"$",
"image",
";",
"// find the background color (fast approximation)\r",
"$",
"bin",
"=",
"$",
"this",
"->",
"getBinaryBuffer",
"(",
")",
";",
"$",
"colors",
"=",
"count_chars",
"(",
"$",
"bin",
")",
";",
"arsort",
"(",
"$",
"colors",
",",
"SORT_NUMERIC",
")",
";",
"reset",
"(",
"$",
"colors",
")",
";",
"// HipHop for PHP compatibility.\r",
"$",
"backgroundColor",
"=",
"key",
"(",
"$",
"colors",
")",
";",
"// make colors negation if necessary, 0's should be used for background.\r",
"if",
"(",
"$",
"backgroundColor",
"===",
"255",
")",
"{",
"imagefilter",
"(",
"$",
"this",
"->",
"image",
",",
"IMG_FILTER_NEGATE",
")",
";",
"}",
"$",
"image",
"=",
"imagecreatetruecolor",
"(",
"$",
"size",
",",
"$",
"size",
")",
";",
"imagefill",
"(",
"$",
"image",
",",
"0",
",",
"0",
",",
"0",
")",
";",
"imagecopy",
"(",
"$",
"image",
",",
"$",
"this",
"->",
"image",
",",
"(",
"$",
"size",
"-",
"$",
"width",
")",
"/",
"2",
",",
"(",
"$",
"size",
"-",
"$",
"height",
")",
"/",
"2",
",",
"0",
",",
"0",
",",
"$",
"width",
",",
"$",
"height",
")",
";",
"$",
"this",
"->",
"image",
"=",
"$",
"image",
";",
"$",
"bin",
"=",
"$",
"this",
"->",
"getBinaryBuffer",
"(",
")",
";",
"$",
"this",
"->",
"getSize",
"(",
")",
";",
"return",
"$",
"bin",
";",
"}"
] |
Creates the image buffer used by the skew functions.
@param int $size Size of the matrix.
@param int $ratio Rescale ratio of this image (value is returned by this method)
@return string Binary frame buffer
|
[
"Creates",
"the",
"image",
"buffer",
"used",
"by",
"the",
"skew",
"functions",
"."
] |
b9b97ea6890f76a957e9e3c74687edc2aa95b57e
|
https://github.com/artur-graniszewski/tigra-image-library/blob/b9b97ea6890f76a957e9e3c74687edc2aa95b57e/gd2imaging.php#L2714-L2760
|
227,678
|
pagekit/razr
|
src/Extension/CoreExtension.php
|
CoreExtension.block
|
public function block($name, $value = null)
{
if ($value === null) {
return isset($this->blocks[$name]) ? $this->blocks[$name] : null;
}
$this->blocks[$name] = $value;
}
|
php
|
public function block($name, $value = null)
{
if ($value === null) {
return isset($this->blocks[$name]) ? $this->blocks[$name] : null;
}
$this->blocks[$name] = $value;
}
|
[
"public",
"function",
"block",
"(",
"$",
"name",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"blocks",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"blocks",
"[",
"$",
"name",
"]",
":",
"null",
";",
"}",
"$",
"this",
"->",
"blocks",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}"
] |
Gets or sets a block.
@param string $name
@param mixed $value
@return string
|
[
"Gets",
"or",
"sets",
"a",
"block",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Extension/CoreExtension.php#L60-L67
|
227,679
|
pagekit/razr
|
src/Extension/CoreExtension.php
|
CoreExtension.startBlock
|
public function startBlock($name)
{
if (in_array($name, $this->openBlocks)) {
throw new InvalidArgumentException(sprintf('A block "%s" is already started.', $name));
}
$this->openBlocks[] = $name;
if (!isset($this->blocks[$name])) {
$this->blocks[$name] = null;
}
ob_start();
ob_implicit_flush(0);
}
|
php
|
public function startBlock($name)
{
if (in_array($name, $this->openBlocks)) {
throw new InvalidArgumentException(sprintf('A block "%s" is already started.', $name));
}
$this->openBlocks[] = $name;
if (!isset($this->blocks[$name])) {
$this->blocks[$name] = null;
}
ob_start();
ob_implicit_flush(0);
}
|
[
"public",
"function",
"startBlock",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"openBlocks",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
"'A block \"%s\" is already started.'",
",",
"$",
"name",
")",
")",
";",
"}",
"$",
"this",
"->",
"openBlocks",
"[",
"]",
"=",
"$",
"name",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"blocks",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"blocks",
"[",
"$",
"name",
"]",
"=",
"null",
";",
"}",
"ob_start",
"(",
")",
";",
"ob_implicit_flush",
"(",
"0",
")",
";",
"}"
] |
Starts a block.
@param string $name
@throws InvalidArgumentException
|
[
"Starts",
"a",
"block",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Extension/CoreExtension.php#L75-L89
|
227,680
|
pagekit/razr
|
src/Extension/CoreExtension.php
|
CoreExtension.endBlock
|
public function endBlock()
{
if (!$this->openBlocks) {
throw new RuntimeException('No block started.');
}
$name = array_pop($this->openBlocks);
$value = ob_get_clean();
if ($this->blocks[$name] === null) {
$this->blocks[$name] = $value;
}
return $this->blocks[$name];
}
|
php
|
public function endBlock()
{
if (!$this->openBlocks) {
throw new RuntimeException('No block started.');
}
$name = array_pop($this->openBlocks);
$value = ob_get_clean();
if ($this->blocks[$name] === null) {
$this->blocks[$name] = $value;
}
return $this->blocks[$name];
}
|
[
"public",
"function",
"endBlock",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"openBlocks",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"'No block started.'",
")",
";",
"}",
"$",
"name",
"=",
"array_pop",
"(",
"$",
"this",
"->",
"openBlocks",
")",
";",
"$",
"value",
"=",
"ob_get_clean",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"blocks",
"[",
"$",
"name",
"]",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"blocks",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"}",
"return",
"$",
"this",
"->",
"blocks",
"[",
"$",
"name",
"]",
";",
"}"
] |
Stops a block.
@throws RuntimeException
@return string
|
[
"Stops",
"a",
"block",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Extension/CoreExtension.php#L97-L111
|
227,681
|
pagekit/razr
|
src/Extension/CoreExtension.php
|
CoreExtension.getConstant
|
public function getConstant($name, $object = null)
{
if ($object !== null) {
$name = sprintf('%s::%s', get_class($object), $name);
}
return constant($name);
}
|
php
|
public function getConstant($name, $object = null)
{
if ($object !== null) {
$name = sprintf('%s::%s', get_class($object), $name);
}
return constant($name);
}
|
[
"public",
"function",
"getConstant",
"(",
"$",
"name",
",",
"$",
"object",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"object",
"!==",
"null",
")",
"{",
"$",
"name",
"=",
"sprintf",
"(",
"'%s::%s'",
",",
"get_class",
"(",
"$",
"object",
")",
",",
"$",
"name",
")",
";",
"}",
"return",
"constant",
"(",
"$",
"name",
")",
";",
"}"
] |
Gets a constant from an object.
@param string $name
@param object $object
@return mixed
|
[
"Gets",
"a",
"constant",
"from",
"an",
"object",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Extension/CoreExtension.php#L131-L138
|
227,682
|
alhoqbani/ar-php
|
src/ArUtil/I18N/CharsetD.php
|
CharsetD.getCharset
|
public function getCharset($string)
{
if (preg_match('/<meta .* charset=([^\"]+)".*>/sim', $string, $matches)) {
$value = $matches[1];
} else {
$charset = $this->guess($string);
arsort($charset);
$value = key($charset);
}
return $value;
}
|
php
|
public function getCharset($string)
{
if (preg_match('/<meta .* charset=([^\"]+)".*>/sim', $string, $matches)) {
$value = $matches[1];
} else {
$charset = $this->guess($string);
arsort($charset);
$value = key($charset);
}
return $value;
}
|
[
"public",
"function",
"getCharset",
"(",
"$",
"string",
")",
"{",
"if",
"(",
"preg_match",
"(",
"'/<meta .* charset=([^\\\"]+)\".*>/sim'",
",",
"$",
"string",
",",
"$",
"matches",
")",
")",
"{",
"$",
"value",
"=",
"$",
"matches",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"$",
"charset",
"=",
"$",
"this",
"->",
"guess",
"(",
"$",
"string",
")",
";",
"arsort",
"(",
"$",
"charset",
")",
";",
"$",
"value",
"=",
"key",
"(",
"$",
"charset",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Find the most possible character set for given Arabic string in unknown
format
@param String $string Arabic string in unknown format
@return String The most possible character set for given Arabic string in
unknown format[utf-8|windows-1256|iso-8859-6]
@author Khaled Al-Sham'aa <khaled@ar-php.org>
|
[
"Find",
"the",
"most",
"possible",
"character",
"set",
"for",
"given",
"Arabic",
"string",
"in",
"unknown",
"format"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/CharsetD.php#L144-L155
|
227,683
|
authlete/authlete-php
|
src/Types/EnumTrait.php
|
EnumTrait.valueOf
|
public static function valueOf($value)
{
if ($value instanceof self)
{
return $value;
}
if (is_null($value))
{
return null;
}
$class = get_called_class();
if (!is_string($value))
{
throw new \InvalidArgumentException("The given object is neither $class nor string.");
}
foreach (self::$values as $element)
{
if ($element->name() == $value)
{
return $element;
}
}
throw new \InvalidArgumentException("The given string cannot be parsed as $class.");
}
|
php
|
public static function valueOf($value)
{
if ($value instanceof self)
{
return $value;
}
if (is_null($value))
{
return null;
}
$class = get_called_class();
if (!is_string($value))
{
throw new \InvalidArgumentException("The given object is neither $class nor string.");
}
foreach (self::$values as $element)
{
if ($element->name() == $value)
{
return $element;
}
}
throw new \InvalidArgumentException("The given string cannot be parsed as $class.");
}
|
[
"public",
"static",
"function",
"valueOf",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"self",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"class",
"=",
"get_called_class",
"(",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The given object is neither $class nor string.\"",
")",
";",
"}",
"foreach",
"(",
"self",
"::",
"$",
"values",
"as",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"->",
"name",
"(",
")",
"==",
"$",
"value",
")",
"{",
"return",
"$",
"element",
";",
"}",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The given string cannot be parsed as $class.\"",
")",
";",
"}"
] |
Get an instance of this class that the given argument represents.
If the given argument is an instance of this class, the instance
itself is returned.
Otherwise, if the given argument is `null`, `null` is returned.
Otherwise, if the type of the given argument is not `string`,
an `InvalidArgumentException` is returned.
Otherwise, a class variable whose name is equal to the given
argument is looked up. If found, the instance is returned.
If not found, an `InvalidArgumentException` is thrown.
@param mixed $value
A string that represents an instance of this class, or an
instance of this class, or `null`.
@return static
An instance of this class.
|
[
"Get",
"an",
"instance",
"of",
"this",
"class",
"that",
"the",
"given",
"argument",
"represents",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Types/EnumTrait.php#L109-L137
|
227,684
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Arabic.php
|
Arabic.load
|
public function load($library)
{
if ($this->_compatibleMode
&& array_key_exists($library, $this->_compatible)
) {
$library = $this->_compatible[$library];
}
$library = "\\ArUtil\\I18N\\$library";
$this->myFile = $library;
$this->myClass = $library;
$class = $library;
// if (!$this->_useAutoload) {
// include_once self::getClassFile($this->myFile);
// }
if (!isset($this->myObject)) {
$this->myObject = new $class();
}
$this->{$library} = &$this->myObject;
}
|
php
|
public function load($library)
{
if ($this->_compatibleMode
&& array_key_exists($library, $this->_compatible)
) {
$library = $this->_compatible[$library];
}
$library = "\\ArUtil\\I18N\\$library";
$this->myFile = $library;
$this->myClass = $library;
$class = $library;
// if (!$this->_useAutoload) {
// include_once self::getClassFile($this->myFile);
// }
if (!isset($this->myObject)) {
$this->myObject = new $class();
}
$this->{$library} = &$this->myObject;
}
|
[
"public",
"function",
"load",
"(",
"$",
"library",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"_compatibleMode",
"&&",
"array_key_exists",
"(",
"$",
"library",
",",
"$",
"this",
"->",
"_compatible",
")",
")",
"{",
"$",
"library",
"=",
"$",
"this",
"->",
"_compatible",
"[",
"$",
"library",
"]",
";",
"}",
"$",
"library",
"=",
"\"\\\\ArUtil\\\\I18N\\\\$library\"",
";",
"$",
"this",
"->",
"myFile",
"=",
"$",
"library",
";",
"$",
"this",
"->",
"myClass",
"=",
"$",
"library",
";",
"$",
"class",
"=",
"$",
"library",
";",
"// if (!$this->_useAutoload) {",
"// include_once self::getClassFile($this->myFile);",
"// }",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"myObject",
")",
")",
"{",
"$",
"this",
"->",
"myObject",
"=",
"new",
"$",
"class",
"(",
")",
";",
"}",
"$",
"this",
"->",
"{",
"$",
"library",
"}",
"=",
"&",
"$",
"this",
"->",
"myObject",
";",
"}"
] |
Load selected Arabic library and create an instance of its class
@param string $library Library name
@return null
@author Khaled Al-Shamaa <khaled@ar-php.org>
|
[
"Load",
"selected",
"Arabic",
"library",
"and",
"create",
"an",
"instance",
"of",
"its",
"class"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Arabic.php#L217-L238
|
227,685
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Arabic.php
|
Arabic.setInputCharset
|
public function setInputCharset($charset)
{
$flag = true;
$charset = strtolower($charset);
$charsets = array('utf-8', 'windows-1256', 'cp1256', 'iso-8859-6');
if (in_array($charset, $charsets)) {
if ($charset == 'windows-1256') {
$charset = 'cp1256';
}
$this->_inputCharset = $charset;
} else {
$flag = false;
}
return $flag;
}
|
php
|
public function setInputCharset($charset)
{
$flag = true;
$charset = strtolower($charset);
$charsets = array('utf-8', 'windows-1256', 'cp1256', 'iso-8859-6');
if (in_array($charset, $charsets)) {
if ($charset == 'windows-1256') {
$charset = 'cp1256';
}
$this->_inputCharset = $charset;
} else {
$flag = false;
}
return $flag;
}
|
[
"public",
"function",
"setInputCharset",
"(",
"$",
"charset",
")",
"{",
"$",
"flag",
"=",
"true",
";",
"$",
"charset",
"=",
"strtolower",
"(",
"$",
"charset",
")",
";",
"$",
"charsets",
"=",
"array",
"(",
"'utf-8'",
",",
"'windows-1256'",
",",
"'cp1256'",
",",
"'iso-8859-6'",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"charset",
",",
"$",
"charsets",
")",
")",
"{",
"if",
"(",
"$",
"charset",
"==",
"'windows-1256'",
")",
"{",
"$",
"charset",
"=",
"'cp1256'",
";",
"}",
"$",
"this",
"->",
"_inputCharset",
"=",
"$",
"charset",
";",
"}",
"else",
"{",
"$",
"flag",
"=",
"false",
";",
"}",
"return",
"$",
"flag",
";",
"}"
] |
Set charset used in class input Arabic strings
@param string $charset Input charset [utf-8|windows-1256|iso-8859-6]
@return TRUE if success, or FALSE if fail
@author Khaled Al-Shamaa <khaled@ar-php.org>
|
[
"Set",
"charset",
"used",
"in",
"class",
"input",
"Arabic",
"strings"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Arabic.php#L342-L359
|
227,686
|
alhoqbani/ar-php
|
src/ArUtil/I18N/Arabic.php
|
Arabic.setOutputCharset
|
public function setOutputCharset($charset)
{
$flag = true;
$charset = strtolower($charset);
$charsets = array('utf-8', 'windows-1256', 'cp1256', 'iso-8859-6');
if (in_array($charset, $charsets)) {
if ($charset == 'windows-1256') {
$charset = 'cp1256';
}
$this->_outputCharset = $charset;
} else {
$flag = false;
}
return $flag;
}
|
php
|
public function setOutputCharset($charset)
{
$flag = true;
$charset = strtolower($charset);
$charsets = array('utf-8', 'windows-1256', 'cp1256', 'iso-8859-6');
if (in_array($charset, $charsets)) {
if ($charset == 'windows-1256') {
$charset = 'cp1256';
}
$this->_outputCharset = $charset;
} else {
$flag = false;
}
return $flag;
}
|
[
"public",
"function",
"setOutputCharset",
"(",
"$",
"charset",
")",
"{",
"$",
"flag",
"=",
"true",
";",
"$",
"charset",
"=",
"strtolower",
"(",
"$",
"charset",
")",
";",
"$",
"charsets",
"=",
"array",
"(",
"'utf-8'",
",",
"'windows-1256'",
",",
"'cp1256'",
",",
"'iso-8859-6'",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"charset",
",",
"$",
"charsets",
")",
")",
"{",
"if",
"(",
"$",
"charset",
"==",
"'windows-1256'",
")",
"{",
"$",
"charset",
"=",
"'cp1256'",
";",
"}",
"$",
"this",
"->",
"_outputCharset",
"=",
"$",
"charset",
";",
"}",
"else",
"{",
"$",
"flag",
"=",
"false",
";",
"}",
"return",
"$",
"flag",
";",
"}"
] |
Set charset used in class output Arabic strings
@param string $charset Output charset [utf-8|windows-1256|iso-8859-6]
@return boolean TRUE if success, or FALSE if fail
@author Khaled Al-Shamaa <khaled@ar-php.org>
|
[
"Set",
"charset",
"used",
"in",
"class",
"output",
"Arabic",
"strings"
] |
27a451d79591f7e49a300e97e3b32ecf24934c86
|
https://github.com/alhoqbani/ar-php/blob/27a451d79591f7e49a300e97e3b32ecf24934c86/src/ArUtil/I18N/Arabic.php#L369-L386
|
227,687
|
jumilla/laravel-versionia
|
sources/Commands/DatabaseStatusCommand.php
|
DatabaseStatusCommand.showMigrations
|
protected function showMigrations(Migrator $migrator)
{
$this->line('<comment>Migrations</comment>');
$groups = $migrator->migrationGroups();
if (count($groups) > 0) {
// get [$group => $items]
$installed_migrations = $migrator->installedMigrationsByDesc();
foreach ($groups as $group) {
// [$items] to [$installed_versions]
$installed_versions = $installed_migrations->get($group, collect())->pluck('version');
// [$versions] to $latest_version
$latest_installed_version = $installed_versions->get(0, Migrator::VERSION_NULL);
// enum definition
foreach ($migrator->migrationVersionsByDesc($group) as $version => $class) {
$installed = $installed_versions->contains($version);
if ($version === $latest_installed_version) {
$mark = '*';
} else {
$mark = $installed ? '-' : ' ';
}
if (!class_exists($class)) {
$this->line("{$mark} <info>[{$group}/{$version}]</info> <error>{$class}</error>");
$this->line('');
$this->error('Error: Class not found.');
continue;
}
$migration = new $class();
if (!$migration instanceof Migration) {
$this->line("{$mark} <info>[{$group}/{$version}]</info> <error>{$class}</error>");
$this->line('');
$this->error('Error: Must inherit from class "Illuminate\Database\Migrations\Migration".');
continue;
}
$this->line("{$mark} <info>[{$group}/{$version}]</info> {$class}");
}
$this->line('');
}
} else {
$this->info('Nothing.');
$this->line('');
}
}
|
php
|
protected function showMigrations(Migrator $migrator)
{
$this->line('<comment>Migrations</comment>');
$groups = $migrator->migrationGroups();
if (count($groups) > 0) {
// get [$group => $items]
$installed_migrations = $migrator->installedMigrationsByDesc();
foreach ($groups as $group) {
// [$items] to [$installed_versions]
$installed_versions = $installed_migrations->get($group, collect())->pluck('version');
// [$versions] to $latest_version
$latest_installed_version = $installed_versions->get(0, Migrator::VERSION_NULL);
// enum definition
foreach ($migrator->migrationVersionsByDesc($group) as $version => $class) {
$installed = $installed_versions->contains($version);
if ($version === $latest_installed_version) {
$mark = '*';
} else {
$mark = $installed ? '-' : ' ';
}
if (!class_exists($class)) {
$this->line("{$mark} <info>[{$group}/{$version}]</info> <error>{$class}</error>");
$this->line('');
$this->error('Error: Class not found.');
continue;
}
$migration = new $class();
if (!$migration instanceof Migration) {
$this->line("{$mark} <info>[{$group}/{$version}]</info> <error>{$class}</error>");
$this->line('');
$this->error('Error: Must inherit from class "Illuminate\Database\Migrations\Migration".');
continue;
}
$this->line("{$mark} <info>[{$group}/{$version}]</info> {$class}");
}
$this->line('');
}
} else {
$this->info('Nothing.');
$this->line('');
}
}
|
[
"protected",
"function",
"showMigrations",
"(",
"Migrator",
"$",
"migrator",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"'<comment>Migrations</comment>'",
")",
";",
"$",
"groups",
"=",
"$",
"migrator",
"->",
"migrationGroups",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"groups",
")",
">",
"0",
")",
"{",
"// get [$group => $items]",
"$",
"installed_migrations",
"=",
"$",
"migrator",
"->",
"installedMigrationsByDesc",
"(",
")",
";",
"foreach",
"(",
"$",
"groups",
"as",
"$",
"group",
")",
"{",
"// [$items] to [$installed_versions]",
"$",
"installed_versions",
"=",
"$",
"installed_migrations",
"->",
"get",
"(",
"$",
"group",
",",
"collect",
"(",
")",
")",
"->",
"pluck",
"(",
"'version'",
")",
";",
"// [$versions] to $latest_version",
"$",
"latest_installed_version",
"=",
"$",
"installed_versions",
"->",
"get",
"(",
"0",
",",
"Migrator",
"::",
"VERSION_NULL",
")",
";",
"// enum definition",
"foreach",
"(",
"$",
"migrator",
"->",
"migrationVersionsByDesc",
"(",
"$",
"group",
")",
"as",
"$",
"version",
"=>",
"$",
"class",
")",
"{",
"$",
"installed",
"=",
"$",
"installed_versions",
"->",
"contains",
"(",
"$",
"version",
")",
";",
"if",
"(",
"$",
"version",
"===",
"$",
"latest_installed_version",
")",
"{",
"$",
"mark",
"=",
"'*'",
";",
"}",
"else",
"{",
"$",
"mark",
"=",
"$",
"installed",
"?",
"'-'",
":",
"' '",
";",
"}",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"\"{$mark} <info>[{$group}/{$version}]</info> <error>{$class}</error>\"",
")",
";",
"$",
"this",
"->",
"line",
"(",
"''",
")",
";",
"$",
"this",
"->",
"error",
"(",
"'Error: Class not found.'",
")",
";",
"continue",
";",
"}",
"$",
"migration",
"=",
"new",
"$",
"class",
"(",
")",
";",
"if",
"(",
"!",
"$",
"migration",
"instanceof",
"Migration",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"\"{$mark} <info>[{$group}/{$version}]</info> <error>{$class}</error>\"",
")",
";",
"$",
"this",
"->",
"line",
"(",
"''",
")",
";",
"$",
"this",
"->",
"error",
"(",
"'Error: Must inherit from class \"Illuminate\\Database\\Migrations\\Migration\".'",
")",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"line",
"(",
"\"{$mark} <info>[{$group}/{$version}]</info> {$class}\"",
")",
";",
"}",
"$",
"this",
"->",
"line",
"(",
"''",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"info",
"(",
"'Nothing.'",
")",
";",
"$",
"this",
"->",
"line",
"(",
"''",
")",
";",
"}",
"}"
] |
Show migration infomation.
@param \Jumilla\Versionia\Laravel\Migrator $migrator
|
[
"Show",
"migration",
"infomation",
"."
] |
08ca0081c856c658d8b235c758c242b80b25da13
|
https://github.com/jumilla/laravel-versionia/blob/08ca0081c856c658d8b235c758c242b80b25da13/sources/Commands/DatabaseStatusCommand.php#L48-L100
|
227,688
|
jumilla/laravel-versionia
|
sources/Commands/DatabaseStatusCommand.php
|
DatabaseStatusCommand.showSeeds
|
protected function showSeeds(Migrator $migrator)
{
$this->line('<comment>Seeds</comment>');
$seeds = $migrator->seedNames();
if (count($seeds) > 0) {
$default_seed = $migrator->defaultSeed();
foreach ($seeds as $seed) {
$class = $migrator->seedClass($seed);
$status_mark = ' ';
$default_mark = $seed == $default_seed ? '(default)' : '';
if (!class_exists($class)) {
$this->line("{$status_mark} <info>[{$seed}]</info> <error>{$class}</error>");
$this->line('');
$this->error('Error: Class not found.');
continue;
}
$this->line("{$status_mark} <comment>{$default_mark}</comment><info>[{$seed}]</info> {$class}");
}
if ($default_seed && !in_array($default_seed, $seeds)) {
$this->line('');
$this->error("Error: default seed '{$default_seed}' is not defined.");
}
} else {
$this->info('Nothing.');
}
$this->line('');
}
|
php
|
protected function showSeeds(Migrator $migrator)
{
$this->line('<comment>Seeds</comment>');
$seeds = $migrator->seedNames();
if (count($seeds) > 0) {
$default_seed = $migrator->defaultSeed();
foreach ($seeds as $seed) {
$class = $migrator->seedClass($seed);
$status_mark = ' ';
$default_mark = $seed == $default_seed ? '(default)' : '';
if (!class_exists($class)) {
$this->line("{$status_mark} <info>[{$seed}]</info> <error>{$class}</error>");
$this->line('');
$this->error('Error: Class not found.');
continue;
}
$this->line("{$status_mark} <comment>{$default_mark}</comment><info>[{$seed}]</info> {$class}");
}
if ($default_seed && !in_array($default_seed, $seeds)) {
$this->line('');
$this->error("Error: default seed '{$default_seed}' is not defined.");
}
} else {
$this->info('Nothing.');
}
$this->line('');
}
|
[
"protected",
"function",
"showSeeds",
"(",
"Migrator",
"$",
"migrator",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"'<comment>Seeds</comment>'",
")",
";",
"$",
"seeds",
"=",
"$",
"migrator",
"->",
"seedNames",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"seeds",
")",
">",
"0",
")",
"{",
"$",
"default_seed",
"=",
"$",
"migrator",
"->",
"defaultSeed",
"(",
")",
";",
"foreach",
"(",
"$",
"seeds",
"as",
"$",
"seed",
")",
"{",
"$",
"class",
"=",
"$",
"migrator",
"->",
"seedClass",
"(",
"$",
"seed",
")",
";",
"$",
"status_mark",
"=",
"' '",
";",
"$",
"default_mark",
"=",
"$",
"seed",
"==",
"$",
"default_seed",
"?",
"'(default)'",
":",
"''",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"class",
")",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"\"{$status_mark} <info>[{$seed}]</info> <error>{$class}</error>\"",
")",
";",
"$",
"this",
"->",
"line",
"(",
"''",
")",
";",
"$",
"this",
"->",
"error",
"(",
"'Error: Class not found.'",
")",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"line",
"(",
"\"{$status_mark} <comment>{$default_mark}</comment><info>[{$seed}]</info> {$class}\"",
")",
";",
"}",
"if",
"(",
"$",
"default_seed",
"&&",
"!",
"in_array",
"(",
"$",
"default_seed",
",",
"$",
"seeds",
")",
")",
"{",
"$",
"this",
"->",
"line",
"(",
"''",
")",
";",
"$",
"this",
"->",
"error",
"(",
"\"Error: default seed '{$default_seed}' is not defined.\"",
")",
";",
"}",
"}",
"else",
"{",
"$",
"this",
"->",
"info",
"(",
"'Nothing.'",
")",
";",
"}",
"$",
"this",
"->",
"line",
"(",
"''",
")",
";",
"}"
] |
Show seed infomation.
@param \Jumilla\Versionia\Laravel\Migrator $migrator
|
[
"Show",
"seed",
"infomation",
"."
] |
08ca0081c856c658d8b235c758c242b80b25da13
|
https://github.com/jumilla/laravel-versionia/blob/08ca0081c856c658d8b235c758c242b80b25da13/sources/Commands/DatabaseStatusCommand.php#L107-L141
|
227,689
|
jumilla/laravel-versionia
|
sources/Commands/DatabaseRefreshCommand.php
|
DatabaseRefreshCommand.doRefresh
|
protected function doRefresh(Migrator $migrator)
{
// retreive installed versions
$installed_migrations = $migrator->installedMigrationsByDesc();
// downgrade
foreach ($installed_migrations as $group => $migrations) {
foreach ($migrations as $data) {
$this->infoDowngrade($group, $data->version, $data->class);
$migrator->doDowngrade($group, $data->version);
}
}
// upgrade
foreach ($migrator->migrationGroups() as $group) {
foreach ($migrator->migrationVersions($group) as $version => $class) {
$this->infoUpgrade($group, $version, $class);
$migrator->doUpgrade($group, $version, $class);
}
}
}
|
php
|
protected function doRefresh(Migrator $migrator)
{
// retreive installed versions
$installed_migrations = $migrator->installedMigrationsByDesc();
// downgrade
foreach ($installed_migrations as $group => $migrations) {
foreach ($migrations as $data) {
$this->infoDowngrade($group, $data->version, $data->class);
$migrator->doDowngrade($group, $data->version);
}
}
// upgrade
foreach ($migrator->migrationGroups() as $group) {
foreach ($migrator->migrationVersions($group) as $version => $class) {
$this->infoUpgrade($group, $version, $class);
$migrator->doUpgrade($group, $version, $class);
}
}
}
|
[
"protected",
"function",
"doRefresh",
"(",
"Migrator",
"$",
"migrator",
")",
"{",
"// retreive installed versions",
"$",
"installed_migrations",
"=",
"$",
"migrator",
"->",
"installedMigrationsByDesc",
"(",
")",
";",
"// downgrade",
"foreach",
"(",
"$",
"installed_migrations",
"as",
"$",
"group",
"=>",
"$",
"migrations",
")",
"{",
"foreach",
"(",
"$",
"migrations",
"as",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"infoDowngrade",
"(",
"$",
"group",
",",
"$",
"data",
"->",
"version",
",",
"$",
"data",
"->",
"class",
")",
";",
"$",
"migrator",
"->",
"doDowngrade",
"(",
"$",
"group",
",",
"$",
"data",
"->",
"version",
")",
";",
"}",
"}",
"// upgrade",
"foreach",
"(",
"$",
"migrator",
"->",
"migrationGroups",
"(",
")",
"as",
"$",
"group",
")",
"{",
"foreach",
"(",
"$",
"migrator",
"->",
"migrationVersions",
"(",
"$",
"group",
")",
"as",
"$",
"version",
"=>",
"$",
"class",
")",
"{",
"$",
"this",
"->",
"infoUpgrade",
"(",
"$",
"group",
",",
"$",
"version",
",",
"$",
"class",
")",
";",
"$",
"migrator",
"->",
"doUpgrade",
"(",
"$",
"group",
",",
"$",
"version",
",",
"$",
"class",
")",
";",
"}",
"}",
"}"
] |
Execute clean and upgrade.
@param \Jumilla\Versionia\Laravel\Migrator $migrator
|
[
"Execute",
"clean",
"and",
"upgrade",
"."
] |
08ca0081c856c658d8b235c758c242b80b25da13
|
https://github.com/jumilla/laravel-versionia/blob/08ca0081c856c658d8b235c758c242b80b25da13/sources/Commands/DatabaseRefreshCommand.php#L60-L82
|
227,690
|
concrete5/doctrine-xml
|
src/Checker.php
|
Checker.checkString
|
public static function checkString($xml, $filename = '')
{
$doc = Utilities::stringToDOMDocument($xml, $filename);
$errors = null;
$preUseInternalErrors = libxml_use_internal_errors(true);
try {
if (!$doc->schemaValidateSource(static::getSchema())) {
$errors = Utilities::explainLibXmlErrors($filename);
}
} catch (Exception $x) {
libxml_use_internal_errors($preUseInternalErrors);
libxml_clear_errors();
throw $x;
}
libxml_use_internal_errors($preUseInternalErrors);
return $errors;
}
|
php
|
public static function checkString($xml, $filename = '')
{
$doc = Utilities::stringToDOMDocument($xml, $filename);
$errors = null;
$preUseInternalErrors = libxml_use_internal_errors(true);
try {
if (!$doc->schemaValidateSource(static::getSchema())) {
$errors = Utilities::explainLibXmlErrors($filename);
}
} catch (Exception $x) {
libxml_use_internal_errors($preUseInternalErrors);
libxml_clear_errors();
throw $x;
}
libxml_use_internal_errors($preUseInternalErrors);
return $errors;
}
|
[
"public",
"static",
"function",
"checkString",
"(",
"$",
"xml",
",",
"$",
"filename",
"=",
"''",
")",
"{",
"$",
"doc",
"=",
"Utilities",
"::",
"stringToDOMDocument",
"(",
"$",
"xml",
",",
"$",
"filename",
")",
";",
"$",
"errors",
"=",
"null",
";",
"$",
"preUseInternalErrors",
"=",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"try",
"{",
"if",
"(",
"!",
"$",
"doc",
"->",
"schemaValidateSource",
"(",
"static",
"::",
"getSchema",
"(",
")",
")",
")",
"{",
"$",
"errors",
"=",
"Utilities",
"::",
"explainLibXmlErrors",
"(",
"$",
"filename",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"x",
")",
"{",
"libxml_use_internal_errors",
"(",
"$",
"preUseInternalErrors",
")",
";",
"libxml_clear_errors",
"(",
")",
";",
"throw",
"$",
"x",
";",
"}",
"libxml_use_internal_errors",
"(",
"$",
"preUseInternalErrors",
")",
";",
"return",
"$",
"errors",
";",
"}"
] |
Check if an xml code satisfy the schema.
@param string $xml The xml code to verify
@param string $filename The name of the file from which the xml code has been read from
@return string[]|null Return null of all is ok, a list of errors otherwise
|
[
"Check",
"if",
"an",
"xml",
"code",
"satisfy",
"the",
"schema",
"."
] |
03f1209d42477070a58d29e5af15688b96c66b56
|
https://github.com/concrete5/doctrine-xml/blob/03f1209d42477070a58d29e5af15688b96c66b56/src/Checker.php#L19-L36
|
227,691
|
concrete5/doctrine-xml
|
src/Checker.php
|
Checker.checkFile
|
public static function checkFile($filename)
{
$fileContents = (is_file($filename) && is_readable($filename)) ? @file_get_contents($filename) : false;
if ($fileContents === false) {
throw new Exception('Failed to load the file '.$filename);
}
return static::checkString($fileContents, $filename);
}
|
php
|
public static function checkFile($filename)
{
$fileContents = (is_file($filename) && is_readable($filename)) ? @file_get_contents($filename) : false;
if ($fileContents === false) {
throw new Exception('Failed to load the file '.$filename);
}
return static::checkString($fileContents, $filename);
}
|
[
"public",
"static",
"function",
"checkFile",
"(",
"$",
"filename",
")",
"{",
"$",
"fileContents",
"=",
"(",
"is_file",
"(",
"$",
"filename",
")",
"&&",
"is_readable",
"(",
"$",
"filename",
")",
")",
"?",
"@",
"file_get_contents",
"(",
"$",
"filename",
")",
":",
"false",
";",
"if",
"(",
"$",
"fileContents",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Failed to load the file '",
".",
"$",
"filename",
")",
";",
"}",
"return",
"static",
"::",
"checkString",
"(",
"$",
"fileContents",
",",
"$",
"filename",
")",
";",
"}"
] |
Check if an xml file satisfy the schema.
@param string $filename The name of the file to verify
@throws Exception
@return string[]|null Return null of all is ok, a list of errors otherwise
|
[
"Check",
"if",
"an",
"xml",
"file",
"satisfy",
"the",
"schema",
"."
] |
03f1209d42477070a58d29e5af15688b96c66b56
|
https://github.com/concrete5/doctrine-xml/blob/03f1209d42477070a58d29e5af15688b96c66b56/src/Checker.php#L46-L54
|
227,692
|
concrete5/doctrine-xml
|
src/Checker.php
|
Checker.getSchema
|
protected static function getSchema()
{
static $cache = null;
if (!isset($cache)) {
$schemaFile = __DIR__.'/doctrine-xml-0.5.xsd';
$s = (is_file($schemaFile) && is_readable($schemaFile)) ? @file_get_contents($schemaFile) : false;
if ($s === false) {
throw new Exception('Failed to load the schema file '.$schemaFile);
}
$cache = $s;
}
return $cache;
}
|
php
|
protected static function getSchema()
{
static $cache = null;
if (!isset($cache)) {
$schemaFile = __DIR__.'/doctrine-xml-0.5.xsd';
$s = (is_file($schemaFile) && is_readable($schemaFile)) ? @file_get_contents($schemaFile) : false;
if ($s === false) {
throw new Exception('Failed to load the schema file '.$schemaFile);
}
$cache = $s;
}
return $cache;
}
|
[
"protected",
"static",
"function",
"getSchema",
"(",
")",
"{",
"static",
"$",
"cache",
"=",
"null",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"cache",
")",
")",
"{",
"$",
"schemaFile",
"=",
"__DIR__",
".",
"'/doctrine-xml-0.5.xsd'",
";",
"$",
"s",
"=",
"(",
"is_file",
"(",
"$",
"schemaFile",
")",
"&&",
"is_readable",
"(",
"$",
"schemaFile",
")",
")",
"?",
"@",
"file_get_contents",
"(",
"$",
"schemaFile",
")",
":",
"false",
";",
"if",
"(",
"$",
"s",
"===",
"false",
")",
"{",
"throw",
"new",
"Exception",
"(",
"'Failed to load the schema file '",
".",
"$",
"schemaFile",
")",
";",
"}",
"$",
"cache",
"=",
"$",
"s",
";",
"}",
"return",
"$",
"cache",
";",
"}"
] |
Returns the xml schema.
@throws Exception Throws an Exception if the xsd file couldn't be read.
@return string
|
[
"Returns",
"the",
"xml",
"schema",
"."
] |
03f1209d42477070a58d29e5af15688b96c66b56
|
https://github.com/concrete5/doctrine-xml/blob/03f1209d42477070a58d29e5af15688b96c66b56/src/Checker.php#L62-L75
|
227,693
|
pagekit/razr
|
src/Parser.php
|
Parser.parse
|
public function parse($stream, $filename = null)
{
$this->stream = $stream;
$this->filename = $filename;
$this->variables = array();
return $this->parseMain();
}
|
php
|
public function parse($stream, $filename = null)
{
$this->stream = $stream;
$this->filename = $filename;
$this->variables = array();
return $this->parseMain();
}
|
[
"public",
"function",
"parse",
"(",
"$",
"stream",
",",
"$",
"filename",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"stream",
"=",
"$",
"stream",
";",
"$",
"this",
"->",
"filename",
"=",
"$",
"filename",
";",
"$",
"this",
"->",
"variables",
"=",
"array",
"(",
")",
";",
"return",
"$",
"this",
"->",
"parseMain",
"(",
")",
";",
"}"
] |
Parsing method.
@param TokenStream $stream
@param string $filename
@return string
|
[
"Parsing",
"method",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Parser.php#L29-L36
|
227,694
|
pagekit/razr
|
src/Parser.php
|
Parser.parseMain
|
public function parseMain()
{
$out = '';
while ($token = $this->stream->next()) {
if ($token->test(T_COMMENT, '/* OUTPUT */')) {
$out .= $this->parseOutput();
} elseif ($token->test(T_COMMENT, '/* DIRECTIVE */')) {
$out .= $this->parseDirective();
} else {
$out .= $token->getValue();
}
}
if ($this->variables) {
$info = sprintf('<?php /* %s */ extract(%s, EXTR_SKIP) ?>', $this->filename, str_replace("\n", '', var_export($this->variables, true)));
} else {
$info = sprintf('<?php /* %s */ ?>', $this->filename);
}
return $info.$out;
}
|
php
|
public function parseMain()
{
$out = '';
while ($token = $this->stream->next()) {
if ($token->test(T_COMMENT, '/* OUTPUT */')) {
$out .= $this->parseOutput();
} elseif ($token->test(T_COMMENT, '/* DIRECTIVE */')) {
$out .= $this->parseDirective();
} else {
$out .= $token->getValue();
}
}
if ($this->variables) {
$info = sprintf('<?php /* %s */ extract(%s, EXTR_SKIP) ?>', $this->filename, str_replace("\n", '', var_export($this->variables, true)));
} else {
$info = sprintf('<?php /* %s */ ?>', $this->filename);
}
return $info.$out;
}
|
[
"public",
"function",
"parseMain",
"(",
")",
"{",
"$",
"out",
"=",
"''",
";",
"while",
"(",
"$",
"token",
"=",
"$",
"this",
"->",
"stream",
"->",
"next",
"(",
")",
")",
"{",
"if",
"(",
"$",
"token",
"->",
"test",
"(",
"T_COMMENT",
",",
"'/* OUTPUT */'",
")",
")",
"{",
"$",
"out",
".=",
"$",
"this",
"->",
"parseOutput",
"(",
")",
";",
"}",
"elseif",
"(",
"$",
"token",
"->",
"test",
"(",
"T_COMMENT",
",",
"'/* DIRECTIVE */'",
")",
")",
"{",
"$",
"out",
".=",
"$",
"this",
"->",
"parseDirective",
"(",
")",
";",
"}",
"else",
"{",
"$",
"out",
".=",
"$",
"token",
"->",
"getValue",
"(",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"variables",
")",
"{",
"$",
"info",
"=",
"sprintf",
"(",
"'<?php /* %s */ extract(%s, EXTR_SKIP) ?>'",
",",
"$",
"this",
"->",
"filename",
",",
"str_replace",
"(",
"\"\\n\"",
",",
"''",
",",
"var_export",
"(",
"$",
"this",
"->",
"variables",
",",
"true",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"info",
"=",
"sprintf",
"(",
"'<?php /* %s */ ?>'",
",",
"$",
"this",
"->",
"filename",
")",
";",
"}",
"return",
"$",
"info",
".",
"$",
"out",
";",
"}"
] |
Parse main.
@return string
|
[
"Parse",
"main",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Parser.php#L43-L64
|
227,695
|
pagekit/razr
|
src/Parser.php
|
Parser.parseDirective
|
public function parseDirective()
{
$out = '';
foreach ($this->engine->getDirectives() as $directive) {
if ($out = $directive->parse($this->stream, $this->stream->get())) {
break;
}
}
return $out;
}
|
php
|
public function parseDirective()
{
$out = '';
foreach ($this->engine->getDirectives() as $directive) {
if ($out = $directive->parse($this->stream, $this->stream->get())) {
break;
}
}
return $out;
}
|
[
"public",
"function",
"parseDirective",
"(",
")",
"{",
"$",
"out",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"engine",
"->",
"getDirectives",
"(",
")",
"as",
"$",
"directive",
")",
"{",
"if",
"(",
"$",
"out",
"=",
"$",
"directive",
"->",
"parse",
"(",
"$",
"this",
"->",
"stream",
",",
"$",
"this",
"->",
"stream",
"->",
"get",
"(",
")",
")",
")",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"out",
";",
"}"
] |
Parse directive.
@return string
|
[
"Parse",
"directive",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Parser.php#L87-L98
|
227,696
|
pagekit/razr
|
src/Parser.php
|
Parser.parseExpression
|
public function parseExpression()
{
$out = '';
$brackets = array();
do {
if ($token = $this->stream->nextIf(T_STRING)) {
$name = $token->getValue();
if ($this->stream->test('(') && $this->engine->getFunction($name)) {
$out .= sprintf("\$this->callFunction('%s', array%s)", $name, $this->parseExpression());
} else {
$out .= $name;
}
} elseif ($token = $this->stream->nextIf(T_VARIABLE)) {
$out .= $this->parseSubscript($var = $token->getValue());
$this->variables[ltrim($var, '$')] = null;
} else {
$token = $this->stream->next();
if ($token->test(array('(', '['))) {
array_push($brackets, $token);
} elseif ($token->test(array(')', ']'))) {
array_pop($brackets);
}
$out .= $token->getValue();
}
} while (!empty($brackets));
return $out;
}
|
php
|
public function parseExpression()
{
$out = '';
$brackets = array();
do {
if ($token = $this->stream->nextIf(T_STRING)) {
$name = $token->getValue();
if ($this->stream->test('(') && $this->engine->getFunction($name)) {
$out .= sprintf("\$this->callFunction('%s', array%s)", $name, $this->parseExpression());
} else {
$out .= $name;
}
} elseif ($token = $this->stream->nextIf(T_VARIABLE)) {
$out .= $this->parseSubscript($var = $token->getValue());
$this->variables[ltrim($var, '$')] = null;
} else {
$token = $this->stream->next();
if ($token->test(array('(', '['))) {
array_push($brackets, $token);
} elseif ($token->test(array(')', ']'))) {
array_pop($brackets);
}
$out .= $token->getValue();
}
} while (!empty($brackets));
return $out;
}
|
[
"public",
"function",
"parseExpression",
"(",
")",
"{",
"$",
"out",
"=",
"''",
";",
"$",
"brackets",
"=",
"array",
"(",
")",
";",
"do",
"{",
"if",
"(",
"$",
"token",
"=",
"$",
"this",
"->",
"stream",
"->",
"nextIf",
"(",
"T_STRING",
")",
")",
"{",
"$",
"name",
"=",
"$",
"token",
"->",
"getValue",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"stream",
"->",
"test",
"(",
"'('",
")",
"&&",
"$",
"this",
"->",
"engine",
"->",
"getFunction",
"(",
"$",
"name",
")",
")",
"{",
"$",
"out",
".=",
"sprintf",
"(",
"\"\\$this->callFunction('%s', array%s)\"",
",",
"$",
"name",
",",
"$",
"this",
"->",
"parseExpression",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"out",
".=",
"$",
"name",
";",
"}",
"}",
"elseif",
"(",
"$",
"token",
"=",
"$",
"this",
"->",
"stream",
"->",
"nextIf",
"(",
"T_VARIABLE",
")",
")",
"{",
"$",
"out",
".=",
"$",
"this",
"->",
"parseSubscript",
"(",
"$",
"var",
"=",
"$",
"token",
"->",
"getValue",
"(",
")",
")",
";",
"$",
"this",
"->",
"variables",
"[",
"ltrim",
"(",
"$",
"var",
",",
"'$'",
")",
"]",
"=",
"null",
";",
"}",
"else",
"{",
"$",
"token",
"=",
"$",
"this",
"->",
"stream",
"->",
"next",
"(",
")",
";",
"if",
"(",
"$",
"token",
"->",
"test",
"(",
"array",
"(",
"'('",
",",
"'['",
")",
")",
")",
"{",
"array_push",
"(",
"$",
"brackets",
",",
"$",
"token",
")",
";",
"}",
"elseif",
"(",
"$",
"token",
"->",
"test",
"(",
"array",
"(",
"')'",
",",
"']'",
")",
")",
")",
"{",
"array_pop",
"(",
"$",
"brackets",
")",
";",
"}",
"$",
"out",
".=",
"$",
"token",
"->",
"getValue",
"(",
")",
";",
"}",
"}",
"while",
"(",
"!",
"empty",
"(",
"$",
"brackets",
")",
")",
";",
"return",
"$",
"out",
";",
"}"
] |
Parse expression.
@return string
|
[
"Parse",
"expression",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Parser.php#L105-L143
|
227,697
|
pagekit/razr
|
src/Parser.php
|
Parser.parseSubscript
|
public function parseSubscript($out)
{
while (true) {
if ($this->stream->nextIf('.')) {
if (!$this->stream->test(T_STRING)) {
$this->stream->prev();
break;
}
$val = $this->stream->next()->getValue();
$out = sprintf("\$this->getAttribute(%s, '%s'", $out, $val);
if ($this->stream->test('(')) {
$out .= sprintf(", array%s, 'method')", $this->parseExpression());
} else {
$out .= ")";
}
} elseif ($this->stream->nextIf('[')) {
$exp = '';
while (!$this->stream->test(']')) {
$exp .= $this->parseExpression();
}
$this->stream->expect(']');
$this->stream->next();
$out = sprintf("\$this->getAttribute(%s, %s, array(), 'array')", $out, $exp);
} else {
break;
}
}
return $out;
}
|
php
|
public function parseSubscript($out)
{
while (true) {
if ($this->stream->nextIf('.')) {
if (!$this->stream->test(T_STRING)) {
$this->stream->prev();
break;
}
$val = $this->stream->next()->getValue();
$out = sprintf("\$this->getAttribute(%s, '%s'", $out, $val);
if ($this->stream->test('(')) {
$out .= sprintf(", array%s, 'method')", $this->parseExpression());
} else {
$out .= ")";
}
} elseif ($this->stream->nextIf('[')) {
$exp = '';
while (!$this->stream->test(']')) {
$exp .= $this->parseExpression();
}
$this->stream->expect(']');
$this->stream->next();
$out = sprintf("\$this->getAttribute(%s, %s, array(), 'array')", $out, $exp);
} else {
break;
}
}
return $out;
}
|
[
"public",
"function",
"parseSubscript",
"(",
"$",
"out",
")",
"{",
"while",
"(",
"true",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"stream",
"->",
"nextIf",
"(",
"'.'",
")",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"stream",
"->",
"test",
"(",
"T_STRING",
")",
")",
"{",
"$",
"this",
"->",
"stream",
"->",
"prev",
"(",
")",
";",
"break",
";",
"}",
"$",
"val",
"=",
"$",
"this",
"->",
"stream",
"->",
"next",
"(",
")",
"->",
"getValue",
"(",
")",
";",
"$",
"out",
"=",
"sprintf",
"(",
"\"\\$this->getAttribute(%s, '%s'\"",
",",
"$",
"out",
",",
"$",
"val",
")",
";",
"if",
"(",
"$",
"this",
"->",
"stream",
"->",
"test",
"(",
"'('",
")",
")",
"{",
"$",
"out",
".=",
"sprintf",
"(",
"\", array%s, 'method')\"",
",",
"$",
"this",
"->",
"parseExpression",
"(",
")",
")",
";",
"}",
"else",
"{",
"$",
"out",
".=",
"\")\"",
";",
"}",
"}",
"elseif",
"(",
"$",
"this",
"->",
"stream",
"->",
"nextIf",
"(",
"'['",
")",
")",
"{",
"$",
"exp",
"=",
"''",
";",
"while",
"(",
"!",
"$",
"this",
"->",
"stream",
"->",
"test",
"(",
"']'",
")",
")",
"{",
"$",
"exp",
".=",
"$",
"this",
"->",
"parseExpression",
"(",
")",
";",
"}",
"$",
"this",
"->",
"stream",
"->",
"expect",
"(",
"']'",
")",
";",
"$",
"this",
"->",
"stream",
"->",
"next",
"(",
")",
";",
"$",
"out",
"=",
"sprintf",
"(",
"\"\\$this->getAttribute(%s, %s, array(), 'array')\"",
",",
"$",
"out",
",",
"$",
"exp",
")",
";",
"}",
"else",
"{",
"break",
";",
"}",
"}",
"return",
"$",
"out",
";",
"}"
] |
Parse subscript.
@param string $out
@return string
|
[
"Parse",
"subscript",
"."
] |
5ba5e580bd71e0907e3966a122ac7b6869bac7f8
|
https://github.com/pagekit/razr/blob/5ba5e580bd71e0907e3966a122ac7b6869bac7f8/src/Parser.php#L151-L189
|
227,698
|
authlete/authlete-php
|
src/Dto/ServiceListResponse.php
|
ServiceListResponse.setServices
|
public function setServices(array $services = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$services', $services, __NAMESPACE__ . '\Service');
$this->services = $services;
return $this;
}
|
php
|
public function setServices(array $services = null)
{
ValidationUtility::ensureNullOrArrayOfType(
'$services', $services, __NAMESPACE__ . '\Service');
$this->services = $services;
return $this;
}
|
[
"public",
"function",
"setServices",
"(",
"array",
"$",
"services",
"=",
"null",
")",
"{",
"ValidationUtility",
"::",
"ensureNullOrArrayOfType",
"(",
"'$services'",
",",
"$",
"services",
",",
"__NAMESPACE__",
".",
"'\\Service'",
")",
";",
"$",
"this",
"->",
"services",
"=",
"$",
"services",
";",
"return",
"$",
"this",
";",
"}"
] |
Set the list of services that match the query conditions.
@param Service[] $services
The list of services that match the query conditions.
@return ServiceListResponse
`$this` object.
|
[
"Set",
"the",
"list",
"of",
"services",
"that",
"match",
"the",
"query",
"conditions",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Dto/ServiceListResponse.php#L178-L186
|
227,699
|
authlete/authlete-php
|
src/Util/ValidationUtility.php
|
ValidationUtility.ensureNullOrStringOrInteger
|
public static function ensureNullOrStringOrInteger($name, $value)
{
if (is_null($value) || is_string($value) || is_integer($value))
{
return;
}
throw new \InvalidArgumentException("'$name' must be null, a string or an integer.");
}
|
php
|
public static function ensureNullOrStringOrInteger($name, $value)
{
if (is_null($value) || is_string($value) || is_integer($value))
{
return;
}
throw new \InvalidArgumentException("'$name' must be null, a string or an integer.");
}
|
[
"public",
"static",
"function",
"ensureNullOrStringOrInteger",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"value",
")",
"||",
"is_string",
"(",
"$",
"value",
")",
"||",
"is_integer",
"(",
"$",
"value",
")",
")",
"{",
"return",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"'$name' must be null, a string or an integer.\"",
")",
";",
"}"
] |
Ensure that the given object is `null`, a `string` instance,
or an `integer` instance.
@param string $name
Name of a parameter.
@param integer $value
Value of a parameter.
@throws \InvalidArgumentException
`$value` is not `null`, a `string` instance or an `integer` instance.
|
[
"Ensure",
"that",
"the",
"given",
"object",
"is",
"null",
"a",
"string",
"instance",
"or",
"an",
"integer",
"instance",
"."
] |
bfa05f52dd39c7be66378770e50e303d12b33fb6
|
https://github.com/authlete/authlete-php/blob/bfa05f52dd39c7be66378770e50e303d12b33fb6/src/Util/ValidationUtility.php#L237-L245
|
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.