repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1
value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
sulu/SuluSalesShippingBundle | src/Sulu/Bundle/Sales/ShippingBundle/DataFixtures/ORM/LoadShippingStatus.php | LoadShippingStatus.load | public function load(ObjectManager $manager)
{
$statuses = array();
// force id = 1
$metadata = $manager->getClassMetaData(get_class(new ShippingStatus()));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
// created
$status =... | php | public function load(ObjectManager $manager)
{
$statuses = array();
// force id = 1
$metadata = $manager->getClassMetaData(get_class(new ShippingStatus()));
$metadata->setIdGeneratorType(\Doctrine\ORM\Mapping\ClassMetadata::GENERATOR_TYPE_NONE);
// created
$status =... | [
"public",
"function",
"load",
"(",
"ObjectManager",
"$",
"manager",
")",
"{",
"$",
"statuses",
"=",
"array",
"(",
")",
";",
"// force id = 1",
"$",
"metadata",
"=",
"$",
"manager",
"->",
"getClassMetaData",
"(",
"get_class",
"(",
"new",
"ShippingStatus",
"("... | {@inheritDoc} | [
"{"
] | train | https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/ShippingBundle/DataFixtures/ORM/LoadShippingStatus.php#L24-L67 |
stubbles/stubbles-webapp-core | src/main/php/response/Cookie.php | Cookie.create | public static function create(string $name, string $value = null): self
{
return new self($name, $value);
} | php | public static function create(string $name, string $value = null): self
{
return new self($name, $value);
} | [
"public",
"static",
"function",
"create",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
"=",
"null",
")",
":",
"self",
"{",
"return",
"new",
"self",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}"
] | creates the cookie
@param string $name name of the cookie
@param string $value value of the cookie
@return \stubbles\webapp\response\Cookie | [
"creates",
"the",
"cookie"
] | train | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/response/Cookie.php#L86-L89 |
ellipsephp/container | src/Container.php | Container.serviceFactoryMap | private function serviceFactoryMap(array $providers): array
{
$wrap = function ($factory) { return [$factory]; };
return array_reduce($providers, function ($factories, ServiceProviderInterface $provider) use ($wrap) {
return array_merge($factories, array_map($wrap, $provider->getFactor... | php | private function serviceFactoryMap(array $providers): array
{
$wrap = function ($factory) { return [$factory]; };
return array_reduce($providers, function ($factories, ServiceProviderInterface $provider) use ($wrap) {
return array_merge($factories, array_map($wrap, $provider->getFactor... | [
"private",
"function",
"serviceFactoryMap",
"(",
"array",
"$",
"providers",
")",
":",
"array",
"{",
"$",
"wrap",
"=",
"function",
"(",
"$",
"factory",
")",
"{",
"return",
"[",
"$",
"factory",
"]",
";",
"}",
";",
"return",
"array_reduce",
"(",
"$",
"pro... | Return a service factory map from the given service providers.
@param array $providers
@return array | [
"Return",
"a",
"service",
"factory",
"map",
"from",
"the",
"given",
"service",
"providers",
"."
] | train | https://github.com/ellipsephp/container/blob/ae0836b071fa1751f41b50fc33e3196fcbced6bf/src/Container.php#L89-L98 |
ellipsephp/container | src/Container.php | Container.serviceExtensionMap | private function serviceExtensionMap(array $providers): array
{
$wrap = function ($factory) { return [$factory]; };
return array_reduce($providers, function ($extensions, ServiceProviderInterface $provider) use ($wrap) {
return array_merge_recursive($extensions, array_map($wrap, $provi... | php | private function serviceExtensionMap(array $providers): array
{
$wrap = function ($factory) { return [$factory]; };
return array_reduce($providers, function ($extensions, ServiceProviderInterface $provider) use ($wrap) {
return array_merge_recursive($extensions, array_map($wrap, $provi... | [
"private",
"function",
"serviceExtensionMap",
"(",
"array",
"$",
"providers",
")",
":",
"array",
"{",
"$",
"wrap",
"=",
"function",
"(",
"$",
"factory",
")",
"{",
"return",
"[",
"$",
"factory",
"]",
";",
"}",
";",
"return",
"array_reduce",
"(",
"$",
"p... | Return a service extension map from the given service providers.
@param array $providers
@return array | [
"Return",
"a",
"service",
"extension",
"map",
"from",
"the",
"given",
"service",
"providers",
"."
] | train | https://github.com/ellipsephp/container/blob/ae0836b071fa1751f41b50fc33e3196fcbced6bf/src/Container.php#L106-L115 |
tjbp/laravel-verify-emails | src/Auth/VerifyEmails/CanVerifyEmail.php | CanVerifyEmail.unverify | public function unverify()
{
VerifyEmail::sendVerificationLink($this, function (Message $message) {
$message->subject($this->getVerifyEmailSubject());
});
$this->setVerified(false);
} | php | public function unverify()
{
VerifyEmail::sendVerificationLink($this, function (Message $message) {
$message->subject($this->getVerifyEmailSubject());
});
$this->setVerified(false);
} | [
"public",
"function",
"unverify",
"(",
")",
"{",
"VerifyEmail",
"::",
"sendVerificationLink",
"(",
"$",
"this",
",",
"function",
"(",
"Message",
"$",
"message",
")",
"{",
"$",
"message",
"->",
"subject",
"(",
"$",
"this",
"->",
"getVerifyEmailSubject",
"(",
... | Unverify the user's email address.
@return void | [
"Unverify",
"the",
"user",
"s",
"email",
"address",
"."
] | train | https://github.com/tjbp/laravel-verify-emails/blob/1e2ac10a696c10f2fdf0d7de6c3388d549bc07c6/src/Auth/VerifyEmails/CanVerifyEmail.php#L66-L73 |
wpottier/WizadSettingsBundle | Parser/XmlFileLoader.php | XmlFileLoader.load | public function load($file)
{
$schema = array();
$path = $this->locator->locate($file);
$xml = $this->parseFile($path);
$document = $xml->documentElement;
/** @var \DOMElement $setting */
$prefix = $document->hasAttribute('prefix') ? $document->getAttribute... | php | public function load($file)
{
$schema = array();
$path = $this->locator->locate($file);
$xml = $this->parseFile($path);
$document = $xml->documentElement;
/** @var \DOMElement $setting */
$prefix = $document->hasAttribute('prefix') ? $document->getAttribute... | [
"public",
"function",
"load",
"(",
"$",
"file",
")",
"{",
"$",
"schema",
"=",
"array",
"(",
")",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"locator",
"->",
"locate",
"(",
"$",
"file",
")",
";",
"$",
"xml",
"=",
"$",
"this",
"->",
"parseFile",
"... | Loads an XML file.
@param mixed $file The resource
@return array | [
"Loads",
"an",
"XML",
"file",
"."
] | train | https://github.com/wpottier/WizadSettingsBundle/blob/92738c59d4da28d3a7376de854ce8505898159cb/Parser/XmlFileLoader.php#L57-L73 |
wpottier/WizadSettingsBundle | Parser/XmlFileLoader.php | XmlFileLoader.parseFile | protected function parseFile($file)
{
try {
$dom = XmlUtils::loadFile($file, __DIR__ . static::SCHEME_PATH);
} catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);
}
retur... | php | protected function parseFile($file)
{
try {
$dom = XmlUtils::loadFile($file, __DIR__ . static::SCHEME_PATH);
} catch (\InvalidArgumentException $e) {
throw new \InvalidArgumentException(sprintf('Unable to parse file "%s".', $file), $e->getCode(), $e);
}
retur... | [
"protected",
"function",
"parseFile",
"(",
"$",
"file",
")",
"{",
"try",
"{",
"$",
"dom",
"=",
"XmlUtils",
"::",
"loadFile",
"(",
"$",
"file",
",",
"__DIR__",
".",
"static",
"::",
"SCHEME_PATH",
")",
";",
"}",
"catch",
"(",
"\\",
"InvalidArgumentExceptio... | Parses a XML file.
@param string $file Path to a file
@return \DOMDocument
@throws \InvalidArgumentException When loading of XML file returns error | [
"Parses",
"a",
"XML",
"file",
"."
] | train | https://github.com/wpottier/WizadSettingsBundle/blob/92738c59d4da28d3a7376de854ce8505898159cb/Parser/XmlFileLoader.php#L120-L129 |
yosmanyga/resource | src/Yosmanyga/Resource/Reader/Iterator/XmlFileReader.php | XmlFileReader.open | public function open(Resource $resource)
{
$file = $resource->getMetadata('file');
if (!is_file($file)) {
throw new \InvalidArgumentException(sprintf('File "%s" not found.', $file));
}
$this->xmlReader = new \XmlReader();
$this->xmlReader->open($file);
... | php | public function open(Resource $resource)
{
$file = $resource->getMetadata('file');
if (!is_file($file)) {
throw new \InvalidArgumentException(sprintf('File "%s" not found.', $file));
}
$this->xmlReader = new \XmlReader();
$this->xmlReader->open($file);
... | [
"public",
"function",
"open",
"(",
"Resource",
"$",
"resource",
")",
"{",
"$",
"file",
"=",
"$",
"resource",
"->",
"getMetadata",
"(",
"'file'",
")",
";",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgum... | {@inheritdoc} | [
"{"
] | train | https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Reader/Iterator/XmlFileReader.php#L48-L71 |
yosmanyga/resource | src/Yosmanyga/Resource/Reader/Iterator/XmlFileReader.php | XmlFileReader.current | public function current()
{
if (!isset($this->xmlReader)) {
throw new \RuntimeException('The resource needs to be open.');
}
if (!$this->xmlReader->name) {
return false;
}
/** @var \DOMElement $data */
$data = $this->xmlReader->expand();
... | php | public function current()
{
if (!isset($this->xmlReader)) {
throw new \RuntimeException('The resource needs to be open.');
}
if (!$this->xmlReader->name) {
return false;
}
/** @var \DOMElement $data */
$data = $this->xmlReader->expand();
... | [
"public",
"function",
"current",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"xmlReader",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The resource needs to be open.'",
")",
";",
"}",
"if",
"(",
"!",
"$",
"this",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Reader/Iterator/XmlFileReader.php#L76-L91 |
yosmanyga/resource | src/Yosmanyga/Resource/Reader/Iterator/XmlFileReader.php | XmlFileReader.next | public function next()
{
if (!isset($this->xmlReader)) {
throw new \RuntimeException('The resource needs to be open.');
}
while ($this->xmlReader->next()) {
$name = $this->xmlReader->name;
$depth = $this->xmlReader->depth;
if (1 == $depth && !... | php | public function next()
{
if (!isset($this->xmlReader)) {
throw new \RuntimeException('The resource needs to be open.');
}
while ($this->xmlReader->next()) {
$name = $this->xmlReader->name;
$depth = $this->xmlReader->depth;
if (1 == $depth && !... | [
"public",
"function",
"next",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"xmlReader",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The resource needs to be open.'",
")",
";",
"}",
"while",
"(",
"$",
"this",
"->",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Reader/Iterator/XmlFileReader.php#L96-L109 |
yosmanyga/resource | src/Yosmanyga/Resource/Reader/Iterator/XmlFileReader.php | XmlFileReader.close | public function close()
{
if (!isset($this->xmlReader)) {
throw new \RuntimeException('The resource needs to be open.');
}
$this->xmlReader->close();
unset($this->xmlReader);
} | php | public function close()
{
if (!isset($this->xmlReader)) {
throw new \RuntimeException('The resource needs to be open.');
}
$this->xmlReader->close();
unset($this->xmlReader);
} | [
"public",
"function",
"close",
"(",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"xmlReader",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"'The resource needs to be open.'",
")",
";",
"}",
"$",
"this",
"->",
"xmlReader",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/yosmanyga/resource/blob/a8b505c355920a908917a0484f764ddfa63205fa/src/Yosmanyga/Resource/Reader/Iterator/XmlFileReader.php#L114-L122 |
phramework/validate | src/AnyOf.php | AnyOf.validate | public function validate($value)
{
$return = new ValidateResult($value, false);
//validator ->
//return ->
$successValidated = [];
foreach ($this->{$this->anyOfProperty} as $validator) {
$validatorReturn = $validator->validate($value);
if ($valida... | php | public function validate($value)
{
$return = new ValidateResult($value, false);
//validator ->
//return ->
$successValidated = [];
foreach ($this->{$this->anyOfProperty} as $validator) {
$validatorReturn = $validator->validate($value);
if ($valida... | [
"public",
"function",
"validate",
"(",
"$",
"value",
")",
"{",
"$",
"return",
"=",
"new",
"ValidateResult",
"(",
"$",
"value",
",",
"false",
")",
";",
"//validator ->",
"//return ->",
"$",
"successValidated",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"... | Validate value
@see \Phramework\Validate\ValidateResult for ValidateResult object
@param mixed $value Value to validate
@return ValidateResult
@uses $requiredCountOfAnyOf
@uses $anyOfProperty | [
"Validate",
"value"
] | train | https://github.com/phramework/validate/blob/22dd3c4e5f7a77a1a75d92f98444f3e4b7ce5cfc/src/AnyOf.php#L101-L144 |
czim/laravel-pxlcms | src/Models/Scopes/OnlyActiveScope.php | OnlyActiveScope.apply | public function apply(Builder $builder, Model $model)
{
$column = $model->getQualifiedActiveColumn();
$builder->where($column, true);
$this->addWithInactive($builder);
} | php | public function apply(Builder $builder, Model $model)
{
$column = $model->getQualifiedActiveColumn();
$builder->where($column, true);
$this->addWithInactive($builder);
} | [
"public",
"function",
"apply",
"(",
"Builder",
"$",
"builder",
",",
"Model",
"$",
"model",
")",
"{",
"$",
"column",
"=",
"$",
"model",
"->",
"getQualifiedActiveColumn",
"(",
")",
";",
"$",
"builder",
"->",
"where",
"(",
"$",
"column",
",",
"true",
")",... | Apply scope on the query
@param \Illuminate\Database\Eloquent\Builder $builder
@param \Illuminate\Database\Eloquent\Model $model | [
"Apply",
"scope",
"on",
"the",
"query"
] | train | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/Scopes/OnlyActiveScope.php#L18-L25 |
czim/laravel-pxlcms | src/Models/Scopes/OnlyActiveScope.php | OnlyActiveScope.remove | public function remove(Builder $builder, Model $model)
{
$query = $builder->getQuery();
$column = $model->getQualifiedActiveColumn();
$bindingKey = 0;
foreach ((array) $query->wheres as $key => $where) {
if ($this->isActiveConstraint($where, $column)) {
... | php | public function remove(Builder $builder, Model $model)
{
$query = $builder->getQuery();
$column = $model->getQualifiedActiveColumn();
$bindingKey = 0;
foreach ((array) $query->wheres as $key => $where) {
if ($this->isActiveConstraint($where, $column)) {
... | [
"public",
"function",
"remove",
"(",
"Builder",
"$",
"builder",
",",
"Model",
"$",
"model",
")",
"{",
"$",
"query",
"=",
"$",
"builder",
"->",
"getQuery",
"(",
")",
";",
"$",
"column",
"=",
"$",
"model",
"->",
"getQualifiedActiveColumn",
"(",
")",
";",... | Remove scope from the query
@param \Illuminate\Database\Eloquent\Builder $builder
@param \Illuminate\Database\Eloquent\Model $model | [
"Remove",
"scope",
"from",
"the",
"query"
] | train | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/Scopes/OnlyActiveScope.php#L33-L51 |
czim/laravel-pxlcms | src/Models/Scopes/OnlyActiveScope.php | OnlyActiveScope.removeWhere | protected function removeWhere(BaseBuilder $query, $key)
{
unset($query->wheres[ $key ]);
$query->wheres = array_values( $query->wheres );
} | php | protected function removeWhere(BaseBuilder $query, $key)
{
unset($query->wheres[ $key ]);
$query->wheres = array_values( $query->wheres );
} | [
"protected",
"function",
"removeWhere",
"(",
"BaseBuilder",
"$",
"query",
",",
"$",
"key",
")",
"{",
"unset",
"(",
"$",
"query",
"->",
"wheres",
"[",
"$",
"key",
"]",
")",
";",
"$",
"query",
"->",
"wheres",
"=",
"array_values",
"(",
"$",
"query",
"->... | Remove scope constraint from the query
@param \Illuminate\Database\Query\Builder $query
@param int $key | [
"Remove",
"scope",
"constraint",
"from",
"the",
"query"
] | train | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/Scopes/OnlyActiveScope.php#L59-L64 |
czim/laravel-pxlcms | src/Models/Scopes/OnlyActiveScope.php | OnlyActiveScope.removeBinding | protected function removeBinding(BaseBuilder $query, $key)
{
$bindings = $query->getRawBindings()['where'];
unset($bindings[ $key ]);
$query->setBindings($bindings);
} | php | protected function removeBinding(BaseBuilder $query, $key)
{
$bindings = $query->getRawBindings()['where'];
unset($bindings[ $key ]);
$query->setBindings($bindings);
} | [
"protected",
"function",
"removeBinding",
"(",
"BaseBuilder",
"$",
"query",
",",
"$",
"key",
")",
"{",
"$",
"bindings",
"=",
"$",
"query",
"->",
"getRawBindings",
"(",
")",
"[",
"'where'",
"]",
";",
"unset",
"(",
"$",
"bindings",
"[",
"$",
"key",
"]",
... | Remove scope constraint from the query
@param \Illuminate\Database\Query\Builder $query
@param int $key | [
"Remove",
"scope",
"constraint",
"from",
"the",
"query"
] | train | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/Scopes/OnlyActiveScope.php#L72-L79 |
czim/laravel-pxlcms | src/Models/Scopes/OnlyActiveScope.php | OnlyActiveScope.addWithInactive | protected function addWithInactive(Builder $builder)
{
$builder->macro('withInactive', function (Builder $builder) {
$this->remove($builder, $builder->getModel());
return $builder;
});
} | php | protected function addWithInactive(Builder $builder)
{
$builder->macro('withInactive', function (Builder $builder) {
$this->remove($builder, $builder->getModel());
return $builder;
});
} | [
"protected",
"function",
"addWithInactive",
"(",
"Builder",
"$",
"builder",
")",
"{",
"$",
"builder",
"->",
"macro",
"(",
"'withInactive'",
",",
"function",
"(",
"Builder",
"$",
"builder",
")",
"{",
"$",
"this",
"->",
"remove",
"(",
"$",
"builder",
",",
... | Extend Builder with custom method
@param \Illuminate\Database\Eloquent\Builder $builder | [
"Extend",
"Builder",
"with",
"custom",
"method"
] | train | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Models/Scopes/OnlyActiveScope.php#L101-L108 |
axelitus/php-base | src/Flag.php | Flag.isOn | public static function isOn($value, $flag)
{
if (!Int::is($value)) {
throw new \InvalidArgumentException("The \$value parameter must be of type int.");
}
if (!static::is($flag)) {
throw new \InvalidArgumentException("The \$flag parameter must be of type int and a pow... | php | public static function isOn($value, $flag)
{
if (!Int::is($value)) {
throw new \InvalidArgumentException("The \$value parameter must be of type int.");
}
if (!static::is($flag)) {
throw new \InvalidArgumentException("The \$flag parameter must be of type int and a pow... | [
"public",
"static",
"function",
"isOn",
"(",
"$",
"value",
",",
"$",
"flag",
")",
"{",
"if",
"(",
"!",
"Int",
"::",
"is",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$value parameter must be of type int.\... | Checks if a flag is set in a given value.
@param int $value The value to test the flag on.
@param int $flag The flag to be tested.
@return bool Returns true if the flag is set in the value, false otherwise.
@throws \InvalidArgumentException | [
"Checks",
"if",
"a",
"flag",
"is",
"set",
"in",
"a",
"given",
"value",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Flag.php#L55-L66 |
axelitus/php-base | src/Flag.php | Flag.setOn | public static function setOn($value, $flag)
{
if (!Int::is($value)) {
throw new \InvalidArgumentException("The \$value parameter must be of type int.");
}
if (is_array($flag)) {
$ret = $value;
foreach ($flag as $item) {
$ret = static::setO... | php | public static function setOn($value, $flag)
{
if (!Int::is($value)) {
throw new \InvalidArgumentException("The \$value parameter must be of type int.");
}
if (is_array($flag)) {
$ret = $value;
foreach ($flag as $item) {
$ret = static::setO... | [
"public",
"static",
"function",
"setOn",
"(",
"$",
"value",
",",
"$",
"flag",
")",
"{",
"if",
"(",
"!",
"Int",
"::",
"is",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$value parameter must be of type int.... | Sets a flag into a value.
@param int $value The value to set the flag on.
@param int|array $flag The flag(s) to be set.
@return int Returns the value with the flag on.
@throws \InvalidArgumentException | [
"Sets",
"a",
"flag",
"into",
"a",
"value",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Flag.php#L95-L113 |
axelitus/php-base | src/Flag.php | Flag.getValues | public static function getValues($count)
{
if (!Int::is($count) || $count < 1) {
throw new \InvalidArgumentException("The \$count parameter must be of type int and greater than zero.");
}
$ret = [];
$flag = 1;
for ($i = 0; $i < $count; $i++) {
$ret[] ... | php | public static function getValues($count)
{
if (!Int::is($count) || $count < 1) {
throw new \InvalidArgumentException("The \$count parameter must be of type int and greater than zero.");
}
$ret = [];
$flag = 1;
for ($i = 0; $i < $count; $i++) {
$ret[] ... | [
"public",
"static",
"function",
"getValues",
"(",
"$",
"count",
")",
"{",
"if",
"(",
"!",
"Int",
"::",
"is",
"(",
"$",
"count",
")",
"||",
"$",
"count",
"<",
"1",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$count parameter ... | Gets an array with n consecutive flag values.
@param int $count The number of flag values to return.
@return array The array containing the n flag values.
@throws \InvalidArgumentException | [
"Gets",
"an",
"array",
"with",
"n",
"consecutive",
"flag",
"values",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Flag.php#L152-L166 |
axelitus/php-base | src/Flag.php | Flag.buildMask | public static function buildMask($flag1, $_ = null)
{
if (!static::is($flag1)) {
throw new \InvalidArgumentException("The first parameter must be a flag.");
}
$mask = $flag1;
$args = array_slice(func_get_args(), 1);
foreach ($args as $flag) {
if (!sta... | php | public static function buildMask($flag1, $_ = null)
{
if (!static::is($flag1)) {
throw new \InvalidArgumentException("The first parameter must be a flag.");
}
$mask = $flag1;
$args = array_slice(func_get_args(), 1);
foreach ($args as $flag) {
if (!sta... | [
"public",
"static",
"function",
"buildMask",
"(",
"$",
"flag1",
",",
"$",
"_",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"flag1",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The first parameter mu... | Builds a flag mask with the given flags.
@param int $flag1 The first flag.
@param int $_ More flags.
@return int The mask containing all the flags given.
@throws \InvalidArgumentException | [
"Builds",
"a",
"flag",
"mask",
"with",
"the",
"given",
"flags",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Flag.php#L214-L231 |
axelitus/php-base | src/Flag.php | Flag.mask | public static function mask($value, $mask)
{
if (!Int::is($value) || !Int::is($mask)) {
throw new \InvalidArgumentException("Both parameters must be integers.");
}
return ($value & $mask);
} | php | public static function mask($value, $mask)
{
if (!Int::is($value) || !Int::is($mask)) {
throw new \InvalidArgumentException("Both parameters must be integers.");
}
return ($value & $mask);
} | [
"public",
"static",
"function",
"mask",
"(",
"$",
"value",
",",
"$",
"mask",
")",
"{",
"if",
"(",
"!",
"Int",
"::",
"is",
"(",
"$",
"value",
")",
"||",
"!",
"Int",
"::",
"is",
"(",
"$",
"mask",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgum... | Applies the mask to the given value and returns the masked result.
@param int $value The value to apply the mask to.
@param int $mask The mask to apply.
@return int The masked value result.
@throws \InvalidArgumentException | [
"Applies",
"the",
"mask",
"to",
"the",
"given",
"value",
"and",
"returns",
"the",
"masked",
"result",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Flag.php#L242-L249 |
gbprod/elastica-provider-bundle | src/ElasticaProviderBundle/Provider/Registry.php | Registry.get | public function get($index = null, $type = null)
{
return array_filter(
$this->entries,
function($entry) use ($index, $type) {
return $entry->match($index, $type);
}
);
} | php | public function get($index = null, $type = null)
{
return array_filter(
$this->entries,
function($entry) use ($index, $type) {
return $entry->match($index, $type);
}
);
} | [
"public",
"function",
"get",
"(",
"$",
"index",
"=",
"null",
",",
"$",
"type",
"=",
"null",
")",
"{",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"entries",
",",
"function",
"(",
"$",
"entry",
")",
"use",
"(",
"$",
"index",
",",
"$",
"type",
... | Get entries for index and type
@param string|null $index
@param string|null $type
@return array<ProviderEntry> | [
"Get",
"entries",
"for",
"index",
"and",
"type"
] | train | https://github.com/gbprod/elastica-provider-bundle/blob/ee1e2ca78651d570b7400049bf81d8405fc744fc/src/ElasticaProviderBundle/Provider/Registry.php#L37-L45 |
php-ddd/command | src/Handler/AbstractCommandHandler.php | AbstractCommandHandler.handle | public function handle(CommandInterface $command)
{
if (!$this->supports(get_class($command))) {
throw new InvalidArgumentException(
sprintf(
'The command must be an instance of "%s". "%s" given.',
$this->getSupportedCommandClassName(),
... | php | public function handle(CommandInterface $command)
{
if (!$this->supports(get_class($command))) {
throw new InvalidArgumentException(
sprintf(
'The command must be an instance of "%s". "%s" given.',
$this->getSupportedCommandClassName(),
... | [
"public",
"function",
"handle",
"(",
"CommandInterface",
"$",
"command",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"supports",
"(",
"get_class",
"(",
"$",
"command",
")",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"sprintf",
"(",
... | @param CommandInterface $command
@return mixed
@throws InvalidArgumentException | [
"@param",
"CommandInterface",
"$command"
] | train | https://github.com/php-ddd/command/blob/dbad1d35c8d740c29c3a28d34f4a787c2b14688a/src/Handler/AbstractCommandHandler.php#L31-L44 |
discophp/framework | core/classes/TemplateLoader.class.php | TemplateLoader.getFinalName | public function getFinalName($name){
try {
return parent::findTemplate($name);
} catch(\Twig_Error_Loader $e){
$exts = \App::config('TEMPLATE_EXTENSION');
if($exts){
if(!is_array($exts)){
$exts = Array($exts);
... | php | public function getFinalName($name){
try {
return parent::findTemplate($name);
} catch(\Twig_Error_Loader $e){
$exts = \App::config('TEMPLATE_EXTENSION');
if($exts){
if(!is_array($exts)){
$exts = Array($exts);
... | [
"public",
"function",
"getFinalName",
"(",
"$",
"name",
")",
"{",
"try",
"{",
"return",
"parent",
"::",
"findTemplate",
"(",
"$",
"name",
")",
";",
"}",
"catch",
"(",
"\\",
"Twig_Error_Loader",
"$",
"e",
")",
"{",
"$",
"exts",
"=",
"\\",
"App",
"::",... | Get the final name where a template lives, regardless of whether it was called with an extension or not.
@param string $name The template name.
@return string The final template name.
@throws \Twig_Error_Loader | [
"Get",
"the",
"final",
"name",
"where",
"a",
"template",
"lives",
"regardless",
"of",
"whether",
"it",
"was",
"called",
"with",
"an",
"extension",
"or",
"not",
"."
] | train | https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/TemplateLoader.class.php#L20-L50 |
shawnsandy/ui-pages | src/PageKitServiceProvider.php | PageKitServiceProvider.boot | public function boot()
{
$this->loadViewsFrom(__DIR__ . '/resources/views/pagekit', 'page');
$this->publishes(
[
__DIR__ . '/resources/views/pagekit' => resource_path('views/vendor/page'),
], 'pagekit-views'
);
$this->publishes(
... | php | public function boot()
{
$this->loadViewsFrom(__DIR__ . '/resources/views/pagekit', 'page');
$this->publishes(
[
__DIR__ . '/resources/views/pagekit' => resource_path('views/vendor/page'),
], 'pagekit-views'
);
$this->publishes(
... | [
"public",
"function",
"boot",
"(",
")",
"{",
"$",
"this",
"->",
"loadViewsFrom",
"(",
"__DIR__",
".",
"'/resources/views/pagekit'",
",",
"'page'",
")",
";",
"$",
"this",
"->",
"publishes",
"(",
"[",
"__DIR__",
".",
"'/resources/views/pagekit'",
"=>",
"resource... | Perform post-registration booting of services.
@return null | [
"Perform",
"post",
"-",
"registration",
"booting",
"of",
"services",
"."
] | train | https://github.com/shawnsandy/ui-pages/blob/11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8/src/PageKitServiceProvider.php#L17-L68 |
shawnsandy/ui-pages | src/PageKitServiceProvider.php | PageKitServiceProvider.register | public function register()
{
$this->mergeConfigFrom(
__DIR__ . '/config/pagekit.php', 'pagekit'
);
$this->app->bind(
'Breadcrumbs', function () {
return new Breadcrumbs();
}
);
$this->app->bind(
'MKD', function () {
return new... | php | public function register()
{
$this->mergeConfigFrom(
__DIR__ . '/config/pagekit.php', 'pagekit'
);
$this->app->bind(
'Breadcrumbs', function () {
return new Breadcrumbs();
}
);
$this->app->bind(
'MKD', function () {
return new... | [
"public",
"function",
"register",
"(",
")",
"{",
"$",
"this",
"->",
"mergeConfigFrom",
"(",
"__DIR__",
".",
"'/config/pagekit.php'",
",",
"'pagekit'",
")",
";",
"$",
"this",
"->",
"app",
"->",
"bind",
"(",
"'Breadcrumbs'",
",",
"function",
"(",
")",
"{",
... | Register any package services.
@return null | [
"Register",
"any",
"package",
"services",
"."
] | train | https://github.com/shawnsandy/ui-pages/blob/11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8/src/PageKitServiceProvider.php#L76-L98 |
shawnsandy/ui-pages | src/PageKitServiceProvider.php | PageKitServiceProvider.pageTheme | public function pageTheme()
{
view()->composer("*", function ($view) {
/* get the theme if set in config */
$theme = config("pagekit.theme", null);
/* if not theme is set in the config */
/* check the theme folder if exist or use the theme in package*/
if (!$theme):
... | php | public function pageTheme()
{
view()->composer("*", function ($view) {
/* get the theme if set in config */
$theme = config("pagekit.theme", null);
/* if not theme is set in the config */
/* check the theme folder if exist or use the theme in package*/
if (!$theme):
... | [
"public",
"function",
"pageTheme",
"(",
")",
"{",
"view",
"(",
")",
"->",
"composer",
"(",
"\"*\"",
",",
"function",
"(",
"$",
"view",
")",
"{",
"/* get the theme if set in config */",
"$",
"theme",
"=",
"config",
"(",
"\"pagekit.theme\"",
",",
"null",
")",
... | get the default theme | [
"get",
"the",
"default",
"theme"
] | train | https://github.com/shawnsandy/ui-pages/blob/11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8/src/PageKitServiceProvider.php#L105-L130 |
jasny/router | src/Router/Middleware/NotFound.php | NotFound.simpleResponse | protected function simpleResponse(ResponseInterface $response, $code)
{
$notFound = $response->withStatus($code);
$notFound->getBody()->write('Not found');
return $notFound;
} | php | protected function simpleResponse(ResponseInterface $response, $code)
{
$notFound = $response->withStatus($code);
$notFound->getBody()->write('Not found');
return $notFound;
} | [
"protected",
"function",
"simpleResponse",
"(",
"ResponseInterface",
"$",
"response",
",",
"$",
"code",
")",
"{",
"$",
"notFound",
"=",
"$",
"response",
"->",
"withStatus",
"(",
"$",
"code",
")",
";",
"$",
"notFound",
"->",
"getBody",
"(",
")",
"->",
"wr... | Simple response
@param ResponseInterface $response
@param int $code
@return ResponseInterface | [
"Simple",
"response"
] | train | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router/Middleware/NotFound.php#L107-L113 |
TypistTech/wp-option-store | src/ConstantStrategy.php | ConstantStrategy.get | public function get(string $optionName)
{
$constantName = $this->constantNameFor($optionName);
if (! defined($constantName)) {
return null;
}
return constant($constantName);
} | php | public function get(string $optionName)
{
$constantName = $this->constantNameFor($optionName);
if (! defined($constantName)) {
return null;
}
return constant($constantName);
} | [
"public",
"function",
"get",
"(",
"string",
"$",
"optionName",
")",
"{",
"$",
"constantName",
"=",
"$",
"this",
"->",
"constantNameFor",
"(",
"$",
"optionName",
")",
";",
"if",
"(",
"!",
"defined",
"(",
"$",
"constantName",
")",
")",
"{",
"return",
"nu... | Option getter.
@param string $optionName Name of option to retrieve.
@return mixed|null Null if option not exists or its value is actually null. | [
"Option",
"getter",
"."
] | train | https://github.com/TypistTech/wp-option-store/blob/115ff7cb4b5f566c89c1294fe2b68c82d62cccc2/src/ConstantStrategy.php#L35-L44 |
phossa2/middleware | src/Middleware/Condition/PathPrefixCondition.php | PathPrefixCondition.evaluate | public function evaluate(
RequestInterface $request,
ResponseInterface $response
)/*# : bool */ {
foreach ($this->prefix as $pref) {
if (0 === strpos($request->getUri()->getPath(), $pref)) {
return true;
}
}
return false;
} | php | public function evaluate(
RequestInterface $request,
ResponseInterface $response
)/*# : bool */ {
foreach ($this->prefix as $pref) {
if (0 === strpos($request->getUri()->getPath(), $pref)) {
return true;
}
}
return false;
} | [
"public",
"function",
"evaluate",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"/*# : bool */",
"{",
"foreach",
"(",
"$",
"this",
"->",
"prefix",
"as",
"$",
"pref",
")",
"{",
"if",
"(",
"0",
"===",
"strpos",
"(",... | {@inheritDoc} | [
"{"
] | train | https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Condition/PathPrefixCondition.php#L54-L64 |
pageon/SlackWebhookMonolog | src/Slack/Attachment/Attachment.php | Attachment.setAuthor | public function setAuthor(Author $author)
{
$this->attachment['author_name'] = $author;
if ($author->hasIcon()) {
$this->attachment['author_icon'] = $author->getIcon();
}
if ($author->hasLink()) {
$this->attachment['author_link'] = $author->getLink();
... | php | public function setAuthor(Author $author)
{
$this->attachment['author_name'] = $author;
if ($author->hasIcon()) {
$this->attachment['author_icon'] = $author->getIcon();
}
if ($author->hasLink()) {
$this->attachment['author_link'] = $author->getLink();
... | [
"public",
"function",
"setAuthor",
"(",
"Author",
"$",
"author",
")",
"{",
"$",
"this",
"->",
"attachment",
"[",
"'author_name'",
"]",
"=",
"$",
"author",
";",
"if",
"(",
"$",
"author",
"->",
"hasIcon",
"(",
")",
")",
"{",
"$",
"this",
"->",
"attachm... | The author parameters will display a small section at the top of a message attachment.
@param Author $author
@return self | [
"The",
"author",
"parameters",
"will",
"display",
"a",
"small",
"section",
"at",
"the",
"top",
"of",
"a",
"message",
"attachment",
"."
] | train | https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Attachment/Attachment.php#L90-L103 |
pageon/SlackWebhookMonolog | src/Slack/Attachment/Attachment.php | Attachment.setTitle | public function setTitle(Title $title)
{
$this->attachment['title'] = $title;
if ($title->hasLink()) {
$this->attachment['title_link'] = $title->getLink();
}
return $this;
} | php | public function setTitle(Title $title)
{
$this->attachment['title'] = $title;
if ($title->hasLink()) {
$this->attachment['title_link'] = $title->getLink();
}
return $this;
} | [
"public",
"function",
"setTitle",
"(",
"Title",
"$",
"title",
")",
"{",
"$",
"this",
"->",
"attachment",
"[",
"'title'",
"]",
"=",
"$",
"title",
";",
"if",
"(",
"$",
"title",
"->",
"hasLink",
"(",
")",
")",
"{",
"$",
"this",
"->",
"attachment",
"["... | The title is displayed as larger, bold text near the top of a message attachment.
@param Title $title
@return self | [
"The",
"title",
"is",
"displayed",
"as",
"larger",
"bold",
"text",
"near",
"the",
"top",
"of",
"a",
"message",
"attachment",
"."
] | train | https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Attachment/Attachment.php#L112-L121 |
pageon/SlackWebhookMonolog | src/Slack/Attachment/Attachment.php | Attachment.addField | public function addField(Field $field)
{
if (!isset($this->attachment['fields'])) {
$this->attachment['fields'] = [];
}
$this->attachment['fields'][] = $field;
return $this;
} | php | public function addField(Field $field)
{
if (!isset($this->attachment['fields'])) {
$this->attachment['fields'] = [];
}
$this->attachment['fields'][] = $field;
return $this;
} | [
"public",
"function",
"addField",
"(",
"Field",
"$",
"field",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attachment",
"[",
"'fields'",
"]",
")",
")",
"{",
"$",
"this",
"->",
"attachment",
"[",
"'fields'",
"]",
"=",
"[",
"]",
";",
... | Will be displayed in a table inside the message attachment.
@param Field $field
@return self | [
"Will",
"be",
"displayed",
"in",
"a",
"table",
"inside",
"the",
"message",
"attachment",
"."
] | train | https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Attachment/Attachment.php#L130-L139 |
winzou/limonetik-php-api | src/APIClient.php | APIClient.PaymentOrderCreate | public function PaymentOrderCreate(array $params)
{
$request = new Request();
$request->setMethod('POST');
foreach (array('PaymentPageId', 'Amount', 'Currency', 'MerchantUrls') as $param) {
if (!isset($params[$param])) {
throw new InvalidArgumentException($param)... | php | public function PaymentOrderCreate(array $params)
{
$request = new Request();
$request->setMethod('POST');
foreach (array('PaymentPageId', 'Amount', 'Currency', 'MerchantUrls') as $param) {
if (!isset($params[$param])) {
throw new InvalidArgumentException($param)... | [
"public",
"function",
"PaymentOrderCreate",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
")",
";",
"$",
"request",
"->",
"setMethod",
"(",
"'POST'",
")",
";",
"foreach",
"(",
"array",
"(",
"'PaymentPageId'",
",",
"'A... | @param array $params
@return array | [
"@param",
"array",
"$params"
] | train | https://github.com/winzou/limonetik-php-api/blob/4580dd455a446d2a78090ff932f65d6d54ab301c/src/APIClient.php#L91-L106 |
winzou/limonetik-php-api | src/APIClient.php | APIClient.PaymentOrderDetail | public function PaymentOrderDetail($paymentOrderId, array $addElements = array())
{
$request = new Request();
$request->setMethod('GET');
if (null == $paymentOrderId) {
throw new InvalidArgumentException('paymentOrderId');
}
$qs = array('Id' => $paymentOrderId);... | php | public function PaymentOrderDetail($paymentOrderId, array $addElements = array())
{
$request = new Request();
$request->setMethod('GET');
if (null == $paymentOrderId) {
throw new InvalidArgumentException('paymentOrderId');
}
$qs = array('Id' => $paymentOrderId);... | [
"public",
"function",
"PaymentOrderDetail",
"(",
"$",
"paymentOrderId",
",",
"array",
"$",
"addElements",
"=",
"array",
"(",
")",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
")",
";",
"$",
"request",
"->",
"setMethod",
"(",
"'GET'",
")",
";",
... | @param int $paymentOrderId
@param array $addElements
@return array | [
"@param",
"int",
"$paymentOrderId",
"@param",
"array",
"$addElements"
] | train | https://github.com/winzou/limonetik-php-api/blob/4580dd455a446d2a78090ff932f65d6d54ab301c/src/APIClient.php#L114-L130 |
winzou/limonetik-php-api | src/APIClient.php | APIClient.PaymentOrderDetailByMerchant | public function PaymentOrderDetailByMerchant($merchantOrderId, array $addElements = array())
{
$request = new Request();
$request->setMethod('GET');
if (null == $merchantOrderId) {
throw new InvalidArgumentException('merchantOrderId');
}
$qs = array(
... | php | public function PaymentOrderDetailByMerchant($merchantOrderId, array $addElements = array())
{
$request = new Request();
$request->setMethod('GET');
if (null == $merchantOrderId) {
throw new InvalidArgumentException('merchantOrderId');
}
$qs = array(
... | [
"public",
"function",
"PaymentOrderDetailByMerchant",
"(",
"$",
"merchantOrderId",
",",
"array",
"$",
"addElements",
"=",
"array",
"(",
")",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
")",
";",
"$",
"request",
"->",
"setMethod",
"(",
"'GET'",
")... | @param string $merchantOrderId
@param array $addElements
@return array | [
"@param",
"string",
"$merchantOrderId",
"@param",
"array",
"$addElements"
] | train | https://github.com/winzou/limonetik-php-api/blob/4580dd455a446d2a78090ff932f65d6d54ab301c/src/APIClient.php#L138-L157 |
winzou/limonetik-php-api | src/APIClient.php | APIClient.PaymentOrderCancel | public function PaymentOrderCancel($paymentOrderId, $amount, $currency)
{
$request = new Request();
$request->setMethod('POST');
foreach (array('paymentOrderId', 'amount', 'currency') as $param) {
if (null == $$param) {
throw new InvalidArgumentException($param);... | php | public function PaymentOrderCancel($paymentOrderId, $amount, $currency)
{
$request = new Request();
$request->setMethod('POST');
foreach (array('paymentOrderId', 'amount', 'currency') as $param) {
if (null == $$param) {
throw new InvalidArgumentException($param);... | [
"public",
"function",
"PaymentOrderCancel",
"(",
"$",
"paymentOrderId",
",",
"$",
"amount",
",",
"$",
"currency",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
")",
";",
"$",
"request",
"->",
"setMethod",
"(",
"'POST'",
")",
";",
"foreach",
"(",
... | @param int $paymentOrderId
@param float $amount
@param string $currency
@return array | [
"@param",
"int",
"$paymentOrderId",
"@param",
"float",
"$amount",
"@param",
"string",
"$currency"
] | train | https://github.com/winzou/limonetik-php-api/blob/4580dd455a446d2a78090ff932f65d6d54ab301c/src/APIClient.php#L166-L186 |
winzou/limonetik-php-api | src/APIClient.php | APIClient.EventDetail | public function EventDetail($eventId)
{
$request = new Request();
if (null == $eventId) {
throw new InvalidArgumentException('eventId');
}
return $this->doRequest('Event/Detail', $request, array('Id' => $eventId))->getContentJson();
} | php | public function EventDetail($eventId)
{
$request = new Request();
if (null == $eventId) {
throw new InvalidArgumentException('eventId');
}
return $this->doRequest('Event/Detail', $request, array('Id' => $eventId))->getContentJson();
} | [
"public",
"function",
"EventDetail",
"(",
"$",
"eventId",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
")",
";",
"if",
"(",
"null",
"==",
"$",
"eventId",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'eventId'",
")",
";",
"}",
"r... | @param int $eventId
@return array | [
"@param",
"int",
"$eventId"
] | train | https://github.com/winzou/limonetik-php-api/blob/4580dd455a446d2a78090ff932f65d6d54ab301c/src/APIClient.php#L251-L260 |
winzou/limonetik-php-api | src/APIClient.php | APIClient.doRequest | protected function doRequest($controller, Request $request, array $qs = array())
{
$request->fromUrl($this->getApiEndpoint($controller).'?'.http_build_query($qs));
$request->addHeader('Authorization: Basic '.$this->options['key']);
$request->addHeader('Accept: text/json');
$this->cl... | php | protected function doRequest($controller, Request $request, array $qs = array())
{
$request->fromUrl($this->getApiEndpoint($controller).'?'.http_build_query($qs));
$request->addHeader('Authorization: Basic '.$this->options['key']);
$request->addHeader('Accept: text/json');
$this->cl... | [
"protected",
"function",
"doRequest",
"(",
"$",
"controller",
",",
"Request",
"$",
"request",
",",
"array",
"$",
"qs",
"=",
"array",
"(",
")",
")",
"{",
"$",
"request",
"->",
"fromUrl",
"(",
"$",
"this",
"->",
"getApiEndpoint",
"(",
"$",
"controller",
... | @parem string $controller
@param Request $request
@param array $qs
@throws RequestException
@return JsonResponse | [
"@parem",
"string",
"$controller",
"@param",
"Request",
"$request",
"@param",
"array",
"$qs"
] | train | https://github.com/winzou/limonetik-php-api/blob/4580dd455a446d2a78090ff932f65d6d54ab301c/src/APIClient.php#L271-L288 |
winzou/limonetik-php-api | src/APIClient.php | APIClient.getApiEndpoint | protected function getApiEndpoint($controller)
{
$url = $this->options['sandbox'] ? self::URL_DEV : self::URL_PROD;
return $url.'/'.self::VERSION.'/'.$controller;
} | php | protected function getApiEndpoint($controller)
{
$url = $this->options['sandbox'] ? self::URL_DEV : self::URL_PROD;
return $url.'/'.self::VERSION.'/'.$controller;
} | [
"protected",
"function",
"getApiEndpoint",
"(",
"$",
"controller",
")",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"options",
"[",
"'sandbox'",
"]",
"?",
"self",
"::",
"URL_DEV",
":",
"self",
"::",
"URL_PROD",
";",
"return",
"$",
"url",
".",
"'/'",
".",
... | @param string $controller
@return string | [
"@param",
"string",
"$controller"
] | train | https://github.com/winzou/limonetik-php-api/blob/4580dd455a446d2a78090ff932f65d6d54ab301c/src/APIClient.php#L295-L300 |
blast-project/CoreBundle | src/Generator/ControllerGenerator.php | ControllerGenerator.generate | public function generate(BundleInterface $bundle, $controllerClassBasename)
{
$this->class = sprintf('%s\Controller\%s', $bundle->getNamespace(), $controllerClassBasename);
$this->file = sprintf(
'%s/Controller/%s.php',
$bundle->getPath(),
str_replace('\\', '/', $... | php | public function generate(BundleInterface $bundle, $controllerClassBasename)
{
$this->class = sprintf('%s\Controller\%s', $bundle->getNamespace(), $controllerClassBasename);
$this->file = sprintf(
'%s/Controller/%s.php',
$bundle->getPath(),
str_replace('\\', '/', $... | [
"public",
"function",
"generate",
"(",
"BundleInterface",
"$",
"bundle",
",",
"$",
"controllerClassBasename",
")",
"{",
"$",
"this",
"->",
"class",
"=",
"sprintf",
"(",
"'%s\\Controller\\%s'",
",",
"$",
"bundle",
"->",
"getNamespace",
"(",
")",
",",
"$",
"co... | @param BundleInterface $bundle
@param string $controllerClassBasename
@throws \RuntimeException | [
"@param",
"BundleInterface",
"$bundle",
"@param",
"string",
"$controllerClassBasename"
] | train | https://github.com/blast-project/CoreBundle/blob/7a0832758ca14e5bc5d65515532c1220df3930ae/src/Generator/ControllerGenerator.php#L47-L69 |
gregorybesson/PlaygroundCore | src/Service/Image.php | Image.correctOrientation | public function correctOrientation()
{
try {
$exif = exif_read_data($this->file);
} catch (\Exception $e) {
return $this;
}
if (!empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 8:
$this->image... | php | public function correctOrientation()
{
try {
$exif = exif_read_data($this->file);
} catch (\Exception $e) {
return $this;
}
if (!empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 8:
$this->image... | [
"public",
"function",
"correctOrientation",
"(",
")",
"{",
"try",
"{",
"$",
"exif",
"=",
"exif_read_data",
"(",
"$",
"this",
"->",
"file",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"return",
"$",
"this",
";",
"}",
"if",
"(... | Correct image orientation (if present in the medadata)
use php_exif
@return \PlaygroundCore\Service\Image | [
"Correct",
"image",
"orientation",
"(",
"if",
"present",
"in",
"the",
"medadata",
")",
"use",
"php_exif"
] | train | https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Service/Image.php#L65-L86 |
gregorybesson/PlaygroundCore | src/Service/Image.php | Image.save | public function save($path = null)
{
if (is_null($path)) {
$path = $this->file;
}
imagejpeg($this->image, $path);
return $this;
} | php | public function save($path = null)
{
if (is_null($path)) {
$path = $this->file;
}
imagejpeg($this->image, $path);
return $this;
} | [
"public",
"function",
"save",
"(",
"$",
"path",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"path",
")",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"file",
";",
"}",
"imagejpeg",
"(",
"$",
"this",
"->",
"image",
",",
"$",
"path",... | save as jpeg
@param string $path
@return \PlaygroundCore\Service\Image | [
"save",
"as",
"jpeg"
] | train | https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/Service/Image.php#L93-L100 |
bocharsky-bw/FileNamingResolver | src/NamingStrategy/HashNamingStrategy.php | HashNamingStrategy.provideName | public function provideName(FileInfo $srcFileInfo)
{
$string = $this->generateUniqueString();
$hash = hash($this->algorithm, $string);
$dstFileInfo = $this->provideNameByHash($srcFileInfo, $hash);
return $dstFileInfo;
} | php | public function provideName(FileInfo $srcFileInfo)
{
$string = $this->generateUniqueString();
$hash = hash($this->algorithm, $string);
$dstFileInfo = $this->provideNameByHash($srcFileInfo, $hash);
return $dstFileInfo;
} | [
"public",
"function",
"provideName",
"(",
"FileInfo",
"$",
"srcFileInfo",
")",
"{",
"$",
"string",
"=",
"$",
"this",
"->",
"generateUniqueString",
"(",
")",
";",
"$",
"hash",
"=",
"hash",
"(",
"$",
"this",
"->",
"algorithm",
",",
"$",
"string",
")",
";... | {@inheritdoc} | [
"{"
] | train | https://github.com/bocharsky-bw/FileNamingResolver/blob/0a0fe86fee0e7acf1ab43a84c1abd51954ce2fbe/src/NamingStrategy/HashNamingStrategy.php#L15-L23 |
huasituo/hstcms | src/Libraries/Fields/Radio.php | Radio.input | public function input($cname, $name, $cfg, $value = NULL, $id = 0)
{
$cfg['option']['value'] = isset($cfg['option']['value']) ? $cfg['option']['value'] : "";
// 字段显示名称
$text = (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1 ? '<font color="red">*</font> ' : '').$cname;
// 表单附加参数... | php | public function input($cname, $name, $cfg, $value = NULL, $id = 0)
{
$cfg['option']['value'] = isset($cfg['option']['value']) ? $cfg['option']['value'] : "";
// 字段显示名称
$text = (isset($cfg['validate']['required']) && $cfg['validate']['required'] == 1 ? '<font color="red">*</font> ' : '').$cname;
// 表单附加参数... | [
"public",
"function",
"input",
"(",
"$",
"cname",
",",
"$",
"name",
",",
"$",
"cfg",
",",
"$",
"value",
"=",
"NULL",
",",
"$",
"id",
"=",
"0",
")",
"{",
"$",
"cfg",
"[",
"'option'",
"]",
"[",
"'value'",
"]",
"=",
"isset",
"(",
"$",
"cfg",
"["... | 字段表单输入
@param string $cname 字段别名
@param string $name 字段名称
@param array $cfg 字段配置
@param string $value 值
@return string | [
"字段表单输入"
] | train | https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Libraries/Fields/Radio.php#L57-L90 |
huasituo/hstcms | src/Libraries/Fields/Radio.php | Radio.output_data | public function output_data($data, $field = [])
{
if(!isset($data[$field['fieldname']])) {
return $data;
}
$value = $data[$field['fieldname']];
$data['_'.$field['fieldname']] = $value;
if(!$value) {
return $data;
}
$cfg = $field['setting']['option'];
$options = @explode(PHP_EOL, str_replace(arra... | php | public function output_data($data, $field = [])
{
if(!isset($data[$field['fieldname']])) {
return $data;
}
$value = $data[$field['fieldname']];
$data['_'.$field['fieldname']] = $value;
if(!$value) {
return $data;
}
$cfg = $field['setting']['option'];
$options = @explode(PHP_EOL, str_replace(arra... | [
"public",
"function",
"output_data",
"(",
"$",
"data",
",",
"$",
"field",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"data",
"[",
"$",
"field",
"[",
"'fieldname'",
"]",
"]",
")",
")",
"{",
"return",
"$",
"data",
";",
"}",
"$",
... | 字段输出 | [
"字段输出"
] | train | https://github.com/huasituo/hstcms/blob/12819979289e58ce38e3e92540aeeb16e205e525/src/Libraries/Fields/Radio.php#L95-L114 |
jan-dolata/crude-crud | src/Engine/CrudeSetupTrait/InputType.php | InputType.setTypes | public function setTypes($attr, $type = null)
{
if (is_array($attr))
$this->inputType = array_merge($this->inputType, $attr);
else
$this->inputType[$attr] = $type;
return $this;
} | php | public function setTypes($attr, $type = null)
{
if (is_array($attr))
$this->inputType = array_merge($this->inputType, $attr);
else
$this->inputType[$attr] = $type;
return $this;
} | [
"public",
"function",
"setTypes",
"(",
"$",
"attr",
",",
"$",
"type",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"attr",
")",
")",
"$",
"this",
"->",
"inputType",
"=",
"array_merge",
"(",
"$",
"this",
"->",
"inputType",
",",
"$",
"attr... | Sets the Input types.
@param string|array $attr
@param array $value
@return self | [
"Sets",
"the",
"Input",
"types",
"."
] | train | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/InputType.php#L34-L42 |
jan-dolata/crude-crud | src/Engine/CrudeSetupTrait/InputType.php | InputType.setTypesGroup | public function setTypesGroup($types, $attr = null)
{
if (! is_array($types))
$types = [$types => $attr];
foreach ($types as $type => $attrList) {
if (! is_array($attrList))
$attrList = [$attrList];
foreach ($attrList as $attr)
$t... | php | public function setTypesGroup($types, $attr = null)
{
if (! is_array($types))
$types = [$types => $attr];
foreach ($types as $type => $attrList) {
if (! is_array($attrList))
$attrList = [$attrList];
foreach ($attrList as $attr)
$t... | [
"public",
"function",
"setTypesGroup",
"(",
"$",
"types",
",",
"$",
"attr",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"types",
")",
")",
"$",
"types",
"=",
"[",
"$",
"types",
"=>",
"$",
"attr",
"]",
";",
"foreach",
"(",
"$",
... | Set new or change input types
@param string|array $types
@param array $attr
@return self | [
"Set",
"new",
"or",
"change",
"input",
"types"
] | train | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/InputType.php#L52-L66 |
itgalaxy/bin-wrapper | src/BinWrapper.php | BinWrapper.binCheck | private function binCheck($bin, $args = ['--help'])
{
$isExecutable = is_executable($bin);
if (!$isExecutable) {
throw new \Exception(
'Couldn\'t execute the ' . $bin . ' binary. Make sure it has the right permissions.'
);
}
exec($bin . ' ' .... | php | private function binCheck($bin, $args = ['--help'])
{
$isExecutable = is_executable($bin);
if (!$isExecutable) {
throw new \Exception(
'Couldn\'t execute the ' . $bin . ' binary. Make sure it has the right permissions.'
);
}
exec($bin . ' ' .... | [
"private",
"function",
"binCheck",
"(",
"$",
"bin",
",",
"$",
"args",
"=",
"[",
"'--help'",
"]",
")",
"{",
"$",
"isExecutable",
"=",
"is_executable",
"(",
"$",
"bin",
")",
";",
"if",
"(",
"!",
"$",
"isExecutable",
")",
"{",
"throw",
"new",
"\\",
"E... | Todo move to separatly repository | [
"Todo",
"move",
"to",
"separatly",
"repository"
] | train | https://github.com/itgalaxy/bin-wrapper/blob/f4217cb6a1ae5a2abea180255ba14ef264118d43/src/BinWrapper.php#L198-L215 |
hollodotme/TreeMDown | src/FileSystem/Tree.php | Tree.getLeafObject | public function getLeafObject( string $filepath ) : Leaf
{
$leafObject = new $this->leafObjectClass( $this->search, $filepath );
if ( $leafObject instanceof Leaf )
{
return $leafObject;
}
throw new \RuntimeException( sprintf( '%s is not a subclass of %s\\Leaf', $this->leafObjectClass, __NAMESPACE__ ) );... | php | public function getLeafObject( string $filepath ) : Leaf
{
$leafObject = new $this->leafObjectClass( $this->search, $filepath );
if ( $leafObject instanceof Leaf )
{
return $leafObject;
}
throw new \RuntimeException( sprintf( '%s is not a subclass of %s\\Leaf', $this->leafObjectClass, __NAMESPACE__ ) );... | [
"public",
"function",
"getLeafObject",
"(",
"string",
"$",
"filepath",
")",
":",
"Leaf",
"{",
"$",
"leafObject",
"=",
"new",
"$",
"this",
"->",
"leafObjectClass",
"(",
"$",
"this",
"->",
"search",
",",
"$",
"filepath",
")",
";",
"if",
"(",
"$",
"leafOb... | Return a new leaf object
@param string $filepath
@throws \RuntimeException
@return Leaf | [
"Return",
"a",
"new",
"leaf",
"object"
] | train | https://github.com/hollodotme/TreeMDown/blob/462c4118c70b68963e0176d540fc8502730ffe27/src/FileSystem/Tree.php#L197-L207 |
BugBuster1701/banner | classes/BannerImage.php | BannerImage.getBannerImageSize | public function getBannerImageSize($BannerImage,$BannerType)
{
switch ($BannerType)
{
case self::BANNER_TYPE_INTERN :
return $this->getImageSizeInternal($BannerImage);
break;
case self::BANNER_TYPE_EXTERN :
return $this->getImageSizeExternal($BannerImage);
break;
case self::BANNER_TYPE_TEX... | php | public function getBannerImageSize($BannerImage,$BannerType)
{
switch ($BannerType)
{
case self::BANNER_TYPE_INTERN :
return $this->getImageSizeInternal($BannerImage);
break;
case self::BANNER_TYPE_EXTERN :
return $this->getImageSizeExternal($BannerImage);
break;
case self::BANNER_TYPE_TEX... | [
"public",
"function",
"getBannerImageSize",
"(",
"$",
"BannerImage",
",",
"$",
"BannerType",
")",
"{",
"switch",
"(",
"$",
"BannerType",
")",
"{",
"case",
"self",
"::",
"BANNER_TYPE_INTERN",
":",
"return",
"$",
"this",
"->",
"getImageSizeInternal",
"(",
"$",
... | Get the size of an image
@param string $BannerImage Image path/link
@param string $BannerType intern,extern,text
@return mixed $array / false | [
"Get",
"the",
"size",
"of",
"an",
"image"
] | train | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L85-L102 |
BugBuster1701/banner | classes/BannerImage.php | BannerImage.getImageSizeInternal | protected function getImageSizeInternal($BannerImage)
{
try
{
$arrImageSize = getimagesize(TL_ROOT . '/' . $BannerImage);
}
catch (\Exception $e)
{
$arrImageSize = false;
}
if ($arrImageSize === false)
{
//Workaround for PHP without zlib on SWC files
... | php | protected function getImageSizeInternal($BannerImage)
{
try
{
$arrImageSize = getimagesize(TL_ROOT . '/' . $BannerImage);
}
catch (\Exception $e)
{
$arrImageSize = false;
}
if ($arrImageSize === false)
{
//Workaround for PHP without zlib on SWC files
... | [
"protected",
"function",
"getImageSizeInternal",
"(",
"$",
"BannerImage",
")",
"{",
"try",
"{",
"$",
"arrImageSize",
"=",
"getimagesize",
"(",
"TL_ROOT",
".",
"'/'",
".",
"$",
"BannerImage",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
... | Get the size of an internal image
@param string $BannerImage Image path
@return mixed $array / false | [
"Get",
"the",
"size",
"of",
"an",
"internal",
"image"
] | train | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L110-L129 |
BugBuster1701/banner | classes/BannerImage.php | BannerImage.getImageSizeExternal | protected function getImageSizeExternal($BannerImage)
{
$token = md5(uniqid(rand(), true));
$tmpImage = 'system/tmp/mod_banner_fe_'.$token.'.tmp';
// HOOK: proxy module
if ( \Config::get('useProxy')
&& in_array('proxy', \ModuleLoader::getActive())
)
{
$objRequest = new \ProxyReques... | php | protected function getImageSizeExternal($BannerImage)
{
$token = md5(uniqid(rand(), true));
$tmpImage = 'system/tmp/mod_banner_fe_'.$token.'.tmp';
// HOOK: proxy module
if ( \Config::get('useProxy')
&& in_array('proxy', \ModuleLoader::getActive())
)
{
$objRequest = new \ProxyReques... | [
"protected",
"function",
"getImageSizeExternal",
"(",
"$",
"BannerImage",
")",
"{",
"$",
"token",
"=",
"md5",
"(",
"uniqid",
"(",
"rand",
"(",
")",
",",
"true",
")",
")",
";",
"$",
"tmpImage",
"=",
"'system/tmp/mod_banner_fe_'",
".",
"$",
"token",
".",
"... | Get the size of an external image
@param string $BannerImage Image link
@return mixed $array / false | [
"Get",
"the",
"size",
"of",
"an",
"external",
"image"
] | train | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L137-L190 |
BugBuster1701/banner | classes/BannerImage.php | BannerImage.getImageSizeCompressed | protected function getImageSizeCompressed($BannerImage)
{
$arrImageSize = false;
$res = $this->uncompressSwcData($BannerImage);
if ($res)
{
// width,height
$arrImageSize = array($res[0], $res[1], 13); // 13 = SWC
}
ModuleBannerLog::writeLog(__METHOD__ , __LINE__ , 'Image Size: '. print_r($arrImageSi... | php | protected function getImageSizeCompressed($BannerImage)
{
$arrImageSize = false;
$res = $this->uncompressSwcData($BannerImage);
if ($res)
{
// width,height
$arrImageSize = array($res[0], $res[1], 13); // 13 = SWC
}
ModuleBannerLog::writeLog(__METHOD__ , __LINE__ , 'Image Size: '. print_r($arrImageSi... | [
"protected",
"function",
"getImageSizeCompressed",
"(",
"$",
"BannerImage",
")",
"{",
"$",
"arrImageSize",
"=",
"false",
";",
"$",
"res",
"=",
"$",
"this",
"->",
"uncompressSwcData",
"(",
"$",
"BannerImage",
")",
";",
"if",
"(",
"$",
"res",
")",
"{",
"//... | getimagesize without zlib doesn't work
workaround for this
@param string $BannerImage Image
@return mixed $array / false | [
"getimagesize",
"without",
"zlib",
"doesn",
"t",
"work",
"workaround",
"for",
"this"
] | train | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L199-L211 |
BugBuster1701/banner | classes/BannerImage.php | BannerImage.uncompressSwcData | private function uncompressSwcData($filename)
{
$size = 0;
$width = 0;
$height = 0;
$file = @fopen(TL_ROOT . '/' . $filename,"rb");
if (!$file)
{
return false;
}
if ("CWS" != fread($file,3))
{
return false;
}
// Version
fread($file,1... | php | private function uncompressSwcData($filename)
{
$size = 0;
$width = 0;
$height = 0;
$file = @fopen(TL_ROOT . '/' . $filename,"rb");
if (!$file)
{
return false;
}
if ("CWS" != fread($file,3))
{
return false;
}
// Version
fread($file,1... | [
"private",
"function",
"uncompressSwcData",
"(",
"$",
"filename",
")",
"{",
"$",
"size",
"=",
"0",
";",
"$",
"width",
"=",
"0",
";",
"$",
"height",
"=",
"0",
";",
"$",
"file",
"=",
"@",
"fopen",
"(",
"TL_ROOT",
".",
"'/'",
".",
"$",
"filename",
"... | Uncompress swc files (zip-like swf)
@param string $filename
@return boolean|array false|$width,$height | [
"Uncompress",
"swc",
"files",
"(",
"zip",
"-",
"like",
"swf",
")"
] | train | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L219-L312 |
BugBuster1701/banner | classes/BannerImage.php | BannerImage.getBannerImageSizeNew | public function getBannerImageSizeNew($oldWidth,$oldHeight,$newWidth=0,$newHeight=0)
{
$Width = $oldWidth; //Default, and flash require this
$Height = $oldHeight; //Default, and flash require this
$oriSize = true; //Attribute for images without conversion
if ($newWidth > 0 && $newHeight > 0)
{
... | php | public function getBannerImageSizeNew($oldWidth,$oldHeight,$newWidth=0,$newHeight=0)
{
$Width = $oldWidth; //Default, and flash require this
$Height = $oldHeight; //Default, and flash require this
$oriSize = true; //Attribute for images without conversion
if ($newWidth > 0 && $newHeight > 0)
{
... | [
"public",
"function",
"getBannerImageSizeNew",
"(",
"$",
"oldWidth",
",",
"$",
"oldHeight",
",",
"$",
"newWidth",
"=",
"0",
",",
"$",
"newHeight",
"=",
"0",
")",
"{",
"$",
"Width",
"=",
"$",
"oldWidth",
";",
"//Default, and flash require this",
"$",
"Height"... | Calculate the new size for witdh and height
@param int $oldWidth ,mandatory
@param int $oldHeight ,mandatory
@param int $newWidth ,optional
@param int $newHeight ,optional
@return array $Width,$Height,$oriSize | [
"Calculate",
"the",
"new",
"size",
"for",
"witdh",
"and",
"height"
] | train | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L323-L348 |
BugBuster1701/banner | classes/BannerImage.php | BannerImage.getCheckBannerImageSize | public function getCheckBannerImageSize($arrImageSize, $maxWidth, $maxHeight)
{
//$arrImageSize[0] Breite (max 250px in BE)
//$arrImageSize[1] Hoehe (max 40px in BE)
//$arrImageSize[2] Type
if ($arrImageSize[0] > $arrImageSize[1]) // Breite > Hoehe = Landscape ==
{
if ($arrImageSize[0] > $maxWidth)
... | php | public function getCheckBannerImageSize($arrImageSize, $maxWidth, $maxHeight)
{
//$arrImageSize[0] Breite (max 250px in BE)
//$arrImageSize[1] Hoehe (max 40px in BE)
//$arrImageSize[2] Type
if ($arrImageSize[0] > $arrImageSize[1]) // Breite > Hoehe = Landscape ==
{
if ($arrImageSize[0] > $maxWidth)
... | [
"public",
"function",
"getCheckBannerImageSize",
"(",
"$",
"arrImageSize",
",",
"$",
"maxWidth",
",",
"$",
"maxHeight",
")",
"{",
"//$arrImageSize[0] Breite (max 250px in BE)",
"//$arrImageSize[1] Hoehe (max 40px in BE)",
"//$arrImageSize[2] Type",
"if",
"(",
"$",
"arrImage... | Calculate the new size if necessary by comparing with maxWidth and maxHeight
@param array $arrImageSize
@param int $maxWidth
@param int $maxHeight
@return array $Width,$Height,$oriSize | [
"Calculate",
"the",
"new",
"size",
"if",
"necessary",
"by",
"comparing",
"with",
"maxWidth",
"and",
"maxHeight"
] | train | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L358-L408 |
BugBuster1701/banner | classes/BannerImage.php | BannerImage.getCheckBannerImageFallback | public function getCheckBannerImageFallback($BannerImage, $intWidth, $intHeight)
{
$fallback_content = false;
$path_parts = pathinfo($BannerImage);
if ( is_file(TL_ROOT . '/' . $path_parts['dirname'] . '/' . $path_parts['filename'].'.jpg') )
{
$fallback_ext = '.jpg';
$fallback_content = tru... | php | public function getCheckBannerImageFallback($BannerImage, $intWidth, $intHeight)
{
$fallback_content = false;
$path_parts = pathinfo($BannerImage);
if ( is_file(TL_ROOT . '/' . $path_parts['dirname'] . '/' . $path_parts['filename'].'.jpg') )
{
$fallback_ext = '.jpg';
$fallback_content = tru... | [
"public",
"function",
"getCheckBannerImageFallback",
"(",
"$",
"BannerImage",
",",
"$",
"intWidth",
",",
"$",
"intHeight",
")",
"{",
"$",
"fallback_content",
"=",
"false",
";",
"$",
"path_parts",
"=",
"pathinfo",
"(",
"$",
"BannerImage",
")",
";",
"if",
"(",... | Search and get a flash fallback image path if exists
@param string $BannerImage Image path (flash file)
@param int $maxWidth Flash file width
@param int $maxHeight Flash file height
@return mixed $string/false Fallback image path / false | [
"Search",
"and",
"get",
"a",
"flash",
"fallback",
"image",
"path",
"if",
"exists"
] | train | https://github.com/BugBuster1701/banner/blob/3ffac36837923194ab0ebaf308c0b23a3684b005/classes/BannerImage.php#L418-L448 |
gregorybesson/PlaygroundCore | src/View/Helper/AdCKEditor.php | AdCKEditor.adCKEditor | public function adCKEditor($name, $options = array())
{
$CKEditor = new \PlaygroundCore\Service\CKEditor();
$CKEditor->returnOutput = true;
/*
* General module configurations
*/
if (isset($this->Config['BasePath'])) {
$CKEditor->basePath = $... | php | public function adCKEditor($name, $options = array())
{
$CKEditor = new \PlaygroundCore\Service\CKEditor();
$CKEditor->returnOutput = true;
/*
* General module configurations
*/
if (isset($this->Config['BasePath'])) {
$CKEditor->basePath = $... | [
"public",
"function",
"adCKEditor",
"(",
"$",
"name",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"CKEditor",
"=",
"new",
"\\",
"PlaygroundCore",
"\\",
"Service",
"\\",
"CKEditor",
"(",
")",
";",
"$",
"CKEditor",
"->",
"returnOutput",
"... | @param $name
@param $options
@return string | [
"@param",
"$name",
"@param",
"$options"
] | train | https://github.com/gregorybesson/PlaygroundCore/blob/f8dfa4c7660b54354933b3c28c0cf35304a649df/src/View/Helper/AdCKEditor.php#L40-L134 |
cabalphp/route | src/RouteCollection.php | RouteCollection.group | public function group($optionsOrMethod, $callback)
{
$collection = new RouteCollection($optionsOrMethod);
$this->routes[] = $collection;
$callback($collection);
return $collection;
} | php | public function group($optionsOrMethod, $callback)
{
$collection = new RouteCollection($optionsOrMethod);
$this->routes[] = $collection;
$callback($collection);
return $collection;
} | [
"public",
"function",
"group",
"(",
"$",
"optionsOrMethod",
",",
"$",
"callback",
")",
"{",
"$",
"collection",
"=",
"new",
"RouteCollection",
"(",
"$",
"optionsOrMethod",
")",
";",
"$",
"this",
"->",
"routes",
"[",
"]",
"=",
"$",
"collection",
";",
"$",
... | Undocumented function
@param string|mixed $optionsOrMethod
@param callable $callback
@return \Cabal\Route\RouteCollection | [
"Undocumented",
"function"
] | train | https://github.com/cabalphp/route/blob/13959fa0c3f6777cb9a9290c9b032dd514cd33b7/src/RouteCollection.php#L32-L38 |
cabalphp/route | src/RouteCollection.php | RouteCollection.map | public function map($optionsOrMethod, $path, $handler)
{
$route = new Route();
$route->map($optionsOrMethod, $path, $handler);
$this->routes[] = $route;
return $route;
} | php | public function map($optionsOrMethod, $path, $handler)
{
$route = new Route();
$route->map($optionsOrMethod, $path, $handler);
$this->routes[] = $route;
return $route;
} | [
"public",
"function",
"map",
"(",
"$",
"optionsOrMethod",
",",
"$",
"path",
",",
"$",
"handler",
")",
"{",
"$",
"route",
"=",
"new",
"Route",
"(",
")",
";",
"$",
"route",
"->",
"map",
"(",
"$",
"optionsOrMethod",
",",
"$",
"path",
",",
"$",
"handle... | Undocumented function
@param string $optionsOrMethod
@param string|mixed $path
@param string|mixed $handler
@return \Cabal\Route\Route | [
"Undocumented",
"function"
] | train | https://github.com/cabalphp/route/blob/13959fa0c3f6777cb9a9290c9b032dd514cd33b7/src/RouteCollection.php#L48-L54 |
geosocio/http-serializer-bundle | src/GeoSocioHttpSerializerBundle.php | GeoSocioHttpSerializerBundle.getContainerExtension | public function getContainerExtension()
{
if ($this->extension === null) {
$extension = $this->createContainerExtension();
$this->extension = $extension ?? false;
}
return $this->extension ?? null;
} | php | public function getContainerExtension()
{
if ($this->extension === null) {
$extension = $this->createContainerExtension();
$this->extension = $extension ?? false;
}
return $this->extension ?? null;
} | [
"public",
"function",
"getContainerExtension",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"extension",
"===",
"null",
")",
"{",
"$",
"extension",
"=",
"$",
"this",
"->",
"createContainerExtension",
"(",
")",
";",
"$",
"this",
"->",
"extension",
"=",
"$... | {@inheritdoc} | [
"{"
] | train | https://github.com/geosocio/http-serializer-bundle/blob/2ceb24a148204b1f3b14083b202db7e5afff2099/src/GeoSocioHttpSerializerBundle.php#L14-L22 |
movoin/one-swoole | src/Swoole/Traits/HasSwoole.php | HasSwoole.createSwooleServer | protected function createSwooleServer(string $protocolName, array $config = []): self
{
switch ($protocolName) {
// HTTP Server
case Protocol::HTTP:
$server = SwHttpServer::class;
break;
// WebSocket Server
case Protocol::WEBSO... | php | protected function createSwooleServer(string $protocolName, array $config = []): self
{
switch ($protocolName) {
// HTTP Server
case Protocol::HTTP:
$server = SwHttpServer::class;
break;
// WebSocket Server
case Protocol::WEBSO... | [
"protected",
"function",
"createSwooleServer",
"(",
"string",
"$",
"protocolName",
",",
"array",
"$",
"config",
"=",
"[",
"]",
")",
":",
"self",
"{",
"switch",
"(",
"$",
"protocolName",
")",
"{",
"// HTTP Server",
"case",
"Protocol",
"::",
"HTTP",
":",
"$"... | 创建 Swoole Server 实例
@param string $protocolName
@param array $config
@return self
@throws \InvalidArgumentException | [
"创建",
"Swoole",
"Server",
"实例"
] | train | https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Swoole/Traits/HasSwoole.php#L56-L91 |
movoin/one-swoole | src/Swoole/Traits/HasSwoole.php | HasSwoole.bindSwooleEvents | protected function bindSwooleEvents(SwServer $swoole, string $protocolName): SwServer
{
// {{ 初始化 Swoole Server 事件
$events = [
'Start' => 'onMasterStart',
'Shutdown' => 'onMasterStop',
'ManagerStart' => 'onManagerStart',
'WorkerStart' =... | php | protected function bindSwooleEvents(SwServer $swoole, string $protocolName): SwServer
{
// {{ 初始化 Swoole Server 事件
$events = [
'Start' => 'onMasterStart',
'Shutdown' => 'onMasterStop',
'ManagerStart' => 'onManagerStart',
'WorkerStart' =... | [
"protected",
"function",
"bindSwooleEvents",
"(",
"SwServer",
"$",
"swoole",
",",
"string",
"$",
"protocolName",
")",
":",
"SwServer",
"{",
"// {{ 初始化 Swoole Server 事件",
"$",
"events",
"=",
"[",
"'Start'",
"=>",
"'onMasterStart'",
",",
"'Shutdown'",
"=>",
"'onMast... | 绑定 Swoole Server 事件
@param \Swoole\Server $swoole
@param string $protocolName
@return \Swoole\Server | [
"绑定",
"Swoole",
"Server",
"事件"
] | train | https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Swoole/Traits/HasSwoole.php#L101-L156 |
phossa2/middleware | src/Middleware/Condition/MultipleCondition.php | MultipleCondition.evaluate | public function evaluate(
RequestInterface $request,
ResponseInterface $response
)/*# : bool */ {
foreach ($this->conditions as $cond) {
if (is_callable($cond)) {
$res = $cond($request, $response);
} else {
$res = $cond->evaluate($reque... | php | public function evaluate(
RequestInterface $request,
ResponseInterface $response
)/*# : bool */ {
foreach ($this->conditions as $cond) {
if (is_callable($cond)) {
$res = $cond($request, $response);
} else {
$res = $cond->evaluate($reque... | [
"public",
"function",
"evaluate",
"(",
"RequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"/*# : bool */",
"{",
"foreach",
"(",
"$",
"this",
"->",
"conditions",
"as",
"$",
"cond",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",... | {@inheritDoc} | [
"{"
] | train | https://github.com/phossa2/middleware/blob/518e97ae48077f2c11adcd3c2393830ed7ab7ce7/src/Middleware/Condition/MultipleCondition.php#L54-L69 |
movoin/one-swoole | src/Run.php | Run.shell | public static function shell($sh, $cwd = null, int $timeout = 60, bool $async = false)
{
$process = new Process($sh, $cwd, null, null, $timeout);
if ($async) {
$process->start();
$process->wait(function ($type, $buffer) {
if (Process::ERR === $type) {
... | php | public static function shell($sh, $cwd = null, int $timeout = 60, bool $async = false)
{
$process = new Process($sh, $cwd, null, null, $timeout);
if ($async) {
$process->start();
$process->wait(function ($type, $buffer) {
if (Process::ERR === $type) {
... | [
"public",
"static",
"function",
"shell",
"(",
"$",
"sh",
",",
"$",
"cwd",
"=",
"null",
",",
"int",
"$",
"timeout",
"=",
"60",
",",
"bool",
"$",
"async",
"=",
"false",
")",
"{",
"$",
"process",
"=",
"new",
"Process",
"(",
"$",
"sh",
",",
"$",
"c... | 运行 Shell
@param array|string $sh
@param string|null $cwd
@param int $timeout
@param bool $async
@return mixed
@throws \Symfony\Component\Process\Exception\ProcessFailedException | [
"运行",
"Shell"
] | train | https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Run.php#L39-L62 |
movoin/one-swoole | src/Run.php | Run.log | private static function log(string $level, string $message, array $context = [])
{
if (static::$logger !== null) {
static::$logger->$level($message, $context);
}
} | php | private static function log(string $level, string $message, array $context = [])
{
if (static::$logger !== null) {
static::$logger->$level($message, $context);
}
} | [
"private",
"static",
"function",
"log",
"(",
"string",
"$",
"level",
",",
"string",
"$",
"message",
",",
"array",
"$",
"context",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"static",
"::",
"$",
"logger",
"!==",
"null",
")",
"{",
"static",
"::",
"$",
"logg... | 写入日志
@param string $level
@param string $message
@param array $context | [
"写入日志"
] | train | https://github.com/movoin/one-swoole/blob/b9b175963ead91416cc50902a04e05ff3ef571de/src/Run.php#L81-L86 |
readdle/fqdb | src/Readdle/Database/FQDBProvider.php | FQDBProvider.defaultFQDB | public static function defaultFQDB() {
if (self::$defaultFQDB)
return self::$defaultFQDB;
if (is_callable(self::$FQDBCreatorCallback))
return self::setDefaultFQDB(call_user_func(self::$FQDBCreatorCallback));
} | php | public static function defaultFQDB() {
if (self::$defaultFQDB)
return self::$defaultFQDB;
if (is_callable(self::$FQDBCreatorCallback))
return self::setDefaultFQDB(call_user_func(self::$FQDBCreatorCallback));
} | [
"public",
"static",
"function",
"defaultFQDB",
"(",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"defaultFQDB",
")",
"return",
"self",
"::",
"$",
"defaultFQDB",
";",
"if",
"(",
"is_callable",
"(",
"self",
"::",
"$",
"FQDBCreatorCallback",
")",
")",
"return",
... | returns default FQDB
@return \Readdle\Database\FQDB | [
"returns",
"default",
"FQDB"
] | train | https://github.com/readdle/fqdb/blob/4ef2e8f3343a7c8fbb309c243be502a160c42083/src/Readdle/Database/FQDBProvider.php#L128-L134 |
activecollab/databasestructure | src/Field/Scalar/Traits/LengthInterface/Implementation.php | Implementation.& | public function &length($length)
{
$length = (int) $length;
if ($length < $this->getMinLength()) {
throw new InvalidArgumentException("Min length is {$this->getMinLength()}");
}
if ($length > $this->getMaxLength()) {
throw new InvalidArgumentException("Max l... | php | public function &length($length)
{
$length = (int) $length;
if ($length < $this->getMinLength()) {
throw new InvalidArgumentException("Min length is {$this->getMinLength()}");
}
if ($length > $this->getMaxLength()) {
throw new InvalidArgumentException("Max l... | [
"public",
"function",
"&",
"length",
"(",
"$",
"length",
")",
"{",
"$",
"length",
"=",
"(",
"int",
")",
"$",
"length",
";",
"if",
"(",
"$",
"length",
"<",
"$",
"this",
"->",
"getMinLength",
"(",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentExceptio... | {@inheritdoc} | [
"{"
] | train | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Field/Scalar/Traits/LengthInterface/Implementation.php#L34-L49 |
VDMi/Guzzle-oAuth | src/GuzzleOauth/Consumer/Google.php | Google.getUserEmail | public function getUserEmail($info = NULL) {
if (empty($info)) {
$info = $this->getUserInfo();
}
$emails = $info->get('emails');
if (is_array($emails) && count($emails)) {
$email = reset($emails);
return $email['value'];
}
} | php | public function getUserEmail($info = NULL) {
if (empty($info)) {
$info = $this->getUserInfo();
}
$emails = $info->get('emails');
if (is_array($emails) && count($emails)) {
$email = reset($emails);
return $email['value'];
}
} | [
"public",
"function",
"getUserEmail",
"(",
"$",
"info",
"=",
"NULL",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"info",
")",
")",
"{",
"$",
"info",
"=",
"$",
"this",
"->",
"getUserInfo",
"(",
")",
";",
"}",
"$",
"emails",
"=",
"$",
"info",
"->",
"... | Google can return an array of emails.
We only give back the first one, since we request one e-mail address | [
"Google",
"can",
"return",
"an",
"array",
"of",
"emails",
".",
"We",
"only",
"give",
"back",
"the",
"first",
"one",
"since",
"we",
"request",
"one",
"e",
"-",
"mail",
"address"
] | train | https://github.com/VDMi/Guzzle-oAuth/blob/e2b2561e4e402e13ba605082bf768b29942f90cb/src/GuzzleOauth/Consumer/Google.php#L13-L22 |
gdbots/pbjx-bundle-php | src/PbjxTokenSigner.php | PbjxTokenSigner.addKey | public function addKey(string $kid, string $secret): void
{
$this->keys[$kid] = $secret;
} | php | public function addKey(string $kid, string $secret): void
{
$this->keys[$kid] = $secret;
} | [
"public",
"function",
"addKey",
"(",
"string",
"$",
"kid",
",",
"string",
"$",
"secret",
")",
":",
"void",
"{",
"$",
"this",
"->",
"keys",
"[",
"$",
"kid",
"]",
"=",
"$",
"secret",
";",
"}"
] | Adds a signing key (will overwrite existing kid if present).
@param string $kid
@param string $secret | [
"Adds",
"a",
"signing",
"key",
"(",
"will",
"overwrite",
"existing",
"kid",
"if",
"present",
")",
"."
] | train | https://github.com/gdbots/pbjx-bundle-php/blob/f3c0088583879fc92f13247a0752634bd8696eac/src/PbjxTokenSigner.php#L47-L50 |
gdbots/pbjx-bundle-php | src/PbjxTokenSigner.php | PbjxTokenSigner.sign | public function sign(string $content, string $aud, ?string $kid = null): PbjxToken
{
$kid = $kid ?: $this->defaultKid;
return PbjxToken::create($content, $aud, $kid, $this->getSecret($kid));
} | php | public function sign(string $content, string $aud, ?string $kid = null): PbjxToken
{
$kid = $kid ?: $this->defaultKid;
return PbjxToken::create($content, $aud, $kid, $this->getSecret($kid));
} | [
"public",
"function",
"sign",
"(",
"string",
"$",
"content",
",",
"string",
"$",
"aud",
",",
"?",
"string",
"$",
"kid",
"=",
"null",
")",
":",
"PbjxToken",
"{",
"$",
"kid",
"=",
"$",
"kid",
"?",
":",
"$",
"this",
"->",
"defaultKid",
";",
"return",
... | Creates a new signed token for the provided content.
@param string $content Pbjx content that is being signed
@param string $aud Pbjx endpoint this token will be sent to
@param string $kid Key ID to use to sign the token.
@return PbjxToken | [
"Creates",
"a",
"new",
"signed",
"token",
"for",
"the",
"provided",
"content",
"."
] | train | https://github.com/gdbots/pbjx-bundle-php/blob/f3c0088583879fc92f13247a0752634bd8696eac/src/PbjxTokenSigner.php#L71-L75 |
gdbots/pbjx-bundle-php | src/PbjxTokenSigner.php | PbjxTokenSigner.validate | public function validate(string $content, string $aud, string $token): void
{
$actualToken = PbjxToken::fromString($token);
$expectedToken = PbjxToken::create(
$content,
$aud,
$actualToken->getKid(),
$this->getSecret($actualToken->getKid()),
... | php | public function validate(string $content, string $aud, string $token): void
{
$actualToken = PbjxToken::fromString($token);
$expectedToken = PbjxToken::create(
$content,
$aud,
$actualToken->getKid(),
$this->getSecret($actualToken->getKid()),
... | [
"public",
"function",
"validate",
"(",
"string",
"$",
"content",
",",
"string",
"$",
"aud",
",",
"string",
"$",
"token",
")",
":",
"void",
"{",
"$",
"actualToken",
"=",
"PbjxToken",
"::",
"fromString",
"(",
"$",
"token",
")",
";",
"$",
"expectedToken",
... | Validates that the provided token is valid and okay to use
and also creates a new token with the same secret and content
and compares our result to the provided token to determine
if they are an exact match.
If no exception is thrown the token is valid.
@param string $content Pbjx content that has been signed
@param ... | [
"Validates",
"that",
"the",
"provided",
"token",
"is",
"valid",
"and",
"okay",
"to",
"use",
"and",
"also",
"creates",
"a",
"new",
"token",
"with",
"the",
"same",
"secret",
"and",
"content",
"and",
"compares",
"our",
"result",
"to",
"the",
"provided",
"toke... | train | https://github.com/gdbots/pbjx-bundle-php/blob/f3c0088583879fc92f13247a0752634bd8696eac/src/PbjxTokenSigner.php#L91-L108 |
gdbots/pbjx-bundle-php | src/PbjxTokenSigner.php | PbjxTokenSigner.getSecret | private function getSecret(string $kid): string
{
$secret = $this->keys[$kid] ?? null;
if (null !== $secret) {
return $secret;
}
throw new \InvalidArgumentException('PbjxTokenSigner given unknown kid.', Code::INVALID_ARGUMENT);
} | php | private function getSecret(string $kid): string
{
$secret = $this->keys[$kid] ?? null;
if (null !== $secret) {
return $secret;
}
throw new \InvalidArgumentException('PbjxTokenSigner given unknown kid.', Code::INVALID_ARGUMENT);
} | [
"private",
"function",
"getSecret",
"(",
"string",
"$",
"kid",
")",
":",
"string",
"{",
"$",
"secret",
"=",
"$",
"this",
"->",
"keys",
"[",
"$",
"kid",
"]",
"??",
"null",
";",
"if",
"(",
"null",
"!==",
"$",
"secret",
")",
"{",
"return",
"$",
"sec... | @param string $kid
@return string
@throws \InvalidArgumentException | [
"@param",
"string",
"$kid"
] | train | https://github.com/gdbots/pbjx-bundle-php/blob/f3c0088583879fc92f13247a0752634bd8696eac/src/PbjxTokenSigner.php#L117-L125 |
axelitus/php-base | src/Str.php | Str.compare | public static function compare($str1, $str2, $caseInsensitive = false)
{
return ($caseInsensitive) ? strcasecmp($str1, $str2) : strcmp($str1, $str2);
} | php | public static function compare($str1, $str2, $caseInsensitive = false)
{
return ($caseInsensitive) ? strcasecmp($str1, $str2) : strcmp($str1, $str2);
} | [
"public",
"static",
"function",
"compare",
"(",
"$",
"str1",
",",
"$",
"str2",
",",
"$",
"caseInsensitive",
"=",
"false",
")",
"{",
"return",
"(",
"$",
"caseInsensitive",
")",
"?",
"strcasecmp",
"(",
"$",
"str1",
",",
"$",
"str2",
")",
":",
"strcmp",
... | Compares two strings.
@param string $str1 The first string.
@param string $str2 The second string.
@param bool $caseInsensitive Whether the comparison should be case sensitive or case insensitive.
@return int Returns < 0 if str1 is less than str2; > 0 if str1 is greater than str2, and 0 if the... | [
"Compares",
"two",
"strings",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L147-L150 |
axelitus/php-base | src/Str.php | Str.contains | public static function contains($input, $search, $caseInsensitive = false, $encoding = self::DEFAULT_ENCODING)
{
return (static::pos($input, $search, $caseInsensitive, $encoding) !== false);
} | php | public static function contains($input, $search, $caseInsensitive = false, $encoding = self::DEFAULT_ENCODING)
{
return (static::pos($input, $search, $caseInsensitive, $encoding) !== false);
} | [
"public",
"static",
"function",
"contains",
"(",
"$",
"input",
",",
"$",
"search",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"(",
"static",
"::",
"pos",
"(",
"$",
"input",
... | Verifies if a string contains a substring. The $encoding parameter is used to determine the
encoding and thus the proper method.
@param string $input The input string to compare to
@param string $search The substring to compare the ending to
@param bool $caseInsensitive Whether the comparison is c... | [
"Verifies",
"if",
"a",
"string",
"contains",
"a",
"substring",
".",
"The",
"$encoding",
"parameter",
"is",
"used",
"to",
"determine",
"the",
"encoding",
"and",
"thus",
"the",
"proper",
"method",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L179-L182 |
axelitus/php-base | src/Str.php | Str.beginsWith | public static function beginsWith($input, $search, $caseInsensitive = false, $encoding = self::DEFAULT_ENCODING)
{
$substr = static::sub($input, 0, static::length($search), $encoding);
return (static::compare($substr, $search, $caseInsensitive) === 0);
} | php | public static function beginsWith($input, $search, $caseInsensitive = false, $encoding = self::DEFAULT_ENCODING)
{
$substr = static::sub($input, 0, static::length($search), $encoding);
return (static::compare($substr, $search, $caseInsensitive) === 0);
} | [
"public",
"static",
"function",
"beginsWith",
"(",
"$",
"input",
",",
"$",
"search",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"$",
"substr",
"=",
"static",
"::",
"sub",
"(",
"$",
... | Verifies if a string begins with a substring.
Uses the multibyte function if available with the given encoding $encoding.
The comparison is case-sensitive by default.
@param string $input The input string to compare to.
@param string $search The substring to compare the beginning to.
@param bool ... | [
"Verifies",
"if",
"a",
"string",
"begins",
"with",
"a",
"substring",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L198-L203 |
axelitus/php-base | src/Str.php | Str.endsWith | public static function endsWith($input, $search, $caseInsensitive = false, $encoding = self::DEFAULT_ENCODING)
{
if (($length = static::length($search, $encoding)) == 0) {
return true;
}
$substr = static::sub($input, -$length, $length, $encoding);
return (static::compar... | php | public static function endsWith($input, $search, $caseInsensitive = false, $encoding = self::DEFAULT_ENCODING)
{
if (($length = static::length($search, $encoding)) == 0) {
return true;
}
$substr = static::sub($input, -$length, $length, $encoding);
return (static::compar... | [
"public",
"static",
"function",
"endsWith",
"(",
"$",
"input",
",",
"$",
"search",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"if",
"(",
"(",
"$",
"length",
"=",
"static",
"::",
"le... | Verifies if a string ends with a substring.
Uses the multibyte function if available with the given encoding $encoding.
The comparison is case-sensitive by default.
@param string $input The input string to compare to.
@param string $search The substring to compare the ending to.
@param bool $case... | [
"Verifies",
"if",
"a",
"string",
"ends",
"with",
"a",
"substring",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L219-L228 |
axelitus/php-base | src/Str.php | Str.isOneOf | public static function isOneOf($input, array $values, $caseInsensitive = false, $returnIndex = false)
{
if (is_null($input)) {
return false;
}
foreach ($values as $index => $str) {
if (static::equals($input, $str, $caseInsensitive)) {
return ($returnI... | php | public static function isOneOf($input, array $values, $caseInsensitive = false, $returnIndex = false)
{
if (is_null($input)) {
return false;
}
foreach ($values as $index => $str) {
if (static::equals($input, $str, $caseInsensitive)) {
return ($returnI... | [
"public",
"static",
"function",
"isOneOf",
"(",
"$",
"input",
",",
"array",
"$",
"values",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"returnIndex",
"=",
"false",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"input",
")",
")",
"{",
"return",
"... | Verifies if the input string is one of the values of the given array.
Verifies if the input string is one of the values of the given array. Each of the values
of the array is matched against the input string. The index of the value that matched can
be returned instead of the default bool value. The comparison can be c... | [
"Verifies",
"if",
"the",
"input",
"string",
"is",
"one",
"of",
"the",
"values",
"of",
"the",
"given",
"array",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L246-L259 |
axelitus/php-base | src/Str.php | Str.match | public static function match($input, $pattern, array &$matches = null, $flags = 0, $offset = 0)
{
return preg_match($pattern, $input, $matches, $flags, $offset);
} | php | public static function match($input, $pattern, array &$matches = null, $flags = 0, $offset = 0)
{
return preg_match($pattern, $input, $matches, $flags, $offset);
} | [
"public",
"static",
"function",
"match",
"(",
"$",
"input",
",",
"$",
"pattern",
",",
"array",
"&",
"$",
"matches",
"=",
"null",
",",
"$",
"flags",
"=",
"0",
",",
"$",
"offset",
"=",
"0",
")",
"{",
"return",
"preg_match",
"(",
"$",
"pattern",
",",
... | Searches the input string for a match to the regular expression given in pattern.
@param string $input The input string.
@param string $pattern The pattern to search for, as a string.
@param array $matches If matches is provided, then it is filled with the results of search.
$matches[0] will contain the text that m... | [
"Searches",
"the",
"input",
"string",
"for",
"a",
"match",
"to",
"the",
"regular",
"expression",
"given",
"in",
"pattern",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L276-L279 |
axelitus/php-base | src/Str.php | Str.length | public static function length($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strlen') ? mb_strlen($input, $encoding) : strlen($input);
} | php | public static function length($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strlen') ? mb_strlen($input, $encoding) : strlen($input);
} | [
"public",
"static",
"function",
"length",
"(",
"$",
"input",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"function_exists",
"(",
"'mb_strlen'",
")",
"?",
"mb_strlen",
"(",
"$",
"input",
",",
"$",
"encoding",
")",
":",
... | Gets the length of the given string.
Uses the multibyte function if available with the given encoding $encoding.
@author FuelPHP (http://fuelphp.com)
@param string $input The input string.
@param string $encoding The encoding of the input string for multibyte functions.
@return int Returns the length of the str... | [
"Gets",
"the",
"length",
"of",
"the",
"given",
"string",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L297-L300 |
axelitus/php-base | src/Str.php | Str.sub | public static function sub($input, $start, $length = null, $encoding = self::DEFAULT_ENCODING)
{
// sub input functions don't parse null correctly
$length = is_null($length)
? (function_exists('mb_substr')
? mb_strlen($input, $encoding)
: strlen($input)) -... | php | public static function sub($input, $start, $length = null, $encoding = self::DEFAULT_ENCODING)
{
// sub input functions don't parse null correctly
$length = is_null($length)
? (function_exists('mb_substr')
? mb_strlen($input, $encoding)
: strlen($input)) -... | [
"public",
"static",
"function",
"sub",
"(",
"$",
"input",
",",
"$",
"start",
",",
"$",
"length",
"=",
"null",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"// sub input functions don't parse null correctly",
"$",
"length",
"=",
"is_nu... | Returns the portion of string specified by the $start and $length parameters.
USes the multibyte function if available with the given encoding $encoding and falls back to substr.
@author FuelPHP (http://fuelphp.com)
@param string $input The input string.
@param int $start The start index from where to begi... | [
"Returns",
"the",
"portion",
"of",
"string",
"specified",
"by",
"the",
"$start",
"and",
"$length",
"parameters",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L321-L334 |
axelitus/php-base | src/Str.php | Str.pos | public static function pos($input, $search, $caseInsensitive = false, $encoding = self::DEFAULT_ENCODING)
{
if ($caseInsensitive) {
return function_exists('mb_stripos')
? mb_stripos($input, $search, 0, $encoding)
: (stripos($input, $search) !== false ? true : fals... | php | public static function pos($input, $search, $caseInsensitive = false, $encoding = self::DEFAULT_ENCODING)
{
if ($caseInsensitive) {
return function_exists('mb_stripos')
? mb_stripos($input, $search, 0, $encoding)
: (stripos($input, $search) !== false ? true : fals... | [
"public",
"static",
"function",
"pos",
"(",
"$",
"input",
",",
"$",
"search",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"if",
"(",
"$",
"caseInsensitive",
")",
"{",
"return",
"functi... | Finds the position of the first occurrence of a substring in a string.
The $encoding parameter is used to determine the encoding and thus the
proper method to be used.
@param string $input The input string to compare to
@param string $search The substring to compare the ending to
@param bool $case... | [
"Finds",
"the",
"position",
"of",
"the",
"first",
"occurrence",
"of",
"a",
"substring",
"in",
"a",
"string",
".",
"The",
"$encoding",
"parameter",
"is",
"used",
"to",
"determine",
"the",
"encoding",
"and",
"thus",
"the",
"proper",
"method",
"to",
"be",
"us... | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L350-L361 |
axelitus/php-base | src/Str.php | Str.replace | public static function replace(
$input,
$search,
$replace,
$caseInsensitive = false,
$encoding = self::DEFAULT_ENCODING,
&$count = null
) {
return function_exists('mb_strlen')
? static::mbStrReplaceCaller($search, $replace, $input, $caseInsensitive... | php | public static function replace(
$input,
$search,
$replace,
$caseInsensitive = false,
$encoding = self::DEFAULT_ENCODING,
&$count = null
) {
return function_exists('mb_strlen')
? static::mbStrReplaceCaller($search, $replace, $input, $caseInsensitive... | [
"public",
"static",
"function",
"replace",
"(",
"$",
"input",
",",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
",",
"&",
"$",
"count",
"=",
"null",
")",
"{"... | Replaces a substring inside a string.
@param string $input The input string
@param string $search The substring to be replaced
@param string $replace The substring replacement
@param bool $caseInsensitive Whether the comparison should be case sensitive
@param string $encoding The en... | [
"Replaces",
"a",
"substring",
"inside",
"a",
"string",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L380-L394 |
axelitus/php-base | src/Str.php | Str.mbStrReplaceCaller | protected static function mbStrReplaceCaller(
$search,
$replace,
$subject,
$caseInsensitive = false,
$encoding = self::DEFAULT_ENCODING,
&$count = null
) {
if (is_array($subject)) {
$result = [];
foreach ($subject as $item) {
... | php | protected static function mbStrReplaceCaller(
$search,
$replace,
$subject,
$caseInsensitive = false,
$encoding = self::DEFAULT_ENCODING,
&$count = null
) {
if (is_array($subject)) {
$result = [];
foreach ($subject as $item) {
... | [
"protected",
"static",
"function",
"mbStrReplaceCaller",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"subject",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
",",
"&",
"$",
"count",
"=",
"nul... | Replaces a substring inside a string with multi-byte support
@param string|array $search
@param string|array $replace
@param string|array $subject
@param bool $caseInsensitive
@param string $encoding
@param int $count
@return array|string
@see https://github.com/faceleg/php-mb_str_replace
@... | [
"Replaces",
"a",
"substring",
"inside",
"a",
"string",
"with",
"multi",
"-",
"byte",
"support"
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L410-L444 |
axelitus/php-base | src/Str.php | Str.mbStrReplaceInternal | protected static function mbStrReplaceInternal(
$search,
$replace,
$subject,
$caseInsensitive = false,
$encoding = self::DEFAULT_ENCODING,
&$count = null
) {
$searchLength = mb_strlen($search, $encoding);
$subjectLength = mb_strlen($subject, $encoding)... | php | protected static function mbStrReplaceInternal(
$search,
$replace,
$subject,
$caseInsensitive = false,
$encoding = self::DEFAULT_ENCODING,
&$count = null
) {
$searchLength = mb_strlen($search, $encoding);
$subjectLength = mb_strlen($subject, $encoding)... | [
"protected",
"static",
"function",
"mbStrReplaceInternal",
"(",
"$",
"search",
",",
"$",
"replace",
",",
"$",
"subject",
",",
"$",
"caseInsensitive",
"=",
"false",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
",",
"&",
"$",
"count",
"=",
"n... | Implementation of mb_str_replace. Do not call directly.
@param string|array $search
@param string|array $replace
@param string|array $subject
@param bool $caseInsensitive
@param string $encoding
@param int $count
@return string
@see https://github.com/faceleg/php-mb_str_replace
@SuppressWa... | [
"Implementation",
"of",
"mb_str_replace",
".",
"Do",
"not",
"call",
"directly",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L460-L495 |
axelitus/php-base | src/Str.php | Str.truncate | public static function truncate($input, $limit, $continuation = '...', $isHtml = false)
{
$offset = 0;
$tags = [];
if ($isHtml) {
$input = static::truncateHtml($input, $limit, $offset, $tags);
}
$newString = static::sub($input, 0, $limit = min(static::length($inp... | php | public static function truncate($input, $limit, $continuation = '...', $isHtml = false)
{
$offset = 0;
$tags = [];
if ($isHtml) {
$input = static::truncateHtml($input, $limit, $offset, $tags);
}
$newString = static::sub($input, 0, $limit = min(static::length($inp... | [
"public",
"static",
"function",
"truncate",
"(",
"$",
"input",
",",
"$",
"limit",
",",
"$",
"continuation",
"=",
"'...'",
",",
"$",
"isHtml",
"=",
"false",
")",
"{",
"$",
"offset",
"=",
"0",
";",
"$",
"tags",
"=",
"[",
"]",
";",
"if",
"(",
"$",
... | Truncates a string to the given length.
Truncates a string to the given length. It will optionally preserve HTML tags if $is_html is set to true.
@author FuelPHP (http://fuelphp.com)
@param string $input The string to truncate.
@param int $limit The number of characters to truncate to.
@param ... | [
"Truncates",
"a",
"string",
"to",
"the",
"given",
"length",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L512-L525 |
axelitus/php-base | src/Str.php | Str.truncateHtml | protected static function truncateHtml($input, &$limit, &$offset, &$tags)
{
static::truncateSpecialChars($input, $limit);
// Handle all the html tags.
preg_match_all('/<[^>]+>([^<]*)/', $input, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
if (is_array($matches) || $matches insta... | php | protected static function truncateHtml($input, &$limit, &$offset, &$tags)
{
static::truncateSpecialChars($input, $limit);
// Handle all the html tags.
preg_match_all('/<[^>]+>([^<]*)/', $input, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
if (is_array($matches) || $matches insta... | [
"protected",
"static",
"function",
"truncateHtml",
"(",
"$",
"input",
",",
"&",
"$",
"limit",
",",
"&",
"$",
"offset",
",",
"&",
"$",
"tags",
")",
"{",
"static",
"::",
"truncateSpecialChars",
"(",
"$",
"input",
",",
"$",
"limit",
")",
";",
"// Handle a... | Handles the strip of tags in the {@link truncate} function.
@param string $input The input string.
@param int $limit The number of characters to truncate to.
@param int $offset The offset.
@param array $tags The stripped tags.
@return string Returns the stripped string to reassemble. | [
"Handles",
"the",
"strip",
"of",
"tags",
"in",
"the",
"{",
"@link",
"truncate",
"}",
"function",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L537-L561 |
axelitus/php-base | src/Str.php | Str.truncateSpecialChars | protected static function truncateSpecialChars($input, &$limit)
{
// Handle special characters.
preg_match_all('/&[a-z]+;/i', strip_tags($input), $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
if (is_array($matches) || $matches instanceof \Traversable) {
foreach ($matches as $m... | php | protected static function truncateSpecialChars($input, &$limit)
{
// Handle special characters.
preg_match_all('/&[a-z]+;/i', strip_tags($input), $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER);
if (is_array($matches) || $matches instanceof \Traversable) {
foreach ($matches as $m... | [
"protected",
"static",
"function",
"truncateSpecialChars",
"(",
"$",
"input",
",",
"&",
"$",
"limit",
")",
"{",
"// Handle special characters.",
"preg_match_all",
"(",
"'/&[a-z]+;/i'",
",",
"strip_tags",
"(",
"$",
"input",
")",
",",
"$",
"matches",
",",
"PREG_OF... | Handles the special characters while stripping html tags in the {@link truncateHtml} function.
@param string $input The input string.
@param int $limit The number of characters to truncate to. | [
"Handles",
"the",
"special",
"characters",
"while",
"stripping",
"html",
"tags",
"in",
"the",
"{",
"@link",
"truncateHtml",
"}",
"function",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L569-L581 |
axelitus/php-base | src/Str.php | Str.lower | public static function lower($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtolower')
? mb_strtolower($input, $encoding)
: strtolower($input);
} | php | public static function lower($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtolower')
? mb_strtolower($input, $encoding)
: strtolower($input);
} | [
"public",
"static",
"function",
"lower",
"(",
"$",
"input",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"function_exists",
"(",
"'mb_strtolower'",
")",
"?",
"mb_strtolower",
"(",
"$",
"input",
",",
"$",
"encoding",
")",
... | Returns a lowercased string.
Returns a lowercased string. The $encoding parameter is used to determine the input string encoding
and thus use the proper method. The functions uses mb_strtolower if present and falls back to strtolower.
@author FuelPHP (http://fuelphp.com)
@param string $input The input string
@par... | [
"Returns",
"a",
"lowercased",
"string",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L600-L605 |
axelitus/php-base | src/Str.php | Str.upper | public static function upper($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtoupper')
? mb_strtoupper($input, $encoding)
: strtoupper($input);
} | php | public static function upper($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtoupper')
? mb_strtoupper($input, $encoding)
: strtoupper($input);
} | [
"public",
"static",
"function",
"upper",
"(",
"$",
"input",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"function_exists",
"(",
"'mb_strtoupper'",
")",
"?",
"mb_strtoupper",
"(",
"$",
"input",
",",
"$",
"encoding",
")",
... | Returns an uppercased string.
Returns an uppercased string. The $encoding parameter is used to determine the input string encoding
and thus use the proper method. The functions uses mb_strtoupper if present and falls back to strtoupper.
@author FuelPHP (http://fuelphp.com)
@param string $input The input string
@p... | [
"Returns",
"an",
"uppercased",
"string",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L620-L625 |
axelitus/php-base | src/Str.php | Str.lcfirst | public static function lcfirst($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtolower')
? mb_strtolower(mb_substr($input, 0, 1, $encoding), $encoding) .
mb_substr($input, 1, mb_strlen($input, $encoding), $encoding)
: lcfirst($input);
} | php | public static function lcfirst($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtolower')
? mb_strtolower(mb_substr($input, 0, 1, $encoding), $encoding) .
mb_substr($input, 1, mb_strlen($input, $encoding), $encoding)
: lcfirst($input);
} | [
"public",
"static",
"function",
"lcfirst",
"(",
"$",
"input",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"function_exists",
"(",
"'mb_strtolower'",
")",
"?",
"mb_strtolower",
"(",
"mb_substr",
"(",
"$",
"input",
",",
"0"... | Returns a string with the first char as lowercase.
Returns a string with the first char as lowercase. The other characters in the string are left untouched.
The $encoding parameter is used to determine the input string encoding and thus use the proper method.
The function uses mb_strtolower, mb_mb_substr and mb_strlen... | [
"Returns",
"a",
"string",
"with",
"the",
"first",
"char",
"as",
"lowercase",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L641-L647 |
axelitus/php-base | src/Str.php | Str.ucfirst | public static function ucfirst($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtoupper')
? mb_strtoupper(mb_substr($input, 0, 1, $encoding), $encoding) .
mb_substr($input, 1, mb_strlen($input, $encoding), $encoding)
: ucfirst($input);
} | php | public static function ucfirst($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_strtoupper')
? mb_strtoupper(mb_substr($input, 0, 1, $encoding), $encoding) .
mb_substr($input, 1, mb_strlen($input, $encoding), $encoding)
: ucfirst($input);
} | [
"public",
"static",
"function",
"ucfirst",
"(",
"$",
"input",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"function_exists",
"(",
"'mb_strtoupper'",
")",
"?",
"mb_strtoupper",
"(",
"mb_substr",
"(",
"$",
"input",
",",
"0"... | Returns a string with the first char as uppercase.
Returns a string with the first char as uppercase. The other characters in the string are left untouched.
The $encoding parameter is used to determine the input string encoding and thus use the proper method.
The function uses mb_strtoupper, mb_mb_substr and mb_strlen... | [
"Returns",
"a",
"string",
"with",
"the",
"first",
"char",
"as",
"uppercase",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L663-L669 |
axelitus/php-base | src/Str.php | Str.ucwords | public static function ucwords($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_convert_case')
? mb_convert_case($input, MB_CASE_TITLE, $encoding)
: ucwords(strtolower($input));
} | php | public static function ucwords($input, $encoding = self::DEFAULT_ENCODING)
{
return function_exists('mb_convert_case')
? mb_convert_case($input, MB_CASE_TITLE, $encoding)
: ucwords(strtolower($input));
} | [
"public",
"static",
"function",
"ucwords",
"(",
"$",
"input",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"return",
"function_exists",
"(",
"'mb_convert_case'",
")",
"?",
"mb_convert_case",
"(",
"$",
"input",
",",
"MB_CASE_TITLE",
",... | Returns a string with the words capitalized.
Returns a string with the words capitalized. The $encoding parameter is used to determine the input string
encoding and thus use the proper method. The function uses mb_convert_case if present and falls back to ucwords.
The ucwords function normally does not lowercase the i... | [
"Returns",
"a",
"string",
"with",
"the",
"words",
"capitalized",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L685-L690 |
axelitus/php-base | src/Str.php | Str.studly | public static function studly($input, array $separators = ['_'], $encoding = self::DEFAULT_ENCODING)
{
$studly = $input;
if (!empty($separators)) {
$studly = preg_replace_callback(
static::studlyBuildPattern($separators),
function ($matches) {
... | php | public static function studly($input, array $separators = ['_'], $encoding = self::DEFAULT_ENCODING)
{
$studly = $input;
if (!empty($separators)) {
$studly = preg_replace_callback(
static::studlyBuildPattern($separators),
function ($matches) {
... | [
"public",
"static",
"function",
"studly",
"(",
"$",
"input",
",",
"array",
"$",
"separators",
"=",
"[",
"'_'",
"]",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"$",
"studly",
"=",
"$",
"input",
";",
"if",
"(",
"!",
"empty",... | Converts a char(s)-separated string into studly caps.
Converts a char(s)-separated string into studly caps. The string can be split using one or more
separators (being them a single char or a string). The $encoding parameter is used to determine the
input string encoding and thus use the proper method.
When the space ... | [
"Converts",
"a",
"char",
"(",
"s",
")",
"-",
"separated",
"string",
"into",
"studly",
"caps",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L711-L731 |
axelitus/php-base | src/Str.php | Str.studlyBuildPattern | protected static function studlyBuildPattern(array $separators)
{
$pattern = '';
foreach ($separators as $separator) {
$pattern .= '|' . preg_quote($separator);
}
$pattern = '/(^' . $pattern . ')(.)/';
return $pattern;
} | php | protected static function studlyBuildPattern(array $separators)
{
$pattern = '';
foreach ($separators as $separator) {
$pattern .= '|' . preg_quote($separator);
}
$pattern = '/(^' . $pattern . ')(.)/';
return $pattern;
} | [
"protected",
"static",
"function",
"studlyBuildPattern",
"(",
"array",
"$",
"separators",
")",
"{",
"$",
"pattern",
"=",
"''",
";",
"foreach",
"(",
"$",
"separators",
"as",
"$",
"separator",
")",
"{",
"$",
"pattern",
".=",
"'|'",
".",
"preg_quote",
"(",
... | Builds the studly patter with the given separators.
@param array $separators The array of separators to use.
@return string Returns the built studly pattern. | [
"Builds",
"the",
"studly",
"patter",
"with",
"the",
"given",
"separators",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L740-L749 |
axelitus/php-base | src/Str.php | Str.camel | public static function camel($input, array $separators = ['_'], $encoding = self::DEFAULT_ENCODING)
{
$camel = static::studly($input, $separators, $encoding);
$words = explode(' ', $camel);
foreach ($words as &$word) {
$word = static::lcfirst($word, $encoding);
}
... | php | public static function camel($input, array $separators = ['_'], $encoding = self::DEFAULT_ENCODING)
{
$camel = static::studly($input, $separators, $encoding);
$words = explode(' ', $camel);
foreach ($words as &$word) {
$word = static::lcfirst($word, $encoding);
}
... | [
"public",
"static",
"function",
"camel",
"(",
"$",
"input",
",",
"array",
"$",
"separators",
"=",
"[",
"'_'",
"]",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"$",
"camel",
"=",
"static",
"::",
"studly",
"(",
"$",
"input",
... | Converts a char(s)-separated string into camel case.
Converts a char(s)-separated string into camel case. The string can be split using one or more
separators (being them a single char or a string). The $encoding parameter is used to determine
the input string encoding and thus use the proper method.
When the space ch... | [
"Converts",
"a",
"char",
"(",
"s",
")",
"-",
"separated",
"string",
"into",
"camel",
"case",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L766-L776 |
axelitus/php-base | src/Str.php | Str.separated | public static function separated($input, $separator = '_', $transform = null, $encoding = self::DEFAULT_ENCODING)
{
if (!is_string($separator) || $separator == '') {
throw new \InvalidArgumentException("The \$separator parameter must be a non-empty string.");
}
$separated = preg... | php | public static function separated($input, $separator = '_', $transform = null, $encoding = self::DEFAULT_ENCODING)
{
if (!is_string($separator) || $separator == '') {
throw new \InvalidArgumentException("The \$separator parameter must be a non-empty string.");
}
$separated = preg... | [
"public",
"static",
"function",
"separated",
"(",
"$",
"input",
",",
"$",
"separator",
"=",
"'_'",
",",
"$",
"transform",
"=",
"null",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"if",
"(",
"!",
"is_string",
"(",
"$",
"separa... | Converts a studly-caps-cased or camel-cased string into a char(s)-separated string using a given separator.
Converts a studly-caps-cased or camel-cased string into a char(s)-separated string using a given separator.
Additionally it can run one of the following transformation in every separated word (words are split by... | [
"Converts",
"a",
"studly",
"-",
"caps",
"-",
"cased",
"or",
"camel",
"-",
"cased",
"string",
"into",
"a",
"char",
"(",
"s",
")",
"-",
"separated",
"string",
"using",
"a",
"given",
"separator",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L794-L817 |
axelitus/php-base | src/Str.php | Str.separatedTransform | protected static function separatedTransform($input, $transform, $encoding = self::DEFAULT_ENCODING)
{
// Do lcfirst, ucfirst and ucwords transformations
if (static::isOneOf($transform, ['lower', 'upper', 'lcfirst', 'ucfirst', 'ucwords'])) {
$words = explode(' ', $input);
Tra... | php | protected static function separatedTransform($input, $transform, $encoding = self::DEFAULT_ENCODING)
{
// Do lcfirst, ucfirst and ucwords transformations
if (static::isOneOf($transform, ['lower', 'upper', 'lcfirst', 'ucfirst', 'ucwords'])) {
$words = explode(' ', $input);
Tra... | [
"protected",
"static",
"function",
"separatedTransform",
"(",
"$",
"input",
",",
"$",
"transform",
",",
"$",
"encoding",
"=",
"self",
"::",
"DEFAULT_ENCODING",
")",
"{",
"// Do lcfirst, ucfirst and ucwords transformations",
"if",
"(",
"static",
"::",
"isOneOf",
"(",... | Runs the transformation for the {@link separated} function.
@param string $input The string to apply the transformation to.
@param string $transform The transformation to apply (options:'lcfirst', 'ucfirst', 'ucwords').
@param string $encoding The encoding of the input string.
@return string The transformed inpu... | [
"Runs",
"the",
"transformation",
"for",
"the",
"{",
"@link",
"separated",
"}",
"function",
"."
] | train | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Str.php#L828-L847 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.