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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
MetaModels/attribute_timestamp | src/EventListener/BootListener.php | BootListener.getSupportedAttribute | private function getSupportedAttribute($event)
{
$model = $event->getModel();
// Not a metamodel model.
if (!$model instanceof Model) {
return null;
}
$property = $event->getProperty();
$attribute = $model->getItem()->getAttribute($property);
if ($attribute instanceof Timestamp) {
return $attribute;
}
return null;
} | php | private function getSupportedAttribute($event)
{
$model = $event->getModel();
// Not a metamodel model.
if (!$model instanceof Model) {
return null;
}
$property = $event->getProperty();
$attribute = $model->getItem()->getAttribute($property);
if ($attribute instanceof Timestamp) {
return $attribute;
}
return null;
} | [
"private",
"function",
"getSupportedAttribute",
"(",
"$",
"event",
")",
"{",
"$",
"model",
"=",
"$",
"event",
"->",
"getModel",
"(",
")",
";",
"// Not a metamodel model.",
"if",
"(",
"!",
"$",
"model",
"instanceof",
"Model",
")",
"{",
"return",
"null",
";"... | Get the supported attribute or null.
@param EncodePropertyValueFromWidgetEvent|DecodePropertyValueForWidgetEvent $event The subscribed event.
@return Timestamp|null | [
"Get",
"the",
"supported",
"attribute",
"or",
"null",
"."
] | ba2e5e946e752fc269cc59b62a9a3c8fbf8768c3 | https://github.com/MetaModels/attribute_timestamp/blob/ba2e5e946e752fc269cc59b62a9a3c8fbf8768c3/src/EventListener/BootListener.php#L90-L107 | train |
kassko/data-mapper | src/Result/AbstractResultHydrator.php | AbstractResultHydrator.hydrateItem | protected function hydrateItem($objectClass, array $item)
{
$object = $this->createObjectToHydrate($objectClass);
if (0 == count($item)) {
return $object;
}
$hydrator = $this->objectManager->getHydratorFor($objectClass);
return $hydrator->hydrate($item, $object);
} | php | protected function hydrateItem($objectClass, array $item)
{
$object = $this->createObjectToHydrate($objectClass);
if (0 == count($item)) {
return $object;
}
$hydrator = $this->objectManager->getHydratorFor($objectClass);
return $hydrator->hydrate($item, $object);
} | [
"protected",
"function",
"hydrateItem",
"(",
"$",
"objectClass",
",",
"array",
"$",
"item",
")",
"{",
"$",
"object",
"=",
"$",
"this",
"->",
"createObjectToHydrate",
"(",
"$",
"objectClass",
")",
";",
"if",
"(",
"0",
"==",
"count",
"(",
"$",
"item",
")... | Create an hydrate an entity from a raw results.
@param array $data Raw results.
@return array Return an hydrated object. | [
"Create",
"an",
"hydrate",
"an",
"entity",
"from",
"a",
"raw",
"results",
"."
] | 653b3d735977d95f6eadb3334ab8787db1dca275 | https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/Result/AbstractResultHydrator.php#L29-L40 | train |
brightnucleus/view | src/View/Location/Locations.php | Locations.add | public function add($location): bool
{
if ($this->hasLocation($location)) {
return false;
}
return parent::add($location);
} | php | public function add($location): bool
{
if ($this->hasLocation($location)) {
return false;
}
return parent::add($location);
} | [
"public",
"function",
"add",
"(",
"$",
"location",
")",
":",
"bool",
"{",
"if",
"(",
"$",
"this",
"->",
"hasLocation",
"(",
"$",
"location",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"parent",
"::",
"add",
"(",
"$",
"location",
")",
";"... | Adds a location at the end of the collection if it does not already exist.
@param mixed $location The location to add.
@return bool Whether the location was added or not. | [
"Adds",
"a",
"location",
"at",
"the",
"end",
"of",
"the",
"collection",
"if",
"it",
"does",
"not",
"already",
"exist",
"."
] | f26703b78bf452403fda112563825f172dc9e8ce | https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/Location/Locations.php#L34-L41 | train |
brightnucleus/view | src/View/Location/Locations.php | Locations.hasLocation | public function hasLocation(Location $location): bool
{
return $this->exists(function ($key, $element) use ($location) {
return $location == $element;
});
} | php | public function hasLocation(Location $location): bool
{
return $this->exists(function ($key, $element) use ($location) {
return $location == $element;
});
} | [
"public",
"function",
"hasLocation",
"(",
"Location",
"$",
"location",
")",
":",
"bool",
"{",
"return",
"$",
"this",
"->",
"exists",
"(",
"function",
"(",
"$",
"key",
",",
"$",
"element",
")",
"use",
"(",
"$",
"location",
")",
"{",
"return",
"$",
"lo... | Check whether a given location is already registered.
For two locations to be equal, both their path and their extensions must be the same.
@since 0.1.1
@param Location $location Location to check the existence of.
@return bool Whether the location is already registered or not. | [
"Check",
"whether",
"a",
"given",
"location",
"is",
"already",
"registered",
"."
] | f26703b78bf452403fda112563825f172dc9e8ce | https://github.com/brightnucleus/view/blob/f26703b78bf452403fda112563825f172dc9e8ce/src/View/Location/Locations.php#L54-L59 | train |
UndefinedOffset/silverstripe-markdown | code/model/fieldtypes/Markdown.php | Markdown.AsHTML | public function AsHTML($useGFM=false) {
if($this->parsedHTML!==false) {
return $this->parsedHTML;
}
//Setup renderer
$renderer=$this->getRenderer();
$supported=$renderer->isSupported();
if($supported!==true) {
$class_name=get_class($renderer);
user_error("Renderer $class_name is not supported on this system: $supported");
}
if($renderer instanceof GithubMarkdownRenderer) {
$beforeUseGFM=GithubMarkdownRenderer::getUseGFM();
GithubMarkdownRenderer::setUseGFM($useGFM);
}
//Init cache stuff
$cacheKey=md5('Markdown_'.$this->tableName.'_'.$this->name.':'.$this->value);
$cache=SS_Cache::factory('Markdown');
$cachedHTML=$cache->load($cacheKey);
//Check cache, if it's good use it instead
if($cachedHTML!==false) {
$this->parsedHTML=$cachedHTML;
return $this->parsedHTML;
}
//If empty save time by not attempting to render
if(empty($this->value)) {
return $this->value;
}
//Get rendered HTML
$response=$renderer->getRenderedHTML($this->value);
//Store response in memory
$this->parsedHTML=$response;
//Cache response to file system
$cache->save($this->parsedHTML, $cacheKey);
//Reset GFM
if($renderer instanceof GithubMarkdownRenderer) {
GithubMarkdownRenderer::setUseGFM($beforeUseGFM);
}
//Return response
return $this->parsedHTML;
} | php | public function AsHTML($useGFM=false) {
if($this->parsedHTML!==false) {
return $this->parsedHTML;
}
//Setup renderer
$renderer=$this->getRenderer();
$supported=$renderer->isSupported();
if($supported!==true) {
$class_name=get_class($renderer);
user_error("Renderer $class_name is not supported on this system: $supported");
}
if($renderer instanceof GithubMarkdownRenderer) {
$beforeUseGFM=GithubMarkdownRenderer::getUseGFM();
GithubMarkdownRenderer::setUseGFM($useGFM);
}
//Init cache stuff
$cacheKey=md5('Markdown_'.$this->tableName.'_'.$this->name.':'.$this->value);
$cache=SS_Cache::factory('Markdown');
$cachedHTML=$cache->load($cacheKey);
//Check cache, if it's good use it instead
if($cachedHTML!==false) {
$this->parsedHTML=$cachedHTML;
return $this->parsedHTML;
}
//If empty save time by not attempting to render
if(empty($this->value)) {
return $this->value;
}
//Get rendered HTML
$response=$renderer->getRenderedHTML($this->value);
//Store response in memory
$this->parsedHTML=$response;
//Cache response to file system
$cache->save($this->parsedHTML, $cacheKey);
//Reset GFM
if($renderer instanceof GithubMarkdownRenderer) {
GithubMarkdownRenderer::setUseGFM($beforeUseGFM);
}
//Return response
return $this->parsedHTML;
} | [
"public",
"function",
"AsHTML",
"(",
"$",
"useGFM",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"parsedHTML",
"!==",
"false",
")",
"{",
"return",
"$",
"this",
"->",
"parsedHTML",
";",
"}",
"//Setup renderer",
"$",
"renderer",
"=",
"$",
"this"... | Checks cache to see if the contents of this field have already been loaded from github, if they haven't then a request is made to the github api to render the markdown
@param {bool} $useGFM Use Github Flavored Markdown or render using plain markdown defaults to false just like how readme files are rendered on github
@return {string} Markdown rendered as HTML | [
"Checks",
"cache",
"to",
"see",
"if",
"the",
"contents",
"of",
"this",
"field",
"have",
"already",
"been",
"loaded",
"from",
"github",
"if",
"they",
"haven",
"t",
"then",
"a",
"request",
"is",
"made",
"to",
"the",
"github",
"api",
"to",
"render",
"the",
... | e55d8478733dfdc1e8ba43dc536c3e029ad0b83d | https://github.com/UndefinedOffset/silverstripe-markdown/blob/e55d8478733dfdc1e8ba43dc536c3e029ad0b83d/code/model/fieldtypes/Markdown.php#L23-L74 | train |
UndefinedOffset/silverstripe-markdown | code/model/fieldtypes/Markdown.php | Markdown.setRenderer | public static function setRenderer($renderer) {
if(ClassInfo::classImplements($renderer, 'IMarkdownRenderer')) {
self::$renderer=$renderer;
}else {
user_error('The renderer '.$renderer.' does not implement IMarkdownRenderer', E_USER_ERROR);
}
} | php | public static function setRenderer($renderer) {
if(ClassInfo::classImplements($renderer, 'IMarkdownRenderer')) {
self::$renderer=$renderer;
}else {
user_error('The renderer '.$renderer.' does not implement IMarkdownRenderer', E_USER_ERROR);
}
} | [
"public",
"static",
"function",
"setRenderer",
"(",
"$",
"renderer",
")",
"{",
"if",
"(",
"ClassInfo",
"::",
"classImplements",
"(",
"$",
"renderer",
",",
"'IMarkdownRenderer'",
")",
")",
"{",
"self",
"::",
"$",
"renderer",
"=",
"$",
"renderer",
";",
"}",
... | Sets the renderer for markdown fields to use
@param {string} $renderer Class Name of an implementation of IMarkdownRenderer | [
"Sets",
"the",
"renderer",
"for",
"markdown",
"fields",
"to",
"use"
] | e55d8478733dfdc1e8ba43dc536c3e029ad0b83d | https://github.com/UndefinedOffset/silverstripe-markdown/blob/e55d8478733dfdc1e8ba43dc536c3e029ad0b83d/code/model/fieldtypes/Markdown.php#L90-L96 | train |
UndefinedOffset/silverstripe-markdown | code/model/fieldtypes/Markdown.php | Markdown.getRenderer | private function getRenderer() {
if(!is_object($this->renderInst)) {
$class=self::$renderer;
$this->renderInst=new $class();
}
return $this->renderInst;
} | php | private function getRenderer() {
if(!is_object($this->renderInst)) {
$class=self::$renderer;
$this->renderInst=new $class();
}
return $this->renderInst;
} | [
"private",
"function",
"getRenderer",
"(",
")",
"{",
"if",
"(",
"!",
"is_object",
"(",
"$",
"this",
"->",
"renderInst",
")",
")",
"{",
"$",
"class",
"=",
"self",
"::",
"$",
"renderer",
";",
"$",
"this",
"->",
"renderInst",
"=",
"new",
"$",
"class",
... | Gets the active mardown renderer
@return {IMarkdownRenderer} An implementation of IMarkdownRenderer | [
"Gets",
"the",
"active",
"mardown",
"renderer"
] | e55d8478733dfdc1e8ba43dc536c3e029ad0b83d | https://github.com/UndefinedOffset/silverstripe-markdown/blob/e55d8478733dfdc1e8ba43dc536c3e029ad0b83d/code/model/fieldtypes/Markdown.php#L102-L109 | train |
meritoo/common-bundle | src/Bundle/Descriptors.php | Descriptors.getDescriptor | public function getDescriptor(string $classNamespace): ?Descriptor
{
if (!$this->isEmpty()) {
/** @var Descriptor $descriptor */
foreach ($this as $rootNamespace => $descriptor) {
$rootNamespace = $descriptor->getRootNamespace();
$doubleSlashed = str_replace('\\', '\\\\', $rootNamespace);
$pattern = sprintf('|^%s\\.*|', $doubleSlashed);
if (preg_match($pattern, $classNamespace)) {
return $descriptor;
}
}
}
return null;
} | php | public function getDescriptor(string $classNamespace): ?Descriptor
{
if (!$this->isEmpty()) {
/** @var Descriptor $descriptor */
foreach ($this as $rootNamespace => $descriptor) {
$rootNamespace = $descriptor->getRootNamespace();
$doubleSlashed = str_replace('\\', '\\\\', $rootNamespace);
$pattern = sprintf('|^%s\\.*|', $doubleSlashed);
if (preg_match($pattern, $classNamespace)) {
return $descriptor;
}
}
}
return null;
} | [
"public",
"function",
"getDescriptor",
"(",
"string",
"$",
"classNamespace",
")",
":",
"?",
"Descriptor",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"/** @var Descriptor $descriptor */",
"foreach",
"(",
"$",
"this",
"as",
"$",
"... | Returns descriptor of bundle that contains given class
@param string $classNamespace Namespace of class for which descriptor of bundle should be returned
@return null|Descriptor | [
"Returns",
"descriptor",
"of",
"bundle",
"that",
"contains",
"given",
"class"
] | 560c3a6c14fce2e17208261b8c606f6208f44e23 | https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Bundle/Descriptors.php#L30-L47 | train |
meritoo/common-bundle | src/Bundle/Descriptors.php | Descriptors.getDescriptorByName | public function getDescriptorByName(string $bundleName): ?Descriptor
{
if (!$this->isEmpty()) {
/** @var Descriptor $descriptor */
foreach ($this as $rootNamespace => $descriptor) {
$name = $descriptor->getName();
if ($bundleName === $name) {
return $descriptor;
}
}
}
return null;
} | php | public function getDescriptorByName(string $bundleName): ?Descriptor
{
if (!$this->isEmpty()) {
/** @var Descriptor $descriptor */
foreach ($this as $rootNamespace => $descriptor) {
$name = $descriptor->getName();
if ($bundleName === $name) {
return $descriptor;
}
}
}
return null;
} | [
"public",
"function",
"getDescriptorByName",
"(",
"string",
"$",
"bundleName",
")",
":",
"?",
"Descriptor",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isEmpty",
"(",
")",
")",
"{",
"/** @var Descriptor $descriptor */",
"foreach",
"(",
"$",
"this",
"as",
"$",
... | Returns descriptor of bundle with given name
@param string $bundleName Name of bundle who descriptor should be returned
@return null|Descriptor | [
"Returns",
"descriptor",
"of",
"bundle",
"with",
"given",
"name"
] | 560c3a6c14fce2e17208261b8c606f6208f44e23 | https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Bundle/Descriptors.php#L55-L69 | train |
meritoo/common-bundle | src/Bundle/Descriptors.php | Descriptors.fromArray | public static function fromArray(array $data): Descriptors
{
$descriptors = new static();
if (!empty($data)) {
foreach ($data as $descriptorData) {
$descriptor = Descriptor::fromArray($descriptorData);
$rootNamespace = $descriptor->getRootNamespace();
$descriptors->add($descriptor, $rootNamespace);
}
}
return $descriptors;
} | php | public static function fromArray(array $data): Descriptors
{
$descriptors = new static();
if (!empty($data)) {
foreach ($data as $descriptorData) {
$descriptor = Descriptor::fromArray($descriptorData);
$rootNamespace = $descriptor->getRootNamespace();
$descriptors->add($descriptor, $rootNamespace);
}
}
return $descriptors;
} | [
"public",
"static",
"function",
"fromArray",
"(",
"array",
"$",
"data",
")",
":",
"Descriptors",
"{",
"$",
"descriptors",
"=",
"new",
"static",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
")",
")",
"{",
"foreach",
"(",
"$",
"data",
"a... | Returns the descriptors created from given data
@param array $data Data of descriptors
@return Descriptors | [
"Returns",
"the",
"descriptors",
"created",
"from",
"given",
"data"
] | 560c3a6c14fce2e17208261b8c606f6208f44e23 | https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Bundle/Descriptors.php#L96-L110 | train |
UndefinedOffset/silverstripe-markdown | code/forms/MarkdownEditor.php | MarkdownEditor.FieldHolder | public function FieldHolder($properties=array()) {
$this->extraClasses['stacked']='stacked';
Requirements::css(MARKDOWN_MODULE_BASE.'/css/MarkdownEditor.css');
Requirements::javascript(MARKDOWN_MODULE_BASE.'/javascript/external/ace/ace.js');
Requirements::javascript(MARKDOWN_MODULE_BASE.'/javascript/external/ace/mode-markdown.js');
Requirements::javascript(MARKDOWN_MODULE_BASE.'/javascript/external/ace/theme-textmate.js');
Requirements::javascript(MARKDOWN_MODULE_BASE.'/javascript/external/ace/theme-twilight.js');
Requirements::javascript(MARKDOWN_MODULE_BASE.'/javascript/MarkdownEditor.js');
return parent::FieldHolder($properties);
} | php | public function FieldHolder($properties=array()) {
$this->extraClasses['stacked']='stacked';
Requirements::css(MARKDOWN_MODULE_BASE.'/css/MarkdownEditor.css');
Requirements::javascript(MARKDOWN_MODULE_BASE.'/javascript/external/ace/ace.js');
Requirements::javascript(MARKDOWN_MODULE_BASE.'/javascript/external/ace/mode-markdown.js');
Requirements::javascript(MARKDOWN_MODULE_BASE.'/javascript/external/ace/theme-textmate.js');
Requirements::javascript(MARKDOWN_MODULE_BASE.'/javascript/external/ace/theme-twilight.js');
Requirements::javascript(MARKDOWN_MODULE_BASE.'/javascript/MarkdownEditor.js');
return parent::FieldHolder($properties);
} | [
"public",
"function",
"FieldHolder",
"(",
"$",
"properties",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"extraClasses",
"[",
"'stacked'",
"]",
"=",
"'stacked'",
";",
"Requirements",
"::",
"css",
"(",
"MARKDOWN_MODULE_BASE",
".",
"'/css/MarkdownEditor... | Returns the field holder used by templates
@return {string} HTML to be used | [
"Returns",
"the",
"field",
"holder",
"used",
"by",
"templates"
] | e55d8478733dfdc1e8ba43dc536c3e029ad0b83d | https://github.com/UndefinedOffset/silverstripe-markdown/blob/e55d8478733dfdc1e8ba43dc536c3e029ad0b83d/code/forms/MarkdownEditor.php#L20-L32 | train |
davedevelopment/dspec | src/DSpec/Console/DSpecApplication.php | DSpecApplication.getDefaultInputDefinition | protected function getDefaultInputDefinition()
{
return new InputDefinition(array(
new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.'),
new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message.'),
new InputOption('--verbose', '-v', InputOption::VALUE_NONE, 'Increase verbosity of messages.'),
new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version.'),
new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output.'),
new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output.'),
new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question.'),
new InputOption('--config', '-c', InputOption::VALUE_REQUIRED, 'Path to a configuration file'),
new InputOption('--profile', '-p', InputOption::VALUE_REQUIRED, 'Chosen configuration profile'),
new InputOption('--bootstrap', '-b', InputOption::VALUE_REQUIRED, 'A php bootstrap file'),
));
} | php | protected function getDefaultInputDefinition()
{
return new InputDefinition(array(
new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.'),
new InputOption('--quiet', '-q', InputOption::VALUE_NONE, 'Do not output any message.'),
new InputOption('--verbose', '-v', InputOption::VALUE_NONE, 'Increase verbosity of messages.'),
new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display this application version.'),
new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output.'),
new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output.'),
new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question.'),
new InputOption('--config', '-c', InputOption::VALUE_REQUIRED, 'Path to a configuration file'),
new InputOption('--profile', '-p', InputOption::VALUE_REQUIRED, 'Chosen configuration profile'),
new InputOption('--bootstrap', '-b', InputOption::VALUE_REQUIRED, 'A php bootstrap file'),
));
} | [
"protected",
"function",
"getDefaultInputDefinition",
"(",
")",
"{",
"return",
"new",
"InputDefinition",
"(",
"array",
"(",
"new",
"InputOption",
"(",
"'--help'",
",",
"'-h'",
",",
"InputOption",
"::",
"VALUE_NONE",
",",
"'Display this help message.'",
")",
",",
"... | Gets the default input definition.
@return InputDefinition An InputDefinition instance | [
"Gets",
"the",
"default",
"input",
"definition",
"."
] | 6077b1d213dc09f1fbcf7b260f3926a7019a0618 | https://github.com/davedevelopment/dspec/blob/6077b1d213dc09f1fbcf7b260f3926a7019a0618/src/DSpec/Console/DSpecApplication.php#L149-L163 | train |
thelia-modules/FeatureType | Model/Base/FeatureTypeI18n.php | FeatureTypeI18n.getFeatureType | public function getFeatureType(ConnectionInterface $con = null)
{
if ($this->aFeatureType === null && ($this->id !== null)) {
$this->aFeatureType = ChildFeatureTypeQuery::create()->findPk($this->id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aFeatureType->addFeatureTypeI18ns($this);
*/
}
return $this->aFeatureType;
} | php | public function getFeatureType(ConnectionInterface $con = null)
{
if ($this->aFeatureType === null && ($this->id !== null)) {
$this->aFeatureType = ChildFeatureTypeQuery::create()->findPk($this->id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aFeatureType->addFeatureTypeI18ns($this);
*/
}
return $this->aFeatureType;
} | [
"public",
"function",
"getFeatureType",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aFeatureType",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"id",
"!==",
"null",
")",
")",
"{",
"$",
"this",
"->",
"... | Get the associated ChildFeatureType object
@param ConnectionInterface $con Optional Connection object.
@return ChildFeatureType The associated ChildFeatureType object.
@throws PropelException | [
"Get",
"the",
"associated",
"ChildFeatureType",
"object"
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeI18n.php#L1148-L1162 | train |
shardimage/shardimage-php | src/helpers/LoggerHelper.php | LoggerHelper.replaceBinaryStrings | public static function replaceBinaryStrings($message)
{
$lines = explode("\r\n", $message);
foreach ($lines as &$line) {
if (!mb_check_encoding($line, 'utf-8')) {
$line = '<' . strlen($line) . ' bytes binary content>';
}
}
return implode("\r\n", $lines);
} | php | public static function replaceBinaryStrings($message)
{
$lines = explode("\r\n", $message);
foreach ($lines as &$line) {
if (!mb_check_encoding($line, 'utf-8')) {
$line = '<' . strlen($line) . ' bytes binary content>';
}
}
return implode("\r\n", $lines);
} | [
"public",
"static",
"function",
"replaceBinaryStrings",
"(",
"$",
"message",
")",
"{",
"$",
"lines",
"=",
"explode",
"(",
"\"\\r\\n\"",
",",
"$",
"message",
")",
";",
"foreach",
"(",
"$",
"lines",
"as",
"&",
"$",
"line",
")",
"{",
"if",
"(",
"!",
"mb... | Replaces the lines containing binary strings with a human readable replacement.
@param string $message
@return string | [
"Replaces",
"the",
"lines",
"containing",
"binary",
"strings",
"with",
"a",
"human",
"readable",
"replacement",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/helpers/LoggerHelper.php#L61-L72 | train |
scherersoftware/cake-cktools | src/Utility/UserToken.php | UserToken.getTokenForUser | public function getTokenForUser(User $user, int $validForSeconds = null, array $additionalData = []): string
{
$tokenData = [
'user_id' => $user->id,
'generated' => time(),
'validForSeconds' => $validForSeconds,
'additionalData' => $additionalData,
];
$tokenDataString = serialize($tokenData);
$encrypted = Security::encrypt($tokenDataString, Configure::read('Security.cryptKey'));
return base64_encode($encrypted);
} | php | public function getTokenForUser(User $user, int $validForSeconds = null, array $additionalData = []): string
{
$tokenData = [
'user_id' => $user->id,
'generated' => time(),
'validForSeconds' => $validForSeconds,
'additionalData' => $additionalData,
];
$tokenDataString = serialize($tokenData);
$encrypted = Security::encrypt($tokenDataString, Configure::read('Security.cryptKey'));
return base64_encode($encrypted);
} | [
"public",
"function",
"getTokenForUser",
"(",
"User",
"$",
"user",
",",
"int",
"$",
"validForSeconds",
"=",
"null",
",",
"array",
"$",
"additionalData",
"=",
"[",
"]",
")",
":",
"string",
"{",
"$",
"tokenData",
"=",
"[",
"'user_id'",
"=>",
"$",
"user",
... | Generates a serialized, encrypted and base64-encoded for identifying a user,
usually for using it in an URL
@param \App\Model\Entity\User $user The user Entity
@param int $validForSeconds how long the token should be valid
@param array $additionalData Optional additional data for storage in the encrypted token
@return string | [
"Generates",
"a",
"serialized",
"encrypted",
"and",
"base64",
"-",
"encoded",
"for",
"identifying",
"a",
"user",
"usually",
"for",
"using",
"it",
"in",
"an",
"URL"
] | efba42cf4e1804df8f1faa83ef75927bee6c206b | https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Utility/UserToken.php#L21-L33 | train |
scherersoftware/cake-cktools | src/Utility/UserToken.php | UserToken.isTokenValid | public function isTokenValid(string $token): bool
{
$tokenData = $this->decryptToken($token);
return is_array($tokenData)
&& isset(
$tokenData['user_id'],
$tokenData['generated'],
$tokenData['validForSeconds']
);
} | php | public function isTokenValid(string $token): bool
{
$tokenData = $this->decryptToken($token);
return is_array($tokenData)
&& isset(
$tokenData['user_id'],
$tokenData['generated'],
$tokenData['validForSeconds']
);
} | [
"public",
"function",
"isTokenValid",
"(",
"string",
"$",
"token",
")",
":",
"bool",
"{",
"$",
"tokenData",
"=",
"$",
"this",
"->",
"decryptToken",
"(",
"$",
"token",
")",
";",
"return",
"is_array",
"(",
"$",
"tokenData",
")",
"&&",
"isset",
"(",
"$",
... | Checks if the given token is valid, meaning it is valid by format. This method
does not check the validity
@param string $token The string token
@return bool | [
"Checks",
"if",
"the",
"given",
"token",
"is",
"valid",
"meaning",
"it",
"is",
"valid",
"by",
"format",
".",
"This",
"method",
"does",
"not",
"check",
"the",
"validity"
] | efba42cf4e1804df8f1faa83ef75927bee6c206b | https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Utility/UserToken.php#L42-L52 | train |
scherersoftware/cake-cktools | src/Utility/UserToken.php | UserToken.isTokenExpired | public function isTokenExpired(string $token): bool
{
if (!$this->isTokenValid($token)) {
throw new \InvalidArgumentException('This token is invalid');
}
$tokenData = $this->decryptToken($token);
$tokenExpiration = $tokenData['generated'] + $tokenData['validForSeconds'];
return $tokenExpiration < time();
} | php | public function isTokenExpired(string $token): bool
{
if (!$this->isTokenValid($token)) {
throw new \InvalidArgumentException('This token is invalid');
}
$tokenData = $this->decryptToken($token);
$tokenExpiration = $tokenData['generated'] + $tokenData['validForSeconds'];
return $tokenExpiration < time();
} | [
"public",
"function",
"isTokenExpired",
"(",
"string",
"$",
"token",
")",
":",
"bool",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isTokenValid",
"(",
"$",
"token",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'This token is invalid'",... | Checks if the given token is expired
@param string $token String token
@return bool
@throws \InvalidArgumentException | [
"Checks",
"if",
"the",
"given",
"token",
"is",
"expired"
] | efba42cf4e1804df8f1faa83ef75927bee6c206b | https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Utility/UserToken.php#L61-L70 | train |
scherersoftware/cake-cktools | src/Utility/UserToken.php | UserToken.getUserIdFromToken | public function getUserIdFromToken(string $token): string
{
if (!$this->isTokenValid($token)) {
throw new \InvalidArgumentException('This token is invalid');
}
$tokenData = $this->decryptToken($token);
return $tokenData['user_id'];
} | php | public function getUserIdFromToken(string $token): string
{
if (!$this->isTokenValid($token)) {
throw new \InvalidArgumentException('This token is invalid');
}
$tokenData = $this->decryptToken($token);
return $tokenData['user_id'];
} | [
"public",
"function",
"getUserIdFromToken",
"(",
"string",
"$",
"token",
")",
":",
"string",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isTokenValid",
"(",
"$",
"token",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'This token is inva... | Returns the user id from the given token
@param string $token The string token
@return string
@throws \InvalidArgumentException | [
"Returns",
"the",
"user",
"id",
"from",
"the",
"given",
"token"
] | efba42cf4e1804df8f1faa83ef75927bee6c206b | https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Utility/UserToken.php#L79-L87 | train |
scherersoftware/cake-cktools | src/Utility/UserToken.php | UserToken.decryptToken | public function decryptToken(string $token)
{
$tokenData = false;
$encrypted = base64_decode($token);
if ($encrypted) {
$serialized = Security::decrypt($encrypted, Configure::read('Security.cryptKey'));
$tokenData = unserialize($serialized);
}
return $tokenData;
} | php | public function decryptToken(string $token)
{
$tokenData = false;
$encrypted = base64_decode($token);
if ($encrypted) {
$serialized = Security::decrypt($encrypted, Configure::read('Security.cryptKey'));
$tokenData = unserialize($serialized);
}
return $tokenData;
} | [
"public",
"function",
"decryptToken",
"(",
"string",
"$",
"token",
")",
"{",
"$",
"tokenData",
"=",
"false",
";",
"$",
"encrypted",
"=",
"base64_decode",
"(",
"$",
"token",
")",
";",
"if",
"(",
"$",
"encrypted",
")",
"{",
"$",
"serialized",
"=",
"Secur... | Tries to decode, decrypt and unserialize the given token and return the data as an
array
@param string $token The string token
@return array|false | [
"Tries",
"to",
"decode",
"decrypt",
"and",
"unserialize",
"the",
"given",
"token",
"and",
"return",
"the",
"data",
"as",
"an",
"array"
] | efba42cf4e1804df8f1faa83ef75927bee6c206b | https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Utility/UserToken.php#L96-L107 | train |
JantaoDev/SitemapBundle | EventListener/ConfigSitemapListener.php | ConfigSitemapListener.getUrlFromConfiguration | protected function getUrlFromConfiguration($routeName, $configuration, $item = null)
{
foreach ($configuration['route_parameters'] as $key=>$parameter) {
$configuration['route_parameters'][$key] = $this->getItemParameter($item, $parameter);
}
$url = $this->router->generate($routeName, $configuration['route_parameters']);
$urlObject = new Url(
$url,
(isset($configuration['last_mod']) ? $this->getItemParameter($item, $configuration['last_mod']) : null),
(isset($configuration['priority']) ? $this->getItemParameter($item, $configuration['priority']) : null),
(isset($configuration['change_freq']) ? $this->getItemParameter($item, $configuration['change_freq']) : null)
);
return $urlObject;
} | php | protected function getUrlFromConfiguration($routeName, $configuration, $item = null)
{
foreach ($configuration['route_parameters'] as $key=>$parameter) {
$configuration['route_parameters'][$key] = $this->getItemParameter($item, $parameter);
}
$url = $this->router->generate($routeName, $configuration['route_parameters']);
$urlObject = new Url(
$url,
(isset($configuration['last_mod']) ? $this->getItemParameter($item, $configuration['last_mod']) : null),
(isset($configuration['priority']) ? $this->getItemParameter($item, $configuration['priority']) : null),
(isset($configuration['change_freq']) ? $this->getItemParameter($item, $configuration['change_freq']) : null)
);
return $urlObject;
} | [
"protected",
"function",
"getUrlFromConfiguration",
"(",
"$",
"routeName",
",",
"$",
"configuration",
",",
"$",
"item",
"=",
"null",
")",
"{",
"foreach",
"(",
"$",
"configuration",
"[",
"'route_parameters'",
"]",
"as",
"$",
"key",
"=>",
"$",
"parameter",
")"... | Create URL object from route configuration
@param string $routeName
@param array $configuration
@param object|array $item
@return Url | [
"Create",
"URL",
"object",
"from",
"route",
"configuration"
] | be21aafc2384d0430ee566bc8cec84de4a45ab03 | https://github.com/JantaoDev/SitemapBundle/blob/be21aafc2384d0430ee566bc8cec84de4a45ab03/EventListener/ConfigSitemapListener.php#L125-L140 | train |
meritoo/common-bundle | src/Service/RequestService.php | RequestService.storeRefererUrl | public function storeRefererUrl(string $url): RequestService
{
$this->session->set($this->refererUrlKey, $url);
return $this;
} | php | public function storeRefererUrl(string $url): RequestService
{
$this->session->set($this->refererUrlKey, $url);
return $this;
} | [
"public",
"function",
"storeRefererUrl",
"(",
"string",
"$",
"url",
")",
":",
"RequestService",
"{",
"$",
"this",
"->",
"session",
"->",
"set",
"(",
"$",
"this",
"->",
"refererUrlKey",
",",
"$",
"url",
")",
";",
"return",
"$",
"this",
";",
"}"
] | Stores url of referer in session
@param string $url Url of referer to store
@return RequestService | [
"Stores",
"url",
"of",
"referer",
"in",
"session"
] | 560c3a6c14fce2e17208261b8c606f6208f44e23 | https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Service/RequestService.php#L65-L70 | train |
meritoo/common-bundle | src/Service/RequestService.php | RequestService.storeRefererUrlFromRequest | public function storeRefererUrlFromRequest(Request $request): RequestService
{
$url = $this->getRefererUrl($request);
/*
* No referer?
* Nothing to do
*/
if ('' === $url) {
return $this;
}
return $this->storeRefererUrl($url);
} | php | public function storeRefererUrlFromRequest(Request $request): RequestService
{
$url = $this->getRefererUrl($request);
/*
* No referer?
* Nothing to do
*/
if ('' === $url) {
return $this;
}
return $this->storeRefererUrl($url);
} | [
"public",
"function",
"storeRefererUrlFromRequest",
"(",
"Request",
"$",
"request",
")",
":",
"RequestService",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"getRefererUrl",
"(",
"$",
"request",
")",
";",
"/*\n * No referer?\n * Nothing to do\n */",
... | Stores the referer url in session grabbed from given request
@param Request $request The request (that probably contains referer)
@return RequestService | [
"Stores",
"the",
"referer",
"url",
"in",
"session",
"grabbed",
"from",
"given",
"request"
] | 560c3a6c14fce2e17208261b8c606f6208f44e23 | https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Service/RequestService.php#L78-L91 | train |
meritoo/common-bundle | src/Service/RequestService.php | RequestService.fetchRefererUrl | public function fetchRefererUrl(): string
{
$url = $this->session->get($this->refererUrlKey, '');
$this->session->remove($this->refererUrlKey);
return $url;
} | php | public function fetchRefererUrl(): string
{
$url = $this->session->get($this->refererUrlKey, '');
$this->session->remove($this->refererUrlKey);
return $url;
} | [
"public",
"function",
"fetchRefererUrl",
"(",
")",
":",
"string",
"{",
"$",
"url",
"=",
"$",
"this",
"->",
"session",
"->",
"get",
"(",
"$",
"this",
"->",
"refererUrlKey",
",",
"''",
")",
";",
"$",
"this",
"->",
"session",
"->",
"remove",
"(",
"$",
... | Fetches url of referer and removes it from session
@return string | [
"Fetches",
"url",
"of",
"referer",
"and",
"removes",
"it",
"from",
"session"
] | 560c3a6c14fce2e17208261b8c606f6208f44e23 | https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/Service/RequestService.php#L98-L104 | train |
widoz/wordpress-model | src/Utils/Assert.php | Assert.isAttachment | public static function isAttachment(WP_Post $post, string $message = null): void
{
$postType = $post->post_type;
'attachment' === $postType or static::reportInvalidArgument(
$message ?: "Expected Post be an Attachment. Type of {$postType} Given."
);
} | php | public static function isAttachment(WP_Post $post, string $message = null): void
{
$postType = $post->post_type;
'attachment' === $postType or static::reportInvalidArgument(
$message ?: "Expected Post be an Attachment. Type of {$postType} Given."
);
} | [
"public",
"static",
"function",
"isAttachment",
"(",
"WP_Post",
"$",
"post",
",",
"string",
"$",
"message",
"=",
"null",
")",
":",
"void",
"{",
"$",
"postType",
"=",
"$",
"post",
"->",
"post_type",
";",
"'attachment'",
"===",
"$",
"postType",
"or",
"stat... | Assert a WP_Post Entity is an Attachment
@param WP_Post $post
@param string|null $message
@throws InvalidArgumentException | [
"Assert",
"a",
"WP_Post",
"Entity",
"is",
"an",
"Attachment"
] | 273301de4b6946144b285c235aea0d79b867244c | https://github.com/widoz/wordpress-model/blob/273301de4b6946144b285c235aea0d79b867244c/src/Utils/Assert.php#L33-L39 | train |
meritoo/common-bundle | src/DependencyInjection/Base/BaseExtension.php | BaseExtension.getFileLoader | private function getFileLoader(ContainerBuilder $container, FileLocator $locator, string $fileType): ?FileLoader
{
$loader = null;
switch ($fileType) {
case ConfigurationFileType::YAML:
$loader = new YamlFileLoader($container, $locator);
break;
case ConfigurationFileType::XML:
$loader = new XmlFileLoader($container, $locator);
break;
case ConfigurationFileType::PHP:
$loader = new PhpFileLoader($container, $locator);
break;
}
return $loader;
} | php | private function getFileLoader(ContainerBuilder $container, FileLocator $locator, string $fileType): ?FileLoader
{
$loader = null;
switch ($fileType) {
case ConfigurationFileType::YAML:
$loader = new YamlFileLoader($container, $locator);
break;
case ConfigurationFileType::XML:
$loader = new XmlFileLoader($container, $locator);
break;
case ConfigurationFileType::PHP:
$loader = new PhpFileLoader($container, $locator);
break;
}
return $loader;
} | [
"private",
"function",
"getFileLoader",
"(",
"ContainerBuilder",
"$",
"container",
",",
"FileLocator",
"$",
"locator",
",",
"string",
"$",
"fileType",
")",
":",
"?",
"FileLoader",
"{",
"$",
"loader",
"=",
"null",
";",
"switch",
"(",
"$",
"fileType",
")",
"... | Returns loader of the configuration file
@param ContainerBuilder $container Container for the Dependency Injection (DI)
@param FileLocator $locator Locator used to find files
@param string $fileType Type of the configuration file
@return null|FileLoader | [
"Returns",
"loader",
"of",
"the",
"configuration",
"file"
] | 560c3a6c14fce2e17208261b8c606f6208f44e23 | https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/DependencyInjection/Base/BaseExtension.php#L249-L269 | train |
meritoo/common-bundle | src/DependencyInjection/Base/BaseExtension.php | BaseExtension.loadParameters | private function loadParameters(array $mergedConfig, ContainerBuilder $container): BaseExtension
{
/*
* No configuration?
* Nothing to do
*/
if (empty($mergedConfig)) {
return $this;
}
// Getting the keys or paths on which building names of parameters should stop
$keysToStop = $this->getKeysToStopLoadingParametersOn();
$globalKeysToStop = $this->getGlobalKeysToStopLoadingParametersOn();
// Merging standard with global keys and paths
$keysToStop = Arrays::makeArray($keysToStop);
$globalKeysToStop = Arrays::makeArray($globalKeysToStop);
$stopIfMatchedBy = array_merge($keysToStop, $globalKeysToStop);
// Let's get the last elements' paths and load values into container
$parameters = Arrays::getLastElementsPaths($mergedConfig, '.', '', $stopIfMatchedBy);
/** @var ConfigurationInterface $configuration */
$configuration = $this->getConfiguration($mergedConfig, $container);
// Getting slug of bundle's name
$bundleShortName = $configuration
->getConfigTreeBuilder()
->buildTree()
->getName()
;
foreach ($parameters as $name => $value) {
if (!\is_array($value)) {
$value = Miscellaneous::trimSmart($value);
}
// Loading parameter into container, prefixed by slug of bundle's name
$prefixedName = sprintf('%s.%s', $bundleShortName, $name);
$container->setParameter($prefixedName, $value); // e.g. simple_bundle.foo.bar.something => 'my-value'
}
return $this;
} | php | private function loadParameters(array $mergedConfig, ContainerBuilder $container): BaseExtension
{
/*
* No configuration?
* Nothing to do
*/
if (empty($mergedConfig)) {
return $this;
}
// Getting the keys or paths on which building names of parameters should stop
$keysToStop = $this->getKeysToStopLoadingParametersOn();
$globalKeysToStop = $this->getGlobalKeysToStopLoadingParametersOn();
// Merging standard with global keys and paths
$keysToStop = Arrays::makeArray($keysToStop);
$globalKeysToStop = Arrays::makeArray($globalKeysToStop);
$stopIfMatchedBy = array_merge($keysToStop, $globalKeysToStop);
// Let's get the last elements' paths and load values into container
$parameters = Arrays::getLastElementsPaths($mergedConfig, '.', '', $stopIfMatchedBy);
/** @var ConfigurationInterface $configuration */
$configuration = $this->getConfiguration($mergedConfig, $container);
// Getting slug of bundle's name
$bundleShortName = $configuration
->getConfigTreeBuilder()
->buildTree()
->getName()
;
foreach ($parameters as $name => $value) {
if (!\is_array($value)) {
$value = Miscellaneous::trimSmart($value);
}
// Loading parameter into container, prefixed by slug of bundle's name
$prefixedName = sprintf('%s.%s', $bundleShortName, $name);
$container->setParameter($prefixedName, $value); // e.g. simple_bundle.foo.bar.something => 'my-value'
}
return $this;
} | [
"private",
"function",
"loadParameters",
"(",
"array",
"$",
"mergedConfig",
",",
"ContainerBuilder",
"$",
"container",
")",
":",
"BaseExtension",
"{",
"/*\n * No configuration?\n * Nothing to do\n */",
"if",
"(",
"empty",
"(",
"$",
"mergedConfig",
... | Loads parameters into container
@param array $mergedConfig Custom configuration merged with defaults
@param ContainerBuilder $container Container for the Dependency Injection (DI)
@return BaseExtension | [
"Loads",
"parameters",
"into",
"container"
] | 560c3a6c14fce2e17208261b8c606f6208f44e23 | https://github.com/meritoo/common-bundle/blob/560c3a6c14fce2e17208261b8c606f6208f44e23/src/DependencyInjection/Base/BaseExtension.php#L278-L321 | train |
Speelpenning-nl/laravel-authentication | src/Http/Controllers/SessionController.php | SessionController.create | public function create()
{
try {
$this->dispatch(new AttemptRememberingUser());
return redirect()->intended($this->config->get('authentication.login.redirectUri'));
} catch (RememberingUserFailed $e) {
return view('authentication::session.create');
}
} | php | public function create()
{
try {
$this->dispatch(new AttemptRememberingUser());
return redirect()->intended($this->config->get('authentication.login.redirectUri'));
} catch (RememberingUserFailed $e) {
return view('authentication::session.create');
}
} | [
"public",
"function",
"create",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"dispatch",
"(",
"new",
"AttemptRememberingUser",
"(",
")",
")",
";",
"return",
"redirect",
"(",
")",
"->",
"intended",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
... | Attempts to authenticate by remember token. When remembering fails the login form is shown.
@return RedirectResponse|View | [
"Attempts",
"to",
"authenticate",
"by",
"remember",
"token",
".",
"When",
"remembering",
"fails",
"the",
"login",
"form",
"is",
"shown",
"."
] | 44671afa8d654a9c6281cce13353d95126478d8b | https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Http/Controllers/SessionController.php#L43-L51 | train |
Speelpenning-nl/laravel-authentication | src/Http/Controllers/SessionController.php | SessionController.store | public function store(Request $request)
{
try {
$this->dispatch(new AttemptUserLogin($request->get('email'), $request->get('password'), $request->get('remember')));
return redirect()->intended($this->config->get('authentication.login.redirectUri'));
} catch (LoginFailed $e) {
return redirect()->back()->withInput()->withErrors([
'authentication::login_error' => $e->getMessage()
]);
} catch (UserIsBanned $e) {
return redirect()->back()->withInput()->withErrors([
'authentication::login_error' => $e->getMessage()
]);
}
} | php | public function store(Request $request)
{
try {
$this->dispatch(new AttemptUserLogin($request->get('email'), $request->get('password'), $request->get('remember')));
return redirect()->intended($this->config->get('authentication.login.redirectUri'));
} catch (LoginFailed $e) {
return redirect()->back()->withInput()->withErrors([
'authentication::login_error' => $e->getMessage()
]);
} catch (UserIsBanned $e) {
return redirect()->back()->withInput()->withErrors([
'authentication::login_error' => $e->getMessage()
]);
}
} | [
"public",
"function",
"store",
"(",
"Request",
"$",
"request",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"dispatch",
"(",
"new",
"AttemptUserLogin",
"(",
"$",
"request",
"->",
"get",
"(",
"'email'",
")",
",",
"$",
"request",
"->",
"get",
"(",
"'password... | Attempts to login the user.
@param Request $request
@return RedirectResponse | [
"Attempts",
"to",
"login",
"the",
"user",
"."
] | 44671afa8d654a9c6281cce13353d95126478d8b | https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Http/Controllers/SessionController.php#L59-L73 | train |
Speelpenning-nl/laravel-authentication | src/Http/Controllers/SessionController.php | SessionController.destroy | public function destroy()
{
try {
$this->dispatch(new PerformUserLogout());
return redirect($this->config->get('authentication.logout.redirectUri'));
} catch (SessionHasExpired $e) {
return redirect()->route('authentication::session.create')->withErrors([
'authentication::login_warning' => $e->getMessage()
]);
}
} | php | public function destroy()
{
try {
$this->dispatch(new PerformUserLogout());
return redirect($this->config->get('authentication.logout.redirectUri'));
} catch (SessionHasExpired $e) {
return redirect()->route('authentication::session.create')->withErrors([
'authentication::login_warning' => $e->getMessage()
]);
}
} | [
"public",
"function",
"destroy",
"(",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"dispatch",
"(",
"new",
"PerformUserLogout",
"(",
")",
")",
";",
"return",
"redirect",
"(",
"$",
"this",
"->",
"config",
"->",
"get",
"(",
"'authentication.logout.redirectUri'",
... | Attempts to log off the user.
@return RedirectResponse | [
"Attempts",
"to",
"log",
"off",
"the",
"user",
"."
] | 44671afa8d654a9c6281cce13353d95126478d8b | https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Http/Controllers/SessionController.php#L80-L90 | train |
kassko/data-mapper | src/ClassMetadataLoader/ArrayLoader.php | ArrayLoader.loadSource | private function loadSource(Model\Source $sourceModel, array $sourceData)
{
$sourceModel
->setId($sourceData['id'])
->setMethod(new Model\Method($sourceData['class'], $sourceData['method'], $sourceData['args']))
->setLazyLoading($sourceData['lazyLoading'])
->setSupplySeveralFields($sourceData['supplySeveralFields'])
->setOnFail($sourceData['onFail'])
->setExceptionClass($sourceData['exceptionClass'])
->setBadReturnValue($sourceData['badReturnValue'])
->setFallbackSourceId($sourceData['fallbackSourceId'])
->setDepends($sourceData['depends'])
;
if (isset($sourceData['preprocessor']['method'])) {
$sourceModel->addPreprocessor(
new Model\Method(
$sourceData['preprocessor']['class'],
$sourceData['preprocessor']['method'],
$sourceData['preprocessor']['args']
)
);
} elseif (isset($sourceData['preprocessors'])) {
foreach ($sourceData['preprocessors'] as $preprocessor) {
$sourceModel->addPreprocessor(
new Model\Method(
$preprocessor['class'],
$preprocessor['method'],
$preprocessor['args']
)
);
}
}
if (isset($sourceData['processor']['method'])) {
$sourceModel->addProcessor(
new Model\Method(
$sourceData['processor']['class'],
$sourceData['processor']['method'],
$sourceData['processor']['args']
)
);
} elseif (isset($sourceData['processors'])) {
foreach ($sourceData['processors'] as $processor) {
$sourceModel->addProcessor(
new Model\Method(
$processor['class'],
$processor['method'],
$processor['args']
)
);
}
}
return $sourceModel;
} | php | private function loadSource(Model\Source $sourceModel, array $sourceData)
{
$sourceModel
->setId($sourceData['id'])
->setMethod(new Model\Method($sourceData['class'], $sourceData['method'], $sourceData['args']))
->setLazyLoading($sourceData['lazyLoading'])
->setSupplySeveralFields($sourceData['supplySeveralFields'])
->setOnFail($sourceData['onFail'])
->setExceptionClass($sourceData['exceptionClass'])
->setBadReturnValue($sourceData['badReturnValue'])
->setFallbackSourceId($sourceData['fallbackSourceId'])
->setDepends($sourceData['depends'])
;
if (isset($sourceData['preprocessor']['method'])) {
$sourceModel->addPreprocessor(
new Model\Method(
$sourceData['preprocessor']['class'],
$sourceData['preprocessor']['method'],
$sourceData['preprocessor']['args']
)
);
} elseif (isset($sourceData['preprocessors'])) {
foreach ($sourceData['preprocessors'] as $preprocessor) {
$sourceModel->addPreprocessor(
new Model\Method(
$preprocessor['class'],
$preprocessor['method'],
$preprocessor['args']
)
);
}
}
if (isset($sourceData['processor']['method'])) {
$sourceModel->addProcessor(
new Model\Method(
$sourceData['processor']['class'],
$sourceData['processor']['method'],
$sourceData['processor']['args']
)
);
} elseif (isset($sourceData['processors'])) {
foreach ($sourceData['processors'] as $processor) {
$sourceModel->addProcessor(
new Model\Method(
$processor['class'],
$processor['method'],
$processor['args']
)
);
}
}
return $sourceModel;
} | [
"private",
"function",
"loadSource",
"(",
"Model",
"\\",
"Source",
"$",
"sourceModel",
",",
"array",
"$",
"sourceData",
")",
"{",
"$",
"sourceModel",
"->",
"setId",
"(",
"$",
"sourceData",
"[",
"'id'",
"]",
")",
"->",
"setMethod",
"(",
"new",
"Model",
"\... | Hydrate a source model from raw datas.
@param Model\Source $sourceModel
@param array $sourceData
@return Model\Source | [
"Hydrate",
"a",
"source",
"model",
"from",
"raw",
"datas",
"."
] | 653b3d735977d95f6eadb3334ab8787db1dca275 | https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/ClassMetadataLoader/ArrayLoader.php#L451-L506 | train |
thelia-modules/FeatureType | Model/Base/FeatureTypeAvMetaQuery.php | FeatureTypeAvMetaQuery.filterByFeatureAvId | public function filterByFeatureAvId($featureAvId = null, $comparison = null)
{
if (is_array($featureAvId)) {
$useMinMax = false;
if (isset($featureAvId['min'])) {
$this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_AV_ID, $featureAvId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($featureAvId['max'])) {
$this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_AV_ID, $featureAvId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_AV_ID, $featureAvId, $comparison);
} | php | public function filterByFeatureAvId($featureAvId = null, $comparison = null)
{
if (is_array($featureAvId)) {
$useMinMax = false;
if (isset($featureAvId['min'])) {
$this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_AV_ID, $featureAvId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($featureAvId['max'])) {
$this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_AV_ID, $featureAvId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_AV_ID, $featureAvId, $comparison);
} | [
"public",
"function",
"filterByFeatureAvId",
"(",
"$",
"featureAvId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"featureAvId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"if",
"(",
"isset",
"(... | Filter the query on the feature_av_id column
Example usage:
<code>
$query->filterByFeatureAvId(1234); // WHERE feature_av_id = 1234
$query->filterByFeatureAvId(array(12, 34)); // WHERE feature_av_id IN (12, 34)
$query->filterByFeatureAvId(array('min' => 12)); // WHERE feature_av_id > 12
</code>
@see filterByFeatureAv()
@param mixed $featureAvId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return ChildFeatureTypeAvMetaQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"feature_av_id",
"column"
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeAvMetaQuery.php#L309-L330 | train |
thelia-modules/FeatureType | Model/Base/FeatureTypeAvMetaQuery.php | FeatureTypeAvMetaQuery.filterByFeatureFeatureTypeId | public function filterByFeatureFeatureTypeId($featureFeatureTypeId = null, $comparison = null)
{
if (is_array($featureFeatureTypeId)) {
$useMinMax = false;
if (isset($featureFeatureTypeId['min'])) {
$this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_FEATURE_TYPE_ID, $featureFeatureTypeId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($featureFeatureTypeId['max'])) {
$this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_FEATURE_TYPE_ID, $featureFeatureTypeId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_FEATURE_TYPE_ID, $featureFeatureTypeId, $comparison);
} | php | public function filterByFeatureFeatureTypeId($featureFeatureTypeId = null, $comparison = null)
{
if (is_array($featureFeatureTypeId)) {
$useMinMax = false;
if (isset($featureFeatureTypeId['min'])) {
$this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_FEATURE_TYPE_ID, $featureFeatureTypeId['min'], Criteria::GREATER_EQUAL);
$useMinMax = true;
}
if (isset($featureFeatureTypeId['max'])) {
$this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_FEATURE_TYPE_ID, $featureFeatureTypeId['max'], Criteria::LESS_EQUAL);
$useMinMax = true;
}
if ($useMinMax) {
return $this;
}
if (null === $comparison) {
$comparison = Criteria::IN;
}
}
return $this->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_FEATURE_TYPE_ID, $featureFeatureTypeId, $comparison);
} | [
"public",
"function",
"filterByFeatureFeatureTypeId",
"(",
"$",
"featureFeatureTypeId",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"featureFeatureTypeId",
")",
")",
"{",
"$",
"useMinMax",
"=",
"false",
";",
"... | Filter the query on the feature_feature_type_id column
Example usage:
<code>
$query->filterByFeatureFeatureTypeId(1234); // WHERE feature_feature_type_id = 1234
$query->filterByFeatureFeatureTypeId(array(12, 34)); // WHERE feature_feature_type_id IN (12, 34)
$query->filterByFeatureFeatureTypeId(array('min' => 12)); // WHERE feature_feature_type_id > 12
</code>
@see filterByFeatureFeatureType()
@param mixed $featureFeatureTypeId The value to use as filter.
Use scalar values for equality.
Use array values for in_array() equivalent.
Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return ChildFeatureTypeAvMetaQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"feature_feature_type_id",
"column"
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeAvMetaQuery.php#L352-L373 | train |
thelia-modules/FeatureType | Model/Base/FeatureTypeAvMetaQuery.php | FeatureTypeAvMetaQuery.filterByLocale | public function filterByLocale($locale = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($locale)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $locale)) {
$locale = str_replace('*', '%', $locale);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(FeatureTypeAvMetaTableMap::LOCALE, $locale, $comparison);
} | php | public function filterByLocale($locale = null, $comparison = null)
{
if (null === $comparison) {
if (is_array($locale)) {
$comparison = Criteria::IN;
} elseif (preg_match('/[\%\*]/', $locale)) {
$locale = str_replace('*', '%', $locale);
$comparison = Criteria::LIKE;
}
}
return $this->addUsingAlias(FeatureTypeAvMetaTableMap::LOCALE, $locale, $comparison);
} | [
"public",
"function",
"filterByLocale",
"(",
"$",
"locale",
"=",
"null",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"comparison",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"locale",
")",
")",
"{",
"$",
"comparison"... | Filter the query on the locale column
Example usage:
<code>
$query->filterByLocale('fooValue'); // WHERE locale = 'fooValue'
$query->filterByLocale('%fooValue%'); // WHERE locale LIKE '%fooValue%'
</code>
@param string $locale The value to use as filter.
Accepts wildcards (* and % trigger a LIKE)
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return ChildFeatureTypeAvMetaQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"on",
"the",
"locale",
"column"
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeAvMetaQuery.php#L390-L402 | train |
thelia-modules/FeatureType | Model/Base/FeatureTypeAvMetaQuery.php | FeatureTypeAvMetaQuery.filterByFeatureAv | public function filterByFeatureAv($featureAv, $comparison = null)
{
if ($featureAv instanceof \Thelia\Model\FeatureAv) {
return $this
->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_AV_ID, $featureAv->getId(), $comparison);
} elseif ($featureAv instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_AV_ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByFeatureAv() only accepts arguments of type \Thelia\Model\FeatureAv or Collection');
}
} | php | public function filterByFeatureAv($featureAv, $comparison = null)
{
if ($featureAv instanceof \Thelia\Model\FeatureAv) {
return $this
->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_AV_ID, $featureAv->getId(), $comparison);
} elseif ($featureAv instanceof ObjectCollection) {
if (null === $comparison) {
$comparison = Criteria::IN;
}
return $this
->addUsingAlias(FeatureTypeAvMetaTableMap::FEATURE_AV_ID, $featureAv->toKeyValue('PrimaryKey', 'Id'), $comparison);
} else {
throw new PropelException('filterByFeatureAv() only accepts arguments of type \Thelia\Model\FeatureAv or Collection');
}
} | [
"public",
"function",
"filterByFeatureAv",
"(",
"$",
"featureAv",
",",
"$",
"comparison",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"featureAv",
"instanceof",
"\\",
"Thelia",
"\\",
"Model",
"\\",
"FeatureAv",
")",
"{",
"return",
"$",
"this",
"->",
"addUsingAl... | Filter the query by a related \Thelia\Model\FeatureAv object
@param \Thelia\Model\FeatureAv|ObjectCollection $featureAv The related object(s) to use as filter
@param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
@return ChildFeatureTypeAvMetaQuery The current query, for fluid interface | [
"Filter",
"the",
"query",
"by",
"a",
"related",
"\\",
"Thelia",
"\\",
"Model",
"\\",
"FeatureAv",
"object"
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeAvMetaQuery.php#L527-L542 | train |
thelia-modules/FeatureType | Model/Base/FeatureTypeAvMetaQuery.php | FeatureTypeAvMetaQuery.useFeatureAvQuery | public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinFeatureAv($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery');
} | php | public function useFeatureAvQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinFeatureAv($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'FeatureAv', '\Thelia\Model\FeatureAvQuery');
} | [
"public",
"function",
"useFeatureAvQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinFeatureAv",
"(",
"$",
"relationAlias",
",",
"$",
"joinType",
")",
"->",
... | Use the FeatureAv relation FeatureAv object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \Thelia\Model\FeatureAvQuery A secondary query class using the current class as primary query | [
"Use",
"the",
"FeatureAv",
"relation",
"FeatureAv",
"object"
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeAvMetaQuery.php#L587-L592 | train |
thelia-modules/FeatureType | Model/Base/FeatureTypeAvMetaQuery.php | FeatureTypeAvMetaQuery.useFeatureFeatureTypeQuery | public function useFeatureFeatureTypeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinFeatureFeatureType($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'FeatureFeatureType', '\FeatureType\Model\FeatureFeatureTypeQuery');
} | php | public function useFeatureFeatureTypeQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN)
{
return $this
->joinFeatureFeatureType($relationAlias, $joinType)
->useQuery($relationAlias ? $relationAlias : 'FeatureFeatureType', '\FeatureType\Model\FeatureFeatureTypeQuery');
} | [
"public",
"function",
"useFeatureFeatureTypeQuery",
"(",
"$",
"relationAlias",
"=",
"null",
",",
"$",
"joinType",
"=",
"Criteria",
"::",
"INNER_JOIN",
")",
"{",
"return",
"$",
"this",
"->",
"joinFeatureFeatureType",
"(",
"$",
"relationAlias",
",",
"$",
"joinType... | Use the FeatureFeatureType relation FeatureFeatureType object
@see useQuery()
@param string $relationAlias optional alias for the relation,
to be used as main alias in the secondary query
@param string $joinType Accepted values are null, 'left join', 'right join', 'inner join'
@return \FeatureType\Model\FeatureFeatureTypeQuery A secondary query class using the current class as primary query | [
"Use",
"the",
"FeatureFeatureType",
"relation",
"FeatureFeatureType",
"object"
] | fc73eaaf53583758a316bb7e4af69ea50ec89997 | https://github.com/thelia-modules/FeatureType/blob/fc73eaaf53583758a316bb7e4af69ea50ec89997/Model/Base/FeatureTypeAvMetaQuery.php#L662-L667 | train |
kherge-abandoned/lib-country | src/lib/Phine/Country/Loader/Loader.php | Loader.createCountry | private function createCountry(DOMElement $element)
{
if ($element->hasAttribute('common_name')) {
$short = $element->getAttribute('common_name');
} else {
$short = $element->getAttribute('name');
}
if ($element->hasAttribute('official_name')) {
$long = $element->getAttribute('official_name');
} else {
$long = null;
}
return new Country(
$element->getAttribute('alpha_2_code'),
$element->getAttribute('alpha_3_code'),
$long,
$element->getAttribute('numeric_code'),
$short
);
} | php | private function createCountry(DOMElement $element)
{
if ($element->hasAttribute('common_name')) {
$short = $element->getAttribute('common_name');
} else {
$short = $element->getAttribute('name');
}
if ($element->hasAttribute('official_name')) {
$long = $element->getAttribute('official_name');
} else {
$long = null;
}
return new Country(
$element->getAttribute('alpha_2_code'),
$element->getAttribute('alpha_3_code'),
$long,
$element->getAttribute('numeric_code'),
$short
);
} | [
"private",
"function",
"createCountry",
"(",
"DOMElement",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"->",
"hasAttribute",
"(",
"'common_name'",
")",
")",
"{",
"$",
"short",
"=",
"$",
"element",
"->",
"getAttribute",
"(",
"'common_name'",
")",
"... | Creates a new Country using an XML element.
@param DOMElement $element An element.
@return Country A new country. | [
"Creates",
"a",
"new",
"Country",
"using",
"an",
"XML",
"element",
"."
] | 17278e939832013a3c7981b71f63ceb7480e79a1 | https://github.com/kherge-abandoned/lib-country/blob/17278e939832013a3c7981b71f63ceb7480e79a1/src/lib/Phine/Country/Loader/Loader.php#L175-L196 | train |
kherge-abandoned/lib-country | src/lib/Phine/Country/Loader/Loader.php | Loader.getCountry | private function getCountry()
{
if (null === $this->country) {
$this->country = $this->loadXml($this->countryFile);
}
return $this->country;
} | php | private function getCountry()
{
if (null === $this->country) {
$this->country = $this->loadXml($this->countryFile);
}
return $this->country;
} | [
"private",
"function",
"getCountry",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"country",
")",
"{",
"$",
"this",
"->",
"country",
"=",
"$",
"this",
"->",
"loadXml",
"(",
"$",
"this",
"->",
"countryFile",
")",
";",
"}",
"return",
"... | Returns the country XPath object.
@return DOMXPath The XPath object. | [
"Returns",
"the",
"country",
"XPath",
"object",
"."
] | 17278e939832013a3c7981b71f63ceb7480e79a1 | https://github.com/kherge-abandoned/lib-country/blob/17278e939832013a3c7981b71f63ceb7480e79a1/src/lib/Phine/Country/Loader/Loader.php#L218-L225 | train |
kherge-abandoned/lib-country | src/lib/Phine/Country/Loader/Loader.php | Loader.getSubdivision | private function getSubdivision()
{
if (null === $this->subdivision) {
$this->subdivision = $this->loadXml($this->subdivisionFile);
}
return $this->subdivision;
} | php | private function getSubdivision()
{
if (null === $this->subdivision) {
$this->subdivision = $this->loadXml($this->subdivisionFile);
}
return $this->subdivision;
} | [
"private",
"function",
"getSubdivision",
"(",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"subdivision",
")",
"{",
"$",
"this",
"->",
"subdivision",
"=",
"$",
"this",
"->",
"loadXml",
"(",
"$",
"this",
"->",
"subdivisionFile",
")",
";",
"}",... | Returns the subdivision XPath object.
@return DOMXPath The XPath object. | [
"Returns",
"the",
"subdivision",
"XPath",
"object",
"."
] | 17278e939832013a3c7981b71f63ceb7480e79a1 | https://github.com/kherge-abandoned/lib-country/blob/17278e939832013a3c7981b71f63ceb7480e79a1/src/lib/Phine/Country/Loader/Loader.php#L232-L239 | train |
kherge-abandoned/lib-country | src/lib/Phine/Country/Loader/Loader.php | Loader.loadXml | private function loadXml($file)
{
$internal = libxml_use_internal_errors(true);
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
$doc->validateOnParse = true;
if (!@$doc->load($file)) {
$errors = libxml_get_errors();
libxml_use_internal_errors($internal);
throw XmlException::createUsingErrors($errors);
}
libxml_use_internal_errors($internal);
return new DOMXPath($doc);
} | php | private function loadXml($file)
{
$internal = libxml_use_internal_errors(true);
$doc = new DOMDocument();
$doc->preserveWhiteSpace = false;
$doc->validateOnParse = true;
if (!@$doc->load($file)) {
$errors = libxml_get_errors();
libxml_use_internal_errors($internal);
throw XmlException::createUsingErrors($errors);
}
libxml_use_internal_errors($internal);
return new DOMXPath($doc);
} | [
"private",
"function",
"loadXml",
"(",
"$",
"file",
")",
"{",
"$",
"internal",
"=",
"libxml_use_internal_errors",
"(",
"true",
")",
";",
"$",
"doc",
"=",
"new",
"DOMDocument",
"(",
")",
";",
"$",
"doc",
"->",
"preserveWhiteSpace",
"=",
"false",
";",
"$",... | Loads and validates an XML document from a file for querying.
@param string $file The file path.
@return DOMXPath The XPath object for querying.
@throws XmlException If the file could not be loaded. | [
"Loads",
"and",
"validates",
"an",
"XML",
"document",
"from",
"a",
"file",
"for",
"querying",
"."
] | 17278e939832013a3c7981b71f63ceb7480e79a1 | https://github.com/kherge-abandoned/lib-country/blob/17278e939832013a3c7981b71f63ceb7480e79a1/src/lib/Phine/Country/Loader/Loader.php#L250-L269 | train |
Speelpenning-nl/laravel-authentication | src/Http/Controllers/PasswordController.php | PasswordController.update | public function update(ChangePasswordRequest $request, Guard $auth)
{
try {
$this->dispatch(new ChangePassword($auth->user()->id, $request->get('current_password'), $request->get('new_password')));
return redirect()->route('authentication::profile.show');
} catch (ValidationException $e) {
return redirect()->back()->withErrors($e->errors());
}
} | php | public function update(ChangePasswordRequest $request, Guard $auth)
{
try {
$this->dispatch(new ChangePassword($auth->user()->id, $request->get('current_password'), $request->get('new_password')));
return redirect()->route('authentication::profile.show');
} catch (ValidationException $e) {
return redirect()->back()->withErrors($e->errors());
}
} | [
"public",
"function",
"update",
"(",
"ChangePasswordRequest",
"$",
"request",
",",
"Guard",
"$",
"auth",
")",
"{",
"try",
"{",
"$",
"this",
"->",
"dispatch",
"(",
"new",
"ChangePassword",
"(",
"$",
"auth",
"->",
"user",
"(",
")",
"->",
"id",
",",
"$",
... | Attempts to update the password.
@param ChangePasswordRequest $request
@param Guard $auth
@return $this|RedirectResponse | [
"Attempts",
"to",
"update",
"the",
"password",
"."
] | 44671afa8d654a9c6281cce13353d95126478d8b | https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Http/Controllers/PasswordController.php#L44-L52 | train |
fabiomlferreira/yii2-file-manager | models/Mediafile.php | Mediafile.getOrientation | private function getOrientation($filename) {
$exif = @exif_read_data($filename);
if($exif === null)
return 0;
$rotation = 0;
if (!empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 3:
$rotation = 180;
break;
case 6:
$rotation = 90;
break;
case 8:
$rotation = -90;
break;
}
}
return $rotation;
} | php | private function getOrientation($filename) {
$exif = @exif_read_data($filename);
if($exif === null)
return 0;
$rotation = 0;
if (!empty($exif['Orientation'])) {
switch ($exif['Orientation']) {
case 3:
$rotation = 180;
break;
case 6:
$rotation = 90;
break;
case 8:
$rotation = -90;
break;
}
}
return $rotation;
} | [
"private",
"function",
"getOrientation",
"(",
"$",
"filename",
")",
"{",
"$",
"exif",
"=",
"@",
"exif_read_data",
"(",
"$",
"filename",
")",
";",
"if",
"(",
"$",
"exif",
"===",
"null",
")",
"return",
"0",
";",
"$",
"rotation",
"=",
"0",
";",
"if",
... | Return the orientation of an image
@param type $filename
@return int | [
"Return",
"the",
"orientation",
"of",
"an",
"image"
] | 45cb1919254c6e0ecb1793240395169f4fc26819 | https://github.com/fabiomlferreira/yii2-file-manager/blob/45cb1919254c6e0ecb1793240395169f4fc26819/models/Mediafile.php#L341-L360 | train |
MovingImage24/VMProApiClient | lib/ApiClient/AbstractApiClient.php | AbstractApiClient.sortChannels | protected function sortChannels(ArrayCollection $channels)
{
$channels->map(function ($channel) {
$channel->setChildren($this->sortChannels($channel->getChildren()));
});
$iterator = $channels->getIterator();
$iterator->uasort(function ($a, $b) {
return $a->getName() > $b->getName();
});
return new ArrayCollection(iterator_to_array($iterator));
} | php | protected function sortChannels(ArrayCollection $channels)
{
$channels->map(function ($channel) {
$channel->setChildren($this->sortChannels($channel->getChildren()));
});
$iterator = $channels->getIterator();
$iterator->uasort(function ($a, $b) {
return $a->getName() > $b->getName();
});
return new ArrayCollection(iterator_to_array($iterator));
} | [
"protected",
"function",
"sortChannels",
"(",
"ArrayCollection",
"$",
"channels",
")",
"{",
"$",
"channels",
"->",
"map",
"(",
"function",
"(",
"$",
"channel",
")",
"{",
"$",
"channel",
"->",
"setChildren",
"(",
"$",
"this",
"->",
"sortChannels",
"(",
"$",... | Since the VMPro API doesn't sort any more the returned channels, we have to do it on our side.
@param ArrayCollection $channels
@return ArrayCollection | [
"Since",
"the",
"VMPro",
"API",
"doesn",
"t",
"sort",
"any",
"more",
"the",
"returned",
"channels",
"we",
"have",
"to",
"do",
"it",
"on",
"our",
"side",
"."
] | e242a88a93a7a915898c888a575502c21434e35b | https://github.com/MovingImage24/VMProApiClient/blob/e242a88a93a7a915898c888a575502c21434e35b/lib/ApiClient/AbstractApiClient.php#L58-L70 | train |
FreezyBee/Httplug | src/ClientFactory/BuzzFactory.php | BuzzFactory.getOptions | private function getOptions(array $config = []): array
{
$resolver = new OptionsResolver();
$resolver->setDefaults([
'timeout' => 5,
'verify_peer' => true,
'verify_host' => 2,
'proxy' => null,
]);
$resolver->setAllowedTypes('timeout', 'int');
$resolver->setAllowedTypes('verify_peer', 'bool');
$resolver->setAllowedTypes('verify_host', 'int');
$resolver->setAllowedTypes('proxy', ['string', 'null']);
return $resolver->resolve($config);
} | php | private function getOptions(array $config = []): array
{
$resolver = new OptionsResolver();
$resolver->setDefaults([
'timeout' => 5,
'verify_peer' => true,
'verify_host' => 2,
'proxy' => null,
]);
$resolver->setAllowedTypes('timeout', 'int');
$resolver->setAllowedTypes('verify_peer', 'bool');
$resolver->setAllowedTypes('verify_host', 'int');
$resolver->setAllowedTypes('proxy', ['string', 'null']);
return $resolver->resolve($config);
} | [
"private",
"function",
"getOptions",
"(",
"array",
"$",
"config",
"=",
"[",
"]",
")",
":",
"array",
"{",
"$",
"resolver",
"=",
"new",
"OptionsResolver",
"(",
")",
";",
"$",
"resolver",
"->",
"setDefaults",
"(",
"[",
"'timeout'",
"=>",
"5",
",",
"'verif... | Get options to configure the Buzz client.
@param array $config
@return array | [
"Get",
"options",
"to",
"configure",
"the",
"Buzz",
"client",
"."
] | ca7fc60b1591588e3f9f771a4c1beb90fe56d064 | https://github.com/FreezyBee/Httplug/blob/ca7fc60b1591588e3f9f771a4c1beb90fe56d064/src/ClientFactory/BuzzFactory.php#L60-L77 | train |
digbang/security | src/Users/DoctrineUserRepository.php | DoctrineUserRepository.validForUpdate | public function validForUpdate($user, array $credentials)
{
if ($user instanceof UserInterface)
{
$user = $user->getUserId();
}
return $this->validate($credentials, $user);
} | php | public function validForUpdate($user, array $credentials)
{
if ($user instanceof UserInterface)
{
$user = $user->getUserId();
}
return $this->validate($credentials, $user);
} | [
"public",
"function",
"validForUpdate",
"(",
"$",
"user",
",",
"array",
"$",
"credentials",
")",
"{",
"if",
"(",
"$",
"user",
"instanceof",
"UserInterface",
")",
"{",
"$",
"user",
"=",
"$",
"user",
"->",
"getUserId",
"(",
")",
";",
"}",
"return",
"$",
... | Validate if the given user is valid for updating.
@param UserInterface|int $user
@param array $credentials
@return bool
@throws \InvalidArgumentException | [
"Validate",
"if",
"the",
"given",
"user",
"is",
"valid",
"for",
"updating",
"."
] | ee925c5a144a1553f5a72ded6f5a66c01a86ab21 | https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Users/DoctrineUserRepository.php#L162-L170 | train |
MovingImage24/VMProApiClient | lib/Factory/Guzzle6ApiClientFactory.php | Guzzle6ApiClientFactory.createHttpClient | public function createHttpClient($baseUri, array $middlewares = [], array $options = [])
{
$stack = HandlerStack::create();
foreach ($middlewares as $middleware) {
$stack->push($middleware);
}
return new Client(array_merge([
'base_uri' => $baseUri,
'handler' => $stack,
], $options));
} | php | public function createHttpClient($baseUri, array $middlewares = [], array $options = [])
{
$stack = HandlerStack::create();
foreach ($middlewares as $middleware) {
$stack->push($middleware);
}
return new Client(array_merge([
'base_uri' => $baseUri,
'handler' => $stack,
], $options));
} | [
"public",
"function",
"createHttpClient",
"(",
"$",
"baseUri",
",",
"array",
"$",
"middlewares",
"=",
"[",
"]",
",",
"array",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"$",
"stack",
"=",
"HandlerStack",
"::",
"create",
"(",
")",
";",
"foreach",
"(",
"... | Method to instantiate a HTTP client.
@param string $baseUri
@param array $middlewares
@param array $options
@return ClientInterface | [
"Method",
"to",
"instantiate",
"a",
"HTTP",
"client",
"."
] | e242a88a93a7a915898c888a575502c21434e35b | https://github.com/MovingImage24/VMProApiClient/blob/e242a88a93a7a915898c888a575502c21434e35b/lib/Factory/Guzzle6ApiClientFactory.php#L56-L68 | train |
kassko/data-mapper | src/ClassMetadata/ClassMetadata.php | ClassMetadata.getMetadataExtensionClassByMappedField | public function getMetadataExtensionClassByMappedField($mappedFieldName)
{
$prefix = '';
if (null != $data = $this->getDataForField($mappedFieldName, $this->columnDataName)) {
switch (true) {
case isset($data['fieldMappingExtensionClass']):
return $prefix.$data['fieldMappingExtensionClass'];
case isset($this->propertyMetadataExtensionClass):
return $prefix.$this->propertyMetadataExtensionClass;
}
}
return null;
} | php | public function getMetadataExtensionClassByMappedField($mappedFieldName)
{
$prefix = '';
if (null != $data = $this->getDataForField($mappedFieldName, $this->columnDataName)) {
switch (true) {
case isset($data['fieldMappingExtensionClass']):
return $prefix.$data['fieldMappingExtensionClass'];
case isset($this->propertyMetadataExtensionClass):
return $prefix.$this->propertyMetadataExtensionClass;
}
}
return null;
} | [
"public",
"function",
"getMetadataExtensionClassByMappedField",
"(",
"$",
"mappedFieldName",
")",
"{",
"$",
"prefix",
"=",
"''",
";",
"if",
"(",
"null",
"!=",
"$",
"data",
"=",
"$",
"this",
"->",
"getDataForField",
"(",
"$",
"mappedFieldName",
",",
"$",
"thi... | Gets the value of metadataExtensionClass for a given fieldName.
@var mappedFieldName string Nom d'un champs pour lequel on cherche la classe contenant ses métadonnées de callback.
@return string Fqcn de la classes contenant les métadonnées de type "callback" pour un champs donné | [
"Gets",
"the",
"value",
"of",
"metadataExtensionClass",
"for",
"a",
"given",
"fieldName",
"."
] | 653b3d735977d95f6eadb3334ab8787db1dca275 | https://github.com/kassko/data-mapper/blob/653b3d735977d95f6eadb3334ab8787db1dca275/src/ClassMetadata/ClassMetadata.php#L364-L381 | train |
delboy1978uk/image | src/Image.php | Image.resize | public function resize($width, $height)
{
$newImage = imagecreatetruecolor($width, $height);
$this->strategy->handleTransparency($newImage, $this->image);
// Now resample the image
imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
// And allocate to $this
$this->image = $newImage;
} | php | public function resize($width, $height)
{
$newImage = imagecreatetruecolor($width, $height);
$this->strategy->handleTransparency($newImage, $this->image);
// Now resample the image
imagecopyresampled($newImage, $this->image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
// And allocate to $this
$this->image = $newImage;
} | [
"public",
"function",
"resize",
"(",
"$",
"width",
",",
"$",
"height",
")",
"{",
"$",
"newImage",
"=",
"imagecreatetruecolor",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"$",
"this",
"->",
"strategy",
"->",
"handleTransparency",
"(",
"$",
"newImage... | Now with added Transparency resizing feature
@param int $width
@param int $height | [
"Now",
"with",
"added",
"Transparency",
"resizing",
"feature"
] | 584d5780d74f4fe67c4b459cd7e8ad5d1b8b93b0 | https://github.com/delboy1978uk/image/blob/584d5780d74f4fe67c4b459cd7e8ad5d1b8b93b0/src/Image.php#L190-L201 | train |
digbang/security | src/Activations/DefaultDoctrineActivationRepository.php | DefaultDoctrineActivationRepository.create | public function create(UserInterface $user)
{
$entity = static::ENTITY_CLASSNAME;
$activation = new $entity($user);
$this->save($activation);
return $activation;
} | php | public function create(UserInterface $user)
{
$entity = static::ENTITY_CLASSNAME;
$activation = new $entity($user);
$this->save($activation);
return $activation;
} | [
"public",
"function",
"create",
"(",
"UserInterface",
"$",
"user",
")",
"{",
"$",
"entity",
"=",
"static",
"::",
"ENTITY_CLASSNAME",
";",
"$",
"activation",
"=",
"new",
"$",
"entity",
"(",
"$",
"user",
")",
";",
"$",
"this",
"->",
"save",
"(",
"$",
"... | Create a new activation record and code.
@param UserInterface $user
@return DefaultActivation | [
"Create",
"a",
"new",
"activation",
"record",
"and",
"code",
"."
] | ee925c5a144a1553f5a72ded6f5a66c01a86ab21 | https://github.com/digbang/security/blob/ee925c5a144a1553f5a72ded6f5a66c01a86ab21/src/Activations/DefaultDoctrineActivationRepository.php#L17-L26 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.pushToIndices | public function pushToIndices(SearchableInterface $searchableModel)
{
$indices = $this->initIndices($searchableModel);
$record = $searchableModel->getAlgoliaRecord();
return $this->processIndices($indices, function (Index $index) use ($record, $searchableModel) {
return $index->addObject($record, $searchableModel->getObjectID());
});
} | php | public function pushToIndices(SearchableInterface $searchableModel)
{
$indices = $this->initIndices($searchableModel);
$record = $searchableModel->getAlgoliaRecord();
return $this->processIndices($indices, function (Index $index) use ($record, $searchableModel) {
return $index->addObject($record, $searchableModel->getObjectID());
});
} | [
"public",
"function",
"pushToIndices",
"(",
"SearchableInterface",
"$",
"searchableModel",
")",
"{",
"$",
"indices",
"=",
"$",
"this",
"->",
"initIndices",
"(",
"$",
"searchableModel",
")",
";",
"$",
"record",
"=",
"$",
"searchableModel",
"->",
"getAlgoliaRecord... | Indexes a searchable model to all indices.
@param SearchableInterface $searchableModel
@return array | [
"Indexes",
"a",
"searchable",
"model",
"to",
"all",
"indices",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L141-L149 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.pushMultipleToIndices | public function pushMultipleToIndices(array $searchableModels)
{
$algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels);
$indices = $this->initIndices($searchableModels[0]);
return $this->processIndices($indices, function (Index $index) use ($algoliaRecords) {
return $index->addObjects($algoliaRecords);
});
} | php | public function pushMultipleToIndices(array $searchableModels)
{
$algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels);
$indices = $this->initIndices($searchableModels[0]);
return $this->processIndices($indices, function (Index $index) use ($algoliaRecords) {
return $index->addObjects($algoliaRecords);
});
} | [
"public",
"function",
"pushMultipleToIndices",
"(",
"array",
"$",
"searchableModels",
")",
"{",
"$",
"algoliaRecords",
"=",
"$",
"this",
"->",
"getAlgoliaRecordsFromSearchableModelArray",
"(",
"$",
"searchableModels",
")",
";",
"$",
"indices",
"=",
"$",
"this",
"-... | Indexes multiple searchable models in a batch. The given searchable models must be of the same class.
@param SearchableInterface[] $searchableModels
@return array | [
"Indexes",
"multiple",
"searchable",
"models",
"in",
"a",
"batch",
".",
"The",
"given",
"searchable",
"models",
"must",
"be",
"of",
"the",
"same",
"class",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L158-L166 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.updateInIndices | public function updateInIndices(SearchableInterface $searchableModel)
{
$indices = $this->initIndices($searchableModel);
$record = $searchableModel->getAlgoliaRecord();
$record['objectID'] = $searchableModel->getObjectID();
return $this->processIndices($indices, function (Index $index) use ($record) {
return $index->saveObject($record);
});
} | php | public function updateInIndices(SearchableInterface $searchableModel)
{
$indices = $this->initIndices($searchableModel);
$record = $searchableModel->getAlgoliaRecord();
$record['objectID'] = $searchableModel->getObjectID();
return $this->processIndices($indices, function (Index $index) use ($record) {
return $index->saveObject($record);
});
} | [
"public",
"function",
"updateInIndices",
"(",
"SearchableInterface",
"$",
"searchableModel",
")",
"{",
"$",
"indices",
"=",
"$",
"this",
"->",
"initIndices",
"(",
"$",
"searchableModel",
")",
";",
"$",
"record",
"=",
"$",
"searchableModel",
"->",
"getAlgoliaReco... | Updates the models data in all indices.
@param SearchableInterface $searchableModel
@return array | [
"Updates",
"the",
"models",
"data",
"in",
"all",
"indices",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L175-L184 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.updateMultipleInIndices | public function updateMultipleInIndices(array $searchableModels)
{
$algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels);
$indices = $this->initIndices($searchableModels[0]);
return $this->processIndices($indices, function (Index $index) use ($algoliaRecords) {
return $index->saveObjects($algoliaRecords);
});
} | php | public function updateMultipleInIndices(array $searchableModels)
{
$algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels);
$indices = $this->initIndices($searchableModels[0]);
return $this->processIndices($indices, function (Index $index) use ($algoliaRecords) {
return $index->saveObjects($algoliaRecords);
});
} | [
"public",
"function",
"updateMultipleInIndices",
"(",
"array",
"$",
"searchableModels",
")",
"{",
"$",
"algoliaRecords",
"=",
"$",
"this",
"->",
"getAlgoliaRecordsFromSearchableModelArray",
"(",
"$",
"searchableModels",
")",
";",
"$",
"indices",
"=",
"$",
"this",
... | Updates multiple models data in all indices. The given searchable models must be of the same class.
@param SearchableInterface[] $searchableModels
@return array | [
"Updates",
"multiple",
"models",
"data",
"in",
"all",
"indices",
".",
"The",
"given",
"searchable",
"models",
"must",
"be",
"of",
"the",
"same",
"class",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L193-L201 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.removeFromIndices | public function removeFromIndices(SearchableInterface $searchableModel)
{
$indices = $indices = $this->initIndices($searchableModel);
$objectID = $searchableModel->getObjectID();
return $this->processIndices($indices, function (Index $index) use ($objectID) {
return $index->deleteObject($objectID);
});
} | php | public function removeFromIndices(SearchableInterface $searchableModel)
{
$indices = $indices = $this->initIndices($searchableModel);
$objectID = $searchableModel->getObjectID();
return $this->processIndices($indices, function (Index $index) use ($objectID) {
return $index->deleteObject($objectID);
});
} | [
"public",
"function",
"removeFromIndices",
"(",
"SearchableInterface",
"$",
"searchableModel",
")",
"{",
"$",
"indices",
"=",
"$",
"indices",
"=",
"$",
"this",
"->",
"initIndices",
"(",
"$",
"searchableModel",
")",
";",
"$",
"objectID",
"=",
"$",
"searchableMo... | Removes a searchable model from indices.
@param SearchableInterface $searchableModel
@return array
@throws \InvalidArgumentException | [
"Removes",
"a",
"searchable",
"model",
"from",
"indices",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L211-L219 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.removeMultipleFromIndices | public function removeMultipleFromIndices(array $searchableModels)
{
$algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels);
$indices = $this->initIndices($searchableModels[0]);
$objectIds = \array_map(function ($algoliaRecord) {
return $algoliaRecord['objectID'];
}, $algoliaRecords);
return $this->processIndices($indices, function (Index $index) use ($objectIds) {
return $index->deleteObjects($objectIds);
});
} | php | public function removeMultipleFromIndices(array $searchableModels)
{
$algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels);
$indices = $this->initIndices($searchableModels[0]);
$objectIds = \array_map(function ($algoliaRecord) {
return $algoliaRecord['objectID'];
}, $algoliaRecords);
return $this->processIndices($indices, function (Index $index) use ($objectIds) {
return $index->deleteObjects($objectIds);
});
} | [
"public",
"function",
"removeMultipleFromIndices",
"(",
"array",
"$",
"searchableModels",
")",
"{",
"$",
"algoliaRecords",
"=",
"$",
"this",
"->",
"getAlgoliaRecordsFromSearchableModelArray",
"(",
"$",
"searchableModels",
")",
";",
"$",
"indices",
"=",
"$",
"this",
... | Removes multiple models from all indices. The given searchable models must be of the same class.
@param array $searchableModels
@return array
@throws \InvalidArgumentException | [
"Removes",
"multiple",
"models",
"from",
"all",
"indices",
".",
"The",
"given",
"searchable",
"models",
"must",
"be",
"of",
"the",
"same",
"class",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L229-L240 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.reindex | public function reindex($className)
{
$this->checkImplementsSearchableInterface($className);
$activeRecord = $this->activeRecordFactory->make($className);
$records = $this->activeQueryChunker->chunk(
$activeRecord->find(),
self::CHUNK_SIZE,
function ($activeRecordEntities) {
return $this->getAlgoliaRecordsFromSearchableModelArray($activeRecordEntities);
}
);
/* @var SearchableInterface $activeRecord */
$indices = $this->initIndices($activeRecord);
return $this->processIndices($indices, function (Index $index) use ($records) {
return $this->reindexAtomically($index, $records);
});
} | php | public function reindex($className)
{
$this->checkImplementsSearchableInterface($className);
$activeRecord = $this->activeRecordFactory->make($className);
$records = $this->activeQueryChunker->chunk(
$activeRecord->find(),
self::CHUNK_SIZE,
function ($activeRecordEntities) {
return $this->getAlgoliaRecordsFromSearchableModelArray($activeRecordEntities);
}
);
/* @var SearchableInterface $activeRecord */
$indices = $this->initIndices($activeRecord);
return $this->processIndices($indices, function (Index $index) use ($records) {
return $this->reindexAtomically($index, $records);
});
} | [
"public",
"function",
"reindex",
"(",
"$",
"className",
")",
"{",
"$",
"this",
"->",
"checkImplementsSearchableInterface",
"(",
"$",
"className",
")",
";",
"$",
"activeRecord",
"=",
"$",
"this",
"->",
"activeRecordFactory",
"->",
"make",
"(",
"$",
"className",... | Re-indexes the indices safely for the given ActiveRecord Class.
@param string $className The name of the ActiveRecord to be indexed
@return array | [
"Re",
"-",
"indexes",
"the",
"indices",
"safely",
"for",
"the",
"given",
"ActiveRecord",
"Class",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L249-L268 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.reindexOnly | public function reindexOnly(array $searchableModels)
{
$records = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels);
$indices = $this->initIndices($searchableModels[0]);
return $this->processIndices($indices, function (Index $index) use ($records) {
return $this->reindexAtomically($index, $records);
});
} | php | public function reindexOnly(array $searchableModels)
{
$records = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels);
$indices = $this->initIndices($searchableModels[0]);
return $this->processIndices($indices, function (Index $index) use ($records) {
return $this->reindexAtomically($index, $records);
});
} | [
"public",
"function",
"reindexOnly",
"(",
"array",
"$",
"searchableModels",
")",
"{",
"$",
"records",
"=",
"$",
"this",
"->",
"getAlgoliaRecordsFromSearchableModelArray",
"(",
"$",
"searchableModels",
")",
";",
"$",
"indices",
"=",
"$",
"this",
"->",
"initIndice... | Re-indexes the related indices for the given array only with the objects from the given array.
The given array must consist of Searchable objects of same class.
@param SearchableInterface[] $searchableModels
@throws \InvalidArgumentException
@return array | [
"Re",
"-",
"indexes",
"the",
"related",
"indices",
"for",
"the",
"given",
"array",
"only",
"with",
"the",
"objects",
"from",
"the",
"given",
"array",
".",
"The",
"given",
"array",
"must",
"consist",
"of",
"Searchable",
"objects",
"of",
"same",
"class",
"."... | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L279-L287 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.reindexByActiveQuery | public function reindexByActiveQuery(ActiveQueryInterface $activeQuery)
{
$indices = null;
$records = $this->activeQueryChunker->chunk(
$activeQuery,
self::CHUNK_SIZE,
function ($activeRecordEntities) use (&$indices) {
$records = $this->getAlgoliaRecordsFromSearchableModelArray($activeRecordEntities);
// The converting ActiveRecords to Algolia ones already does the type checking
// so it's safe to init indices here during the first chunk.
if ($indices === null) {
$indices = $this->initIndices($activeRecordEntities[0]);
}
return $records;
}
);
return $this->processIndices($indices, function (Index $index) use ($records) {
return $this->reindexAtomically($index, $records);
});
} | php | public function reindexByActiveQuery(ActiveQueryInterface $activeQuery)
{
$indices = null;
$records = $this->activeQueryChunker->chunk(
$activeQuery,
self::CHUNK_SIZE,
function ($activeRecordEntities) use (&$indices) {
$records = $this->getAlgoliaRecordsFromSearchableModelArray($activeRecordEntities);
// The converting ActiveRecords to Algolia ones already does the type checking
// so it's safe to init indices here during the first chunk.
if ($indices === null) {
$indices = $this->initIndices($activeRecordEntities[0]);
}
return $records;
}
);
return $this->processIndices($indices, function (Index $index) use ($records) {
return $this->reindexAtomically($index, $records);
});
} | [
"public",
"function",
"reindexByActiveQuery",
"(",
"ActiveQueryInterface",
"$",
"activeQuery",
")",
"{",
"$",
"indices",
"=",
"null",
";",
"$",
"records",
"=",
"$",
"this",
"->",
"activeQueryChunker",
"->",
"chunk",
"(",
"$",
"activeQuery",
",",
"self",
"::",
... | Re-indexes the related indices for the given ActiveQueryInterface.
The result of the given ActiveQuery must consist from Searchable models of the same class.
@param ActiveQueryInterface $activeQuery
@return array | [
"Re",
"-",
"indexes",
"the",
"related",
"indices",
"for",
"the",
"given",
"ActiveQueryInterface",
".",
"The",
"result",
"of",
"the",
"given",
"ActiveQuery",
"must",
"consist",
"from",
"Searchable",
"models",
"of",
"the",
"same",
"class",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L297-L319 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.clearIndices | public function clearIndices($className)
{
$this->checkImplementsSearchableInterface($className);
/** @var SearchableInterface $activeRecord */
$activeRecord = $this->activeRecordFactory->make($className);
$indices = $indices = $this->initIndices($activeRecord);
return $this->processIndices($indices, function (Index $index) {
return $index->clearIndex();
});
} | php | public function clearIndices($className)
{
$this->checkImplementsSearchableInterface($className);
/** @var SearchableInterface $activeRecord */
$activeRecord = $this->activeRecordFactory->make($className);
$indices = $indices = $this->initIndices($activeRecord);
return $this->processIndices($indices, function (Index $index) {
return $index->clearIndex();
});
} | [
"public",
"function",
"clearIndices",
"(",
"$",
"className",
")",
"{",
"$",
"this",
"->",
"checkImplementsSearchableInterface",
"(",
"$",
"className",
")",
";",
"/** @var SearchableInterface $activeRecord */",
"$",
"activeRecord",
"=",
"$",
"this",
"->",
"activeRecord... | Clears the indices for the given Class that implements SearchableInterface.
@param string $className The name of the Class which indices are to be cleared.
@throws \InvalidArgumentException
@return array | [
"Clears",
"the",
"indices",
"for",
"the",
"given",
"Class",
"that",
"implements",
"SearchableInterface",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L329-L339 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.initIndices | private function initIndices(SearchableInterface $searchableModel)
{
$indexNames = $searchableModel->getIndices();
return \array_map(function ($indexName) {
if ($this->env !== null) {
$indexName = $this->env . '_' . $indexName;
}
return $this->initIndex($indexName);
}, $indexNames);
} | php | private function initIndices(SearchableInterface $searchableModel)
{
$indexNames = $searchableModel->getIndices();
return \array_map(function ($indexName) {
if ($this->env !== null) {
$indexName = $this->env . '_' . $indexName;
}
return $this->initIndex($indexName);
}, $indexNames);
} | [
"private",
"function",
"initIndices",
"(",
"SearchableInterface",
"$",
"searchableModel",
")",
"{",
"$",
"indexNames",
"=",
"$",
"searchableModel",
"->",
"getIndices",
"(",
")",
";",
"return",
"\\",
"array_map",
"(",
"function",
"(",
"$",
"indexName",
")",
"{"... | Initializes indices for the given SearchableModel.
@param SearchableInterface $searchableModel
@return Index[] | [
"Initializes",
"indices",
"for",
"the",
"given",
"SearchableModel",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L396-L407 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.getAlgoliaRecordsFromSearchableModelArray | private function getAlgoliaRecordsFromSearchableModelArray(array $searchableModels)
{
if (empty($searchableModels)) {
throw new \InvalidArgumentException('The given array should not be empty');
}
// Use the first element of the array to define what kind of models we are indexing.
$arrayType = \get_class($searchableModels[0]);
$this->checkImplementsSearchableInterface($arrayType);
return \array_map(function (SearchableInterface $searchableModel) use ($arrayType) {
if (! $searchableModel instanceof $arrayType) {
throw new \InvalidArgumentException('The given array should not contain multiple different classes');
}
$algoliaRecord = $searchableModel->getAlgoliaRecord();
$algoliaRecord['objectID'] = $searchableModel->getObjectID();
return $algoliaRecord;
}, $searchableModels);
} | php | private function getAlgoliaRecordsFromSearchableModelArray(array $searchableModels)
{
if (empty($searchableModels)) {
throw new \InvalidArgumentException('The given array should not be empty');
}
// Use the first element of the array to define what kind of models we are indexing.
$arrayType = \get_class($searchableModels[0]);
$this->checkImplementsSearchableInterface($arrayType);
return \array_map(function (SearchableInterface $searchableModel) use ($arrayType) {
if (! $searchableModel instanceof $arrayType) {
throw new \InvalidArgumentException('The given array should not contain multiple different classes');
}
$algoliaRecord = $searchableModel->getAlgoliaRecord();
$algoliaRecord['objectID'] = $searchableModel->getObjectID();
return $algoliaRecord;
}, $searchableModels);
} | [
"private",
"function",
"getAlgoliaRecordsFromSearchableModelArray",
"(",
"array",
"$",
"searchableModels",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"searchableModels",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'The given array should not be e... | Maps an array of searchable models into an Algolia friendly array.
@param SearchableInterface[] $searchableModels
@return array | [
"Maps",
"an",
"array",
"of",
"searchable",
"models",
"into",
"an",
"Algolia",
"friendly",
"array",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L416-L436 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.reindexAtomically | private function reindexAtomically(Index $index, array $algoliaRecords)
{
$temporaryIndexName = 'tmp_' . $index->indexName;
$temporaryIndex = $this->initIndex($temporaryIndexName);
$temporaryIndex->addObjects($algoliaRecords);
$settings = $index->getSettings();
// Temporary index overrides all the settings on the main one.
// So we need to set the original settings on the temporary one before atomically moving the index.
$temporaryIndex->setSettings($settings);
return $this->moveIndex($temporaryIndexName, $index->indexName);
} | php | private function reindexAtomically(Index $index, array $algoliaRecords)
{
$temporaryIndexName = 'tmp_' . $index->indexName;
$temporaryIndex = $this->initIndex($temporaryIndexName);
$temporaryIndex->addObjects($algoliaRecords);
$settings = $index->getSettings();
// Temporary index overrides all the settings on the main one.
// So we need to set the original settings on the temporary one before atomically moving the index.
$temporaryIndex->setSettings($settings);
return $this->moveIndex($temporaryIndexName, $index->indexName);
} | [
"private",
"function",
"reindexAtomically",
"(",
"Index",
"$",
"index",
",",
"array",
"$",
"algoliaRecords",
")",
"{",
"$",
"temporaryIndexName",
"=",
"'tmp_'",
".",
"$",
"index",
"->",
"indexName",
";",
"$",
"temporaryIndex",
"=",
"$",
"this",
"->",
"initIn... | Reindex atomically the given index with the given records.
@param Index $index
@param array $algoliaRecords
@return mixed | [
"Reindex",
"atomically",
"the",
"given",
"index",
"with",
"the",
"given",
"records",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L446-L460 | train |
lordthorzonus/yii2-algolia | src/AlgoliaManager.php | AlgoliaManager.processIndices | private function processIndices($indices, callable $callback)
{
$response = [];
foreach ($indices as $index) {
$response[$index->indexName] = \call_user_func($callback, $index);
}
return $response;
} | php | private function processIndices($indices, callable $callback)
{
$response = [];
foreach ($indices as $index) {
$response[$index->indexName] = \call_user_func($callback, $index);
}
return $response;
} | [
"private",
"function",
"processIndices",
"(",
"$",
"indices",
",",
"callable",
"$",
"callback",
")",
"{",
"$",
"response",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"indices",
"as",
"$",
"index",
")",
"{",
"$",
"response",
"[",
"$",
"index",
"->",
"in... | Performs actions for given indices returning an array of responses from those actions.
@param Index[] $indices
@param callable $callback
@return array The response as an array in format of ['indexName' => $responseFromAlgoliaClient] | [
"Performs",
"actions",
"for",
"given",
"indices",
"returning",
"an",
"array",
"of",
"responses",
"from",
"those",
"actions",
"."
] | 29593c356b727f6d52c2cb4080fc0c232d27c3bb | https://github.com/lordthorzonus/yii2-algolia/blob/29593c356b727f6d52c2cb4080fc0c232d27c3bb/src/AlgoliaManager.php#L470-L479 | train |
koolkode/async | src/Concurrent/Process/ProcessBuilder.php | ProcessBuilder.withDir | public function withDir(string $dir): self
{
$builder = clone $this;
$builder->dir = $dir;
return $builder;
} | php | public function withDir(string $dir): self
{
$builder = clone $this;
$builder->dir = $dir;
return $builder;
} | [
"public",
"function",
"withDir",
"(",
"string",
"$",
"dir",
")",
":",
"self",
"{",
"$",
"builder",
"=",
"clone",
"$",
"this",
";",
"$",
"builder",
"->",
"dir",
"=",
"$",
"dir",
";",
"return",
"$",
"builder",
";",
"}"
] | Set the working directory to be used by the process.
@param string $dir Working directory. | [
"Set",
"the",
"working",
"directory",
"to",
"be",
"used",
"by",
"the",
"process",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Process/ProcessBuilder.php#L92-L98 | train |
koolkode/async | src/Concurrent/Process/ProcessBuilder.php | ProcessBuilder.withEnv | public function withEnv(string $name, string $value): self
{
$builder = clone $this;
$builder->env[$name] = $value;
return $builder;
} | php | public function withEnv(string $name, string $value): self
{
$builder = clone $this;
$builder->env[$name] = $value;
return $builder;
} | [
"public",
"function",
"withEnv",
"(",
"string",
"$",
"name",
",",
"string",
"$",
"value",
")",
":",
"self",
"{",
"$",
"builder",
"=",
"clone",
"$",
"this",
";",
"$",
"builder",
"->",
"env",
"[",
"$",
"name",
"]",
"=",
"$",
"value",
";",
"return",
... | Set an environment variable to be passed to the process.
@param string $name Name of the environment variable (should only contain uppercase letters and underscores).
@param string $value Value of the environment variable. | [
"Set",
"an",
"environment",
"variable",
"to",
"be",
"passed",
"to",
"the",
"process",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Process/ProcessBuilder.php#L106-L112 | train |
koolkode/async | src/Concurrent/Process/ProcessBuilder.php | ProcessBuilder.start | public function start(Context $context, array $args = []): Promise
{
$factory = $context->lookup(ProcessFactory::class);
if ($factory === null) {
throw new \RuntimeException('Cannot launch an async process without a process factory');
}
$options = [];
foreach ($this->options as $k => $v) {
if (\strlen($k) === 1) {
$name = '-' . $k;
} else {
$name = '--' . $k;
}
if ($v === null) {
$options[] = $name;
} else {
foreach ($v as $val) {
$options[] = $name;
$options[] = $val;
}
}
}
return $context->task($factory->createProcess($context, $this->command, \array_merge($options, $args), $this->dir, $this->env));
} | php | public function start(Context $context, array $args = []): Promise
{
$factory = $context->lookup(ProcessFactory::class);
if ($factory === null) {
throw new \RuntimeException('Cannot launch an async process without a process factory');
}
$options = [];
foreach ($this->options as $k => $v) {
if (\strlen($k) === 1) {
$name = '-' . $k;
} else {
$name = '--' . $k;
}
if ($v === null) {
$options[] = $name;
} else {
foreach ($v as $val) {
$options[] = $name;
$options[] = $val;
}
}
}
return $context->task($factory->createProcess($context, $this->command, \array_merge($options, $args), $this->dir, $this->env));
} | [
"public",
"function",
"start",
"(",
"Context",
"$",
"context",
",",
"array",
"$",
"args",
"=",
"[",
"]",
")",
":",
"Promise",
"{",
"$",
"factory",
"=",
"$",
"context",
"->",
"lookup",
"(",
"ProcessFactory",
"::",
"class",
")",
";",
"if",
"(",
"$",
... | Start an instance of the configured process.
@param array $args Arguments to be passed to the process.
@return Process Provides access to the running process instance.
@throws \RuntimeException If the process could not be started. | [
"Start",
"an",
"instance",
"of",
"the",
"configured",
"process",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Process/ProcessBuilder.php#L122-L150 | train |
koolkode/async | src/Concurrent/Process/ProcessBuilder.php | ProcessBuilder.run | public function run(Context $context, array $args, ?callable $stdin = null, ?callable $stdout = null, ?callable $stderr = null): Promise
{
static $discard;
static $closer;
if ($discard === null) {
$discard = static function (Context $context, ReadableStream $stream) {
yield $stream->discard($context);
};
}
if ($closer === null) {
$closer = static function (Context $context, ?callable $callback, $pipe) {
$result = null;
try {
if ($callback) {
$result = yield from Coroutine::generate($callback, $context, $pipe);
}
} finally {
$pipe->close();
}
return $result;
};
}
return $context->task(function (Context $context) use ($args, $stdin, $stdout, $stderr, $closer, $discard) {
$process = yield $this->start($context, $args);
try {
$context = $context->cancellable($cancel = $context->cancellationHandler());
yield $context->all([
$closer($context, $stdin, $process->getStdin()),
$closer($context, $stdout ?? $discard, $process->getStdout()),
$closer($context, $stderr ?? $discard, $process->getStderr())
], $cancel);
$code = yield $process->exitCode($context);
} finally {
$process->close();
}
return $code;
});
} | php | public function run(Context $context, array $args, ?callable $stdin = null, ?callable $stdout = null, ?callable $stderr = null): Promise
{
static $discard;
static $closer;
if ($discard === null) {
$discard = static function (Context $context, ReadableStream $stream) {
yield $stream->discard($context);
};
}
if ($closer === null) {
$closer = static function (Context $context, ?callable $callback, $pipe) {
$result = null;
try {
if ($callback) {
$result = yield from Coroutine::generate($callback, $context, $pipe);
}
} finally {
$pipe->close();
}
return $result;
};
}
return $context->task(function (Context $context) use ($args, $stdin, $stdout, $stderr, $closer, $discard) {
$process = yield $this->start($context, $args);
try {
$context = $context->cancellable($cancel = $context->cancellationHandler());
yield $context->all([
$closer($context, $stdin, $process->getStdin()),
$closer($context, $stdout ?? $discard, $process->getStdout()),
$closer($context, $stderr ?? $discard, $process->getStderr())
], $cancel);
$code = yield $process->exitCode($context);
} finally {
$process->close();
}
return $code;
});
} | [
"public",
"function",
"run",
"(",
"Context",
"$",
"context",
",",
"array",
"$",
"args",
",",
"?",
"callable",
"$",
"stdin",
"=",
"null",
",",
"?",
"callable",
"$",
"stdout",
"=",
"null",
",",
"?",
"callable",
"$",
"stderr",
"=",
"null",
")",
":",
"... | Run the configured process to completion using the given read and write handlers.
@param Context $context Async execution context.
@param array $args Arguments to be passed to the process.
@param callable $stdin Is called with context and writable STDIN stream.
@param callable $stdout Is called with context and readable STDOUT stream.
@param callable $stderr Is called with context and readable STDERR stream
@return array Values returned by STDIN, STDOUT and STDERR tasks in elements 0, 1 and 2. | [
"Run",
"the",
"configured",
"process",
"to",
"completion",
"using",
"the",
"given",
"read",
"and",
"write",
"handlers",
"."
] | 9c985dcdd3b328323826dd4254d9f2e5aea0b75b | https://github.com/koolkode/async/blob/9c985dcdd3b328323826dd4254d9f2e5aea0b75b/src/Concurrent/Process/ProcessBuilder.php#L162-L208 | train |
BlackBonjour/stdlib | src/Lang/Character.php | Character.charCount | public static function charCount($char): int
{
self::handleIncomingChar($char);
$stringChar = (string) $char;
return mb_ord($stringChar, mb_detect_encoding($stringChar)) > 0xFFFF ? 2 : 1;
} | php | public static function charCount($char): int
{
self::handleIncomingChar($char);
$stringChar = (string) $char;
return mb_ord($stringChar, mb_detect_encoding($stringChar)) > 0xFFFF ? 2 : 1;
} | [
"public",
"static",
"function",
"charCount",
"(",
"$",
"char",
")",
":",
"int",
"{",
"self",
"::",
"handleIncomingChar",
"(",
"$",
"char",
")",
";",
"$",
"stringChar",
"=",
"(",
"string",
")",
"$",
"char",
";",
"return",
"mb_ord",
"(",
"$",
"stringChar... | Determines the number of char values needed to represent the specified character
@param static|string $char
@return int
@throws InvalidArgumentException
@throws TypeError | [
"Determines",
"the",
"number",
"of",
"char",
"values",
"needed",
"to",
"represent",
"the",
"specified",
"character"
] | 0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814 | https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/Character.php#L56-L62 | train |
BlackBonjour/stdlib | src/Lang/Character.php | Character.codePointBefore | public static function codePointBefore($chars, int $index, int $start = null): int
{
if ($start !== null && ($start < 0 || $index <= $start)) {
throw new InvalidArgumentException('Start cannot be negative and index must be greater than start!');
}
return static::codePointAt($chars, $index - 1);
} | php | public static function codePointBefore($chars, int $index, int $start = null): int
{
if ($start !== null && ($start < 0 || $index <= $start)) {
throw new InvalidArgumentException('Start cannot be negative and index must be greater than start!');
}
return static::codePointAt($chars, $index - 1);
} | [
"public",
"static",
"function",
"codePointBefore",
"(",
"$",
"chars",
",",
"int",
"$",
"index",
",",
"int",
"$",
"start",
"=",
"null",
")",
":",
"int",
"{",
"if",
"(",
"$",
"start",
"!==",
"null",
"&&",
"(",
"$",
"start",
"<",
"0",
"||",
"$",
"in... | Returns the unicode code point before specified index
@param CharSequence|static[] $chars
@param int $index
@param int $start
@return int
@throws InvalidArgumentException | [
"Returns",
"the",
"unicode",
"code",
"point",
"before",
"specified",
"index"
] | 0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814 | https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/Character.php#L121-L128 | train |
BlackBonjour/stdlib | src/Lang/Character.php | Character.compare | public static function compare($charA, $charB): int
{
self::handleIncomingChar($charA, $charB);
return (string) $charA <=> (string) $charB;
} | php | public static function compare($charA, $charB): int
{
self::handleIncomingChar($charA, $charB);
return (string) $charA <=> (string) $charB;
} | [
"public",
"static",
"function",
"compare",
"(",
"$",
"charA",
",",
"$",
"charB",
")",
":",
"int",
"{",
"self",
"::",
"handleIncomingChar",
"(",
"$",
"charA",
",",
"$",
"charB",
")",
";",
"return",
"(",
"string",
")",
"$",
"charA",
"<=>",
"(",
"string... | Compares specified characters numerically
@param static|string $charA
@param static|string $charB
@return int
@throws InvalidArgumentException
@throws TypeError | [
"Compares",
"specified",
"characters",
"numerically"
] | 0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814 | https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/Character.php#L139-L144 | train |
BlackBonjour/stdlib | src/Lang/Character.php | Character.handleIncomingChar | private static function handleIncomingChar(...$chars): void
{
foreach ($chars as $char) {
Assert::typeOf(['string', __CLASS__], $char);
if (mb_strlen((string) $char) !== 1) {
throw new InvalidArgumentException('Only one character can be represented!');
}
}
} | php | private static function handleIncomingChar(...$chars): void
{
foreach ($chars as $char) {
Assert::typeOf(['string', __CLASS__], $char);
if (mb_strlen((string) $char) !== 1) {
throw new InvalidArgumentException('Only one character can be represented!');
}
}
} | [
"private",
"static",
"function",
"handleIncomingChar",
"(",
"...",
"$",
"chars",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"chars",
"as",
"$",
"char",
")",
"{",
"Assert",
"::",
"typeOf",
"(",
"[",
"'string'",
",",
"__CLASS__",
"]",
",",
"$",
"char",
... | Validates given character and throws an exception if required
@param mixed[] $chars
@return void
@throws InvalidArgumentException
@throws TypeError | [
"Validates",
"given",
"character",
"and",
"throws",
"an",
"exception",
"if",
"required"
] | 0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814 | https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/Character.php#L166-L175 | train |
BlackBonjour/stdlib | src/Lang/Character.php | Character.isLowerCase | public static function isLowerCase($char): bool
{
self::handleIncomingChar($char);
return static::compare($char, static::toLowerCase($char)) === 0;
} | php | public static function isLowerCase($char): bool
{
self::handleIncomingChar($char);
return static::compare($char, static::toLowerCase($char)) === 0;
} | [
"public",
"static",
"function",
"isLowerCase",
"(",
"$",
"char",
")",
":",
"bool",
"{",
"self",
"::",
"handleIncomingChar",
"(",
"$",
"char",
")",
";",
"return",
"static",
"::",
"compare",
"(",
"$",
"char",
",",
"static",
"::",
"toLowerCase",
"(",
"$",
... | Checks if specified character is lower case
@param static|string $char
@return boolean
@throws InvalidArgumentException
@throws TypeError | [
"Checks",
"if",
"specified",
"character",
"is",
"lower",
"case"
] | 0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814 | https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/Character.php#L185-L190 | train |
BlackBonjour/stdlib | src/Lang/Character.php | Character.isUpperCase | public static function isUpperCase($char): bool
{
self::handleIncomingChar($char);
return static::compare($char, static::toUpperCase($char)) === 0;
} | php | public static function isUpperCase($char): bool
{
self::handleIncomingChar($char);
return static::compare($char, static::toUpperCase($char)) === 0;
} | [
"public",
"static",
"function",
"isUpperCase",
"(",
"$",
"char",
")",
":",
"bool",
"{",
"self",
"::",
"handleIncomingChar",
"(",
"$",
"char",
")",
";",
"return",
"static",
"::",
"compare",
"(",
"$",
"char",
",",
"static",
"::",
"toUpperCase",
"(",
"$",
... | Checks if specified character is upper case
@param static|string $char
@return boolean
@throws InvalidArgumentException
@throws TypeError | [
"Checks",
"if",
"specified",
"character",
"is",
"upper",
"case"
] | 0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814 | https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/Character.php#L200-L205 | train |
BlackBonjour/stdlib | src/Lang/Character.php | Character.valueOf | public static function valueOf($char): self
{
if (\is_string($char) || $char instanceof self) {
return new static((string) $char);
}
throw new InvalidArgumentException('Unsupported character type!');
} | php | public static function valueOf($char): self
{
if (\is_string($char) || $char instanceof self) {
return new static((string) $char);
}
throw new InvalidArgumentException('Unsupported character type!');
} | [
"public",
"static",
"function",
"valueOf",
"(",
"$",
"char",
")",
":",
"self",
"{",
"if",
"(",
"\\",
"is_string",
"(",
"$",
"char",
")",
"||",
"$",
"char",
"instanceof",
"self",
")",
"{",
"return",
"new",
"static",
"(",
"(",
"string",
")",
"$",
"ch... | Returns specified value as character
@param static|string $char
@return static
@throws InvalidArgumentException | [
"Returns",
"specified",
"value",
"as",
"character"
] | 0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814 | https://github.com/BlackBonjour/stdlib/blob/0ec59db9d8b77c2b3877c8d8a3d6ecbdcf75f814/src/Lang/Character.php#L244-L251 | train |
widoz/wordpress-model | src/Attachment/Image/Size.php | Size.createBySizeName | public static function createBySizeName(string $name): self
{
$registeredImageSizes = get_intermediate_image_sizes();
$additionalImageSizes = wp_get_additional_image_sizes();
Assert::oneOf(
$name,
$registeredImageSizes,
"{$name} size not found on WordPress registered sizes."
);
if ($additionalImageSizes[$name] ?? false) {
return new self(
(int)$additionalImageSizes[$name]['width'],
(int)$additionalImageSizes[$name]['height']
);
}
return new self(
(int)get_option("{$name}_size_w", null),
(int)get_option("{$name}_size_h", null)
);
} | php | public static function createBySizeName(string $name): self
{
$registeredImageSizes = get_intermediate_image_sizes();
$additionalImageSizes = wp_get_additional_image_sizes();
Assert::oneOf(
$name,
$registeredImageSizes,
"{$name} size not found on WordPress registered sizes."
);
if ($additionalImageSizes[$name] ?? false) {
return new self(
(int)$additionalImageSizes[$name]['width'],
(int)$additionalImageSizes[$name]['height']
);
}
return new self(
(int)get_option("{$name}_size_w", null),
(int)get_option("{$name}_size_h", null)
);
} | [
"public",
"static",
"function",
"createBySizeName",
"(",
"string",
"$",
"name",
")",
":",
"self",
"{",
"$",
"registeredImageSizes",
"=",
"get_intermediate_image_sizes",
"(",
")",
";",
"$",
"additionalImageSizes",
"=",
"wp_get_additional_image_sizes",
"(",
")",
";",
... | Create a Size Instance by string WordPress style
@param string $name
@return Size
@throws InvalidArgumentException | [
"Create",
"a",
"Size",
"Instance",
"by",
"string",
"WordPress",
"style"
] | 273301de4b6946144b285c235aea0d79b867244c | https://github.com/widoz/wordpress-model/blob/273301de4b6946144b285c235aea0d79b867244c/src/Attachment/Image/Size.php#L45-L67 | train |
Speelpenning-nl/laravel-authentication | src/Http/Controllers/ProfileController.php | ProfileController.update | public function update(UpdateUserRequest $request)
{
$this->dispatch(new UpdateUser($this->auth->user()->id, $request->get('name'), $request->get('email')));
return redirect()->route('authentication::profile.show');
} | php | public function update(UpdateUserRequest $request)
{
$this->dispatch(new UpdateUser($this->auth->user()->id, $request->get('name'), $request->get('email')));
return redirect()->route('authentication::profile.show');
} | [
"public",
"function",
"update",
"(",
"UpdateUserRequest",
"$",
"request",
")",
"{",
"$",
"this",
"->",
"dispatch",
"(",
"new",
"UpdateUser",
"(",
"$",
"this",
"->",
"auth",
"->",
"user",
"(",
")",
"->",
"id",
",",
"$",
"request",
"->",
"get",
"(",
"'... | Attempts to update the user profile.
@param UpdateUserRequest $request
@return RedirectResponse | [
"Attempts",
"to",
"update",
"the",
"user",
"profile",
"."
] | 44671afa8d654a9c6281cce13353d95126478d8b | https://github.com/Speelpenning-nl/laravel-authentication/blob/44671afa8d654a9c6281cce13353d95126478d8b/src/Http/Controllers/ProfileController.php#L63-L67 | train |
LaraChimp/pine-annotations | src/Support/Reader/AnnotationsReader.php | AnnotationsReader.target | public function target($target, $keyName = null)
{
$this->target = $target;
$this->keyName = $keyName;
return $this;
} | php | public function target($target, $keyName = null)
{
$this->target = $target;
$this->keyName = $keyName;
return $this;
} | [
"public",
"function",
"target",
"(",
"$",
"target",
",",
"$",
"keyName",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"target",
"=",
"$",
"target",
";",
"$",
"this",
"->",
"keyName",
"=",
"$",
"keyName",
";",
"return",
"$",
"this",
";",
"}"
] | Which type of annotation should the reader target.
The default is class.
@param string $target
@param string $keyName
@return self | [
"Which",
"type",
"of",
"annotation",
"should",
"the",
"reader",
"target",
".",
"The",
"default",
"is",
"class",
"."
] | f7d0cc77a1e24813b541acb98be8de34175da6e6 | https://github.com/LaraChimp/pine-annotations/blob/f7d0cc77a1e24813b541acb98be8de34175da6e6/src/Support/Reader/AnnotationsReader.php#L77-L83 | train |
LaraChimp/pine-annotations | src/Support/Reader/AnnotationsReader.php | AnnotationsReader.read | public function read($argument)
{
// Get Reflection.
$reflection = $this->getReflectionFrom($argument);
// We have some specific annotations to be read.
if ($this->wantsSpecificAnnotation()) {
return $this->readSpecificAnnotationFor($reflection);
}
// We require to read all annotations.
return $this->readAllAnnotationsFor($reflection);
} | php | public function read($argument)
{
// Get Reflection.
$reflection = $this->getReflectionFrom($argument);
// We have some specific annotations to be read.
if ($this->wantsSpecificAnnotation()) {
return $this->readSpecificAnnotationFor($reflection);
}
// We require to read all annotations.
return $this->readAllAnnotationsFor($reflection);
} | [
"public",
"function",
"read",
"(",
"$",
"argument",
")",
"{",
"// Get Reflection.",
"$",
"reflection",
"=",
"$",
"this",
"->",
"getReflectionFrom",
"(",
"$",
"argument",
")",
";",
"// We have some specific annotations to be read.",
"if",
"(",
"$",
"this",
"->",
... | Reads annotations for a given object.
@param mixed $argument
@return \Illuminate\Support\Collection | [
"Reads",
"annotations",
"for",
"a",
"given",
"object",
"."
] | f7d0cc77a1e24813b541acb98be8de34175da6e6 | https://github.com/LaraChimp/pine-annotations/blob/f7d0cc77a1e24813b541acb98be8de34175da6e6/src/Support/Reader/AnnotationsReader.php#L106-L118 | train |
LaraChimp/pine-annotations | src/Support/Reader/AnnotationsReader.php | AnnotationsReader.addFilesToRegistry | public function addFilesToRegistry($filePaths)
{
collect((array) $filePaths)->each(function ($filePath) {
if (file_exists($filePath)) {
AnnotationRegistry::registerFile($filePath);
}
});
return $this;
} | php | public function addFilesToRegistry($filePaths)
{
collect((array) $filePaths)->each(function ($filePath) {
if (file_exists($filePath)) {
AnnotationRegistry::registerFile($filePath);
}
});
return $this;
} | [
"public",
"function",
"addFilesToRegistry",
"(",
"$",
"filePaths",
")",
"{",
"collect",
"(",
"(",
"array",
")",
"$",
"filePaths",
")",
"->",
"each",
"(",
"function",
"(",
"$",
"filePath",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"filePath",
")",
"... | Adds files containing annotations to the registry.
@param array|string $filePaths
@return self | [
"Adds",
"files",
"containing",
"annotations",
"to",
"the",
"registry",
"."
] | f7d0cc77a1e24813b541acb98be8de34175da6e6 | https://github.com/LaraChimp/pine-annotations/blob/f7d0cc77a1e24813b541acb98be8de34175da6e6/src/Support/Reader/AnnotationsReader.php#L127-L136 | train |
LaraChimp/pine-annotations | src/Support/Reader/AnnotationsReader.php | AnnotationsReader.addNamespacesToRegistry | public function addNamespacesToRegistry($namespaces)
{
collect((array) $namespaces)->each(function ($namespace) {
// Get path from namespace.
$path = $this->getPathFromNamespace($namespace);
if (file_exists($path)) {
// Register each annotations file found in the namespace.
foreach (Finder::create()->files()->name('*.php')->in($path) as $file) {
$this->addFilesToRegistry($file->getRealPath());
}
}
});
return $this;
} | php | public function addNamespacesToRegistry($namespaces)
{
collect((array) $namespaces)->each(function ($namespace) {
// Get path from namespace.
$path = $this->getPathFromNamespace($namespace);
if (file_exists($path)) {
// Register each annotations file found in the namespace.
foreach (Finder::create()->files()->name('*.php')->in($path) as $file) {
$this->addFilesToRegistry($file->getRealPath());
}
}
});
return $this;
} | [
"public",
"function",
"addNamespacesToRegistry",
"(",
"$",
"namespaces",
")",
"{",
"collect",
"(",
"(",
"array",
")",
"$",
"namespaces",
")",
"->",
"each",
"(",
"function",
"(",
"$",
"namespace",
")",
"{",
"// Get path from namespace.",
"$",
"path",
"=",
"$"... | Adds namespaces containing annotations to the registry.
@param array|string $namespaces
@return $this | [
"Adds",
"namespaces",
"containing",
"annotations",
"to",
"the",
"registry",
"."
] | f7d0cc77a1e24813b541acb98be8de34175da6e6 | https://github.com/LaraChimp/pine-annotations/blob/f7d0cc77a1e24813b541acb98be8de34175da6e6/src/Support/Reader/AnnotationsReader.php#L145-L160 | train |
LaraChimp/pine-annotations | src/Support/Reader/AnnotationsReader.php | AnnotationsReader.readAllAnnotationsFor | protected function readAllAnnotationsFor($reflection)
{
// Construct Method to be used for reading.
$methodName = $this->constructReadMethod();
// Read, Collect and return annotations.
return collect($this->reader->{$methodName}($reflection));
} | php | protected function readAllAnnotationsFor($reflection)
{
// Construct Method to be used for reading.
$methodName = $this->constructReadMethod();
// Read, Collect and return annotations.
return collect($this->reader->{$methodName}($reflection));
} | [
"protected",
"function",
"readAllAnnotationsFor",
"(",
"$",
"reflection",
")",
"{",
"// Construct Method to be used for reading.",
"$",
"methodName",
"=",
"$",
"this",
"->",
"constructReadMethod",
"(",
")",
";",
"// Read, Collect and return annotations.",
"return",
"collect... | Reads all the annotations for the given target.
@param ReflectionClass|ReflectionProperty|ReflectionMethod $reflection
@return \Illuminate\Support\Collection | [
"Reads",
"all",
"the",
"annotations",
"for",
"the",
"given",
"target",
"."
] | f7d0cc77a1e24813b541acb98be8de34175da6e6 | https://github.com/LaraChimp/pine-annotations/blob/f7d0cc77a1e24813b541acb98be8de34175da6e6/src/Support/Reader/AnnotationsReader.php#L169-L176 | train |
LaraChimp/pine-annotations | src/Support/Reader/AnnotationsReader.php | AnnotationsReader.readSpecificAnnotationFor | protected function readSpecificAnnotationFor($reflection)
{
// Construct Method to be used for reading.
$methodName = $this->constructReadMethod();
// Read, Collect and return annotations.
return collect($this->reader->{$methodName}($reflection, $this->annotationName));
} | php | protected function readSpecificAnnotationFor($reflection)
{
// Construct Method to be used for reading.
$methodName = $this->constructReadMethod();
// Read, Collect and return annotations.
return collect($this->reader->{$methodName}($reflection, $this->annotationName));
} | [
"protected",
"function",
"readSpecificAnnotationFor",
"(",
"$",
"reflection",
")",
"{",
"// Construct Method to be used for reading.",
"$",
"methodName",
"=",
"$",
"this",
"->",
"constructReadMethod",
"(",
")",
";",
"// Read, Collect and return annotations.",
"return",
"col... | Reads the specified annotation name given for the target.
@param ReflectionClass|ReflectionProperty|ReflectionMethod $reflection
@return \Illuminate\Support\Collection | [
"Reads",
"the",
"specified",
"annotation",
"name",
"given",
"for",
"the",
"target",
"."
] | f7d0cc77a1e24813b541acb98be8de34175da6e6 | https://github.com/LaraChimp/pine-annotations/blob/f7d0cc77a1e24813b541acb98be8de34175da6e6/src/Support/Reader/AnnotationsReader.php#L185-L192 | train |
LaraChimp/pine-annotations | src/Support/Reader/AnnotationsReader.php | AnnotationsReader.getReflectionFrom | protected function getReflectionFrom($argument)
{
// Method name to use.
$reflectionMethodName = Str::camel('getreflection'.$this->target.'from');
// Return Reflection
return $this->{$reflectionMethodName}($argument);
} | php | protected function getReflectionFrom($argument)
{
// Method name to use.
$reflectionMethodName = Str::camel('getreflection'.$this->target.'from');
// Return Reflection
return $this->{$reflectionMethodName}($argument);
} | [
"protected",
"function",
"getReflectionFrom",
"(",
"$",
"argument",
")",
"{",
"// Method name to use.",
"$",
"reflectionMethodName",
"=",
"Str",
"::",
"camel",
"(",
"'getreflection'",
".",
"$",
"this",
"->",
"target",
".",
"'from'",
")",
";",
"// Return Reflection... | Get the ReflectionClass from an argument.
be it an object or a class name.
@param mixed $argument
@return ReflectionClass|ReflectionMethod|ReflectionProperty | [
"Get",
"the",
"ReflectionClass",
"from",
"an",
"argument",
".",
"be",
"it",
"an",
"object",
"or",
"a",
"class",
"name",
"."
] | f7d0cc77a1e24813b541acb98be8de34175da6e6 | https://github.com/LaraChimp/pine-annotations/blob/f7d0cc77a1e24813b541acb98be8de34175da6e6/src/Support/Reader/AnnotationsReader.php#L202-L209 | train |
LaraChimp/pine-annotations | src/Support/Reader/AnnotationsReader.php | AnnotationsReader.getReflectionPropertyFrom | protected function getReflectionPropertyFrom($argument)
{
// No property name is given for targetting.
if (is_null($this->keyName)) {
throw new InvalidArgumentException('Property name to target is required');
}
// Argument is an Object.
if (is_object($argument)) {
$argument = get_class($argument);
}
// Get Reflected property of the object.
return new ReflectionProperty($argument, $this->keyName);
} | php | protected function getReflectionPropertyFrom($argument)
{
// No property name is given for targetting.
if (is_null($this->keyName)) {
throw new InvalidArgumentException('Property name to target is required');
}
// Argument is an Object.
if (is_object($argument)) {
$argument = get_class($argument);
}
// Get Reflected property of the object.
return new ReflectionProperty($argument, $this->keyName);
} | [
"protected",
"function",
"getReflectionPropertyFrom",
"(",
"$",
"argument",
")",
"{",
"// No property name is given for targetting.",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"keyName",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Property na... | Get the ReflectionProperty for a given argument.
@param mixed $argument
@throws InvalidArgumentException
@return ReflectionProperty | [
"Get",
"the",
"ReflectionProperty",
"for",
"a",
"given",
"argument",
"."
] | f7d0cc77a1e24813b541acb98be8de34175da6e6 | https://github.com/LaraChimp/pine-annotations/blob/f7d0cc77a1e24813b541acb98be8de34175da6e6/src/Support/Reader/AnnotationsReader.php#L238-L252 | train |
LaraChimp/pine-annotations | src/Support/Reader/AnnotationsReader.php | AnnotationsReader.getReflectionMethodFrom | protected function getReflectionMethodFrom($argument)
{
// No method name is given for targetting.
if (is_null($this->keyName)) {
throw new InvalidArgumentException('Method name to target is required');
}
// Argument is an Object.
if (is_object($argument)) {
$argument = get_class($argument);
}
// Get Reflected method of the object.
return new ReflectionMethod($argument, $this->keyName);
} | php | protected function getReflectionMethodFrom($argument)
{
// No method name is given for targetting.
if (is_null($this->keyName)) {
throw new InvalidArgumentException('Method name to target is required');
}
// Argument is an Object.
if (is_object($argument)) {
$argument = get_class($argument);
}
// Get Reflected method of the object.
return new ReflectionMethod($argument, $this->keyName);
} | [
"protected",
"function",
"getReflectionMethodFrom",
"(",
"$",
"argument",
")",
"{",
"// No method name is given for targetting.",
"if",
"(",
"is_null",
"(",
"$",
"this",
"->",
"keyName",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Method name to ... | Get the ReflectionMethod for a given argument.
@param mixed $argument
@return ReflectionMethod | [
"Get",
"the",
"ReflectionMethod",
"for",
"a",
"given",
"argument",
"."
] | f7d0cc77a1e24813b541acb98be8de34175da6e6 | https://github.com/LaraChimp/pine-annotations/blob/f7d0cc77a1e24813b541acb98be8de34175da6e6/src/Support/Reader/AnnotationsReader.php#L261-L275 | train |
LaraChimp/pine-annotations | src/Support/Reader/AnnotationsReader.php | AnnotationsReader.constructReadMethod | protected function constructReadMethod()
{
// Reader methods ends with this.
$endsWith = 'annotations';
// We have an annotation name which means
// we have to target a specific one.
if ($this->wantsSpecificAnnotation()) {
$endsWith = 'annotation';
}
return Str::camel('get'.$this->target.$endsWith);
} | php | protected function constructReadMethod()
{
// Reader methods ends with this.
$endsWith = 'annotations';
// We have an annotation name which means
// we have to target a specific one.
if ($this->wantsSpecificAnnotation()) {
$endsWith = 'annotation';
}
return Str::camel('get'.$this->target.$endsWith);
} | [
"protected",
"function",
"constructReadMethod",
"(",
")",
"{",
"// Reader methods ends with this.",
"$",
"endsWith",
"=",
"'annotations'",
";",
"// We have an annotation name which means",
"// we have to target a specific one.",
"if",
"(",
"$",
"this",
"->",
"wantsSpecificAnnot... | Gets the Method name to be used by the Reader.
@return string | [
"Gets",
"the",
"Method",
"name",
"to",
"be",
"used",
"by",
"the",
"Reader",
"."
] | f7d0cc77a1e24813b541acb98be8de34175da6e6 | https://github.com/LaraChimp/pine-annotations/blob/f7d0cc77a1e24813b541acb98be8de34175da6e6/src/Support/Reader/AnnotationsReader.php#L282-L294 | train |
scherersoftware/cake-cktools | src/Model/Behavior/SortableBehavior.php | SortableBehavior.restoreSorting | public function restoreSorting(array $scope = []): void
{
$records = $this->_table->find()
->select([$this->_table->getPrimaryKey(), $this->getConfig('sortField')])
->select($this->getConfig('columnScope'))
->order($this->getConfig('defaultOrder'));
if (!empty($scope)) {
$records->where($scope);
}
$sorts = [];
foreach ($records as $entity) {
$individualScope = '';
foreach ($this->getConfig('columnScope') as $column) {
$individualScope .= $entity->get($column);
}
if (!isset($sorts[$individualScope])) {
$sorts[$individualScope] = 0;
}
$sort = ++$sorts[$individualScope];
$this->_table->updateAll([
$this->getConfig('sortField') => $sort,
], [
$this->_table->getPrimaryKey() => $entity->get($this->_table->getPrimaryKey()),
]);
}
} | php | public function restoreSorting(array $scope = []): void
{
$records = $this->_table->find()
->select([$this->_table->getPrimaryKey(), $this->getConfig('sortField')])
->select($this->getConfig('columnScope'))
->order($this->getConfig('defaultOrder'));
if (!empty($scope)) {
$records->where($scope);
}
$sorts = [];
foreach ($records as $entity) {
$individualScope = '';
foreach ($this->getConfig('columnScope') as $column) {
$individualScope .= $entity->get($column);
}
if (!isset($sorts[$individualScope])) {
$sorts[$individualScope] = 0;
}
$sort = ++$sorts[$individualScope];
$this->_table->updateAll([
$this->getConfig('sortField') => $sort,
], [
$this->_table->getPrimaryKey() => $entity->get($this->_table->getPrimaryKey()),
]);
}
} | [
"public",
"function",
"restoreSorting",
"(",
"array",
"$",
"scope",
"=",
"[",
"]",
")",
":",
"void",
"{",
"$",
"records",
"=",
"$",
"this",
"->",
"_table",
"->",
"find",
"(",
")",
"->",
"select",
"(",
"[",
"$",
"this",
"->",
"_table",
"->",
"getPri... | Restores the sorting based on defaultOrder
@return void | [
"Restores",
"the",
"sorting",
"based",
"on",
"defaultOrder"
] | efba42cf4e1804df8f1faa83ef75927bee6c206b | https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Model/Behavior/SortableBehavior.php#L44-L73 | train |
scherersoftware/cake-cktools | src/Model/Behavior/SortableBehavior.php | SortableBehavior.getNextSortValue | public function getNextSortValue(array $scope = []): int
{
$query = $this->_table->query();
$scope = Hash::merge($this->getConfig('scope'), $scope);
if (!empty($scope)) {
$query->where($scope);
}
$query->select([
'maxSort' => $query->func()->max($this->getConfig('sortField')),
]);
$res = $query->enableHydration(false)->first();
if (empty($res)) {
return 1;
}
return ($res['maxSort'] + 1);
} | php | public function getNextSortValue(array $scope = []): int
{
$query = $this->_table->query();
$scope = Hash::merge($this->getConfig('scope'), $scope);
if (!empty($scope)) {
$query->where($scope);
}
$query->select([
'maxSort' => $query->func()->max($this->getConfig('sortField')),
]);
$res = $query->enableHydration(false)->first();
if (empty($res)) {
return 1;
}
return ($res['maxSort'] + 1);
} | [
"public",
"function",
"getNextSortValue",
"(",
"array",
"$",
"scope",
"=",
"[",
"]",
")",
":",
"int",
"{",
"$",
"query",
"=",
"$",
"this",
"->",
"_table",
"->",
"query",
"(",
")",
";",
"$",
"scope",
"=",
"Hash",
"::",
"merge",
"(",
"$",
"this",
"... | Returns the next highest sort value
@param array $scope Optional conditions
@return int | [
"Returns",
"the",
"next",
"highest",
"sort",
"value"
] | efba42cf4e1804df8f1faa83ef75927bee6c206b | https://github.com/scherersoftware/cake-cktools/blob/efba42cf4e1804df8f1faa83ef75927bee6c206b/src/Model/Behavior/SortableBehavior.php#L171-L187 | train |
Roave/RoaveDeveloperTools | src/Roave/DeveloperTools/Mvc/Inspection/ConfigInspection.php | ConfigInspection.makeArraySerializable | private function makeArraySerializable(array $data)
{
$serializable = [];
foreach ($data as $key => $value) {
if (is_object($value)) {
$serializable[$key] = new ObjectStub($value);
continue;
}
$serializable[$key] = is_array($value) ? $this->makeArraySerializable($value) : $value;
}
return $serializable;
} | php | private function makeArraySerializable(array $data)
{
$serializable = [];
foreach ($data as $key => $value) {
if (is_object($value)) {
$serializable[$key] = new ObjectStub($value);
continue;
}
$serializable[$key] = is_array($value) ? $this->makeArraySerializable($value) : $value;
}
return $serializable;
} | [
"private",
"function",
"makeArraySerializable",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"serializable",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"is_object",
"(",
"$",
"value",
")",... | Replaces the un-serializable items in an array with stubs
@param array|\Traversable $data
@return array | [
"Replaces",
"the",
"un",
"-",
"serializable",
"items",
"in",
"an",
"array",
"with",
"stubs"
] | 424285eb861c9df7891ce7c6e66a21756eecd81c | https://github.com/Roave/RoaveDeveloperTools/blob/424285eb861c9df7891ce7c6e66a21756eecd81c/src/Roave/DeveloperTools/Mvc/Inspection/ConfigInspection.php#L74-L89 | train |
MovingImage24/VMProApiClient | lib/Util/SearchEndpointTrait.php | SearchEndpointTrait.createElasticSearchQuery | private function createElasticSearchQuery(array $params, $operator = 'AND')
{
$filteredParams = [];
foreach ($params as $name => $value) {
if (empty($name) || empty($value)) {
continue;
}
$filteredParams[] = "$name:$value";
}
return implode(" $operator ", $filteredParams);
} | php | private function createElasticSearchQuery(array $params, $operator = 'AND')
{
$filteredParams = [];
foreach ($params as $name => $value) {
if (empty($name) || empty($value)) {
continue;
}
$filteredParams[] = "$name:$value";
}
return implode(" $operator ", $filteredParams);
} | [
"private",
"function",
"createElasticSearchQuery",
"(",
"array",
"$",
"params",
",",
"$",
"operator",
"=",
"'AND'",
")",
"{",
"$",
"filteredParams",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if... | Creates an elastic search query from the provided array od parameters.
@param array $params
@param string $operator
@return string | [
"Creates",
"an",
"elastic",
"search",
"query",
"from",
"the",
"provided",
"array",
"od",
"parameters",
"."
] | e242a88a93a7a915898c888a575502c21434e35b | https://github.com/MovingImage24/VMProApiClient/blob/e242a88a93a7a915898c888a575502c21434e35b/lib/Util/SearchEndpointTrait.php#L23-L35 | train |
MovingImage24/VMProApiClient | lib/Util/SearchEndpointTrait.php | SearchEndpointTrait.normalizeSearchChannelsResponse | private function normalizeSearchChannelsResponse($response)
{
$response = json_decode($response, true);
if (!is_array($response) || !array_key_exists('result', $response) || !array_key_exists('total', $response)) {
throw new Exception('Invalid response from search endpoint');
}
$response['totalCount'] = $response['total'];
$response['channels'] = $response['result'];
unset($response['result'], $response['total']);
return json_encode($response);
} | php | private function normalizeSearchChannelsResponse($response)
{
$response = json_decode($response, true);
if (!is_array($response) || !array_key_exists('result', $response) || !array_key_exists('total', $response)) {
throw new Exception('Invalid response from search endpoint');
}
$response['totalCount'] = $response['total'];
$response['channels'] = $response['result'];
unset($response['result'], $response['total']);
return json_encode($response);
} | [
"private",
"function",
"normalizeSearchChannelsResponse",
"(",
"$",
"response",
")",
"{",
"$",
"response",
"=",
"json_decode",
"(",
"$",
"response",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"response",
")",
"||",
"!",
"array_key_exists",
... | Adjust the response from the `search` endpoint for channel data type.
Namely, it renames the root-level properties, so they can be correctly unserialized.
@param string $response
@return string
@throws Exception | [
"Adjust",
"the",
"response",
"from",
"the",
"search",
"endpoint",
"for",
"channel",
"data",
"type",
".",
"Namely",
"it",
"renames",
"the",
"root",
"-",
"level",
"properties",
"so",
"they",
"can",
"be",
"correctly",
"unserialized",
"."
] | e242a88a93a7a915898c888a575502c21434e35b | https://github.com/MovingImage24/VMProApiClient/blob/e242a88a93a7a915898c888a575502c21434e35b/lib/Util/SearchEndpointTrait.php#L93-L105 | train |
shardimage/shardimage-php | src/services/UrlService.php | UrlService.createFetch | public function createFetch($params, $optParams = [])
{
if (is_string($params)) {
$params = ['url' => $params];
}
$params = $this->client->fillParams(['cloudId', 'url'], $params);
return $this->build('/f/'.$params['url'], $params, $optParams);
} | php | public function createFetch($params, $optParams = [])
{
if (is_string($params)) {
$params = ['url' => $params];
}
$params = $this->client->fillParams(['cloudId', 'url'], $params);
return $this->build('/f/'.$params['url'], $params, $optParams);
} | [
"public",
"function",
"createFetch",
"(",
"$",
"params",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"[",
"'url'",
"=>",
"$",
"params",
"]",
";",
"}",
"$",
"params... | Creates the fetch URL for a remote image.
@param array|string $params Required API parameters
<li>cloudId - cloud ID
<li>url - image URL
@param array $optParams Optional API parameters
<li>option - options defined by shardimage\shardimagephp\factories\Option
<li>transformation - transformations defined by shardimage\shardimagephp\factories\Transformation
<li>version - version number (to force cache miss)
<li>security - "basic" or "token"
@return string | [
"Creates",
"the",
"fetch",
"URL",
"for",
"a",
"remote",
"image",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/UrlService.php#L92-L101 | train |
shardimage/shardimage-php | src/services/UrlService.php | UrlService.createFacebook | public function createFacebook($params, $optParams = [])
{
if (is_string($params)) {
$params = ['facebookId' => $params];
}
$params = $this->client->fillParams(['cloudId', 'facebookId'], $params);
return $this->build('/r/facebook/'.$params['facebookId'], $params, $optParams);
} | php | public function createFacebook($params, $optParams = [])
{
if (is_string($params)) {
$params = ['facebookId' => $params];
}
$params = $this->client->fillParams(['cloudId', 'facebookId'], $params);
return $this->build('/r/facebook/'.$params['facebookId'], $params, $optParams);
} | [
"public",
"function",
"createFacebook",
"(",
"$",
"params",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"[",
"'facebookId'",
"=>",
"$",
"params",
"]",
";",
"}",
"$",... | Creates the URL for a Facebook profile picture.
@param array|string $params Required API parameters
<li>cloudId - cloud ID
<li>facebookId - Facebook user ID
@param array $optParams Optional API parameters
<li>option - options defined by shardimage\shardimagephp\factories\Option
<li>transformation - transformations defined by shardimage\shardimagephp\factories\Transformation
<li>version - version number (to force cache miss)
<li>format - output format
<li>seo - SEO filename
<li>security - "basic" or "token"
@return string | [
"Creates",
"the",
"URL",
"for",
"a",
"Facebook",
"profile",
"picture",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/UrlService.php#L121-L129 | train |
shardimage/shardimage-php | src/services/UrlService.php | UrlService.createTwitter | public function createTwitter($params, $optParams = [])
{
if (is_string($params)) {
$params = ['twitterId' => $params];
}
$params = $this->client->fillParams(['cloudId', 'twitterId'], $params);
return $this->build('/r/twitter/'.$params['twitterId'], $params, $optParams);
} | php | public function createTwitter($params, $optParams = [])
{
if (is_string($params)) {
$params = ['twitterId' => $params];
}
$params = $this->client->fillParams(['cloudId', 'twitterId'], $params);
return $this->build('/r/twitter/'.$params['twitterId'], $params, $optParams);
} | [
"public",
"function",
"createTwitter",
"(",
"$",
"params",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"[",
"'twitterId'",
"=>",
"$",
"params",
"]",
";",
"}",
"$",
... | Creates the URL for a Twitter profile picture.
@param array|string $params Required API parameters
<li>cloudId - cloud ID
<li>twitterId - Twitter user ID
@param array $optParams Optional API parameters
<li>option - options defined by shardimage\shardimagephp\factories\Option
<li>transformation - transformations defined by shardimage\shardimagephp\factories\Transformation
<li>version - version number (to force cache miss)
<li>format - output format
<li>seo - SEO filename
<li>security - "basic" or "token"
@return string | [
"Creates",
"the",
"URL",
"for",
"a",
"Twitter",
"profile",
"picture",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/UrlService.php#L149-L157 | train |
shardimage/shardimage-php | src/services/UrlService.php | UrlService.createYoutube | public function createYoutube($params, $optParams = [])
{
if (is_string($params)) {
$params = ['youtubeId' => $params];
}
$params = $this->client->fillParams(['cloudId', 'youtubeId'], $params);
return $this->build('/r/youtube/'.$params['youtubeId'], $params, $optParams);
} | php | public function createYoutube($params, $optParams = [])
{
if (is_string($params)) {
$params = ['youtubeId' => $params];
}
$params = $this->client->fillParams(['cloudId', 'youtubeId'], $params);
return $this->build('/r/youtube/'.$params['youtubeId'], $params, $optParams);
} | [
"public",
"function",
"createYoutube",
"(",
"$",
"params",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"[",
"'youtubeId'",
"=>",
"$",
"params",
"]",
";",
"}",
"$",
... | Creates the URL for a YouTube video preview image.
@param array|string $params Required API parameters
<li>cloudId - cloud ID
<li>youtubeId - YouTube video ID
@param array $optParams Optional API parameters
<li>option - options defined by shardimage\shardimagephp\factories\Option
<li>transformation - transformations defined by shardimage\shardimagephp\factories\Transformation
<li>version - version number (to force cache miss)
<li>format - output format
<li>seo - SEO filename
<li>security - "basic" or "token"
@return string | [
"Creates",
"the",
"URL",
"for",
"a",
"YouTube",
"video",
"preview",
"image",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/UrlService.php#L177-L185 | train |
shardimage/shardimage-php | src/services/UrlService.php | UrlService.createCloudinary | public function createCloudinary($params, $optParams = [])
{
$params = $this->client->fillParams(['cloudId', 'cloudinaryCloud', 'cloudinaryImage'], $params);
return $this->build('/r/cloudinary/'.urlencode($params['cloudinaryCloud'].'/'.$params['cloudinaryImage']), $params, $optParams);
} | php | public function createCloudinary($params, $optParams = [])
{
$params = $this->client->fillParams(['cloudId', 'cloudinaryCloud', 'cloudinaryImage'], $params);
return $this->build('/r/cloudinary/'.urlencode($params['cloudinaryCloud'].'/'.$params['cloudinaryImage']), $params, $optParams);
} | [
"public",
"function",
"createCloudinary",
"(",
"$",
"params",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"$",
"params",
"=",
"$",
"this",
"->",
"client",
"->",
"fillParams",
"(",
"[",
"'cloudId'",
",",
"'cloudinaryCloud'",
",",
"'cloudinaryImage'",
"]... | Creates the URL for a Cloudinary image.
@param array $params Required API parameters
<li>cloudId - cloud ID
<li>cloudinaryCloud - Cloudinary cloud ID + folder
<li>cloudinaryImage - Cloudinary image ID
@param array $optParams Optional API parameters
<li>option - options defined by shardimage\shardimagephp\factories\Option
<li>transformation - transformations defined by shardimage\shardimagephp\factories\Transformation
<li>version - version number (to force cache miss)
<li>format - output format
<li>seo - SEO filename
<li>security - "basic" or "token"
@return string | [
"Creates",
"the",
"URL",
"for",
"a",
"Cloudinary",
"image",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/UrlService.php#L206-L211 | train |
shardimage/shardimage-php | src/services/UrlService.php | UrlService.createWikimedia | public function createWikimedia($params, $optParams = [])
{
if (is_string($params)) {
$params = ['wikimediaImage' => $params];
}
$params = $this->client->fillParams(['cloudId', 'wikimediaImage'], $params);
return $this->build('/r/commons/'.urlencode($params['wikimediaImage']), $params, $optParams);
} | php | public function createWikimedia($params, $optParams = [])
{
if (is_string($params)) {
$params = ['wikimediaImage' => $params];
}
$params = $this->client->fillParams(['cloudId', 'wikimediaImage'], $params);
return $this->build('/r/commons/'.urlencode($params['wikimediaImage']), $params, $optParams);
} | [
"public",
"function",
"createWikimedia",
"(",
"$",
"params",
",",
"$",
"optParams",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"params",
")",
")",
"{",
"$",
"params",
"=",
"[",
"'wikimediaImage'",
"=>",
"$",
"params",
"]",
";",
"}",
... | Creates the URL for a Wikimedia commons image.
@param array|string $params Required API parameters
<li>cloudId - cloud ID
<li>wikimediaImage - Wikimedia image URL
@param array $optParams Optional API parameters
<li>option - options defined by shardimage\shardimagephp\factories\Option
<li>transformation - transformations defined by shardimage\shardimagephp\factories\Transformation
<li>version - version number (to force cache miss)
<li>format - output format
<li>seo - SEO filename
<li>security - "basic" or "token"
@return string | [
"Creates",
"the",
"URL",
"for",
"a",
"Wikimedia",
"commons",
"image",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/UrlService.php#L231-L239 | train |
shardimage/shardimage-php | src/services/UrlService.php | UrlService.build | private function build($resource, $params, $optParams)
{
$url = '';
if (isset($optParams['option'])) {
$option = (string) $optParams['option'];
if (!empty($option)) {
$url .= '/o-'.$option;
}
}
if (isset($optParams['transformation'])) {
$transformation = (string) $optParams['transformation'];
if (!empty($transformation)) {
$url .= '/' . trim($transformation, '/');
}
}
if (isset($optParams['version'])) {
$url .= '/v/'.$optParams['version'];
}
$url .= $resource;
if (isset($optParams['format'])) {
$url .= '.'.$optParams['format'];
}
if (isset($optParams['seo'])) {
$url .= '/seo/'.$optParams['seo'];
}
$security = '';
if (isset($optParams['security'])) {
switch ($optParams['security']) {
case 'basic':
if (!$this->client->apiKey || !$this->client->imageSecret) {
throw new InvalidConfigException('The apiKey and imageSecret must be specified!');
}
$security = '/s-b3:'.SecurityHelper::generateImageSecretSignature($this->client->imageHostname, ltrim($url, '/'), $this->client->apiKey, $this->client->imageSecret);
break;
case 'token':
if (!$this->client->apiAccessTokenSecret){
throw new InvalidConfigException('The apiAccessTokenSecret must be specified!');
}
$security = '/s-token:'.$this->client->apiAccessToken.','.SecurityHelper::generateTokenHash($this->client->imageHostname, ltrim($url, '/'), $this->client->apiAccessToken, $this->client->apiAccessTokenSecret);
break;
}
}
return $this->client->imageHost.'/'.$params['cloudId'].$security.$url;
} | php | private function build($resource, $params, $optParams)
{
$url = '';
if (isset($optParams['option'])) {
$option = (string) $optParams['option'];
if (!empty($option)) {
$url .= '/o-'.$option;
}
}
if (isset($optParams['transformation'])) {
$transformation = (string) $optParams['transformation'];
if (!empty($transformation)) {
$url .= '/' . trim($transformation, '/');
}
}
if (isset($optParams['version'])) {
$url .= '/v/'.$optParams['version'];
}
$url .= $resource;
if (isset($optParams['format'])) {
$url .= '.'.$optParams['format'];
}
if (isset($optParams['seo'])) {
$url .= '/seo/'.$optParams['seo'];
}
$security = '';
if (isset($optParams['security'])) {
switch ($optParams['security']) {
case 'basic':
if (!$this->client->apiKey || !$this->client->imageSecret) {
throw new InvalidConfigException('The apiKey and imageSecret must be specified!');
}
$security = '/s-b3:'.SecurityHelper::generateImageSecretSignature($this->client->imageHostname, ltrim($url, '/'), $this->client->apiKey, $this->client->imageSecret);
break;
case 'token':
if (!$this->client->apiAccessTokenSecret){
throw new InvalidConfigException('The apiAccessTokenSecret must be specified!');
}
$security = '/s-token:'.$this->client->apiAccessToken.','.SecurityHelper::generateTokenHash($this->client->imageHostname, ltrim($url, '/'), $this->client->apiAccessToken, $this->client->apiAccessTokenSecret);
break;
}
}
return $this->client->imageHost.'/'.$params['cloudId'].$security.$url;
} | [
"private",
"function",
"build",
"(",
"$",
"resource",
",",
"$",
"params",
",",
"$",
"optParams",
")",
"{",
"$",
"url",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"optParams",
"[",
"'option'",
"]",
")",
")",
"{",
"$",
"option",
"=",
"(",
"strin... | Builds the URL.
@param string $resource Resource component of URL
@param array $params Required API parameters
<li>cloudId - cloud ID
@param array $optParams Optional API parameters
<li>option - options defined by shardimage\shardimagephp\factories\Option
<li>transformation - transformations defined by shardimage\shardimagephp\factories\Transformation
<li>version - version number (to force cache miss)
<li>format - output format
<li>seo - SEO filename
<li>security - "basic" or "token"
@return string | [
"Builds",
"the",
"URL",
"."
] | 1988e3996dfdf7e17d1bd44d5d807f9884ac64bd | https://github.com/shardimage/shardimage-php/blob/1988e3996dfdf7e17d1bd44d5d807f9884ac64bd/src/services/UrlService.php#L259-L303 | train |
CHH/pipe | lib/Pipe/Environment.php | Environment.find | function find($logicalPath, $options = array())
{
$path = new FileUtils\PathInfo($logicalPath);
if ($path->isAbsolute()) {
$realPath = $logicalPath;
} else {
$realPath = $this->loadPaths->find($logicalPath);
}
if (!is_file($realPath)) {
return;
}
if (null === $realPath) {
return;
}
if (@$options["bundled"]) {
$asset = new BundledAsset($this, $realPath, $logicalPath);
} else {
$asset = new ProcessedAsset($this, $realPath, $logicalPath);
}
return $asset;
} | php | function find($logicalPath, $options = array())
{
$path = new FileUtils\PathInfo($logicalPath);
if ($path->isAbsolute()) {
$realPath = $logicalPath;
} else {
$realPath = $this->loadPaths->find($logicalPath);
}
if (!is_file($realPath)) {
return;
}
if (null === $realPath) {
return;
}
if (@$options["bundled"]) {
$asset = new BundledAsset($this, $realPath, $logicalPath);
} else {
$asset = new ProcessedAsset($this, $realPath, $logicalPath);
}
return $asset;
} | [
"function",
"find",
"(",
"$",
"logicalPath",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"path",
"=",
"new",
"FileUtils",
"\\",
"PathInfo",
"(",
"$",
"logicalPath",
")",
";",
"if",
"(",
"$",
"path",
"->",
"isAbsolute",
"(",
")",
")"... | Finds the logical path in the stack of load paths
and returns the Asset.
Example:
<?php
// Get the bundled application.js
$asset = $env->find('application.js', ['bundled' => true]);
@param string $logicalPath Path relative to the load path.
@param array $options
@return Asset | [
"Finds",
"the",
"logical",
"path",
"in",
"the",
"stack",
"of",
"load",
"paths",
"and",
"returns",
"the",
"Asset",
"."
] | 306ee3a1e763ba6c0536ed8a0225d1c81f780e83 | https://github.com/CHH/pipe/blob/306ee3a1e763ba6c0536ed8a0225d1c81f780e83/lib/Pipe/Environment.php#L123-L148 | train |
CHH/pipe | lib/Pipe/Environment.php | Environment.logicalPath | function logicalPath($absolutePath)
{
foreach ($this->loadPaths->paths() as $lp) {
$absoluteLoadPath = realpath($lp);
if (strpos($absolutePath, $absoluteLoadPath) === 0) {
return ltrim(substr($absolutePath, strlen($absoluteLoadPath)), '/');
}
}
} | php | function logicalPath($absolutePath)
{
foreach ($this->loadPaths->paths() as $lp) {
$absoluteLoadPath = realpath($lp);
if (strpos($absolutePath, $absoluteLoadPath) === 0) {
return ltrim(substr($absolutePath, strlen($absoluteLoadPath)), '/');
}
}
} | [
"function",
"logicalPath",
"(",
"$",
"absolutePath",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"loadPaths",
"->",
"paths",
"(",
")",
"as",
"$",
"lp",
")",
"{",
"$",
"absoluteLoadPath",
"=",
"realpath",
"(",
"$",
"lp",
")",
";",
"if",
"(",
"strpos"... | Calculates the logical path for the given absolute path
@param string $absolutePath
@return string | [
"Calculates",
"the",
"logical",
"path",
"for",
"the",
"given",
"absolute",
"path"
] | 306ee3a1e763ba6c0536ed8a0225d1c81f780e83 | https://github.com/CHH/pipe/blob/306ee3a1e763ba6c0536ed8a0225d1c81f780e83/lib/Pipe/Environment.php#L156-L165 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.