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
SaftIng/Saft
src/Saft/Store/AbstractTriplePatternStore.php
AbstractTriplePatternStore.getStatements
protected function getStatements(Query $queryObject) { $queryParts = $queryObject->getQueryParts(); $statementArray = []; // if only triples, but no quads if (true === isset($queryParts['triple_pattern']) && false === isset($queryParts['quad_pattern'])) { foreach ($queryParts['triple_pattern'] as $pattern) { /** * Create Node instances for S, P and O to build a Statement instance later on. */ $s = $this->createNodeByValueAndType($pattern['s'], $pattern['s_type']); $p = $this->createNodeByValueAndType($pattern['p'], $pattern['p_type']); $o = $this->createNodeByValueAndType($pattern['o'], $pattern['o_type']); $g = null; $statementArray[] = $this->statementFactory->createStatement($s, $p, $o, $g); } // if only quads, but not triples } elseif (false === isset($queryParts['triple_pattern']) && true === isset($queryParts['quad_pattern'])) { foreach ($queryParts['quad_pattern'] as $pattern) { /** * Create Node instances for S, P and O to build a Statement instance later on. */ $s = $this->createNodeByValueAndType($pattern['s'], $pattern['s_type']); $p = $this->createNodeByValueAndType($pattern['p'], $pattern['p_type']); $o = $this->createNodeByValueAndType($pattern['o'], $pattern['o_type']); $g = $this->createNodeByValueAndType($pattern['g'], $pattern['g_type']); $statementArray[] = $this->statementFactory->createStatement($s, $p, $o, $g); } // found quads and triples } elseif (true === isset($queryParts['triple_pattern']) && true === isset($queryParts['quad_pattern'])) { throw new \Exception('Query contains quads and triples. That is not supported yet.'); // neither quads nor triples } else { throw new \Exception('Query contains neither quads nor triples.'); } return $this->statementIteratorFactory->createStatementIteratorFromArray($statementArray); }
php
protected function getStatements(Query $queryObject) { $queryParts = $queryObject->getQueryParts(); $statementArray = []; // if only triples, but no quads if (true === isset($queryParts['triple_pattern']) && false === isset($queryParts['quad_pattern'])) { foreach ($queryParts['triple_pattern'] as $pattern) { /** * Create Node instances for S, P and O to build a Statement instance later on. */ $s = $this->createNodeByValueAndType($pattern['s'], $pattern['s_type']); $p = $this->createNodeByValueAndType($pattern['p'], $pattern['p_type']); $o = $this->createNodeByValueAndType($pattern['o'], $pattern['o_type']); $g = null; $statementArray[] = $this->statementFactory->createStatement($s, $p, $o, $g); } // if only quads, but not triples } elseif (false === isset($queryParts['triple_pattern']) && true === isset($queryParts['quad_pattern'])) { foreach ($queryParts['quad_pattern'] as $pattern) { /** * Create Node instances for S, P and O to build a Statement instance later on. */ $s = $this->createNodeByValueAndType($pattern['s'], $pattern['s_type']); $p = $this->createNodeByValueAndType($pattern['p'], $pattern['p_type']); $o = $this->createNodeByValueAndType($pattern['o'], $pattern['o_type']); $g = $this->createNodeByValueAndType($pattern['g'], $pattern['g_type']); $statementArray[] = $this->statementFactory->createStatement($s, $p, $o, $g); } // found quads and triples } elseif (true === isset($queryParts['triple_pattern']) && true === isset($queryParts['quad_pattern'])) { throw new \Exception('Query contains quads and triples. That is not supported yet.'); // neither quads nor triples } else { throw new \Exception('Query contains neither quads nor triples.'); } return $this->statementIteratorFactory->createStatementIteratorFromArray($statementArray); }
[ "protected", "function", "getStatements", "(", "Query", "$", "queryObject", ")", "{", "$", "queryParts", "=", "$", "queryObject", "->", "getQueryParts", "(", ")", ";", "$", "statementArray", "=", "[", "]", ";", "// if only triples, but no quads", "if", "(", "t...
Create statements from query. @param Query $queryObject query object which represents a SPARQL query @return StatementIterator StatementIterator object @throws \Exception if query contains quads and triples at the same time @throws \Exception if query contains neither quads nor triples @api @since 0.1
[ "Create", "statements", "from", "query", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Store/AbstractTriplePatternStore.php#L255-L301
train
inpsyde/inpsyde-validator
src/ValidatorFactory.php
ValidatorFactory.create
public function create( $type, array $properties = [ ] ) { // If type is already an instance of validator, and no properties provided, we just return it as is if ( $type instanceof ValidatorInterface && ! $properties ) { return $type; } // If an instance of validator is given alongside some properties, we extract the class so a new instance // will be created with given properties if ( $type instanceof ValidatorInterface ) { $type = get_class( $type ); } // From now on, we expect a string, if not, let's just throw an exception if ( ! is_string( $type ) ) { throw new Exception\InvalidArgumentException( sprintf( 'Validator identifier must be in a string, %s given.', gettype( $type ) ) ); } // If `$type` is the fully qualified name of a validator class, just use it if ( is_subclass_of( $type, ValidatorInterface::class, TRUE ) ) { return new $type( $properties ); } // If name is fine, but namespace is missing, let's just add it and instantiate if ( is_subclass_of( __NAMESPACE__ . '\\' . $type, ValidatorInterface::class, TRUE ) ) { $class = __NAMESPACE__ . '\\' . $type; return new $class( $properties ); } $type = trim( $type ); // We accept case-insensitive types, e.g. 'greater_than', 'Greater_Than', 'GREATER_THAN' $lower_case_type = strtolower( $type ); if ( isset( self::$classes_map[ $lower_case_type ] ) ) { $class = self::$classes_map[ $lower_case_type ]; return new $class( $properties ); } // We also accept alternative version of identifier: // - TitleCased: 'GreaterThan' // - camelCased: 'greaterThan' // - separated with any character and case insensitive: 'greater-than', 'greater~than', 'Greater Than'... $alt_types[] = strtolower( preg_replace( [ '/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/' ], '$1_$2', $type ) ); $alt_types[] = preg_replace( '/[^a-z]+/', '_', $lower_case_type ); foreach ( $alt_types as $alt_type ) { if ( isset( self::$classes_map[ $alt_type ] ) ) { $class = self::$classes_map[ $alt_type ]; return new $class( $properties ); } } throw new Exception\InvalidArgumentException( sprintf( '%s is not an accepted validator identifier for %s.', $type, __METHOD__ ) ); }
php
public function create( $type, array $properties = [ ] ) { // If type is already an instance of validator, and no properties provided, we just return it as is if ( $type instanceof ValidatorInterface && ! $properties ) { return $type; } // If an instance of validator is given alongside some properties, we extract the class so a new instance // will be created with given properties if ( $type instanceof ValidatorInterface ) { $type = get_class( $type ); } // From now on, we expect a string, if not, let's just throw an exception if ( ! is_string( $type ) ) { throw new Exception\InvalidArgumentException( sprintf( 'Validator identifier must be in a string, %s given.', gettype( $type ) ) ); } // If `$type` is the fully qualified name of a validator class, just use it if ( is_subclass_of( $type, ValidatorInterface::class, TRUE ) ) { return new $type( $properties ); } // If name is fine, but namespace is missing, let's just add it and instantiate if ( is_subclass_of( __NAMESPACE__ . '\\' . $type, ValidatorInterface::class, TRUE ) ) { $class = __NAMESPACE__ . '\\' . $type; return new $class( $properties ); } $type = trim( $type ); // We accept case-insensitive types, e.g. 'greater_than', 'Greater_Than', 'GREATER_THAN' $lower_case_type = strtolower( $type ); if ( isset( self::$classes_map[ $lower_case_type ] ) ) { $class = self::$classes_map[ $lower_case_type ]; return new $class( $properties ); } // We also accept alternative version of identifier: // - TitleCased: 'GreaterThan' // - camelCased: 'greaterThan' // - separated with any character and case insensitive: 'greater-than', 'greater~than', 'Greater Than'... $alt_types[] = strtolower( preg_replace( [ '/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/' ], '$1_$2', $type ) ); $alt_types[] = preg_replace( '/[^a-z]+/', '_', $lower_case_type ); foreach ( $alt_types as $alt_type ) { if ( isset( self::$classes_map[ $alt_type ] ) ) { $class = self::$classes_map[ $alt_type ]; return new $class( $properties ); } } throw new Exception\InvalidArgumentException( sprintf( '%s is not an accepted validator identifier for %s.', $type, __METHOD__ ) ); }
[ "public", "function", "create", "(", "$", "type", ",", "array", "$", "properties", "=", "[", "]", ")", "{", "// If type is already an instance of validator, and no properties provided, we just return it as is", "if", "(", "$", "type", "instanceof", "ValidatorInterface", "...
Creates and returns a new validator instance of the given type. @param string|ValidatorInterface $type @param array $properties @throws Exception\InvalidArgumentException if validator of given $type is not found. @return ValidatorInterface|ExtendedValidatorInterface
[ "Creates", "and", "returns", "a", "new", "validator", "instance", "of", "the", "given", "type", "." ]
dcc57f705f142071a1764204bb469eee0bb5015d
https://github.com/inpsyde/inpsyde-validator/blob/dcc57f705f142071a1764204bb469eee0bb5015d/src/ValidatorFactory.php#L49-L117
train
danadesrosiers/silex-annotation-provider
src/ControllerFinder.php
ControllerFinder.parseNamespace
private function parseNamespace($filePath): string { preg_match('/namespace(.*);/', file_get_contents($filePath), $result); return isset($result[1]) ? $result[1] . "\\" : ''; }
php
private function parseNamespace($filePath): string { preg_match('/namespace(.*);/', file_get_contents($filePath), $result); return isset($result[1]) ? $result[1] . "\\" : ''; }
[ "private", "function", "parseNamespace", "(", "$", "filePath", ")", ":", "string", "{", "preg_match", "(", "'/namespace(.*);/'", ",", "file_get_contents", "(", "$", "filePath", ")", ",", "$", "result", ")", ";", "return", "isset", "(", "$", "result", "[", ...
Parse the given file to find the namespace. @param $filePath @return string
[ "Parse", "the", "given", "file", "to", "find", "the", "namespace", "." ]
f1bdf18bba17f3842ef0aab231e0ac5c831bd61f
https://github.com/danadesrosiers/silex-annotation-provider/blob/f1bdf18bba17f3842ef0aab231e0ac5c831bd61f/src/ControllerFinder.php#L95-L99
train
hypeJunction/hypeApps
classes/hypeJunction/Integration.php
Integration.getServiceProvider
public static function getServiceProvider() { if (is_callable('_elgg_services')) { return _elgg_services(); } global $CONFIG; if (!isset($CONFIG)) { $path = self::getRootPath() . '/engine/settings.php'; if (!is_file($path)) { $path = self::getRootPath() . '/elgg-config/settings.php'; } require_once $path; } return new \Elgg\Di\ServiceProvider(new \Elgg\Config($CONFIG)); }
php
public static function getServiceProvider() { if (is_callable('_elgg_services')) { return _elgg_services(); } global $CONFIG; if (!isset($CONFIG)) { $path = self::getRootPath() . '/engine/settings.php'; if (!is_file($path)) { $path = self::getRootPath() . '/elgg-config/settings.php'; } require_once $path; } return new \Elgg\Di\ServiceProvider(new \Elgg\Config($CONFIG)); }
[ "public", "static", "function", "getServiceProvider", "(", ")", "{", "if", "(", "is_callable", "(", "'_elgg_services'", ")", ")", "{", "return", "_elgg_services", "(", ")", ";", "}", "global", "$", "CONFIG", ";", "if", "(", "!", "isset", "(", "$", "CONFI...
Returns Elgg ServiceProvider instance @return ServiceProvider
[ "Returns", "Elgg", "ServiceProvider", "instance" ]
704a0aa57e817aa38bb9e40ad3710ba69d52e44c
https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Integration.php#L24-L39
train
hypeJunction/hypeApps
classes/hypeJunction/Integration.php
Integration.getElggVersion
public static function getElggVersion() { if (isset(self::$version)) { return self::$version; } if (is_callable('elgg_get_version')) { return elgg_get_version(true); } else { $path = self::getRootPath() . '/version.php'; if (!include($path)) { return false; } self::$version = $release; return self::$version; } }
php
public static function getElggVersion() { if (isset(self::$version)) { return self::$version; } if (is_callable('elgg_get_version')) { return elgg_get_version(true); } else { $path = self::getRootPath() . '/version.php'; if (!include($path)) { return false; } self::$version = $release; return self::$version; } }
[ "public", "static", "function", "getElggVersion", "(", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "version", ")", ")", "{", "return", "self", "::", "$", "version", ";", "}", "if", "(", "is_callable", "(", "'elgg_get_version'", ")", ")", "{",...
Returns Elgg version @return string|false
[ "Returns", "Elgg", "version" ]
704a0aa57e817aa38bb9e40ad3710ba69d52e44c
https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/Integration.php#L45-L61
train
cymapgt/UserCredential
lib/Multiotp/contrib/MultiotpXmlParser.php
MultiotpXmlParser.Parse
function Parse() { //Create the parser resource $this->parser = xml_parser_create(); //Set the handlers xml_set_object($this->parser, $this); xml_set_element_handler($this->parser, 'StartElement', 'EndElement'); xml_set_character_data_handler($this->parser, 'CharacterData'); //Error handling if (!xml_parse($this->parser, $this->xml)) $this->HandleError(xml_get_error_code($this->parser), xml_get_current_line_number($this->parser), xml_get_current_column_number($this->parser), xml_get_current_byte_index($this->parser)); //Free the parser xml_parser_free($this->parser); }
php
function Parse() { //Create the parser resource $this->parser = xml_parser_create(); //Set the handlers xml_set_object($this->parser, $this); xml_set_element_handler($this->parser, 'StartElement', 'EndElement'); xml_set_character_data_handler($this->parser, 'CharacterData'); //Error handling if (!xml_parse($this->parser, $this->xml)) $this->HandleError(xml_get_error_code($this->parser), xml_get_current_line_number($this->parser), xml_get_current_column_number($this->parser), xml_get_current_byte_index($this->parser)); //Free the parser xml_parser_free($this->parser); }
[ "function", "Parse", "(", ")", "{", "//Create the parser resource", "$", "this", "->", "parser", "=", "xml_parser_create", "(", ")", ";", "//Set the handlers", "xml_set_object", "(", "$", "this", "->", "parser", ",", "$", "this", ")", ";", "xml_set_element_handl...
Initiates and runs PHP's XML parser
[ "Initiates", "and", "runs", "PHP", "s", "XML", "parser" ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpXmlParser.php#L87-L103
train
cymapgt/UserCredential
lib/Multiotp/contrib/MultiotpXmlParser.php
MultiotpXmlParser.HandleError
function HandleError($code, $line, $col, $byte_index = 0) { $sample_size = 80; $sample_start = $byte_index - ($sample_size / 2); if ($sample_start < 0) { $sample_start = 0; } trigger_error('XML Parsing Error at '.$line.':'.$col. (($byte_index != 0)?' (byte index: '.$byte_index.')':''). '. Error '.$code.': '.xml_error_string($code). ' check sample which starts at position '.$sample_start.': html encoded: '.htmlentities(substr($this->xml, $sample_start, $sample_size)). ' (hex: '.bin2hex(substr($this->xml, $sample_start, $sample_size)).', raw: '.(substr($this->xml, $sample_start, $sample_size)).')'); }
php
function HandleError($code, $line, $col, $byte_index = 0) { $sample_size = 80; $sample_start = $byte_index - ($sample_size / 2); if ($sample_start < 0) { $sample_start = 0; } trigger_error('XML Parsing Error at '.$line.':'.$col. (($byte_index != 0)?' (byte index: '.$byte_index.')':''). '. Error '.$code.': '.xml_error_string($code). ' check sample which starts at position '.$sample_start.': html encoded: '.htmlentities(substr($this->xml, $sample_start, $sample_size)). ' (hex: '.bin2hex(substr($this->xml, $sample_start, $sample_size)).', raw: '.(substr($this->xml, $sample_start, $sample_size)).')'); }
[ "function", "HandleError", "(", "$", "code", ",", "$", "line", ",", "$", "col", ",", "$", "byte_index", "=", "0", ")", "{", "$", "sample_size", "=", "80", ";", "$", "sample_start", "=", "$", "byte_index", "-", "(", "$", "sample_size", "/", "2", ")"...
Handles an XML parsing error @param int $code XML Error Code @param int $line Line on which the error happened @param int $col Column on which the error happened
[ "Handles", "an", "XML", "parsing", "error" ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpXmlParser.php#L112-L121
train
cymapgt/UserCredential
lib/Multiotp/contrib/MultiotpXmlParser.php
MultiotpXmlParser.StartElement
function StartElement($parser, $name, $attrs = array()) { //Make the name of the tag lower case $name = strtolower($name); //Check to see if tag is root-level if (count($this->stack) == 0) { //If so, set the document as the current tag $this->document = new MultiotpXMLTag($name, $attrs); //And start out the stack with the document tag $this->stack = array('document'); } //If it isn't root level, use the stack to find the parent else { //Get the name which points to the current direct parent, relative to $this $parent = $this->GetStackLocation(); //Add the child eval('$this->'.$parent.'->AddChild($name, $attrs, '.count($this->stack).', $this->cleanTagNames);'); //If the cleanTagName feature is on, replace colons and dashes with underscores if($this->cleanTagNames) $name = str_replace(array(':', '-'), '_', $name); //Update the stack eval('$this->stack[] = $name.\'[\'.(count($this->'.$parent.'->'.$name.') - 1).\']\';'); } }
php
function StartElement($parser, $name, $attrs = array()) { //Make the name of the tag lower case $name = strtolower($name); //Check to see if tag is root-level if (count($this->stack) == 0) { //If so, set the document as the current tag $this->document = new MultiotpXMLTag($name, $attrs); //And start out the stack with the document tag $this->stack = array('document'); } //If it isn't root level, use the stack to find the parent else { //Get the name which points to the current direct parent, relative to $this $parent = $this->GetStackLocation(); //Add the child eval('$this->'.$parent.'->AddChild($name, $attrs, '.count($this->stack).', $this->cleanTagNames);'); //If the cleanTagName feature is on, replace colons and dashes with underscores if($this->cleanTagNames) $name = str_replace(array(':', '-'), '_', $name); //Update the stack eval('$this->stack[] = $name.\'[\'.(count($this->'.$parent.'->'.$name.') - 1).\']\';'); } }
[ "function", "StartElement", "(", "$", "parser", ",", "$", "name", ",", "$", "attrs", "=", "array", "(", ")", ")", "{", "//Make the name of the tag lower case", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "//Check to see if tag is root-level", "...
Handler function for the start of a tag @param resource $parser @param string $name @param array $attrs
[ "Handler", "function", "for", "the", "start", "of", "a", "tag" ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpXmlParser.php#L156-L187
train
cymapgt/UserCredential
lib/Multiotp/contrib/MultiotpXmlParser.php
MultiotpXMLTag.AddChild
function AddChild($name, $attrs, $parents, $cleanTagName = true) { //If the tag is a reserved name, output an error if(in_array($name, array('tagChildren', 'tagAttrs', 'tagParents', 'tagData', 'tagName'))) { trigger_error('You have used a reserved name as the name of an XML tag. Please consult the documentation (http://www.criticaldevelopment.net/xml/) and rename the tag named "'.$name.'" to something other than a reserved name.', E_USER_ERROR); return; } //Create the child object itself $child = new MultiotpXMLTag($name, $attrs, $parents); //If the cleanTagName feature is on, replace colons and dashes with underscores if($cleanTagName) $name = str_replace(array(':', '-'), '_', $name); //Toss up a notice if someone's trying to to use a colon or dash in a tag name elseif(strstr($name, ':') || strstr($name, '-')) trigger_error('Your tag named "'.$name.'" contains either a dash or a colon. Neither of these characters are friendly with PHP variable names, and, as such, they cannot be accessed and will cause the parser to not work. You must enable the cleanTagName feature (pass true as the second argument of the MultiotpXmlParser constructor). For more details, see http://www.criticaldevelopment.net/xml/', E_USER_ERROR); //If there is no array already set for the tag name being added, //create an empty array for it if(!isset($this->$name)) $this->$name = array(); //Add the reference of it to the end of an array member named for the tag's name $this->{$name}[] =& $child; //Add the reference to the children array member $this->tagChildren[] =& $child; }
php
function AddChild($name, $attrs, $parents, $cleanTagName = true) { //If the tag is a reserved name, output an error if(in_array($name, array('tagChildren', 'tagAttrs', 'tagParents', 'tagData', 'tagName'))) { trigger_error('You have used a reserved name as the name of an XML tag. Please consult the documentation (http://www.criticaldevelopment.net/xml/) and rename the tag named "'.$name.'" to something other than a reserved name.', E_USER_ERROR); return; } //Create the child object itself $child = new MultiotpXMLTag($name, $attrs, $parents); //If the cleanTagName feature is on, replace colons and dashes with underscores if($cleanTagName) $name = str_replace(array(':', '-'), '_', $name); //Toss up a notice if someone's trying to to use a colon or dash in a tag name elseif(strstr($name, ':') || strstr($name, '-')) trigger_error('Your tag named "'.$name.'" contains either a dash or a colon. Neither of these characters are friendly with PHP variable names, and, as such, they cannot be accessed and will cause the parser to not work. You must enable the cleanTagName feature (pass true as the second argument of the MultiotpXmlParser constructor). For more details, see http://www.criticaldevelopment.net/xml/', E_USER_ERROR); //If there is no array already set for the tag name being added, //create an empty array for it if(!isset($this->$name)) $this->$name = array(); //Add the reference of it to the end of an array member named for the tag's name $this->{$name}[] =& $child; //Add the reference to the children array member $this->tagChildren[] =& $child; }
[ "function", "AddChild", "(", "$", "name", ",", "$", "attrs", ",", "$", "parents", ",", "$", "cleanTagName", "=", "true", ")", "{", "//If the tag is a reserved name, output an error", "if", "(", "in_array", "(", "$", "name", ",", "array", "(", "'tagChildren'", ...
Adds a direct child to this object @param string $name @param array $attrs @param int $parents @param bool $cleanTagName
[ "Adds", "a", "direct", "child", "to", "this", "object" ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpXmlParser.php#L310-L341
train
cymapgt/UserCredential
lib/Multiotp/contrib/MultiotpXmlParser.php
MultiotpXMLTag.GetXML
function GetXML() { //Start a new line, indent by the number indicated in $this->parents, add a <, and add the name of the tag $out = "\n".str_repeat("\t", $this->tagParents).'<'.$this->tagName; //For each attribute, add attr="value" foreach($this->tagAttrs as $attr => $value) $out .= ' '.$attr.'="'.$value.'"'; //If there are no children and it contains no data, end it off with a /> if(empty($this->tagChildren) && empty($this->tagData)) $out .= " />"; //Otherwise... else { //If there are children if(!empty($this->tagChildren)) { //Close off the start tag $out .= '>'; //For each child, call the GetXML function (this will ensure that all children are added recursively) foreach($this->tagChildren as $child) { if(is_object($child)) $out .= $child->GetXML(); } //Add the newline and indentation to go along with the close tag $out .= "\n".str_repeat("\t", $this->tagParents); } //If there is data, close off the start tag and add the data elseif(!empty($this->tagData)) $out .= '>'.$this->tagData; //Add the end tag $out .= '</'.$this->tagName.'>'; } //Return the final output return $out; }
php
function GetXML() { //Start a new line, indent by the number indicated in $this->parents, add a <, and add the name of the tag $out = "\n".str_repeat("\t", $this->tagParents).'<'.$this->tagName; //For each attribute, add attr="value" foreach($this->tagAttrs as $attr => $value) $out .= ' '.$attr.'="'.$value.'"'; //If there are no children and it contains no data, end it off with a /> if(empty($this->tagChildren) && empty($this->tagData)) $out .= " />"; //Otherwise... else { //If there are children if(!empty($this->tagChildren)) { //Close off the start tag $out .= '>'; //For each child, call the GetXML function (this will ensure that all children are added recursively) foreach($this->tagChildren as $child) { if(is_object($child)) $out .= $child->GetXML(); } //Add the newline and indentation to go along with the close tag $out .= "\n".str_repeat("\t", $this->tagParents); } //If there is data, close off the start tag and add the data elseif(!empty($this->tagData)) $out .= '>'.$this->tagData; //Add the end tag $out .= '</'.$this->tagName.'>'; } //Return the final output return $out; }
[ "function", "GetXML", "(", ")", "{", "//Start a new line, indent by the number indicated in $this->parents, add a <, and add the name of the tag", "$", "out", "=", "\"\\n\"", ".", "str_repeat", "(", "\"\\t\"", ",", "$", "this", "->", "tagParents", ")", ".", "'<'", ".", ...
Returns the string of the XML document which would be generated from this object This function works recursively, so it gets the XML of itself and all of its children, which in turn gets the XML of all their children, which in turn gets the XML of all thier children, and so on. So, if you call GetXML from the document root object, it will return a string for the XML of the entire document. This function does not, however, return a DTD or an XML version/encoding tag. That should be handled by MultiotpXmlParser::GetXML() @return string
[ "Returns", "the", "string", "of", "the", "XML", "document", "which", "would", "be", "generated", "from", "this", "object" ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpXmlParser.php#L356-L399
train
cymapgt/UserCredential
lib/Multiotp/contrib/MultiotpXmlParser.php
MultiotpXMLTag.DeleteChildren
function DeleteChildren() { //Loop through all child tags for($x = 0; $x < count($this->tagChildren); $x ++) { //Do this recursively $this->tagChildren[$x]->DeleteChildren(); //Delete the name and value $this->tagChildren[$x] = null; unset($this->tagChildren[$x]); } }
php
function DeleteChildren() { //Loop through all child tags for($x = 0; $x < count($this->tagChildren); $x ++) { //Do this recursively $this->tagChildren[$x]->DeleteChildren(); //Delete the name and value $this->tagChildren[$x] = null; unset($this->tagChildren[$x]); } }
[ "function", "DeleteChildren", "(", ")", "{", "//Loop through all child tags", "for", "(", "$", "x", "=", "0", ";", "$", "x", "<", "count", "(", "$", "this", "->", "tagChildren", ")", ";", "$", "x", "++", ")", "{", "//Do this recursively", "$", "this", ...
Removes all of the children of this tag in both name and value
[ "Removes", "all", "of", "the", "children", "of", "this", "tag", "in", "both", "name", "and", "value" ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/MultiotpXmlParser.php#L431-L443
train
shopgate/cart-integration-magento2-base
src/Helper/Redirect.php
Redirect.isTypeJavaScript
public function isTypeJavaScript() { $redirectType = $this->coreConfig->getConfigByPath(SgCoreInterface::PATH_REDIRECT_TYPE); return $redirectType->getValue() === SgCoreInterface::VALUE_REDIRECT_JS; }
php
public function isTypeJavaScript() { $redirectType = $this->coreConfig->getConfigByPath(SgCoreInterface::PATH_REDIRECT_TYPE); return $redirectType->getValue() === SgCoreInterface::VALUE_REDIRECT_JS; }
[ "public", "function", "isTypeJavaScript", "(", ")", "{", "$", "redirectType", "=", "$", "this", "->", "coreConfig", "->", "getConfigByPath", "(", "SgCoreInterface", "::", "PATH_REDIRECT_TYPE", ")", ";", "return", "$", "redirectType", "->", "getValue", "(", ")", ...
Checks if setting for JavaScript type redirect is set in core_config_data table @return bool
[ "Checks", "if", "setting", "for", "JavaScript", "type", "redirect", "is", "set", "in", "core_config_data", "table" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Redirect.php#L93-L98
train
Team-Tea-Time/laravel-filer
src/Controllers/LocalFileController.php
LocalFileController.view
public function view($id) { $file = LocalFile::getByIdentifier($id); $response = response($file->getContents(), 200)->withHeaders([ 'Content-Type' => $file->getFile()->getMimeType(), 'Cache-Control' => 'max-age=86400, public', 'Expires' => Carbon::now()->addSeconds(86400)->format('D, d M Y H:i:s \G\M\T') ]); return $response; }
php
public function view($id) { $file = LocalFile::getByIdentifier($id); $response = response($file->getContents(), 200)->withHeaders([ 'Content-Type' => $file->getFile()->getMimeType(), 'Cache-Control' => 'max-age=86400, public', 'Expires' => Carbon::now()->addSeconds(86400)->format('D, d M Y H:i:s \G\M\T') ]); return $response; }
[ "public", "function", "view", "(", "$", "id", ")", "{", "$", "file", "=", "LocalFile", "::", "getByIdentifier", "(", "$", "id", ")", ";", "$", "response", "=", "response", "(", "$", "file", "->", "getContents", "(", ")", ",", "200", ")", "->", "wit...
Attempt to render the specified file. @param int $id @return \Illuminate\Http\Response
[ "Attempt", "to", "render", "the", "specified", "file", "." ]
e69fae1bc99a317097e997b3d029ecc9be0a0b4b
https://github.com/Team-Tea-Time/laravel-filer/blob/e69fae1bc99a317097e997b3d029ecc9be0a0b4b/src/Controllers/LocalFileController.php#L15-L25
train
Team-Tea-Time/laravel-filer
src/Controllers/LocalFileController.php
LocalFileController.download
public function download($id) { $file = LocalFile::getByIdentifier($id); return response()->download($file->getAbsolutePath(), $file->getDownloadName()); }
php
public function download($id) { $file = LocalFile::getByIdentifier($id); return response()->download($file->getAbsolutePath(), $file->getDownloadName()); }
[ "public", "function", "download", "(", "$", "id", ")", "{", "$", "file", "=", "LocalFile", "::", "getByIdentifier", "(", "$", "id", ")", ";", "return", "response", "(", ")", "->", "download", "(", "$", "file", "->", "getAbsolutePath", "(", ")", ",", ...
Return a download response for the specified file. @param int $id @return \Illuminate\Http\Response
[ "Return", "a", "download", "response", "for", "the", "specified", "file", "." ]
e69fae1bc99a317097e997b3d029ecc9be0a0b4b
https://github.com/Team-Tea-Time/laravel-filer/blob/e69fae1bc99a317097e997b3d029ecc9be0a0b4b/src/Controllers/LocalFileController.php#L33-L37
train
SaftIng/Saft
src/Saft/Sparql/Query/QueryFactoryImpl.php
QueryFactoryImpl.createInstanceByQueryString
public function createInstanceByQueryString($query) { switch ($this->rdfHelpers->getQueryType($query)) { case 'askQuery': return new AskQueryImpl($query, $this->rdfHelpers); case 'constructQuery': return new ConstructQueryImpl($query, $this->rdfHelpers); case 'describeQuery': return new DescribeQueryImpl($query, $this->rdfHelpers); case 'graphQuery': return new GraphQueryImpl($query, $this->rdfHelpers); case 'selectQuery': return new SelectQueryImpl($query, $this->rdfHelpers); case 'updateQuery': return new UpdateQueryImpl($query, $this->rdfHelpers); default: throw new \Exception('Unknown query type: '.$query); } }
php
public function createInstanceByQueryString($query) { switch ($this->rdfHelpers->getQueryType($query)) { case 'askQuery': return new AskQueryImpl($query, $this->rdfHelpers); case 'constructQuery': return new ConstructQueryImpl($query, $this->rdfHelpers); case 'describeQuery': return new DescribeQueryImpl($query, $this->rdfHelpers); case 'graphQuery': return new GraphQueryImpl($query, $this->rdfHelpers); case 'selectQuery': return new SelectQueryImpl($query, $this->rdfHelpers); case 'updateQuery': return new UpdateQueryImpl($query, $this->rdfHelpers); default: throw new \Exception('Unknown query type: '.$query); } }
[ "public", "function", "createInstanceByQueryString", "(", "$", "query", ")", "{", "switch", "(", "$", "this", "->", "rdfHelpers", "->", "getQueryType", "(", "$", "query", ")", ")", "{", "case", "'askQuery'", ":", "return", "new", "AskQueryImpl", "(", "$", ...
Creates an instance of Query based on given query string. @param string $query SPARQL query string to use for class instantiation @return Query instance of Query
[ "Creates", "an", "instance", "of", "Query", "based", "on", "given", "query", "string", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Sparql/Query/QueryFactoryImpl.php#L36-L60
train
bakaphp/database
src/Model.php
Model.toFullArray
public function toFullArray(): array { //convert the obj to array in order to conver to json $result = get_object_vars($this); foreach ($result as $key => $value) { if (preg_match('#^_#', $key) === 1) { unset($result[$key]); } } return $result; }
php
public function toFullArray(): array { //convert the obj to array in order to conver to json $result = get_object_vars($this); foreach ($result as $key => $value) { if (preg_match('#^_#', $key) === 1) { unset($result[$key]); } } return $result; }
[ "public", "function", "toFullArray", "(", ")", ":", "array", "{", "//convert the obj to array in order to conver to json", "$", "result", "=", "get_object_vars", "(", "$", "this", ")", ";", "foreach", "(", "$", "result", "as", "$", "key", "=>", "$", "value", "...
Since Phalcon 3, they pass model objet throught the toArray function when we call json_encode, that can fuck u up, if you modify the obj so we need a way to convert it to array without loosing all the extra info we add @return array
[ "Since", "Phalcon", "3", "they", "pass", "model", "objet", "throught", "the", "toArray", "function", "when", "we", "call", "json_encode", "that", "can", "fuck", "u", "up", "if", "you", "modify", "the", "obj", "so", "we", "need", "a", "way", "to", "conver...
b227de7c27e819abadf56cfd66ff08dab2797d62
https://github.com/bakaphp/database/blob/b227de7c27e819abadf56cfd66ff08dab2797d62/src/Model.php#L97-L109
train
BerliozFramework/Berlioz
src/Services/Template/TwigExtension.php
TwigExtension.getApp
public function getApp(): App { if (!is_null($this->getTemplateEngine()->getApp())) { return $this->getTemplateEngine()->getApp(); } else { throw new RuntimeException('Template engine is not initialized with application'); } }
php
public function getApp(): App { if (!is_null($this->getTemplateEngine()->getApp())) { return $this->getTemplateEngine()->getApp(); } else { throw new RuntimeException('Template engine is not initialized with application'); } }
[ "public", "function", "getApp", "(", ")", ":", "App", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "getTemplateEngine", "(", ")", "->", "getApp", "(", ")", ")", ")", "{", "return", "$", "this", "->", "getTemplateEngine", "(", ")", "->", ...
Get application. @return \Berlioz\Core\App @throws \Berlioz\Core\Exception\RuntimeException if template engine is not initialized with application
[ "Get", "application", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Template/TwigExtension.php#L49-L56
train
BerliozFramework/Berlioz
src/Services/Template/TwigExtension.php
TwigExtension.filterDateFormat
public function filterDateFormat($datetime, string $pattern = 'dd/MM/yyyy', string $locale = null): string { if (empty($locale)) { $locale = $this->getApp()->getProfile()->getLocale(); } return b_date_format($datetime, $pattern, $locale); }
php
public function filterDateFormat($datetime, string $pattern = 'dd/MM/yyyy', string $locale = null): string { if (empty($locale)) { $locale = $this->getApp()->getProfile()->getLocale(); } return b_date_format($datetime, $pattern, $locale); }
[ "public", "function", "filterDateFormat", "(", "$", "datetime", ",", "string", "$", "pattern", "=", "'dd/MM/yyyy'", ",", "string", "$", "locale", "=", "null", ")", ":", "string", "{", "if", "(", "empty", "(", "$", "locale", ")", ")", "{", "$", "locale"...
Filter to format date. @param \DateTime|int $datetime DateTime object or timestamp @param string $pattern Pattern of date result waiting @param string $locale Locale for pattern translation @return string @throws \Berlioz\Core\Exception\RuntimeException if application not accessible
[ "Filter", "to", "format", "date", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Template/TwigExtension.php#L96-L103
train
BerliozFramework/Berlioz
src/Services/Template/TwigExtension.php
TwigExtension.functionPath
public function functionPath(string $name, array $parameters = []): string { return $this->getApp()->getService('routing')->generate($name, $parameters); }
php
public function functionPath(string $name, array $parameters = []): string { return $this->getApp()->getService('routing')->generate($name, $parameters); }
[ "public", "function", "functionPath", "(", "string", "$", "name", ",", "array", "$", "parameters", "=", "[", "]", ")", ":", "string", "{", "return", "$", "this", "->", "getApp", "(", ")", "->", "getService", "(", "'routing'", ")", "->", "generate", "("...
Function path to generate path. @param string $name @param array $parameters @return string @throws \Berlioz\Core\Exception\RuntimeException if application not accessible
[ "Function", "path", "to", "generate", "path", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Template/TwigExtension.php#L156-L159
train
BerliozFramework/Berlioz
src/Services/Template/TwigExtension.php
TwigExtension.functionPreload
public function functionPreload(string $link, array $parameters = []): string { $push = !(!empty($parameters['nopush']) && $parameters['nopush'] == true); if (!$push || !in_array(md5($link), $this->h2pushCache)) { $header = sprintf('Link: <%s>; rel=preload', $link); // as if (!empty($parameters['as'])) { $header = sprintf('%s; as=%s', $header, $parameters['as']); } // type if (!empty($parameters['type'])) { $header = sprintf('%s; type=%s', $header, $parameters['as']); } // crossorigin if (!empty($parameters['crossorigin']) && $parameters['crossorigin'] == true) { $header .= '; crossorigin'; } // nopush if (!$push) { $header .= '; nopush'; } header($header, false); // Cache if ($push) { $this->h2pushCache[] = md5($link); setcookie(sprintf('%s[%s]', self::H2PUSH_CACHE_COOKIE, md5($link)), 1, 0, '/', '', false, true); } } return $link; }
php
public function functionPreload(string $link, array $parameters = []): string { $push = !(!empty($parameters['nopush']) && $parameters['nopush'] == true); if (!$push || !in_array(md5($link), $this->h2pushCache)) { $header = sprintf('Link: <%s>; rel=preload', $link); // as if (!empty($parameters['as'])) { $header = sprintf('%s; as=%s', $header, $parameters['as']); } // type if (!empty($parameters['type'])) { $header = sprintf('%s; type=%s', $header, $parameters['as']); } // crossorigin if (!empty($parameters['crossorigin']) && $parameters['crossorigin'] == true) { $header .= '; crossorigin'; } // nopush if (!$push) { $header .= '; nopush'; } header($header, false); // Cache if ($push) { $this->h2pushCache[] = md5($link); setcookie(sprintf('%s[%s]', self::H2PUSH_CACHE_COOKIE, md5($link)), 1, 0, '/', '', false, true); } } return $link; }
[ "public", "function", "functionPreload", "(", "string", "$", "link", ",", "array", "$", "parameters", "=", "[", "]", ")", ":", "string", "{", "$", "push", "=", "!", "(", "!", "empty", "(", "$", "parameters", "[", "'nopush'", "]", ")", "&&", "$", "p...
Function preload to pre loading of request for HTTP 2 protocol. @param string $link @param array $parameters @return string Link
[ "Function", "preload", "to", "pre", "loading", "of", "request", "for", "HTTP", "2", "protocol", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Template/TwigExtension.php#L169-L203
train
p3ym4n/laravel-asset-manager
BaseAsset.php
BaseAsset.run
private function run($type) { //getting the defined array of assets //this method will define in the children classes $this->init(); //making the base path of public dir $this->getTarget(); //duplication check if ($type == 'del') { return Asset::delAsset($this->name); } //find all of them between patterns and folders $this->boot(); //check for those that have to copy to their cache folders foreach ($this->loop as $kind => $contents) { if ( ! empty($contents)) { foreach ($contents as $index => $content) { if ( ! $this->isPublic($this->baseDir . $content)) { $index = $this->baseDir . $content; $this->copy[$kind][$index] = public_path() . $this->target . $content; } else { $this->target = ''; } $this->destination[$kind][] = $this->target . $content; } } } //remove the ignored items from all other kinds if ( ! empty($this->loop['ignore'])) { foreach ($this->loop as $kind => $contents) { if ($kind != 'ignore' && ! empty($contents)) { $this->copy[$kind] = array_diff($this->copy[$kind], $this->copy['ignore']); $this->destination[$kind] = array_diff($this->destination[$kind], $this->destination['ignore']); } } unset($this->copy['ignore']); unset($this->destination['ignore']); } //un setting the include index from destination if (array_key_exists('include', $this->destination)) { unset($this->destination['include']); } //flatting the copy array $copyTemp = []; foreach ($this->copy as $kind => $contents) { foreach ($contents as $from => $to) { $copyTemp[$from] = $to; } } $this->copy = $copyTemp; //detect type of command and then we pass the data to the AssetHolder if ($type == 'add') { $result = array_merge($this->destination, [ 'name' => $this->name, 'copy' => $this->copy, 'forceCopy' => $this->forceCopy, 'chmod' => $this->chmod, 'style' => $this->style, 'script' => $this->script, 'cssOption' => $this->cssOption, 'jsOption' => $this->jsOption, ]); Asset::addAsset($result); } //we must destroy the previous object! self::$instance = null; }
php
private function run($type) { //getting the defined array of assets //this method will define in the children classes $this->init(); //making the base path of public dir $this->getTarget(); //duplication check if ($type == 'del') { return Asset::delAsset($this->name); } //find all of them between patterns and folders $this->boot(); //check for those that have to copy to their cache folders foreach ($this->loop as $kind => $contents) { if ( ! empty($contents)) { foreach ($contents as $index => $content) { if ( ! $this->isPublic($this->baseDir . $content)) { $index = $this->baseDir . $content; $this->copy[$kind][$index] = public_path() . $this->target . $content; } else { $this->target = ''; } $this->destination[$kind][] = $this->target . $content; } } } //remove the ignored items from all other kinds if ( ! empty($this->loop['ignore'])) { foreach ($this->loop as $kind => $contents) { if ($kind != 'ignore' && ! empty($contents)) { $this->copy[$kind] = array_diff($this->copy[$kind], $this->copy['ignore']); $this->destination[$kind] = array_diff($this->destination[$kind], $this->destination['ignore']); } } unset($this->copy['ignore']); unset($this->destination['ignore']); } //un setting the include index from destination if (array_key_exists('include', $this->destination)) { unset($this->destination['include']); } //flatting the copy array $copyTemp = []; foreach ($this->copy as $kind => $contents) { foreach ($contents as $from => $to) { $copyTemp[$from] = $to; } } $this->copy = $copyTemp; //detect type of command and then we pass the data to the AssetHolder if ($type == 'add') { $result = array_merge($this->destination, [ 'name' => $this->name, 'copy' => $this->copy, 'forceCopy' => $this->forceCopy, 'chmod' => $this->chmod, 'style' => $this->style, 'script' => $this->script, 'cssOption' => $this->cssOption, 'jsOption' => $this->jsOption, ]); Asset::addAsset($result); } //we must destroy the previous object! self::$instance = null; }
[ "private", "function", "run", "(", "$", "type", ")", "{", "//getting the defined array of assets", "//this method will define in the children classes", "$", "this", "->", "init", "(", ")", ";", "//making the base path of public dir", "$", "this", "->", "getTarget", "(", ...
run all the process and give the result to AssetHolder @param $type
[ "run", "all", "the", "process", "and", "give", "the", "result", "to", "AssetHolder" ]
cd51fd2226e1e97c9d0ee75f1e062089082c33b2
https://github.com/p3ym4n/laravel-asset-manager/blob/cd51fd2226e1e97c9d0ee75f1e062089082c33b2/BaseAsset.php#L69-L143
train
p3ym4n/laravel-asset-manager
BaseAsset.php
BaseAsset.getTarget
private function getTarget() { $this->name = str_replace('Asset', '', class_basename(static::class)); $name = $this->name; if ( ! empty($this->cacheFolder)) { $name = $this->cacheFolder; } $cacheName = trim(config('asset.public_cache_folder'), '/'); $this->target = '/' . $cacheName . '/' . studly_case($name) . '/'; }
php
private function getTarget() { $this->name = str_replace('Asset', '', class_basename(static::class)); $name = $this->name; if ( ! empty($this->cacheFolder)) { $name = $this->cacheFolder; } $cacheName = trim(config('asset.public_cache_folder'), '/'); $this->target = '/' . $cacheName . '/' . studly_case($name) . '/'; }
[ "private", "function", "getTarget", "(", ")", "{", "$", "this", "->", "name", "=", "str_replace", "(", "'Asset'", ",", "''", ",", "class_basename", "(", "static", "::", "class", ")", ")", ";", "$", "name", "=", "$", "this", "->", "name", ";", "if", ...
return the folder path of the assets in cache folder @return string
[ "return", "the", "folder", "path", "of", "the", "assets", "in", "cache", "folder" ]
cd51fd2226e1e97c9d0ee75f1e062089082c33b2
https://github.com/p3ym4n/laravel-asset-manager/blob/cd51fd2226e1e97c9d0ee75f1e062089082c33b2/BaseAsset.php#L226-L236
train
shopgate/cart-integration-magento2-base
src/Model/Carrier/Fix.php
Fix.getDefaultMethod
private function getDefaultMethod($price, $cost = null) { $method = $this->rateMethodFactory->create(); $method->setData('carrier', $this->getCarrierCode()); $method->setData('carrier_title', 'Shopgate'); $method->setData('method', $this->method); $method->setData('method_title', $this->getConfigData('name')); $method->setData('cost', $cost ? : $price); $method->setPrice($price); return $method; }
php
private function getDefaultMethod($price, $cost = null) { $method = $this->rateMethodFactory->create(); $method->setData('carrier', $this->getCarrierCode()); $method->setData('carrier_title', 'Shopgate'); $method->setData('method', $this->method); $method->setData('method_title', $this->getConfigData('name')); $method->setData('cost', $cost ? : $price); $method->setPrice($price); return $method; }
[ "private", "function", "getDefaultMethod", "(", "$", "price", ",", "$", "cost", "=", "null", ")", "{", "$", "method", "=", "$", "this", "->", "rateMethodFactory", "->", "create", "(", ")", ";", "$", "method", "->", "setData", "(", "'carrier'", ",", "$"...
Return the default shopgate payment method @param float $price @param float | null $cost @return \Magento\Quote\Model\Quote\Address\RateResult\Method
[ "Return", "the", "default", "shopgate", "payment", "method" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Model/Carrier/Fix.php#L127-L138
train
milesj/transit
src/Transit/Transformer/Image/FitTransformer.php
FitTransformer.fill
public function fill($image) { $fill = $this->getConfig('fill'); $r = $fill[0]; $g = $fill[1]; $b = $fill[2]; $a = isset($fill[3]) ? $fill[3] : 127; imagefill($image, 0, 0, imagecolorallocatealpha($image, $r, $g, $b, $a)); return $image; }
php
public function fill($image) { $fill = $this->getConfig('fill'); $r = $fill[0]; $g = $fill[1]; $b = $fill[2]; $a = isset($fill[3]) ? $fill[3] : 127; imagefill($image, 0, 0, imagecolorallocatealpha($image, $r, $g, $b, $a)); return $image; }
[ "public", "function", "fill", "(", "$", "image", ")", "{", "$", "fill", "=", "$", "this", "->", "getConfig", "(", "'fill'", ")", ";", "$", "r", "=", "$", "fill", "[", "0", "]", ";", "$", "g", "=", "$", "fill", "[", "1", "]", ";", "$", "b", ...
Fill the background with an RGB color. @param resource $image @return resource
[ "Fill", "the", "background", "with", "an", "RGB", "color", "." ]
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transformer/Image/FitTransformer.php#L117-L127
train
webeweb/core-library
src/Argument/DateTimeHelper.php
DateTimeHelper.getWeekNumberToApply
public static function getWeekNumberToApply(DateTime $date, DateTime $startDate, $weekCount, $weekOffset = 1) { // Check the week arguments. if ($weekCount <= 0 || $weekOffset <= 0 || $weekCount < $weekOffset) { return -1; } // Calculate. $result = intval($date->diff($startDate)->d / 7); $result %= $weekCount; $result += $weekOffset; if ($weekCount < $result) { $result -= $weekCount; } // Return. return $result; }
php
public static function getWeekNumberToApply(DateTime $date, DateTime $startDate, $weekCount, $weekOffset = 1) { // Check the week arguments. if ($weekCount <= 0 || $weekOffset <= 0 || $weekCount < $weekOffset) { return -1; } // Calculate. $result = intval($date->diff($startDate)->d / 7); $result %= $weekCount; $result += $weekOffset; if ($weekCount < $result) { $result -= $weekCount; } // Return. return $result; }
[ "public", "static", "function", "getWeekNumberToApply", "(", "DateTime", "$", "date", ",", "DateTime", "$", "startDate", ",", "$", "weekCount", ",", "$", "weekOffset", "=", "1", ")", "{", "// Check the week arguments.", "if", "(", "$", "weekCount", "<=", "0", ...
Get a week number to apply with a schedule. <p> For example: We have a schedule etablished over 5 weeks. We start the schedule with the week number 1. If the current date is 2018-01-01 and the start date is 2018-01-01, the week number is 1 If the current date is 2018-01-08 and the start date is 2018-01-01, the week number is 2 etc. We start the schedule with the week number 3. If the current date is 2018-01-01 and the start date is 2018-01-01, the week number is 3 If the current date is 2018-01-08 and the start date is 2018-01-01, the week number is 4 etc. </p> @param DateTime $date The date. @param DateTime $startDate The start date. @param int $weekCount The week count. @param int $weekOffset The week offset. @return int Returns the week number to apply between 1 and $weekCount.
[ "Get", "a", "week", "number", "to", "apply", "with", "a", "schedule", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Argument/DateTimeHelper.php#L165-L182
train
webeweb/core-library
src/Argument/DateTimeHelper.php
DateTimeHelper.translateWeekday
public static function translateWeekday($date, $locale = "en") { // Initialize. $template = __DIR__ . "/../Resources/translations/messages.%locale%.yml"; $filename = str_replace("%locale%", $locale, $template); // Check if the filename exists. if (false === file_exists($filename)) { $filename = str_replace("%locale%", "en", $template); } // Parse the translations. $translations = Yaml::parse(file_get_contents($filename)); // Return the weekday part translated. return str_ireplace(array_keys($translations["weekdays"]), array_values($translations["weekdays"]), $date); }
php
public static function translateWeekday($date, $locale = "en") { // Initialize. $template = __DIR__ . "/../Resources/translations/messages.%locale%.yml"; $filename = str_replace("%locale%", $locale, $template); // Check if the filename exists. if (false === file_exists($filename)) { $filename = str_replace("%locale%", "en", $template); } // Parse the translations. $translations = Yaml::parse(file_get_contents($filename)); // Return the weekday part translated. return str_ireplace(array_keys($translations["weekdays"]), array_values($translations["weekdays"]), $date); }
[ "public", "static", "function", "translateWeekday", "(", "$", "date", ",", "$", "locale", "=", "\"en\"", ")", "{", "// Initialize.", "$", "template", "=", "__DIR__", ".", "\"/../Resources/translations/messages.%locale%.yml\"", ";", "$", "filename", "=", "str_replace...
Translate the weekday part. @param string $date The date. @param string $locale The locale. @return string Returns the weekday part translated.
[ "Translate", "the", "weekday", "part", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Argument/DateTimeHelper.php#L256-L272
train
camspiers/silverstripe-loggerbridge
src/Camspiers/LoggerBridge/BacktraceReporter/FilteredBacktraceReporter.php
FilteredBacktraceReporter.getBacktrace
public function getBacktrace($exception = null) { $backtrace = parent::getBacktrace($exception); foreach ($backtrace as $index => $backtraceCall) { $functionName = $this->buildFunctionName($backtraceCall); foreach ($this->filteredFunctions as $pattern) { if (preg_match('/'.$pattern.'/', $functionName)) { unset($backtrace[$index]); break; } } } return array_values($backtrace); }
php
public function getBacktrace($exception = null) { $backtrace = parent::getBacktrace($exception); foreach ($backtrace as $index => $backtraceCall) { $functionName = $this->buildFunctionName($backtraceCall); foreach ($this->filteredFunctions as $pattern) { if (preg_match('/'.$pattern.'/', $functionName)) { unset($backtrace[$index]); break; } } } return array_values($backtrace); }
[ "public", "function", "getBacktrace", "(", "$", "exception", "=", "null", ")", "{", "$", "backtrace", "=", "parent", "::", "getBacktrace", "(", "$", "exception", ")", ";", "foreach", "(", "$", "backtrace", "as", "$", "index", "=>", "$", "backtraceCall", ...
Returns a filtered backtrace using regular expressions @param mixed $exception @return array|void
[ "Returns", "a", "filtered", "backtrace", "using", "regular", "expressions" ]
16891556ff2e9eb7c2f94e42106044fb28bde33d
https://github.com/camspiers/silverstripe-loggerbridge/blob/16891556ff2e9eb7c2f94e42106044fb28bde33d/src/Camspiers/LoggerBridge/BacktraceReporter/FilteredBacktraceReporter.php#L35-L50
train
smirik/php-datetime-ago
src/Smirik/PHPDateTimeAgo/DateTimeAgo.php
DateTimeAgo.get
public function get(DateTime $date, DateTime $reference_date = null ) { if (is_null($reference_date)) { $reference_date = new DateTime(); } $diff = $reference_date->diff($date); return $this->getText($diff, $date); }
php
public function get(DateTime $date, DateTime $reference_date = null ) { if (is_null($reference_date)) { $reference_date = new DateTime(); } $diff = $reference_date->diff($date); return $this->getText($diff, $date); }
[ "public", "function", "get", "(", "DateTime", "$", "date", ",", "DateTime", "$", "reference_date", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "reference_date", ")", ")", "{", "$", "reference_date", "=", "new", "DateTime", "(", ")", ";", "}"...
Get string representation of the date with given translator @param DateTime $date @param DateTime|null $reference_date @return string
[ "Get", "string", "representation", "of", "the", "date", "with", "given", "translator" ]
9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39
https://github.com/smirik/php-datetime-ago/blob/9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39/src/Smirik/PHPDateTimeAgo/DateTimeAgo.php#L43-L51
train
smirik/php-datetime-ago
src/Smirik/PHPDateTimeAgo/DateTimeAgo.php
DateTimeAgo.getText
public function getText(DateInterval $diff, $date) { if ($this->now($diff)) { return $this->text_translator->now(); } if ($this->minutes($diff)) { return $this->text_translator->minutes($this->minutes($diff)); } if ($this->hours($diff)) { return $this->text_translator->hours($this->hours($diff)); } if ($this->days($diff)) { return $this->text_translator->days($this->days($diff)); } if ($this->text_translator->supportsWeeks() && $this->weeks($diff)) { return $this->text_translator->weeks($this->weeks($diff)); } if ($this->text_translator->supportsMonths() && $this->months($diff)) { return $this->text_translator->months($this->months($diff)); } if ($this->text_translator->supportsYears() && $this->years($diff)) { return $this->text_translator->years($this->years($diff)); } return $date->format($this->format); }
php
public function getText(DateInterval $diff, $date) { if ($this->now($diff)) { return $this->text_translator->now(); } if ($this->minutes($diff)) { return $this->text_translator->minutes($this->minutes($diff)); } if ($this->hours($diff)) { return $this->text_translator->hours($this->hours($diff)); } if ($this->days($diff)) { return $this->text_translator->days($this->days($diff)); } if ($this->text_translator->supportsWeeks() && $this->weeks($diff)) { return $this->text_translator->weeks($this->weeks($diff)); } if ($this->text_translator->supportsMonths() && $this->months($diff)) { return $this->text_translator->months($this->months($diff)); } if ($this->text_translator->supportsYears() && $this->years($diff)) { return $this->text_translator->years($this->years($diff)); } return $date->format($this->format); }
[ "public", "function", "getText", "(", "DateInterval", "$", "diff", ",", "$", "date", ")", "{", "if", "(", "$", "this", "->", "now", "(", "$", "diff", ")", ")", "{", "return", "$", "this", "->", "text_translator", "->", "now", "(", ")", ";", "}", ...
Get string related to DateInterval object @param DateInterval $diff @return string
[ "Get", "string", "related", "to", "DateInterval", "object" ]
9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39
https://github.com/smirik/php-datetime-ago/blob/9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39/src/Smirik/PHPDateTimeAgo/DateTimeAgo.php#L58-L89
train
smirik/php-datetime-ago
src/Smirik/PHPDateTimeAgo/DateTimeAgo.php
DateTimeAgo.daily
public function daily($diff) { if (($diff->y == 0) && ($diff->m == 0) && (($diff->d == 0) || (($diff->d == 1) && ($diff->h == 0) && ($diff->i == 0)))) { return true; } return false; }
php
public function daily($diff) { if (($diff->y == 0) && ($diff->m == 0) && (($diff->d == 0) || (($diff->d == 1) && ($diff->h == 0) && ($diff->i == 0)))) { return true; } return false; }
[ "public", "function", "daily", "(", "$", "diff", ")", "{", "if", "(", "(", "$", "diff", "->", "y", "==", "0", ")", "&&", "(", "$", "diff", "->", "m", "==", "0", ")", "&&", "(", "(", "$", "diff", "->", "d", "==", "0", ")", "||", "(", "(", ...
Is date limit by day @param DateInterval $diff @return bool
[ "Is", "date", "limit", "by", "day" ]
9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39
https://github.com/smirik/php-datetime-ago/blob/9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39/src/Smirik/PHPDateTimeAgo/DateTimeAgo.php#L96-L102
train
smirik/php-datetime-ago
src/Smirik/PHPDateTimeAgo/DateTimeAgo.php
DateTimeAgo.hourly
public function hourly($diff) { if ($this->daily($diff) && ($diff->d == 0) && (($diff->h == 0) || (($diff->h == 1) && ($diff->i == 0)))) { return true; } return false; }
php
public function hourly($diff) { if ($this->daily($diff) && ($diff->d == 0) && (($diff->h == 0) || (($diff->h == 1) && ($diff->i == 0)))) { return true; } return false; }
[ "public", "function", "hourly", "(", "$", "diff", ")", "{", "if", "(", "$", "this", "->", "daily", "(", "$", "diff", ")", "&&", "(", "$", "diff", "->", "d", "==", "0", ")", "&&", "(", "(", "$", "diff", "->", "h", "==", "0", ")", "||", "(", ...
Is date limit by hour @param DateInterval $diff @return bool
[ "Is", "date", "limit", "by", "hour" ]
9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39
https://github.com/smirik/php-datetime-ago/blob/9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39/src/Smirik/PHPDateTimeAgo/DateTimeAgo.php#L109-L115
train
smirik/php-datetime-ago
src/Smirik/PHPDateTimeAgo/DateTimeAgo.php
DateTimeAgo.days
public function days(DateInterval $diff) { if ($diff->days <= $this->max_days_count) { return $diff->days; } return false; }
php
public function days(DateInterval $diff) { if ($diff->days <= $this->max_days_count) { return $diff->days; } return false; }
[ "public", "function", "days", "(", "DateInterval", "$", "diff", ")", "{", "if", "(", "$", "diff", "->", "days", "<=", "$", "this", "->", "max_days_count", ")", "{", "return", "$", "diff", "->", "days", ";", "}", "return", "false", ";", "}" ]
Number of days related to the interval or false if more. @param DateInterval $diff @return integer|false
[ "Number", "of", "days", "related", "to", "the", "interval", "or", "false", "if", "more", "." ]
9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39
https://github.com/smirik/php-datetime-ago/blob/9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39/src/Smirik/PHPDateTimeAgo/DateTimeAgo.php#L160-L166
train
smirik/php-datetime-ago
src/Smirik/PHPDateTimeAgo/DateTimeAgo.php
DateTimeAgo.weeks
public function weeks(DateInterval $diff) { if ($diff->days < 30) { return (int) floor($diff->days / 7); } return false; }
php
public function weeks(DateInterval $diff) { if ($diff->days < 30) { return (int) floor($diff->days / 7); } return false; }
[ "public", "function", "weeks", "(", "DateInterval", "$", "diff", ")", "{", "if", "(", "$", "diff", "->", "days", "<", "30", ")", "{", "return", "(", "int", ")", "floor", "(", "$", "diff", "->", "days", "/", "7", ")", ";", "}", "return", "false", ...
Get Number of weeks @param DateInterval $diff @return integer|false
[ "Get", "Number", "of", "weeks" ]
9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39
https://github.com/smirik/php-datetime-ago/blob/9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39/src/Smirik/PHPDateTimeAgo/DateTimeAgo.php#L173-L179
train
smirik/php-datetime-ago
src/Smirik/PHPDateTimeAgo/DateTimeAgo.php
DateTimeAgo.months
public function months(DateInterval $diff) { if ($diff->days >= 365) { return FALSE; } $x = (int) floor($diff->days / 30.417); if ($x === 0) { return 1; } else { return $x; } }
php
public function months(DateInterval $diff) { if ($diff->days >= 365) { return FALSE; } $x = (int) floor($diff->days / 30.417); if ($x === 0) { return 1; } else { return $x; } }
[ "public", "function", "months", "(", "DateInterval", "$", "diff", ")", "{", "if", "(", "$", "diff", "->", "days", ">=", "365", ")", "{", "return", "FALSE", ";", "}", "$", "x", "=", "(", "int", ")", "floor", "(", "$", "diff", "->", "days", "/", ...
Get Number of months @param DateInterval $diff @return integer|false
[ "Get", "Number", "of", "months" ]
9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39
https://github.com/smirik/php-datetime-ago/blob/9a4cdbe1855b2bf9d0627b287eefa2b23ecf0b39/src/Smirik/PHPDateTimeAgo/DateTimeAgo.php#L186-L198
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.addClassOption
protected function addClassOption($name, $value) { $value = trim($value); if (substr($value, 0, 1) == '.' || substr($value, 0, 1) == '#') { $value = substr($value, 1); } if ($value != '') { $this->addOption('class', $name, $value); } }
php
protected function addClassOption($name, $value) { $value = trim($value); if (substr($value, 0, 1) == '.' || substr($value, 0, 1) == '#') { $value = substr($value, 1); } if ($value != '') { $this->addOption('class', $name, $value); } }
[ "protected", "function", "addClassOption", "(", "$", "name", ",", "$", "value", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "if", "(", "substr", "(", "$", "value", ",", "0", ",", "1", ")", "==", "'.'", "||", "substr", "(", ...
Adds class option, removes dot and hash. @param string $name option name @param string $value option value
[ "Adds", "class", "option", "removes", "dot", "and", "hash", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L196-L205
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.addContentOption
protected function addContentOption($name, $value) { $value = trim($value); if (!empty($value) && is_string($value)) { $this->addOption('content', $name, $value); } }
php
protected function addContentOption($name, $value) { $value = trim($value); if (!empty($value) && is_string($value)) { $this->addOption('content', $name, $value); } }
[ "protected", "function", "addContentOption", "(", "$", "name", ",", "$", "value", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "if", "(", "!", "empty", "(", "$", "value", ")", "&&", "is_string", "(", "$", "value", ")", ")", "...
Adds content option. @param string $name option name @param string $value option value
[ "Adds", "content", "option", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L212-L218
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.addCookieBoolOption
protected function addCookieBoolOption($name, $value) { if ($value === true || $value === false) { $this->addOption('cookie', $name, $value); } }
php
protected function addCookieBoolOption($name, $value) { if ($value === true || $value === false) { $this->addOption('cookie', $name, $value); } }
[ "protected", "function", "addCookieBoolOption", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "$", "value", "===", "true", "||", "$", "value", "===", "false", ")", "{", "$", "this", "->", "addOption", "(", "'cookie'", ",", "$", "name", ",...
Adds boolean cookie option. @param string $name option name @param string $value option value
[ "Adds", "boolean", "cookie", "option", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L225-L230
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.addCookieIntOption
protected function addCookieIntOption($name, $value) { $value = trim($value); if ($value !== null && $value !== '' && is_numeric($value)) { $this->addOption('cookie', $name, (int)$value); } }
php
protected function addCookieIntOption($name, $value) { $value = trim($value); if ($value !== null && $value !== '' && is_numeric($value)) { $this->addOption('cookie', $name, (int)$value); } }
[ "protected", "function", "addCookieIntOption", "(", "$", "name", ",", "$", "value", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "if", "(", "$", "value", "!==", "null", "&&", "$", "value", "!==", "''", "&&", "is_numeric", "(", ...
Adds integer cookie option. @param string $name option name @param string|integer|float $value option value
[ "Adds", "integer", "cookie", "option", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L237-L243
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.addCookieOption
protected function addCookieOption($name, $value) { if (is_string($value)) { $value = preg_replace("~^;? ?$name=~", '', trim($value)); if ($value !== '') { $this->addOption('cookie', $name, $value); } } }
php
protected function addCookieOption($name, $value) { if (is_string($value)) { $value = preg_replace("~^;? ?$name=~", '', trim($value)); if ($value !== '') { $this->addOption('cookie', $name, $value); } } }
[ "protected", "function", "addCookieOption", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "preg_replace", "(", "\"~^;? ?$name=~\"", ",", "''", ",", "trim", "(", "$", "value",...
Adds cookie option, removes '; name=' part. @param string $name option name @param string $value option value
[ "Adds", "cookie", "option", "removes", ";", "name", "=", "part", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L250-L258
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.addParamsOption
protected function addParamsOption($name, $value) { if (is_array($value) && count($value)) { $this->addOption('content', $name, $value); } }
php
protected function addParamsOption($name, $value) { if (is_array($value) && count($value)) { $this->addOption('content', $name, $value); } }
[ "protected", "function", "addParamsOption", "(", "$", "name", ",", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "&&", "count", "(", "$", "value", ")", ")", "{", "$", "this", "->", "addOption", "(", "'content'", ",", "$", "...
Adds content parameters option. @param string $name option name @param array $value list of parameters
[ "Adds", "content", "parameters", "option", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L276-L281
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.addStyle
protected function addStyle($what, $value) { if (is_array($value) && count($value)) { $type = 'inner'; switch ($what) { case 0: $type = 'outer'; break; case 2: $type = 'button'; break; } foreach ($value as $name => $set) { if (!empty($set) && is_string($set)) { $this->{$type . 'Style'}[$name] = str_replace(';', '', trim($set)); } } } }
php
protected function addStyle($what, $value) { if (is_array($value) && count($value)) { $type = 'inner'; switch ($what) { case 0: $type = 'outer'; break; case 2: $type = 'button'; break; } foreach ($value as $name => $set) { if (!empty($set) && is_string($set)) { $this->{$type . 'Style'}[$name] = str_replace(';', '', trim($set)); } } } }
[ "protected", "function", "addStyle", "(", "$", "what", ",", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "&&", "count", "(", "$", "value", ")", ")", "{", "$", "type", "=", "'inner'", ";", "switch", "(", "$", "what", ")",...
Adds the CSS styles for selected part. @param integer $what number of part @param array $value list of styles
[ "Adds", "the", "CSS", "styles", "for", "selected", "part", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L288-L306
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.checkContent
protected function checkContent() { if (is_array($this->content) && count($this->content)) { foreach ($this->content as $name => $value) { switch ($name) { case 'category': case 'mainMessage': case 'buttonMessage': case 'language': $this->addContentOption($name, $value); break; case 'mainParams': case 'buttonParams': $this->addParamsOption($name, $value); break; } } } }
php
protected function checkContent() { if (is_array($this->content) && count($this->content)) { foreach ($this->content as $name => $value) { switch ($name) { case 'category': case 'mainMessage': case 'buttonMessage': case 'language': $this->addContentOption($name, $value); break; case 'mainParams': case 'buttonParams': $this->addParamsOption($name, $value); break; } } } }
[ "protected", "function", "checkContent", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "content", ")", "&&", "count", "(", "$", "this", "->", "content", ")", ")", "{", "foreach", "(", "$", "this", "->", "content", "as", "$", "name", ...
Validates content parameters.
[ "Validates", "content", "parameters", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L372-L390
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.checkCookie
protected function checkCookie() { if (is_array($this->cookie) && count($this->cookie)) { foreach ($this->cookie as $name => $value) { switch ($name) { case 'domain': case 'path': $this->addCookieOption($name, $value); break; case 'max-age': case 'expires': $this->addCookieIntOption($name, $value); break; case 'secure': $this->addCookieBoolOption($name, $value); break; } } } }
php
protected function checkCookie() { if (is_array($this->cookie) && count($this->cookie)) { foreach ($this->cookie as $name => $value) { switch ($name) { case 'domain': case 'path': $this->addCookieOption($name, $value); break; case 'max-age': case 'expires': $this->addCookieIntOption($name, $value); break; case 'secure': $this->addCookieBoolOption($name, $value); break; } } } }
[ "protected", "function", "checkCookie", "(", ")", "{", "if", "(", "is_array", "(", "$", "this", "->", "cookie", ")", "&&", "count", "(", "$", "this", "->", "cookie", ")", ")", "{", "foreach", "(", "$", "this", "->", "cookie", "as", "$", "name", "=>...
Validates cookie parameters.
[ "Validates", "cookie", "parameters", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L395-L414
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.initCookie
protected function initCookie() { $cookieOptions = Json::encode( array_merge( $this->cookieOptions, [ 'classOuter' => str_replace(' ', '.', $this->classOptions['classOuter']), 'classInner' => str_replace(' ', '.', $this->classOptions['classInner']), 'classButton' => str_replace(' ', '.', $this->classOptions['classButton']), ] ) ); $view = $this->getView(); assets\CookieMonsterAsset::register($view); $view->registerJs("CookieMonster.init($cookieOptions);"); }
php
protected function initCookie() { $cookieOptions = Json::encode( array_merge( $this->cookieOptions, [ 'classOuter' => str_replace(' ', '.', $this->classOptions['classOuter']), 'classInner' => str_replace(' ', '.', $this->classOptions['classInner']), 'classButton' => str_replace(' ', '.', $this->classOptions['classButton']), ] ) ); $view = $this->getView(); assets\CookieMonsterAsset::register($view); $view->registerJs("CookieMonster.init($cookieOptions);"); }
[ "protected", "function", "initCookie", "(", ")", "{", "$", "cookieOptions", "=", "Json", "::", "encode", "(", "array_merge", "(", "$", "this", "->", "cookieOptions", ",", "[", "'classOuter'", "=>", "str_replace", "(", "' '", ",", "'.'", ",", "$", "this", ...
Initialises the js file, prepares the JSON js options.
[ "Initialises", "the", "js", "file", "prepares", "the", "JSON", "js", "options", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L419-L434
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.prepareViewParams
protected function prepareViewParams() { $outerStyle = []; $innerStyle = []; $buttonStyle = []; foreach ($this->outerStyle as $name => $value) { $outerStyle[] = $name . ':' . $value; } foreach ($this->innerStyle as $name => $value) { $innerStyle[] = $name . ':' . $value; } foreach ($this->buttonStyle as $name => $value) { $buttonStyle[] = $name . ':' . $value; } return [ 'content' => $this->contentOptions, 'outerHtmlOptions' => array_merge( $this->outerHtml, [ 'style' => implode(';', $outerStyle), 'class' => $this->classOptions['classOuter'] ] ), 'innerHtmlOptions' => array_merge( $this->innerHtml, [ 'style' => implode(';', $innerStyle), 'class' => $this->classOptions['classInner'] ] ), 'buttonHtmlOptions' => array_merge( $this->buttonHtml, [ 'style' => implode(';', $buttonStyle), 'class' => $this->classOptions['classButton'] ] ), 'params' => $this->params ]; }
php
protected function prepareViewParams() { $outerStyle = []; $innerStyle = []; $buttonStyle = []; foreach ($this->outerStyle as $name => $value) { $outerStyle[] = $name . ':' . $value; } foreach ($this->innerStyle as $name => $value) { $innerStyle[] = $name . ':' . $value; } foreach ($this->buttonStyle as $name => $value) { $buttonStyle[] = $name . ':' . $value; } return [ 'content' => $this->contentOptions, 'outerHtmlOptions' => array_merge( $this->outerHtml, [ 'style' => implode(';', $outerStyle), 'class' => $this->classOptions['classOuter'] ] ), 'innerHtmlOptions' => array_merge( $this->innerHtml, [ 'style' => implode(';', $innerStyle), 'class' => $this->classOptions['classInner'] ] ), 'buttonHtmlOptions' => array_merge( $this->buttonHtml, [ 'style' => implode(';', $buttonStyle), 'class' => $this->classOptions['classButton'] ] ), 'params' => $this->params ]; }
[ "protected", "function", "prepareViewParams", "(", ")", "{", "$", "outerStyle", "=", "[", "]", ";", "$", "innerStyle", "=", "[", "]", ";", "$", "buttonStyle", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "outerStyle", "as", "$", "name", "=>...
Prepares the list of parameters to send to the view. @return array
[ "Prepares", "the", "list", "of", "parameters", "to", "send", "to", "the", "view", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L440-L481
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.replaceStyle
protected function replaceStyle($what, $value) { if (is_array($value) && count($value)) { $type = 'inner'; switch ($what) { case 0: $type = 'outer'; break; case 2: $type = 'button'; break; } foreach ($value as $name => $set) { if (isset($this->{$type . 'Style'}[$name])) { if ($set === false || $set === null) { unset($this->{$type . 'Style'}[$name]); } else { $this->{$type . 'Style'}[$name] = str_replace(';', '', trim($set)); } } } } }
php
protected function replaceStyle($what, $value) { if (is_array($value) && count($value)) { $type = 'inner'; switch ($what) { case 0: $type = 'outer'; break; case 2: $type = 'button'; break; } foreach ($value as $name => $set) { if (isset($this->{$type . 'Style'}[$name])) { if ($set === false || $set === null) { unset($this->{$type . 'Style'}[$name]); } else { $this->{$type . 'Style'}[$name] = str_replace(';', '', trim($set)); } } } } }
[ "protected", "function", "replaceStyle", "(", "$", "what", ",", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "&&", "count", "(", "$", "value", ")", ")", "{", "$", "type", "=", "'inner'", ";", "switch", "(", "$", "what", ...
Replaces the CSS styles for selected part. @param integer $what number of part @param array $value list of styles
[ "Replaces", "the", "CSS", "styles", "for", "selected", "part", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L488-L510
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.setDefaults
protected function setDefaults() { if (!isset($this->contentOptions['category']) || (isset($this->contentOptions['category']) && empty($this->contentOptions['category']))) { $this->contentOptions['category'] = 'app'; } if (!isset($this->contentOptions['mainParams'])) { $this->contentOptions['mainParams'] = []; } if (!isset($this->contentOptions['buttonParams'])) { $this->contentOptions['buttonParams'] = []; } if (!isset($this->contentOptions['language'])) { $this->contentOptions['language'] = null; } if (!isset($this->contentOptions['mainMessage'])) { $this->contentOptions['mainMessage'] = 'We use cookies on our websites to help us offer you the best online experience. By continuing to use our website, you are agreeing to our use of cookies. Alternatively, you can manage them in your browser settings.'; } if (!isset($this->contentOptions['buttonMessage'])) { $this->contentOptions['buttonMessage'] = 'I understand'; } if (!isset($this->cookieOptions['path'])) { $this->cookieOptions['path'] = '/'; } if (!isset($this->cookieOptions['expires'])) { $this->cookieOptions['expires'] = 30; } if (!isset($this->cookieOptions['secure'])) { $this->cookieOptions['secure'] = false; } if (!isset($this->classOptions['classOuter'])) { $this->classOptions['classOuter'] = 'CookieMonsterBox'; } if (!isset($this->classOptions['classInner'])) { $this->classOptions['classInner'] = ''; } if (!isset($this->classOptions['classButton'])) { $this->classOptions['classButton'] = 'CookieMonsterOk'; } }
php
protected function setDefaults() { if (!isset($this->contentOptions['category']) || (isset($this->contentOptions['category']) && empty($this->contentOptions['category']))) { $this->contentOptions['category'] = 'app'; } if (!isset($this->contentOptions['mainParams'])) { $this->contentOptions['mainParams'] = []; } if (!isset($this->contentOptions['buttonParams'])) { $this->contentOptions['buttonParams'] = []; } if (!isset($this->contentOptions['language'])) { $this->contentOptions['language'] = null; } if (!isset($this->contentOptions['mainMessage'])) { $this->contentOptions['mainMessage'] = 'We use cookies on our websites to help us offer you the best online experience. By continuing to use our website, you are agreeing to our use of cookies. Alternatively, you can manage them in your browser settings.'; } if (!isset($this->contentOptions['buttonMessage'])) { $this->contentOptions['buttonMessage'] = 'I understand'; } if (!isset($this->cookieOptions['path'])) { $this->cookieOptions['path'] = '/'; } if (!isset($this->cookieOptions['expires'])) { $this->cookieOptions['expires'] = 30; } if (!isset($this->cookieOptions['secure'])) { $this->cookieOptions['secure'] = false; } if (!isset($this->classOptions['classOuter'])) { $this->classOptions['classOuter'] = 'CookieMonsterBox'; } if (!isset($this->classOptions['classInner'])) { $this->classOptions['classInner'] = ''; } if (!isset($this->classOptions['classButton'])) { $this->classOptions['classButton'] = 'CookieMonsterOk'; } }
[ "protected", "function", "setDefaults", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "contentOptions", "[", "'category'", "]", ")", "||", "(", "isset", "(", "$", "this", "->", "contentOptions", "[", "'category'", "]", ")", "&&", "emp...
Sets default values.
[ "Sets", "default", "values", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L536-L576
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.setHtmlOptions
protected function setHtmlOptions($what, $value) { if (is_array($value) && count($value)) { $type = 'inner'; switch ($what) { case 0: $type = 'outer'; break; case 2: $type = 'button'; break; } foreach ($value as $name => $set) { if ($name == 'class' || $name == 'style') { continue; } else { $this->{$type . 'Html'}[$name] = trim($set); } } } }
php
protected function setHtmlOptions($what, $value) { if (is_array($value) && count($value)) { $type = 'inner'; switch ($what) { case 0: $type = 'outer'; break; case 2: $type = 'button'; break; } foreach ($value as $name => $set) { if ($name == 'class' || $name == 'style') { continue; } else { $this->{$type . 'Html'}[$name] = trim($set); } } } }
[ "protected", "function", "setHtmlOptions", "(", "$", "what", ",", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", "&&", "count", "(", "$", "value", ")", ")", "{", "$", "type", "=", "'inner'", ";", "switch", "(", "$", "what", ...
Sets HTML options for selected part. @param integer $what number of part @param array $value list of options
[ "Sets", "HTML", "options", "for", "selected", "part", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L583-L603
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.setMode
protected function setMode() { $this->outerStyle = [ 'display' => 'none', 'z-index' => 10000, 'position' => 'fixed', 'background-color' => '#fff', 'font-size' => '12px', 'color' => '#000' ]; $this->innerStyle = ['margin' => '10px']; $this->buttonStyle = ['margin-left' => '10px']; switch ($this->mode) { case 'bottom': $this->outerStyle = array_merge( $this->outerStyle, [ 'bottom' => 0, 'left' => 0, 'width' => '100%', 'box-shadow' => '0 -2px 2px #000', ] ); break; case 'box': $this->outerStyle = array_merge( $this->outerStyle, [ 'bottom' => '20px', 'right' => '20px', 'width' => '300px', 'box-shadow' => '-2px 2px 2px #000', 'border-radius' => '10px', ] ); break; case 'custom': $this->outerStyle = []; $this->innerStyle = []; $this->buttonStyle = []; break; case 'top': default: $this->outerStyle = array_merge( $this->outerStyle, [ 'top' => 0, 'left' => 0, 'width' => '100%', 'box-shadow' => '0 2px 2px #000', ] ); } }
php
protected function setMode() { $this->outerStyle = [ 'display' => 'none', 'z-index' => 10000, 'position' => 'fixed', 'background-color' => '#fff', 'font-size' => '12px', 'color' => '#000' ]; $this->innerStyle = ['margin' => '10px']; $this->buttonStyle = ['margin-left' => '10px']; switch ($this->mode) { case 'bottom': $this->outerStyle = array_merge( $this->outerStyle, [ 'bottom' => 0, 'left' => 0, 'width' => '100%', 'box-shadow' => '0 -2px 2px #000', ] ); break; case 'box': $this->outerStyle = array_merge( $this->outerStyle, [ 'bottom' => '20px', 'right' => '20px', 'width' => '300px', 'box-shadow' => '-2px 2px 2px #000', 'border-radius' => '10px', ] ); break; case 'custom': $this->outerStyle = []; $this->innerStyle = []; $this->buttonStyle = []; break; case 'top': default: $this->outerStyle = array_merge( $this->outerStyle, [ 'top' => 0, 'left' => 0, 'width' => '100%', 'box-shadow' => '0 2px 2px #000', ] ); } }
[ "protected", "function", "setMode", "(", ")", "{", "$", "this", "->", "outerStyle", "=", "[", "'display'", "=>", "'none'", ",", "'z-index'", "=>", "10000", ",", "'position'", "=>", "'fixed'", ",", "'background-color'", "=>", "'#fff'", ",", "'font-size'", "=>...
Sets the mode with default CSS styles.
[ "Sets", "the", "mode", "with", "default", "CSS", "styles", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L608-L662
train
bizley/yii2-cookiemonster
src/CookieMonster.php
CookieMonster.setCookieView
protected function setCookieView($value) { $value = trim($value); if (!empty($value)) { $this->cookieView = $value; } }
php
protected function setCookieView($value) { $value = trim($value); if (!empty($value)) { $this->cookieView = $value; } }
[ "protected", "function", "setCookieView", "(", "$", "value", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "this", "->", "cookieView", "=", "$", "value", ";", "}"...
Sets custom user's view path. @param string $value view path
[ "Sets", "custom", "user", "s", "view", "path", "." ]
471c45768b183025b9986e73569880fb628c6be6
https://github.com/bizley/yii2-cookiemonster/blob/471c45768b183025b9986e73569880fb628c6be6/src/CookieMonster.php#L695-L701
train
nabu-3/provider-mysql-driver
CMySQLDescriptor.php
CMySQLDescriptor.buildFieldReplacement
public function buildFieldReplacement(array $field_descriptor, $alias = false) { if ($alias === false) { $alias = $field_descriptor['name']; } switch ($field_descriptor['data_type']) { case 'int': $retval = "%d$alias\$d"; break; case 'float': case 'double': $retval = "%F$alias\$d"; break; case 'varchar': case 'text': case 'longtext': case 'enum': case 'set': case 'tinytext': $retval = "'%s$alias\$s'"; break; default: $retval = false; } return $retval; }
php
public function buildFieldReplacement(array $field_descriptor, $alias = false) { if ($alias === false) { $alias = $field_descriptor['name']; } switch ($field_descriptor['data_type']) { case 'int': $retval = "%d$alias\$d"; break; case 'float': case 'double': $retval = "%F$alias\$d"; break; case 'varchar': case 'text': case 'longtext': case 'enum': case 'set': case 'tinytext': $retval = "'%s$alias\$s'"; break; default: $retval = false; } return $retval; }
[ "public", "function", "buildFieldReplacement", "(", "array", "$", "field_descriptor", ",", "$", "alias", "=", "false", ")", "{", "if", "(", "$", "alias", "===", "false", ")", "{", "$", "alias", "=", "$", "field_descriptor", "[", "'name'", "]", ";", "}", ...
Builds a well formed replacement string for a field value. @param array $field_descriptor Field descriptor to build the replacement string. @param string $alias Alternate name used to map the value in the replacement string. @return string Returns a well formed replacement string of false if no valid descriptor data_type found in field descriptor.
[ "Builds", "a", "well", "formed", "replacement", "string", "for", "a", "field", "value", "." ]
85fc8ff326819c3970c933fc65a1e298f92fb017
https://github.com/nabu-3/provider-mysql-driver/blob/85fc8ff326819c3970c933fc65a1e298f92fb017/CMySQLDescriptor.php#L132-L159
train
nabu-3/provider-mysql-driver
CMySQLDescriptor.php
CMySQLDescriptor.buildFieldValue
public function buildFieldValue($field_descriptor, $value) { if ($value === null) { $retval = 'NULL'; } elseif ($value === false) { $retval = 'false'; } elseif ($value === true) { $retval = 'true'; } else { if (!is_array($value)) { $value = array($value); } switch ($field_descriptor['data_type']) { case 'int': $retval = $this->nb_connector->buildSentence('%d', $value); break; case 'float': case 'double': $retval = $this->nb_connector->buildSentence('%F', $value); break; case 'varchar': case 'text': case 'longtext': case 'enum': case 'set': case 'tinytext': $retval = $this->nb_connector->buildSentence("'%s'", $value); break; case 'date': case 'datetime': if ($field_descriptor['name'] !== $this->storage_descriptor['name'] . '_creation_datetime') { if ($value === null) { $retval = 'null'; } else { $retval = $this->nb_connector->buildSentence("'%s'", $value); } } else { $retval = false; } break; default: error_log($field_descriptor['data_type']); throw new ENabuCoreException(ENabuCoreException::ERROR_FEATURE_NOT_IMPLEMENTED); } } return $retval; }
php
public function buildFieldValue($field_descriptor, $value) { if ($value === null) { $retval = 'NULL'; } elseif ($value === false) { $retval = 'false'; } elseif ($value === true) { $retval = 'true'; } else { if (!is_array($value)) { $value = array($value); } switch ($field_descriptor['data_type']) { case 'int': $retval = $this->nb_connector->buildSentence('%d', $value); break; case 'float': case 'double': $retval = $this->nb_connector->buildSentence('%F', $value); break; case 'varchar': case 'text': case 'longtext': case 'enum': case 'set': case 'tinytext': $retval = $this->nb_connector->buildSentence("'%s'", $value); break; case 'date': case 'datetime': if ($field_descriptor['name'] !== $this->storage_descriptor['name'] . '_creation_datetime') { if ($value === null) { $retval = 'null'; } else { $retval = $this->nb_connector->buildSentence("'%s'", $value); } } else { $retval = false; } break; default: error_log($field_descriptor['data_type']); throw new ENabuCoreException(ENabuCoreException::ERROR_FEATURE_NOT_IMPLEMENTED); } } return $retval; }
[ "public", "function", "buildFieldValue", "(", "$", "field_descriptor", ",", "$", "value", ")", "{", "if", "(", "$", "value", "===", "null", ")", "{", "$", "retval", "=", "'NULL'", ";", "}", "elseif", "(", "$", "value", "===", "false", ")", "{", "$", ...
Builds a well formed string for a field value containing their value represented in MySQL SQL syntax. This method prevents SQL Injection. @param array $field_descriptor Field descriptor to build the field value string. @param mixed $value Value to be converted into a valid MySQL value representation. @return string Returns the well formed string or false if no valid data_type found in field descriptor.
[ "Builds", "a", "well", "formed", "string", "for", "a", "field", "value", "containing", "their", "value", "represented", "in", "MySQL", "SQL", "syntax", ".", "This", "method", "prevents", "SQL", "Injection", "." ]
85fc8ff326819c3970c933fc65a1e298f92fb017
https://github.com/nabu-3/provider-mysql-driver/blob/85fc8ff326819c3970c933fc65a1e298f92fb017/CMySQLDescriptor.php#L168-L215
train
xabbuh/panda-client
src/Signer/PandaSigner.php
PandaSigner.signParams
public function signParams($method, $path, array $params = array()) { $params = $this->completeParams($params); // generate the signature $params['signature'] = $this->signature($method, $path, $params); return $params; }
php
public function signParams($method, $path, array $params = array()) { $params = $this->completeParams($params); // generate the signature $params['signature'] = $this->signature($method, $path, $params); return $params; }
[ "public", "function", "signParams", "(", "$", "method", ",", "$", "path", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "params", "=", "$", "this", "->", "completeParams", "(", "$", "params", ")", ";", "// generate the signature", ...
Generates the signature for a given set of request parameters and add this signature to the set of parameters. @param string $method The HTTP method @param string $path The request path @param string[] $params Request parameters @return string[] The signed parameters
[ "Generates", "the", "signature", "for", "a", "given", "set", "of", "request", "parameters", "and", "add", "this", "signature", "to", "the", "set", "of", "parameters", "." ]
0b0f530a47621353441e4de7f6303e5742fc7bd0
https://github.com/xabbuh/panda-client/blob/0b0f530a47621353441e4de7f6303e5742fc7bd0/src/Signer/PandaSigner.php#L91-L99
train
xabbuh/panda-client
src/Signer/PandaSigner.php
PandaSigner.signature
public function signature($method, $path, array $params = array()) { $params = $this->completeParams($params); ksort($params); if (isset($params['file'])) { unset($params['file']); } $canonicalQueryString = str_replace( array('+', '%5B', '%5D'), array('%20', '[', ']'), http_build_query($params, '', '&') ); $stringToSign = sprintf( "%s\n%s\n%s\n%s", strtoupper($method), $this->account->getApiHost(), $path, $canonicalQueryString ); $hmac = hash_hmac('sha256', $stringToSign, $this->account->getSecretKey(), true); return base64_encode($hmac); }
php
public function signature($method, $path, array $params = array()) { $params = $this->completeParams($params); ksort($params); if (isset($params['file'])) { unset($params['file']); } $canonicalQueryString = str_replace( array('+', '%5B', '%5D'), array('%20', '[', ']'), http_build_query($params, '', '&') ); $stringToSign = sprintf( "%s\n%s\n%s\n%s", strtoupper($method), $this->account->getApiHost(), $path, $canonicalQueryString ); $hmac = hash_hmac('sha256', $stringToSign, $this->account->getSecretKey(), true); return base64_encode($hmac); }
[ "public", "function", "signature", "(", "$", "method", ",", "$", "path", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "params", "=", "$", "this", "->", "completeParams", "(", "$", "params", ")", ";", "ksort", "(", "$", "param...
Generates the signature for an API requests based on its parameters. @param string $method The HTTP method @param string $path The request path @param string[] $params Request parameters @return string The generated signature
[ "Generates", "the", "signature", "for", "an", "API", "requests", "based", "on", "its", "parameters", "." ]
0b0f530a47621353441e4de7f6303e5742fc7bd0
https://github.com/xabbuh/panda-client/blob/0b0f530a47621353441e4de7f6303e5742fc7bd0/src/Signer/PandaSigner.php#L110-L135
train
xabbuh/panda-client
src/Signer/PandaSigner.php
PandaSigner.getInstance
public static function getInstance($cloudId, Account $account) { $signer = new PandaSigner(); $signer->setCloudId($cloudId); $signer->setAccount($account); return $signer; }
php
public static function getInstance($cloudId, Account $account) { $signer = new PandaSigner(); $signer->setCloudId($cloudId); $signer->setAccount($account); return $signer; }
[ "public", "static", "function", "getInstance", "(", "$", "cloudId", ",", "Account", "$", "account", ")", "{", "$", "signer", "=", "new", "PandaSigner", "(", ")", ";", "$", "signer", "->", "setCloudId", "(", "$", "cloudId", ")", ";", "$", "signer", "->"...
Returns a Signing instance for a Cloud. @param string $cloudId The cloud id @param Account $account The authorization details @return PandaSigner The generated Signing instance
[ "Returns", "a", "Signing", "instance", "for", "a", "Cloud", "." ]
0b0f530a47621353441e4de7f6303e5742fc7bd0
https://github.com/xabbuh/panda-client/blob/0b0f530a47621353441e4de7f6303e5742fc7bd0/src/Signer/PandaSigner.php#L145-L152
train
hypeJunction/hypeApps
classes/hypeJunction/BatchResult.php
BatchResult.getItems
public function getItems() { $batch = $this->getBatch(); $items = array(); foreach ($batch as $b) { $items[] = $b; } return $items; }
php
public function getItems() { $batch = $this->getBatch(); $items = array(); foreach ($batch as $b) { $items[] = $b; } return $items; }
[ "public", "function", "getItems", "(", ")", "{", "$", "batch", "=", "$", "this", "->", "getBatch", "(", ")", ";", "$", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "batch", "as", "$", "b", ")", "{", "$", "items", "[", "]", "=", ...
Returns an array of items in the batch @return array
[ "Returns", "an", "array", "of", "items", "in", "the", "batch" ]
704a0aa57e817aa38bb9e40ad3710ba69d52e44c
https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/BatchResult.php#L58-L65
train
hypeJunction/hypeApps
classes/hypeJunction/BatchResult.php
BatchResult.export
public function export(array $params = array()) { $result = array( 'type' => 'list', 'count' => $this->getCount(), 'limit' => elgg_extract('limit', $this->options, elgg_get_config('default_limit')), 'offset' => elgg_extract('offset', $this->options, 0), 'items' => array(), ); $batch = $this->getBatch(); foreach ($batch as $entity) { $result['items'][] = hypeApps()->graph->export($entity, $params); } return $result; }
php
public function export(array $params = array()) { $result = array( 'type' => 'list', 'count' => $this->getCount(), 'limit' => elgg_extract('limit', $this->options, elgg_get_config('default_limit')), 'offset' => elgg_extract('offset', $this->options, 0), 'items' => array(), ); $batch = $this->getBatch(); foreach ($batch as $entity) { $result['items'][] = hypeApps()->graph->export($entity, $params); } return $result; }
[ "public", "function", "export", "(", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "result", "=", "array", "(", "'type'", "=>", "'list'", ",", "'count'", "=>", "$", "this", "->", "getCount", "(", ")", ",", "'limit'", "=>", "elgg_extr...
Export batch into an array @param array $params Export params @return array
[ "Export", "batch", "into", "an", "array" ]
704a0aa57e817aa38bb9e40ad3710ba69d52e44c
https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/BatchResult.php#L73-L88
train
hypeJunction/hypeApps
classes/hypeJunction/BatchResult.php
BatchResult.prepareBatchOptions
protected function prepareBatchOptions(array $options = array()) { if (!in_array($this->getter, array( 'elgg_get_entities', 'elgg_get_entities_from_metadata', 'elgg_get_entities_from_relationship', ))) { return $options; } $sort = elgg_extract('sort', $options); unset($options['sort']); if (!is_array($sort)) { return $options; } $dbprefix = elgg_get_config('dbprefix'); $order_by = array(); foreach ($sort as $field => $direction) { $field = sanitize_string($field); $direction = strtoupper(sanitize_string($direction)); if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'ASC'; } switch ($field) { case 'alpha' : if (elgg_extract('types', $options) == 'user') { $options['joins']['ue'] = "JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid"; $order_by[] = "ue.name {$direction}"; } else if (elgg_extract('types', $options) == 'group') { $options['joins']['ge'] = "JOIN {$dbprefix}groups_entity ge ON ge.guid = e.guid"; $order_by[] = "ge.name {$direction}"; } else if (elgg_extract('types', $options) == 'object') { $options['joins']['oe'] = "JOIN {$dbprefix}objects_entity oe ON oe.guid = e.guid"; $order_by[] = "oe.title {$direction}"; } break; case 'type' : case 'subtype' : case 'guid' : case 'owner_guid' : case 'container_guid' : case 'site_guid' : case 'enabled' : case 'time_created'; case 'time_updated' : case 'last_action' : case 'access_id' : $order_by[] = "e.{$field} {$direction}"; break; } } $options['order_by'] = implode(',', $order_by); return $options; }
php
protected function prepareBatchOptions(array $options = array()) { if (!in_array($this->getter, array( 'elgg_get_entities', 'elgg_get_entities_from_metadata', 'elgg_get_entities_from_relationship', ))) { return $options; } $sort = elgg_extract('sort', $options); unset($options['sort']); if (!is_array($sort)) { return $options; } $dbprefix = elgg_get_config('dbprefix'); $order_by = array(); foreach ($sort as $field => $direction) { $field = sanitize_string($field); $direction = strtoupper(sanitize_string($direction)); if (!in_array($direction, array('ASC', 'DESC'))) { $direction = 'ASC'; } switch ($field) { case 'alpha' : if (elgg_extract('types', $options) == 'user') { $options['joins']['ue'] = "JOIN {$dbprefix}users_entity ue ON ue.guid = e.guid"; $order_by[] = "ue.name {$direction}"; } else if (elgg_extract('types', $options) == 'group') { $options['joins']['ge'] = "JOIN {$dbprefix}groups_entity ge ON ge.guid = e.guid"; $order_by[] = "ge.name {$direction}"; } else if (elgg_extract('types', $options) == 'object') { $options['joins']['oe'] = "JOIN {$dbprefix}objects_entity oe ON oe.guid = e.guid"; $order_by[] = "oe.title {$direction}"; } break; case 'type' : case 'subtype' : case 'guid' : case 'owner_guid' : case 'container_guid' : case 'site_guid' : case 'enabled' : case 'time_created'; case 'time_updated' : case 'last_action' : case 'access_id' : $order_by[] = "e.{$field} {$direction}"; break; } } $options['order_by'] = implode(',', $order_by); return $options; }
[ "protected", "function", "prepareBatchOptions", "(", "array", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "!", "in_array", "(", "$", "this", "->", "getter", ",", "array", "(", "'elgg_get_entities'", ",", "'elgg_get_entities_from_metadata'", ",...
Prepares batch options @param array $options ege* options @return array
[ "Prepares", "batch", "options" ]
704a0aa57e817aa38bb9e40ad3710ba69d52e44c
https://github.com/hypeJunction/hypeApps/blob/704a0aa57e817aa38bb9e40ad3710ba69d52e44c/classes/hypeJunction/BatchResult.php#L96-L160
train
retrinko/ini
src/IniParser.php
IniParser.castItemValueToProperType
public function castItemValueToProperType($value) { $normalized = $value; if (in_array($value, ['true', 'on', 'yes'])) { $normalized = true; } elseif (in_array($value, ['false', 'off', 'no', 'none'])) { $normalized = false; } elseif ('null' == $value) { $normalized = null; } elseif (is_numeric($value)) { $number = $value + 0; if (intval($number) == $number) { $normalized = (int)$number; } elseif (floatval($number) == $number) { $normalized = (float)$number; } } elseif (is_array($value)) { foreach ($value as $itemKey => $itemValue) { $normalized[$itemKey] = $this->castItemValueToProperType($itemValue); } } return $normalized; }
php
public function castItemValueToProperType($value) { $normalized = $value; if (in_array($value, ['true', 'on', 'yes'])) { $normalized = true; } elseif (in_array($value, ['false', 'off', 'no', 'none'])) { $normalized = false; } elseif ('null' == $value) { $normalized = null; } elseif (is_numeric($value)) { $number = $value + 0; if (intval($number) == $number) { $normalized = (int)$number; } elseif (floatval($number) == $number) { $normalized = (float)$number; } } elseif (is_array($value)) { foreach ($value as $itemKey => $itemValue) { $normalized[$itemKey] = $this->castItemValueToProperType($itemValue); } } return $normalized; }
[ "public", "function", "castItemValueToProperType", "(", "$", "value", ")", "{", "$", "normalized", "=", "$", "value", ";", "if", "(", "in_array", "(", "$", "value", ",", "[", "'true'", ",", "'on'", ",", "'yes'", "]", ")", ")", "{", "$", "normalized", ...
Cast item string value to proper type @param string $value @return array|string|bool|int|float|null
[ "Cast", "item", "string", "value", "to", "proper", "type" ]
a8d41646e95a0c3026dc293f2aa679bb5f88b102
https://github.com/retrinko/ini/blob/a8d41646e95a0c3026dc293f2aa679bb5f88b102/src/IniParser.php#L101-L137
train
BerliozFramework/Berlioz
src/Services/Routing/Route.php
Route.createFromReflection
public static function createFromReflection(\ReflectionMethod $reflectionMethod, string $basePath = '') { $routes = []; if (is_a($reflectionMethod->class, '\Berlioz\Core\Controller\Controller', true)) { try { if ($reflectionMethod->isPublic()) { if ($methodDoc = $reflectionMethod->getDocComment()) { $docBlock = Router::getDocBlockFactory()->create($methodDoc); if ($docBlock->hasTag('route')) { /** @var \phpDocumentor\Reflection\DocBlock\Tags\Generic $tag */ foreach ($docBlock->getTagsByName('route') as $tag) { $route = new Route; $route->setRouteDeclaration($tag->getDescription()->render(), $basePath); $route->setSummary($docBlock->getSummary()); $route->setDescription($docBlock->getDescription()->render()); $route->setInvoke($reflectionMethod->class, $reflectionMethod->getName()); $route->getRouteRegex(); $routes[] = $route; } } } } else { /** @var \ReflectionMethod $reflectionMethod */ throw new BerliozException('Must be public'); } } catch (BerliozException $e) { /** @var \ReflectionMethod $reflectionMethod */ throw new BerliozException(sprintf('Method "%s::%s" route error: %s', $reflectionMethod->class, $reflectionMethod->getName(), $e->getMessage())); } } else { throw new BerliozException(sprintf('Class "%s" must be a sub class of "\Berlioz\Core\Controller\Controller"', $reflectionMethod->class)); } return $routes; }
php
public static function createFromReflection(\ReflectionMethod $reflectionMethod, string $basePath = '') { $routes = []; if (is_a($reflectionMethod->class, '\Berlioz\Core\Controller\Controller', true)) { try { if ($reflectionMethod->isPublic()) { if ($methodDoc = $reflectionMethod->getDocComment()) { $docBlock = Router::getDocBlockFactory()->create($methodDoc); if ($docBlock->hasTag('route')) { /** @var \phpDocumentor\Reflection\DocBlock\Tags\Generic $tag */ foreach ($docBlock->getTagsByName('route') as $tag) { $route = new Route; $route->setRouteDeclaration($tag->getDescription()->render(), $basePath); $route->setSummary($docBlock->getSummary()); $route->setDescription($docBlock->getDescription()->render()); $route->setInvoke($reflectionMethod->class, $reflectionMethod->getName()); $route->getRouteRegex(); $routes[] = $route; } } } } else { /** @var \ReflectionMethod $reflectionMethod */ throw new BerliozException('Must be public'); } } catch (BerliozException $e) { /** @var \ReflectionMethod $reflectionMethod */ throw new BerliozException(sprintf('Method "%s::%s" route error: %s', $reflectionMethod->class, $reflectionMethod->getName(), $e->getMessage())); } } else { throw new BerliozException(sprintf('Class "%s" must be a sub class of "\Berlioz\Core\Controller\Controller"', $reflectionMethod->class)); } return $routes; }
[ "public", "static", "function", "createFromReflection", "(", "\\", "ReflectionMethod", "$", "reflectionMethod", ",", "string", "$", "basePath", "=", "''", ")", "{", "$", "routes", "=", "[", "]", ";", "if", "(", "is_a", "(", "$", "reflectionMethod", "->", "...
Create Route from \ReflectionMethod object. @param \ReflectionMethod $reflectionMethod Reflection of method @param string $basePath Base of path for all routes in method @return Route[] @throws \Berlioz\Core\Exception\BerliozException
[ "Create", "Route", "from", "\\", "ReflectionMethod", "object", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Routing/Route.php#L58-L95
train
BerliozFramework/Berlioz
src/Services/Routing/Route.php
Route.filterParameters
private function filterParameters(array $params): array { return array_filter( $params, function (&$value) { if (is_array($value)) { $value = $this->filterParameters($value); return count($value) > 0; } else { return !is_null($value); } } ); }
php
private function filterParameters(array $params): array { return array_filter( $params, function (&$value) { if (is_array($value)) { $value = $this->filterParameters($value); return count($value) > 0; } else { return !is_null($value); } } ); }
[ "private", "function", "filterParameters", "(", "array", "$", "params", ")", ":", "array", "{", "return", "array_filter", "(", "$", "params", ",", "function", "(", "&", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", ...
Filter parameters, and remove null parameters. @param array $params Parameters @return array
[ "Filter", "parameters", "and", "remove", "null", "parameters", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/Services/Routing/Route.php#L506-L521
train
inpsyde/inpsyde-validator
src/Error/ErrorLogger.php
ErrorLogger.as_string
private function as_string( $value ) { if ( is_object( $value ) && method_exists( $value, '__toString' ) ) { $value = (string) $value; } if ( is_string( $value ) ) { return $value; } elseif ( is_null( $value ) ) { return 'NULL'; } elseif ( is_bool( $value ) ) { return $value ? '(boolean) TRUE' : '(boolean) FALSE'; } if ( is_object( $value ) ) { $value = get_class( $value ); $type = '(object) '; } elseif ( is_array( $value ) ) { $type = ''; $value = var_export( $value, TRUE ); } isset( $type ) or $type = '(' . gettype( $value ) . ') '; return $type . (string) $value; }
php
private function as_string( $value ) { if ( is_object( $value ) && method_exists( $value, '__toString' ) ) { $value = (string) $value; } if ( is_string( $value ) ) { return $value; } elseif ( is_null( $value ) ) { return 'NULL'; } elseif ( is_bool( $value ) ) { return $value ? '(boolean) TRUE' : '(boolean) FALSE'; } if ( is_object( $value ) ) { $value = get_class( $value ); $type = '(object) '; } elseif ( is_array( $value ) ) { $type = ''; $value = var_export( $value, TRUE ); } isset( $type ) or $type = '(' . gettype( $value ) . ') '; return $type . (string) $value; }
[ "private", "function", "as_string", "(", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", "&&", "method_exists", "(", "$", "value", ",", "'__toString'", ")", ")", "{", "$", "value", "=", "(", "string", ")", "$", "value", ";", ...
Returns a string representation of any value. @param mixed $value @return string $type
[ "Returns", "a", "string", "representation", "of", "any", "value", "." ]
dcc57f705f142071a1764204bb469eee0bb5015d
https://github.com/inpsyde/inpsyde-validator/blob/dcc57f705f142071a1764204bb469eee0bb5015d/src/Error/ErrorLogger.php#L303-L328
train
SaftIng/Saft
src/Saft/Rdf/NodeFactoryImpl.php
NodeFactoryImpl.createNodeInstanceFromNodeParameter
public function createNodeInstanceFromNodeParameter($value, $type, $datatype = null, $language = null) { switch ($type) { case 'uri': return $this->createNamedNode($value); case 'bnode': return $this->createBlankNode($value); case 'literal': return $this->createLiteral($value, $datatype, $language); case 'typed-literal': return $this->createLiteral($value, $datatype, $language); case 'var': return $this->createAnyPattern(); default: throw new \Exception('Unknown $type given: '.$type); } }
php
public function createNodeInstanceFromNodeParameter($value, $type, $datatype = null, $language = null) { switch ($type) { case 'uri': return $this->createNamedNode($value); case 'bnode': return $this->createBlankNode($value); case 'literal': return $this->createLiteral($value, $datatype, $language); case 'typed-literal': return $this->createLiteral($value, $datatype, $language); case 'var': return $this->createAnyPattern(); default: throw new \Exception('Unknown $type given: '.$type); } }
[ "public", "function", "createNodeInstanceFromNodeParameter", "(", "$", "value", ",", "$", "type", ",", "$", "datatype", "=", "null", ",", "$", "language", "=", "null", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'uri'", ":", "return", "$", ...
Helper function, which is useful, if you have all the meta information about a Node and want to create the according Node instance. @param string $value value of the node @param string $type Can be uri, bnode, var or literal @param string $datatype URI of the datatype (optional) @param string $language Language tag (optional) @return Node Node instance, which type is one of: NamedNode, BlankNode, Literal, AnyPattern @throws \Exception if an unknown type was given @throws \Exception if something went wrong during Node creation @api @since 0.8
[ "Helper", "function", "which", "is", "useful", "if", "you", "have", "all", "the", "meta", "information", "about", "a", "Node", "and", "want", "to", "create", "the", "according", "Node", "instance", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Rdf/NodeFactoryImpl.php#L143-L164
train
shopgate/cart-integration-magento2-base
src/Helper/Settings/Retriever.php
Retriever.methodLoader
private function methodLoader($methods) { foreach ($methods as $key => $param) { if (is_array($param)) { $methods[$key] = $this->methodLoader($this->getExportParams($key)); continue; } $method = 'get' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($param); if (method_exists($this, $method)) { $methods[$param] = $this->{$method}(); unset($methods[$key]); } } return $methods; }
php
private function methodLoader($methods) { foreach ($methods as $key => $param) { if (is_array($param)) { $methods[$key] = $this->methodLoader($this->getExportParams($key)); continue; } $method = 'get' . SimpleDataObjectConverter::snakeCaseToUpperCamelCase($param); if (method_exists($this, $method)) { $methods[$param] = $this->{$method}(); unset($methods[$key]); } } return $methods; }
[ "private", "function", "methodLoader", "(", "$", "methods", ")", "{", "foreach", "(", "$", "methods", "as", "$", "key", "=>", "$", "param", ")", "{", "if", "(", "is_array", "(", "$", "param", ")", ")", "{", "$", "methods", "[", "$", "key", "]", "...
Traverses method array and calls the functions of this class @param array $methods - array(snake_case) @return array
[ "Traverses", "method", "array", "and", "calls", "the", "functions", "of", "this", "class" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Settings/Retriever.php#L83-L99
train
shopgate/cart-integration-magento2-base
src/Helper/Settings/Retriever.php
Retriever.getExportParams
private function getExportParams($key = null) { if ($key && isset($this->exportParams[$key])) { return $this->exportParams[$key]; } return $this->exportParams; }
php
private function getExportParams($key = null) { if ($key && isset($this->exportParams[$key])) { return $this->exportParams[$key]; } return $this->exportParams; }
[ "private", "function", "getExportParams", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", "&&", "isset", "(", "$", "this", "->", "exportParams", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "exportParams", "[", "...
Retrieves all parameters if no key is specified @param string|null $key @return string|array
[ "Retrieves", "all", "parameters", "if", "no", "key", "is", "specified" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Settings/Retriever.php#L108-L115
train
mmoreram/SimpleDoctrineMapping
Locator/SimpleDoctrineMappingLocator.php
SimpleDoctrineMappingLocator.setPaths
public function setPaths($paths) { $this->paths = $paths; self::$pathsMap[$this->namespace] = $this->paths; }
php
public function setPaths($paths) { $this->paths = $paths; self::$pathsMap[$this->namespace] = $this->paths; }
[ "public", "function", "setPaths", "(", "$", "paths", ")", "{", "$", "this", "->", "paths", "=", "$", "paths", ";", "self", "::", "$", "pathsMap", "[", "$", "this", "->", "namespace", "]", "=", "$", "this", "->", "paths", ";", "}" ]
Set paths. @param array $paths
[ "Set", "paths", "." ]
7b527eb4e4552fce600b094786d2f416948b1657
https://github.com/mmoreram/SimpleDoctrineMapping/blob/7b527eb4e4552fce600b094786d2f416948b1657/Locator/SimpleDoctrineMappingLocator.php#L57-L61
train
shopgate/cart-integration-magento2-base
src/Block/Adminhtml/Form/Field/CmsMap.php
CmsMap._toHtml
protected function _toHtml() { if (!$this->getOptions()) { $cmsPages = $this->cmsPageCollection->addStoreFilter($this->getStoreFromContext()); foreach ($cmsPages as $cmsPage) { /** @var \Magento\Cms\Model\Page $cmsPage */ $this->addOption($cmsPage->getId(), $cmsPage->getTitle()); } } return parent::_toHtml(); }
php
protected function _toHtml() { if (!$this->getOptions()) { $cmsPages = $this->cmsPageCollection->addStoreFilter($this->getStoreFromContext()); foreach ($cmsPages as $cmsPage) { /** @var \Magento\Cms\Model\Page $cmsPage */ $this->addOption($cmsPage->getId(), $cmsPage->getTitle()); } } return parent::_toHtml(); }
[ "protected", "function", "_toHtml", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getOptions", "(", ")", ")", "{", "$", "cmsPages", "=", "$", "this", "->", "cmsPageCollection", "->", "addStoreFilter", "(", "$", "this", "->", "getStoreFromContext", "...
Retrieves all the pages that are allowed to be viewed in the current context @return string @throws \Magento\Framework\Exception\LocalizedException @codingStandardsIgnoreStart
[ "Retrieves", "all", "the", "pages", "that", "are", "allowed", "to", "be", "viewed", "in", "the", "current", "context" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Block/Adminhtml/Form/Field/CmsMap.php#L74-L85
train
shopgate/cart-integration-magento2-base
src/Block/Adminhtml/Form/Field/CmsMap.php
CmsMap.getStoreFromContext
public function getStoreFromContext() { $params = $this->getRequest()->getParams(); if (isset($params['store'])) { return [$params['store']]; } elseif (isset($params['website'])) { /** @var Website $website */ $website = $this->storeManager->getWebsite($params['website']); return $website->getStoreIds(); } return array_keys($this->storeManager->getStores()); }
php
public function getStoreFromContext() { $params = $this->getRequest()->getParams(); if (isset($params['store'])) { return [$params['store']]; } elseif (isset($params['website'])) { /** @var Website $website */ $website = $this->storeManager->getWebsite($params['website']); return $website->getStoreIds(); } return array_keys($this->storeManager->getStores()); }
[ "public", "function", "getStoreFromContext", "(", ")", "{", "$", "params", "=", "$", "this", "->", "getRequest", "(", ")", "->", "getParams", "(", ")", ";", "if", "(", "isset", "(", "$", "params", "[", "'store'", "]", ")", ")", "{", "return", "[", ...
Retrieves the stores that are allowed in the context E.g. Store X will just return itself E.g. Website Y will return an array of all stores under it E.g. Default will return all store ids @return array - e.g. [1] or [1,3] @throws \Magento\Framework\Exception\LocalizedException
[ "Retrieves", "the", "stores", "that", "are", "allowed", "in", "the", "context", "E", ".", "g", ".", "Store", "X", "will", "just", "return", "itself", "E", ".", "g", ".", "Website", "Y", "will", "return", "an", "array", "of", "all", "stores", "under", ...
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Block/Adminhtml/Form/Field/CmsMap.php#L97-L111
train
cymapgt/UserCredential
src/abstractclass/UserCredentialAbstract.php
UserCredentialAbstract._initializeProfile
private function _initializeProfile($userProfile) { die(print_r($userProfile)); //validate that user profile has the correct information for password validation if (!is_array($userProfile) || !isset($userProfile['username']) || !isset($userProfile['password']) || !isset($userProfile['fullname']) || !isset($userProfile['passhash']) || !is_string($userProfile['passhash']) || !isset($userProfile['passhist']) || !is_array($userProfile['passhist']) || !isset($userProfile['account_state']) || !isset($userProfile['policyinfo']) || !is_array($userProfile['policyinfo']) || !is_array($userProfile['platforminfo']) ) { throw new UserCredentialException('The user profile is not properly initialized', 1000); } //validate tenancy is a datetime if (array_key_exists('tenancy_expiry', $userProfile['policyinfo'])) { $tenancyExpiry = $userProfile['policyinfo']['tenancy_expiry']; if (($tenancyExpiry instanceof \DateTime) === false) { throw new UserCredentialException('The user profile is not properly initialized', 1000); } } //set a blank TOTP profile if not set if (!isset($userProfile['totpinfo'])) { $userProfile['totpinfo'] = array(); } $this->_userProfile = $userProfile; }
php
private function _initializeProfile($userProfile) { die(print_r($userProfile)); //validate that user profile has the correct information for password validation if (!is_array($userProfile) || !isset($userProfile['username']) || !isset($userProfile['password']) || !isset($userProfile['fullname']) || !isset($userProfile['passhash']) || !is_string($userProfile['passhash']) || !isset($userProfile['passhist']) || !is_array($userProfile['passhist']) || !isset($userProfile['account_state']) || !isset($userProfile['policyinfo']) || !is_array($userProfile['policyinfo']) || !is_array($userProfile['platforminfo']) ) { throw new UserCredentialException('The user profile is not properly initialized', 1000); } //validate tenancy is a datetime if (array_key_exists('tenancy_expiry', $userProfile['policyinfo'])) { $tenancyExpiry = $userProfile['policyinfo']['tenancy_expiry']; if (($tenancyExpiry instanceof \DateTime) === false) { throw new UserCredentialException('The user profile is not properly initialized', 1000); } } //set a blank TOTP profile if not set if (!isset($userProfile['totpinfo'])) { $userProfile['totpinfo'] = array(); } $this->_userProfile = $userProfile; }
[ "private", "function", "_initializeProfile", "(", "$", "userProfile", ")", "{", "die", "(", "print_r", "(", "$", "userProfile", ")", ")", ";", "//validate that user profile has the correct information for password validation\r", "if", "(", "!", "is_array", "(", "$", "...
initializes the user profiles data as per the user credentials provided to the constructor method Cyril Ogana <cogana@gmail.com> - 2015-07-18 @param array / ArrayAccess $userProfile @access private
[ "initializes", "the", "user", "profiles", "data", "as", "per", "the", "user", "credentials", "provided", "to", "the", "constructor", "method" ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/abstractclass/UserCredentialAbstract.php#L66-L100
train
cymapgt/UserCredential
src/abstractclass/UserCredentialAbstract.php
UserCredentialAbstract._validateConsecutiveCharacterRepeat
final protected function _validateConsecutiveCharacterRepeat() { //validate that required indices exist if (!isset($this->_userProfile['username']) || !isset($this->_userProfile['password']) || !isset($this->_userProfile['fullname']) || !isset($this->_userProfile['passhist']) ) { throw new UserCredentialException('The username and password are not set', 1016); } //FOR CHARACTER REPETITION //determine which entropy to use (base or udf) $entropyObj = $this->_udfEntropySetting; $maxConsecutiveChars = (int) ($entropyObj['max_consecutive_chars']); //because we offset by -2 when doing regex, if the limit is not greater or equal to 2, default to 2 if (!($maxConsecutiveChars >= 2)) { $maxConsecutiveChars = 2; } //offset for purposes of matching (TODO: fix?) $maxConsecutiveCharsRegexOffset = ++$maxConsecutiveChars - 2; //build regex $maxConsecutiveCharsRegex = '/' . $this->_regexBuildPattern(5, $maxConsecutiveCharsRegexOffset) . '/'; $testVal = preg_match($maxConsecutiveCharsRegex,$this->_userProfile['password']); if ($testVal === false) { throw new UserCredentialException('A fatal error occured in the password validation', 1018); } elseif ($testVal == true) { throw new UserCredentialException('The password violates policy about consecutive character repetitions. '. $this->_getPasswordCharacterRepeatDescription(), \USERCREDENTIAL_ACCOUNTPOLICY_WEAKPASSWD); } else {/*Do nothing*/} //FOR CHARACTER CLASS REPETITION //determine which entropy to use (base or udf) $maxConsecutiveCharsSameClass = (int) ($entropyObj['max_consecutive_chars_of_same_class']); //because we offset by -2 when doing regex, if the limit is not greater or equal to 2, default to 2 if (!($maxConsecutiveCharsSameClass >= 2)) { $maxConsecutiveCharsSameClass = 2; } //offset for purposes of matching (TODO: fix?) $maxConsecutiveCharsSameClassRegexOffset = ++$maxConsecutiveCharsSameClass; //build regex $maxConsecutiveCharsSameClassRegex = '/' . $this->_regexBuildPattern(6, $maxConsecutiveCharsSameClassRegexOffset) . '/'; $testValSameClass = preg_match($maxConsecutiveCharsSameClassRegex,$this->_userProfile['password']); if ($testValSameClass === false) { throw new UserCredentialException('A fatal error occured in the password validation', 1018); } elseif ($testValSameClass == true) { throw new UserCredentialException('The password violates policy about consecutive repetition of characters of the same class. '. $this->_getPasswordCharacterClassRepeatDescription(), \USERCREDENTIAL_ACCOUNTPOLICY_WEAKPASSWD); } else { return true; } return true; }
php
final protected function _validateConsecutiveCharacterRepeat() { //validate that required indices exist if (!isset($this->_userProfile['username']) || !isset($this->_userProfile['password']) || !isset($this->_userProfile['fullname']) || !isset($this->_userProfile['passhist']) ) { throw new UserCredentialException('The username and password are not set', 1016); } //FOR CHARACTER REPETITION //determine which entropy to use (base or udf) $entropyObj = $this->_udfEntropySetting; $maxConsecutiveChars = (int) ($entropyObj['max_consecutive_chars']); //because we offset by -2 when doing regex, if the limit is not greater or equal to 2, default to 2 if (!($maxConsecutiveChars >= 2)) { $maxConsecutiveChars = 2; } //offset for purposes of matching (TODO: fix?) $maxConsecutiveCharsRegexOffset = ++$maxConsecutiveChars - 2; //build regex $maxConsecutiveCharsRegex = '/' . $this->_regexBuildPattern(5, $maxConsecutiveCharsRegexOffset) . '/'; $testVal = preg_match($maxConsecutiveCharsRegex,$this->_userProfile['password']); if ($testVal === false) { throw new UserCredentialException('A fatal error occured in the password validation', 1018); } elseif ($testVal == true) { throw new UserCredentialException('The password violates policy about consecutive character repetitions. '. $this->_getPasswordCharacterRepeatDescription(), \USERCREDENTIAL_ACCOUNTPOLICY_WEAKPASSWD); } else {/*Do nothing*/} //FOR CHARACTER CLASS REPETITION //determine which entropy to use (base or udf) $maxConsecutiveCharsSameClass = (int) ($entropyObj['max_consecutive_chars_of_same_class']); //because we offset by -2 when doing regex, if the limit is not greater or equal to 2, default to 2 if (!($maxConsecutiveCharsSameClass >= 2)) { $maxConsecutiveCharsSameClass = 2; } //offset for purposes of matching (TODO: fix?) $maxConsecutiveCharsSameClassRegexOffset = ++$maxConsecutiveCharsSameClass; //build regex $maxConsecutiveCharsSameClassRegex = '/' . $this->_regexBuildPattern(6, $maxConsecutiveCharsSameClassRegexOffset) . '/'; $testValSameClass = preg_match($maxConsecutiveCharsSameClassRegex,$this->_userProfile['password']); if ($testValSameClass === false) { throw new UserCredentialException('A fatal error occured in the password validation', 1018); } elseif ($testValSameClass == true) { throw new UserCredentialException('The password violates policy about consecutive repetition of characters of the same class. '. $this->_getPasswordCharacterClassRepeatDescription(), \USERCREDENTIAL_ACCOUNTPOLICY_WEAKPASSWD); } else { return true; } return true; }
[ "final", "protected", "function", "_validateConsecutiveCharacterRepeat", "(", ")", "{", "//validate that required indices exist\r", "if", "(", "!", "isset", "(", "$", "this", "->", "_userProfile", "[", "'username'", "]", ")", "||", "!", "isset", "(", "$", "this", ...
validate that there are no instances of consecutive character repetitions beyond allowed number in the users password string Cyril Ogana <cogana@gmail.com> 2015-07-18 @return bool @access protected @final
[ "validate", "that", "there", "are", "no", "instances", "of", "consecutive", "character", "repetitions", "beyond", "allowed", "number", "in", "the", "users", "password", "string" ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/abstractclass/UserCredentialAbstract.php#L825-L883
train
cymapgt/UserCredential
src/abstractclass/UserCredentialAbstract.php
UserCredentialAbstract._validatePolicy
final protected function _validatePolicy() { //validate that required indices exist if (!isset($this->_userProfile['username']) || !isset($this->_userProfile['password']) || !isset($this->_userProfile['fullname']) || !isset($this->_userProfile['passhist']) ) { throw new UserCredentialException('The username and password are not set', 1016); } //determine which entropy to use (base or udf) $policyObj = $this->_udfPasswordPolicy; //check attempt limits if ($this->_userProfile['account_state'] == \USERCREDENTIAL_ACCOUNTSTATE_AUTHFAILED) { if ($this->_userProfile['policyinfo']['failed_attempt_count'] > $policyObj['illegal_attempts_limit']) { throw new UserCredentialException('The account has exceeded login attempts and is locked. Contact admin', \USERCREDENTIAL_ACCOUNTPOLICY_ATTEMPTLIMIT2); } elseif ($this->_userProfile['policyinfo']['failed_attempt_count'] == $policyObj['illegal_attempts_limit']) { throw new UserCredentialException('The account has failed login '.(++$policyObj['illegal_attempts_limit']).' times in a row and is temporarily locked. Any further wrong passwords will lead to your account being locked fully. You will be automatically unlocked in '.(($policyObj['illegal_attempts_penalty_seconds']) / 60).' minutes or contact admin to unlock immediately', \USERCREDENTIAL_ACCOUNTPOLICY_ATTEMPTLIMIT1); } else { throw new UserCredentialException('Login failed. Wrong username or password', \USERCREDENTIAL_ACCOUNTPOLICY_VALID); } } //check needs reset $currDateTimeObj = new \DateTime(); $passChangeDaysElapsedObj = $currDateTimeObj->diff($this->_userProfile['policyinfo']['password_last_changed_datetime']); $passChangeDaysElapsed = $passChangeDaysElapsedObj->format('%a'); if ($passChangeDaysElapsed > $policyObj['password_reset_frequency']) { throw new UserCredentialException('The password has expired and must be changed', \USERCREDENTIAL_ACCOUNTPOLICY_EXPIRED); } return true; }
php
final protected function _validatePolicy() { //validate that required indices exist if (!isset($this->_userProfile['username']) || !isset($this->_userProfile['password']) || !isset($this->_userProfile['fullname']) || !isset($this->_userProfile['passhist']) ) { throw new UserCredentialException('The username and password are not set', 1016); } //determine which entropy to use (base or udf) $policyObj = $this->_udfPasswordPolicy; //check attempt limits if ($this->_userProfile['account_state'] == \USERCREDENTIAL_ACCOUNTSTATE_AUTHFAILED) { if ($this->_userProfile['policyinfo']['failed_attempt_count'] > $policyObj['illegal_attempts_limit']) { throw new UserCredentialException('The account has exceeded login attempts and is locked. Contact admin', \USERCREDENTIAL_ACCOUNTPOLICY_ATTEMPTLIMIT2); } elseif ($this->_userProfile['policyinfo']['failed_attempt_count'] == $policyObj['illegal_attempts_limit']) { throw new UserCredentialException('The account has failed login '.(++$policyObj['illegal_attempts_limit']).' times in a row and is temporarily locked. Any further wrong passwords will lead to your account being locked fully. You will be automatically unlocked in '.(($policyObj['illegal_attempts_penalty_seconds']) / 60).' minutes or contact admin to unlock immediately', \USERCREDENTIAL_ACCOUNTPOLICY_ATTEMPTLIMIT1); } else { throw new UserCredentialException('Login failed. Wrong username or password', \USERCREDENTIAL_ACCOUNTPOLICY_VALID); } } //check needs reset $currDateTimeObj = new \DateTime(); $passChangeDaysElapsedObj = $currDateTimeObj->diff($this->_userProfile['policyinfo']['password_last_changed_datetime']); $passChangeDaysElapsed = $passChangeDaysElapsedObj->format('%a'); if ($passChangeDaysElapsed > $policyObj['password_reset_frequency']) { throw new UserCredentialException('The password has expired and must be changed', \USERCREDENTIAL_ACCOUNTPOLICY_EXPIRED); } return true; }
[ "final", "protected", "function", "_validatePolicy", "(", ")", "{", "//validate that required indices exist\r", "if", "(", "!", "isset", "(", "$", "this", "->", "_userProfile", "[", "'username'", "]", ")", "||", "!", "isset", "(", "$", "this", "->", "_userProf...
validate the password policy during authentication Cyril Ogana <cogana@gmail.com> 2015-07-18 @return bool @access protected @final
[ "validate", "the", "password", "policy", "during", "authentication" ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/abstractclass/UserCredentialAbstract.php#L896-L930
train
cymapgt/UserCredential
src/abstractclass/UserCredentialAbstract.php
UserCredentialAbstract._validatePolicyAtChange
final protected function _validatePolicyAtChange() { //validate that required indices exist if (!isset($this->_userProfile['username']) || !isset($this->_userProfile['password']) || !isset($this->_userProfile['fullname']) || !isset($this->_userProfile['passhist']) ) { throw new UserCredentialException('The username and password are not set', 1016); } //determine which entropy to use (base or udf) $policyObj = $this->_udfPasswordPolicy; //check password repeat $passHistory = $this->_userProfile['passhist']; $passHistoryRequired = array_slice($passHistory, 0, ((int) $policyObj['password_repeat_minimum'])); //iterate and verify foreach ($passHistoryRequired as $passHistoryItem) { if (password_verify($this->_userProfile['password'], $passHistoryItem)) { throw new UserCredentialException('User cannot repeat any of their ' . $policyObj['password_repeat_minimum'] . ' last passwords', \USERCREDENTIAL_ACCOUNTPOLICY_REPEATERROR); } } return true; }
php
final protected function _validatePolicyAtChange() { //validate that required indices exist if (!isset($this->_userProfile['username']) || !isset($this->_userProfile['password']) || !isset($this->_userProfile['fullname']) || !isset($this->_userProfile['passhist']) ) { throw new UserCredentialException('The username and password are not set', 1016); } //determine which entropy to use (base or udf) $policyObj = $this->_udfPasswordPolicy; //check password repeat $passHistory = $this->_userProfile['passhist']; $passHistoryRequired = array_slice($passHistory, 0, ((int) $policyObj['password_repeat_minimum'])); //iterate and verify foreach ($passHistoryRequired as $passHistoryItem) { if (password_verify($this->_userProfile['password'], $passHistoryItem)) { throw new UserCredentialException('User cannot repeat any of their ' . $policyObj['password_repeat_minimum'] . ' last passwords', \USERCREDENTIAL_ACCOUNTPOLICY_REPEATERROR); } } return true; }
[ "final", "protected", "function", "_validatePolicyAtChange", "(", ")", "{", "//validate that required indices exist\r", "if", "(", "!", "isset", "(", "$", "this", "->", "_userProfile", "[", "'username'", "]", ")", "||", "!", "isset", "(", "$", "this", "->", "_...
validate the password policy during process of making a password change Cyril Ogana <cogana@gmail.com> 2015-07-18 @return bool @access protected @final
[ "validate", "the", "password", "policy", "during", "process", "of", "making", "a", "password", "change" ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/abstractclass/UserCredentialAbstract.php#L944-L969
train
cymapgt/UserCredential
src/abstractclass/UserCredentialAbstract.php
UserCredentialAbstract._canChangePassword
final protected function _canChangePassword() { //validate that required indices exist if (!isset($this->_userProfile['username']) || !isset($this->_userProfile['password']) || !isset($this->_userProfile['fullname']) || !isset($this->_userProfile['passhist']) ) { throw new UserCredentialException('The username and password are not set', 1016); } //Verify if the password was changed today or server has been futuredated $currDateTimeObj = new \DateTime(); //Password was changed today or in the future if ($currDateTimeObj <= $this->_userProfile['policyinfo']['password_last_changed_datetime']) { return false; } else { return true; } }
php
final protected function _canChangePassword() { //validate that required indices exist if (!isset($this->_userProfile['username']) || !isset($this->_userProfile['password']) || !isset($this->_userProfile['fullname']) || !isset($this->_userProfile['passhist']) ) { throw new UserCredentialException('The username and password are not set', 1016); } //Verify if the password was changed today or server has been futuredated $currDateTimeObj = new \DateTime(); //Password was changed today or in the future if ($currDateTimeObj <= $this->_userProfile['policyinfo']['password_last_changed_datetime']) { return false; } else { return true; } }
[ "final", "protected", "function", "_canChangePassword", "(", ")", "{", "//validate that required indices exist\r", "if", "(", "!", "isset", "(", "$", "this", "->", "_userProfile", "[", "'username'", "]", ")", "||", "!", "isset", "(", "$", "this", "->", "_userP...
Check that a user can change password in case you want to implement limits on changing passwords only once in 24 hours Cyril Ogana <cogana@gmail.com> 2015-07-18 @return bool @access protected @final
[ "Check", "that", "a", "user", "can", "change", "password", "in", "case", "you", "want", "to", "implement", "limits", "on", "changing", "passwords", "only", "once", "in", "24", "hours" ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/abstractclass/UserCredentialAbstract.php#L983-L1002
train
cymapgt/UserCredential
src/abstractclass/UserCredentialAbstract.php
UserCredentialAbstract._validateTenancy
final protected function _validateTenancy() { $userProfile = $this->_userProfile; //Verify if the password was changed today or server has been futuredated $currDateTimeObj = new \DateTime(); //if account has tenancy expiry, deny login if user account tenancy is past if (array_key_exists('tenancy_expiry', $userProfile['policyinfo'])) { $tenancyExpiry = $userProfile['policyinfo']['tenancy_expiry']; if ($currDateTimeObj > $tenancyExpiry) { throw new UserCredentialException('Tenancy problem with your account. Please contact your Administrator'); } } return true; }
php
final protected function _validateTenancy() { $userProfile = $this->_userProfile; //Verify if the password was changed today or server has been futuredated $currDateTimeObj = new \DateTime(); //if account has tenancy expiry, deny login if user account tenancy is past if (array_key_exists('tenancy_expiry', $userProfile['policyinfo'])) { $tenancyExpiry = $userProfile['policyinfo']['tenancy_expiry']; if ($currDateTimeObj > $tenancyExpiry) { throw new UserCredentialException('Tenancy problem with your account. Please contact your Administrator'); } } return true; }
[ "final", "protected", "function", "_validateTenancy", "(", ")", "{", "$", "userProfile", "=", "$", "this", "->", "_userProfile", ";", "//Verify if the password was changed today or server has been futuredated\r", "$", "currDateTimeObj", "=", "new", "\\", "DateTime", "(", ...
validate the tenancy of an account. This can be preset by the system admin so that accounts that are past tenancy date are automatically not allowed to authenticate. Tenancy should be validated after other policies to avoid farming of accounts by testing which ones are still in tenancy Cyril Ogana <cogana@gmail.com> 2018-04-25 @return bool @access protected @final
[ "validate", "the", "tenancy", "of", "an", "account", ".", "This", "can", "be", "preset", "by", "the", "system", "admin", "so", "that", "accounts", "that", "are", "past", "tenancy", "date", "are", "automatically", "not", "allowed", "to", "authenticate", ".", ...
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/abstractclass/UserCredentialAbstract.php#L1017-L1033
train
Problematic/ProblematicAclManagerBundle
Domain/AbstractAclManager.php
AbstractAclManager.doLoadAcl
protected function doLoadAcl(ObjectIdentityInterface $objectIdentity) { $acl = null; try { $acl = $this->getAclProvider()->createAcl($objectIdentity); } catch (AclAlreadyExistsException $ex) { $acl = $this->getAclProvider()->findAcl($objectIdentity); } return $acl; }
php
protected function doLoadAcl(ObjectIdentityInterface $objectIdentity) { $acl = null; try { $acl = $this->getAclProvider()->createAcl($objectIdentity); } catch (AclAlreadyExistsException $ex) { $acl = $this->getAclProvider()->findAcl($objectIdentity); } return $acl; }
[ "protected", "function", "doLoadAcl", "(", "ObjectIdentityInterface", "$", "objectIdentity", ")", "{", "$", "acl", "=", "null", ";", "try", "{", "$", "acl", "=", "$", "this", "->", "getAclProvider", "(", ")", "->", "createAcl", "(", "$", "objectIdentity", ...
Loads an ACL from the ACL provider, first by attempting to create, then finding if it already exists @param mixed $entity @return MutableAclInterface
[ "Loads", "an", "ACL", "from", "the", "ACL", "provider", "first", "by", "attempting", "to", "create", "then", "finding", "if", "it", "already", "exists" ]
a4382d158bf3d4007c1944aa38765cb04d1f560d
https://github.com/Problematic/ProblematicAclManagerBundle/blob/a4382d158bf3d4007c1944aa38765cb04d1f560d/Domain/AbstractAclManager.php#L71-L81
train
webeweb/core-library
src/Network/FTP/FTPClient.php
FTPClient.connect
public function connect($timeout = 90) { $host = $this->getAuthenticator()->getHost(); $port = $this->getAuthenticator()->getPort(); $this->setConnection(@ftp_connect($host, $port, $timeout)); if (false === $this->getConnection()) { throw $this->newFTPException("connection failed"); } return $this; }
php
public function connect($timeout = 90) { $host = $this->getAuthenticator()->getHost(); $port = $this->getAuthenticator()->getPort(); $this->setConnection(@ftp_connect($host, $port, $timeout)); if (false === $this->getConnection()) { throw $this->newFTPException("connection failed"); } return $this; }
[ "public", "function", "connect", "(", "$", "timeout", "=", "90", ")", "{", "$", "host", "=", "$", "this", "->", "getAuthenticator", "(", ")", "->", "getHost", "(", ")", ";", "$", "port", "=", "$", "this", "->", "getAuthenticator", "(", ")", "->", "...
Opens this FTP connection. @param int $timeout The timeout. @return FTPClient Returns this FTP client. @throws FTPException Throws a FTP exception if an I/O error occurs.
[ "Opens", "this", "FTP", "connection", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/FTP/FTPClient.php#L58-L66
train
webeweb/core-library
src/Network/FTP/FTPClient.php
FTPClient.delete
public function delete($path) { if (false === @ftp_delete($this->getConnection(), $path)) { throw $this->newFTPException(sprintf("delete %s failed", $path)); } return $this; }
php
public function delete($path) { if (false === @ftp_delete($this->getConnection(), $path)) { throw $this->newFTPException(sprintf("delete %s failed", $path)); } return $this; }
[ "public", "function", "delete", "(", "$", "path", ")", "{", "if", "(", "false", "===", "@", "ftp_delete", "(", "$", "this", "->", "getConnection", "(", ")", ",", "$", "path", ")", ")", "{", "throw", "$", "this", "->", "newFTPException", "(", "sprintf...
Deletes a file on the FTP server. @param string $path The file to delete. @return FTPClient Returns this FTP client. @throws FTPException Throws a FTP exception if an I/O error occurs.
[ "Deletes", "a", "file", "on", "the", "FTP", "server", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/FTP/FTPClient.php#L75-L80
train
webeweb/core-library
src/Network/FTP/FTPClient.php
FTPClient.pasv
public function pasv($pasv) { if (false === @ftp_pasv($this->getConnection(), $pasv)) { throw $this->newFTPException(sprintf("pasv from %d to %d failed", !$pasv, $pasv)); } return $this; }
php
public function pasv($pasv) { if (false === @ftp_pasv($this->getConnection(), $pasv)) { throw $this->newFTPException(sprintf("pasv from %d to %d failed", !$pasv, $pasv)); } return $this; }
[ "public", "function", "pasv", "(", "$", "pasv", ")", "{", "if", "(", "false", "===", "@", "ftp_pasv", "(", "$", "this", "->", "getConnection", "(", ")", ",", "$", "pasv", ")", ")", "{", "throw", "$", "this", "->", "newFTPException", "(", "sprintf", ...
Tuns passive mode on or off. @param bool $pasv The passive mode. @return FTPClient Returns this FTP client. @throws FTPException Throws a FTP exception if an I/O error occurs.
[ "Tuns", "passive", "mode", "on", "or", "off", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/FTP/FTPClient.php#L104-L109
train
webeweb/core-library
src/Network/FTP/FTPClient.php
FTPClient.put
public function put($localFile, $remoteFile, $mode = FTP_IMAGE, $startPos = 0) { if (false === @ftp_put($this->getConnection(), $remoteFile, $localFile, $mode, $startPos)) { throw $this->newFTPException(sprintf("put %s into %s failed", $localFile, $remoteFile)); } return $this; }
php
public function put($localFile, $remoteFile, $mode = FTP_IMAGE, $startPos = 0) { if (false === @ftp_put($this->getConnection(), $remoteFile, $localFile, $mode, $startPos)) { throw $this->newFTPException(sprintf("put %s into %s failed", $localFile, $remoteFile)); } return $this; }
[ "public", "function", "put", "(", "$", "localFile", ",", "$", "remoteFile", ",", "$", "mode", "=", "FTP_IMAGE", ",", "$", "startPos", "=", "0", ")", "{", "if", "(", "false", "===", "@", "ftp_put", "(", "$", "this", "->", "getConnection", "(", ")", ...
Uploads a file to The FTP server. @param string $localFile The local file. @param string $remoteFile The remote file. @param int $mode The mode. @param int $startPos The start position. @return FTPClient Returns this FTP client. @throws FTPException Throws a FTP exception if an I/O error occurs.
[ "Uploads", "a", "file", "to", "The", "FTP", "server", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/Network/FTP/FTPClient.php#L121-L126
train
orchestral/notifier
src/Concerns/Illuminate.php
Illuminate.alwaysFrom
public function alwaysFrom(string $address, ?string $name = null): void { $this->getMailer()->alwaysFrom($address, $name); }
php
public function alwaysFrom(string $address, ?string $name = null): void { $this->getMailer()->alwaysFrom($address, $name); }
[ "public", "function", "alwaysFrom", "(", "string", "$", "address", ",", "?", "string", "$", "name", "=", "null", ")", ":", "void", "{", "$", "this", "->", "getMailer", "(", ")", "->", "alwaysFrom", "(", "$", "address", ",", "$", "name", ")", ";", "...
Set the global from address and name. @param string $address @param string|null $name @return void
[ "Set", "the", "global", "from", "address", "and", "name", "." ]
a0036f924c51ead67f3e339cd2688163876f3b59
https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Concerns/Illuminate.php#L45-L48
train
orchestral/notifier
src/Concerns/Illuminate.php
Illuminate.alwaysTo
public function alwaysTo(string $address, ?string $name = null): void { $this->getMailer()->alwaysTo($address, $name); }
php
public function alwaysTo(string $address, ?string $name = null): void { $this->getMailer()->alwaysTo($address, $name); }
[ "public", "function", "alwaysTo", "(", "string", "$", "address", ",", "?", "string", "$", "name", "=", "null", ")", ":", "void", "{", "$", "this", "->", "getMailer", "(", ")", "->", "alwaysTo", "(", "$", "address", ",", "$", "name", ")", ";", "}" ]
Set the global to address and name. @param string $address @param string|null $name @return void
[ "Set", "the", "global", "to", "address", "and", "name", "." ]
a0036f924c51ead67f3e339cd2688163876f3b59
https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Concerns/Illuminate.php#L58-L61
train
orchestral/notifier
src/Concerns/Illuminate.php
Illuminate.plain
public function plain(string $view, array $data, $callback): Receipt { return $this->send(['text' => $view], $data, $callback); }
php
public function plain(string $view, array $data, $callback): Receipt { return $this->send(['text' => $view], $data, $callback); }
[ "public", "function", "plain", "(", "string", "$", "view", ",", "array", "$", "data", ",", "$", "callback", ")", ":", "Receipt", "{", "return", "$", "this", "->", "send", "(", "[", "'text'", "=>", "$", "view", "]", ",", "$", "data", ",", "$", "ca...
Send a new message when only a plain part. @param string $view @param array $data @param mixed $callback @return \Orchestra\Contracts\Notification\Receipt
[ "Send", "a", "new", "message", "when", "only", "a", "plain", "part", "." ]
a0036f924c51ead67f3e339cd2688163876f3b59
https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Concerns/Illuminate.php#L85-L88
train
orchestral/notifier
src/Concerns/Illuminate.php
Illuminate.setQueue
public function setQueue(QueueContract $queue) { if ($this->mailer instanceof MailerContract) { $this->mailer->setQueue($queue); } $this->queue = $queue; return $this; }
php
public function setQueue(QueueContract $queue) { if ($this->mailer instanceof MailerContract) { $this->mailer->setQueue($queue); } $this->queue = $queue; return $this; }
[ "public", "function", "setQueue", "(", "QueueContract", "$", "queue", ")", "{", "if", "(", "$", "this", "->", "mailer", "instanceof", "MailerContract", ")", "{", "$", "this", "->", "mailer", "->", "setQueue", "(", "$", "queue", ")", ";", "}", "$", "thi...
Set the queue manager instance. @param \Illuminate\Contracts\Queue\Factory $queue @return $this
[ "Set", "the", "queue", "manager", "instance", "." ]
a0036f924c51ead67f3e339cd2688163876f3b59
https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Concerns/Illuminate.php#L145-L154
train
orchestral/notifier
src/Concerns/Illuminate.php
Illuminate.handleQueuedMessage
public function handleQueuedMessage(Job $job, $data) { $this->send($data['view'], $data['data'], $this->getQueuedCallable($data)); $job->delete(); }
php
public function handleQueuedMessage(Job $job, $data) { $this->send($data['view'], $data['data'], $this->getQueuedCallable($data)); $job->delete(); }
[ "public", "function", "handleQueuedMessage", "(", "Job", "$", "job", ",", "$", "data", ")", "{", "$", "this", "->", "send", "(", "$", "data", "[", "'view'", "]", ",", "$", "data", "[", "'data'", "]", ",", "$", "this", "->", "getQueuedCallable", "(", ...
Handle a queued e-mail message job. @param \Illuminate\Contracts\Queue\Job $job @param array $data @return void
[ "Handle", "a", "queued", "e", "-", "mail", "message", "job", "." ]
a0036f924c51ead67f3e339cd2688163876f3b59
https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/Concerns/Illuminate.php#L190-L195
train
shopgate/cart-integration-magento2-base
src/Helper/Config.php
Config.loadUndefinedConfigPaths
public function loadUndefinedConfigPaths() { $list = []; $collection = $this->coreConfig->getCollectionByPath(SgCoreInterface::PATH_UNDEFINED . '%'); /** @var \Magento\Framework\App\Config\Value $item */ foreach ($collection as $item) { $path = explode('/', $item->getPath()); $key = array_pop($path); $list[$key] = $item->getPath(); } return $list; }
php
public function loadUndefinedConfigPaths() { $list = []; $collection = $this->coreConfig->getCollectionByPath(SgCoreInterface::PATH_UNDEFINED . '%'); /** @var \Magento\Framework\App\Config\Value $item */ foreach ($collection as $item) { $path = explode('/', $item->getPath()); $key = array_pop($path); $list[$key] = $item->getPath(); } return $list; }
[ "public", "function", "loadUndefinedConfigPaths", "(", ")", "{", "$", "list", "=", "[", "]", ";", "$", "collection", "=", "$", "this", "->", "coreConfig", "->", "getCollectionByPath", "(", "SgCoreInterface", "::", "PATH_UNDEFINED", ".", "'%'", ")", ";", "/**...
Loads all core_config_data paths with "undefined" in them so that we can load up the configuration properly @return array $list - list of undefined keys and core_config_paths to them
[ "Loads", "all", "core_config_data", "paths", "with", "undefined", "in", "them", "so", "that", "we", "can", "load", "up", "the", "configuration", "properly" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Config.php#L56-L68
train
shopgate/cart-integration-magento2-base
src/Helper/Config.php
Config.getShopNumber
public function getShopNumber() { $shopNumber = $this->request->getParam('shop_number'); $item = $this->sgCoreConfig->getShopNumberCollection($shopNumber)->getFirstItem(); return $item->getData('value') ? $shopNumber : ''; }
php
public function getShopNumber() { $shopNumber = $this->request->getParam('shop_number'); $item = $this->sgCoreConfig->getShopNumberCollection($shopNumber)->getFirstItem(); return $item->getData('value') ? $shopNumber : ''; }
[ "public", "function", "getShopNumber", "(", ")", "{", "$", "shopNumber", "=", "$", "this", "->", "request", "->", "getParam", "(", "'shop_number'", ")", ";", "$", "item", "=", "$", "this", "->", "sgCoreConfig", "->", "getShopNumberCollection", "(", "$", "s...
The Gods will forever hate me for using request interface here @return string
[ "The", "Gods", "will", "forever", "hate", "me", "for", "using", "request", "interface", "here" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Config.php#L88-L94
train
orchestral/notifier
src/NotifierServiceProvider.php
NotifierServiceProvider.registerMailer
protected function registerMailer(): void { $this->app->singleton('orchestra.mail', function ($app) { $mailer = new Mailer($app, $transport = new TransportManager($app)); if ($app->bound('orchestra.platform.memory')) { $mailer->attach($memory = $app->make('orchestra.platform.memory')); $transport->setMemoryProvider($memory); } if ($app->bound('queue')) { $mailer->setQueue($app->make('queue')); } return $mailer; }); }
php
protected function registerMailer(): void { $this->app->singleton('orchestra.mail', function ($app) { $mailer = new Mailer($app, $transport = new TransportManager($app)); if ($app->bound('orchestra.platform.memory')) { $mailer->attach($memory = $app->make('orchestra.platform.memory')); $transport->setMemoryProvider($memory); } if ($app->bound('queue')) { $mailer->setQueue($app->make('queue')); } return $mailer; }); }
[ "protected", "function", "registerMailer", "(", ")", ":", "void", "{", "$", "this", "->", "app", "->", "singleton", "(", "'orchestra.mail'", ",", "function", "(", "$", "app", ")", "{", "$", "mailer", "=", "new", "Mailer", "(", "$", "app", ",", "$", "...
Register the service provider for mail. @return void
[ "Register", "the", "service", "provider", "for", "mail", "." ]
a0036f924c51ead67f3e339cd2688163876f3b59
https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/NotifierServiceProvider.php#L29-L45
train
orchestral/notifier
src/NotifierServiceProvider.php
NotifierServiceProvider.registerIlluminateMailerResolver
protected function registerIlluminateMailerResolver(): void { $this->app->afterResolving('mailer', function ($service) { $this->app->make('orchestra.mail')->configureIlluminateMailer($service); }); }
php
protected function registerIlluminateMailerResolver(): void { $this->app->afterResolving('mailer', function ($service) { $this->app->make('orchestra.mail')->configureIlluminateMailer($service); }); }
[ "protected", "function", "registerIlluminateMailerResolver", "(", ")", ":", "void", "{", "$", "this", "->", "app", "->", "afterResolving", "(", "'mailer'", ",", "function", "(", "$", "service", ")", "{", "$", "this", "->", "app", "->", "make", "(", "'orche...
Register the service provider for notifier. @return void
[ "Register", "the", "service", "provider", "for", "notifier", "." ]
a0036f924c51ead67f3e339cd2688163876f3b59
https://github.com/orchestral/notifier/blob/a0036f924c51ead67f3e339cd2688163876f3b59/src/NotifierServiceProvider.php#L64-L69
train
milesj/transit
src/Transit/Transporter/Aws/S3Transporter.php
S3Transporter.delete
public function delete($id) { $params = $this->parseUrl($id); try { $this->getClient()->deleteObject(array( 'Bucket' => $params['bucket'], 'Key' => $params['key'] )); } catch (S3Exception $e) { return false; } return true; }
php
public function delete($id) { $params = $this->parseUrl($id); try { $this->getClient()->deleteObject(array( 'Bucket' => $params['bucket'], 'Key' => $params['key'] )); } catch (S3Exception $e) { return false; } return true; }
[ "public", "function", "delete", "(", "$", "id", ")", "{", "$", "params", "=", "$", "this", "->", "parseUrl", "(", "$", "id", ")", ";", "try", "{", "$", "this", "->", "getClient", "(", ")", "->", "deleteObject", "(", "array", "(", "'Bucket'", "=>", ...
Delete a file from Amazon S3 by parsing a URL or using a direct key. @param string $id @return bool
[ "Delete", "a", "file", "from", "Amazon", "S3", "by", "parsing", "a", "URL", "or", "using", "a", "direct", "key", "." ]
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transporter/Aws/S3Transporter.php#L89-L102
train
milesj/transit
src/Transit/Transporter/Aws/S3Transporter.php
S3Transporter.parseUrl
public function parseUrl($url) { $region = $this->getConfig('region'); $bucket = $this->getConfig('bucket'); $key = $url; if (strpos($url, 'amazonaws.com') !== false) { // s3<region>.amazonaws.com/<bucket> if (preg_match('/^https?:\/\/s3(.+?)?\.amazonaws\.com\/(.+?)\/(.+?)$/i', $url, $matches)) { $region = $matches[1] ?: $region; $bucket = $matches[2]; $key = $matches[3]; // <bucket>.s3<region>.amazonaws.com } else if (preg_match('/^https?:\/\/(.+?)\.s3(.+?)?\.amazonaws\.com\/(.+?)$/i', $url, $matches)) { $bucket = $matches[1]; $region = $matches[2] ?: $region; $key = $matches[3]; } } return array( 'bucket' => $bucket, 'key' => trim($key, '/'), 'region' => trim($region, '-') ); }
php
public function parseUrl($url) { $region = $this->getConfig('region'); $bucket = $this->getConfig('bucket'); $key = $url; if (strpos($url, 'amazonaws.com') !== false) { // s3<region>.amazonaws.com/<bucket> if (preg_match('/^https?:\/\/s3(.+?)?\.amazonaws\.com\/(.+?)\/(.+?)$/i', $url, $matches)) { $region = $matches[1] ?: $region; $bucket = $matches[2]; $key = $matches[3]; // <bucket>.s3<region>.amazonaws.com } else if (preg_match('/^https?:\/\/(.+?)\.s3(.+?)?\.amazonaws\.com\/(.+?)$/i', $url, $matches)) { $bucket = $matches[1]; $region = $matches[2] ?: $region; $key = $matches[3]; } } return array( 'bucket' => $bucket, 'key' => trim($key, '/'), 'region' => trim($region, '-') ); }
[ "public", "function", "parseUrl", "(", "$", "url", ")", "{", "$", "region", "=", "$", "this", "->", "getConfig", "(", "'region'", ")", ";", "$", "bucket", "=", "$", "this", "->", "getConfig", "(", "'bucket'", ")", ";", "$", "key", "=", "$", "url", ...
Parse an S3 URL and extract the bucket and key. @param string $url @return array
[ "Parse", "an", "S3", "URL", "and", "extract", "the", "bucket", "and", "key", "." ]
2454f464e26cd1aa9c900c0535fceb731562c2e5
https://github.com/milesj/transit/blob/2454f464e26cd1aa9c900c0535fceb731562c2e5/src/Transit/Transporter/Aws/S3Transporter.php#L187-L213
train
cymapgt/UserCredential
lib/Multiotp/contrib/Stream.php
Net_SFTP_Stream.register
static function register($protocol = 'sftp') { if (in_array($protocol, stream_get_wrappers(), true)) { return false; } $class = function_exists('get_called_class') ? get_called_class() : __CLASS__; return stream_wrapper_register($protocol, $class); }
php
static function register($protocol = 'sftp') { if (in_array($protocol, stream_get_wrappers(), true)) { return false; } $class = function_exists('get_called_class') ? get_called_class() : __CLASS__; return stream_wrapper_register($protocol, $class); }
[ "static", "function", "register", "(", "$", "protocol", "=", "'sftp'", ")", "{", "if", "(", "in_array", "(", "$", "protocol", ",", "stream_get_wrappers", "(", ")", ",", "true", ")", ")", "{", "return", "false", ";", "}", "$", "class", "=", "function_ex...
Registers this class as a URL wrapper. @param string $protocol The wrapper name to be registered. @return bool True on success, false otherwise. @access public
[ "Registers", "this", "class", "as", "a", "URL", "wrapper", "." ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/lib/Multiotp/contrib/Stream.php#L135-L142
train
cymapgt/UserCredential
src/services/UserCredentialGoogleAuthLoginService.php
UserCredentialGoogleAuthLoginService.checkToken
protected function checkToken() { //instantiate MultiOtp Wrapper $multiOtpWrapper = new MultiotpWrapper(); //get the username $currentUserName = $this->getCurrentUsername(); //assert that username is set if (!(\strlen((string) $currentUserName))) { throw new UserCredentialException('Cannot validate a TOTP token when username is not set!', 2106); } //assert that the token exists $tokenExists = $multiOtpWrapper->CheckTokenExists($currentUserName); if (!($tokenExists)) { throw new UserCredentialException('The TOTP token for the current user does not exist', 2107); } //username mapped to their token name $multiOtpWrapper->setToken($currentUserName); //validate the Token $oneTimeToken = $this->getOneTimeToken(); $tokenCheckResult = $multiOtpWrapper->CheckToken($oneTimeToken); //The results are reversed //TODO: Add intepretation of MultiOtp return results here to enable exception handling if ($tokenCheckResult == 0) { return true; } else { return false; } }
php
protected function checkToken() { //instantiate MultiOtp Wrapper $multiOtpWrapper = new MultiotpWrapper(); //get the username $currentUserName = $this->getCurrentUsername(); //assert that username is set if (!(\strlen((string) $currentUserName))) { throw new UserCredentialException('Cannot validate a TOTP token when username is not set!', 2106); } //assert that the token exists $tokenExists = $multiOtpWrapper->CheckTokenExists($currentUserName); if (!($tokenExists)) { throw new UserCredentialException('The TOTP token for the current user does not exist', 2107); } //username mapped to their token name $multiOtpWrapper->setToken($currentUserName); //validate the Token $oneTimeToken = $this->getOneTimeToken(); $tokenCheckResult = $multiOtpWrapper->CheckToken($oneTimeToken); //The results are reversed //TODO: Add intepretation of MultiOtp return results here to enable exception handling if ($tokenCheckResult == 0) { return true; } else { return false; } }
[ "protected", "function", "checkToken", "(", ")", "{", "//instantiate MultiOtp Wrapper\r", "$", "multiOtpWrapper", "=", "new", "MultiotpWrapper", "(", ")", ";", "//get the username\r", "$", "currentUserName", "=", "$", "this", "->", "getCurrentUsername", "(", ")", ";...
Verify a user token if it exists as part of the multi factor login process Cyril Ogana <cogana@gmail.com> - 2016-07-05 @return boolean @throws UserCredentialException
[ "Verify", "a", "user", "token", "if", "it", "exists", "as", "part", "of", "the", "multi", "factor", "login", "process" ]
06fc4539bda4aecb8342e49b4326497eb38ea28e
https://github.com/cymapgt/UserCredential/blob/06fc4539bda4aecb8342e49b4326497eb38ea28e/src/services/UserCredentialGoogleAuthLoginService.php#L275-L308
train
shopgate/cart-integration-magento2-base
src/Helper/Regions.php
Regions.getIsoStateByMagentoRegion
public function getIsoStateByMagentoRegion(DataObject $address) { $map = $this->getIsoToMagentoMapping(); $sIsoCode = null; if ($address->getData('country_id') && $address->getData('region_code')) { $sIsoCode = $address->getData('country_id') . "-" . $address->getData('region_code'); } if (isset($map[$address->getData('country_id')])) { foreach ($map[$address->getData('country_id')] as $isoCode => $mageCode) { if ($mageCode === $address->getData('region_code')) { $sIsoCode = $address->getData('country_id') . "-" . $isoCode; break; } } } return $sIsoCode; }
php
public function getIsoStateByMagentoRegion(DataObject $address) { $map = $this->getIsoToMagentoMapping(); $sIsoCode = null; if ($address->getData('country_id') && $address->getData('region_code')) { $sIsoCode = $address->getData('country_id') . "-" . $address->getData('region_code'); } if (isset($map[$address->getData('country_id')])) { foreach ($map[$address->getData('country_id')] as $isoCode => $mageCode) { if ($mageCode === $address->getData('region_code')) { $sIsoCode = $address->getData('country_id') . "-" . $isoCode; break; } } } return $sIsoCode; }
[ "public", "function", "getIsoStateByMagentoRegion", "(", "DataObject", "$", "address", ")", "{", "$", "map", "=", "$", "this", "->", "getIsoToMagentoMapping", "(", ")", ";", "$", "sIsoCode", "=", "null", ";", "if", "(", "$", "address", "->", "getData", "("...
Return ISO-Code for Magento address @param DataObject $address @return null|string
[ "Return", "ISO", "-", "Code", "for", "Magento", "address" ]
e7f8dec935aa9b23cd5b434484bc45033e62d270
https://github.com/shopgate/cart-integration-magento2-base/blob/e7f8dec935aa9b23cd5b434484bc45033e62d270/src/Helper/Regions.php#L54-L73
train
SaftIng/Saft
src/Saft/Addition/EasyRdf/Data/SerializerEasyRdf.php
SerializerEasyRdf.serializeIteratorToStream
public function serializeIteratorToStream(StatementIterator $statements, $outputStream) { /* * check parameter $outputStream */ if (is_resource($outputStream)) { // use it as it is } elseif (is_string($outputStream)) { $outputStream = fopen($outputStream, 'w'); } else { throw new \Exception('Parameter $outputStream is neither a string nor resource.'); } $graph = new \EasyRdf_Graph(); // go through all statements foreach ($statements as $statement) { /* * Handle subject */ $stmtSubject = $statement->getSubject(); if ($stmtSubject->isNamed()) { $s = $stmtSubject->getUri(); } elseif ($stmtSubject->isBlank()) { $s = '_:'.$stmtSubject->getBlankId(); } else { throw new \Exception('Subject can either be a blank node or an URI.'); } /* * Handle predicate */ $stmtPredicate = $statement->getPredicate(); if ($stmtPredicate->isNamed()) { $p = $stmtPredicate->getUri(); } else { throw new \Exception('Predicate can only be an URI.'); } /* * Handle object */ $stmtObject = $statement->getObject(); if ($stmtObject->isNamed()) { $o = ['type' => 'uri', 'value' => $stmtObject->getUri()]; } elseif ($stmtObject->isBlank()) { $o = ['type' => 'bnode', 'value' => '_:'.$stmtObject->getBlankId()]; } elseif ($stmtObject->isLiteral()) { $o = [ 'type' => 'literal', 'value' => $stmtObject->getValue(), 'datatype' => $stmtObject->getDataType()->getUri(), ]; } else { throw new \Exception('Object can either be a blank node, an URI or literal.'); } $graph->add($s, $p, $o); } fwrite($outputStream, $graph->serialise($this->serialization).PHP_EOL); }
php
public function serializeIteratorToStream(StatementIterator $statements, $outputStream) { /* * check parameter $outputStream */ if (is_resource($outputStream)) { // use it as it is } elseif (is_string($outputStream)) { $outputStream = fopen($outputStream, 'w'); } else { throw new \Exception('Parameter $outputStream is neither a string nor resource.'); } $graph = new \EasyRdf_Graph(); // go through all statements foreach ($statements as $statement) { /* * Handle subject */ $stmtSubject = $statement->getSubject(); if ($stmtSubject->isNamed()) { $s = $stmtSubject->getUri(); } elseif ($stmtSubject->isBlank()) { $s = '_:'.$stmtSubject->getBlankId(); } else { throw new \Exception('Subject can either be a blank node or an URI.'); } /* * Handle predicate */ $stmtPredicate = $statement->getPredicate(); if ($stmtPredicate->isNamed()) { $p = $stmtPredicate->getUri(); } else { throw new \Exception('Predicate can only be an URI.'); } /* * Handle object */ $stmtObject = $statement->getObject(); if ($stmtObject->isNamed()) { $o = ['type' => 'uri', 'value' => $stmtObject->getUri()]; } elseif ($stmtObject->isBlank()) { $o = ['type' => 'bnode', 'value' => '_:'.$stmtObject->getBlankId()]; } elseif ($stmtObject->isLiteral()) { $o = [ 'type' => 'literal', 'value' => $stmtObject->getValue(), 'datatype' => $stmtObject->getDataType()->getUri(), ]; } else { throw new \Exception('Object can either be a blank node, an URI or literal.'); } $graph->add($s, $p, $o); } fwrite($outputStream, $graph->serialise($this->serialization).PHP_EOL); }
[ "public", "function", "serializeIteratorToStream", "(", "StatementIterator", "$", "statements", ",", "$", "outputStream", ")", "{", "/*\n * check parameter $outputStream\n */", "if", "(", "is_resource", "(", "$", "outputStream", ")", ")", "{", "// use it a...
Transforms the statements of a StatementIterator instance into a stream, a file for instance. @param StatementIterator $statements the StatementIterator containing all the Statements which should be serialized by the serializer @param string|resource $outputStream filename or file pointer to the stream to where the serialization should be written @throws \Exception if unknown serilaization was given
[ "Transforms", "the", "statements", "of", "a", "StatementIterator", "instance", "into", "a", "stream", "a", "file", "for", "instance", "." ]
ac2d9aed53da6ab3bb5ea05165644027df5248e8
https://github.com/SaftIng/Saft/blob/ac2d9aed53da6ab3bb5ea05165644027df5248e8/src/Saft/Addition/EasyRdf/Data/SerializerEasyRdf.php#L78-L139
train
BerliozFramework/Berlioz
src/OptionList.php
OptionList.set
public function set(string $name, $value, int $type = self::TYPE_LOCAL): OptionList { if ($type == self::TYPE_GLOBAL) { self::$globalOptions[$name] = $value; } else { $this->options[$name] = $value; } return $this; }
php
public function set(string $name, $value, int $type = self::TYPE_LOCAL): OptionList { if ($type == self::TYPE_GLOBAL) { self::$globalOptions[$name] = $value; } else { $this->options[$name] = $value; } return $this; }
[ "public", "function", "set", "(", "string", "$", "name", ",", "$", "value", ",", "int", "$", "type", "=", "self", "::", "TYPE_LOCAL", ")", ":", "OptionList", "{", "if", "(", "$", "type", "==", "self", "::", "TYPE_GLOBAL", ")", "{", "self", "::", "$...
Set option. @param string $name Option name @param mixed $value Option value @param int $type Type of option (TYPE_LOCAL|TYPE_GLOBAL) @return static
[ "Set", "option", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/OptionList.php#L90-L99
train
BerliozFramework/Berlioz
src/OptionList.php
OptionList.isset
public function isset(string $name, int $type = null): bool { if (is_null($type)) { return array_key_exists($name, $this->options) || array_key_exists($name, self::$globalOptions); } else { if ($type == self::TYPE_GLOBAL) { return array_key_exists($name, self::$globalOptions); } else { return array_key_exists($name, $this->options); } } }
php
public function isset(string $name, int $type = null): bool { if (is_null($type)) { return array_key_exists($name, $this->options) || array_key_exists($name, self::$globalOptions); } else { if ($type == self::TYPE_GLOBAL) { return array_key_exists($name, self::$globalOptions); } else { return array_key_exists($name, $this->options); } } }
[ "public", "function", "isset", "(", "string", "$", "name", ",", "int", "$", "type", "=", "null", ")", ":", "bool", "{", "if", "(", "is_null", "(", "$", "type", ")", ")", "{", "return", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", ...
Know if option exists. @param string $name Option name @param null|int $type Type of option (TYPE_LOCAL|TYPE_GLOBAL) @return bool
[ "Know", "if", "option", "exists", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/OptionList.php#L128-L139
train
BerliozFramework/Berlioz
src/OptionList.php
OptionList.getGlobal
public static function getGlobal(string $name) { if (isset(self::$globalOptions[$name])) { return self::$globalOptions[$name]; } else { return null; } }
php
public static function getGlobal(string $name) { if (isset(self::$globalOptions[$name])) { return self::$globalOptions[$name]; } else { return null; } }
[ "public", "static", "function", "getGlobal", "(", "string", "$", "name", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "globalOptions", "[", "$", "name", "]", ")", ")", "{", "return", "self", "::", "$", "globalOptions", "[", "$", "name", "]",...
Get global option value. @param string $name Option name @return mixed
[ "Get", "global", "option", "value", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/OptionList.php#L148-L155
train
BerliozFramework/Berlioz
src/OptionList.php
OptionList.is_null
public function is_null(string $name, int $type = null): bool { if (isset(self::$globalOptions[$name]) && (is_null($type) || $type == self::TYPE_GLOBAL)) { return is_null(self::$globalOptions[$name]); } else { if (isset($this->options[$name]) && (is_null($type) || $type == self::TYPE_LOCAL)) { return is_null($this->options[$name]); } else { return true; } } }
php
public function is_null(string $name, int $type = null): bool { if (isset(self::$globalOptions[$name]) && (is_null($type) || $type == self::TYPE_GLOBAL)) { return is_null(self::$globalOptions[$name]); } else { if (isset($this->options[$name]) && (is_null($type) || $type == self::TYPE_LOCAL)) { return is_null($this->options[$name]); } else { return true; } } }
[ "public", "function", "is_null", "(", "string", "$", "name", ",", "int", "$", "type", "=", "null", ")", ":", "bool", "{", "if", "(", "isset", "(", "self", "::", "$", "globalOptions", "[", "$", "name", "]", ")", "&&", "(", "is_null", "(", "$", "ty...
Know if value of an option is null. @param string $name Option name @param null|int $type Type of option (TYPE_LOCAL|TYPE_GLOBAL) @return bool
[ "Know", "if", "value", "of", "an", "option", "is", "null", "." ]
cd5f28f93fdff254b9a123a30dad275e5bbfd78c
https://github.com/BerliozFramework/Berlioz/blob/cd5f28f93fdff254b9a123a30dad275e5bbfd78c/src/OptionList.php#L198-L209
train
Team-Tea-Time/laravel-filer
src/LocalFile.php
LocalFile.getByIdentifier
public static function getByIdentifier($id) { $file = config('filer.hash_routes') ? static::whereHash($id)->first() : static::find($id); if (!$file) { throw (new ModelNotFoundException)->setModel(static::class); } return $file; }
php
public static function getByIdentifier($id) { $file = config('filer.hash_routes') ? static::whereHash($id)->first() : static::find($id); if (!$file) { throw (new ModelNotFoundException)->setModel(static::class); } return $file; }
[ "public", "static", "function", "getByIdentifier", "(", "$", "id", ")", "{", "$", "file", "=", "config", "(", "'filer.hash_routes'", ")", "?", "static", "::", "whereHash", "(", "$", "id", ")", "->", "first", "(", ")", ":", "static", "::", "find", "(", ...
Get a model instance using a unique identifier according to filer.hash_routes. @param integer $id @return LocalFIle
[ "Get", "a", "model", "instance", "using", "a", "unique", "identifier", "according", "to", "filer", ".", "hash_routes", "." ]
e69fae1bc99a317097e997b3d029ecc9be0a0b4b
https://github.com/Team-Tea-Time/laravel-filer/blob/e69fae1bc99a317097e997b3d029ecc9be0a0b4b/src/LocalFile.php#L147-L156
train
webeweb/core-library
src/FileSystem/FileHelper.php
FileHelper.appendTo
public static function appendTo($src, $dest, $newline = false) { // Open the destination. $reader = @fopen($src, "r"); if (false === $reader) { throw new FileNotFoundException($src); } // Open the destination. $writer = @fopen($dest, "a"); if (false === $writer) { throw new IOException(sprintf("Failed to open \"%s\"", $dest)); } // Append the source into destination. if (false === @file_put_contents($dest, $reader, FILE_APPEND)) { throw new IOException(sprintf("Failed to append \"%s\" into \"%s\"", $src, $dest)); } // Append a new line. if (true === $newline && false === @file_put_contents($dest, "\n", FILE_APPEND)) { throw new IOException(sprintf("Failed to append \"%s\" into \"%s\"", $src, $dest)); } // Close the files. if (false === @fclose($reader)) { throw new IOException(sprintf("Failed to close \"%s\"", $src)); } if (false === @fclose($writer)) { throw new IOException(sprintf("Failed to close \"%s\"", $dest)); } }
php
public static function appendTo($src, $dest, $newline = false) { // Open the destination. $reader = @fopen($src, "r"); if (false === $reader) { throw new FileNotFoundException($src); } // Open the destination. $writer = @fopen($dest, "a"); if (false === $writer) { throw new IOException(sprintf("Failed to open \"%s\"", $dest)); } // Append the source into destination. if (false === @file_put_contents($dest, $reader, FILE_APPEND)) { throw new IOException(sprintf("Failed to append \"%s\" into \"%s\"", $src, $dest)); } // Append a new line. if (true === $newline && false === @file_put_contents($dest, "\n", FILE_APPEND)) { throw new IOException(sprintf("Failed to append \"%s\" into \"%s\"", $src, $dest)); } // Close the files. if (false === @fclose($reader)) { throw new IOException(sprintf("Failed to close \"%s\"", $src)); } if (false === @fclose($writer)) { throw new IOException(sprintf("Failed to close \"%s\"", $dest)); } }
[ "public", "static", "function", "appendTo", "(", "$", "src", ",", "$", "dest", ",", "$", "newline", "=", "false", ")", "{", "// Open the destination.", "$", "reader", "=", "@", "fopen", "(", "$", "src", ",", "\"r\"", ")", ";", "if", "(", "false", "==...
Append to. @param string $src The source filename. @param string $dest The destination filename. @param bool $newline New line ? @return void @throws IOException Throws an I/O exception if an error occurs.
[ "Append", "to", "." ]
bd454a47f6a28fbf6029635ee77ed01c9995cf60
https://github.com/webeweb/core-library/blob/bd454a47f6a28fbf6029635ee77ed01c9995cf60/src/FileSystem/FileHelper.php#L38-L69
train