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
koolkode/async
src/DNS/Message.php
Message.encodeHeader
protected function encodeHeader(): string { return \pack('n*', ...[ $this->id, $this->getFlags(), \count($this->questions), \count($this->answers), $this->authorityCount, $this->additionalCount ]); }
php
protected function encodeHeader(): string { return \pack('n*', ...[ $this->id, $this->getFlags(), \count($this->questions), \count($this->answers), $this->authorityCount, $this->additionalCount ]); }
[ "protected", "function", "encodeHeader", "(", ")", ":", "string", "{", "return", "\\", "pack", "(", "'n*'", ",", "...", "[", "$", "this", "->", "id", ",", "$", "this", "->", "getFlags", "(", ")", ",", "\\", "count", "(", "$", "this", "->", "questio...
Encode the message header into it's binary form.
[ "Encode", "the", "message", "header", "into", "it", "s", "binary", "form", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/DNS/Message.php#L284-L294
train
koolkode/async
src/DNS/Message.php
Message.encodeLabel
protected function encodeLabel(string $label): string { $encoded = ''; foreach (\explode('.', $label) as $part) { $encoded .= \chr(\strlen($part)) . $part; } return $encoded . "\x00"; }
php
protected function encodeLabel(string $label): string { $encoded = ''; foreach (\explode('.', $label) as $part) { $encoded .= \chr(\strlen($part)) . $part; } return $encoded . "\x00"; }
[ "protected", "function", "encodeLabel", "(", "string", "$", "label", ")", ":", "string", "{", "$", "encoded", "=", "''", ";", "foreach", "(", "\\", "explode", "(", "'.'", ",", "$", "label", ")", "as", "$", "part", ")", "{", "$", "encoded", ".=", "\...
Encode a DNS label into it's binary form.
[ "Encode", "a", "DNS", "label", "into", "it", "s", "binary", "form", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/DNS/Message.php#L299-L308
train
koolkode/async
src/DNS/Message.php
Message.encodeQuestion
protected function encodeQuestion(array $question): string { $encoded = $this->encodeLabel($question['host']); $encoded .= \pack('nn', $question['type'], $question['class']); return $encoded; }
php
protected function encodeQuestion(array $question): string { $encoded = $this->encodeLabel($question['host']); $encoded .= \pack('nn', $question['type'], $question['class']); return $encoded; }
[ "protected", "function", "encodeQuestion", "(", "array", "$", "question", ")", ":", "string", "{", "$", "encoded", "=", "$", "this", "->", "encodeLabel", "(", "$", "question", "[", "'host'", "]", ")", ";", "$", "encoded", ".=", "\\", "pack", "(", "'nn'...
Encode a question record.
[ "Encode", "a", "question", "record", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/DNS/Message.php#L313-L319
train
koolkode/async
src/DNS/Message.php
Message.encodeAnswer
protected function encodeAnswer(array $answer): string { $encoded = $this->encodeLabel($answer['host']); switch ($answer['type']) { case self::TYPE_A: case self::TYPE_AAAA: $data = \inet_pton($answer['data']); break; case self::TYPE_CNAME: $data = $this->encodeLabel($answer['data']); break; default: $data = $answer['data']; } $encoded .= \pack('nnNn', $answer['type'], self::CLASS_IN, $answer['ttl'], \strlen($data)); $encoded .= $data; return $encoded; }
php
protected function encodeAnswer(array $answer): string { $encoded = $this->encodeLabel($answer['host']); switch ($answer['type']) { case self::TYPE_A: case self::TYPE_AAAA: $data = \inet_pton($answer['data']); break; case self::TYPE_CNAME: $data = $this->encodeLabel($answer['data']); break; default: $data = $answer['data']; } $encoded .= \pack('nnNn', $answer['type'], self::CLASS_IN, $answer['ttl'], \strlen($data)); $encoded .= $data; return $encoded; }
[ "protected", "function", "encodeAnswer", "(", "array", "$", "answer", ")", ":", "string", "{", "$", "encoded", "=", "$", "this", "->", "encodeLabel", "(", "$", "answer", "[", "'host'", "]", ")", ";", "switch", "(", "$", "answer", "[", "'type'", "]", ...
Encode an answer record.
[ "Encode", "an", "answer", "record", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/DNS/Message.php#L324-L344
train
silvercommerce/shoppingcart
src/control/ShoppingCart.php
ShoppingCart.emptycart
public function emptycart() { ShoppingCartFactory::create()->delete(); $form = $this->CartForm(); $form->sessionMessage(_t( "ShoppingCart.EmptiedCart", "Shopping cart emptied" )); return $this->redirectBack(); }
php
public function emptycart() { ShoppingCartFactory::create()->delete(); $form = $this->CartForm(); $form->sessionMessage(_t( "ShoppingCart.EmptiedCart", "Shopping cart emptied" )); return $this->redirectBack(); }
[ "public", "function", "emptycart", "(", ")", "{", "ShoppingCartFactory", "::", "create", "(", ")", "->", "delete", "(", ")", ";", "$", "form", "=", "$", "this", "->", "CartForm", "(", ")", ";", "$", "form", "->", "sessionMessage", "(", "_t", "(", "\"...
Action that will clear shopping cart and associated items
[ "Action", "that", "will", "clear", "shopping", "cart", "and", "associated", "items" ]
11e1296c095f9c2d35395d8d3b9d30e8a9db745b
https://github.com/silvercommerce/shoppingcart/blob/11e1296c095f9c2d35395d8d3b9d30e8a9db745b/src/control/ShoppingCart.php#L268-L279
train
silvercommerce/shoppingcart
src/control/ShoppingCart.php
ShoppingCart.checkout
public function checkout() { if (!class_exists($this->config()->checkout_class)) { return $this->httpError(404); } $checkout = Injector::inst() ->get($this->config()->checkout_class); $checkout->setEstimate($this->dataRecord); $this->extend("onBeforeCheckout"); $this->redirect($checkout->Link()); }
php
public function checkout() { if (!class_exists($this->config()->checkout_class)) { return $this->httpError(404); } $checkout = Injector::inst() ->get($this->config()->checkout_class); $checkout->setEstimate($this->dataRecord); $this->extend("onBeforeCheckout"); $this->redirect($checkout->Link()); }
[ "public", "function", "checkout", "(", ")", "{", "if", "(", "!", "class_exists", "(", "$", "this", "->", "config", "(", ")", "->", "checkout_class", ")", ")", "{", "return", "$", "this", "->", "httpError", "(", "404", ")", ";", "}", "$", "checkout", ...
Setup the checkout and redirect to it @return Redirect
[ "Setup", "the", "checkout", "and", "redirect", "to", "it" ]
11e1296c095f9c2d35395d8d3b9d30e8a9db745b
https://github.com/silvercommerce/shoppingcart/blob/11e1296c095f9c2d35395d8d3b9d30e8a9db745b/src/control/ShoppingCart.php#L320-L333
train
meritoo/common-bundle
src/Service/DateService.php
DateService.getFormat
public function getFormat(string $dateLength): string { // Oops, unknown length of date if (false === (new DateLength())->isCorrectType($dateLength)) { throw UnknownDateLengthException::createException($dateLength); } $format = ''; switch ($dateLength) { case DateLength::DATE: $format = $this->dateFormat; break; case DateLength::DATETIME: $format = $this->dateTimeFormat; break; case DateLength::TIME: $format = $this->timeFormat; break; } return $format; }
php
public function getFormat(string $dateLength): string { // Oops, unknown length of date if (false === (new DateLength())->isCorrectType($dateLength)) { throw UnknownDateLengthException::createException($dateLength); } $format = ''; switch ($dateLength) { case DateLength::DATE: $format = $this->dateFormat; break; case DateLength::DATETIME: $format = $this->dateTimeFormat; break; case DateLength::TIME: $format = $this->timeFormat; break; } return $format; }
[ "public", "function", "getFormat", "(", "string", "$", "dateLength", ")", ":", "string", "{", "// Oops, unknown length of date", "if", "(", "false", "===", "(", "new", "DateLength", "(", ")", ")", "->", "isCorrectType", "(", "$", "dateLength", ")", ")", "{",...
Returns format of date according to given length of date @param string $dateLength Type of date length. One of the DateLength's class constants. @throws UnknownDateLengthException @return string
[ "Returns", "format", "of", "date", "according", "to", "given", "length", "of", "date" ]
560c3a6c14fce2e17208261b8c606f6208f44e23
https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Service/DateService.php#L67-L92
train
meritoo/common-bundle
src/Service/DateService.php
DateService.formatDate
public function formatDate(\DateTimeInterface $dateTime, string $dateLength): string { $format = $this->getFormat($dateLength); return $dateTime->format($format); }
php
public function formatDate(\DateTimeInterface $dateTime, string $dateLength): string { $format = $this->getFormat($dateLength); return $dateTime->format($format); }
[ "public", "function", "formatDate", "(", "\\", "DateTimeInterface", "$", "dateTime", ",", "string", "$", "dateLength", ")", ":", "string", "{", "$", "format", "=", "$", "this", "->", "getFormat", "(", "$", "dateLength", ")", ";", "return", "$", "dateTime",...
Returns date formatted according to given length of date @param \DateTimeInterface $dateTime The date to format @param string $dateLength Type of date length. One of the DateLength's class constants. @return string
[ "Returns", "date", "formatted", "according", "to", "given", "length", "of", "date" ]
560c3a6c14fce2e17208261b8c606f6208f44e23
https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Service/DateService.php#L101-L106
train
songshenzong/api
src/Traits/Success.php
Success.success
public function success(int $statusCode, string $message, $data = null): JsonResponse { $this->setStatusCode($statusCode); $this->setMessage($message); $this->setData($data); $content['message'] = $this->getMessage(); if (null !== $this->getCode()) { $content['code'] = $this->getCode(); } $content['status_code'] = $this->getStatusCode(); if (null !== $this->getData() && $this->getErrors() !== $this->getData()) { $content['data'] = $this->getData(); } if (null !== $this->getErrors()) { $content['errors'] = $this->getErrors(); } $content += $this->Hypermedia; return new JsonResponse($content, $this->getHttpStatusCode() ?: $this->getStatusCode()); }
php
public function success(int $statusCode, string $message, $data = null): JsonResponse { $this->setStatusCode($statusCode); $this->setMessage($message); $this->setData($data); $content['message'] = $this->getMessage(); if (null !== $this->getCode()) { $content['code'] = $this->getCode(); } $content['status_code'] = $this->getStatusCode(); if (null !== $this->getData() && $this->getErrors() !== $this->getData()) { $content['data'] = $this->getData(); } if (null !== $this->getErrors()) { $content['errors'] = $this->getErrors(); } $content += $this->Hypermedia; return new JsonResponse($content, $this->getHttpStatusCode() ?: $this->getStatusCode()); }
[ "public", "function", "success", "(", "int", "$", "statusCode", ",", "string", "$", "message", ",", "$", "data", "=", "null", ")", ":", "JsonResponse", "{", "$", "this", "->", "setStatusCode", "(", "$", "statusCode", ")", ";", "$", "this", "->", "setMe...
Public Success Method. @param int $statusCode @param string $message @param null $data @return JsonResponse @throws \Songshenzong\Api\Exception\ApiException
[ "Public", "Success", "Method", "." ]
b81751be0fe64eb9e6c775957aa2e8f8c6c2444e
https://github.com/songshenzong/api/blob/b81751be0fe64eb9e6c775957aa2e8f8c6c2444e/src/Traits/Success.php#L52-L84
train
Roave/RoaveDeveloperTools
src/Roave/DeveloperTools/Renderer/Util/HierarchyBuilder.php
HierarchyBuilder.explodeChildren
private function explodeChildren($id, array $childrenMap) { if (! isset($childrenMap[$id])) { return []; } // Indexing items by their value $indexed = []; foreach ($childrenMap[$id] as $childName) { $indexed[$childName] = $childName; } return array_map( function ($childId) use ($childrenMap) { return $this->explodeChildren($childId, $childrenMap); }, $indexed ); }
php
private function explodeChildren($id, array $childrenMap) { if (! isset($childrenMap[$id])) { return []; } // Indexing items by their value $indexed = []; foreach ($childrenMap[$id] as $childName) { $indexed[$childName] = $childName; } return array_map( function ($childId) use ($childrenMap) { return $this->explodeChildren($childId, $childrenMap); }, $indexed ); }
[ "private", "function", "explodeChildren", "(", "$", "id", ",", "array", "$", "childrenMap", ")", "{", "if", "(", "!", "isset", "(", "$", "childrenMap", "[", "$", "id", "]", ")", ")", "{", "return", "[", "]", ";", "}", "// Indexing items by their value", ...
Retrieves all children of a given element, recursively Must be given a childrenMap for performance reasons @param string $id @param array $childrenMap @return array
[ "Retrieves", "all", "children", "of", "a", "given", "element", "recursively", "Must", "be", "given", "a", "childrenMap", "for", "performance", "reasons" ]
424285eb861c9df7891ce7c6e66a21756eecd81c
https://github.com/Roave/RoaveDeveloperTools/blob/424285eb861c9df7891ce7c6e66a21756eecd81c/src/Roave/DeveloperTools/Renderer/Util/HierarchyBuilder.php#L111-L130
train
kassko/data-mapper
src/Hydrator/Hydrator.php
Hydrator.doHydrate
protected function doHydrate(array $data, $object) { $previousHydrationContext = $this->currentHydrationContext; $this->currentHydrationContext = new CurrentHydrationContext($data, $object); foreach ($this->metadata->getMappedFieldNames() as $mappedFieldName) { $defaultValue = $this->metadata->getFieldDefaultValue($mappedFieldName); if (null !== $defaultValue) { $this->resolveValue($defaultValue, $object); $this->memberAccessStrategy->setValue($defaultValue, $object, $mappedFieldName); } } if (! $this->metadata->hasCustomHydrator()) { $this->executeMethods($object, $this->metadata->getPreHydrateListeners()); foreach ($data as $originalFieldName => $value) { $mappedFieldName = $this->metadata->getMappedFieldName($originalFieldName); if (null === $mappedFieldName) { //It's possible that a raw field name has no corresponding field name //because a raw field can be a value object part. continue; } if (! $this->metadata->hasSource($mappedFieldName)) { //Classical hydration. $this->walkHydration($mappedFieldName, $object, $value, $data); } } } else { list($customHydratorClass, $customHydrateMethod) = $this->metadata->getCustomHydratorInfo(); $this->executeMethod($object, new ClassMetadata\Model\Method($customHydratorClass, $customHydrateMethod, [$data, $object])); } //DataSources hydration. foreach ($this->metadata->getFieldsWithDataSources() as $mappedFieldName) { if ($this->metadata->hasDataSource($mappedFieldName)) {//<= Is this test usefull ? $this->walkHydrationByDataSource($mappedFieldName, $object, false); } } //Providers hydration. foreach ($this->metadata->getFieldsWithProviders() as $mappedFieldName) { if ($this->metadata->hasProvider($mappedFieldName)) {//<= Is this test usefull ? $this->walkHydrationByProvider($mappedFieldName, $object, false); } } //Value objects hydration. foreach ($this->metadata->getFieldsWithValueObjects() as $mappedFieldName) { $this->walkValueObjectHydration($mappedFieldName, $object, $data); } $this->executeMethods($object, $this->metadata->getPostHydrateListeners()); $this->currentHydrationContext = $previousHydrationContext; return $object; }
php
protected function doHydrate(array $data, $object) { $previousHydrationContext = $this->currentHydrationContext; $this->currentHydrationContext = new CurrentHydrationContext($data, $object); foreach ($this->metadata->getMappedFieldNames() as $mappedFieldName) { $defaultValue = $this->metadata->getFieldDefaultValue($mappedFieldName); if (null !== $defaultValue) { $this->resolveValue($defaultValue, $object); $this->memberAccessStrategy->setValue($defaultValue, $object, $mappedFieldName); } } if (! $this->metadata->hasCustomHydrator()) { $this->executeMethods($object, $this->metadata->getPreHydrateListeners()); foreach ($data as $originalFieldName => $value) { $mappedFieldName = $this->metadata->getMappedFieldName($originalFieldName); if (null === $mappedFieldName) { //It's possible that a raw field name has no corresponding field name //because a raw field can be a value object part. continue; } if (! $this->metadata->hasSource($mappedFieldName)) { //Classical hydration. $this->walkHydration($mappedFieldName, $object, $value, $data); } } } else { list($customHydratorClass, $customHydrateMethod) = $this->metadata->getCustomHydratorInfo(); $this->executeMethod($object, new ClassMetadata\Model\Method($customHydratorClass, $customHydrateMethod, [$data, $object])); } //DataSources hydration. foreach ($this->metadata->getFieldsWithDataSources() as $mappedFieldName) { if ($this->metadata->hasDataSource($mappedFieldName)) {//<= Is this test usefull ? $this->walkHydrationByDataSource($mappedFieldName, $object, false); } } //Providers hydration. foreach ($this->metadata->getFieldsWithProviders() as $mappedFieldName) { if ($this->metadata->hasProvider($mappedFieldName)) {//<= Is this test usefull ? $this->walkHydrationByProvider($mappedFieldName, $object, false); } } //Value objects hydration. foreach ($this->metadata->getFieldsWithValueObjects() as $mappedFieldName) { $this->walkValueObjectHydration($mappedFieldName, $object, $data); } $this->executeMethods($object, $this->metadata->getPostHydrateListeners()); $this->currentHydrationContext = $previousHydrationContext; return $object; }
[ "protected", "function", "doHydrate", "(", "array", "$", "data", ",", "$", "object", ")", "{", "$", "previousHydrationContext", "=", "$", "this", "->", "currentHydrationContext", ";", "$", "this", "->", "currentHydrationContext", "=", "new", "CurrentHydrationConte...
Hydrate an object from data. @param array $data @param object $object @return object
[ "Hydrate", "an", "object", "from", "data", "." ]
653b3d735977d95f6eadb3334ab8787db1dca275
https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/Hydrator/Hydrator.php#L271-L334
train
kassko/data-mapper
src/Hydrator/Hydrator.php
Hydrator.getCurrentConfigVariableByName
public function getCurrentConfigVariableByName($variableKey) { if (! isset($this->currentConfigVariables[$variableKey])) { throw new ObjectMappingException( sprintf( 'The current config variables do not contains key "%s". Availables keys are "[%s]".', $variableKey, implode(',', array_keys($this->currentConfigVariables)) ) ); } return $this->currentConfigVariables[$variableKey]; }
php
public function getCurrentConfigVariableByName($variableKey) { if (! isset($this->currentConfigVariables[$variableKey])) { throw new ObjectMappingException( sprintf( 'The current config variables do not contains key "%s". Availables keys are "[%s]".', $variableKey, implode(',', array_keys($this->currentConfigVariables)) ) ); } return $this->currentConfigVariables[$variableKey]; }
[ "public", "function", "getCurrentConfigVariableByName", "(", "$", "variableKey", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "currentConfigVariables", "[", "$", "variableKey", "]", ")", ")", "{", "throw", "new", "ObjectMappingException", "(", "s...
Gets all the variables used in a object mapping configuration. @return array
[ "Gets", "all", "the", "variables", "used", "in", "a", "object", "mapping", "configuration", "." ]
653b3d735977d95f6eadb3334ab8787db1dca275
https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/Hydrator/Hydrator.php#L799-L812
train
LaraChimp/pine-annotations
src/PineAnnotationsServiceProvider.php
PineAnnotationsServiceProvider.registerReader
protected function registerReader() { // Give a Cached Reader when our // reader class needs // a ReaderContract. $this->app->when(AnnotationsReader::class) ->needs(Reader::class) ->give(function () { return $this->createAndReturnCachedReader(); }); }
php
protected function registerReader() { // Give a Cached Reader when our // reader class needs // a ReaderContract. $this->app->when(AnnotationsReader::class) ->needs(Reader::class) ->give(function () { return $this->createAndReturnCachedReader(); }); }
[ "protected", "function", "registerReader", "(", ")", "{", "// Give a Cached Reader when our", "// reader class needs", "// a ReaderContract.", "$", "this", "->", "app", "->", "when", "(", "AnnotationsReader", "::", "class", ")", "->", "needs", "(", "Reader", "::", "...
Registers the Annotations reader. @return void
[ "Registers", "the", "Annotations", "reader", "." ]
f7d0cc77a1e24813b541acb98be8de34175da6e6
https://github.com/LaraChimp/pine-annotations/blob/f7d0cc77a1e24813b541acb98be8de34175da6e6/src/PineAnnotationsServiceProvider.php#L52-L62
train
LaraChimp/pine-annotations
src/PineAnnotationsServiceProvider.php
PineAnnotationsServiceProvider.addAnnotationsToRegistry
protected function addAnnotationsToRegistry() { // Creates annotation Reader. $reader = $this->app->make(AnnotationsReader::class); // Register files autoload. $reader->addFilesToRegistry(config('pine-annotations.autoload_files')); // Register namespaces autoload. $reader->addNamespacesToRegistry(config('pine-annotations.autoload_namespaces')); }
php
protected function addAnnotationsToRegistry() { // Creates annotation Reader. $reader = $this->app->make(AnnotationsReader::class); // Register files autoload. $reader->addFilesToRegistry(config('pine-annotations.autoload_files')); // Register namespaces autoload. $reader->addNamespacesToRegistry(config('pine-annotations.autoload_namespaces')); }
[ "protected", "function", "addAnnotationsToRegistry", "(", ")", "{", "// Creates annotation Reader.", "$", "reader", "=", "$", "this", "->", "app", "->", "make", "(", "AnnotationsReader", "::", "class", ")", ";", "// Register files autoload.", "$", "reader", "->", ...
Add files and namespaces to the annotations registry. @return void
[ "Add", "files", "and", "namespaces", "to", "the", "annotations", "registry", "." ]
f7d0cc77a1e24813b541acb98be8de34175da6e6
https://github.com/LaraChimp/pine-annotations/blob/f7d0cc77a1e24813b541acb98be8de34175da6e6/src/PineAnnotationsServiceProvider.php#L100-L110
train
MichaelPavlista/palette
src/Utils/Compare.php
Compare.isDimensionsEqual
public function isDimensionsEqual() { if($this->image1->getImageWidth() !== $this->image2->getImageWidth() || $this->image1->getImageHeight() !== $this->image2->getImageHeight()) { return FALSE; } return TRUE; }
php
public function isDimensionsEqual() { if($this->image1->getImageWidth() !== $this->image2->getImageWidth() || $this->image1->getImageHeight() !== $this->image2->getImageHeight()) { return FALSE; } return TRUE; }
[ "public", "function", "isDimensionsEqual", "(", ")", "{", "if", "(", "$", "this", "->", "image1", "->", "getImageWidth", "(", ")", "!==", "$", "this", "->", "image2", "->", "getImageWidth", "(", ")", "||", "$", "this", "->", "image1", "->", "getImageHeig...
Check if dimensions of images is equal. @return bool
[ "Check", "if", "dimensions", "of", "images", "is", "equal", "." ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Utils/Compare.php#L73-L82
train
MichaelPavlista/palette
src/Utils/Compare.php
Compare.isEqual
public function isEqual() { // CHECK IMAGES DIMENSIONS if(!$this->isDimensionsEqual()) { return FALSE; } $compare = $this->image1->compareImages($this->image2, Imagick::METRIC_MEANSQUAREERROR); // IMAGE IS EXACTLY THE SAME if($compare === TRUE) { return TRUE; } // IMAGE IS IN TOLERABLE RANGE elseif($compare) { if($compare[1] < $this->tolerance) { return TRUE; } } return FALSE; }
php
public function isEqual() { // CHECK IMAGES DIMENSIONS if(!$this->isDimensionsEqual()) { return FALSE; } $compare = $this->image1->compareImages($this->image2, Imagick::METRIC_MEANSQUAREERROR); // IMAGE IS EXACTLY THE SAME if($compare === TRUE) { return TRUE; } // IMAGE IS IN TOLERABLE RANGE elseif($compare) { if($compare[1] < $this->tolerance) { return TRUE; } } return FALSE; }
[ "public", "function", "isEqual", "(", ")", "{", "// CHECK IMAGES DIMENSIONS", "if", "(", "!", "$", "this", "->", "isDimensionsEqual", "(", ")", ")", "{", "return", "FALSE", ";", "}", "$", "compare", "=", "$", "this", "->", "image1", "->", "compareImages", ...
Check if images is exactly the same. @return bool
[ "Check", "if", "images", "is", "exactly", "the", "same", "." ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Utils/Compare.php#L89-L114
train
threesquared/laravel-paymill
src/Threesquared/LaravelPaymill/Paymill.php
Paymill.createModel
public function createModel($class, $id) { $this->model = new $class(); if ($id) { $this->model->setId($id); } return $this; }
php
public function createModel($class, $id) { $this->model = new $class(); if ($id) { $this->model->setId($id); } return $this; }
[ "public", "function", "createModel", "(", "$", "class", ",", "$", "id", ")", "{", "$", "this", "->", "model", "=", "new", "$", "class", "(", ")", ";", "if", "(", "$", "id", ")", "{", "$", "this", "->", "model", "->", "setId", "(", "$", "id", ...
Create the Paymill model @param string $class @param string $id @return mixed
[ "Create", "the", "Paymill", "model" ]
876762bc9ca9d0185219548e8492f3e48b84b4a3
https://github.com/threesquared/laravel-paymill/blob/876762bc9ca9d0185219548e8492f3e48b84b4a3/src/Threesquared/LaravelPaymill/Paymill.php#L87-L96
train
Speelpenning-nl/laravel-authentication
src/Http/Controllers/Administration/UserController.php
UserController.index
public function index(Request $request, UserRepository $users) { return view('authentication::user.index') ->with('users', $users->query($request->get('q'))); }
php
public function index(Request $request, UserRepository $users) { return view('authentication::user.index') ->with('users', $users->query($request->get('q'))); }
[ "public", "function", "index", "(", "Request", "$", "request", ",", "UserRepository", "$", "users", ")", "{", "return", "view", "(", "'authentication::user.index'", ")", "->", "with", "(", "'users'", ",", "$", "users", "->", "query", "(", "$", "request", "...
Shows the user index. @param Request $request @param UserRepository $users @return View
[ "Shows", "the", "user", "index", "." ]
44671afa8d654a9c6281cce13353d95126478d8b
https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Http/Controllers/Administration/UserController.php#L33-L37
train
dionsnoeijen/sexy-field
src/Command/InstallDirectoryCommand.php
InstallDirectoryCommand.getAllYamls
private static function getAllYamls(string $directory): \Generator { /** @var \SplFileInfo $file */ foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory)) as $file) { if ($file->isFile() && $file->getExtension() === 'yml') { $fileName = $file->getPathname(); yield $fileName => Yaml::parse(file_get_contents($fileName)); } } }
php
private static function getAllYamls(string $directory): \Generator { /** @var \SplFileInfo $file */ foreach (new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($directory)) as $file) { if ($file->isFile() && $file->getExtension() === 'yml') { $fileName = $file->getPathname(); yield $fileName => Yaml::parse(file_get_contents($fileName)); } } }
[ "private", "static", "function", "getAllYamls", "(", "string", "$", "directory", ")", ":", "\\", "Generator", "{", "/** @var \\SplFileInfo $file */", "foreach", "(", "new", "\\", "RecursiveIteratorIterator", "(", "new", "\\", "RecursiveDirectoryIterator", "(", "$", ...
Get the contents of all yaml files in a directory, recursively. @param string $directory @return \Generator
[ "Get", "the", "contents", "of", "all", "yaml", "files", "in", "a", "directory", "recursively", "." ]
68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033
https://github.com/dionsnoeijen/sexy-field/blob/68cb7bbbda641f5df0b5f11c17ca6ed0e18d6033/src/Command/InstallDirectoryCommand.php#L282-L291
train
kassko/data-mapper
src/Expression/ExpressionContext.php
ExpressionContext.addVariable
public function addVariable($key, $value) { if (is_null($key) || ! is_string($key)) { throw new RuntimeException(sprintf('The key where to save your variable in the expression context is invalid. Got "%s".', $key)); } $this->variables[$key] = $value; }
php
public function addVariable($key, $value) { if (is_null($key) || ! is_string($key)) { throw new RuntimeException(sprintf('The key where to save your variable in the expression context is invalid. Got "%s".', $key)); } $this->variables[$key] = $value; }
[ "public", "function", "addVariable", "(", "$", "key", ",", "$", "value", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", "||", "!", "is_string", "(", "$", "key", ")", ")", "{", "throw", "new", "RuntimeException", "(", "sprintf", "(", "'The key ...
Add a variable in the context. @param string $key A key to store the variable. @param mixed $value The variable to store.
[ "Add", "a", "variable", "in", "the", "context", "." ]
653b3d735977d95f6eadb3334ab8787db1dca275
https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/Expression/ExpressionContext.php#L38-L45
train
MichaelPavlista/palette
src/Generator/Server.php
Server.serverResponse
public function serverResponse() { if(!empty($_GET['imageQuery'])) { $picture = $this->loadPicture($_GET['imageQuery']); $savePath = $this->getPath($picture); $picture->save($savePath); if($savePath !== $this->getPath($picture)) { throw new Exception('Picture effect is changing its own arguments on effect apply'); } $picture->output(); } if(!empty($_POST['regenerate'])) { $picture = $this->loadPicture($_POST['regenerate']); $picture->save($this->getPath($picture)); } }
php
public function serverResponse() { if(!empty($_GET['imageQuery'])) { $picture = $this->loadPicture($_GET['imageQuery']); $savePath = $this->getPath($picture); $picture->save($savePath); if($savePath !== $this->getPath($picture)) { throw new Exception('Picture effect is changing its own arguments on effect apply'); } $picture->output(); } if(!empty($_POST['regenerate'])) { $picture = $this->loadPicture($_POST['regenerate']); $picture->save($this->getPath($picture)); } }
[ "public", "function", "serverResponse", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "_GET", "[", "'imageQuery'", "]", ")", ")", "{", "$", "picture", "=", "$", "this", "->", "loadPicture", "(", "$", "_GET", "[", "'imageQuery'", "]", ")", ";", ...
Execute server generator backend. @return void @throws Exception
[ "Execute", "server", "generator", "backend", "." ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Generator/Server.php#L99-L121
train
MichaelPavlista/palette
src/Generator/Server.php
Server.requestWithoutWaiting
function requestWithoutWaiting($url, array $params = array()) { $post = array(); foreach($params as $index => $val) { $post[] = $index . '=' . urlencode($val); } $post = implode('&', $post); $request = parse_url($url); // SUPPORT FOR RELATIVE GENERATOR URL if(!isset($request['host'])) { $request['host'] = $_SERVER['HTTP_HOST']; } if(!isset($request['port'])) { $request['port'] = $_SERVER['SERVER_PORT']; } // SEND REQUEST WITHOUT WAITING $protocol = isset($_SERVER['HTTPS']) ? 'ssl://' : ''; $safePort = isset($_SERVER['HTTPS']) ? 443 : 80; // HTTPS WORKAROUND if($request['port'] == 80 && $safePort == 443) { $request['port'] = $safePort; } $fp = fsockopen($protocol . $request['host'], $request['port'], $errNo, $errStr, 60); $command = "POST " . $request['path'] . " HTTP/1.1\r\n"; $command .= "Host: " . $request['host'] . "\r\n"; $command .= "Content-Type: application/x-www-form-urlencoded\r\n"; $command .= "Content-Length: " . strlen($post) . "\r\n"; $command .= "Connection: Close\r\n\r\n"; if($post) { $command .= $post; } fwrite($fp, $command); fclose($fp); }
php
function requestWithoutWaiting($url, array $params = array()) { $post = array(); foreach($params as $index => $val) { $post[] = $index . '=' . urlencode($val); } $post = implode('&', $post); $request = parse_url($url); // SUPPORT FOR RELATIVE GENERATOR URL if(!isset($request['host'])) { $request['host'] = $_SERVER['HTTP_HOST']; } if(!isset($request['port'])) { $request['port'] = $_SERVER['SERVER_PORT']; } // SEND REQUEST WITHOUT WAITING $protocol = isset($_SERVER['HTTPS']) ? 'ssl://' : ''; $safePort = isset($_SERVER['HTTPS']) ? 443 : 80; // HTTPS WORKAROUND if($request['port'] == 80 && $safePort == 443) { $request['port'] = $safePort; } $fp = fsockopen($protocol . $request['host'], $request['port'], $errNo, $errStr, 60); $command = "POST " . $request['path'] . " HTTP/1.1\r\n"; $command .= "Host: " . $request['host'] . "\r\n"; $command .= "Content-Type: application/x-www-form-urlencoded\r\n"; $command .= "Content-Length: " . strlen($post) . "\r\n"; $command .= "Connection: Close\r\n\r\n"; if($post) { $command .= $post; } fwrite($fp, $command); fclose($fp); }
[ "function", "requestWithoutWaiting", "(", "$", "url", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "post", "=", "array", "(", ")", ";", "foreach", "(", "$", "params", "as", "$", "index", "=>", "$", "val", ")", "{", "$", "po...
Sends the POST request without waiting for a response. @param string $url @param array $params
[ "Sends", "the", "POST", "request", "without", "waiting", "for", "a", "response", "." ]
dfb8d0e1b98880932851233faa048e2bfc9abed5
https://github.com/MichaelPavlista/palette/blob/dfb8d0e1b98880932851233faa048e2bfc9abed5/src/Generator/Server.php#L129-L178
train
klermonte/zerg
src/Zerg/DataSet.php
DataSet.setValue
public function setValue($name, $value) { $child = & $this->data; foreach ($this->currentPath as $part) { if (isset($child[$part])) { $child = & $child[$part]; } else { $child[$part] = []; $child = & $child[$part]; } } $child[$name] = $value; }
php
public function setValue($name, $value) { $child = & $this->data; foreach ($this->currentPath as $part) { if (isset($child[$part])) { $child = & $child[$part]; } else { $child[$part] = []; $child = & $child[$part]; } } $child[$name] = $value; }
[ "public", "function", "setValue", "(", "$", "name", ",", "$", "value", ")", "{", "$", "child", "=", "&", "$", "this", "->", "data", ";", "foreach", "(", "$", "this", "->", "currentPath", "as", "$", "part", ")", "{", "if", "(", "isset", "(", "$", ...
Set a value in the current level. @param string|int $name The name of the value to add. @param string|int|array|null $value The value to add.
[ "Set", "a", "value", "in", "the", "current", "level", "." ]
c5d9c52cfade1fe9169e3cbae855b49a054f04ff
https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/DataSet.php#L78-L92
train
klermonte/zerg
src/Zerg/DataSet.php
DataSet.getValue
public function getValue($name) { $child = & $this->data; foreach ($this->currentPath as $part) { if (isset($child[$part])) { $child = & $child[$part]; } else { return null; } } return isset($child[$name]) ? $child[$name] : null; }
php
public function getValue($name) { $child = & $this->data; foreach ($this->currentPath as $part) { if (isset($child[$part])) { $child = & $child[$part]; } else { return null; } } return isset($child[$name]) ? $child[$name] : null; }
[ "public", "function", "getValue", "(", "$", "name", ")", "{", "$", "child", "=", "&", "$", "this", "->", "data", ";", "foreach", "(", "$", "this", "->", "currentPath", "as", "$", "part", ")", "{", "if", "(", "isset", "(", "$", "child", "[", "$", ...
Get a value by name from the current level. @param string|int $name The name of the value to retrieve. @return string|int|array|null The found value. Returns null if the value cannot be found.
[ "Get", "a", "value", "by", "name", "from", "the", "current", "level", "." ]
c5d9c52cfade1fe9169e3cbae855b49a054f04ff
https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/DataSet.php#L100-L113
train
klermonte/zerg
src/Zerg/DataSet.php
DataSet.getValueByPath
public function getValueByPath($path) { if (is_string($path)) { $path = $this->parsePath($path); } $child = $this->data; foreach ($path as $part) { if (isset($child[$part])) { $child = $child[$part]; } else { return null; } } return $child; }
php
public function getValueByPath($path) { if (is_string($path)) { $path = $this->parsePath($path); } $child = $this->data; foreach ($path as $part) { if (isset($child[$part])) { $child = $child[$part]; } else { return null; } } return $child; }
[ "public", "function", "getValueByPath", "(", "$", "path", ")", "{", "if", "(", "is_string", "(", "$", "path", ")", ")", "{", "$", "path", "=", "$", "this", "->", "parsePath", "(", "$", "path", ")", ";", "}", "$", "child", "=", "$", "this", "->", ...
Find a value by path within the DataSet instance. @see $currentPath @param string|array $path Path in internal or human format. @return string|int|array|null The found value. Returns null if the value cannot be found.
[ "Find", "a", "value", "by", "path", "within", "the", "DataSet", "instance", "." ]
c5d9c52cfade1fe9169e3cbae855b49a054f04ff
https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/DataSet.php#L122-L139
train
klermonte/zerg
src/Zerg/DataSet.php
DataSet.setValueByPath
public function setValueByPath($path, $value) { if (is_string($path)) { $path = $this->parsePath($path); } $endPart = array_pop($path); $child = & $this->data; foreach ($path as $part) { if (isset($child[$part])) { $child = & $child[$part]; } else { $child[$part] = []; $child = & $child[$part]; } } $child[$endPart] = $value; }
php
public function setValueByPath($path, $value) { if (is_string($path)) { $path = $this->parsePath($path); } $endPart = array_pop($path); $child = & $this->data; foreach ($path as $part) { if (isset($child[$part])) { $child = & $child[$part]; } else { $child[$part] = []; $child = & $child[$part]; } } $child[$endPart] = $value; }
[ "public", "function", "setValueByPath", "(", "$", "path", ",", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "path", ")", ")", "{", "$", "path", "=", "$", "this", "->", "parsePath", "(", "$", "path", ")", ";", "}", "$", "endPart", "="...
Assign a value by path within the DataSet instance, overwrites any existing value. @see $currentPath @param string|array $path A path in internal or human format. @param string|int|array|null $value The value to assign.
[ "Assign", "a", "value", "by", "path", "within", "the", "DataSet", "instance", "overwrites", "any", "existing", "value", "." ]
c5d9c52cfade1fe9169e3cbae855b49a054f04ff
https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/DataSet.php#L149-L168
train
klermonte/zerg
src/Zerg/DataSet.php
DataSet.parsePath
public function parsePath($path) { $parts = explode('/', trim($path, '/')); $pathArray = []; if ($parts[0] == '.') { $pathArray = $this->currentPath; array_shift($parts); } foreach ($parts as $part) { if ($part == '..') { if (count($pathArray)) { array_pop($pathArray); } else { throw new Field\ConfigurationException("Invalid path. To many '..', can't move higher root."); } } else { $pathArray[] = $part; } } return $pathArray; }
php
public function parsePath($path) { $parts = explode('/', trim($path, '/')); $pathArray = []; if ($parts[0] == '.') { $pathArray = $this->currentPath; array_shift($parts); } foreach ($parts as $part) { if ($part == '..') { if (count($pathArray)) { array_pop($pathArray); } else { throw new Field\ConfigurationException("Invalid path. To many '..', can't move higher root."); } } else { $pathArray[] = $part; } } return $pathArray; }
[ "public", "function", "parsePath", "(", "$", "path", ")", "{", "$", "parts", "=", "explode", "(", "'/'", ",", "trim", "(", "$", "path", ",", "'/'", ")", ")", ";", "$", "pathArray", "=", "[", "]", ";", "if", "(", "$", "parts", "[", "0", "]", "...
Transform human path to internal DataSet format. @see $currentPath @param string $path Path in human format ('/a/b' or 'a/../b' or './b/c'). @return array Path in internal format. @throws Field\ConfigurationException If path could not be parsed.
[ "Transform", "human", "path", "to", "internal", "DataSet", "format", "." ]
c5d9c52cfade1fe9169e3cbae855b49a054f04ff
https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/DataSet.php#L178-L201
train
klermonte/zerg
src/Zerg/DataSet.php
DataSet.resolvePath
public function resolvePath($value) { do { $value = $this->getValueByPath($value); } while (self::isPath($value)); return $value; }
php
public function resolvePath($value) { do { $value = $this->getValueByPath($value); } while (self::isPath($value)); return $value; }
[ "public", "function", "resolvePath", "(", "$", "value", ")", "{", "do", "{", "$", "value", "=", "$", "this", "->", "getValueByPath", "(", "$", "value", ")", ";", "}", "while", "(", "self", "::", "isPath", "(", "$", "value", ")", ")", ";", "return",...
Recursively find value by path. @param string $value Value path. @return array|int|null|string @since 1.0
[ "Recursively", "find", "value", "by", "path", "." ]
c5d9c52cfade1fe9169e3cbae855b49a054f04ff
https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/DataSet.php#L222-L229
train
widoz/wordpress-model
src/Attachment/Image/SourceFactory.php
SourceFactory.create
public function create(WP_Post $attachment, Size $size): Source { if (!wp_attachment_is_image($attachment)) { throw new InvalidArgumentException('Attachment must be an image.'); } $imageSource = (array)wp_get_attachment_image_src( $attachment->ID, [$size->width(), $size->height()] ); $imageSource = array_filter($imageSource); if (!$imageSource) { throw new DomainException( sprintf('Image with ID: %d, no longer exists', $attachment->ID) ); } return new Source(...$imageSource); }
php
public function create(WP_Post $attachment, Size $size): Source { if (!wp_attachment_is_image($attachment)) { throw new InvalidArgumentException('Attachment must be an image.'); } $imageSource = (array)wp_get_attachment_image_src( $attachment->ID, [$size->width(), $size->height()] ); $imageSource = array_filter($imageSource); if (!$imageSource) { throw new DomainException( sprintf('Image with ID: %d, no longer exists', $attachment->ID) ); } return new Source(...$imageSource); }
[ "public", "function", "create", "(", "WP_Post", "$", "attachment", ",", "Size", "$", "size", ")", ":", "Source", "{", "if", "(", "!", "wp_attachment_is_image", "(", "$", "attachment", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Attachme...
Create an Instance of Source by the Given Attachment Post and Size @param WP_Post $attachment @param Size $size @return Source @throws InvalidArgumentException @throws DomainException @throws LengthException
[ "Create", "an", "Instance", "of", "Source", "by", "the", "Given", "Attachment", "Post", "and", "Size" ]
273301de4b6946144b285c235aea0d79b867244c
https://github.com/widoz/wordpress-model/blob/273301de4b6946144b285c235aea0d79b867244c/src/Attachment/Image/SourceFactory.php#L41-L60
train
MovingImage24/VMProApiClient
lib/ApiClient/Guzzle5ApiClient.php
Guzzle5ApiClient._doRequest
protected function _doRequest($method, $uri, $options) { // For Guzzle5 we cannot have any options that are not pre-defined, // so instead we put it in the config array if (isset($options[self::OPT_VIDEO_MANAGER_ID])) { $options['config'][self::OPT_VIDEO_MANAGER_ID] = $options[self::OPT_VIDEO_MANAGER_ID]; unset($options[self::OPT_VIDEO_MANAGER_ID]); } $request = $this->httpClient->createRequest($method, $uri, $options); return $this->httpClient->send($request); }
php
protected function _doRequest($method, $uri, $options) { // For Guzzle5 we cannot have any options that are not pre-defined, // so instead we put it in the config array if (isset($options[self::OPT_VIDEO_MANAGER_ID])) { $options['config'][self::OPT_VIDEO_MANAGER_ID] = $options[self::OPT_VIDEO_MANAGER_ID]; unset($options[self::OPT_VIDEO_MANAGER_ID]); } $request = $this->httpClient->createRequest($method, $uri, $options); return $this->httpClient->send($request); }
[ "protected", "function", "_doRequest", "(", "$", "method", ",", "$", "uri", ",", "$", "options", ")", "{", "// For Guzzle5 we cannot have any options that are not pre-defined,", "// so instead we put it in the config array", "if", "(", "isset", "(", "$", "options", "[", ...
Guzzle5 Client implementation for making HTTP requests with the appropriate options. @param string $method @param string $uri @param array $options @return \GuzzleHttp\Message\ResponseInterface
[ "Guzzle5", "Client", "implementation", "for", "making", "HTTP", "requests", "with", "the", "appropriate", "options", "." ]
e242a88a93a7a915898c888a575502c21434e35b
https://github.com/MovingImage24/VMProApiClient/blob/e242a88a93a7a915898c888a575502c21434e35b/lib/ApiClient/Guzzle5ApiClient.php#L29-L41
train
lordthorzonus/yii2-algolia
src/AlgoliaComponent.php
AlgoliaComponent.createManager
private function createManager() { $config = $this->generateConfig(); $algoliaManager = $this->algoliaFactory->make($config); $algoliaManager->setEnv($this->env); return $algoliaManager; }
php
private function createManager() { $config = $this->generateConfig(); $algoliaManager = $this->algoliaFactory->make($config); $algoliaManager->setEnv($this->env); return $algoliaManager; }
[ "private", "function", "createManager", "(", ")", "{", "$", "config", "=", "$", "this", "->", "generateConfig", "(", ")", ";", "$", "algoliaManager", "=", "$", "this", "->", "algoliaFactory", "->", "make", "(", "$", "config", ")", ";", "$", "algoliaManag...
Returns a new AlgoliaManager. @return AlgoliaManager
[ "Returns", "a", "new", "AlgoliaManager", "." ]
29593c356b727f6d52c2cb4080fc0c232d27c3bb
https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaComponent.php#L149-L157
train
lordthorzonus/yii2-algolia
src/AlgoliaComponent.php
AlgoliaComponent.generateConfig
private function generateConfig() { return new AlgoliaConfig( $this->applicationId, $this->apiKey, $this->hostsArray, $this->options ); }
php
private function generateConfig() { return new AlgoliaConfig( $this->applicationId, $this->apiKey, $this->hostsArray, $this->options ); }
[ "private", "function", "generateConfig", "(", ")", "{", "return", "new", "AlgoliaConfig", "(", "$", "this", "->", "applicationId", ",", "$", "this", "->", "apiKey", ",", "$", "this", "->", "hostsArray", ",", "$", "this", "->", "options", ")", ";", "}" ]
Generates config for the Algolia Manager. @return AlgoliaConfig
[ "Generates", "config", "for", "the", "Algolia", "Manager", "." ]
29593c356b727f6d52c2cb4080fc0c232d27c3bb
https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaComponent.php#L164-L172
train
brightnucleus/view
src/View/Support/URIHelper.php
URIHelper.hasExtension
public static function hasExtension(string $uri, string $extension): bool { $extension = '.' . ltrim($extension, '.'); $uriLength = mb_strlen($uri); $extensionLength = mb_strlen($extension); if ($extensionLength > $uriLength) { return false; } return substr_compare($uri, $extension, $uriLength - $extensionLength, $extensionLength) === 0; }
php
public static function hasExtension(string $uri, string $extension): bool { $extension = '.' . ltrim($extension, '.'); $uriLength = mb_strlen($uri); $extensionLength = mb_strlen($extension); if ($extensionLength > $uriLength) { return false; } return substr_compare($uri, $extension, $uriLength - $extensionLength, $extensionLength) === 0; }
[ "public", "static", "function", "hasExtension", "(", "string", "$", "uri", ",", "string", "$", "extension", ")", ":", "bool", "{", "$", "extension", "=", "'.'", ".", "ltrim", "(", "$", "extension", ",", "'.'", ")", ";", "$", "uriLength", "=", "mb_strle...
Check whether a given URI has a specific extension. @since 0.1.3 @param string $uri URI to check the extension of. @param string $extension Extension to check for. @return bool
[ "Check", "whether", "a", "given", "URI", "has", "a", "specific", "extension", "." ]
f26703b78bf452403fda112563825f172dc9e8ce
https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/Support/URIHelper.php#L35-L45
train
brightnucleus/view
src/View/Support/URIHelper.php
URIHelper.containsExtension
public static function containsExtension(string $uri): string { $pathParts = explode('/', $uri); $filename = array_pop($pathParts); $filenameParts = explode('.', $filename); if (count($filenameParts) > 1) { return array_pop($filenameParts); } return ''; }
php
public static function containsExtension(string $uri): string { $pathParts = explode('/', $uri); $filename = array_pop($pathParts); $filenameParts = explode('.', $filename); if (count($filenameParts) > 1) { return array_pop($filenameParts); } return ''; }
[ "public", "static", "function", "containsExtension", "(", "string", "$", "uri", ")", ":", "string", "{", "$", "pathParts", "=", "explode", "(", "'/'", ",", "$", "uri", ")", ";", "$", "filename", "=", "array_pop", "(", "$", "pathParts", ")", ";", "$", ...
Check whether a given URI contains an extension and return it. @param string $uri URI to check. @return string Extension that was found, empty string if none found.
[ "Check", "whether", "a", "given", "URI", "contains", "an", "extension", "and", "return", "it", "." ]
f26703b78bf452403fda112563825f172dc9e8ce
https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/Support/URIHelper.php#L53-L64
train
digbang/security
src/Permissions/RoutePermissionRepository.php
RoutePermissionRepository.extractPermissionFrom
private function extractPermissionFrom(Route $route) { $parameters = $route->getAction(); if (isset($parameters['permission'])) { return $parameters['permission']; } return null; }
php
private function extractPermissionFrom(Route $route) { $parameters = $route->getAction(); if (isset($parameters['permission'])) { return $parameters['permission']; } return null; }
[ "private", "function", "extractPermissionFrom", "(", "Route", "$", "route", ")", "{", "$", "parameters", "=", "$", "route", "->", "getAction", "(", ")", ";", "if", "(", "isset", "(", "$", "parameters", "[", "'permission'", "]", ")", ")", "{", "return", ...
Extracts the permission configured inside the route action array. @param Route $route @return string|null
[ "Extracts", "the", "permission", "configured", "inside", "the", "route", "action", "array", "." ]
ee925c5a144a1553f5a72ded6f5a66c01a86ab21
https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Permissions/RoutePermissionRepository.php#L86-L96
train
JantaoDev/SitemapBundle
EventListener/RouteAnnotationListener.php
RouteAnnotationListener.getUrlFromRoute
protected function getUrlFromRoute($name, Route $route) { $option = $route->getOption('sitemap'); if ($option === null) { return null; } if (is_string($option)) { $decoded = json_decode($option, true); if (!json_last_error() && is_array($decoded)) { $option = $decoded; } } if (!is_array($option) && !is_bool($option)) { $bool = filter_var($option, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); if (null === $bool) { throw new \InvalidArgumentException("The sitemap option for route $name must be boolean or array"); } $option = $bool; } if (!$option) { return null; } $url = $this->router->generate($name); $urlObject = new Url( $url, (isset($option['lastMod']) ? $option['lastMod'] : null), (isset($option['priority']) ? $option['priority'] : null), (isset($option['changeFreq']) ? $option['changeFreq'] : null) ); return $urlObject; }
php
protected function getUrlFromRoute($name, Route $route) { $option = $route->getOption('sitemap'); if ($option === null) { return null; } if (is_string($option)) { $decoded = json_decode($option, true); if (!json_last_error() && is_array($decoded)) { $option = $decoded; } } if (!is_array($option) && !is_bool($option)) { $bool = filter_var($option, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE); if (null === $bool) { throw new \InvalidArgumentException("The sitemap option for route $name must be boolean or array"); } $option = $bool; } if (!$option) { return null; } $url = $this->router->generate($name); $urlObject = new Url( $url, (isset($option['lastMod']) ? $option['lastMod'] : null), (isset($option['priority']) ? $option['priority'] : null), (isset($option['changeFreq']) ? $option['changeFreq'] : null) ); return $urlObject; }
[ "protected", "function", "getUrlFromRoute", "(", "$", "name", ",", "Route", "$", "route", ")", "{", "$", "option", "=", "$", "route", "->", "getOption", "(", "'sitemap'", ")", ";", "if", "(", "$", "option", "===", "null", ")", "{", "return", "null", ...
Create URL object from route annotations @param string $name @param Route $route @return Url|null @throws \InvalidArgumentException
[ "Create", "URL", "object", "from", "route", "annotations" ]
be21aafc2384d0430ee566bc8cec84de4a45ab03
https://github.com/JantaoDev/SitemapBundle/blob/be21aafc2384d0430ee566bc8cec84de4a45ab03/EventListener/RouteAnnotationListener.php#L56-L89
train
brightnucleus/view
src/View/Engine/PHPEngine.php
PHPEngine.getRenderCallback
public function getRenderCallback(string $uri, array $context = []): callable { if (! is_readable($uri)) { throw new FailedToLoadView( sprintf( _('The View URI "%1$s" is not accessible or readable.'), $uri ) ); } $closure = function () use ($uri, $context) { // Save current buffering level so we can backtrack in case of an error. // This is needed because the view itself might also add an unknown number of output buffering levels. $bufferLevel = ob_get_level(); ob_start(); try { include $uri; } catch (Exception $exception) { // Remove whatever levels were added up until now. while (ob_get_level() > $bufferLevel) { ob_end_clean(); } throw new FailedToLoadView( sprintf( _('Could not load the View URI "%1$s". Reason: "%2$s".'), $uri, $exception->getMessage() ), $exception->getCode(), $exception ); } return ob_get_clean(); }; return $closure; }
php
public function getRenderCallback(string $uri, array $context = []): callable { if (! is_readable($uri)) { throw new FailedToLoadView( sprintf( _('The View URI "%1$s" is not accessible or readable.'), $uri ) ); } $closure = function () use ($uri, $context) { // Save current buffering level so we can backtrack in case of an error. // This is needed because the view itself might also add an unknown number of output buffering levels. $bufferLevel = ob_get_level(); ob_start(); try { include $uri; } catch (Exception $exception) { // Remove whatever levels were added up until now. while (ob_get_level() > $bufferLevel) { ob_end_clean(); } throw new FailedToLoadView( sprintf( _('Could not load the View URI "%1$s". Reason: "%2$s".'), $uri, $exception->getMessage() ), $exception->getCode(), $exception ); } return ob_get_clean(); }; return $closure; }
[ "public", "function", "getRenderCallback", "(", "string", "$", "uri", ",", "array", "$", "context", "=", "[", "]", ")", ":", "callable", "{", "if", "(", "!", "is_readable", "(", "$", "uri", ")", ")", "{", "throw", "new", "FailedToLoadView", "(", "sprin...
Get the rendering callback for a given URI. @since 0.1.0 @param string $uri URI to render. @param array $context Context in which to render. @return callable Rendering callback. @throws FailedToLoadView If the View URI is not accessible or readable. @throws FailedToLoadView If the View URI could not be loaded.
[ "Get", "the", "rendering", "callback", "for", "a", "given", "URI", "." ]
f26703b78bf452403fda112563825f172dc9e8ce
https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/Engine/PHPEngine.php#L58-L99
train
pear/Text_Password
Text/Password.php
Text_Password.createMultiple
public static function createMultiple( $number, $length = 10, $type = 'pronounceable', $chars = '' ) { $passwords = array(); while ($number > 0) { while (true) { $password = self::create($length, $type, $chars); if (!in_array($password, $passwords)) { $passwords[] = $password; break; } } $number--; } return $passwords; }
php
public static function createMultiple( $number, $length = 10, $type = 'pronounceable', $chars = '' ) { $passwords = array(); while ($number > 0) { while (true) { $password = self::create($length, $type, $chars); if (!in_array($password, $passwords)) { $passwords[] = $password; break; } } $number--; } return $passwords; }
[ "public", "static", "function", "createMultiple", "(", "$", "number", ",", "$", "length", "=", "10", ",", "$", "type", "=", "'pronounceable'", ",", "$", "chars", "=", "''", ")", "{", "$", "passwords", "=", "array", "(", ")", ";", "while", "(", "$", ...
Create multiple, different passwords Method to create a list of different passwords which are all different. @param integer Number of different password @param integer Length of the password @param string Type of password (pronounceable, unpronounceable) @param string Character which could be use in the unpronounceable password ex : 'A,B,C,D,E,F,G' or numeric, alphabetical or alphanumeric. @return array Array containing the passwords
[ "Create", "multiple", "different", "passwords" ]
b03dedc7b75196a27da4dc533f4ac70b64afa8b1
https://github.com/pear/Text_Password/blob/b03dedc7b75196a27da4dc533f4ac70b64afa8b1/Text/Password.php#L100-L119
train
pear/Text_Password
Text/Password.php
Text_Password.createMultipleFromLogin
public static function createMultipleFromLogin($login, $type, $key = 0) { $passwords = array(); $number = count($login); $save = $number; while ($number > 0) { while (true) { $password = self::createFromLogin($login[$save - $number], $type, $key); if (!in_array($password, $passwords)) { $passwords[] = $password; break; } } $number--; } return $passwords; }
php
public static function createMultipleFromLogin($login, $type, $key = 0) { $passwords = array(); $number = count($login); $save = $number; while ($number > 0) { while (true) { $password = self::createFromLogin($login[$save - $number], $type, $key); if (!in_array($password, $passwords)) { $passwords[] = $password; break; } } $number--; } return $passwords; }
[ "public", "static", "function", "createMultipleFromLogin", "(", "$", "login", ",", "$", "type", ",", "$", "key", "=", "0", ")", "{", "$", "passwords", "=", "array", "(", ")", ";", "$", "number", "=", "count", "(", "$", "login", ")", ";", "$", "save...
Create multiple, different passwords from an array of login Method to create a list of different password from login @param array Login @param string Type @param integer Key @return array Array containing the passwords
[ "Create", "multiple", "different", "passwords", "from", "an", "array", "of", "login" ]
b03dedc7b75196a27da4dc533f4ac70b64afa8b1
https://github.com/pear/Text_Password/blob/b03dedc7b75196a27da4dc533f4ac70b64afa8b1/Text/Password.php#L176-L193
train
pear/Text_Password
Text/Password.php
Text_Password._shuffle
protected static function _shuffle($login) { $tmp = array(); for ($i = 0; $i < strlen($login); $i++) { $tmp[] = $login[$i]; } shuffle($tmp); return implode($tmp, ''); }
php
protected static function _shuffle($login) { $tmp = array(); for ($i = 0; $i < strlen($login); $i++) { $tmp[] = $login[$i]; } shuffle($tmp); return implode($tmp, ''); }
[ "protected", "static", "function", "_shuffle", "(", "$", "login", ")", "{", "$", "tmp", "=", "array", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "login", ")", ";", "$", "i", "++", ")", "{", "$", "...
Helper method to create password Method to create a password from a login @param string Login @return string
[ "Helper", "method", "to", "create", "password" ]
b03dedc7b75196a27da4dc533f4ac70b64afa8b1
https://github.com/pear/Text_Password/blob/b03dedc7b75196a27da4dc533f4ac70b64afa8b1/Text/Password.php#L424-L435
train
pear/Text_Password
Text/Password.php
Text_Password._rand
protected static function _rand($min, $max) { if (version_compare(PHP_VERSION, '7.0.0', 'ge')) { $value = random_int($min, $max); } else { $value = mt_rand($min, $max); } return $value; }
php
protected static function _rand($min, $max) { if (version_compare(PHP_VERSION, '7.0.0', 'ge')) { $value = random_int($min, $max); } else { $value = mt_rand($min, $max); } return $value; }
[ "protected", "static", "function", "_rand", "(", "$", "min", ",", "$", "max", ")", "{", "if", "(", "version_compare", "(", "PHP_VERSION", ",", "'7.0.0'", ",", "'ge'", ")", ")", "{", "$", "value", "=", "random_int", "(", "$", "min", ",", "$", "max", ...
Gets a random integer between min and max On PHP 7, this uses random_int(). On older systems it uses mt_rand(). @param integer $min @param integer $max @return integer
[ "Gets", "a", "random", "integer", "between", "min", "and", "max" ]
b03dedc7b75196a27da4dc533f4ac70b64afa8b1
https://github.com/pear/Text_Password/blob/b03dedc7b75196a27da4dc533f4ac70b64afa8b1/Text/Password.php#L596-L605
train
songshenzong/api
src/Traits/Errors.php
Errors.badRequest
public function badRequest($message = 'Bad Request', $errors = null): void { $this->setStatusCode(400); $this->setMessage($message); $this->setErrors($errors); throw new ApiException($this); }
php
public function badRequest($message = 'Bad Request', $errors = null): void { $this->setStatusCode(400); $this->setMessage($message); $this->setErrors($errors); throw new ApiException($this); }
[ "public", "function", "badRequest", "(", "$", "message", "=", "'Bad Request'", ",", "$", "errors", "=", "null", ")", ":", "void", "{", "$", "this", "->", "setStatusCode", "(", "400", ")", ";", "$", "this", "->", "setMessage", "(", "$", "message", ")", ...
Client errors - Bad Request The server cannot or will not process the request due to an apparent client error (e.g., malformed request syntax, too large size, invalid request message framing, or deceptive request routing). @param string $message @param null $errors @throws ApiException
[ "Client", "errors", "-", "Bad", "Request" ]
b81751be0fe64eb9e6c775957aa2e8f8c6c2444e
https://github.com/songshenzong/api/blob/b81751be0fe64eb9e6c775957aa2e8f8c6c2444e/src/Traits/Errors.php#L70-L77
train
VitexSoftware/Ease-PHP-Bricks
src/Ease/ui/TWBTreeView.php
TWBTreeView.finalize
public function finalize() { \Ease\TWB\Part::twBootstrapize(); $this->includeJavascript('https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.js'); $this->includeCss('https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.css'); $this->addJavascript('$(\'#'.$this->getTagID().'\').treeview({'.\Ease\TWB\Part::partPropertiesToString($this->properties).'})', null, true); }
php
public function finalize() { \Ease\TWB\Part::twBootstrapize(); $this->includeJavascript('https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.js'); $this->includeCss('https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.css'); $this->addJavascript('$(\'#'.$this->getTagID().'\').treeview({'.\Ease\TWB\Part::partPropertiesToString($this->properties).'})', null, true); }
[ "public", "function", "finalize", "(", ")", "{", "\\", "Ease", "\\", "TWB", "\\", "Part", "::", "twBootstrapize", "(", ")", ";", "$", "this", "->", "includeJavascript", "(", "'https://cdnjs.cloudflare.com/ajax/libs/bootstrap-treeview/1.2.0/bootstrap-treeview.min.js'", "...
Include requied assets in page
[ "Include", "requied", "assets", "in", "page" ]
e1616d1b1baebf99cdb7f3ce6d71369d709278a7
https://github.com/VitexSoftware/Ease-PHP-Bricks/blob/e1616d1b1baebf99cdb7f3ce6d71369d709278a7/src/Ease/ui/TWBTreeView.php#L35-L42
train
digicol/dcx-sdk-php
src/DcxApiClient.php
DcxApiClient.stream
public function stream($url, array $query, callable $eventListener) { try { $response = $this->guzzleClient->request ( 'GET', $this->fullUrl($url), $this->getRequestOptions ( [ 'stream' => true, 'query' => $this->mergeQuery($url, $query), 'headers' => [ 'Accept' => 'text/event-stream' ] ] ) ); } catch (RequestException $exception) { if ($exception->hasResponse()) { $response = $exception->getResponse(); } else { return 500; } } if (strpos($response->getHeader('Content-Type')[0], 'text/event-stream') !== false) { $this->handleStreamBody($response->getBody(), $eventListener); } elseif ($this->isJsonResponse($response)) { $responseData = $this->decodeJson($response->getBody()); $eventListener(['type' => '', 'id' => '', 'data' => $responseData]); } return $response->getStatusCode(); }
php
public function stream($url, array $query, callable $eventListener) { try { $response = $this->guzzleClient->request ( 'GET', $this->fullUrl($url), $this->getRequestOptions ( [ 'stream' => true, 'query' => $this->mergeQuery($url, $query), 'headers' => [ 'Accept' => 'text/event-stream' ] ] ) ); } catch (RequestException $exception) { if ($exception->hasResponse()) { $response = $exception->getResponse(); } else { return 500; } } if (strpos($response->getHeader('Content-Type')[0], 'text/event-stream') !== false) { $this->handleStreamBody($response->getBody(), $eventListener); } elseif ($this->isJsonResponse($response)) { $responseData = $this->decodeJson($response->getBody()); $eventListener(['type' => '', 'id' => '', 'data' => $responseData]); } return $response->getStatusCode(); }
[ "public", "function", "stream", "(", "$", "url", ",", "array", "$", "query", ",", "callable", "$", "eventListener", ")", "{", "try", "{", "$", "response", "=", "$", "this", "->", "guzzleClient", "->", "request", "(", "'GET'", ",", "$", "this", "->", ...
Request object stream @see https://html.spec.whatwg.org/multipage/comms.html#server-sent-events @param string $url @param array $query @param callable $eventListener Callback function with a single parameter (associative array of type, id, data) @return int HTTP status code
[ "Request", "object", "stream" ]
e42c23f20c4069317d46bd33ade0ec7fbb82224e
https://github.com/digicol/dcx-sdk-php/blob/e42c23f20c4069317d46bd33ade0ec7fbb82224e/src/DcxApiClient.php#L239-L274
train
shardimage/shardimage-php
src/services/Service.php
Service.sendRequest
protected function sendRequest($requiredParams, $params, $callback) { $response = $this->client->send($requiredParams, array_merge($params, [ 'module' => static::getModule(), 'controller' => static::getController(), 'version' => $this->version, ]), function ($response) use ($callback) { if (isset($response->error)) { return $response; } return call_user_func($callback, $response); }); if (isset($response->error)) { $this->lastError = isset($response->error->message) ? $response->error->message : 'Unknown error!'; if ($this->client->softExceptionEnabled) { if (isset($response->meta['statusCode']) ? $response->meta['statusCode'] : false) { throw $response->error->exception; } throw new Exception('API error ' . (isset($response->error->code) ? $response->error->code : -1) . '!'); } } return $response; }
php
protected function sendRequest($requiredParams, $params, $callback) { $response = $this->client->send($requiredParams, array_merge($params, [ 'module' => static::getModule(), 'controller' => static::getController(), 'version' => $this->version, ]), function ($response) use ($callback) { if (isset($response->error)) { return $response; } return call_user_func($callback, $response); }); if (isset($response->error)) { $this->lastError = isset($response->error->message) ? $response->error->message : 'Unknown error!'; if ($this->client->softExceptionEnabled) { if (isset($response->meta['statusCode']) ? $response->meta['statusCode'] : false) { throw $response->error->exception; } throw new Exception('API error ' . (isset($response->error->code) ? $response->error->code : -1) . '!'); } } return $response; }
[ "protected", "function", "sendRequest", "(", "$", "requiredParams", ",", "$", "params", ",", "$", "callback", ")", "{", "$", "response", "=", "$", "this", "->", "client", "->", "send", "(", "$", "requiredParams", ",", "array_merge", "(", "$", "params", "...
Sends the request to the Shardimage API and returns with the Response object or the ID for the request if deferred. Optionally throws an exception for soft errors. @param string[] $requiredParams Mandatory API parameters for precheck @param array $params API parameters @param callable $callback Response callback @return Response|string @throws Exception|HttpException
[ "Sends", "the", "request", "to", "the", "Shardimage", "API", "and", "returns", "with", "the", "Response", "object", "or", "the", "ID", "for", "the", "request", "if", "deferred", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/Service.php#L64-L87
train
orchestral/translation
src/FileLoader.php
FileLoader.mergeEnvironments
public function mergeEnvironments(array $lines, string $file): array { if ($this->files->exists($file)) { $lines = \array_replace_recursive($lines, $this->files->getRequire($file)); } return $lines; }
php
public function mergeEnvironments(array $lines, string $file): array { if ($this->files->exists($file)) { $lines = \array_replace_recursive($lines, $this->files->getRequire($file)); } return $lines; }
[ "public", "function", "mergeEnvironments", "(", "array", "$", "lines", ",", "string", "$", "file", ")", ":", "array", "{", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "file", ")", ")", "{", "$", "lines", "=", "\\", "array_replace...
Merge the items in the given file into the items. @param array $lines @param string $file @return array
[ "Merge", "the", "items", "in", "the", "given", "file", "into", "the", "items", "." ]
13fc130f58a0d2af0779d052b6799b0451febb27
https://github.com/orchestral/translation/blob/13fc130f58a0d2af0779d052b6799b0451febb27/src/FileLoader.php#L34-L41
train
thelia-modules/FeatureType
Model/FeatureType.php
FeatureType.getValue
public static function getValue($slug, $featureId, $locale = 'en_US') { return self::getValues([$slug], [$featureId], $locale)[$slug][$featureId]; }
php
public static function getValue($slug, $featureId, $locale = 'en_US') { return self::getValues([$slug], [$featureId], $locale)[$slug][$featureId]; }
[ "public", "static", "function", "getValue", "(", "$", "slug", ",", "$", "featureId", ",", "$", "locale", "=", "'en_US'", ")", "{", "return", "self", "::", "getValues", "(", "[", "$", "slug", "]", ",", "[", "$", "featureId", "]", ",", "$", "locale", ...
Returns a value based on the slug, feature_av_id and locale <code> $value = FeatureType::getValue('color', 2); </code> @param string $slug @param int $featureId @param string $locale @return string @throws \Propel\Runtime\Exception\PropelException
[ "Returns", "a", "value", "based", "on", "the", "slug", "feature_av_id", "and", "locale" ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/FeatureType.php#L40-L43
train
MovingImage24/VMProApiClient
lib/ApiClient/Guzzle6ApiClient.php
Guzzle6ApiClient._doRequest
protected function _doRequest($method, $uri, $options) { return $this->httpClient->request($method, $uri, $options); }
php
protected function _doRequest($method, $uri, $options) { return $this->httpClient->request($method, $uri, $options); }
[ "protected", "function", "_doRequest", "(", "$", "method", ",", "$", "uri", ",", "$", "options", ")", "{", "return", "$", "this", "->", "httpClient", "->", "request", "(", "$", "method", ",", "$", "uri", ",", "$", "options", ")", ";", "}" ]
Guzzle6 Client implementation for making HTTP requests with the appropriate options. @param string $method @param string $uri @param array $options @return mixed
[ "Guzzle6", "Client", "implementation", "for", "making", "HTTP", "requests", "with", "the", "appropriate", "options", "." ]
e242a88a93a7a915898c888a575502c21434e35b
https://github.com/MovingImage24/VMProApiClient/blob/e242a88a93a7a915898c888a575502c21434e35b/lib/ApiClient/Guzzle6ApiClient.php#L27-L30
train
JantaoDev/SitemapBundle
DoctrineIterator/DoctrineIterator.php
DoctrineIterator.loadPage
protected function loadPage($page) { $this->pageStart = $page * $this->pageSize; $this->pageData = $this->query->setFirstResult($this->pageStart)->setMaxResults($this->pageSize)->getResult(); }
php
protected function loadPage($page) { $this->pageStart = $page * $this->pageSize; $this->pageData = $this->query->setFirstResult($this->pageStart)->setMaxResults($this->pageSize)->getResult(); }
[ "protected", "function", "loadPage", "(", "$", "page", ")", "{", "$", "this", "->", "pageStart", "=", "$", "page", "*", "$", "this", "->", "pageSize", ";", "$", "this", "->", "pageData", "=", "$", "this", "->", "query", "->", "setFirstResult", "(", "...
Load cache page @param int $page Page number
[ "Load", "cache", "page" ]
be21aafc2384d0430ee566bc8cec84de4a45ab03
https://github.com/JantaoDev/SitemapBundle/blob/be21aafc2384d0430ee566bc8cec84de4a45ab03/DoctrineIterator/DoctrineIterator.php#L44-L48
train
thelia-modules/FeatureType
Model/Base/FeatureType.php
FeatureType.initFeatureFeatureTypes
public function initFeatureFeatureTypes($overrideExisting = true) { if (null !== $this->collFeatureFeatureTypes && !$overrideExisting) { return; } $this->collFeatureFeatureTypes = new ObjectCollection(); $this->collFeatureFeatureTypes->setModel('\FeatureType\Model\FeatureFeatureType'); }
php
public function initFeatureFeatureTypes($overrideExisting = true) { if (null !== $this->collFeatureFeatureTypes && !$overrideExisting) { return; } $this->collFeatureFeatureTypes = new ObjectCollection(); $this->collFeatureFeatureTypes->setModel('\FeatureType\Model\FeatureFeatureType'); }
[ "public", "function", "initFeatureFeatureTypes", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collFeatureFeatureTypes", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->",...
Initializes the collFeatureFeatureTypes collection. By default this just sets the collFeatureFeatureTypes collection to an empty array (like clearcollFeatureFeatureTypes()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collFeatureFeatureTypes", "collection", "." ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureType.php#L1943-L1950
train
thelia-modules/FeatureType
Model/Base/FeatureType.php
FeatureType.getFeatureFeatureTypes
public function getFeatureFeatureTypes($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFeatureFeatureTypesPartial && !$this->isNew(); if (null === $this->collFeatureFeatureTypes || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureFeatureTypes) { // return empty collection $this->initFeatureFeatureTypes(); } else { $collFeatureFeatureTypes = ChildFeatureFeatureTypeQuery::create(null, $criteria) ->filterByFeatureType($this) ->find($con); if (null !== $criteria) { if (false !== $this->collFeatureFeatureTypesPartial && count($collFeatureFeatureTypes)) { $this->initFeatureFeatureTypes(false); foreach ($collFeatureFeatureTypes as $obj) { if (false == $this->collFeatureFeatureTypes->contains($obj)) { $this->collFeatureFeatureTypes->append($obj); } } $this->collFeatureFeatureTypesPartial = true; } reset($collFeatureFeatureTypes); return $collFeatureFeatureTypes; } if ($partial && $this->collFeatureFeatureTypes) { foreach ($this->collFeatureFeatureTypes as $obj) { if ($obj->isNew()) { $collFeatureFeatureTypes[] = $obj; } } } $this->collFeatureFeatureTypes = $collFeatureFeatureTypes; $this->collFeatureFeatureTypesPartial = false; } } return $this->collFeatureFeatureTypes; }
php
public function getFeatureFeatureTypes($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFeatureFeatureTypesPartial && !$this->isNew(); if (null === $this->collFeatureFeatureTypes || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureFeatureTypes) { // return empty collection $this->initFeatureFeatureTypes(); } else { $collFeatureFeatureTypes = ChildFeatureFeatureTypeQuery::create(null, $criteria) ->filterByFeatureType($this) ->find($con); if (null !== $criteria) { if (false !== $this->collFeatureFeatureTypesPartial && count($collFeatureFeatureTypes)) { $this->initFeatureFeatureTypes(false); foreach ($collFeatureFeatureTypes as $obj) { if (false == $this->collFeatureFeatureTypes->contains($obj)) { $this->collFeatureFeatureTypes->append($obj); } } $this->collFeatureFeatureTypesPartial = true; } reset($collFeatureFeatureTypes); return $collFeatureFeatureTypes; } if ($partial && $this->collFeatureFeatureTypes) { foreach ($this->collFeatureFeatureTypes as $obj) { if ($obj->isNew()) { $collFeatureFeatureTypes[] = $obj; } } } $this->collFeatureFeatureTypes = $collFeatureFeatureTypes; $this->collFeatureFeatureTypesPartial = false; } } return $this->collFeatureFeatureTypes; }
[ "public", "function", "getFeatureFeatureTypes", "(", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collFeatureFeatureTypesPartial", "&&", "!", "$", "this", "->", "isNew", ...
Gets an array of ChildFeatureFeatureType objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildFeatureType is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @return Collection|ChildFeatureFeatureType[] List of ChildFeatureFeatureType objects @throws PropelException
[ "Gets", "an", "array", "of", "ChildFeatureFeatureType", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureType.php#L1966-L2010
train
thelia-modules/FeatureType
Model/Base/FeatureType.php
FeatureType.countFeatureFeatureTypes
public function countFeatureFeatureTypes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFeatureFeatureTypesPartial && !$this->isNew(); if (null === $this->collFeatureFeatureTypes || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureFeatureTypes) { return 0; } if ($partial && !$criteria) { return count($this->getFeatureFeatureTypes()); } $query = ChildFeatureFeatureTypeQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByFeatureType($this) ->count($con); } return count($this->collFeatureFeatureTypes); }
php
public function countFeatureFeatureTypes(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFeatureFeatureTypesPartial && !$this->isNew(); if (null === $this->collFeatureFeatureTypes || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureFeatureTypes) { return 0; } if ($partial && !$criteria) { return count($this->getFeatureFeatureTypes()); } $query = ChildFeatureFeatureTypeQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByFeatureType($this) ->count($con); } return count($this->collFeatureFeatureTypes); }
[ "public", "function", "countFeatureFeatureTypes", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collFeatureFeatureTypes...
Returns the number of related FeatureFeatureType objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related FeatureFeatureType objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "FeatureFeatureType", "objects", "." ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureType.php#L2053-L2076
train
thelia-modules/FeatureType
Model/Base/FeatureType.php
FeatureType.addFeatureFeatureType
public function addFeatureFeatureType(ChildFeatureFeatureType $l) { if ($this->collFeatureFeatureTypes === null) { $this->initFeatureFeatureTypes(); $this->collFeatureFeatureTypesPartial = true; } if (!in_array($l, $this->collFeatureFeatureTypes->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureFeatureType($l); } return $this; }
php
public function addFeatureFeatureType(ChildFeatureFeatureType $l) { if ($this->collFeatureFeatureTypes === null) { $this->initFeatureFeatureTypes(); $this->collFeatureFeatureTypesPartial = true; } if (!in_array($l, $this->collFeatureFeatureTypes->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureFeatureType($l); } return $this; }
[ "public", "function", "addFeatureFeatureType", "(", "ChildFeatureFeatureType", "$", "l", ")", "{", "if", "(", "$", "this", "->", "collFeatureFeatureTypes", "===", "null", ")", "{", "$", "this", "->", "initFeatureFeatureTypes", "(", ")", ";", "$", "this", "->",...
Method called to associate a ChildFeatureFeatureType object to this object through the ChildFeatureFeatureType foreign key attribute. @param ChildFeatureFeatureType $l ChildFeatureFeatureType @return \FeatureType\Model\FeatureType The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "ChildFeatureFeatureType", "object", "to", "this", "object", "through", "the", "ChildFeatureFeatureType", "foreign", "key", "attribute", "." ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureType.php#L2085-L2097
train
thelia-modules/FeatureType
Model/Base/FeatureType.php
FeatureType.getFeatureFeatureTypesJoinFeature
public function getFeatureFeatureTypesJoinFeature($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildFeatureFeatureTypeQuery::create(null, $criteria); $query->joinWith('Feature', $joinBehavior); return $this->getFeatureFeatureTypes($query, $con); }
php
public function getFeatureFeatureTypesJoinFeature($criteria = null, $con = null, $joinBehavior = Criteria::LEFT_JOIN) { $query = ChildFeatureFeatureTypeQuery::create(null, $criteria); $query->joinWith('Feature', $joinBehavior); return $this->getFeatureFeatureTypes($query, $con); }
[ "public", "function", "getFeatureFeatureTypesJoinFeature", "(", "$", "criteria", "=", "null", ",", "$", "con", "=", "null", ",", "$", "joinBehavior", "=", "Criteria", "::", "LEFT_JOIN", ")", "{", "$", "query", "=", "ChildFeatureFeatureTypeQuery", "::", "create",...
If this collection has already been initialized with an identical criteria, it returns the collection. Otherwise if this FeatureType is new, it will return an empty collection; or if this FeatureType has previously been saved, it will retrieve related FeatureFeatureTypes from storage. This method is protected by default in order to keep the public api reasonable. You can provide public methods for those you actually need in FeatureType. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @param string $joinBehavior optional join type to use (defaults to Criteria::LEFT_JOIN) @return Collection|ChildFeatureFeatureType[] List of ChildFeatureFeatureType objects
[ "If", "this", "collection", "has", "already", "been", "initialized", "with", "an", "identical", "criteria", "it", "returns", "the", "collection", ".", "Otherwise", "if", "this", "FeatureType", "is", "new", "it", "will", "return", "an", "empty", "collection", "...
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureType.php#L2144-L2150
train
thelia-modules/FeatureType
Model/Base/FeatureType.php
FeatureType.initFeatureTypeI18ns
public function initFeatureTypeI18ns($overrideExisting = true) { if (null !== $this->collFeatureTypeI18ns && !$overrideExisting) { return; } $this->collFeatureTypeI18ns = new ObjectCollection(); $this->collFeatureTypeI18ns->setModel('\FeatureType\Model\FeatureTypeI18n'); }
php
public function initFeatureTypeI18ns($overrideExisting = true) { if (null !== $this->collFeatureTypeI18ns && !$overrideExisting) { return; } $this->collFeatureTypeI18ns = new ObjectCollection(); $this->collFeatureTypeI18ns->setModel('\FeatureType\Model\FeatureTypeI18n'); }
[ "public", "function", "initFeatureTypeI18ns", "(", "$", "overrideExisting", "=", "true", ")", "{", "if", "(", "null", "!==", "$", "this", "->", "collFeatureTypeI18ns", "&&", "!", "$", "overrideExisting", ")", "{", "return", ";", "}", "$", "this", "->", "co...
Initializes the collFeatureTypeI18ns collection. By default this just sets the collFeatureTypeI18ns collection to an empty array (like clearcollFeatureTypeI18ns()); however, you may wish to override this method in your stub class to provide setting appropriate to your application -- for example, setting the initial array to the values stored in database. @param boolean $overrideExisting If set to true, the method call initializes the collection even if it is not empty @return void
[ "Initializes", "the", "collFeatureTypeI18ns", "collection", "." ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureType.php#L2186-L2193
train
thelia-modules/FeatureType
Model/Base/FeatureType.php
FeatureType.getFeatureTypeI18ns
public function getFeatureTypeI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFeatureTypeI18nsPartial && !$this->isNew(); if (null === $this->collFeatureTypeI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureTypeI18ns) { // return empty collection $this->initFeatureTypeI18ns(); } else { $collFeatureTypeI18ns = ChildFeatureTypeI18nQuery::create(null, $criteria) ->filterByFeatureType($this) ->find($con); if (null !== $criteria) { if (false !== $this->collFeatureTypeI18nsPartial && count($collFeatureTypeI18ns)) { $this->initFeatureTypeI18ns(false); foreach ($collFeatureTypeI18ns as $obj) { if (false == $this->collFeatureTypeI18ns->contains($obj)) { $this->collFeatureTypeI18ns->append($obj); } } $this->collFeatureTypeI18nsPartial = true; } reset($collFeatureTypeI18ns); return $collFeatureTypeI18ns; } if ($partial && $this->collFeatureTypeI18ns) { foreach ($this->collFeatureTypeI18ns as $obj) { if ($obj->isNew()) { $collFeatureTypeI18ns[] = $obj; } } } $this->collFeatureTypeI18ns = $collFeatureTypeI18ns; $this->collFeatureTypeI18nsPartial = false; } } return $this->collFeatureTypeI18ns; }
php
public function getFeatureTypeI18ns($criteria = null, ConnectionInterface $con = null) { $partial = $this->collFeatureTypeI18nsPartial && !$this->isNew(); if (null === $this->collFeatureTypeI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureTypeI18ns) { // return empty collection $this->initFeatureTypeI18ns(); } else { $collFeatureTypeI18ns = ChildFeatureTypeI18nQuery::create(null, $criteria) ->filterByFeatureType($this) ->find($con); if (null !== $criteria) { if (false !== $this->collFeatureTypeI18nsPartial && count($collFeatureTypeI18ns)) { $this->initFeatureTypeI18ns(false); foreach ($collFeatureTypeI18ns as $obj) { if (false == $this->collFeatureTypeI18ns->contains($obj)) { $this->collFeatureTypeI18ns->append($obj); } } $this->collFeatureTypeI18nsPartial = true; } reset($collFeatureTypeI18ns); return $collFeatureTypeI18ns; } if ($partial && $this->collFeatureTypeI18ns) { foreach ($this->collFeatureTypeI18ns as $obj) { if ($obj->isNew()) { $collFeatureTypeI18ns[] = $obj; } } } $this->collFeatureTypeI18ns = $collFeatureTypeI18ns; $this->collFeatureTypeI18nsPartial = false; } } return $this->collFeatureTypeI18ns; }
[ "public", "function", "getFeatureTypeI18ns", "(", "$", "criteria", "=", "null", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collFeatureTypeI18nsPartial", "&&", "!", "$", "this", "->", "isNew", "(", ...
Gets an array of ChildFeatureTypeI18n objects which contain a foreign key that references this object. If the $criteria is not null, it is used to always fetch the results from the database. Otherwise the results are fetched from the database the first time, then cached. Next time the same method is called without $criteria, the cached collection is returned. If this ChildFeatureType is new, it will return an empty collection or the current collection; the criteria is ignored on a new object. @param Criteria $criteria optional Criteria object to narrow the query @param ConnectionInterface $con optional connection object @return Collection|ChildFeatureTypeI18n[] List of ChildFeatureTypeI18n objects @throws PropelException
[ "Gets", "an", "array", "of", "ChildFeatureTypeI18n", "objects", "which", "contain", "a", "foreign", "key", "that", "references", "this", "object", "." ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureType.php#L2209-L2253
train
thelia-modules/FeatureType
Model/Base/FeatureType.php
FeatureType.countFeatureTypeI18ns
public function countFeatureTypeI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFeatureTypeI18nsPartial && !$this->isNew(); if (null === $this->collFeatureTypeI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureTypeI18ns) { return 0; } if ($partial && !$criteria) { return count($this->getFeatureTypeI18ns()); } $query = ChildFeatureTypeI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByFeatureType($this) ->count($con); } return count($this->collFeatureTypeI18ns); }
php
public function countFeatureTypeI18ns(Criteria $criteria = null, $distinct = false, ConnectionInterface $con = null) { $partial = $this->collFeatureTypeI18nsPartial && !$this->isNew(); if (null === $this->collFeatureTypeI18ns || null !== $criteria || $partial) { if ($this->isNew() && null === $this->collFeatureTypeI18ns) { return 0; } if ($partial && !$criteria) { return count($this->getFeatureTypeI18ns()); } $query = ChildFeatureTypeI18nQuery::create(null, $criteria); if ($distinct) { $query->distinct(); } return $query ->filterByFeatureType($this) ->count($con); } return count($this->collFeatureTypeI18ns); }
[ "public", "function", "countFeatureTypeI18ns", "(", "Criteria", "$", "criteria", "=", "null", ",", "$", "distinct", "=", "false", ",", "ConnectionInterface", "$", "con", "=", "null", ")", "{", "$", "partial", "=", "$", "this", "->", "collFeatureTypeI18nsPartia...
Returns the number of related FeatureTypeI18n objects. @param Criteria $criteria @param boolean $distinct @param ConnectionInterface $con @return int Count of related FeatureTypeI18n objects. @throws PropelException
[ "Returns", "the", "number", "of", "related", "FeatureTypeI18n", "objects", "." ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureType.php#L2299-L2322
train
thelia-modules/FeatureType
Model/Base/FeatureType.php
FeatureType.addFeatureTypeI18n
public function addFeatureTypeI18n(ChildFeatureTypeI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); $this->currentTranslations[$locale] = $l; } if ($this->collFeatureTypeI18ns === null) { $this->initFeatureTypeI18ns(); $this->collFeatureTypeI18nsPartial = true; } if (!in_array($l, $this->collFeatureTypeI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureTypeI18n($l); } return $this; }
php
public function addFeatureTypeI18n(ChildFeatureTypeI18n $l) { if ($l && $locale = $l->getLocale()) { $this->setLocale($locale); $this->currentTranslations[$locale] = $l; } if ($this->collFeatureTypeI18ns === null) { $this->initFeatureTypeI18ns(); $this->collFeatureTypeI18nsPartial = true; } if (!in_array($l, $this->collFeatureTypeI18ns->getArrayCopy(), true)) { // only add it if the **same** object is not already associated $this->doAddFeatureTypeI18n($l); } return $this; }
[ "public", "function", "addFeatureTypeI18n", "(", "ChildFeatureTypeI18n", "$", "l", ")", "{", "if", "(", "$", "l", "&&", "$", "locale", "=", "$", "l", "->", "getLocale", "(", ")", ")", "{", "$", "this", "->", "setLocale", "(", "$", "locale", ")", ";",...
Method called to associate a ChildFeatureTypeI18n object to this object through the ChildFeatureTypeI18n foreign key attribute. @param ChildFeatureTypeI18n $l ChildFeatureTypeI18n @return \FeatureType\Model\FeatureType The current object (for fluent API support)
[ "Method", "called", "to", "associate", "a", "ChildFeatureTypeI18n", "object", "to", "this", "object", "through", "the", "ChildFeatureTypeI18n", "foreign", "key", "attribute", "." ]
fc73eaaf53583758a316bb7e4af69ea50ec89997
https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureType.php#L2331-L2347
train
shardimage/shardimage-php
src/services/ImageService.php
ImageService.index
public function index($params = [], $optParams = []) { if ($optParams instanceof IndexParams) { $optParams = $optParams->toArray(true); } if (is_string($params)) { $params = ['cloudId' => $params]; } return $this->sendRequest(['cloudId'], [ 'restAction' => 'index', 'uri' => '/c/<cloudId>', 'params' => $params, 'getParams' => $optParams, ], function ($response) use ($params) { $images = []; foreach ($response->data['items'] as $image) { if (!isset($image['cloudId'])) { $image['cloudId'] = $this->client->getParam($params, 'cloudId'); } $images[] = new Image($image); } return new Index([ 'models' => $images, 'nextPageToken' => $response->data['nextPageToken'], ]); }); }
php
public function index($params = [], $optParams = []) { if ($optParams instanceof IndexParams) { $optParams = $optParams->toArray(true); } if (is_string($params)) { $params = ['cloudId' => $params]; } return $this->sendRequest(['cloudId'], [ 'restAction' => 'index', 'uri' => '/c/<cloudId>', 'params' => $params, 'getParams' => $optParams, ], function ($response) use ($params) { $images = []; foreach ($response->data['items'] as $image) { if (!isset($image['cloudId'])) { $image['cloudId'] = $this->client->getParam($params, 'cloudId'); } $images[] = new Image($image); } return new Index([ 'models' => $images, 'nextPageToken' => $response->data['nextPageToken'], ]); }); }
[ "public", "function", "index", "(", "$", "params", "=", "[", "]", ",", "$", "optParams", "=", "[", "]", ")", "{", "if", "(", "$", "optParams", "instanceof", "IndexParams", ")", "{", "$", "optParams", "=", "$", "optParams", "->", "toArray", "(", "true...
Fetches all images. @param array $params Required API parameters <li>cloudId - cloud ID @param IndexParams|array $optParams Optional API parameters <li>projection - an array of projection flags: noExif, noObject, noDimensions <li>order - the order of results: latest, publicId <li>maxResults - number of results <li>pageToken - token for next result page <li>nextPageTokenType - type of paging token: shortTime, longTime <li>prefix - prefix of publicId for filtering <li>byTag - image tag for filtering @return Index
[ "Fetches", "all", "images", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/ImageService.php#L43-L71
train
shardimage/shardimage-php
src/services/ImageService.php
ImageService.view
public function view($params, $optParams = []) { if (is_string($params)) { $params = ['publicId' => $params]; } if ($optParams instanceof ViewParams) { $optParams = $optParams->toArray(true); } return $this->sendRequest(['cloudId', 'publicId'], [ 'restAction' => 'view', 'uri' => '/c/<cloudId>/o/<publicId>', 'params' => $params, 'getParams' => $optParams, ], function ($response) use ($params) { if ($response->data && !isset($response->data['cloudId'])) { $response->data['cloudId'] = $this->client->getParam($params, 'cloudId'); } return isset($response->data) ? new Image($response->data) : $response; }); }
php
public function view($params, $optParams = []) { if (is_string($params)) { $params = ['publicId' => $params]; } if ($optParams instanceof ViewParams) { $optParams = $optParams->toArray(true); } return $this->sendRequest(['cloudId', 'publicId'], [ 'restAction' => 'view', 'uri' => '/c/<cloudId>/o/<publicId>', 'params' => $params, 'getParams' => $optParams, ], function ($response) use ($params) { if ($response->data && !isset($response->data['cloudId'])) { $response->data['cloudId'] = $this->client->getParam($params, 'cloudId'); } return isset($response->data) ? new Image($response->data) : $response; }); }
[ "public", "function", "view", "(", "$", "params", ",", "$", "optParams", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "params", ")", ")", "{", "$", "params", "=", "[", "'publicId'", "=>", "$", "params", "]", ";", "}", "if", "(", "...
Fetches an image. @param array $params Required API parameters <li>cloudId - cloud ID <li>publicId - image ID @param ImageViewParams|array $optParams Optional API parameters <li>projection - an array of projection flags: noExif, noObject, noDimensions @return Image|Response
[ "Fetches", "an", "image", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/ImageService.php#L86-L107
train
shardimage/shardimage-php
src/services/ImageService.php
ImageService.rename
public function rename($params, $optParams = []) { return $this->sendRequest(['cloudId', 'publicId', 'newPublicId'], [ 'restAction' => 'update', 'uri' => '/c/<cloudId>/o/<publicId>/rename/o/<newPublicId>', 'params' => $params, 'getParams' => $optParams, ], function ($response) use ($params) { if ($response->data && !isset($response->data['cloudId'])) { $response->data['cloudId'] = $this->client->getParam($params, 'cloudId'); } return isset($response->data) ? new Image($response->data) : $response; }); }
php
public function rename($params, $optParams = []) { return $this->sendRequest(['cloudId', 'publicId', 'newPublicId'], [ 'restAction' => 'update', 'uri' => '/c/<cloudId>/o/<publicId>/rename/o/<newPublicId>', 'params' => $params, 'getParams' => $optParams, ], function ($response) use ($params) { if ($response->data && !isset($response->data['cloudId'])) { $response->data['cloudId'] = $this->client->getParam($params, 'cloudId'); } return isset($response->data) ? new Image($response->data) : $response; }); }
[ "public", "function", "rename", "(", "$", "params", ",", "$", "optParams", "=", "[", "]", ")", "{", "return", "$", "this", "->", "sendRequest", "(", "[", "'cloudId'", ",", "'publicId'", ",", "'newPublicId'", "]", ",", "[", "'restAction'", "=>", "'update'...
Renames the ID of an image. @param array $params Required API parameters <li>cloudId - cloud ID <li>publicId - image ID <li>newPublicId - new image ID @param array $optParams Optional API parameters @return Image|Response
[ "Renames", "the", "ID", "of", "an", "image", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/ImageService.php#L121-L135
train
shardimage/shardimage-php
src/services/ImageService.php
ImageService.delete
public function delete($params, $optParams = []) { if (is_string($params)) { $params = ['publicId' => $params]; } return $this->sendRequest(['cloudId', 'publicId'], [ 'restAction' => 'delete', 'uri' => '/c/<cloudId>/o/<publicId>', 'params' => $params, 'getParams' => $optParams, ], function ($response) { return $response->success; }); }
php
public function delete($params, $optParams = []) { if (is_string($params)) { $params = ['publicId' => $params]; } return $this->sendRequest(['cloudId', 'publicId'], [ 'restAction' => 'delete', 'uri' => '/c/<cloudId>/o/<publicId>', 'params' => $params, 'getParams' => $optParams, ], function ($response) { return $response->success; }); }
[ "public", "function", "delete", "(", "$", "params", ",", "$", "optParams", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "params", ")", ")", "{", "$", "params", "=", "[", "'publicId'", "=>", "$", "params", "]", ";", "}", "return", "$...
Deletes an image. @param array $params Required API parameters <li>cloudId - cloud ID <li>publicId - image ID @param array $optParams Optional API parameters @return bool
[ "Deletes", "an", "image", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/ImageService.php#L148-L162
train
shardimage/shardimage-php
src/services/ImageService.php
ImageService.deleteByTag
public function deleteByTag($params, $optParams = []) { if (is_string($params)) { $params = ['tag' => $params]; } return $this->sendRequest(['cloudId', 'tag'], [ 'restAction' => 'delete', 'uri' => '/c/<cloudId>/t/<tag>', 'params' => $params, 'getParams' => $optParams, ], function ($response) { return isset($response->data) ? new Job($response->data) : $response; }); }
php
public function deleteByTag($params, $optParams = []) { if (is_string($params)) { $params = ['tag' => $params]; } return $this->sendRequest(['cloudId', 'tag'], [ 'restAction' => 'delete', 'uri' => '/c/<cloudId>/t/<tag>', 'params' => $params, 'getParams' => $optParams, ], function ($response) { return isset($response->data) ? new Job($response->data) : $response; }); }
[ "public", "function", "deleteByTag", "(", "$", "params", ",", "$", "optParams", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "params", ")", ")", "{", "$", "params", "=", "[", "'tag'", "=>", "$", "params", "]", ";", "}", "return", "$...
Deletes images by tag. @param array $params Required API parameters <li>cloudId - cloud ID <li>tag - image tag @param array $optParams Optional API parameters @return Job|Response
[ "Deletes", "images", "by", "tag", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/ImageService.php#L175-L189
train
shardimage/shardimage-php
src/services/ImageService.php
ImageService.exists
public function exists($params, $optParams = []) { if (is_string($params)) { $params = ['publicId' => $params]; } return $this->sendRequest(['cloudId', 'publicId'], [ 'restAction' => 'exists', 'uri' => '/c/<cloudId>/o/<publicId>', 'params' => $params, 'getParams' => $optParams, ], function ($response) { return $response->success; }); }
php
public function exists($params, $optParams = []) { if (is_string($params)) { $params = ['publicId' => $params]; } return $this->sendRequest(['cloudId', 'publicId'], [ 'restAction' => 'exists', 'uri' => '/c/<cloudId>/o/<publicId>', 'params' => $params, 'getParams' => $optParams, ], function ($response) { return $response->success; }); }
[ "public", "function", "exists", "(", "$", "params", ",", "$", "optParams", "=", "[", "]", ")", "{", "if", "(", "is_string", "(", "$", "params", ")", ")", "{", "$", "params", "=", "[", "'publicId'", "=>", "$", "params", "]", ";", "}", "return", "$...
Returns whether an image exists. @param array $params Required API parameters <li>cloudId - cloud ID <li>publicId - image ID @param array $optParams Optional API parameters @return bool
[ "Returns", "whether", "an", "image", "exists", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/ImageService.php#L202-L216
train
koolkode/async
src/Stream/ReadableStreamTrait.php
ReadableStreamTrait.buffer
public function buffer(Context $context): Promise { return $context->task(function (Context $context) { $buffer = ''; try { while (null !== ($chunk = yield $this->read($context, 0xFFFF))) { $buffer .= $chunk; } } finally { $this->close(); } return $buffer; }); }
php
public function buffer(Context $context): Promise { return $context->task(function (Context $context) { $buffer = ''; try { while (null !== ($chunk = yield $this->read($context, 0xFFFF))) { $buffer .= $chunk; } } finally { $this->close(); } return $buffer; }); }
[ "public", "function", "buffer", "(", "Context", "$", "context", ")", ":", "Promise", "{", "return", "$", "context", "->", "task", "(", "function", "(", "Context", "$", "context", ")", "{", "$", "buffer", "=", "''", ";", "try", "{", "while", "(", "nul...
Buffer remaining stream contents in memory and close the stream. @param Context $context Async execution context. @return string Buffered stream contents. @throws StreamClosedException When the stream has been closed.
[ "Buffer", "remaining", "stream", "contents", "in", "memory", "and", "close", "the", "stream", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Stream/ReadableStreamTrait.php#L58-L73
train
koolkode/async
src/Stream/ReadableStreamTrait.php
ReadableStreamTrait.pipe
public function pipe(Context $context, WritableStream $stream, bool $close = false): Promise { return $context->task(function (Context $context) use ($stream, $close) { $len = 0; try { while (null != ($chunk = yield $this->read($context, 0xFFFF))) { $len += yield $stream->write($context, $chunk); } } finally { $this->close(); if ($close) { $stream->close(); } } return $len; }); }
php
public function pipe(Context $context, WritableStream $stream, bool $close = false): Promise { return $context->task(function (Context $context) use ($stream, $close) { $len = 0; try { while (null != ($chunk = yield $this->read($context, 0xFFFF))) { $len += yield $stream->write($context, $chunk); } } finally { $this->close(); if ($close) { $stream->close(); } } return $len; }); }
[ "public", "function", "pipe", "(", "Context", "$", "context", ",", "WritableStream", "$", "stream", ",", "bool", "$", "close", "=", "false", ")", ":", "Promise", "{", "return", "$", "context", "->", "task", "(", "function", "(", "Context", "$", "context"...
Copy remaining stream contents to the given stream. The readable stream will be closed after all bytes have been copied. @param Context $context Async execution context. @param WritableStream $stream Target stream to receive the data. @param bool $close Close writable stream after contents have been copied? @return int Number of bytes that have been copied. @throws StreamClosedException When the stream has been closed.
[ "Copy", "remaining", "stream", "contents", "to", "the", "given", "stream", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Stream/ReadableStreamTrait.php#L87-L106
train
koolkode/async
src/Stream/ReadableStreamTrait.php
ReadableStreamTrait.discard
public function discard(Context $context): Promise { return $context->task(function (Context $context) { $len = 0; try { while (null !== ($chunk = yield $this->read($context, 0xFFFF))) { $len += \strlen($chunk); } } catch (StreamClosedException $e) { // Ignore this case as we are discarding all data anyways. } finally { $this->close(); } return $len; }); }
php
public function discard(Context $context): Promise { return $context->task(function (Context $context) { $len = 0; try { while (null !== ($chunk = yield $this->read($context, 0xFFFF))) { $len += \strlen($chunk); } } catch (StreamClosedException $e) { // Ignore this case as we are discarding all data anyways. } finally { $this->close(); } return $len; }); }
[ "public", "function", "discard", "(", "Context", "$", "context", ")", ":", "Promise", "{", "return", "$", "context", "->", "task", "(", "function", "(", "Context", "$", "context", ")", "{", "$", "len", "=", "0", ";", "try", "{", "while", "(", "null",...
Discard remaining stream contents and close the stream. @param Context $context Async execution context. @return int Number of bytes that have been discarded.
[ "Discard", "remaining", "stream", "contents", "and", "close", "the", "stream", "." ]
9c985dcdd3b328323826dd4254d9f2e5aea0b75b
https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Stream/ReadableStreamTrait.php#L114-L131
train
meritoo/common-bundle
src/Bundle/Descriptor.php
Descriptor.addDataFixtures
public function addDataFixtures(array $fixturesPaths): Descriptor { if (!empty($fixturesPaths)) { foreach ($fixturesPaths as $path) { $this->dataFixtures->add($path); } } return $this; }
php
public function addDataFixtures(array $fixturesPaths): Descriptor { if (!empty($fixturesPaths)) { foreach ($fixturesPaths as $path) { $this->dataFixtures->add($path); } } return $this; }
[ "public", "function", "addDataFixtures", "(", "array", "$", "fixturesPaths", ")", ":", "Descriptor", "{", "if", "(", "!", "empty", "(", "$", "fixturesPaths", ")", ")", "{", "foreach", "(", "$", "fixturesPaths", "as", "$", "path", ")", "{", "$", "this", ...
Adds names of files with data fixtures from bundle @param array $fixturesPaths Names of files with data fixtures @return Descriptor
[ "Adds", "names", "of", "files", "with", "data", "fixtures", "from", "bundle" ]
560c3a6c14fce2e17208261b8c606f6208f44e23
https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Bundle/Descriptor.php#L271-L280
train
meritoo/common-bundle
src/Bundle/Descriptor.php
Descriptor.getShortName
public function getShortName(): string { if (empty($this->shortName)) { $name = strtolower($this->getName()); $replaced = preg_replace('|bundle$|', '', $name); $this->shortName = trim($replaced); } return $this->shortName; }
php
public function getShortName(): string { if (empty($this->shortName)) { $name = strtolower($this->getName()); $replaced = preg_replace('|bundle$|', '', $name); $this->shortName = trim($replaced); } return $this->shortName; }
[ "public", "function", "getShortName", "(", ")", ":", "string", "{", "if", "(", "empty", "(", "$", "this", "->", "shortName", ")", ")", "{", "$", "name", "=", "strtolower", "(", "$", "this", "->", "getName", "(", ")", ")", ";", "$", "replaced", "=",...
Returns short, simple name of bundle @return string
[ "Returns", "short", "simple", "name", "of", "bundle" ]
560c3a6c14fce2e17208261b8c606f6208f44e23
https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Bundle/Descriptor.php#L293-L303
train
meritoo/common-bundle
src/Bundle/Descriptor.php
Descriptor.toArray
public function toArray(bool $withParentAndChild = true): array { $array = [ 'name' => $this->getName(), 'shortName' => $this->getShortName(), 'configurationRootName' => $this->getConfigurationRootName(), 'rootNamespace' => $this->getRootNamespace(), 'path' => $this->getPath(), 'dataFixtures' => $this->getDataFixtures()->toArray(), ]; if ($withParentAndChild) { if (null !== $this->getParentBundleDescriptor()) { $array['parentBundleDescriptor'] = $this->getParentBundleDescriptor()->toArray(false); } if (null !== $this->getChildBundleDescriptor()) { $array['childBundleDescriptor'] = $this->getChildBundleDescriptor()->toArray(false); } } return $array; }
php
public function toArray(bool $withParentAndChild = true): array { $array = [ 'name' => $this->getName(), 'shortName' => $this->getShortName(), 'configurationRootName' => $this->getConfigurationRootName(), 'rootNamespace' => $this->getRootNamespace(), 'path' => $this->getPath(), 'dataFixtures' => $this->getDataFixtures()->toArray(), ]; if ($withParentAndChild) { if (null !== $this->getParentBundleDescriptor()) { $array['parentBundleDescriptor'] = $this->getParentBundleDescriptor()->toArray(false); } if (null !== $this->getChildBundleDescriptor()) { $array['childBundleDescriptor'] = $this->getChildBundleDescriptor()->toArray(false); } } return $array; }
[ "public", "function", "toArray", "(", "bool", "$", "withParentAndChild", "=", "true", ")", ":", "array", "{", "$", "array", "=", "[", "'name'", "=>", "$", "this", "->", "getName", "(", ")", ",", "'shortName'", "=>", "$", "this", "->", "getShortName", "...
Returns an array representation of the descriptor @param bool $withParentAndChild (optional) If is set to true, includes descriptor of the parent and child bundle (default behaviour). Otherwise - not. @return array
[ "Returns", "an", "array", "representation", "of", "the", "descriptor" ]
560c3a6c14fce2e17208261b8c606f6208f44e23
https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Bundle/Descriptor.php#L342-L364
train
meritoo/common-bundle
src/Bundle/Descriptor.php
Descriptor.fromArray
public static function fromArray(array $data): Descriptor { // Default values $name = ''; $configurationRootName = ''; $rootNamespace = ''; $path = ''; $parentBundleDescriptor = null; $childBundleDescriptor = null; // Grab values from provided array if (array_key_exists('name', $data) && !empty($data['name'])) { $name = $data['name']; } if (array_key_exists('configurationRootName', $data) && !empty($data['configurationRootName'])) { $configurationRootName = $data['configurationRootName']; } if (array_key_exists('rootNamespace', $data) && !empty($data['rootNamespace'])) { $rootNamespace = $data['rootNamespace']; } if (array_key_exists('path', $data) && !empty($data['path'])) { $path = $data['path']; } if (array_key_exists('parentBundleDescriptor', $data) && !empty($data['parentBundleDescriptor'])) { $parentData = $data['parentBundleDescriptor']; $parentBundleDescriptor = static::fromArray($parentData); } if (array_key_exists('childBundleDescriptor', $data) && !empty($data['childBundleDescriptor'])) { $childData = $data['childBundleDescriptor']; $childBundleDescriptor = static::fromArray($childData); } return new static( $name, $configurationRootName, $rootNamespace, $path, $parentBundleDescriptor, $childBundleDescriptor ); }
php
public static function fromArray(array $data): Descriptor { // Default values $name = ''; $configurationRootName = ''; $rootNamespace = ''; $path = ''; $parentBundleDescriptor = null; $childBundleDescriptor = null; // Grab values from provided array if (array_key_exists('name', $data) && !empty($data['name'])) { $name = $data['name']; } if (array_key_exists('configurationRootName', $data) && !empty($data['configurationRootName'])) { $configurationRootName = $data['configurationRootName']; } if (array_key_exists('rootNamespace', $data) && !empty($data['rootNamespace'])) { $rootNamespace = $data['rootNamespace']; } if (array_key_exists('path', $data) && !empty($data['path'])) { $path = $data['path']; } if (array_key_exists('parentBundleDescriptor', $data) && !empty($data['parentBundleDescriptor'])) { $parentData = $data['parentBundleDescriptor']; $parentBundleDescriptor = static::fromArray($parentData); } if (array_key_exists('childBundleDescriptor', $data) && !empty($data['childBundleDescriptor'])) { $childData = $data['childBundleDescriptor']; $childBundleDescriptor = static::fromArray($childData); } return new static( $name, $configurationRootName, $rootNamespace, $path, $parentBundleDescriptor, $childBundleDescriptor ); }
[ "public", "static", "function", "fromArray", "(", "array", "$", "data", ")", ":", "Descriptor", "{", "// Default values", "$", "name", "=", "''", ";", "$", "configurationRootName", "=", "''", ";", "$", "rootNamespace", "=", "''", ";", "$", "path", "=", "...
Creates and returns descriptor from given data @param array $data Data of descriptor @return Descriptor
[ "Creates", "and", "returns", "descriptor", "from", "given", "data" ]
560c3a6c14fce2e17208261b8c606f6208f44e23
https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Bundle/Descriptor.php#L372-L417
train
meritoo/common-bundle
src/Bundle/Descriptor.php
Descriptor.fromBundle
public static function fromBundle(Bundle $bundle): Descriptor { // Values from bundle $name = $bundle->getName(); $rootNamespace = $bundle->getNamespace(); $path = $bundle->getPath(); // Default values, not provided by bundle directly $configurationRootName = ''; return new static($name, $configurationRootName, $rootNamespace, $path); }
php
public static function fromBundle(Bundle $bundle): Descriptor { // Values from bundle $name = $bundle->getName(); $rootNamespace = $bundle->getNamespace(); $path = $bundle->getPath(); // Default values, not provided by bundle directly $configurationRootName = ''; return new static($name, $configurationRootName, $rootNamespace, $path); }
[ "public", "static", "function", "fromBundle", "(", "Bundle", "$", "bundle", ")", ":", "Descriptor", "{", "// Values from bundle", "$", "name", "=", "$", "bundle", "->", "getName", "(", ")", ";", "$", "rootNamespace", "=", "$", "bundle", "->", "getNamespace",...
Creates and returns descriptor of given bundle @param Bundle $bundle The bundle @return Descriptor
[ "Creates", "and", "returns", "descriptor", "of", "given", "bundle" ]
560c3a6c14fce2e17208261b8c606f6208f44e23
https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Bundle/Descriptor.php#L425-L436
train
19Gerhard85/sfSelect2WidgetsPlugin
lib/select2/Select2.class.php
Select2.addJavascripts
public static function addJavascripts($culture = null) { $path = sfConfig::get('sf_sfSelect2Widgets_select2_web_dir'); $available_cultures = sfConfig::get('sf_sfSelect2Widgets_available_cultures'); $javascripts = array($path . '/select2.js'); if ($culture != 'en' && in_array($culture, $available_cultures)) { $javascripts[] = $path . '/select2_locale_' . $culture . '.js'; } return $javascripts; }
php
public static function addJavascripts($culture = null) { $path = sfConfig::get('sf_sfSelect2Widgets_select2_web_dir'); $available_cultures = sfConfig::get('sf_sfSelect2Widgets_available_cultures'); $javascripts = array($path . '/select2.js'); if ($culture != 'en' && in_array($culture, $available_cultures)) { $javascripts[] = $path . '/select2_locale_' . $culture . '.js'; } return $javascripts; }
[ "public", "static", "function", "addJavascripts", "(", "$", "culture", "=", "null", ")", "{", "$", "path", "=", "sfConfig", "::", "get", "(", "'sf_sfSelect2Widgets_select2_web_dir'", ")", ";", "$", "available_cultures", "=", "sfConfig", "::", "get", "(", "'sf_...
Adds javascripts for Select2 Widgets @param null|string $culture Culture @return array Array of javascripts
[ "Adds", "javascripts", "for", "Select2", "Widgets" ]
ce912eb0ddff2f288542b83d6847cbb17c736ac4
https://github.com/19Gerhard85/sfSelect2WidgetsPlugin/blob/ce912eb0ddff2f288542b83d6847cbb17c736ac4/lib/select2/Select2.class.php#L10-L22
train
postalservice14/php-actuator
src/Health/AbstractHealthAggregator.php
AbstractHealthAggregator.aggregate
public function aggregate($healths) { $statusCandidates = []; foreach ($healths as $key => $health) { $statusCandidates[] = $health->getStatus(); } $status = $this->aggregateStatus($statusCandidates); $details = $this->aggregateDetails($healths); $builder = new HealthBuilder($status, $details); return $builder->build(); }
php
public function aggregate($healths) { $statusCandidates = []; foreach ($healths as $key => $health) { $statusCandidates[] = $health->getStatus(); } $status = $this->aggregateStatus($statusCandidates); $details = $this->aggregateDetails($healths); $builder = new HealthBuilder($status, $details); return $builder->build(); }
[ "public", "function", "aggregate", "(", "$", "healths", ")", "{", "$", "statusCandidates", "=", "[", "]", ";", "foreach", "(", "$", "healths", "as", "$", "key", "=>", "$", "health", ")", "{", "$", "statusCandidates", "[", "]", "=", "$", "health", "->...
Aggregate several given Health instances into one. @param Health[] $healths @return Health
[ "Aggregate", "several", "given", "Health", "instances", "into", "one", "." ]
08e0ab32fb0cdc24356aa8cc86245fab294ec841
https://github.com/postalservice14/php-actuator/blob/08e0ab32fb0cdc24356aa8cc86245fab294ec841/src/Health/AbstractHealthAggregator.php#L18-L29
train
shardimage/shardimage-php
src/services/UploadService.php
UploadService.upload
public function upload($params, $optParams = []) { $resource = null; if (is_string($params) || is_resource($params)) { $params = ['file' => $params]; } elseif (is_array($params) && isset($params['tmp_name'])) { $params = ['file' => $params['tmp_name']]; } if (isset($params['file']) && is_array($params['file']) && isset($params['file']['tmp_name'])) { $params['file'] = $params['file']['tmp_name']; } if (isset($params['file']) && is_string($params['file'])) { $resource = $params['file'] = fopen($params['file'], 'r'); } ArrayHelper::stringify($optParams, [ 'transformation', ]); return $this->sendRequest(['cloudId', 'file'], [ 'restAction' => 'create', 'uri' => '/c/<cloudId>', 'params' => $params, 'postParams' => array_merge($params, $optParams), ], function ($response) use ($resource) { if (is_resource($resource)) { fclose($resource); } return isset($response->data) ? new Image($response->data) : $response; }); }
php
public function upload($params, $optParams = []) { $resource = null; if (is_string($params) || is_resource($params)) { $params = ['file' => $params]; } elseif (is_array($params) && isset($params['tmp_name'])) { $params = ['file' => $params['tmp_name']]; } if (isset($params['file']) && is_array($params['file']) && isset($params['file']['tmp_name'])) { $params['file'] = $params['file']['tmp_name']; } if (isset($params['file']) && is_string($params['file'])) { $resource = $params['file'] = fopen($params['file'], 'r'); } ArrayHelper::stringify($optParams, [ 'transformation', ]); return $this->sendRequest(['cloudId', 'file'], [ 'restAction' => 'create', 'uri' => '/c/<cloudId>', 'params' => $params, 'postParams' => array_merge($params, $optParams), ], function ($response) use ($resource) { if (is_resource($resource)) { fclose($resource); } return isset($response->data) ? new Image($response->data) : $response; }); }
[ "public", "function", "upload", "(", "$", "params", ",", "$", "optParams", "=", "[", "]", ")", "{", "$", "resource", "=", "null", ";", "if", "(", "is_string", "(", "$", "params", ")", "||", "is_resource", "(", "$", "params", ")", ")", "{", "$", "...
Uploads an image from a local source. @param array|string|resource $params Required API parameters <li>file - source (string - filepath, array - a $_FILES entry, resource - an opened file resource (@see fopen()), an array with a 'file' key consisting of the above 3) <li>cloudId - cloud ID @param array $optParams Optional API parameters <li>publicId - image ID <li>format - image format <li>transformation - transformations <li>tags - tags <li>plugins - plugins @return Image|Response
[ "Uploads", "an", "image", "from", "a", "local", "source", "." ]
1988e3996dfdf7e17d1bd44d5d807f9884ac64bd
https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/UploadService.php#L41-L71
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.concat
public function concat($string): self { Assert::typeOf(['string', __CLASS__], $string); return new static($this->data . $string, $this->encoding); }
php
public function concat($string): self { Assert::typeOf(['string', __CLASS__], $string); return new static($this->data . $string, $this->encoding); }
[ "public", "function", "concat", "(", "$", "string", ")", ":", "self", "{", "Assert", "::", "typeOf", "(", "[", "'string'", ",", "__CLASS__", "]", ",", "$", "string", ")", ";", "return", "new", "static", "(", "$", "this", "->", "data", ".", "$", "st...
Concatenates given string to the end of this string @param static|string $string @return static @throws InvalidArgumentException @throws TypeError
[ "Concatenates", "given", "string", "to", "the", "end", "of", "this", "string" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L146-L151
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.copyValueOf
public static function copyValueOf($charList): self { Assert::typeOf(['string', 'array', __CLASS__], $charList); // Convert to native string before creating a new string object $string = ''; if (\is_array($charList)) { foreach ($charList as $value) { $string .= static::valueOf($value); } } else { $string = (string) $charList; } return new static($string); }
php
public static function copyValueOf($charList): self { Assert::typeOf(['string', 'array', __CLASS__], $charList); // Convert to native string before creating a new string object $string = ''; if (\is_array($charList)) { foreach ($charList as $value) { $string .= static::valueOf($value); } } else { $string = (string) $charList; } return new static($string); }
[ "public", "static", "function", "copyValueOf", "(", "$", "charList", ")", ":", "self", "{", "Assert", "::", "typeOf", "(", "[", "'string'", ",", "'array'", ",", "__CLASS__", "]", ",", "$", "charList", ")", ";", "// Convert to native string before creating a new ...
Returns a string that represents the character sequence in the array specified @param static|string|array $charList @return static @throws InvalidArgumentException @throws TypeError
[ "Returns", "a", "string", "that", "represents", "the", "character", "sequence", "in", "the", "array", "specified" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L195-L211
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.explode
public function explode($delimiter): array { Assert::typeOf(['string', __CLASS__], $delimiter); $response = []; $results = explode((string) $delimiter, $this->data); if ($results === false) { throw new RuntimeException('An unknown error occurred while splitting string!'); } foreach ($results as $result) { $response[] = new static($result, $this->encoding); } return $response; }
php
public function explode($delimiter): array { Assert::typeOf(['string', __CLASS__], $delimiter); $response = []; $results = explode((string) $delimiter, $this->data); if ($results === false) { throw new RuntimeException('An unknown error occurred while splitting string!'); } foreach ($results as $result) { $response[] = new static($result, $this->encoding); } return $response; }
[ "public", "function", "explode", "(", "$", "delimiter", ")", ":", "array", "{", "Assert", "::", "typeOf", "(", "[", "'string'", ",", "__CLASS__", "]", ",", "$", "delimiter", ")", ";", "$", "response", "=", "[", "]", ";", "$", "results", "=", "explode...
Explodes this string by specified delimiter @param static|string $delimiter @return static[] @throws InvalidArgumentException @throws RuntimeException @throws TypeError
[ "Explodes", "this", "string", "by", "specified", "delimiter" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L276-L292
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.format
public static function format($format, ...$args): self { Assert::typeOf(['string', __CLASS__], $format); return new static(sprintf((string) $format, ...$args)); }
php
public static function format($format, ...$args): self { Assert::typeOf(['string', __CLASS__], $format); return new static(sprintf((string) $format, ...$args)); }
[ "public", "static", "function", "format", "(", "$", "format", ",", "...", "$", "args", ")", ":", "self", "{", "Assert", "::", "typeOf", "(", "[", "'string'", ",", "__CLASS__", "]", ",", "$", "format", ")", ";", "return", "new", "static", "(", "sprint...
Returns a formatted string using the given format and arguments @param static|string $format @param mixed ...$args @return static @throws InvalidArgumentException @throws TypeError
[ "Returns", "a", "formatted", "string", "using", "the", "given", "format", "and", "arguments" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L303-L308
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.getChars
public function getChars(int $begin, int $end, array &$destination, int $dstBegin): void { $length = $end - $begin + 1; for ($i = 0; $i < $length; $i++) { $destination[$dstBegin + $i] = $this->charAt($begin + $i); } }
php
public function getChars(int $begin, int $end, array &$destination, int $dstBegin): void { $length = $end - $begin + 1; for ($i = 0; $i < $length; $i++) { $destination[$dstBegin + $i] = $this->charAt($begin + $i); } }
[ "public", "function", "getChars", "(", "int", "$", "begin", ",", "int", "$", "end", ",", "array", "&", "$", "destination", ",", "int", "$", "dstBegin", ")", ":", "void", "{", "$", "length", "=", "$", "end", "-", "$", "begin", "+", "1", ";", "for"...
Copies characters from this string into the destination array @param int $begin @param int $end @param Character[] $destination @param int $dstBegin @return void @throws InvalidArgumentException @throws OutOfBoundsException
[ "Copies", "characters", "from", "this", "string", "into", "the", "destination", "array" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L331-L338
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.indexOf
public function indexOf($string, int $offset = 0): int { Assert::typeOf(['string', __CLASS__], $string); $pos = mb_strpos($this->data, (string) $string, $offset, $this->encoding); return $pos > -1 ? $pos : -1; }
php
public function indexOf($string, int $offset = 0): int { Assert::typeOf(['string', __CLASS__], $string); $pos = mb_strpos($this->data, (string) $string, $offset, $this->encoding); return $pos > -1 ? $pos : -1; }
[ "public", "function", "indexOf", "(", "$", "string", ",", "int", "$", "offset", "=", "0", ")", ":", "int", "{", "Assert", "::", "typeOf", "(", "[", "'string'", ",", "__CLASS__", "]", ",", "$", "string", ")", ";", "$", "pos", "=", "mb_strpos", "(", ...
Returns the index within this string of the first occurrence of the specified string @param static|string $string @param int $offset @return int @throws InvalidArgumentException @throws TypeError
[ "Returns", "the", "index", "within", "this", "string", "of", "the", "first", "occurrence", "of", "the", "specified", "string" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L349-L355
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.lastIndexOf
public function lastIndexOf($string, int $offset = 0): int { Assert::typeOf(['string', __CLASS__], $string); $pos = mb_strrpos($this->data, (string) $string, $offset, $this->encoding); return $pos > -1 ? $pos : -1; }
php
public function lastIndexOf($string, int $offset = 0): int { Assert::typeOf(['string', __CLASS__], $string); $pos = mb_strrpos($this->data, (string) $string, $offset, $this->encoding); return $pos > -1 ? $pos : -1; }
[ "public", "function", "lastIndexOf", "(", "$", "string", ",", "int", "$", "offset", "=", "0", ")", ":", "int", "{", "Assert", "::", "typeOf", "(", "[", "'string'", ",", "__CLASS__", "]", ",", "$", "string", ")", ";", "$", "pos", "=", "mb_strrpos", ...
Returns the index within this string of the last occurrence of the specified string @param static|string $string @param int $offset @return int @throws InvalidArgumentException @throws TypeError
[ "Returns", "the", "index", "within", "this", "string", "of", "the", "last", "occurrence", "of", "the", "specified", "string" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L376-L382
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.matches
public function matches($pattern): bool { Assert::typeOf(['string', __CLASS__], $pattern); return preg_match((string) $pattern, $this->data) === 1; }
php
public function matches($pattern): bool { Assert::typeOf(['string', __CLASS__], $pattern); return preg_match((string) $pattern, $this->data) === 1; }
[ "public", "function", "matches", "(", "$", "pattern", ")", ":", "bool", "{", "Assert", "::", "typeOf", "(", "[", "'string'", ",", "__CLASS__", "]", ",", "$", "pattern", ")", ";", "return", "preg_match", "(", "(", "string", ")", "$", "pattern", ",", "...
Checks if this string matches the given regex pattern @param static|string $pattern @return boolean @throws InvalidArgumentException @throws TypeError
[ "Checks", "if", "this", "string", "matches", "the", "given", "regex", "pattern" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L400-L405
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.regionMatches
public function regionMatches(int $offset, $string, int $strOffset, int $len, bool $ignoreCase = false): bool { Assert::typeOf(['string', __CLASS__], $string); $strLen = \is_string($string) ? mb_strlen($string, $this->encoding) : $string->length(); if ($offset < 0 || $strOffset < 0 || ($strOffset + $len) > $strLen || ($offset + $len) > $this->length()) { return false; } $stringA = mb_substr($this->data, $offset, $len, $this->encoding); $stringB = mb_substr((string) $string, $strOffset, $len, $this->encoding); // Compare strings if ($ignoreCase) { $result = strcmp(mb_strtolower($stringA, $this->encoding), mb_strtolower($stringB, $this->encoding)); } else { $result = strcmp($stringA, $stringB); } return $result === 0; }
php
public function regionMatches(int $offset, $string, int $strOffset, int $len, bool $ignoreCase = false): bool { Assert::typeOf(['string', __CLASS__], $string); $strLen = \is_string($string) ? mb_strlen($string, $this->encoding) : $string->length(); if ($offset < 0 || $strOffset < 0 || ($strOffset + $len) > $strLen || ($offset + $len) > $this->length()) { return false; } $stringA = mb_substr($this->data, $offset, $len, $this->encoding); $stringB = mb_substr((string) $string, $strOffset, $len, $this->encoding); // Compare strings if ($ignoreCase) { $result = strcmp(mb_strtolower($stringA, $this->encoding), mb_strtolower($stringB, $this->encoding)); } else { $result = strcmp($stringA, $stringB); } return $result === 0; }
[ "public", "function", "regionMatches", "(", "int", "$", "offset", ",", "$", "string", ",", "int", "$", "strOffset", ",", "int", "$", "len", ",", "bool", "$", "ignoreCase", "=", "false", ")", ":", "bool", "{", "Assert", "::", "typeOf", "(", "[", "'str...
Checks if two string regions are equal @param int $offset @param static|string $string @param int $strOffset @param int $len @param boolean $ignoreCase @return boolean @throws InvalidArgumentException @throws TypeError
[ "Checks", "if", "two", "string", "regions", "are", "equal" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L500-L520
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.replaceFirst
public function replaceFirst($pattern, $replacement): self { Assert::typeOf(['string', __CLASS__], $pattern, $replacement); $result = preg_replace($pattern, $replacement, $this->data, 1); return new static($result ?: $this->data, $this->encoding); }
php
public function replaceFirst($pattern, $replacement): self { Assert::typeOf(['string', __CLASS__], $pattern, $replacement); $result = preg_replace($pattern, $replacement, $this->data, 1); return new static($result ?: $this->data, $this->encoding); }
[ "public", "function", "replaceFirst", "(", "$", "pattern", ",", "$", "replacement", ")", ":", "self", "{", "Assert", "::", "typeOf", "(", "[", "'string'", ",", "__CLASS__", "]", ",", "$", "pattern", ",", "$", "replacement", ")", ";", "$", "result", "="...
Replaces the first substring of this string that matches the given regex pattern with the specified replacement @param static|string $pattern @param static|string $replacement @return static @throws InvalidArgumentException @throws TypeError
[ "Replaces", "the", "first", "substring", "of", "this", "string", "that", "matches", "the", "given", "regex", "pattern", "with", "the", "specified", "replacement" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L564-L570
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.split
public function split($pattern, int $limit = -1): array { Assert::typeOf(['string', __CLASS__], $pattern); $response = []; $results = preg_split((string) $pattern, $this->data, $limit); if ($results === false) { throw new RuntimeException('An unknown error occurred while splitting string!'); } foreach ($results as $result) { $response[] = new static($result, $this->encoding); } return $response; }
php
public function split($pattern, int $limit = -1): array { Assert::typeOf(['string', __CLASS__], $pattern); $response = []; $results = preg_split((string) $pattern, $this->data, $limit); if ($results === false) { throw new RuntimeException('An unknown error occurred while splitting string!'); } foreach ($results as $result) { $response[] = new static($result, $this->encoding); } return $response; }
[ "public", "function", "split", "(", "$", "pattern", ",", "int", "$", "limit", "=", "-", "1", ")", ":", "array", "{", "Assert", "::", "typeOf", "(", "[", "'string'", ",", "__CLASS__", "]", ",", "$", "pattern", ")", ";", "$", "response", "=", "[", ...
Splits this string around matches of the given regex pattern @param static|string $pattern @param int $limit @return static[] @throws InvalidArgumentException @throws RuntimeException @throws TypeError
[ "Splits", "this", "string", "around", "matches", "of", "the", "given", "regex", "pattern" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L582-L598
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.substr
public function substr(int $start, int $length = null): self { if ($start < 0) { throw new InvalidArgumentException('Negative index is not allowed!'); } return new static(mb_substr($this->data, $start, $length, $this->encoding), $this->encoding); }
php
public function substr(int $start, int $length = null): self { if ($start < 0) { throw new InvalidArgumentException('Negative index is not allowed!'); } return new static(mb_substr($this->data, $start, $length, $this->encoding), $this->encoding); }
[ "public", "function", "substr", "(", "int", "$", "start", ",", "int", "$", "length", "=", "null", ")", ":", "self", "{", "if", "(", "$", "start", "<", "0", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Negative index is not allowed!'", ")", ...
Returns a new string object that is a substring of this string @param int $start @param int $length @return static @throws InvalidArgumentException
[ "Returns", "a", "new", "string", "object", "that", "is", "a", "substring", "of", "this", "string" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L644-L651
train
BlackBonjour/stdlib
src/Lang/StdString.php
StdString.valueOf
public static function valueOf($value): self { $strVal = null; switch (gettype($value)) { case 'object': if ($value instanceof StdObject || (\is_object($value) && method_exists($value, '__toString'))) { $strVal = (string) $value; } break; case 'boolean': $strVal = $value ? 'true' : 'false'; break; case 'double': case 'integer': case 'string': $strVal = (string) $value; break; } if ($strVal === null) { throw new InvalidArgumentException('Unsupported value type!'); } return new static($strVal); }
php
public static function valueOf($value): self { $strVal = null; switch (gettype($value)) { case 'object': if ($value instanceof StdObject || (\is_object($value) && method_exists($value, '__toString'))) { $strVal = (string) $value; } break; case 'boolean': $strVal = $value ? 'true' : 'false'; break; case 'double': case 'integer': case 'string': $strVal = (string) $value; break; } if ($strVal === null) { throw new InvalidArgumentException('Unsupported value type!'); } return new static($strVal); }
[ "public", "static", "function", "valueOf", "(", "$", "value", ")", ":", "self", "{", "$", "strVal", "=", "null", ";", "switch", "(", "gettype", "(", "$", "value", ")", ")", "{", "case", "'object'", ":", "if", "(", "$", "value", "instanceof", "StdObje...
Returns the string representation of the given value @param mixed $value @return static @throws InvalidArgumentException
[ "Returns", "the", "string", "representation", "of", "the", "given", "value" ]
0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814
https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/StdString.php#L721-L746
train
klermonte/zerg
src/Zerg/Field/String.php
String.read
public function read(AbstractStream $stream) { return $stream->getBuffer()->read($this->getSize(), $this->getEndian()); }
php
public function read(AbstractStream $stream) { return $stream->getBuffer()->read($this->getSize(), $this->getEndian()); }
[ "public", "function", "read", "(", "AbstractStream", "$", "stream", ")", "{", "return", "$", "stream", "->", "getBuffer", "(", ")", "->", "read", "(", "$", "this", "->", "getSize", "(", ")", ",", "$", "this", "->", "getEndian", "(", ")", ")", ";", ...
Read string from stream as it is. @param AbstractStream $stream Stream from which read. @return string Returned string.
[ "Read", "string", "from", "stream", "as", "it", "is", "." ]
c5d9c52cfade1fe9169e3cbae855b49a054f04ff
https://github.com/klermonte/zerg/blob/c5d9c52cfade1fe9169e3cbae855b49a054f04ff/src/Zerg/Field/String.php#L23-L26
train
scherersoftware/cake-cktools
src/Utility/BackButtonTrait.php
BackButtonTrait.handleBackActions
public function handleBackActions(): void { if (!$this->request->getSession()->check('back_action')) { $this->request->getSession()->write('back_action', []); } if (!empty($this->request->getQuery('back_action'))) { $requestedBackAction = $this->request->getQuery('back_action'); $requestedAction = $this->getRequestedAction(); if (!$this->request->getSession()->check('back_action.' . $requestedBackAction) || ($this->request->getSession()->check('back_action.' . $requestedBackAction) && $this->request->getSession()->read('back_action.' . $requestedBackAction) != $requestedAction ) && !$this->request->getSession()->check('back_action.' . $requestedAction) ) { $this->request->getSession()->write('back_action.' . $requestedAction, $requestedBackAction); } } }
php
public function handleBackActions(): void { if (!$this->request->getSession()->check('back_action')) { $this->request->getSession()->write('back_action', []); } if (!empty($this->request->getQuery('back_action'))) { $requestedBackAction = $this->request->getQuery('back_action'); $requestedAction = $this->getRequestedAction(); if (!$this->request->getSession()->check('back_action.' . $requestedBackAction) || ($this->request->getSession()->check('back_action.' . $requestedBackAction) && $this->request->getSession()->read('back_action.' . $requestedBackAction) != $requestedAction ) && !$this->request->getSession()->check('back_action.' . $requestedAction) ) { $this->request->getSession()->write('back_action.' . $requestedAction, $requestedBackAction); } } }
[ "public", "function", "handleBackActions", "(", ")", ":", "void", "{", "if", "(", "!", "$", "this", "->", "request", "->", "getSession", "(", ")", "->", "check", "(", "'back_action'", ")", ")", "{", "$", "this", "->", "request", "->", "getSession", "("...
persists requested back actions with their context in session @return void
[ "persists", "requested", "back", "actions", "with", "their", "context", "in", "session" ]
efba42cf4e1804df8f1faa83ef75927bee6c206b
https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Utility/BackButtonTrait.php#L37-L55
train
scherersoftware/cake-cktools
src/Utility/BackButtonTrait.php
BackButtonTrait.augmentUrlByBackParam
public function augmentUrlByBackParam(array $url): array { $backAction = $this->request->getRequestTarget(); if ($this->request->is('ajax')) { $backAction = $this->request->referer(true); } $backAction = preg_replace('/back_action=.*?(&|$)/', '', $backAction); $url['?']['back_action'] = preg_replace('/\\?$/', '', $backAction); return $url; }
php
public function augmentUrlByBackParam(array $url): array { $backAction = $this->request->getRequestTarget(); if ($this->request->is('ajax')) { $backAction = $this->request->referer(true); } $backAction = preg_replace('/back_action=.*?(&|$)/', '', $backAction); $url['?']['back_action'] = preg_replace('/\\?$/', '', $backAction); return $url; }
[ "public", "function", "augmentUrlByBackParam", "(", "array", "$", "url", ")", ":", "array", "{", "$", "backAction", "=", "$", "this", "->", "request", "->", "getRequestTarget", "(", ")", ";", "if", "(", "$", "this", "->", "request", "->", "is", "(", "'...
Adds a back action get param to an url array @param array $url URL array @return array
[ "Adds", "a", "back", "action", "get", "param", "to", "an", "url", "array" ]
efba42cf4e1804df8f1faa83ef75927bee6c206b
https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Utility/BackButtonTrait.php#L63-L74
train
meritoo/common-bundle
src/Validator/Constraints/Date/BaseThanTodayValidator.php
BaseThanTodayValidator.getDifference
private function getDifference($value): ?int { // Let's prepare the dates... $now = (new \DateTime())->setTime(0, 0); $date = Date::getDateTime($value); // ...and make comparison with "day" as unit if ($date instanceof \DateTime) { return Date::getDateDifference($now, $date, Date::DATE_DIFFERENCE_UNIT_DAYS); } return null; }
php
private function getDifference($value): ?int { // Let's prepare the dates... $now = (new \DateTime())->setTime(0, 0); $date = Date::getDateTime($value); // ...and make comparison with "day" as unit if ($date instanceof \DateTime) { return Date::getDateDifference($now, $date, Date::DATE_DIFFERENCE_UNIT_DAYS); } return null; }
[ "private", "function", "getDifference", "(", "$", "value", ")", ":", "?", "int", "{", "// Let's prepare the dates...", "$", "now", "=", "(", "new", "\\", "DateTime", "(", ")", ")", "->", "setTime", "(", "0", ",", "0", ")", ";", "$", "date", "=", "Dat...
Returns difference between validated date and today @param mixed $value Value to validate @return null|int
[ "Returns", "difference", "between", "validated", "date", "and", "today" ]
560c3a6c14fce2e17208261b8c606f6208f44e23
https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Validator/Constraints/Date/BaseThanTodayValidator.php#L65-L77
train
meritoo/common-bundle
src/Validator/Constraints/Date/BaseThanTodayValidator.php
BaseThanTodayValidator.isValid
private function isValid(Constraint $constraint, int $difference): bool { /* * It's a earlier than today date? * Nothing to do */ if ($constraint instanceof EarlierThanToday && $difference < 0) { return true; } /* * It's a earlier than or equal today date? * Nothing to do */ if ($constraint instanceof EarlierThanOrEqualToday && $difference <= 0) { return true; } /* * It's a later than today date? * Nothing to do */ if ($constraint instanceof LaterThanToday && $difference > 0) { return true; } /* * It's a later than or equal today date? * Nothing to do */ if ($constraint instanceof LaterThanOrEqualToday && $difference >= 0) { return true; } return false; }
php
private function isValid(Constraint $constraint, int $difference): bool { /* * It's a earlier than today date? * Nothing to do */ if ($constraint instanceof EarlierThanToday && $difference < 0) { return true; } /* * It's a earlier than or equal today date? * Nothing to do */ if ($constraint instanceof EarlierThanOrEqualToday && $difference <= 0) { return true; } /* * It's a later than today date? * Nothing to do */ if ($constraint instanceof LaterThanToday && $difference > 0) { return true; } /* * It's a later than or equal today date? * Nothing to do */ if ($constraint instanceof LaterThanOrEqualToday && $difference >= 0) { return true; } return false; }
[ "private", "function", "isValid", "(", "Constraint", "$", "constraint", ",", "int", "$", "difference", ")", ":", "bool", "{", "/*\n * It's a earlier than today date?\n * Nothing to do\n */", "if", "(", "$", "constraint", "instanceof", "EarlierThanTod...
Returns information if processing date is valid. Based on given constraint and difference between the date and today. @param Constraint $constraint The constraint @param int $difference Difference between validated date and today @return bool
[ "Returns", "information", "if", "processing", "date", "is", "valid", ".", "Based", "on", "given", "constraint", "and", "difference", "between", "the", "date", "and", "today", "." ]
560c3a6c14fce2e17208261b8c606f6208f44e23
https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Validator/Constraints/Date/BaseThanTodayValidator.php#L87-L122
train
dazzle-php/util
src/Util/Support/ArraySupport.php
ArraySupport.exists
public static function exists($array, $key) { $key = static::normalizeKey($key); if ($key === null || $key === '' || static::isEmpty($array)) { return false; } $keys = explode('.', $key); $currentElement = $array; foreach ($keys as $currentKey) { if (!is_array($currentElement) || !array_key_exists($currentKey, $currentElement)) { return false; } $currentElement = $currentElement[(string) $currentKey]; } return true; }
php
public static function exists($array, $key) { $key = static::normalizeKey($key); if ($key === null || $key === '' || static::isEmpty($array)) { return false; } $keys = explode('.', $key); $currentElement = $array; foreach ($keys as $currentKey) { if (!is_array($currentElement) || !array_key_exists($currentKey, $currentElement)) { return false; } $currentElement = $currentElement[(string) $currentKey]; } return true; }
[ "public", "static", "function", "exists", "(", "$", "array", ",", "$", "key", ")", "{", "$", "key", "=", "static", "::", "normalizeKey", "(", "$", "key", ")", ";", "if", "(", "$", "key", "===", "null", "||", "$", "key", "===", "''", "||", "static...
Check if given key exists in array with dot notation support. @param array $array @param string $key @return bool
[ "Check", "if", "given", "key", "exists", "in", "array", "with", "dot", "notation", "support", "." ]
eb78617678964579b40104ad55780d4465817314
https://github.com/dazzle-php/util/blob/eb78617678964579b40104ad55780d4465817314/src/Util/Support/ArraySupport.php#L25-L48
train
dazzle-php/util
src/Util/Support/ArraySupport.php
ArraySupport.get
public static function get($array, $key, $default = null) { $key = static::normalizeKey($key); if ($key === null || $key === '') { return $array; } $keys = explode('.', $key); $currentElement = $array; foreach ($keys as $currentKey) { if (!is_array($currentElement) || !array_key_exists($currentKey, $currentElement)) { return $default; } $currentElement = $currentElement[(string) $currentKey]; } return $currentElement; }
php
public static function get($array, $key, $default = null) { $key = static::normalizeKey($key); if ($key === null || $key === '') { return $array; } $keys = explode('.', $key); $currentElement = $array; foreach ($keys as $currentKey) { if (!is_array($currentElement) || !array_key_exists($currentKey, $currentElement)) { return $default; } $currentElement = $currentElement[(string) $currentKey]; } return $currentElement; }
[ "public", "static", "function", "get", "(", "$", "array", ",", "$", "key", ",", "$", "default", "=", "null", ")", "{", "$", "key", "=", "static", "::", "normalizeKey", "(", "$", "key", ")", ";", "if", "(", "$", "key", "===", "null", "||", "$", ...
Return the value stored under given key in the array with dot notation support. @param string $key @param array $array @param mixed $default @return mixed
[ "Return", "the", "value", "stored", "under", "given", "key", "in", "the", "array", "with", "dot", "notation", "support", "." ]
eb78617678964579b40104ad55780d4465817314
https://github.com/dazzle-php/util/blob/eb78617678964579b40104ad55780d4465817314/src/Util/Support/ArraySupport.php#L58-L81
train
dazzle-php/util
src/Util/Support/ArraySupport.php
ArraySupport.set
public static function set(&$array, $key, $value) { $key = static::normalizeKey($key); if ($key === null || $key === '') { return ($array = $value); } $keys = explode('.', $key); $last = array_pop($keys); $currentElement =& $array; foreach ($keys as $currentKey) { if (!array_key_exists($currentKey, $currentElement) || !is_array($currentElement[$currentKey])) { $currentElement[$currentKey] = []; } $currentElement =& $currentElement[$currentKey]; } $currentElement[$last] = $value; return $array; }
php
public static function set(&$array, $key, $value) { $key = static::normalizeKey($key); if ($key === null || $key === '') { return ($array = $value); } $keys = explode('.', $key); $last = array_pop($keys); $currentElement =& $array; foreach ($keys as $currentKey) { if (!array_key_exists($currentKey, $currentElement) || !is_array($currentElement[$currentKey])) { $currentElement[$currentKey] = []; } $currentElement =& $currentElement[$currentKey]; } $currentElement[$last] = $value; return $array; }
[ "public", "static", "function", "set", "(", "&", "$", "array", ",", "$", "key", ",", "$", "value", ")", "{", "$", "key", "=", "static", "::", "normalizeKey", "(", "$", "key", ")", ";", "if", "(", "$", "key", "===", "null", "||", "$", "key", "==...
Set the value for given key in the array with dot notation support. @param array &$array @param string $key @param mixed $value @return array
[ "Set", "the", "value", "for", "given", "key", "in", "the", "array", "with", "dot", "notation", "support", "." ]
eb78617678964579b40104ad55780d4465817314
https://github.com/dazzle-php/util/blob/eb78617678964579b40104ad55780d4465817314/src/Util/Support/ArraySupport.php#L91-L117
train
dazzle-php/util
src/Util/Support/ArraySupport.php
ArraySupport.expand
public static function expand($array) { $multiArray = []; foreach ($array as $key=>&$value) { $keys = explode('.', $key); $lastKey = array_pop($keys); $currentPointer = &$multiArray; foreach ($keys as $currentKey) { if (!isset($currentPointer[$currentKey])) { $currentPointer[$currentKey] = []; } $currentPointer = &$currentPointer[$currentKey]; } $currentPointer[$lastKey] = $value; } return $multiArray; }
php
public static function expand($array) { $multiArray = []; foreach ($array as $key=>&$value) { $keys = explode('.', $key); $lastKey = array_pop($keys); $currentPointer = &$multiArray; foreach ($keys as $currentKey) { if (!isset($currentPointer[$currentKey])) { $currentPointer[$currentKey] = []; } $currentPointer = &$currentPointer[$currentKey]; } $currentPointer[$lastKey] = $value; } return $multiArray; }
[ "public", "static", "function", "expand", "(", "$", "array", ")", "{", "$", "multiArray", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "$", "keys", "=", "explode", "(", "'.'", ",", "$", ...
Expand flattened array into a multi-dimensional one. @param $array @return array
[ "Expand", "flattened", "array", "into", "a", "multi", "-", "dimensional", "one", "." ]
eb78617678964579b40104ad55780d4465817314
https://github.com/dazzle-php/util/blob/eb78617678964579b40104ad55780d4465817314/src/Util/Support/ArraySupport.php#L171-L195
train
dazzle-php/util
src/Util/Support/ArraySupport.php
ArraySupport.merge
public static function merge($arrays) { $merged = []; foreach ($arrays as $array) { $merged = array_merge($merged, static::flatten($array)); } return static::expand($merged); }
php
public static function merge($arrays) { $merged = []; foreach ($arrays as $array) { $merged = array_merge($merged, static::flatten($array)); } return static::expand($merged); }
[ "public", "static", "function", "merge", "(", "$", "arrays", ")", "{", "$", "merged", "=", "[", "]", ";", "foreach", "(", "$", "arrays", "as", "$", "array", ")", "{", "$", "merged", "=", "array_merge", "(", "$", "merged", ",", "static", "::", "flat...
Merge several arrays, preserving dot notation. @param array[] $arrays @return array
[ "Merge", "several", "arrays", "preserving", "dot", "notation", "." ]
eb78617678964579b40104ad55780d4465817314
https://github.com/dazzle-php/util/blob/eb78617678964579b40104ad55780d4465817314/src/Util/Support/ArraySupport.php#L203-L213
train
dazzle-php/util
src/Util/Support/ArraySupport.php
ArraySupport.flattenRecursive
protected static function flattenRecursive(&$recursion, $prefix) { $values = []; foreach ($recursion as $key=>&$value) { if (is_array($value) && !empty($value)) { $values = array_merge($values, static::flattenRecursive($value, $prefix . $key . '.')); } else { $values[$prefix . $key] = $value; } } return $values; }
php
protected static function flattenRecursive(&$recursion, $prefix) { $values = []; foreach ($recursion as $key=>&$value) { if (is_array($value) && !empty($value)) { $values = array_merge($values, static::flattenRecursive($value, $prefix . $key . '.')); } else { $values[$prefix . $key] = $value; } } return $values; }
[ "protected", "static", "function", "flattenRecursive", "(", "&", "$", "recursion", ",", "$", "prefix", ")", "{", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "recursion", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "if", "(", "i...
Flatten a single recursion of array. @param array $recursion @param string $prefix @return array
[ "Flatten", "a", "single", "recursion", "of", "array", "." ]
eb78617678964579b40104ad55780d4465817314
https://github.com/dazzle-php/util/blob/eb78617678964579b40104ad55780d4465817314/src/Util/Support/ArraySupport.php#L255-L272
train
brightnucleus/view
src/View/Support/AbstractFinder.php
AbstractFinder.registerFindables
public function registerFindables(ConfigInterface $config) { $findables = (array) $config->getKey($this->getFindablesConfigKey()); foreach ($findables as $findableKey => $findableObject) { $this->findables->set($findableKey, $findableObject); } }
php
public function registerFindables(ConfigInterface $config) { $findables = (array) $config->getKey($this->getFindablesConfigKey()); foreach ($findables as $findableKey => $findableObject) { $this->findables->set($findableKey, $findableObject); } }
[ "public", "function", "registerFindables", "(", "ConfigInterface", "$", "config", ")", "{", "$", "findables", "=", "(", "array", ")", "$", "config", "->", "getKey", "(", "$", "this", "->", "getFindablesConfigKey", "(", ")", ")", ";", "foreach", "(", "$", ...
Register the Findables defined in the given configuration. @since 0.1.0 @param ConfigInterface $config Configuration to register the Findables from.
[ "Register", "the", "Findables", "defined", "in", "the", "given", "configuration", "." ]
f26703b78bf452403fda112563825f172dc9e8ce
https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/Support/AbstractFinder.php#L74-L80
train