repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
kassko/data-mapper | src/ObjectManager.php | ObjectManager.createHydratorFor | public function createHydratorFor($objectClass)
{
$metadata = $this->getMetadata($objectClass);
$propertyAccessStrategy = $metadata->isPropertyAccessStrategyEnabled();
$hydrator = new Hydrator\Hydrator($this, $propertyAccessStrategy);
if ($this->classResolver) {
$hydrator->setClassResolver($this->classResolver);
}
$fieldsWithHydrationStrategy = $metadata->computeFieldsWithHydrationStrategy();
$mappedFieldNames = $metadata->getMappedFieldNames();
foreach ($mappedFieldNames as $mappedFieldName) {
$strategy = null;
if ($metadata->isMappedFieldWithStrategy($mappedFieldName)) {
$fieldStrategy = $fieldsWithHydrationStrategy[$mappedFieldName];
$strategy = new ClosureHydrationStrategy(
$fieldStrategy[$metadata::INDEX_EXTRACTION_STRATEGY],
$fieldStrategy[$metadata::INDEX_HYDRATION_STRATEGY]
);
}
if ($metadata->isMappedDateField($mappedFieldName)) {
$readDateConverter = $metadata->getReadDateFormatByMappedField($mappedFieldName, null);
$writeDateConverter = $metadata->getWriteDateFormatByMappedField($mappedFieldName, null);
if (! is_null($readDateConverter) && ! is_null($writeDateConverter)) {
$strategy = new DateHydrationStrategy($readDateConverter, $writeDateConverter, $strategy);
} else {
throw new ObjectMappingException(
sprintf(
'The date field "%s" should provide "readDateConverter" and "writeDateConverter" metadata.',
$mappedFieldName
)
);
}
}
if (! is_null($strategy)) {
$hydrator->addStrategy($mappedFieldName, $strategy);
}
}
//------------------------------------------------------------------------------------------
if ($metadata->eventsExist()) {
$hydrator = new Hydrator\EventHydrator($hydrator, $this);
}
return $hydrator;
} | php | public function createHydratorFor($objectClass)
{
$metadata = $this->getMetadata($objectClass);
$propertyAccessStrategy = $metadata->isPropertyAccessStrategyEnabled();
$hydrator = new Hydrator\Hydrator($this, $propertyAccessStrategy);
if ($this->classResolver) {
$hydrator->setClassResolver($this->classResolver);
}
$fieldsWithHydrationStrategy = $metadata->computeFieldsWithHydrationStrategy();
$mappedFieldNames = $metadata->getMappedFieldNames();
foreach ($mappedFieldNames as $mappedFieldName) {
$strategy = null;
if ($metadata->isMappedFieldWithStrategy($mappedFieldName)) {
$fieldStrategy = $fieldsWithHydrationStrategy[$mappedFieldName];
$strategy = new ClosureHydrationStrategy(
$fieldStrategy[$metadata::INDEX_EXTRACTION_STRATEGY],
$fieldStrategy[$metadata::INDEX_HYDRATION_STRATEGY]
);
}
if ($metadata->isMappedDateField($mappedFieldName)) {
$readDateConverter = $metadata->getReadDateFormatByMappedField($mappedFieldName, null);
$writeDateConverter = $metadata->getWriteDateFormatByMappedField($mappedFieldName, null);
if (! is_null($readDateConverter) && ! is_null($writeDateConverter)) {
$strategy = new DateHydrationStrategy($readDateConverter, $writeDateConverter, $strategy);
} else {
throw new ObjectMappingException(
sprintf(
'The date field "%s" should provide "readDateConverter" and "writeDateConverter" metadata.',
$mappedFieldName
)
);
}
}
if (! is_null($strategy)) {
$hydrator->addStrategy($mappedFieldName, $strategy);
}
}
//------------------------------------------------------------------------------------------
if ($metadata->eventsExist()) {
$hydrator = new Hydrator\EventHydrator($hydrator, $this);
}
return $hydrator;
} | [
"public",
"function",
"createHydratorFor",
"(",
"$",
"objectClass",
")",
"{",
"$",
"metadata",
"=",
"$",
"this",
"->",
"getMetadata",
"(",
"$",
"objectClass",
")",
";",
"$",
"propertyAccessStrategy",
"=",
"$",
"metadata",
"->",
"isPropertyAccessStrategyEnabled",
... | Factory method to create an hydrator.
@param $objectClass Object class to hydrate
@return AbstractHydrator | [
"Factory",
"method",
"to",
"create",
"an",
"hydrator",
"."
] | 653b3d735977d95f6eadb3334ab8787db1dca275 | https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/ObjectManager.php#L244-L299 | train |
kassko/data-mapper | src/ObjectManager.php | ObjectManager.getMetadata | public function getMetadata($objectClass)
{
if (! $objectClass instanceof ObjectKey) {
$objectClass = new ObjectKey($objectClass);
}
$key = $objectClass->getKey();
return $this->classMetadataFactory->loadMetadata(
$objectClass,
LoadingCriteria::createFromConfiguration($this->configuration, $objectClass),
$this->configuration
);
} | php | public function getMetadata($objectClass)
{
if (! $objectClass instanceof ObjectKey) {
$objectClass = new ObjectKey($objectClass);
}
$key = $objectClass->getKey();
return $this->classMetadataFactory->loadMetadata(
$objectClass,
LoadingCriteria::createFromConfiguration($this->configuration, $objectClass),
$this->configuration
);
} | [
"public",
"function",
"getMetadata",
"(",
"$",
"objectClass",
")",
"{",
"if",
"(",
"!",
"$",
"objectClass",
"instanceof",
"ObjectKey",
")",
"{",
"$",
"objectClass",
"=",
"new",
"ObjectKey",
"(",
"$",
"objectClass",
")",
";",
"}",
"$",
"key",
"=",
"$",
... | Return the class metadata.
@param string $className FQCN without a leading back slash as does get_class()
@return \Kassko\DataMapper\ClassMetadata\ClassMetadata | [
"Return",
"the",
"class",
"metadata",
"."
] | 653b3d735977d95f6eadb3334ab8787db1dca275 | https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/ObjectManager.php#L378-L391 | train |
kassko/data-mapper | src/DataMapperBuilder.php | DataMapperBuilder.instance | public function instance()
{
$settings = $this->getValidatedSettings();
$objectManager = $this->createObjectManager($settings);
$logger = isset($settings['logger']) ? isset($settings['logger']) : null;
$this->initializeRegistry($objectManager, $logger);
return new DataMapper($objectManager);
} | php | public function instance()
{
$settings = $this->getValidatedSettings();
$objectManager = $this->createObjectManager($settings);
$logger = isset($settings['logger']) ? isset($settings['logger']) : null;
$this->initializeRegistry($objectManager, $logger);
return new DataMapper($objectManager);
} | [
"public",
"function",
"instance",
"(",
")",
"{",
"$",
"settings",
"=",
"$",
"this",
"->",
"getValidatedSettings",
"(",
")",
";",
"$",
"objectManager",
"=",
"$",
"this",
"->",
"createObjectManager",
"(",
"$",
"settings",
")",
";",
"$",
"logger",
"=",
"iss... | Instantiate a DataMapper from settings
@return self | [
"Instantiate",
"a",
"DataMapper",
"from",
"settings"
] | 653b3d735977d95f6eadb3334ab8787db1dca275 | https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/DataMapperBuilder.php#L85-L95 | train |
kassko/data-mapper | src/DataMapperBuilder.php | DataMapperBuilder.getValidatedSettings | private function getValidatedSettings()
{
$processor = new Processor();
$settingsValidator = new SettingsValidator();
$validatedSettings = $processor->processConfiguration(
$settingsValidator,
$this->pSettings
);
return $validatedSettings;
} | php | private function getValidatedSettings()
{
$processor = new Processor();
$settingsValidator = new SettingsValidator();
$validatedSettings = $processor->processConfiguration(
$settingsValidator,
$this->pSettings
);
return $validatedSettings;
} | [
"private",
"function",
"getValidatedSettings",
"(",
")",
"{",
"$",
"processor",
"=",
"new",
"Processor",
"(",
")",
";",
"$",
"settingsValidator",
"=",
"new",
"SettingsValidator",
"(",
")",
";",
"$",
"validatedSettings",
"=",
"$",
"processor",
"->",
"processCon... | Validates settings and reduces them if multiple settings given. | [
"Validates",
"settings",
"and",
"reduces",
"them",
"if",
"multiple",
"settings",
"given",
"."
] | 653b3d735977d95f6eadb3334ab8787db1dca275 | https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/DataMapperBuilder.php#L133-L143 | train |
dionsnoeijen/sexy-field | src/SectionField/Service/DefaultCache.php | DefaultCache.getItemKey | private function getItemKey(
string $sectionHandle,
array $requestedFields = null,
string $context = null,
string $id = null
): string {
return sha1($sectionHandle) .
$this->getFieldKey($requestedFields) .
$this->getContextKey($context) .
$this->getIdKey($id);
} | php | private function getItemKey(
string $sectionHandle,
array $requestedFields = null,
string $context = null,
string $id = null
): string {
return sha1($sectionHandle) .
$this->getFieldKey($requestedFields) .
$this->getContextKey($context) .
$this->getIdKey($id);
} | [
"private",
"function",
"getItemKey",
"(",
"string",
"$",
"sectionHandle",
",",
"array",
"$",
"requestedFields",
"=",
"null",
",",
"string",
"$",
"context",
"=",
"null",
",",
"string",
"$",
"id",
"=",
"null",
")",
":",
"string",
"{",
"return",
"sha1",
"("... | Get the key for the item so the key will be unique for this
specific cache item and can't be unexpectedly overridden.
@param string $sectionHandle
@param array $requestedFields
@param string|null $context
@param string|null $id
@return string | [
"Get",
"the",
"key",
"for",
"the",
"item",
"so",
"the",
"key",
"will",
"be",
"unique",
"for",
"this",
"specific",
"cache",
"item",
"and",
"can",
"t",
"be",
"unexpectedly",
"overridden",
"."
] | 68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033 | https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/SectionField/Service/DefaultCache.php#L156-L166 | train |
dionsnoeijen/sexy-field | src/SectionField/Service/DefaultCache.php | DefaultCache.getFieldKey | private function getFieldKey(array $requestedFields = null): string
{
if (is_null($requestedFields)) {
return 'no-field-key';
}
return $fieldKey = '.' . sha1(implode(',', $requestedFields));
} | php | private function getFieldKey(array $requestedFields = null): string
{
if (is_null($requestedFields)) {
return 'no-field-key';
}
return $fieldKey = '.' . sha1(implode(',', $requestedFields));
} | [
"private",
"function",
"getFieldKey",
"(",
"array",
"$",
"requestedFields",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"is_null",
"(",
"$",
"requestedFields",
")",
")",
"{",
"return",
"'no-field-key'",
";",
"}",
"return",
"$",
"fieldKey",
"=",
"'.'",... | A lot of calls contain the fields one want's to have in return.
Make sure this is also added to the item key.
@param array $requestedFields
@return string | [
"A",
"lot",
"of",
"calls",
"contain",
"the",
"fields",
"one",
"want",
"s",
"to",
"have",
"in",
"return",
".",
"Make",
"sure",
"this",
"is",
"also",
"added",
"to",
"the",
"item",
"key",
"."
] | 68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033 | https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/SectionField/Service/DefaultCache.php#L188-L194 | train |
dionsnoeijen/sexy-field | src/SectionField/Service/DefaultCache.php | DefaultCache.getRelationships | private function getRelationships(FullyQualifiedClassName $fullyQualifiedClassName): array
{
$fields = (string)$fullyQualifiedClassName;
if (!is_subclass_of($fields, CommonSectionInterface::class)) {
throw new NotASexyFieldEntityException;
}
/** @var CommonSectionInterface $fields */
$relationships = [];
foreach ($fields::fieldInfo() as $field) {
if (!is_null($field['relationship'])) {
$relationships[] = $field['relationship']['class'];
}
}
return $relationships;
} | php | private function getRelationships(FullyQualifiedClassName $fullyQualifiedClassName): array
{
$fields = (string)$fullyQualifiedClassName;
if (!is_subclass_of($fields, CommonSectionInterface::class)) {
throw new NotASexyFieldEntityException;
}
/** @var CommonSectionInterface $fields */
$relationships = [];
foreach ($fields::fieldInfo() as $field) {
if (!is_null($field['relationship'])) {
$relationships[] = $field['relationship']['class'];
}
}
return $relationships;
} | [
"private",
"function",
"getRelationships",
"(",
"FullyQualifiedClassName",
"$",
"fullyQualifiedClassName",
")",
":",
"array",
"{",
"$",
"fields",
"=",
"(",
"string",
")",
"$",
"fullyQualifiedClassName",
";",
"if",
"(",
"!",
"is_subclass_of",
"(",
"$",
"fields",
... | Entries can have relationships, make sure to tag them.
@param FullyQualifiedClassName $fullyQualifiedClassName
@return array
@throws NotASexyFieldEntityException | [
"Entries",
"can",
"have",
"relationships",
"make",
"sure",
"to",
"tag",
"them",
"."
] | 68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033 | https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/SectionField/Service/DefaultCache.php#L214-L228 | train |
lordthorzonus/yii2-algolia | src/ActiveRecord/Searchable.php | Searchable.getIndices | public function getIndices()
{
$indices = $this->indices();
if (empty($indices)) {
$className = (new \ReflectionClass($this))->getShortName();
return [$className];
}
return $indices;
} | php | public function getIndices()
{
$indices = $this->indices();
if (empty($indices)) {
$className = (new \ReflectionClass($this))->getShortName();
return [$className];
}
return $indices;
} | [
"public",
"function",
"getIndices",
"(",
")",
"{",
"$",
"indices",
"=",
"$",
"this",
"->",
"indices",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"indices",
")",
")",
"{",
"$",
"className",
"=",
"(",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"this... | Returns an array of indices for this model.
@return array | [
"Returns",
"an",
"array",
"of",
"indices",
"for",
"this",
"model",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/ActiveRecord/Searchable.php#L45-L56 | train |
digbang/security | src/Reminders/DoctrineReminderRepository.php | DoctrineReminderRepository.exists | public function exists(UserInterface $user, $code = null)
{
return $this->findIncomplete($user, $code) !== null;
} | php | public function exists(UserInterface $user, $code = null)
{
return $this->findIncomplete($user, $code) !== null;
} | [
"public",
"function",
"exists",
"(",
"UserInterface",
"$",
"user",
",",
"$",
"code",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"findIncomplete",
"(",
"$",
"user",
",",
"$",
"code",
")",
"!==",
"null",
";",
"}"
] | Check if a valid reminder exists.
@param User $user
@param string $code
@return bool | [
"Check",
"if",
"a",
"valid",
"reminder",
"exists",
"."
] | ee925c5a144a1553f5a72ded6f5a66c01a86ab21 | https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Reminders/DoctrineReminderRepository.php#L50-L53 | train |
digbang/security | src/Reminders/DoctrineReminderRepository.php | DoctrineReminderRepository.complete | public function complete(UserInterface $user, $code, $password)
{
$reminder = $this->findIncomplete($user, $code);
if ($reminder === null)
{
return false;
}
$credentials = ['password' => $password];
if (! $this->users->validForUpdate($user, $credentials))
{
return false;
}
$entityManager = $this->getEntityManager();
$entityManager->beginTransaction();
try
{
$this->users->update($user, $credentials);
$reminder->complete();
$this->save($reminder);
$entityManager->commit();
return true;
}
catch (\Exception $e)
{
$entityManager->rollback();
return false;
}
} | php | public function complete(UserInterface $user, $code, $password)
{
$reminder = $this->findIncomplete($user, $code);
if ($reminder === null)
{
return false;
}
$credentials = ['password' => $password];
if (! $this->users->validForUpdate($user, $credentials))
{
return false;
}
$entityManager = $this->getEntityManager();
$entityManager->beginTransaction();
try
{
$this->users->update($user, $credentials);
$reminder->complete();
$this->save($reminder);
$entityManager->commit();
return true;
}
catch (\Exception $e)
{
$entityManager->rollback();
return false;
}
} | [
"public",
"function",
"complete",
"(",
"UserInterface",
"$",
"user",
",",
"$",
"code",
",",
"$",
"password",
")",
"{",
"$",
"reminder",
"=",
"$",
"this",
"->",
"findIncomplete",
"(",
"$",
"user",
",",
"$",
"code",
")",
";",
"if",
"(",
"$",
"reminder"... | Complete reminder for the given user.
@param User $user
@param string $code
@param string $password
@return bool | [
"Complete",
"reminder",
"for",
"the",
"given",
"user",
"."
] | ee925c5a144a1553f5a72ded6f5a66c01a86ab21 | https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Reminders/DoctrineReminderRepository.php#L64-L99 | train |
lordthorzonus/yii2-algolia | src/AlgoliaFactory.php | AlgoliaFactory.make | public function make(AlgoliaConfig $config)
{
return new AlgoliaManager(
new Client(
$config->getApplicationId(),
$config->getApiKey(),
$config->getHostsArray(),
$config->getOptions()
),
new ActiveRecordFactory(),
new ActiveQueryChunker()
);
} | php | public function make(AlgoliaConfig $config)
{
return new AlgoliaManager(
new Client(
$config->getApplicationId(),
$config->getApiKey(),
$config->getHostsArray(),
$config->getOptions()
),
new ActiveRecordFactory(),
new ActiveQueryChunker()
);
} | [
"public",
"function",
"make",
"(",
"AlgoliaConfig",
"$",
"config",
")",
"{",
"return",
"new",
"AlgoliaManager",
"(",
"new",
"Client",
"(",
"$",
"config",
"->",
"getApplicationId",
"(",
")",
",",
"$",
"config",
"->",
"getApiKey",
"(",
")",
",",
"$",
"conf... | Makes a new Algolia Client.
@param AlgoliaConfig $config
@return AlgoliaManager
@throws \Exception | [
"Makes",
"a",
"new",
"Algolia",
"Client",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaFactory.php#L20-L32 | train |
songshenzong/api | src/Middleware.php | Middleware.sendRequestThroughRouter | protected function sendRequestThroughRouter(Request $request)
{
return (new Pipeline($this->app))->send($request)->then(function ($request) {
/**
* @var Response $response
*/
$response = $this->router->dispatch($request);
if (property_exists($response, 'exception') && $response->exception instanceof Exception) {
throw $response->exception;
}
return $response;
});
} | php | protected function sendRequestThroughRouter(Request $request)
{
return (new Pipeline($this->app))->send($request)->then(function ($request) {
/**
* @var Response $response
*/
$response = $this->router->dispatch($request);
if (property_exists($response, 'exception') && $response->exception instanceof Exception) {
throw $response->exception;
}
return $response;
});
} | [
"protected",
"function",
"sendRequestThroughRouter",
"(",
"Request",
"$",
"request",
")",
"{",
"return",
"(",
"new",
"Pipeline",
"(",
"$",
"this",
"->",
"app",
")",
")",
"->",
"send",
"(",
"$",
"request",
")",
"->",
"then",
"(",
"function",
"(",
"$",
"... | Send the request through the Songshenzong router.
@param Request $request
@return Response
@throws \Exception | [
"Send",
"the",
"request",
"through",
"the",
"Songshenzong",
"router",
"."
] | b81751be0fe64eb9e6c775957aa2e8f8c6c2444e | https://github.com/songshenzong/api/blob/b81751be0fe64eb9e6c775957aa2e8f8c6c2444e/src/Middleware.php#L232-L247 | train |
MovingImage24/VMProApiClient | lib/ApiClient/AbstractCoreApiClient.php | AbstractCoreApiClient.generateCacheKey | private function generateCacheKey($method, $uri, array $options = [])
{
return sha1(sprintf('%s.%s.%s.%s', get_class($this), $method, $uri, json_encode($options)));
} | php | private function generateCacheKey($method, $uri, array $options = [])
{
return sha1(sprintf('%s.%s.%s.%s', get_class($this), $method, $uri, json_encode($options)));
} | [
"private",
"function",
"generateCacheKey",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"return",
"sha1",
"(",
"sprintf",
"(",
"'%s.%s.%s.%s'",
",",
"get_class",
"(",
"$",
"this",
")",
",",
"$",
"method",
... | Generates the cache key based on the class name, request method, uri and options.
@param string $method
@param string $uri
@param array $options
@return string | [
"Generates",
"the",
"cache",
"key",
"based",
"on",
"the",
"class",
"name",
"request",
"method",
"uri",
"and",
"options",
"."
] | e242a88a93a7a915898c888a575502c21434e35b | https://github.com/MovingImage24/VMProApiClient/blob/e242a88a93a7a915898c888a575502c21434e35b/lib/ApiClient/AbstractCoreApiClient.php#L227-L230 | train |
MovingImage24/VMProApiClient | lib/ApiClient/AbstractCoreApiClient.php | AbstractCoreApiClient.isCacheable | private function isCacheable($method, $uri, array $options, $response)
{
/** @var ResponseInterface $statusCode */
$statusCode = $response->getStatusCode();
//cache only 2** responses
if ($statusCode < 200 || $statusCode >= 300) {
return false;
}
//GET is always safe to cache
if ('GET' === $method) {
return true;
}
//POST may be cached for certain endpoints only (forgive us Roy Fielding)
if ('POST' === $method) {
return in_array($uri, self::CACHEABLE_POST_ENDPOINTS);
}
//assume not cacheable in all other cases
return false;
} | php | private function isCacheable($method, $uri, array $options, $response)
{
/** @var ResponseInterface $statusCode */
$statusCode = $response->getStatusCode();
//cache only 2** responses
if ($statusCode < 200 || $statusCode >= 300) {
return false;
}
//GET is always safe to cache
if ('GET' === $method) {
return true;
}
//POST may be cached for certain endpoints only (forgive us Roy Fielding)
if ('POST' === $method) {
return in_array($uri, self::CACHEABLE_POST_ENDPOINTS);
}
//assume not cacheable in all other cases
return false;
} | [
"private",
"function",
"isCacheable",
"(",
"$",
"method",
",",
"$",
"uri",
",",
"array",
"$",
"options",
",",
"$",
"response",
")",
"{",
"/** @var ResponseInterface $statusCode */",
"$",
"statusCode",
"=",
"$",
"response",
"->",
"getStatusCode",
"(",
")",
";",... | Checks if the request may be cached.
@param string $method
@param string $uri
@param array $options
@param mixed $response
@return bool | [
"Checks",
"if",
"the",
"request",
"may",
"be",
"cached",
"."
] | e242a88a93a7a915898c888a575502c21434e35b | https://github.com/MovingImage24/VMProApiClient/blob/e242a88a93a7a915898c888a575502c21434e35b/lib/ApiClient/AbstractCoreApiClient.php#L242-L264 | train |
Speelpenning-nl/laravel-authentication | src/Repositories/UserRepository.php | UserRepository.query | public function query($q = null)
{
return User::where(function ($query) use ($q) {
$query->where('email', 'like', "%{$q}")
->orWhere('name', 'like', "%{$q}");
})->orderBy('email')->paginate();
} | php | public function query($q = null)
{
return User::where(function ($query) use ($q) {
$query->where('email', 'like', "%{$q}")
->orWhere('name', 'like', "%{$q}");
})->orderBy('email')->paginate();
} | [
"public",
"function",
"query",
"(",
"$",
"q",
"=",
"null",
")",
"{",
"return",
"User",
"::",
"where",
"(",
"function",
"(",
"$",
"query",
")",
"use",
"(",
"$",
"q",
")",
"{",
"$",
"query",
"->",
"where",
"(",
"'email'",
",",
"'like'",
",",
"\"%{$... | Queries the repository and returns a paginated result.
@param null|string $q
@return LengthAwarePaginator | [
"Queries",
"the",
"repository",
"and",
"returns",
"a",
"paginated",
"result",
"."
] | 44671afa8d654a9c6281cce13353d95126478d8b | https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Repositories/UserRepository.php#L54-L60 | train |
dionsnoeijen/sexy-field | src/SectionField/Generator/Generator.php | Generator.shouldIgnore | protected function shouldIgnore(FieldInterface $field): bool
{
$fieldType = $this->container->get(
(string) $field->getFieldType()->getFullyQualifiedClassName()
);
// The field type generator config refers to how the field type itself is defined
// as a service. You can see that in the services.yml
$fieldTypeGeneratorConfig = $fieldType->getFieldTypeGeneratorConfig()->toArray();
if (!key_exists(static::GENERATE_FOR, $fieldTypeGeneratorConfig)) {
return true;
}
// See if this field is to be ignored by this generator because it's explicitly
// set to ignore === true
try {
// The field generator config refers to how the field instructs the generator
// You see that in the field configuration yml
$fieldGeneratorConfig = $field->getConfig()->getGeneratorConfig()->toArray();
if (!empty($fieldGeneratorConfig[static::GENERATE_FOR]['ignore']) &&
$fieldGeneratorConfig[static::GENERATE_FOR]['ignore']
) {
return true;
}
} catch (\Exception $exception) {}
return false;
} | php | protected function shouldIgnore(FieldInterface $field): bool
{
$fieldType = $this->container->get(
(string) $field->getFieldType()->getFullyQualifiedClassName()
);
// The field type generator config refers to how the field type itself is defined
// as a service. You can see that in the services.yml
$fieldTypeGeneratorConfig = $fieldType->getFieldTypeGeneratorConfig()->toArray();
if (!key_exists(static::GENERATE_FOR, $fieldTypeGeneratorConfig)) {
return true;
}
// See if this field is to be ignored by this generator because it's explicitly
// set to ignore === true
try {
// The field generator config refers to how the field instructs the generator
// You see that in the field configuration yml
$fieldGeneratorConfig = $field->getConfig()->getGeneratorConfig()->toArray();
if (!empty($fieldGeneratorConfig[static::GENERATE_FOR]['ignore']) &&
$fieldGeneratorConfig[static::GENERATE_FOR]['ignore']
) {
return true;
}
} catch (\Exception $exception) {}
return false;
} | [
"protected",
"function",
"shouldIgnore",
"(",
"FieldInterface",
"$",
"field",
")",
":",
"bool",
"{",
"$",
"fieldType",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"(",
"string",
")",
"$",
"field",
"->",
"getFieldType",
"(",
")",
"->",
"getFull... | There are scenario's in which a field should be ignored by a generator
@param FieldInterface $field
@return bool | [
"There",
"are",
"scenario",
"s",
"in",
"which",
"a",
"field",
"should",
"be",
"ignored",
"by",
"a",
"generator"
] | 68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033 | https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/SectionField/Generator/Generator.php#L103-L129 | train |
dionsnoeijen/sexy-field | src/SectionField/Generator/Generator.php | Generator.getFieldTypeTemplateDirectory | protected function getFieldTypeTemplateDirectory(
FieldInterface $field,
string $supportingDirectory
) {
/** @var FieldTypeInterface $fieldType */
$fieldType = $this->container->get((string) $field->getFieldType()->getFullyQualifiedClassName());
$fieldTypeDirectory = explode('/', $fieldType->directory());
foreach ($fieldTypeDirectory as $key => $segment) {
if ($segment === 'vendor') {
$selector = $key + 2;
$fieldTypeDirectory[$selector] = $supportingDirectory;
break;
}
}
return implode('/', $fieldTypeDirectory);
} | php | protected function getFieldTypeTemplateDirectory(
FieldInterface $field,
string $supportingDirectory
) {
/** @var FieldTypeInterface $fieldType */
$fieldType = $this->container->get((string) $field->getFieldType()->getFullyQualifiedClassName());
$fieldTypeDirectory = explode('/', $fieldType->directory());
foreach ($fieldTypeDirectory as $key => $segment) {
if ($segment === 'vendor') {
$selector = $key + 2;
$fieldTypeDirectory[$selector] = $supportingDirectory;
break;
}
}
return implode('/', $fieldTypeDirectory);
} | [
"protected",
"function",
"getFieldTypeTemplateDirectory",
"(",
"FieldInterface",
"$",
"field",
",",
"string",
"$",
"supportingDirectory",
")",
"{",
"/** @var FieldTypeInterface $fieldType */",
"$",
"fieldType",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"(... | The field type generator templates are to be defined in the packages
that provide the specific support for what is to be generated
The field's field type, is in a base package, the default package is: 'sexy-field-field-types-base'
The supporting directory, is where the generator is to find it's templates
For example: 'sexy-field-entity' or 'sexy-field-doctrine'
@param FieldInterface $field
@param string $supportingDirectory
@return mixed | [
"The",
"field",
"type",
"generator",
"templates",
"are",
"to",
"be",
"defined",
"in",
"the",
"packages",
"that",
"provide",
"the",
"specific",
"support",
"for",
"what",
"is",
"to",
"be",
"generated"
] | 68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033 | https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/SectionField/Generator/Generator.php#L165-L182 | train |
MichaelPavlista/palette | src/Effect/Watermark.php | Watermark.applyWatermarkImagick | private function applyWatermarkImagick(Imagick $image)
{
$pictureWidth = $image->getImageWidth();
$pictureHeight = $image->getImageHeight();
$watermarkPicture = new Picture($this->watermark, NULL, Picture::WORKER_IMAGICK);
$opacity = new Opacity($this->opacity);
$opacity->apply($watermarkPicture);
if($this->size)
{
$resize = new Resize(
$pictureWidth / 100 * $this->size,
$pictureHeight / 100 * $this->size,
Resize::MODE_FIT
);
$resize->apply($watermarkPicture);
}
$watermark = $watermarkPicture->getResource(Picture::WORKER_IMAGICK);
$watermarkWidth = $watermark->getImageWidth();
$watermarkHeight = $watermark->getImageHeight();
switch($this->position)
{
case 'repeat':
for($w = 0; $w < $pictureWidth; $w += $watermarkWidth + $this->space)
{
for($h = 0; $h < $pictureHeight; $h += $watermarkHeight + $this->space)
{
$image->compositeImage($watermark, $watermark->getImageCompose(), $w, $h);
}
}
return;
case 'center':
$positionX = ($image->getImageWidth() - $watermark->getImageWidth()) / 2 - $this->offsetX;
$positionY = ($image->getImageHeight() - $watermark->getImageHeight()) / 2 - $this->offsetY;
break;
case 'topRight':
$positionX = $image->getImageWidth() - $watermark->getImageWidth() - $this->offsetX;
$positionY = $this->offsetY;
break;
case 'bottomRight':
$positionX = $image->getImageWidth() - $watermark->getImageWidth() - $this->offsetX;
$positionY = $image->getImageHeight() - $watermark->getImageHeight() - $this->offsetY;
break;
case 'bottomLeft':
$positionX = $this->offsetX;
$positionY = $image->getImageHeight() - $watermark->getImageHeight() - $this->offsetY;
break;
default:
$positionX = $this->offsetX;
$positionY = $this->offsetY;
break;
}
$image->compositeImage($watermark, $watermark->getImageCompose(), $positionX, $positionY);
} | php | private function applyWatermarkImagick(Imagick $image)
{
$pictureWidth = $image->getImageWidth();
$pictureHeight = $image->getImageHeight();
$watermarkPicture = new Picture($this->watermark, NULL, Picture::WORKER_IMAGICK);
$opacity = new Opacity($this->opacity);
$opacity->apply($watermarkPicture);
if($this->size)
{
$resize = new Resize(
$pictureWidth / 100 * $this->size,
$pictureHeight / 100 * $this->size,
Resize::MODE_FIT
);
$resize->apply($watermarkPicture);
}
$watermark = $watermarkPicture->getResource(Picture::WORKER_IMAGICK);
$watermarkWidth = $watermark->getImageWidth();
$watermarkHeight = $watermark->getImageHeight();
switch($this->position)
{
case 'repeat':
for($w = 0; $w < $pictureWidth; $w += $watermarkWidth + $this->space)
{
for($h = 0; $h < $pictureHeight; $h += $watermarkHeight + $this->space)
{
$image->compositeImage($watermark, $watermark->getImageCompose(), $w, $h);
}
}
return;
case 'center':
$positionX = ($image->getImageWidth() - $watermark->getImageWidth()) / 2 - $this->offsetX;
$positionY = ($image->getImageHeight() - $watermark->getImageHeight()) / 2 - $this->offsetY;
break;
case 'topRight':
$positionX = $image->getImageWidth() - $watermark->getImageWidth() - $this->offsetX;
$positionY = $this->offsetY;
break;
case 'bottomRight':
$positionX = $image->getImageWidth() - $watermark->getImageWidth() - $this->offsetX;
$positionY = $image->getImageHeight() - $watermark->getImageHeight() - $this->offsetY;
break;
case 'bottomLeft':
$positionX = $this->offsetX;
$positionY = $image->getImageHeight() - $watermark->getImageHeight() - $this->offsetY;
break;
default:
$positionX = $this->offsetX;
$positionY = $this->offsetY;
break;
}
$image->compositeImage($watermark, $watermark->getImageCompose(), $positionX, $positionY);
} | [
"private",
"function",
"applyWatermarkImagick",
"(",
"Imagick",
"$",
"image",
")",
"{",
"$",
"pictureWidth",
"=",
"$",
"image",
"->",
"getImageWidth",
"(",
")",
";",
"$",
"pictureHeight",
"=",
"$",
"image",
"->",
"getImageHeight",
"(",
")",
";",
"$",
"wate... | Watermark effect processed by Imagick
@param Imagick $image | [
"Watermark",
"effect",
"processed",
"by",
"Imagick"
] | dfb8d0e1b98880932851233faa048e2bfc9abed5 | https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Effect/Watermark.php#L89-L160 | train |
MichaelPavlista/palette | src/Effect/Watermark.php | Watermark.applyWatermarkGD | protected function applyWatermarkGD($resource, Picture $picture) {
// SOURCE IMAGE DIMENSIONS
$pictureWidth = imagesx($resource);
$pictureHeight = imagesy($resource);
// WATERMARK DIMENSIONS
$watermarkPicture = new Picture($this->watermark, NULL, Picture::WORKER_GD);
$opacity = new Opacity($this->opacity);
$opacity->apply($watermarkPicture);
if($this->size)
{
$resize = new Resize(
$pictureWidth / 100 * $this->size,
$pictureHeight / 100 * $this->size,
Resize::MODE_FIT
);
$resize->apply($watermarkPicture);
}
$watermark = $watermarkPicture->getResource($watermarkPicture::WORKER_GD);
imagealphablending($watermark, TRUE);
$watermarkWidth = imagesx($watermark);
$watermarkHeight = imagesx($watermark);
// CALCULATE WATERMARK POSITION
switch($this->position)
{
case 'repeat':
for($w = 0; $w < $pictureWidth; $w += $watermarkWidth + $this->space)
{
for($h = 0; $h < $pictureHeight; $h += $watermarkHeight + $this->space)
{
imagecopy($resource, $watermark, $w, $h, 0, 0, $watermarkWidth, $watermarkHeight);
}
}
return $resource;
case 'center':
$positionX = ($pictureWidth - $watermarkWidth) / 2 - $this->offsetX;
$positionY = ($pictureHeight - $watermarkHeight) / 2 - $this->offsetY;
break;
case 'topRight':
$positionX = $pictureWidth - $watermarkWidth - $this->offsetX;
$positionY = $this->offsetY;
break;
case 'bottomRight':
$positionX = $pictureWidth - $watermarkWidth - $this->offsetX;
$positionY = $pictureHeight - $watermarkHeight - $this->offsetY;
break;
case 'bottomLeft':
$positionX = $this->offsetX;
$positionY = $pictureHeight - $watermarkHeight - $this->offsetY;
break;
default:
$positionX = $this->offsetX;
$positionY = $this->offsetY;
break;
}
imagecopy($resource, $watermark, $positionX, $positionY, 0, 0, $watermarkWidth, $watermarkHeight);
return $resource;
} | php | protected function applyWatermarkGD($resource, Picture $picture) {
// SOURCE IMAGE DIMENSIONS
$pictureWidth = imagesx($resource);
$pictureHeight = imagesy($resource);
// WATERMARK DIMENSIONS
$watermarkPicture = new Picture($this->watermark, NULL, Picture::WORKER_GD);
$opacity = new Opacity($this->opacity);
$opacity->apply($watermarkPicture);
if($this->size)
{
$resize = new Resize(
$pictureWidth / 100 * $this->size,
$pictureHeight / 100 * $this->size,
Resize::MODE_FIT
);
$resize->apply($watermarkPicture);
}
$watermark = $watermarkPicture->getResource($watermarkPicture::WORKER_GD);
imagealphablending($watermark, TRUE);
$watermarkWidth = imagesx($watermark);
$watermarkHeight = imagesx($watermark);
// CALCULATE WATERMARK POSITION
switch($this->position)
{
case 'repeat':
for($w = 0; $w < $pictureWidth; $w += $watermarkWidth + $this->space)
{
for($h = 0; $h < $pictureHeight; $h += $watermarkHeight + $this->space)
{
imagecopy($resource, $watermark, $w, $h, 0, 0, $watermarkWidth, $watermarkHeight);
}
}
return $resource;
case 'center':
$positionX = ($pictureWidth - $watermarkWidth) / 2 - $this->offsetX;
$positionY = ($pictureHeight - $watermarkHeight) / 2 - $this->offsetY;
break;
case 'topRight':
$positionX = $pictureWidth - $watermarkWidth - $this->offsetX;
$positionY = $this->offsetY;
break;
case 'bottomRight':
$positionX = $pictureWidth - $watermarkWidth - $this->offsetX;
$positionY = $pictureHeight - $watermarkHeight - $this->offsetY;
break;
case 'bottomLeft':
$positionX = $this->offsetX;
$positionY = $pictureHeight - $watermarkHeight - $this->offsetY;
break;
default:
$positionX = $this->offsetX;
$positionY = $this->offsetY;
break;
}
imagecopy($resource, $watermark, $positionX, $positionY, 0, 0, $watermarkWidth, $watermarkHeight);
return $resource;
} | [
"protected",
"function",
"applyWatermarkGD",
"(",
"$",
"resource",
",",
"Picture",
"$",
"picture",
")",
"{",
"// SOURCE IMAGE DIMENSIONS",
"$",
"pictureWidth",
"=",
"imagesx",
"(",
"$",
"resource",
")",
";",
"$",
"pictureHeight",
"=",
"imagesy",
"(",
"$",
"res... | Watermark effect processed by gd
@param resource $resource gd image
@param Picture $picture
@return resource gd image | [
"Watermark",
"effect",
"processed",
"by",
"gd"
] | dfb8d0e1b98880932851233faa048e2bfc9abed5 | https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Effect/Watermark.php#L169-L248 | train |
neo-framework/neo-core | src/neo/core/Application.php | Application.run | public function run(Request $request = null)
{
\ini_set('display_errors', $this->config['debug'] ? 1 : 0);
\ini_set('display_startup_errors', $this->config['debug'] ? 1 : 0);
\date_default_timezone_set($this->config['timezone']);
// map all routes
foreach ($this->routes as $r => &$x) {
if (isset($x['controller'])) {
$this->router->map($x['method'], $r, $x['action'], $x['controller']);
} else foreach ($x as &$xx) {
$this->router->map($xx['method'], $r, $xx['action'], $xx['controller']);
}
}
// dispatch
try {
try {
$this->router->dispatch(
$request === null ? Request::createFromGlobals() : $request,
new class(
(new MultiControllerFactory(...$this->controller_factories))->close(),
$this->endobox,
$this->logger,
$this->config['app-namespace']) extends ControllerFactoryDecorator {
private $endobox;
private $logger;
private $namespace;
public function __construct(
ControllerFactory $factory,
BoxFactory $endobox,
Logger $logger,
string $namespace) {
parent::__construct($factory);
$this->endobox = $endobox;
$this->logger = $logger;
$this->namespace = $namespace;
}
public function create(string $type) : ?Controller {
return parent::create('\\' . $this->namespace . '\\controllers\\' . $type)
->setBoxFactory($this->endobox)
->setLogger($this->logger);
}
});
} catch (\Klein\Exceptions\UnhandledException $e) {
// TODO fix this mess with the stack trace being part of the message
throw new \RuntimeException(\sprintf("%s: %s\n<pre>%s</pre>",
\get_class($e), $e->getMessage(), $e->getTraceAsString()), $e->getCode(), $e);
}
} catch (\Exception $e) {
if ($this->config['catch-exceptions'] === false) {
throw $e;
}
if ($this->config['debug'] === true) {
die(self::formatException($e));
}
die();
}
return $this;
} | php | public function run(Request $request = null)
{
\ini_set('display_errors', $this->config['debug'] ? 1 : 0);
\ini_set('display_startup_errors', $this->config['debug'] ? 1 : 0);
\date_default_timezone_set($this->config['timezone']);
// map all routes
foreach ($this->routes as $r => &$x) {
if (isset($x['controller'])) {
$this->router->map($x['method'], $r, $x['action'], $x['controller']);
} else foreach ($x as &$xx) {
$this->router->map($xx['method'], $r, $xx['action'], $xx['controller']);
}
}
// dispatch
try {
try {
$this->router->dispatch(
$request === null ? Request::createFromGlobals() : $request,
new class(
(new MultiControllerFactory(...$this->controller_factories))->close(),
$this->endobox,
$this->logger,
$this->config['app-namespace']) extends ControllerFactoryDecorator {
private $endobox;
private $logger;
private $namespace;
public function __construct(
ControllerFactory $factory,
BoxFactory $endobox,
Logger $logger,
string $namespace) {
parent::__construct($factory);
$this->endobox = $endobox;
$this->logger = $logger;
$this->namespace = $namespace;
}
public function create(string $type) : ?Controller {
return parent::create('\\' . $this->namespace . '\\controllers\\' . $type)
->setBoxFactory($this->endobox)
->setLogger($this->logger);
}
});
} catch (\Klein\Exceptions\UnhandledException $e) {
// TODO fix this mess with the stack trace being part of the message
throw new \RuntimeException(\sprintf("%s: %s\n<pre>%s</pre>",
\get_class($e), $e->getMessage(), $e->getTraceAsString()), $e->getCode(), $e);
}
} catch (\Exception $e) {
if ($this->config['catch-exceptions'] === false) {
throw $e;
}
if ($this->config['debug'] === true) {
die(self::formatException($e));
}
die();
}
return $this;
} | [
"public",
"function",
"run",
"(",
"Request",
"$",
"request",
"=",
"null",
")",
"{",
"\\",
"ini_set",
"(",
"'display_errors'",
",",
"$",
"this",
"->",
"config",
"[",
"'debug'",
"]",
"?",
"1",
":",
"0",
")",
";",
"\\",
"ini_set",
"(",
"'display_startup_e... | Entry point for Neo. | [
"Entry",
"point",
"for",
"Neo",
"."
] | 6bcd0982a6c7fac652180ae2c6aae7a99fd90d67 | https://github.com/neo-framework/neo-core/blob/6bcd0982a6c7fac652180ae2c6aae7a99fd90d67/src/neo/core/Application.php#L67-L141 | train |
cleaniquecoders/money-wrapper | src/Utilities/Money.php | Money.make | public static function make(string $country = null)
{
if (empty($country)) {
$country = config('default');
}
return (new static() )->setCurrency($country);
} | php | public static function make(string $country = null)
{
if (empty($country)) {
$country = config('default');
}
return (new static() )->setCurrency($country);
} | [
"public",
"static",
"function",
"make",
"(",
"string",
"$",
"country",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"country",
")",
")",
"{",
"$",
"country",
"=",
"config",
"(",
"'default'",
")",
";",
"}",
"return",
"(",
"new",
"static",
"(... | Create Static Instance.
@param string $country
@return $this static instance | [
"Create",
"Static",
"Instance",
"."
] | 91de90b86136e80b6d25fee683323b3603f30db2 | https://github.com/cleaniquecoders/money-wrapper/blob/91de90b86136e80b6d25fee683323b3603f30db2/src/Utilities/Money.php#L37-L44 | train |
cleaniquecoders/money-wrapper | src/Utilities/Money.php | Money.setCurrency | public function setCurrency($country = null)
{
if (is_null($country)) {
$country = config('currency.default');
}
$config = config('currency.' . $country);
if (empty($config)) {
throw new CurrencyNotAvaialbleException($country . ' currency not avaialble.');
}
$this->currency = $config;
return $this;
} | php | public function setCurrency($country = null)
{
if (is_null($country)) {
$country = config('currency.default');
}
$config = config('currency.' . $country);
if (empty($config)) {
throw new CurrencyNotAvaialbleException($country . ' currency not avaialble.');
}
$this->currency = $config;
return $this;
} | [
"public",
"function",
"setCurrency",
"(",
"$",
"country",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"country",
")",
")",
"{",
"$",
"country",
"=",
"config",
"(",
"'currency.default'",
")",
";",
"}",
"$",
"config",
"=",
"config",
"(",
"'c... | Set Currency.
@param string $country | [
"Set",
"Currency",
"."
] | 91de90b86136e80b6d25fee683323b3603f30db2 | https://github.com/cleaniquecoders/money-wrapper/blob/91de90b86136e80b6d25fee683323b3603f30db2/src/Utilities/Money.php#L51-L63 | train |
cleaniquecoders/money-wrapper | src/Utilities/Money.php | Money.getCurrency | public function getCurrency()
{
if (! empty($this->currency)) {
return $this->currency;
}
return $this->setCurrency(config('currency.default'))->getCurrency();
} | php | public function getCurrency()
{
if (! empty($this->currency)) {
return $this->currency;
}
return $this->setCurrency(config('currency.default'))->getCurrency();
} | [
"public",
"function",
"getCurrency",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"currency",
")",
")",
"{",
"return",
"$",
"this",
"->",
"currency",
";",
"}",
"return",
"$",
"this",
"->",
"setCurrency",
"(",
"config",
"(",
"'curre... | Ge Current Use Currency.
@return array | [
"Ge",
"Current",
"Use",
"Currency",
"."
] | 91de90b86136e80b6d25fee683323b3603f30db2 | https://github.com/cleaniquecoders/money-wrapper/blob/91de90b86136e80b6d25fee683323b3603f30db2/src/Utilities/Money.php#L70-L77 | train |
cleaniquecoders/money-wrapper | src/Utilities/Money.php | Money.toCommon | public function toCommon(int $amount, bool $format = true): string
{
$money = $this->castMoney($amount, $this->getCurrencySwiftCode());
$moneyFormatter = new DecimalMoneyFormatter(new ISOCurrencies());
return ($format) ?
number_format($moneyFormatter->format($money), 2, '.', ',') :
$moneyFormatter->format($money);
} | php | public function toCommon(int $amount, bool $format = true): string
{
$money = $this->castMoney($amount, $this->getCurrencySwiftCode());
$moneyFormatter = new DecimalMoneyFormatter(new ISOCurrencies());
return ($format) ?
number_format($moneyFormatter->format($money), 2, '.', ',') :
$moneyFormatter->format($money);
} | [
"public",
"function",
"toCommon",
"(",
"int",
"$",
"amount",
",",
"bool",
"$",
"format",
"=",
"true",
")",
":",
"string",
"{",
"$",
"money",
"=",
"$",
"this",
"->",
"castMoney",
"(",
"$",
"amount",
",",
"$",
"this",
"->",
"getCurrencySwiftCode",
"(",
... | Convert integer money to common view for the system
Instead of 700000, to 7000.
@param int $amount Integer money representation
@return string Return readable format for human | [
"Convert",
"integer",
"money",
"to",
"common",
"view",
"for",
"the",
"system",
"Instead",
"of",
"700000",
"to",
"7000",
"."
] | 91de90b86136e80b6d25fee683323b3603f30db2 | https://github.com/cleaniquecoders/money-wrapper/blob/91de90b86136e80b6d25fee683323b3603f30db2/src/Utilities/Money.php#L131-L139 | train |
cleaniquecoders/money-wrapper | src/Utilities/Money.php | Money.toMachine | public function toMachine(string $amount, string $swift_code = ''): int
{
$swift_code = empty($swift_code) ? config('currency.default_swift_code') : $swift_code;
return (new DecimalMoneyParser(
new ISOCurrencies()
))->parse(
preg_replace('/[^0-9.-]/im', '', $amount),
(new Currency($swift_code))
)->getAmount();
} | php | public function toMachine(string $amount, string $swift_code = ''): int
{
$swift_code = empty($swift_code) ? config('currency.default_swift_code') : $swift_code;
return (new DecimalMoneyParser(
new ISOCurrencies()
))->parse(
preg_replace('/[^0-9.-]/im', '', $amount),
(new Currency($swift_code))
)->getAmount();
} | [
"public",
"function",
"toMachine",
"(",
"string",
"$",
"amount",
",",
"string",
"$",
"swift_code",
"=",
"''",
")",
":",
"int",
"{",
"$",
"swift_code",
"=",
"empty",
"(",
"$",
"swift_code",
")",
"?",
"config",
"(",
"'currency.default_swift_code'",
")",
":",... | Return to Database Format.
This method intended to be use before save to the database
and this need to be call manually.
@param string $amount
@param string $swift_code
@return int | [
"Return",
"to",
"Database",
"Format",
".",
"This",
"method",
"intended",
"to",
"be",
"use",
"before",
"save",
"to",
"the",
"database",
"and",
"this",
"need",
"to",
"be",
"call",
"manually",
"."
] | 91de90b86136e80b6d25fee683323b3603f30db2 | https://github.com/cleaniquecoders/money-wrapper/blob/91de90b86136e80b6d25fee683323b3603f30db2/src/Utilities/Money.php#L151-L161 | train |
cleaniquecoders/money-wrapper | src/Utilities/Money.php | Money.convertFixedRate | public function convertFixedRate(array $fixedExchange, int $amount, string $swift_code): MoneyPHP
{
return (new Converter(
new ISOCurrencies(),
(new ReversedCurrenciesExchange(new FixedExchange($fixedExchange)))
))->convert($this->castMoney($amount), new Currency($swift_code));
} | php | public function convertFixedRate(array $fixedExchange, int $amount, string $swift_code): MoneyPHP
{
return (new Converter(
new ISOCurrencies(),
(new ReversedCurrenciesExchange(new FixedExchange($fixedExchange)))
))->convert($this->castMoney($amount), new Currency($swift_code));
} | [
"public",
"function",
"convertFixedRate",
"(",
"array",
"$",
"fixedExchange",
",",
"int",
"$",
"amount",
",",
"string",
"$",
"swift_code",
")",
":",
"MoneyPHP",
"{",
"return",
"(",
"new",
"Converter",
"(",
"new",
"ISOCurrencies",
"(",
")",
",",
"(",
"new",... | Convert Money with given fixed rate.
@see http://moneyphp.org/en/latest/features/currency-conversion.html#fixed-exchange
@param array $fixedExchange ['EUR' => ['USD' => 1.25]]
@param int $amount
@param string $swift_code
@return \Money\Money | [
"Convert",
"Money",
"with",
"given",
"fixed",
"rate",
"."
] | 91de90b86136e80b6d25fee683323b3603f30db2 | https://github.com/cleaniquecoders/money-wrapper/blob/91de90b86136e80b6d25fee683323b3603f30db2/src/Utilities/Money.php#L174-L180 | train |
koolkode/async | src/Stream/AbstractReadableStream.php | AbstractReadableStream.handleCancel | protected function handleCancel(CancellationException $e): ?string
{
throw $this->closed ? ($e->getPrevious() ?? $e) : $e;
} | php | protected function handleCancel(CancellationException $e): ?string
{
throw $this->closed ? ($e->getPrevious() ?? $e) : $e;
} | [
"protected",
"function",
"handleCancel",
"(",
"CancellationException",
"$",
"e",
")",
":",
"?",
"string",
"{",
"throw",
"$",
"this",
"->",
"closed",
"?",
"(",
"$",
"e",
"->",
"getPrevious",
"(",
")",
"??",
"$",
"e",
")",
":",
"$",
"e",
";",
"}"
] | Handle a cancelled read operation.
@param CancellationException $e | [
"Handle",
"a",
"cancelled",
"read",
"operation",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Stream/AbstractReadableStream.php#L136-L139 | train |
kherge-abandoned/lib-country | src/lib/Phine/Country/Exception/XmlException.php | XmlException.createUsingErrors | public static function createUsingErrors(array $errors)
{
$message = "An error was encountered reading an XML document:\n";
foreach ($errors as $error) {
switch ($error->level) {
case LIBXML_ERR_ERROR:
$message .= '[Error] ';
break;
case LIBXML_ERR_FATAL:
$message .= '[Fatal] ';
break;
case LIBXML_ERR_WARNING:
$message .= '[Warning] ';
break;
}
$message .= sprintf(
"[line %d] [column %d] %s in \"%s\".\n",
$error->line,
$error->column,
trim($error->message),
$error->file
);
}
return new self($message);
} | php | public static function createUsingErrors(array $errors)
{
$message = "An error was encountered reading an XML document:\n";
foreach ($errors as $error) {
switch ($error->level) {
case LIBXML_ERR_ERROR:
$message .= '[Error] ';
break;
case LIBXML_ERR_FATAL:
$message .= '[Fatal] ';
break;
case LIBXML_ERR_WARNING:
$message .= '[Warning] ';
break;
}
$message .= sprintf(
"[line %d] [column %d] %s in \"%s\".\n",
$error->line,
$error->column,
trim($error->message),
$error->file
);
}
return new self($message);
} | [
"public",
"static",
"function",
"createUsingErrors",
"(",
"array",
"$",
"errors",
")",
"{",
"$",
"message",
"=",
"\"An error was encountered reading an XML document:\\n\"",
";",
"foreach",
"(",
"$",
"errors",
"as",
"$",
"error",
")",
"{",
"switch",
"(",
"$",
"er... | Creates a new exception using an array of `libXMLError` instances.
@param libXMLError[] $errors A list of errors.
@return XmlException A new exception. | [
"Creates",
"a",
"new",
"exception",
"using",
"an",
"array",
"of",
"libXMLError",
"instances",
"."
] | 17278e939832013a3c7981b71f63ceb7480e79a1 | https://github.com/kherge-abandoned/lib-country/blob/17278e939832013a3c7981b71f63ceb7480e79a1/src/lib/Phine/Country/Exception/XmlException.php#L22-L49 | train |
kbrabrand/silex-swagger-ui | src/SwaggerUI/Silex/Provider/SwaggerUIServiceProvider.php | SwaggerUIServiceProvider.boot | public function boot(Application $app)
{
// Reference to $this, it's used for closure in anonymous function (PHP 5.3.x)
$self = &$this;
$app->get($app['swaggerui.path'], function(Request $request) use ($app) {
return str_replace(
array('{{swaggerui-root}}', '{{swagger-docs}}'),
array($request->getBasePath() . $app['swaggerui.path'], $request->getBasePath() . $app['swaggerui.apiDocPath']),
file_get_contents(__DIR__ . '/../../../../public/index.html')
);
});
$app->get($app['swaggerui.path'] . '/{resource}', function($resource) use ($app) {
$file = __DIR__ . '/../../../../public/' . $resource;
if (is_file($file)) {
return file_get_contents($file);
}
return '';
});
$app->get($app['swaggerui.path'] . '/lib/{resource}', function($resource) use ($app, $self) {
return $self->getFile(
__DIR__ . '/../../../../public/lib/' . $resource,
'text/javascript'
);
});
$app->get($app['swaggerui.path'] . '/css/{resource}', function($resource) use ($app, $self) {
return $self->getFile(
__DIR__ . '/../../../../public/css/' . $resource,
'text/css'
);
});
$app->get($app['swaggerui.path'] . '/images/{resource}', function($resource) use ($app, $self) {
return $self->getFile(
__DIR__ . '/../../../../public/images/' . $resource,
'image/png'
);
});
} | php | public function boot(Application $app)
{
// Reference to $this, it's used for closure in anonymous function (PHP 5.3.x)
$self = &$this;
$app->get($app['swaggerui.path'], function(Request $request) use ($app) {
return str_replace(
array('{{swaggerui-root}}', '{{swagger-docs}}'),
array($request->getBasePath() . $app['swaggerui.path'], $request->getBasePath() . $app['swaggerui.apiDocPath']),
file_get_contents(__DIR__ . '/../../../../public/index.html')
);
});
$app->get($app['swaggerui.path'] . '/{resource}', function($resource) use ($app) {
$file = __DIR__ . '/../../../../public/' . $resource;
if (is_file($file)) {
return file_get_contents($file);
}
return '';
});
$app->get($app['swaggerui.path'] . '/lib/{resource}', function($resource) use ($app, $self) {
return $self->getFile(
__DIR__ . '/../../../../public/lib/' . $resource,
'text/javascript'
);
});
$app->get($app['swaggerui.path'] . '/css/{resource}', function($resource) use ($app, $self) {
return $self->getFile(
__DIR__ . '/../../../../public/css/' . $resource,
'text/css'
);
});
$app->get($app['swaggerui.path'] . '/images/{resource}', function($resource) use ($app, $self) {
return $self->getFile(
__DIR__ . '/../../../../public/images/' . $resource,
'image/png'
);
});
} | [
"public",
"function",
"boot",
"(",
"Application",
"$",
"app",
")",
"{",
"// Reference to $this, it's used for closure in anonymous function (PHP 5.3.x)",
"$",
"self",
"=",
"&",
"$",
"this",
";",
"$",
"app",
"->",
"get",
"(",
"$",
"app",
"[",
"'swaggerui.path'",
"]... | Add routes to the swagger UI documentation browser
@param Application $app | [
"Add",
"routes",
"to",
"the",
"swagger",
"UI",
"documentation",
"browser"
] | 300687988bcc1479b75462f63b9a72cdf9484ecf | https://github.com/kbrabrand/silex-swagger-ui/blob/300687988bcc1479b75462f63b9a72cdf9484ecf/src/SwaggerUI/Silex/Provider/SwaggerUIServiceProvider.php#L22-L63 | train |
kbrabrand/silex-swagger-ui | src/SwaggerUI/Silex/Provider/SwaggerUIServiceProvider.php | SwaggerUIServiceProvider.getFile | public function getFile($path, $contentType) {
if (is_file($path)) {
$response = new Response(file_get_contents($path));
$response->headers->set('Content-Type', $contentType);
$response->setCharset('UTF-8');
return $response;
}
return new Response('', 404);
} | php | public function getFile($path, $contentType) {
if (is_file($path)) {
$response = new Response(file_get_contents($path));
$response->headers->set('Content-Type', $contentType);
$response->setCharset('UTF-8');
return $response;
}
return new Response('', 404);
} | [
"public",
"function",
"getFile",
"(",
"$",
"path",
",",
"$",
"contentType",
")",
"{",
"if",
"(",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"$",
"response",
"=",
"new",
"Response",
"(",
"file_get_contents",
"(",
"$",
"path",
")",
")",
";",
"$",
"r... | Get a public file
@param string Path to file
@param string Content-type
@return Response | [
"Get",
"a",
"public",
"file"
] | 300687988bcc1479b75462f63b9a72cdf9484ecf | https://github.com/kbrabrand/silex-swagger-ui/blob/300687988bcc1479b75462f63b9a72cdf9484ecf/src/SwaggerUI/Silex/Provider/SwaggerUIServiceProvider.php#L79-L88 | train |
shardimage/shardimage-php | src/factories/Option.php | Option.addMultiItem | private function addMultiItem()
{
$args = func_get_args();
$optionKey = array_shift($args);
$this->items[] = sprintf("%s:%s", $optionKey, implode(',', $args));
return $this;
} | php | private function addMultiItem()
{
$args = func_get_args();
$optionKey = array_shift($args);
$this->items[] = sprintf("%s:%s", $optionKey, implode(',', $args));
return $this;
} | [
"private",
"function",
"addMultiItem",
"(",
")",
"{",
"$",
"args",
"=",
"func_get_args",
"(",
")",
";",
"$",
"optionKey",
"=",
"array_shift",
"(",
"$",
"args",
")",
";",
"$",
"this",
"->",
"items",
"[",
"]",
"=",
"sprintf",
"(",
"\"%s:%s\"",
",",
"$"... | Adds repeating property item.
@return \self | [
"Adds",
"repeating",
"property",
"item",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/factories/Option.php#L91-L97 | train |
scherersoftware/cake-cktools | src/Lib/PdfGenerator.php | PdfGenerator._getView | protected function _getView(): View
{
if (!$this->getConfig('view')) {
$view = new View();
foreach ($this->getConfig('helpers') as $helper) {
$view->loadHelper($helper);
}
$this->setConfig('view', $view);
}
return $this->getConfig('view');
} | php | protected function _getView(): View
{
if (!$this->getConfig('view')) {
$view = new View();
foreach ($this->getConfig('helpers') as $helper) {
$view->loadHelper($helper);
}
$this->setConfig('view', $view);
}
return $this->getConfig('view');
} | [
"protected",
"function",
"_getView",
"(",
")",
":",
"View",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getConfig",
"(",
"'view'",
")",
")",
"{",
"$",
"view",
"=",
"new",
"View",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getConfig",
"(",
"'... | Prepares a View instance with which the given view file
will be rendered.
@return \Cake\View\View | [
"Prepares",
"a",
"View",
"instance",
"with",
"which",
"the",
"given",
"view",
"file",
"will",
"be",
"rendered",
"."
] | efba42cf4e1804df8f1faa83ef75927bee6c206b | https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Lib/PdfGenerator.php#L83-L95 | train |
scherersoftware/cake-cktools | src/Lib/PdfGenerator.php | PdfGenerator._preparePdf | protected function _preparePdf($viewFile, $viewVars): Mpdf
{
$mpdf = new Mpdf($this->_config['mpdfSettings']);
if (is_callable($this->_config['mpdfConfigurationCallback'])) {
$this->_config['mpdfConfigurationCallback']($mpdf);
}
$styles = '';
if ($this->_config['cssFile']) {
$styles = file_get_contents($this->_config['cssFile']);
}
if ($this->_config['cssStyles']) {
$styles .= $this->_config['cssStyles'];
}
if (!empty($styles)) {
$mpdf->WriteHTML($styles, 1);
}
if ($this->_config['pdfSourceFile']) {
$mpdf->SetImportUse();
$pagecount = $mpdf->SetSourceFile($this->_config['pdfSourceFile']);
if ($pagecount > 1) {
for ($i = 0; $i <= $pagecount; ++$i) {
// Import next page from the pdfSourceFile
$pageNumber = $i + 1;
if ($pageNumber <= $pagecount) {
$importPage = $mpdf->ImportPage($pageNumber);
$mpdf->UseTemplate($importPage);
if (is_array($viewFile) && isset($viewFile[$i])) {
$mpdf->WriteHTML($this->_getView()->element($viewFile[$i], $viewVars));
}
}
if ($pageNumber < $pagecount) {
$mpdf->AddPage();
}
}
} else {
$tplId = $mpdf->ImportPage($pagecount);
$mpdf->SetPageTemplate($tplId);
}
}
return $mpdf;
} | php | protected function _preparePdf($viewFile, $viewVars): Mpdf
{
$mpdf = new Mpdf($this->_config['mpdfSettings']);
if (is_callable($this->_config['mpdfConfigurationCallback'])) {
$this->_config['mpdfConfigurationCallback']($mpdf);
}
$styles = '';
if ($this->_config['cssFile']) {
$styles = file_get_contents($this->_config['cssFile']);
}
if ($this->_config['cssStyles']) {
$styles .= $this->_config['cssStyles'];
}
if (!empty($styles)) {
$mpdf->WriteHTML($styles, 1);
}
if ($this->_config['pdfSourceFile']) {
$mpdf->SetImportUse();
$pagecount = $mpdf->SetSourceFile($this->_config['pdfSourceFile']);
if ($pagecount > 1) {
for ($i = 0; $i <= $pagecount; ++$i) {
// Import next page from the pdfSourceFile
$pageNumber = $i + 1;
if ($pageNumber <= $pagecount) {
$importPage = $mpdf->ImportPage($pageNumber);
$mpdf->UseTemplate($importPage);
if (is_array($viewFile) && isset($viewFile[$i])) {
$mpdf->WriteHTML($this->_getView()->element($viewFile[$i], $viewVars));
}
}
if ($pageNumber < $pagecount) {
$mpdf->AddPage();
}
}
} else {
$tplId = $mpdf->ImportPage($pagecount);
$mpdf->SetPageTemplate($tplId);
}
}
return $mpdf;
} | [
"protected",
"function",
"_preparePdf",
"(",
"$",
"viewFile",
",",
"$",
"viewVars",
")",
":",
"Mpdf",
"{",
"$",
"mpdf",
"=",
"new",
"Mpdf",
"(",
"$",
"this",
"->",
"_config",
"[",
"'mpdfSettings'",
"]",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"... | Instanciate and configure the MPDF instance
@param string|array $viewFile One or more view files
@param array $viewVars View variables
@return \Mpdf\Mpdf | [
"Instanciate",
"and",
"configure",
"the",
"MPDF",
"instance"
] | efba42cf4e1804df8f1faa83ef75927bee6c206b | https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Lib/PdfGenerator.php#L104-L149 | train |
scherersoftware/cake-cktools | src/Lib/PdfGenerator.php | PdfGenerator.render | public function render($viewFile, array $options = [])
{
$options = Hash::merge([
'target' => self::TARGET_RETURN,
'filename' => 'pdf.pdf',
], $options);
$mpdf = $this->_preparePdf($viewFile, $options['viewVars']);
$options['viewVars']['mpdf'] = $mpdf;
if (!is_array($viewFile)) {
$wholeString = $this->_getView()->element($viewFile, $options['viewVars']);
// use 10% less than pcre.backtrack_limit to account for multibyte characters
$splitLength = ini_get('pcre.backtrack_limit') - (ini_get('pcre.backtrack_limit') / 10);
$splitString = str_split($wholeString, $splitLength);
foreach ($splitString as $string) {
$mpdf->WriteHTML($string);
}
}
switch ($options['target']) {
case self::TARGET_RETURN:
return $mpdf;
break;
case self::TARGET_DOWNLOAD:
$mpdf->Output($options['filename'], 'D');
break;
case self::TARGET_BROWSER:
$mpdf->Output($options['filename'], 'I');
break;
case self::TARGET_FILE:
$mpdf->Output($options['filename'], 'F');
break;
case self::TARGET_BINARY:
return $mpdf->Output('', 'S');
break;
default:
throw new \InvalidArgumentException("{$options['target']} is not a valid target");
break;
}
} | php | public function render($viewFile, array $options = [])
{
$options = Hash::merge([
'target' => self::TARGET_RETURN,
'filename' => 'pdf.pdf',
], $options);
$mpdf = $this->_preparePdf($viewFile, $options['viewVars']);
$options['viewVars']['mpdf'] = $mpdf;
if (!is_array($viewFile)) {
$wholeString = $this->_getView()->element($viewFile, $options['viewVars']);
// use 10% less than pcre.backtrack_limit to account for multibyte characters
$splitLength = ini_get('pcre.backtrack_limit') - (ini_get('pcre.backtrack_limit') / 10);
$splitString = str_split($wholeString, $splitLength);
foreach ($splitString as $string) {
$mpdf->WriteHTML($string);
}
}
switch ($options['target']) {
case self::TARGET_RETURN:
return $mpdf;
break;
case self::TARGET_DOWNLOAD:
$mpdf->Output($options['filename'], 'D');
break;
case self::TARGET_BROWSER:
$mpdf->Output($options['filename'], 'I');
break;
case self::TARGET_FILE:
$mpdf->Output($options['filename'], 'F');
break;
case self::TARGET_BINARY:
return $mpdf->Output('', 'S');
break;
default:
throw new \InvalidArgumentException("{$options['target']} is not a valid target");
break;
}
} | [
"public",
"function",
"render",
"(",
"$",
"viewFile",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"options",
"=",
"Hash",
"::",
"merge",
"(",
"[",
"'target'",
"=>",
"self",
"::",
"TARGET_RETURN",
",",
"'filename'",
"=>",
"'pdf.pdf'",
",... | Render a view file
@param string|array $viewFile Path to the View file to render or array with multiple
@param array $options Options
- target
- TARGET_RETURN: Return the MPDF instance
- TARGET_BROWSER: Send the rendered PDF file to the browser
- TARGET_FILE: Save the PDF to the given file
- viewVars: Variables to pass to the $viewFile
- filename: Used with TARGET_BROWSER and TARGET_FILE
@return mixed | [
"Render",
"a",
"view",
"file"
] | efba42cf4e1804df8f1faa83ef75927bee6c206b | https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Lib/PdfGenerator.php#L164-L204 | train |
digbang/security | src/Permissions/LazyPermissionsTrait.php | LazyPermissionsTrait.hasAccess | public function hasAccess($permissions)
{
if ($this->permissions->isEmpty())
{
$this->mergePermissions($this->userPermissions, $this->rolePermissions);
}
if (func_num_args() > 1)
{
$permissions = func_get_args();
}
foreach ((array) $permissions as $permissionName)
{
if (! $this->allows($permissionName))
{
return false;
}
}
return true;
} | php | public function hasAccess($permissions)
{
if ($this->permissions->isEmpty())
{
$this->mergePermissions($this->userPermissions, $this->rolePermissions);
}
if (func_num_args() > 1)
{
$permissions = func_get_args();
}
foreach ((array) $permissions as $permissionName)
{
if (! $this->allows($permissionName))
{
return false;
}
}
return true;
} | [
"public",
"function",
"hasAccess",
"(",
"$",
"permissions",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"permissions",
"->",
"isEmpty",
"(",
")",
")",
"{",
"$",
"this",
"->",
"mergePermissions",
"(",
"$",
"this",
"->",
"userPermissions",
",",
"$",
"this",
... | Returns if access is available for all given permissions.
@param array|string $permissions
@return bool | [
"Returns",
"if",
"access",
"is",
"available",
"for",
"all",
"given",
"permissions",
"."
] | ee925c5a144a1553f5a72ded6f5a66c01a86ab21 | https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Permissions/LazyPermissionsTrait.php#L38-L59 | train |
digbang/security | src/Permissions/LazyPermissionsTrait.php | LazyPermissionsTrait.add | protected function add(Permission $permission, $override = true)
{
if ($override || ! $this->permissions->containsKey($permission->getName()))
{
$this->permissions->set($permission->getName(), $permission);
}
} | php | protected function add(Permission $permission, $override = true)
{
if ($override || ! $this->permissions->containsKey($permission->getName()))
{
$this->permissions->set($permission->getName(), $permission);
}
} | [
"protected",
"function",
"add",
"(",
"Permission",
"$",
"permission",
",",
"$",
"override",
"=",
"true",
")",
"{",
"if",
"(",
"$",
"override",
"||",
"!",
"$",
"this",
"->",
"permissions",
"->",
"containsKey",
"(",
"$",
"permission",
"->",
"getName",
"(",... | Adds a permission to the merged permissions Collection.
Override logic is handled from outside to enable strict or standard permissions.
@param Permission $permission
@param bool $override | [
"Adds",
"a",
"permission",
"to",
"the",
"merged",
"permissions",
"Collection",
".",
"Override",
"logic",
"is",
"handled",
"from",
"outside",
"to",
"enable",
"strict",
"or",
"standard",
"permissions",
"."
] | ee925c5a144a1553f5a72ded6f5a66c01a86ab21 | https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Permissions/LazyPermissionsTrait.php#L98-L104 | train |
digbang/security | src/Permissions/LazyPermissionsTrait.php | LazyPermissionsTrait.allows | protected function allows($permissionName)
{
foreach ($this->getMatchingPermissions($permissionName) as $key)
{
/** @var Permission $permission */
$permission = $this->permissions->get($key);
if ($permission->isAllowed())
{
return true;
}
}
return false;
} | php | protected function allows($permissionName)
{
foreach ($this->getMatchingPermissions($permissionName) as $key)
{
/** @var Permission $permission */
$permission = $this->permissions->get($key);
if ($permission->isAllowed())
{
return true;
}
}
return false;
} | [
"protected",
"function",
"allows",
"(",
"$",
"permissionName",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"getMatchingPermissions",
"(",
"$",
"permissionName",
")",
"as",
"$",
"key",
")",
"{",
"/** @var Permission $permission */",
"$",
"permission",
"=",
"$",
... | Check if the given permission is allowed.
Only explicitly allowed permissions will return true.
@param string $permissionName
@return bool | [
"Check",
"if",
"the",
"given",
"permission",
"is",
"allowed",
".",
"Only",
"explicitly",
"allowed",
"permissions",
"will",
"return",
"true",
"."
] | ee925c5a144a1553f5a72ded6f5a66c01a86ab21 | https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Permissions/LazyPermissionsTrait.php#L113-L127 | train |
klermonte/zerg | src/Zerg/Field/Scalar.php | Scalar.setSize | public function setSize($size)
{
if (is_string($size) && $parsed = $this->parseSizeWord($size)) {
$this->size = $parsed;
} else {
$this->size = $size;
}
return $this;
} | php | public function setSize($size)
{
if (is_string($size) && $parsed = $this->parseSizeWord($size)) {
$this->size = $parsed;
} else {
$this->size = $size;
}
return $this;
} | [
"public",
"function",
"setSize",
"(",
"$",
"size",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"size",
")",
"&&",
"$",
"parsed",
"=",
"$",
"this",
"->",
"parseSizeWord",
"(",
"$",
"size",
")",
")",
"{",
"$",
"this",
"->",
"size",
"=",
"$",
"parse... | Process and sets size.
Size can be represented as a string containing on of size key words {@see $sizes}.
Also you can set path to already parsed value in DataSet.
@param int|string $size Size in bits/bytes or DataSet path.
@return static For chaining. | [
"Process",
"and",
"sets",
"size",
"."
] | c5d9c52cfade1fe9169e3cbae855b49a054f04ff | https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/Scalar.php#L103-L111 | train |
klermonte/zerg | src/Zerg/Field/Scalar.php | Scalar.parse | public function parse(AbstractStream $stream)
{
$value = $this->format($this->read($stream));
$this->validate($value);
return $value;
} | php | public function parse(AbstractStream $stream)
{
$value = $this->format($this->read($stream));
$this->validate($value);
return $value;
} | [
"public",
"function",
"parse",
"(",
"AbstractStream",
"$",
"stream",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"format",
"(",
"$",
"this",
"->",
"read",
"(",
"$",
"stream",
")",
")",
";",
"$",
"this",
"->",
"validate",
"(",
"$",
"value",
")",... | Reads and process value from Stream.
@api
@param AbstractStream $stream Stream from which read.
@return mixed The final value. | [
"Reads",
"and",
"process",
"value",
"from",
"Stream",
"."
] | c5d9c52cfade1fe9169e3cbae855b49a054f04ff | https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/Scalar.php#L167-L172 | train |
klermonte/zerg | src/Zerg/Field/Scalar.php | Scalar.format | private function format($value)
{
if (is_callable($this->formatter)) {
$value = call_user_func($this->formatter, $value, $this->dataSet);
}
return $value;
} | php | private function format($value)
{
if (is_callable($this->formatter)) {
$value = call_user_func($this->formatter, $value, $this->dataSet);
}
return $value;
} | [
"private",
"function",
"format",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_callable",
"(",
"$",
"this",
"->",
"formatter",
")",
")",
"{",
"$",
"value",
"=",
"call_user_func",
"(",
"$",
"this",
"->",
"formatter",
",",
"$",
"value",
",",
"$",
"this",... | Applies value formatter to read value.
@param int|string|null $value Read value.
@return mixed Processed value. | [
"Applies",
"value",
"formatter",
"to",
"read",
"value",
"."
] | c5d9c52cfade1fe9169e3cbae855b49a054f04ff | https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/Scalar.php#L180-L186 | train |
klermonte/zerg | src/Zerg/Field/Scalar.php | Scalar.parseSizeWord | private function parseSizeWord($word)
{
$sizeWord = strtoupper(preg_replace('/([a-z])([A-Z])/', '$1_$2', $word));
if (array_key_exists($sizeWord, $this->sizes)) {
$size = $this->sizes[$sizeWord];
} else {
$size = 0;
}
return $size;
} | php | private function parseSizeWord($word)
{
$sizeWord = strtoupper(preg_replace('/([a-z])([A-Z])/', '$1_$2', $word));
if (array_key_exists($sizeWord, $this->sizes)) {
$size = $this->sizes[$sizeWord];
} else {
$size = 0;
}
return $size;
} | [
"private",
"function",
"parseSizeWord",
"(",
"$",
"word",
")",
"{",
"$",
"sizeWord",
"=",
"strtoupper",
"(",
"preg_replace",
"(",
"'/([a-z])([A-Z])/'",
",",
"'$1_$2'",
",",
"$",
"word",
")",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"sizeWord",
",... | Process given string and return appropriate size value.
@param $word
@return int | [
"Process",
"given",
"string",
"and",
"return",
"appropriate",
"size",
"value",
"."
] | c5d9c52cfade1fe9169e3cbae855b49a054f04ff | https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/Scalar.php#L194-L203 | train |
laravie/webhook | src/Request.php | Request.send | protected function send($url, array $headers = [], $body = []): ResponseContract
{
$endpoint = $url instanceof EndpointContract ? $url : static::to($url);
return $this->responseWith(
$this->client->send('POST', $endpoint, $headers, $body)
);
} | php | protected function send($url, array $headers = [], $body = []): ResponseContract
{
$endpoint = $url instanceof EndpointContract ? $url : static::to($url);
return $this->responseWith(
$this->client->send('POST', $endpoint, $headers, $body)
);
} | [
"protected",
"function",
"send",
"(",
"$",
"url",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"$",
"body",
"=",
"[",
"]",
")",
":",
"ResponseContract",
"{",
"$",
"endpoint",
"=",
"$",
"url",
"instanceof",
"EndpointContract",
"?",
"$",
"url",
":... | Send Webhook request.
@param \Laravie\Codex\Contracts\Endpoint|string $url
@param array $headers
@param \Psr\Http\Message\StreamInterface|\Laravie\Codex\Payload|array|null $body
@return \Laravie\Codex\Contracts\Response | [
"Send",
"Webhook",
"request",
"."
] | a68b11ca58b1c9564b1cec6a52c2a738fbe9f023 | https://github.com/laravie/webhook/blob/a68b11ca58b1c9564b1cec6a52c2a738fbe9f023/src/Request.php#L21-L28 | train |
postalservice14/php-actuator | src/Health/OrderedHealthAggregator.php | OrderedHealthAggregator.statusComparator | private function statusComparator($s1, $s2)
{
if (array_search($s1->getCode(), $this->statusOrder) === array_search($s2->getCode(), $this->statusOrder)) {
return 0;
}
return (array_search($s1->getCode(), $this->statusOrder)
< array_search($s2->getCode(), $this->statusOrder)) ? -1 : 1;
} | php | private function statusComparator($s1, $s2)
{
if (array_search($s1->getCode(), $this->statusOrder) === array_search($s2->getCode(), $this->statusOrder)) {
return 0;
}
return (array_search($s1->getCode(), $this->statusOrder)
< array_search($s2->getCode(), $this->statusOrder)) ? -1 : 1;
} | [
"private",
"function",
"statusComparator",
"(",
"$",
"s1",
",",
"$",
"s2",
")",
"{",
"if",
"(",
"array_search",
"(",
"$",
"s1",
"->",
"getCode",
"(",
")",
",",
"$",
"this",
"->",
"statusOrder",
")",
"===",
"array_search",
"(",
"$",
"s2",
"->",
"getCo... | Callable used to order Status.
@param Status $s1
@param Status $s2
@return int | [
"Callable",
"used",
"to",
"order",
"Status",
"."
] | 08e0ab32fb0cdc24356aa8cc86245fab294ec841 | https://github.com/postalservice14/php-actuator/blob/08e0ab32fb0cdc24356aa8cc86245fab294ec841/src/Health/OrderedHealthAggregator.php#L57-L65 | train |
digbang/security | src/Reminders/DefaultDoctrineReminderRepository.php | DefaultDoctrineReminderRepository.create | public function create(UserInterface $user)
{
$entity = static::ENTITY_CLASSNAME;
$reminder = new $entity($user);
$this->save($reminder);
return $reminder;
} | php | public function create(UserInterface $user)
{
$entity = static::ENTITY_CLASSNAME;
$reminder = new $entity($user);
$this->save($reminder);
return $reminder;
} | [
"public",
"function",
"create",
"(",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"entity",
"=",
"static",
"::",
"ENTITY_CLASSNAME",
";",
"$",
"reminder",
"=",
"new",
"$",
"entity",
"(",
"$",
"user",
")",
";",
"$",
"this",
"->",
"save",
"(",
"$",
"re... | Create a new reminder record and code.
@param \Digbang\Security\Users\User $user
@return Reminder | [
"Create",
"a",
"new",
"reminder",
"record",
"and",
"code",
"."
] | ee925c5a144a1553f5a72ded6f5a66c01a86ab21 | https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Reminders/DefaultDoctrineReminderRepository.php#L27-L36 | train |
Roave/RoaveDeveloperTools | src/Roave/DeveloperTools/Stub/SerializableValueStub.php | SerializableValueStub.makeSerializable | private function makeSerializable($value)
{
if (null === $value) {
return $value;
}
if ($value instanceof Traversable || is_array($value)) {
$value = ArrayUtils::iteratorToArray($value);
foreach ($value as $key => $val) {
$value[$key] = $this->makeSerializable($val);
}
return $value;
}
if (is_scalar($value)) {
return $value;
}
if (is_resource($value)) {
return 'resource';
}
return new ObjectStub($value);
} | php | private function makeSerializable($value)
{
if (null === $value) {
return $value;
}
if ($value instanceof Traversable || is_array($value)) {
$value = ArrayUtils::iteratorToArray($value);
foreach ($value as $key => $val) {
$value[$key] = $this->makeSerializable($val);
}
return $value;
}
if (is_scalar($value)) {
return $value;
}
if (is_resource($value)) {
return 'resource';
}
return new ObjectStub($value);
} | [
"private",
"function",
"makeSerializable",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"value",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"Traversable",
"||",
"is_array",
"(",
"$",
"value",
")",
... | Retrieves a serializable version of a given value
@param mixed $value
@return mixed
@throws \Zend\Stdlib\Exception\InvalidArgumentException | [
"Retrieves",
"a",
"serializable",
"version",
"of",
"a",
"given",
"value"
] | 424285eb861c9df7891ce7c6e66a21756eecd81c | https://github.com/Roave/RoaveDeveloperTools/blob/424285eb861c9df7891ce7c6e66a21756eecd81c/src/Roave/DeveloperTools/Stub/SerializableValueStub.php#L82-L107 | train |
Roave/RoaveDeveloperTools | src/Roave/DeveloperTools/Stub/SerializableValueStub.php | SerializableValueStub.makeReal | private function makeReal($value)
{
if (is_array($value)) {
foreach ($value as $key => $val) {
$value[$key] = $this->makeReal($val);
}
}
if ($value instanceof ObjectStub) {
return $value->getObject();
}
return $value;
} | php | private function makeReal($value)
{
if (is_array($value)) {
foreach ($value as $key => $val) {
$value[$key] = $this->makeReal($val);
}
}
if ($value instanceof ObjectStub) {
return $value->getObject();
}
return $value;
} | [
"private",
"function",
"makeReal",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"value",
"[",
"$",
"key",
"]",
"=",
"$",
... | Retrieves a "semi-real" version of the value
@param mixed $value
@return mixed | [
"Retrieves",
"a",
"semi",
"-",
"real",
"version",
"of",
"the",
"value"
] | 424285eb861c9df7891ce7c6e66a21756eecd81c | https://github.com/Roave/RoaveDeveloperTools/blob/424285eb861c9df7891ce7c6e66a21756eecd81c/src/Roave/DeveloperTools/Stub/SerializableValueStub.php#L116-L129 | train |
brightnucleus/view | src/View/ViewBuilder.php | ViewBuilder.getView | public function getView(string $uri, Engine $engine, $type = null): View
{
if (null === $type) {
$view = $this->getViewFinder()->find([$uri], $engine);
return $view->setBuilder( $this );
}
return $this->resolveType($type, $uri, $engine);
} | php | public function getView(string $uri, Engine $engine, $type = null): View
{
if (null === $type) {
$view = $this->getViewFinder()->find([$uri], $engine);
return $view->setBuilder( $this );
}
return $this->resolveType($type, $uri, $engine);
} | [
"public",
"function",
"getView",
"(",
"string",
"$",
"uri",
",",
"Engine",
"$",
"engine",
",",
"$",
"type",
"=",
"null",
")",
":",
"View",
"{",
"if",
"(",
"null",
"===",
"$",
"type",
")",
"{",
"$",
"view",
"=",
"$",
"this",
"->",
"getViewFinder",
... | Get a view for a given URI, engine and type.
@since 0.1.0
@param string $uri URI to get a view for.
@param Engine $engine Engine to use for the view.
@param mixed $type Type of view to get.
@return View View that matches the given requirements.
@throws FailedToInstantiateView If the view could not be instantiated. | [
"Get",
"a",
"view",
"for",
"a",
"given",
"URI",
"engine",
"and",
"type",
"."
] | f26703b78bf452403fda112563825f172dc9e8ce | https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/ViewBuilder.php#L168-L176 | train |
brightnucleus/view | src/View/ViewBuilder.php | ViewBuilder.addLocation | public function addLocation(Location $location)
{
$this->locations->add($location);
unset( $this->viewPathCache );
$this->viewPathCache = [];
return $this;
} | php | public function addLocation(Location $location)
{
$this->locations->add($location);
unset( $this->viewPathCache );
$this->viewPathCache = [];
return $this;
} | [
"public",
"function",
"addLocation",
"(",
"Location",
"$",
"location",
")",
"{",
"$",
"this",
"->",
"locations",
"->",
"add",
"(",
"$",
"location",
")",
";",
"unset",
"(",
"$",
"this",
"->",
"viewPathCache",
")",
";",
"$",
"this",
"->",
"viewPathCache",
... | Add a location to scan with the BaseViewFinder.
@since 0.1.0
@param Location $location Location to scan with the BaseViewFinder.
@return static | [
"Add",
"a",
"location",
"to",
"scan",
"with",
"the",
"BaseViewFinder",
"."
] | f26703b78bf452403fda112563825f172dc9e8ce | https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/ViewBuilder.php#L211-L219 | train |
brightnucleus/view | src/View/ViewBuilder.php | ViewBuilder.scanLocations | public function scanLocations(array $criteria)
{
$uris = $this->locations->map(function ($location) use ($criteria) {
/** @var Location $location */
return $location->getURI($criteria);
})->filter(function ($uri) {
return false !== $uri;
});
// Fall back for absolute paths on current filesystem.
if ($uris->isEmpty()) {
foreach ($criteria as $criterion) {
if (file_exists($criterion)) {
return $criterion;
}
}
}
return $uris->isEmpty() ? false : $uris->first();
} | php | public function scanLocations(array $criteria)
{
$uris = $this->locations->map(function ($location) use ($criteria) {
/** @var Location $location */
return $location->getURI($criteria);
})->filter(function ($uri) {
return false !== $uri;
});
// Fall back for absolute paths on current filesystem.
if ($uris->isEmpty()) {
foreach ($criteria as $criterion) {
if (file_exists($criterion)) {
return $criterion;
}
}
}
return $uris->isEmpty() ? false : $uris->first();
} | [
"public",
"function",
"scanLocations",
"(",
"array",
"$",
"criteria",
")",
"{",
"$",
"uris",
"=",
"$",
"this",
"->",
"locations",
"->",
"map",
"(",
"function",
"(",
"$",
"location",
")",
"use",
"(",
"$",
"criteria",
")",
"{",
"/** @var Location $location *... | Scan Locations for an URI that matches the specified criteria.
@since 0.1.0
@param array $criteria Criteria to match.
@return string|false URI of the requested view, or false if not found. | [
"Scan",
"Locations",
"for",
"an",
"URI",
"that",
"matches",
"the",
"specified",
"criteria",
"."
] | f26703b78bf452403fda112563825f172dc9e8ce | https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/ViewBuilder.php#L242-L261 | train |
brightnucleus/view | src/View/ViewBuilder.php | ViewBuilder.getFinder | protected function getFinder($key)
{
$finderClass = $this->config->getKey($key, 'ClassName');
return new $finderClass($this->config->getSubConfig($key));
} | php | protected function getFinder($key)
{
$finderClass = $this->config->getKey($key, 'ClassName');
return new $finderClass($this->config->getSubConfig($key));
} | [
"protected",
"function",
"getFinder",
"(",
"$",
"key",
")",
"{",
"$",
"finderClass",
"=",
"$",
"this",
"->",
"config",
"->",
"getKey",
"(",
"$",
"key",
",",
"'ClassName'",
")",
";",
"return",
"new",
"$",
"finderClass",
"(",
"$",
"this",
"->",
"config",... | Get a finder instance.
@since 0.1.1
@param string $key Configuration key to use.
@return ViewFinder|EngineFinder The requested finder instance. | [
"Get",
"a",
"finder",
"instance",
"."
] | f26703b78bf452403fda112563825f172dc9e8ce | https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/ViewBuilder.php#L272-L276 | train |
brightnucleus/view | src/View/ViewBuilder.php | ViewBuilder.resolveType | protected function resolveType($type, string $uri, Engine $engine = null): View
{
$configKey = [static::VIEW_FINDER_KEY, 'Views', $type];
if (is_string($type) && $this->config->hasKey($configKey)) {
$className = $this->config->getKey($configKey);
$type = new $className($uri, $engine, $this);
}
if (is_string($type)) {
$type = new $type($uri, $engine, $this);
}
if (is_callable($type)) {
$type = $type($uri, $engine, $this);
}
if (! $type instanceof View) {
throw new FailedToInstantiateView(
sprintf(
_('Could not instantiate view "%s".'),
serialize($type)
)
);
}
return $type;
} | php | protected function resolveType($type, string $uri, Engine $engine = null): View
{
$configKey = [static::VIEW_FINDER_KEY, 'Views', $type];
if (is_string($type) && $this->config->hasKey($configKey)) {
$className = $this->config->getKey($configKey);
$type = new $className($uri, $engine, $this);
}
if (is_string($type)) {
$type = new $type($uri, $engine, $this);
}
if (is_callable($type)) {
$type = $type($uri, $engine, $this);
}
if (! $type instanceof View) {
throw new FailedToInstantiateView(
sprintf(
_('Could not instantiate view "%s".'),
serialize($type)
)
);
}
return $type;
} | [
"protected",
"function",
"resolveType",
"(",
"$",
"type",
",",
"string",
"$",
"uri",
",",
"Engine",
"$",
"engine",
"=",
"null",
")",
":",
"View",
"{",
"$",
"configKey",
"=",
"[",
"static",
"::",
"VIEW_FINDER_KEY",
",",
"'Views'",
",",
"$",
"type",
"]",... | Resolve the view type.
@since 0.1.0
@param mixed $type Type of view that was requested.
@param string $uri URI to get a view for.
@param Engine|null $engine Engine to use for the view.
@return View Resolved View object.
@throws FailedToInstantiateView If the view type could not be resolved. | [
"Resolve",
"the",
"view",
"type",
"."
] | f26703b78bf452403fda112563825f172dc9e8ce | https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/ViewBuilder.php#L290-L317 | train |
brightnucleus/view | src/View/ViewBuilder.php | ViewBuilder.getConfig | protected function getConfig($config = []): ConfigInterface
{
$defaults = ConfigFactory::create(dirname(__DIR__, 2) . '/config/defaults.php', $config);
$config = $config
? ConfigFactory::createFromArray(array_merge_recursive($defaults->getArrayCopy(), $config->getArrayCopy()))
: $defaults;
return $config->getSubConfig('BrightNucleus\View');
} | php | protected function getConfig($config = []): ConfigInterface
{
$defaults = ConfigFactory::create(dirname(__DIR__, 2) . '/config/defaults.php', $config);
$config = $config
? ConfigFactory::createFromArray(array_merge_recursive($defaults->getArrayCopy(), $config->getArrayCopy()))
: $defaults;
return $config->getSubConfig('BrightNucleus\View');
} | [
"protected",
"function",
"getConfig",
"(",
"$",
"config",
"=",
"[",
"]",
")",
":",
"ConfigInterface",
"{",
"$",
"defaults",
"=",
"ConfigFactory",
"::",
"create",
"(",
"dirname",
"(",
"__DIR__",
",",
"2",
")",
".",
"'/config/defaults.php'",
",",
"$",
"confi... | Get the configuration to use in the ViewBuilder.
@since 0.2.0
@param ConfigInterface|array $config Config to merge with defaults.
@return ConfigInterface Configuration passed in through the constructor. | [
"Get",
"the",
"configuration",
"to",
"use",
"in",
"the",
"ViewBuilder",
"."
] | f26703b78bf452403fda112563825f172dc9e8ce | https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/ViewBuilder.php#L328-L336 | train |
thinktomorrow/assetlibrary | src/Models/Asset.php | Asset.attachToModel | public function attachToModel(Model $model, $type = '', $locale = null): Model
{
if ($model->assets()->get()->contains($this)) {
throw AssetUploadException::create();
}
$model->assets->where('pivot.type', $type)->where('pivot.locale', $locale);
$locale = $locale ?? config('app.locale');
$model->assets()->attach($this, ['type' => $type, 'locale' => $locale, 'order' => $this->order]);
return $model->load('assets');
} | php | public function attachToModel(Model $model, $type = '', $locale = null): Model
{
if ($model->assets()->get()->contains($this)) {
throw AssetUploadException::create();
}
$model->assets->where('pivot.type', $type)->where('pivot.locale', $locale);
$locale = $locale ?? config('app.locale');
$model->assets()->attach($this, ['type' => $type, 'locale' => $locale, 'order' => $this->order]);
return $model->load('assets');
} | [
"public",
"function",
"attachToModel",
"(",
"Model",
"$",
"model",
",",
"$",
"type",
"=",
"''",
",",
"$",
"locale",
"=",
"null",
")",
":",
"Model",
"{",
"if",
"(",
"$",
"model",
"->",
"assets",
"(",
")",
"->",
"get",
"(",
")",
"->",
"contains",
"... | Attaches this asset instance to the given model and
sets the type and locale to the given values and
returns the model with the asset relationship.
@param Model $model
@param string $type
@param null|string $locale
@return Model
@throws \Thinktomorrow\AssetLibrary\Exceptions\AssetUploadException | [
"Attaches",
"this",
"asset",
"instance",
"to",
"the",
"given",
"model",
"and",
"sets",
"the",
"type",
"and",
"locale",
"to",
"the",
"given",
"values",
"and",
"returns",
"the",
"model",
"with",
"the",
"asset",
"relationship",
"."
] | 606c14924dc03b858d88bcc47668038365f717cf | https://github.com/thinktomorrow/assetlibrary/blob/606c14924dc03b858d88bcc47668038365f717cf/src/Models/Asset.php#L35-L48 | train |
thinktomorrow/assetlibrary | src/Models/Asset.php | Asset.getImageUrl | public function getImageUrl($type = ''): string
{
if ($this->getMedia()->isEmpty()) {
return asset('assets/back/img/other.png');
}
$extension = $this->getExtensionType();
if ($extension === 'image') {
return $this->getFileUrl($type);
} elseif ($extension) {
return asset('assets/back/img/'.$extension.'.png');
}
return asset('assets/back/img/other.png');
} | php | public function getImageUrl($type = ''): string
{
if ($this->getMedia()->isEmpty()) {
return asset('assets/back/img/other.png');
}
$extension = $this->getExtensionType();
if ($extension === 'image') {
return $this->getFileUrl($type);
} elseif ($extension) {
return asset('assets/back/img/'.$extension.'.png');
}
return asset('assets/back/img/other.png');
} | [
"public",
"function",
"getImageUrl",
"(",
"$",
"type",
"=",
"''",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"getMedia",
"(",
")",
"->",
"isEmpty",
"(",
")",
")",
"{",
"return",
"asset",
"(",
"'assets/back/img/other.png'",
")",
";",
"}",
... | Returns the image url or a fallback specific per filetype.
@param string $type
@return string | [
"Returns",
"the",
"image",
"url",
"or",
"a",
"fallback",
"specific",
"per",
"filetype",
"."
] | 606c14924dc03b858d88bcc47668038365f717cf | https://github.com/thinktomorrow/assetlibrary/blob/606c14924dc03b858d88bcc47668038365f717cf/src/Models/Asset.php#L91-L104 | train |
thinktomorrow/assetlibrary | src/Models/Asset.php | Asset.removeByIds | public static function removeByIds($imageIds)
{
if (is_array($imageIds)) {
foreach ($imageIds as $id) {
if (! $id) {
continue;
}
self::remove($id);
}
} else {
if (! $imageIds) {
return;
}
self::remove($imageIds);
}
} | php | public static function removeByIds($imageIds)
{
if (is_array($imageIds)) {
foreach ($imageIds as $id) {
if (! $id) {
continue;
}
self::remove($id);
}
} else {
if (! $imageIds) {
return;
}
self::remove($imageIds);
}
} | [
"public",
"static",
"function",
"removeByIds",
"(",
"$",
"imageIds",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"imageIds",
")",
")",
"{",
"foreach",
"(",
"$",
"imageIds",
"as",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"continue",
... | Removes one or more assets by their ids.
@param $imageIds | [
"Removes",
"one",
"or",
"more",
"assets",
"by",
"their",
"ids",
"."
] | 606c14924dc03b858d88bcc47668038365f717cf | https://github.com/thinktomorrow/assetlibrary/blob/606c14924dc03b858d88bcc47668038365f717cf/src/Models/Asset.php#L193-L210 | train |
thinktomorrow/assetlibrary | src/Models/Asset.php | Asset.remove | public static function remove($id)
{
$asset = self::find($id)->first();
$media = $asset->media;
foreach ($media as $file) {
if (! is_file(public_path($file->getUrl())) || ! is_writable(public_path($file->getUrl()))) {
return;
}
}
$asset->delete();
} | php | public static function remove($id)
{
$asset = self::find($id)->first();
$media = $asset->media;
foreach ($media as $file) {
if (! is_file(public_path($file->getUrl())) || ! is_writable(public_path($file->getUrl()))) {
return;
}
}
$asset->delete();
} | [
"public",
"static",
"function",
"remove",
"(",
"$",
"id",
")",
"{",
"$",
"asset",
"=",
"self",
"::",
"find",
"(",
"$",
"id",
")",
"->",
"first",
"(",
")",
";",
"$",
"media",
"=",
"$",
"asset",
"->",
"media",
";",
"foreach",
"(",
"$",
"media",
"... | Removes one assets by id.
It also checks if you have the permissions to remove the file.
@param $imageIds | [
"Removes",
"one",
"assets",
"by",
"id",
".",
"It",
"also",
"checks",
"if",
"you",
"have",
"the",
"permissions",
"to",
"remove",
"the",
"file",
"."
] | 606c14924dc03b858d88bcc47668038365f717cf | https://github.com/thinktomorrow/assetlibrary/blob/606c14924dc03b858d88bcc47668038365f717cf/src/Models/Asset.php#L218-L230 | train |
thinktomorrow/assetlibrary | src/Models/Asset.php | Asset.registerMediaConversions | public function registerMediaConversions(Media $media = null)
{
$conversions = config('assetlibrary.conversions');
foreach ($conversions as $key => $value) {
$conversionName = $key;
$this->addMediaConversion($conversionName)
->width($value['width'])
->height($value['height'])
->keepOriginalImageFormat()
->optimize();
}
if (config('assetlibrary.allowCropping')) {
$this->addMediaConversion('cropped')
->keepOriginalImageFormat()
->optimize();
}
} | php | public function registerMediaConversions(Media $media = null)
{
$conversions = config('assetlibrary.conversions');
foreach ($conversions as $key => $value) {
$conversionName = $key;
$this->addMediaConversion($conversionName)
->width($value['width'])
->height($value['height'])
->keepOriginalImageFormat()
->optimize();
}
if (config('assetlibrary.allowCropping')) {
$this->addMediaConversion('cropped')
->keepOriginalImageFormat()
->optimize();
}
} | [
"public",
"function",
"registerMediaConversions",
"(",
"Media",
"$",
"media",
"=",
"null",
")",
"{",
"$",
"conversions",
"=",
"config",
"(",
"'assetlibrary.conversions'",
")",
";",
"foreach",
"(",
"$",
"conversions",
"as",
"$",
"key",
"=>",
"$",
"value",
")"... | Register the conversions that should be performed.
@param Media|null $media
@throws \Spatie\Image\Exceptions\InvalidManipulation | [
"Register",
"the",
"conversions",
"that",
"should",
"be",
"performed",
"."
] | 606c14924dc03b858d88bcc47668038365f717cf | https://github.com/thinktomorrow/assetlibrary/blob/606c14924dc03b858d88bcc47668038365f717cf/src/Models/Asset.php#L271-L290 | train |
MovingImage24/VMProApiClient | lib/Util/AccessorTrait.php | AccessorTrait.checkArguments | protected function checkArguments(array $args, $min, $max, $methodName)
{
$argc = count($args);
if ($argc < $min || $argc > $max) {
throw new \BadMethodCallException("Method $methodName is not exist");
}
} | php | protected function checkArguments(array $args, $min, $max, $methodName)
{
$argc = count($args);
if ($argc < $min || $argc > $max) {
throw new \BadMethodCallException("Method $methodName is not exist");
}
} | [
"protected",
"function",
"checkArguments",
"(",
"array",
"$",
"args",
",",
"$",
"min",
",",
"$",
"max",
",",
"$",
"methodName",
")",
"{",
"$",
"argc",
"=",
"count",
"(",
"$",
"args",
")",
";",
"if",
"(",
"$",
"argc",
"<",
"$",
"min",
"||",
"$",
... | Check if args are valid or not.
@param array $args List of arguments
@param int $min integer Minimum valid params
@param int $max Maximum valid params
@param string $methodName Method name | [
"Check",
"if",
"args",
"are",
"valid",
"or",
"not",
"."
] | e242a88a93a7a915898c888a575502c21434e35b | https://github.com/MovingImage24/VMProApiClient/blob/e242a88a93a7a915898c888a575502c21434e35b/lib/Util/AccessorTrait.php#L115-L121 | train |
TheBnl/event-tickets | code/forms/WaitingListRegistrationForm.php | WaitingListRegistrationForm.doRegister | public function doRegister($data, WaitingListRegistrationForm $form)
{
$form->saveInto($registration = WaitingListRegistration::create());
$registration->EventID = $this->getController()->ID;
$this->getController()->WaitingList()->add($registration);
$this->getController()->redirect($this->getController()->Link('?waitinglist=1'));
} | php | public function doRegister($data, WaitingListRegistrationForm $form)
{
$form->saveInto($registration = WaitingListRegistration::create());
$registration->EventID = $this->getController()->ID;
$this->getController()->WaitingList()->add($registration);
$this->getController()->redirect($this->getController()->Link('?waitinglist=1'));
} | [
"public",
"function",
"doRegister",
"(",
"$",
"data",
",",
"WaitingListRegistrationForm",
"$",
"form",
")",
"{",
"$",
"form",
"->",
"saveInto",
"(",
"$",
"registration",
"=",
"WaitingListRegistration",
"::",
"create",
"(",
")",
")",
";",
"$",
"registration",
... | Sets the person on the waiting list
@param $data
@param WaitingListRegistrationForm $form | [
"Sets",
"the",
"person",
"on",
"the",
"waiting",
"list"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/forms/WaitingListRegistrationForm.php#L43-L49 | train |
k-gun/oppa | src/Database.php | Database.getInfo | public function getInfo(string $key = null)
{
if ($this->info == null) {
$resource = $this->linker->getLink()->getAgent()->getResource();
$resourceType = $resource->getType();
$serverVersion = $clientVersion = null;
if ($resourceType == Resource::TYPE_MYSQL_LINK) {
$object = $resource->getObject();
foreach (get_class_vars(get_class($object)) as $var => $_) {
$this->info[$var] = $object->{$var};
}
$serverVersion = preg_replace('~\s*([^ ]+).*~', '\1', $object->server_info);
$clientVersion = preg_replace('~(?:[a-z]+\s+)?([^ ]+).*~i', '\1', $object->client_info);
} elseif ($resourceType == Resource::TYPE_PGSQL_LINK) {
$this->info = pg_version($resource->getObject());
$serverVersion = preg_replace('~\s*([^ ]+).*~', '\1', $this->info['server']);
$clientVersion = preg_replace('~\s*([^ ]+).*~', '\1', $this->info['client']);
}
$this->info['serverVersion'] = $serverVersion;
$this->info['clientVersion'] = $clientVersion;
}
return ($key == null) ? $this->info : $this->info[$key] ?? null;
} | php | public function getInfo(string $key = null)
{
if ($this->info == null) {
$resource = $this->linker->getLink()->getAgent()->getResource();
$resourceType = $resource->getType();
$serverVersion = $clientVersion = null;
if ($resourceType == Resource::TYPE_MYSQL_LINK) {
$object = $resource->getObject();
foreach (get_class_vars(get_class($object)) as $var => $_) {
$this->info[$var] = $object->{$var};
}
$serverVersion = preg_replace('~\s*([^ ]+).*~', '\1', $object->server_info);
$clientVersion = preg_replace('~(?:[a-z]+\s+)?([^ ]+).*~i', '\1', $object->client_info);
} elseif ($resourceType == Resource::TYPE_PGSQL_LINK) {
$this->info = pg_version($resource->getObject());
$serverVersion = preg_replace('~\s*([^ ]+).*~', '\1', $this->info['server']);
$clientVersion = preg_replace('~\s*([^ ]+).*~', '\1', $this->info['client']);
}
$this->info['serverVersion'] = $serverVersion;
$this->info['clientVersion'] = $clientVersion;
}
return ($key == null) ? $this->info : $this->info[$key] ?? null;
} | [
"public",
"function",
"getInfo",
"(",
"string",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"info",
"==",
"null",
")",
"{",
"$",
"resource",
"=",
"$",
"this",
"->",
"linker",
"->",
"getLink",
"(",
")",
"->",
"getAgent",
"(",
... | Get info.
@param string|null $key
@return any | [
"Get",
"info",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Database.php#L90-L116 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Gui/Layouts/LayoutRow.php | LayoutRow.updateSize | protected function updateSize()
{
$sizeY = abs($this->startY);
$sizeX = 0;
foreach ($this->elements as $idx => $element) {
$sizeY += $element->getHeight() + $this->margin;
if (abs($element->getX()) + $element->getWidth() > $sizeX) {
$sizeX = abs($element->getX()) + $element->getWidth();
}
}
$this->setSize($sizeX, $sizeY);
} | php | protected function updateSize()
{
$sizeY = abs($this->startY);
$sizeX = 0;
foreach ($this->elements as $idx => $element) {
$sizeY += $element->getHeight() + $this->margin;
if (abs($element->getX()) + $element->getWidth() > $sizeX) {
$sizeX = abs($element->getX()) + $element->getWidth();
}
}
$this->setSize($sizeX, $sizeY);
} | [
"protected",
"function",
"updateSize",
"(",
")",
"{",
"$",
"sizeY",
"=",
"abs",
"(",
"$",
"this",
"->",
"startY",
")",
";",
"$",
"sizeX",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"elements",
"as",
"$",
"idx",
"=>",
"$",
"element",
")",
"... | Update the size of the layout according to all the elements in it. | [
"Update",
"the",
"size",
"of",
"the",
"layout",
"according",
"to",
"all",
"the",
"elements",
"in",
"it",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Gui/Layouts/LayoutRow.php#L82-L95 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Gui/Layouts/LayoutRow.php | LayoutRow.setPosition | public function setPosition($x, $y)
{
$this->posX = $x;
$this->posy = $y;
return $this;
} | php | public function setPosition($x, $y)
{
$this->posX = $x;
$this->posy = $y;
return $this;
} | [
"public",
"function",
"setPosition",
"(",
"$",
"x",
",",
"$",
"y",
")",
"{",
"$",
"this",
"->",
"posX",
"=",
"$",
"x",
";",
"$",
"this",
"->",
"posy",
"=",
"$",
"y",
";",
"return",
"$",
"this",
";",
"}"
] | Set position.
@param double $x
@param double $y
@return LayoutRow | [
"Set",
"position",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Gui/Layouts/LayoutRow.php#L104-L110 | train |
mgallegos/decima-accounting | src/Mgallegos/DecimaAccounting/Accounting/Services/AccountManagement/AccountManager.php | AccountManager.getAccounts | public function getAccounts()
{
//Is Group: Further accounts can be made under Groups, but entries can be made against non-Groups
$accounts = array();
$this->Account->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($Account) use (&$accounts)
{
array_push($accounts, array('label'=> $Account->key . ' ' . $Account->name, 'value'=>$Account->id));
});
return $accounts;
} | php | public function getAccounts()
{
//Is Group: Further accounts can be made under Groups, but entries can be made against non-Groups
$accounts = array();
$this->Account->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($Account) use (&$accounts)
{
array_push($accounts, array('label'=> $Account->key . ' ' . $Account->name, 'value'=>$Account->id));
});
return $accounts;
} | [
"public",
"function",
"getAccounts",
"(",
")",
"{",
"//Is Group: Further accounts can be made under Groups, but entries can be made against non-Groups",
"$",
"accounts",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"Account",
"->",
"byOrganization",
"(",
"$",
"this",
... | Get organization accounts
@return array
An array of arrays as follows: array( array('label'=>$name0, 'value'=>$id0), array('label'=>$name1, 'value'=>$id1),…) | [
"Get",
"organization",
"accounts"
] | 6410585303a13892e64e9dfeacbae0ca212b458b | https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Services/AccountManagement/AccountManager.php#L180-L191 | train |
mgallegos/decima-accounting | src/Mgallegos/DecimaAccounting/Accounting/Services/AccountManagement/AccountManager.php | AccountManager.getGroupsAccounts | public function getGroupsAccounts()
{
//Is Group: Further accounts can be made under Groups, but entries can be made against non-Groups
$accounts = array();
$this->Account->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($Account) use (&$accounts)
{
if($Account->is_group)
{
array_push($accounts, array('label'=> $Account->key . ' ' . $Account->name, 'value'=>$Account->id));
}
});
return $accounts;
} | php | public function getGroupsAccounts()
{
//Is Group: Further accounts can be made under Groups, but entries can be made against non-Groups
$accounts = array();
$this->Account->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($Account) use (&$accounts)
{
if($Account->is_group)
{
array_push($accounts, array('label'=> $Account->key . ' ' . $Account->name, 'value'=>$Account->id));
}
});
return $accounts;
} | [
"public",
"function",
"getGroupsAccounts",
"(",
")",
"{",
"//Is Group: Further accounts can be made under Groups, but entries can be made against non-Groups",
"$",
"accounts",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"Account",
"->",
"byOrganization",
"(",
"$",
"th... | Get group organization accounts
@return array
An array of arrays as follows: array( array('label'=>$name0, 'value'=>$id0), array('label'=>$name1, 'value'=>$id1),…) | [
"Get",
"group",
"organization",
"accounts"
] | 6410585303a13892e64e9dfeacbae0ca212b458b | https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Services/AccountManagement/AccountManager.php#L199-L213 | train |
mgallegos/decima-accounting | src/Mgallegos/DecimaAccounting/Accounting/Services/AccountManagement/AccountManager.php | AccountManager.getAccountsTypes | public function getAccountsTypes()
{
//Is Group: Further accounts can be made under Groups, but entries can be made against non-Groups
$accountTypes = array();
$this->AccountType->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($AccountType) use (&$accountTypes)
{
array_push($accountTypes, array('label'=> $AccountType->name, 'value'=>$AccountType->id));
});
return $accountTypes;
} | php | public function getAccountsTypes()
{
//Is Group: Further accounts can be made under Groups, but entries can be made against non-Groups
$accountTypes = array();
$this->AccountType->byOrganization($this->AuthenticationManager->getCurrentUserOrganizationId())->each(function($AccountType) use (&$accountTypes)
{
array_push($accountTypes, array('label'=> $AccountType->name, 'value'=>$AccountType->id));
});
return $accountTypes;
} | [
"public",
"function",
"getAccountsTypes",
"(",
")",
"{",
"//Is Group: Further accounts can be made under Groups, but entries can be made against non-Groups",
"$",
"accountTypes",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"AccountType",
"->",
"byOrganization",
"(",
"$"... | Get organization accounts types
@return array
An array of arrays as follows: array( array('label'=>$name0, 'value'=>$id0), array('label'=>$name1, 'value'=>$id1),…) | [
"Get",
"organization",
"accounts",
"types"
] | 6410585303a13892e64e9dfeacbae0ca212b458b | https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Services/AccountManagement/AccountManager.php#L269-L280 | train |
byrokrat/autogiro | src/Tree/Node.php | Node.accept | public function accept(VisitorInterface $visitor): void
{
$visitor->visitBefore($this);
foreach ($this->getChildren() as $node) {
$node->accept($visitor);
}
$visitor->visitAfter($this);
} | php | public function accept(VisitorInterface $visitor): void
{
$visitor->visitBefore($this);
foreach ($this->getChildren() as $node) {
$node->accept($visitor);
}
$visitor->visitAfter($this);
} | [
"public",
"function",
"accept",
"(",
"VisitorInterface",
"$",
"visitor",
")",
":",
"void",
"{",
"$",
"visitor",
"->",
"visitBefore",
"(",
"$",
"this",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"getChildren",
"(",
")",
"as",
"$",
"node",
")",
"{",
... | Accept a visitor | [
"Accept",
"a",
"visitor"
] | 7035467af18e991c0c130d83294b0779aa3e1583 | https://github.com/byrokrat/autogiro/blob/7035467af18e991c0c130d83294b0779aa3e1583/src/Tree/Node.php#L62-L71 | train |
byrokrat/autogiro | src/Tree/Node.php | Node.getChild | public function getChild(string $name): Node
{
foreach ($this->children as $node) {
if (strcasecmp($node->getName(), $name) == 0) {
return $node;
}
}
return new NullNode;
} | php | public function getChild(string $name): Node
{
foreach ($this->children as $node) {
if (strcasecmp($node->getName(), $name) == 0) {
return $node;
}
}
return new NullNode;
} | [
"public",
"function",
"getChild",
"(",
"string",
"$",
"name",
")",
":",
"Node",
"{",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"strcasecmp",
"(",
"$",
"node",
"->",
"getName",
"(",
")",
",",
"$",
"name",... | Get child node | [
"Get",
"child",
"node"
] | 7035467af18e991c0c130d83294b0779aa3e1583 | https://github.com/byrokrat/autogiro/blob/7035467af18e991c0c130d83294b0779aa3e1583/src/Tree/Node.php#L134-L143 | train |
byrokrat/autogiro | src/Tree/Node.php | Node.hasChild | public function hasChild(string $name): bool
{
foreach ($this->children as $node) {
if (strcasecmp($node->getName(), $name) == 0) {
return true;
}
}
return false;
} | php | public function hasChild(string $name): bool
{
foreach ($this->children as $node) {
if (strcasecmp($node->getName(), $name) == 0) {
return true;
}
}
return false;
} | [
"public",
"function",
"hasChild",
"(",
"string",
"$",
"name",
")",
":",
"bool",
"{",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"strcasecmp",
"(",
"$",
"node",
"->",
"getName",
"(",
")",
",",
"$",
"name",... | Check if child exists | [
"Check",
"if",
"child",
"exists"
] | 7035467af18e991c0c130d83294b0779aa3e1583 | https://github.com/byrokrat/autogiro/blob/7035467af18e991c0c130d83294b0779aa3e1583/src/Tree/Node.php#L148-L157 | train |
byrokrat/autogiro | src/Tree/Node.php | Node.getChildren | public function getChildren(string $name = ''): array
{
$nodes = [];
foreach ($this->children as $node) {
if (!$name || strcasecmp($node->getName(), $name) == 0) {
$nodes[] = $node;
}
}
return $nodes;
} | php | public function getChildren(string $name = ''): array
{
$nodes = [];
foreach ($this->children as $node) {
if (!$name || strcasecmp($node->getName(), $name) == 0) {
$nodes[] = $node;
}
}
return $nodes;
} | [
"public",
"function",
"getChildren",
"(",
"string",
"$",
"name",
"=",
"''",
")",
":",
"array",
"{",
"$",
"nodes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"children",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"!",
"$",
"name",
"||",
... | Get registered child nodes
@return Node[] | [
"Get",
"registered",
"child",
"nodes"
] | 7035467af18e991c0c130d83294b0779aa3e1583 | https://github.com/byrokrat/autogiro/blob/7035467af18e991c0c130d83294b0779aa3e1583/src/Tree/Node.php#L164-L175 | train |
mgallegos/decima-accounting | src/Mgallegos/DecimaAccounting/Accounting/Services/SettingManagement/SettingManager.php | SettingManager.getCountryAccountsChartsTypes | public function getCountryAccountsChartsTypes()
{
$accountsChartsTypes = array();
$this->AccountChartType->accountsChartsTypesByCountry($this->AuthenticationManager->getCurrentUserOrganizationCountry())->each(function($AccountChartType) use(&$accountsChartsTypes)
{
$name = $this->Lang->has($AccountChartType->lang_key) ? $this->Lang->get($AccountChartType->lang_key) : $AccountChartType->name;
array_push($accountsChartsTypes, array('id' => $AccountChartType->id, 'name' => $name, 'url' => $AccountChartType->url));
});
return $accountsChartsTypes;
} | php | public function getCountryAccountsChartsTypes()
{
$accountsChartsTypes = array();
$this->AccountChartType->accountsChartsTypesByCountry($this->AuthenticationManager->getCurrentUserOrganizationCountry())->each(function($AccountChartType) use(&$accountsChartsTypes)
{
$name = $this->Lang->has($AccountChartType->lang_key) ? $this->Lang->get($AccountChartType->lang_key) : $AccountChartType->name;
array_push($accountsChartsTypes, array('id' => $AccountChartType->id, 'name' => $name, 'url' => $AccountChartType->url));
});
return $accountsChartsTypes;
} | [
"public",
"function",
"getCountryAccountsChartsTypes",
"(",
")",
"{",
"$",
"accountsChartsTypes",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"AccountChartType",
"->",
"accountsChartsTypesByCountry",
"(",
"$",
"this",
"->",
"AuthenticationManager",
"->",
"getCur... | Get country accounts chart types.
@return array
An array of arrays as follows: array(array('id' => $id, 'name' => $name, 'url' => $url),…) | [
"Get",
"country",
"accounts",
"chart",
"types",
"."
] | 6410585303a13892e64e9dfeacbae0ca212b458b | https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Services/SettingManagement/SettingManager.php#L270-L282 | train |
mgallegos/decima-accounting | src/Mgallegos/DecimaAccounting/Accounting/Services/SettingManagement/SettingManager.php | SettingManager.getSystemCurrencies | public function getSystemCurrencies()
{
$currencies = array();
$this->Currency->all()->each(function($Currency) use (&$currencies)
{
array_push($currencies, array('label'=> $Currency->name . ' (' . $Currency->symbol . ')', 'value'=>$Currency->id));
});
return $currencies;
} | php | public function getSystemCurrencies()
{
$currencies = array();
$this->Currency->all()->each(function($Currency) use (&$currencies)
{
array_push($currencies, array('label'=> $Currency->name . ' (' . $Currency->symbol . ')', 'value'=>$Currency->id));
});
return $currencies;
} | [
"public",
"function",
"getSystemCurrencies",
"(",
")",
"{",
"$",
"currencies",
"=",
"array",
"(",
")",
";",
"$",
"this",
"->",
"Currency",
"->",
"all",
"(",
")",
"->",
"each",
"(",
"function",
"(",
"$",
"Currency",
")",
"use",
"(",
"&",
"$",
"currenc... | Get system currencies
@return array
An array of arrays as follows: array( array('label'=>$name0, 'value'=>$id0), array('label'=>$name1, 'value'=>$id1),…) | [
"Get",
"system",
"currencies"
] | 6410585303a13892e64e9dfeacbae0ca212b458b | https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Services/SettingManagement/SettingManager.php#L290-L300 | train |
mgallegos/decima-accounting | src/Mgallegos/DecimaAccounting/Accounting/Services/SettingManagement/SettingManager.php | SettingManager.getSettingJournals | public function getSettingJournals()
{
return $this->JournalManager->getJournalsByApp(array('appId' => 'acct-initial-acounting-setup', 'page' => 1, 'journalizedId' => $this->Setting->byOrganization($this->AuthenticationManager->getCurrentUserOrganization('id'))->first()->id, 'filter' => null, 'userId' => null, 'onlyActions' => false), true);
} | php | public function getSettingJournals()
{
return $this->JournalManager->getJournalsByApp(array('appId' => 'acct-initial-acounting-setup', 'page' => 1, 'journalizedId' => $this->Setting->byOrganization($this->AuthenticationManager->getCurrentUserOrganization('id'))->first()->id, 'filter' => null, 'userId' => null, 'onlyActions' => false), true);
} | [
"public",
"function",
"getSettingJournals",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"JournalManager",
"->",
"getJournalsByApp",
"(",
"array",
"(",
"'appId'",
"=>",
"'acct-initial-acounting-setup'",
",",
"'page'",
"=>",
"1",
",",
"'journalizedId'",
"=>",
"$",
... | Get Setting Journals
@return array | [
"Get",
"Setting",
"Journals"
] | 6410585303a13892e64e9dfeacbae0ca212b458b | https://github.com/mgallegos/decima-accounting/blob/6410585303a13892e64e9dfeacbae0ca212b458b/src/Mgallegos/DecimaAccounting/Accounting/Services/SettingManagement/SettingManager.php#L322-L325 | train |
Corviz/framework | src/Mvc/Model.php | Model.initModelProperties | private static function initModelProperties()
{
$currentModel = static::class;
if (isset(self::$modelProperties[$currentModel])) {
return;
}
$properties = [
'connection' => ConnectionFactory::build(static::$connection),
'dateFields' => static::$dates ?: [],
'fields' => static::$fields ?: [],
'primaryKeys' => (array) static::$primaryKey,
'table' => static::$table,
'timestamps' => (bool) static::$timestamps,
];
if ($properties['timestamps']) {
$properties['fields'][] = 'created_at';
$properties['fields'][] = 'updated_at';
$properties['dateFields'][] = 'created_at';
$properties['dateFields'][] = 'updated_at';
}
self::$modelProperties[$currentModel] = $properties;
} | php | private static function initModelProperties()
{
$currentModel = static::class;
if (isset(self::$modelProperties[$currentModel])) {
return;
}
$properties = [
'connection' => ConnectionFactory::build(static::$connection),
'dateFields' => static::$dates ?: [],
'fields' => static::$fields ?: [],
'primaryKeys' => (array) static::$primaryKey,
'table' => static::$table,
'timestamps' => (bool) static::$timestamps,
];
if ($properties['timestamps']) {
$properties['fields'][] = 'created_at';
$properties['fields'][] = 'updated_at';
$properties['dateFields'][] = 'created_at';
$properties['dateFields'][] = 'updated_at';
}
self::$modelProperties[$currentModel] = $properties;
} | [
"private",
"static",
"function",
"initModelProperties",
"(",
")",
"{",
"$",
"currentModel",
"=",
"static",
"::",
"class",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"modelProperties",
"[",
"$",
"currentModel",
"]",
")",
")",
"{",
"return",
";",
"}"... | Initialize static properties. | [
"Initialize",
"static",
"properties",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Mvc/Model.php#L208-L233 | train |
Corviz/framework | src/Mvc/Model.php | Model.exists | public function exists() : bool
{
$query = static::createQuery();
$pks = static::getPrimaryKeys();
$pkValues = $this->getPrimaryKeyValues();
if (count($pks) != count($pkValues)) {
return false;
}
$filterFunction = function (WhereClause $whereClause) use (&$pkValues, $query) {
foreach ($pkValues as $field => $value) {
$whereClause->and($field, '=', '?');
$query->bind($value);
}
};
$query->where($filterFunction)
->count('*');
$row = $query->execute()->fetch();
return $row['all_count'] > 0;
} | php | public function exists() : bool
{
$query = static::createQuery();
$pks = static::getPrimaryKeys();
$pkValues = $this->getPrimaryKeyValues();
if (count($pks) != count($pkValues)) {
return false;
}
$filterFunction = function (WhereClause $whereClause) use (&$pkValues, $query) {
foreach ($pkValues as $field => $value) {
$whereClause->and($field, '=', '?');
$query->bind($value);
}
};
$query->where($filterFunction)
->count('*');
$row = $query->execute()->fetch();
return $row['all_count'] > 0;
} | [
"public",
"function",
"exists",
"(",
")",
":",
"bool",
"{",
"$",
"query",
"=",
"static",
"::",
"createQuery",
"(",
")",
";",
"$",
"pks",
"=",
"static",
"::",
"getPrimaryKeys",
"(",
")",
";",
"$",
"pkValues",
"=",
"$",
"this",
"->",
"getPrimaryKeyValues... | Checks if the current Model exists in the storage.
@return bool | [
"Checks",
"if",
"the",
"current",
"Model",
"exists",
"in",
"the",
"storage",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Mvc/Model.php#L272-L294 | train |
Corviz/framework | src/Mvc/Model.php | Model.insert | public function insert() : Result
{
$result = self::getConnection()->insert($this);
/*
* In a successful insert operation, assign the new id to
* current model.
*/
if ($result->count()) {
$pks = static::getPrimaryKeys();
if (count($pks) == 1) {
$this->data[$pks[0]] = static::getConnection()->lastId();
}
}
return $result;
} | php | public function insert() : Result
{
$result = self::getConnection()->insert($this);
/*
* In a successful insert operation, assign the new id to
* current model.
*/
if ($result->count()) {
$pks = static::getPrimaryKeys();
if (count($pks) == 1) {
$this->data[$pks[0]] = static::getConnection()->lastId();
}
}
return $result;
} | [
"public",
"function",
"insert",
"(",
")",
":",
"Result",
"{",
"$",
"result",
"=",
"self",
"::",
"getConnection",
"(",
")",
"->",
"insert",
"(",
"$",
"this",
")",
";",
"/*\n * In a successful insert operation, assign the new id to\n * current model.\n ... | Insert data in the database.
@return Result | [
"Insert",
"data",
"in",
"the",
"database",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Mvc/Model.php#L351-L368 | train |
melisplatform/melis-installer | src/MelisModuleManager.php | MelisModuleManager.sanitize | public static function sanitize($input, $skip = [], $textOnly = false, $removeFunctions = true)
{
if (!is_array($input)) {
if (true === $removeFunctions) {
$input = preg_replace('/[a-zA-Z][a-zA-Z0-9_]+(\()+([a-zA-Z0-9_\-$,\s\"]?)+(\))(\;?)/', '', $input);
}
$invalidValues = ['exec', '\\', '&', '&#', '0x', '<script>', '</script>', '">', "'>"];
$allowableTags = '<p><br><img><label><input><textarea><div><span><a><strong><i><u>';
$input = str_replace($invalidValues, '', $input);
$input = preg_replace('/%[a-zA-Z0-9]{2}/', '', $input);
$input = strip_tags(trim($input), $allowableTags);
if ($textOnly) {
$input = str_replace(['<', '>', "'", '"'], '', $input);
}
return $input;
} else {
$array = [];
foreach ($input as $key => $item) {
if (in_array($key, $skip)) {
$array[$key] = $item;
} else {
if (!is_array($item)) {
$array[$key] = self::sanitize($item, $skip, $textOnly, $removeFunctions);
} else {
$array = array_merge($array, [$key => self::sanitize($item, $skip, $textOnly, $removeFunctions)]);
}
}
}
return $array;
}
} | php | public static function sanitize($input, $skip = [], $textOnly = false, $removeFunctions = true)
{
if (!is_array($input)) {
if (true === $removeFunctions) {
$input = preg_replace('/[a-zA-Z][a-zA-Z0-9_]+(\()+([a-zA-Z0-9_\-$,\s\"]?)+(\))(\;?)/', '', $input);
}
$invalidValues = ['exec', '\\', '&', '&#', '0x', '<script>', '</script>', '">', "'>"];
$allowableTags = '<p><br><img><label><input><textarea><div><span><a><strong><i><u>';
$input = str_replace($invalidValues, '', $input);
$input = preg_replace('/%[a-zA-Z0-9]{2}/', '', $input);
$input = strip_tags(trim($input), $allowableTags);
if ($textOnly) {
$input = str_replace(['<', '>', "'", '"'], '', $input);
}
return $input;
} else {
$array = [];
foreach ($input as $key => $item) {
if (in_array($key, $skip)) {
$array[$key] = $item;
} else {
if (!is_array($item)) {
$array[$key] = self::sanitize($item, $skip, $textOnly, $removeFunctions);
} else {
$array = array_merge($array, [$key => self::sanitize($item, $skip, $textOnly, $removeFunctions)]);
}
}
}
return $array;
}
} | [
"public",
"static",
"function",
"sanitize",
"(",
"$",
"input",
",",
"$",
"skip",
"=",
"[",
"]",
",",
"$",
"textOnly",
"=",
"false",
",",
"$",
"removeFunctions",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
... | Sanitizes or recursively sanitizes a value
@param $input
@param array $skip
@param bool $textOnly
@param bool $removeFunctions
@return array|mixed|string | [
"Sanitizes",
"or",
"recursively",
"sanitizes",
"a",
"value"
] | f34d925b847c1389a5498844fdae890eeb34e461 | https://github.com/melisplatform/melis-installer/blob/f34d925b847c1389a5498844fdae890eeb34e461/src/MelisModuleManager.php#L102-L139 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlDualList.php | XmlDualList.setDataSource | public function setDataSource($listLeft, $listRight = null)
{
$this->_listLeftDataSource = $listLeft;
$this->_listRightDataSource = $listRight;
} | php | public function setDataSource($listLeft, $listRight = null)
{
$this->_listLeftDataSource = $listLeft;
$this->_listRightDataSource = $listRight;
} | [
"public",
"function",
"setDataSource",
"(",
"$",
"listLeft",
",",
"$",
"listRight",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"_listLeftDataSource",
"=",
"$",
"listLeft",
";",
"$",
"this",
"->",
"_listRightDataSource",
"=",
"$",
"listRight",
";",
"}"
] | Config DataSource to Dual List
@param IteratorInterface $listLeft
@param IteratorInterface $listRight | [
"Config",
"DataSource",
"to",
"Dual",
"List"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlDualList.php#L181-L185 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlDualList.php | XmlDualList.createDefaultButtons | public function createDefaultButtons()
{
$this->setButtonOneLeft(new DualListButton("<--", DualListButtonType::Button));
$this->setButtonAllLeft(new DualListButton("<<<", DualListButtonType::Button));
$this->setButtonOneRight(new DualListButton("-->", DualListButtonType::Button));
$this->setButtonAllRight(new DualListButton(">>>", DualListButtonType::Button));
} | php | public function createDefaultButtons()
{
$this->setButtonOneLeft(new DualListButton("<--", DualListButtonType::Button));
$this->setButtonAllLeft(new DualListButton("<<<", DualListButtonType::Button));
$this->setButtonOneRight(new DualListButton("-->", DualListButtonType::Button));
$this->setButtonAllRight(new DualListButton(">>>", DualListButtonType::Button));
} | [
"public",
"function",
"createDefaultButtons",
"(",
")",
"{",
"$",
"this",
"->",
"setButtonOneLeft",
"(",
"new",
"DualListButton",
"(",
"\"<--\"",
",",
"DualListButtonType",
"::",
"Button",
")",
")",
";",
"$",
"this",
"->",
"setButtonAllLeft",
"(",
"new",
"... | Create all default buttons. | [
"Create",
"all",
"default",
"buttons",
"."
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlDualList.php#L213-L219 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlDualList.php | XmlDualList.Parse | public static function Parse($context, $duallistaname)
{
$val = $context->get($duallistaname);
if ($val != "")
{
return explode(",", $val);
}
else
{
return array();
}
} | php | public static function Parse($context, $duallistaname)
{
$val = $context->get($duallistaname);
if ($val != "")
{
return explode(",", $val);
}
else
{
return array();
}
} | [
"public",
"static",
"function",
"Parse",
"(",
"$",
"context",
",",
"$",
"duallistaname",
")",
"{",
"$",
"val",
"=",
"$",
"context",
"->",
"get",
"(",
"$",
"duallistaname",
")",
";",
"if",
"(",
"$",
"val",
"!=",
"\"\"",
")",
"{",
"return",
"explode",
... | Parse RESULTSS from DualList object
@param Context $context
@param string $duallistaname
@return string[] | [
"Parse",
"RESULTSS",
"from",
"DualList",
"object"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlDualList.php#L394-L405 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlDualList.php | XmlDualList.buildListItens | private function buildListItens($list, $arr)
{
foreach ($arr as $key=>$value)
{
$item = XmlUtil::CreateChild($list, "item", "");
XmlUtil::AddAttribute($item, "id", $key);
XmlUtil::AddAttribute($item, "text", $value);
}
} | php | private function buildListItens($list, $arr)
{
foreach ($arr as $key=>$value)
{
$item = XmlUtil::CreateChild($list, "item", "");
XmlUtil::AddAttribute($item, "id", $key);
XmlUtil::AddAttribute($item, "text", $value);
}
} | [
"private",
"function",
"buildListItens",
"(",
"$",
"list",
",",
"$",
"arr",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"item",
"=",
"XmlUtil",
"::",
"CreateChild",
"(",
"$",
"list",
",",
"\"item\"",
"... | Build Dual lista data
@param DOMNode $list
@param array $arr | [
"Build",
"Dual",
"lista",
"data"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlDualList.php#L414-L422 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlDualList.php | XmlDualList.makeButton | private function makeButton($button, $name, $duallist, $from, $to, $all)
{
$newbutton = XmlUtil::CreateChild($duallist, "button", "");
XmlUtil::AddAttribute($newbutton, "name", $name);
if ($button->type == DualListButtonType::Image ) {
XmlUtil::AddAttribute($newbutton, "type", "image");
XmlUtil::AddAttribute($newbutton, "src", $button->href);
XmlUtil::AddAttribute($newbutton, "value", $button->text);
}else {
XmlUtil::AddAttribute($newbutton, "type", "button");
XmlUtil::AddAttribute($newbutton, "value", $button->text);
}
XmlUtil::AddAttribute($newbutton, "from", $from);
XmlUtil::AddAttribute($newbutton, "to", $to);
XmlUtil::AddAttribute($newbutton, "all", $all);
} | php | private function makeButton($button, $name, $duallist, $from, $to, $all)
{
$newbutton = XmlUtil::CreateChild($duallist, "button", "");
XmlUtil::AddAttribute($newbutton, "name", $name);
if ($button->type == DualListButtonType::Image ) {
XmlUtil::AddAttribute($newbutton, "type", "image");
XmlUtil::AddAttribute($newbutton, "src", $button->href);
XmlUtil::AddAttribute($newbutton, "value", $button->text);
}else {
XmlUtil::AddAttribute($newbutton, "type", "button");
XmlUtil::AddAttribute($newbutton, "value", $button->text);
}
XmlUtil::AddAttribute($newbutton, "from", $from);
XmlUtil::AddAttribute($newbutton, "to", $to);
XmlUtil::AddAttribute($newbutton, "all", $all);
} | [
"private",
"function",
"makeButton",
"(",
"$",
"button",
",",
"$",
"name",
",",
"$",
"duallist",
",",
"$",
"from",
",",
"$",
"to",
",",
"$",
"all",
")",
"{",
"$",
"newbutton",
"=",
"XmlUtil",
"::",
"CreateChild",
"(",
"$",
"duallist",
",",
"\"button\... | Make a buttom
@param DualListButton $button
@param string $name
@param DOMNode $duallist
@param string $from
@param string $to
@param string $all | [
"Make",
"a",
"buttom"
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlDualList.php#L434-L449 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.delete | function delete($key) {
$this->data[$key] = null;
unset($this->data[$key]);
return $this;
} | php | function delete($key) {
$this->data[$key] = null;
unset($this->data[$key]);
return $this;
} | [
"function",
"delete",
"(",
"$",
"key",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
"=",
"null",
";",
"unset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"key",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Removes an item from the collection by its key.
@param mixed $key
@return $this | [
"Removes",
"an",
"item",
"from",
"the",
"collection",
"by",
"its",
"key",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L100-L104 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.chunk | function chunk(int $numitems, bool $preserve_keys = false) {
return (new self(\array_chunk($this->data, $numitems, $preserve_keys)));
} | php | function chunk(int $numitems, bool $preserve_keys = false) {
return (new self(\array_chunk($this->data, $numitems, $preserve_keys)));
} | [
"function",
"chunk",
"(",
"int",
"$",
"numitems",
",",
"bool",
"$",
"preserve_keys",
"=",
"false",
")",
"{",
"return",
"(",
"new",
"self",
"(",
"\\",
"array_chunk",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"numitems",
",",
"$",
"preserve_keys",
")",
... | Breaks the collection into multiple, smaller chunks of a given size. Returns a new Collection.
@param int $numitems
@param bool $preserve_keys
@return \CharlotteDunois\Collect\Collection | [
"Breaks",
"the",
"collection",
"into",
"multiple",
"smaller",
"chunks",
"of",
"a",
"given",
"size",
".",
"Returns",
"a",
"new",
"Collection",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L129-L131 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.diff | function diff($arr) {
if($arr instanceof self) {
$arr = $arr->all();
}
return (new self(\array_diff($this->data, $arr)));
} | php | function diff($arr) {
if($arr instanceof self) {
$arr = $arr->all();
}
return (new self(\array_diff($this->data, $arr)));
} | [
"function",
"diff",
"(",
"$",
"arr",
")",
"{",
"if",
"(",
"$",
"arr",
"instanceof",
"self",
")",
"{",
"$",
"arr",
"=",
"$",
"arr",
"->",
"all",
"(",
")",
";",
"}",
"return",
"(",
"new",
"self",
"(",
"\\",
"array_diff",
"(",
"$",
"this",
"->",
... | Compares the collection against another collection or a plain PHP array based on its value. Returns a new Collection.
@param mixed[]|\CharlotteDunois\Collect\Collection $arr
@return \CharlotteDunois\Collect\Collection | [
"Compares",
"the",
"collection",
"against",
"another",
"collection",
"or",
"a",
"plain",
"PHP",
"array",
"based",
"on",
"its",
"value",
".",
"Returns",
"a",
"new",
"Collection",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L154-L160 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.diffKeys | function diffKeys($arr) {
if($arr instanceof self) {
$arr = $arr->all();
}
return (new self(\array_diff_key($this->data, $arr)));
} | php | function diffKeys($arr) {
if($arr instanceof self) {
$arr = $arr->all();
}
return (new self(\array_diff_key($this->data, $arr)));
} | [
"function",
"diffKeys",
"(",
"$",
"arr",
")",
"{",
"if",
"(",
"$",
"arr",
"instanceof",
"self",
")",
"{",
"$",
"arr",
"=",
"$",
"arr",
"->",
"all",
"(",
")",
";",
"}",
"return",
"(",
"new",
"self",
"(",
"\\",
"array_diff_key",
"(",
"$",
"this",
... | Compares the collection against another collection or a plain PHP array based on its key. Returns a new Collection.
@param mixed[]|\CharlotteDunois\Collect\Collection $arr
@return \CharlotteDunois\Collect\Collection | [
"Compares",
"the",
"collection",
"against",
"another",
"collection",
"or",
"a",
"plain",
"PHP",
"array",
"based",
"on",
"its",
"key",
".",
"Returns",
"a",
"new",
"Collection",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L167-L173 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.each | function each(callable $closure) {
foreach($this->data as $key => $val) {
$feed = $closure($val, $key);
if($feed === false) {
break;
}
}
return $this;
} | php | function each(callable $closure) {
foreach($this->data as $key => $val) {
$feed = $closure($val, $key);
if($feed === false) {
break;
}
}
return $this;
} | [
"function",
"each",
"(",
"callable",
"$",
"closure",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"feed",
"=",
"$",
"closure",
"(",
"$",
"val",
",",
"$",
"key",
")",
";",
"if",
"(",
"... | Iterates over the items in the collection and passes each item to a given callback. Returning `false` in the callback will stop the processing.
@param callable $closure Callback specification: `function ($value, $key): bool`
@return $this | [
"Iterates",
"over",
"the",
"items",
"in",
"the",
"collection",
"and",
"passes",
"each",
"item",
"to",
"a",
"given",
"callback",
".",
"Returning",
"false",
"in",
"the",
"callback",
"will",
"stop",
"the",
"processing",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L180-L189 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.filter | function filter(callable $closure) {
$new = array();
foreach($this->data as $key => $val) {
$feed = (bool) $closure($val, $key);
if($feed) {
$new[$key] = $val;
}
}
return (new self($new));
} | php | function filter(callable $closure) {
$new = array();
foreach($this->data as $key => $val) {
$feed = (bool) $closure($val, $key);
if($feed) {
$new[$key] = $val;
}
}
return (new self($new));
} | [
"function",
"filter",
"(",
"callable",
"$",
"closure",
")",
"{",
"$",
"new",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"feed",
"=",
"(",
"bool",
")",
"$",
"closure... | Filters the collection by a given callback, keeping only those items that pass a given truth test. Returns a new Collection.
@param callable $closure Callback specification: `function ($value, $key): bool`
@return \CharlotteDunois\Collect\Collection | [
"Filters",
"the",
"collection",
"by",
"a",
"given",
"callback",
"keeping",
"only",
"those",
"items",
"that",
"pass",
"a",
"given",
"truth",
"test",
".",
"Returns",
"a",
"new",
"Collection",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L227-L237 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.first | function first(callable $closure = null) {
if($closure === null) {
if(empty($this->data)) {
return null;
}
$keys = \array_keys($this->data);
return ($this->data[$keys[0]] ?? null);
}
foreach($this->data as $key => $val) {
$feed = (bool) $closure($val, $key);
if($feed) {
return $val;
}
}
return null;
} | php | function first(callable $closure = null) {
if($closure === null) {
if(empty($this->data)) {
return null;
}
$keys = \array_keys($this->data);
return ($this->data[$keys[0]] ?? null);
}
foreach($this->data as $key => $val) {
$feed = (bool) $closure($val, $key);
if($feed) {
return $val;
}
}
return null;
} | [
"function",
"first",
"(",
"callable",
"$",
"closure",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"closure",
"===",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"keys",
"=",
"\... | Returns the first element in the collection that passes a given truth test.
@param callable|null $closure Callback specification: `function ($value, $key): bool`
@return mixed|null | [
"Returns",
"the",
"first",
"element",
"in",
"the",
"collection",
"that",
"passes",
"a",
"given",
"truth",
"test",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L244-L262 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.flatten | function flatten(int $depth = 0) {
$data = $this->flattenDo($this->data, $depth);
return (new self($data));
} | php | function flatten(int $depth = 0) {
$data = $this->flattenDo($this->data, $depth);
return (new self($data));
} | [
"function",
"flatten",
"(",
"int",
"$",
"depth",
"=",
"0",
")",
"{",
"$",
"data",
"=",
"$",
"this",
"->",
"flattenDo",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"depth",
")",
";",
"return",
"(",
"new",
"self",
"(",
"$",
"data",
")",
")",
";",
... | Flattens a multi-dimensional collection into a single dimension. Returns a new Collection.
@param int $depth
@return \CharlotteDunois\Collect\Collection | [
"Flattens",
"a",
"multi",
"-",
"dimensional",
"collection",
"into",
"a",
"single",
"dimension",
".",
"Returns",
"a",
"new",
"Collection",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L269-L272 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.groupBy | function groupBy($column) {
if($column === null || $column === '') {
return $this;
}
$new = array();
foreach($this->data as $key => $val) {
if(\is_callable($column)) {
$key = $column($val, $key);
} elseif(\is_array($val)) {
$key = $val[$column];
} elseif(\is_object($val)) {
$key = $val->$column;
}
$new[$key][] = $val;
}
return (new self($new));
} | php | function groupBy($column) {
if($column === null || $column === '') {
return $this;
}
$new = array();
foreach($this->data as $key => $val) {
if(\is_callable($column)) {
$key = $column($val, $key);
} elseif(\is_array($val)) {
$key = $val[$column];
} elseif(\is_object($val)) {
$key = $val->$column;
}
$new[$key][] = $val;
}
return (new self($new));
} | [
"function",
"groupBy",
"(",
"$",
"column",
")",
"{",
"if",
"(",
"$",
"column",
"===",
"null",
"||",
"$",
"column",
"===",
"''",
")",
"{",
"return",
"$",
"this",
";",
"}",
"$",
"new",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->... | Groups the collection's items by a given key. Returns a new Collection.
@param callable|mixed $column Callback specification: `function ($value, $key): mixed`
@return \CharlotteDunois\Collect\Collection | [
"Groups",
"the",
"collection",
"s",
"items",
"by",
"a",
"given",
"key",
".",
"Returns",
"a",
"new",
"Collection",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L288-L307 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.implode | function implode($col, string $glue = ', ') {
$data = '';
foreach($this->data as $key => $val) {
if(\is_array($val)) {
if(!isset($val[$col])) {
throw new \BadMethodCallException('Specified key "'.$col.'" does not exist on array');
}
$data .= $glue.$val[$col];
} elseif(\is_object($val)) {
if(!isset($val->$col)) {
throw new \BadMethodCallException('Specified key "'.$col.'" does not exist on object');
}
$data .= $glue.$val->$col;
} else {
$data .= $glue.$val;
}
}
return \substr($data, \strlen($glue));
} | php | function implode($col, string $glue = ', ') {
$data = '';
foreach($this->data as $key => $val) {
if(\is_array($val)) {
if(!isset($val[$col])) {
throw new \BadMethodCallException('Specified key "'.$col.'" does not exist on array');
}
$data .= $glue.$val[$col];
} elseif(\is_object($val)) {
if(!isset($val->$col)) {
throw new \BadMethodCallException('Specified key "'.$col.'" does not exist on object');
}
$data .= $glue.$val->$col;
} else {
$data .= $glue.$val;
}
}
return \substr($data, \strlen($glue));
} | [
"function",
"implode",
"(",
"$",
"col",
",",
"string",
"$",
"glue",
"=",
"', '",
")",
"{",
"$",
"data",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
... | Joins the items in a collection. Its arguments depend on the type of items in the collection.
If the collection contains arrays or objects, you should pass the key of the attributes you wish to join, and the "glue" string you wish to place between the values.
@param mixed $col
@param string $glue
@return string
@throws \BadMethodCallException | [
"Joins",
"the",
"items",
"in",
"a",
"collection",
".",
"Its",
"arguments",
"depend",
"on",
"the",
"type",
"of",
"items",
"in",
"the",
"collection",
".",
"If",
"the",
"collection",
"contains",
"arrays",
"or",
"objects",
"you",
"should",
"pass",
"the",
"key"... | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L326-L348 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.indexOf | function indexOf($value) {
$i = 0;
foreach($this->data as $val) {
if($val === $value) {
return $i;
}
$i++;
}
return null;
} | php | function indexOf($value) {
$i = 0;
foreach($this->data as $val) {
if($val === $value) {
return $i;
}
$i++;
}
return null;
} | [
"function",
"indexOf",
"(",
"$",
"value",
")",
"{",
"$",
"i",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"val",
")",
"{",
"if",
"(",
"$",
"val",
"===",
"$",
"value",
")",
"{",
"return",
"$",
"i",
";",
"}",
"$",
"i"... | Returns the position of the given value in the collection. Returns null if the given value couldn't be found.
@param mixed $value
@return int|null | [
"Returns",
"the",
"position",
"of",
"the",
"given",
"value",
"in",
"the",
"collection",
".",
"Returns",
"null",
"if",
"the",
"given",
"value",
"couldn",
"t",
"be",
"found",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L355-L367 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.intersect | function intersect($arr) {
if($arr instanceof self) {
$arr = $arr->all();
}
return (new self(\array_intersect($this->data, $arr)));
} | php | function intersect($arr) {
if($arr instanceof self) {
$arr = $arr->all();
}
return (new self(\array_intersect($this->data, $arr)));
} | [
"function",
"intersect",
"(",
"$",
"arr",
")",
"{",
"if",
"(",
"$",
"arr",
"instanceof",
"self",
")",
"{",
"$",
"arr",
"=",
"$",
"arr",
"->",
"all",
"(",
")",
";",
"}",
"return",
"(",
"new",
"self",
"(",
"\\",
"array_intersect",
"(",
"$",
"this",... | Removes any values that are not present in the given array or collection. Returns a new Collection.
@param mixed[]|\CharlotteDunois\Collect\Collection $arr
@return \CharlotteDunois\Collect\Collection | [
"Removes",
"any",
"values",
"that",
"are",
"not",
"present",
"in",
"the",
"given",
"array",
"or",
"collection",
".",
"Returns",
"a",
"new",
"Collection",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L374-L380 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.last | function last(callable $closure = null) {
if($closure === null) {
if(empty($this->data)) {
return null;
}
$keys = \array_keys($this->data);
return $this->data[$keys[(\count($keys) - 1)]];
}
$data = null;
foreach($this->data as $key => $val) {
$feed = $closure($val, $key);
if($feed) {
$data = $val;
}
}
return $data;
} | php | function last(callable $closure = null) {
if($closure === null) {
if(empty($this->data)) {
return null;
}
$keys = \array_keys($this->data);
return $this->data[$keys[(\count($keys) - 1)]];
}
$data = null;
foreach($this->data as $key => $val) {
$feed = $closure($val, $key);
if($feed) {
$data = $val;
}
}
return $data;
} | [
"function",
"last",
"(",
"callable",
"$",
"closure",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"closure",
"===",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"data",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"keys",
"=",
"\\... | Returns the last element in the collection that passes a given truth test.
@param callable|null $closure Callback specification: `function ($value, $key): bool`
@return mixed|null | [
"Returns",
"the",
"last",
"element",
"in",
"the",
"collection",
"that",
"passes",
"a",
"given",
"truth",
"test",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L395-L414 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.map | function map(callable $closure) {
$keys = \array_keys($this->data);
$items = \array_map($closure, $this->data, $keys);
return (new self(\array_combine($keys, $items)));
} | php | function map(callable $closure) {
$keys = \array_keys($this->data);
$items = \array_map($closure, $this->data, $keys);
return (new self(\array_combine($keys, $items)));
} | [
"function",
"map",
"(",
"callable",
"$",
"closure",
")",
"{",
"$",
"keys",
"=",
"\\",
"array_keys",
"(",
"$",
"this",
"->",
"data",
")",
";",
"$",
"items",
"=",
"\\",
"array_map",
"(",
"$",
"closure",
",",
"$",
"this",
"->",
"data",
",",
"$",
"ke... | Iterates through the collection and passes each value to the given callback. The callback is free to modify the item and return it, thus forming a new collection of modified items.
@param callable|null $closure Callback specification: `function ($value, $key): mixed`
@return \CharlotteDunois\Collect\Collection | [
"Iterates",
"through",
"the",
"collection",
"and",
"passes",
"each",
"value",
"to",
"the",
"given",
"callback",
".",
"The",
"callback",
"is",
"free",
"to",
"modify",
"the",
"item",
"and",
"return",
"it",
"thus",
"forming",
"a",
"new",
"collection",
"of",
"... | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L421-L426 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.max | function max($key = null) {
if($key !== null) {
$data = \array_column($this->data, $key);
} else {
$data = $this->data;
}
return \max($data);
} | php | function max($key = null) {
if($key !== null) {
$data = \array_column($this->data, $key);
} else {
$data = $this->data;
}
return \max($data);
} | [
"function",
"max",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"null",
")",
"{",
"$",
"data",
"=",
"\\",
"array_column",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"key",
")",
";",
"}",
"else",
"{",
"$",
"data",
"=",
... | Return the maximum value of a given key.
@param mixed|null $key
@return int | [
"Return",
"the",
"maximum",
"value",
"of",
"a",
"given",
"key",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L433-L441 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.min | function min($key = null) {
if($key !== null) {
$data = \array_column($this->data, $key);
} else {
$data = $this->data;
}
return \min($data);
} | php | function min($key = null) {
if($key !== null) {
$data = \array_column($this->data, $key);
} else {
$data = $this->data;
}
return \min($data);
} | [
"function",
"min",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
"!==",
"null",
")",
"{",
"$",
"data",
"=",
"\\",
"array_column",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"key",
")",
";",
"}",
"else",
"{",
"$",
"data",
"=",
... | Return the minimum value of a given key.
@param mixed|null $key
@return int | [
"Return",
"the",
"minimum",
"value",
"of",
"a",
"given",
"key",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L448-L456 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.merge | function merge(\CharlotteDunois\Collect\Collection $collection) {
return (new self(\array_merge($this->data, $collection->all())));
} | php | function merge(\CharlotteDunois\Collect\Collection $collection) {
return (new self(\array_merge($this->data, $collection->all())));
} | [
"function",
"merge",
"(",
"\\",
"CharlotteDunois",
"\\",
"Collect",
"\\",
"Collection",
"$",
"collection",
")",
"{",
"return",
"(",
"new",
"self",
"(",
"\\",
"array_merge",
"(",
"$",
"this",
"->",
"data",
",",
"$",
"collection",
"->",
"all",
"(",
")",
... | Merges the given collection into this collection, resulting in a new collection.
Any string key in the given collection matching a string key in this collection will overwrite the value in this collection.
@param \CharlotteDunois\Collect\Collection $collection
@return \CharlotteDunois\Collect\Collection | [
"Merges",
"the",
"given",
"collection",
"into",
"this",
"collection",
"resulting",
"in",
"a",
"new",
"collection",
".",
"Any",
"string",
"key",
"in",
"the",
"given",
"collection",
"matching",
"a",
"string",
"key",
"in",
"this",
"collection",
"will",
"overwrite... | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L464-L466 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.nth | function nth(int $nth, int $offset = 0) {
if($nth <= 0) {
throw new \InvalidArgumentException('nth must be a non-zero positive integer');
}
$new = array();
$size = \count($this->data);
for($i = $offset; $i < $size; $i += $nth) {
$new[] = $this->data[$i];
}
return (new self($new));
} | php | function nth(int $nth, int $offset = 0) {
if($nth <= 0) {
throw new \InvalidArgumentException('nth must be a non-zero positive integer');
}
$new = array();
$size = \count($this->data);
for($i = $offset; $i < $size; $i += $nth) {
$new[] = $this->data[$i];
}
return (new self($new));
} | [
"function",
"nth",
"(",
"int",
"$",
"nth",
",",
"int",
"$",
"offset",
"=",
"0",
")",
"{",
"if",
"(",
"$",
"nth",
"<=",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'nth must be a non-zero positive integer'",
")",
";",
"}",
"$",
... | Creates a new collection consisting of every n-th element.
@param int $nth
@param int $offset
@return \CharlotteDunois\Collect\Collection
@throws \InvalidArgumentException | [
"Creates",
"a",
"new",
"collection",
"consisting",
"of",
"every",
"n",
"-",
"th",
"element",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L475-L488 | train |
CharlotteDunois/Collection | src/Collection.php | Collection.only | function only(array $keys) {
$new = array();
foreach($this->data as $key => $val) {
if(\in_array($key, $keys, true)) {
$new[$key] = $val;
}
}
return (new self($new));
} | php | function only(array $keys) {
$new = array();
foreach($this->data as $key => $val) {
if(\in_array($key, $keys, true)) {
$new[$key] = $val;
}
}
return (new self($new));
} | [
"function",
"only",
"(",
"array",
"$",
"keys",
")",
"{",
"$",
"new",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"if",
"(",
"\\",
"in_array",
"(",
"$",
"key",
",",
"$",... | Returns the items in the collection with the specified keys. Returns a new Collection.
@param mixed[] $keys
@return \CharlotteDunois\Collect\Collection | [
"Returns",
"the",
"items",
"in",
"the",
"collection",
"with",
"the",
"specified",
"keys",
".",
"Returns",
"a",
"new",
"Collection",
"."
] | 3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce | https://github.com/CharlotteDunois/Collection/blob/3b27d5fbd947f7f25a9d4d25d517f895aa3b1bce/src/Collection.php#L495-L504 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.