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
tom--/yii2-dynamic-ar
DynamicActiveQuery.php
DynamicActiveQuery.createCommand
public function createCommand($db = null) { /** @var DynamicActiveRecord $modelClass */ $modelClass = $this->modelClass; if ($db === null) { $db = $modelClass::getDb(); } if ($this->sql === null) { list ($sql, $params) = $db->getQueryBuilder()->build($this); } else { $sql = $this->sql; $params = $this->params; } $dynamicColumn = $modelClass::dynamicColumn(); $callback = function ($matches) use (&$params, $dynamicColumn) { $type = !empty($matches[3]) ? $matches[3] : 'CHAR'; $sql = $dynamicColumn; $parts = explode('.', $matches[2]); $lastPart = array_pop($parts); foreach ($parts as $column) { $placeholder = DynamicActiveRecord::placeholder(); $params[$placeholder] = $column; $sql = "COLUMN_GET($sql, $placeholder AS BINARY)"; } $placeholder = DynamicActiveRecord::placeholder(); $params[$placeholder] = $lastPart; $sql = "COLUMN_GET($sql, $placeholder AS $type)"; return $sql; }; $pattern = <<<'REGEXP' % (`?) \(! \s*? ( [a-z_\x7f-\xff][a-z0-9_\x7f-\xff]* (?: \. [^.|\s]+)* ) (?: \| (binary (?:\(\d+\))? | char (?:\(\d+\))? | time (?:\(\d+\))? | datetime (?:\(\d+\))? | date | decimal (?:\(\d\d?(?:,\d\d?)?\))? | double (?:\(\d\d?,\d\d?\))? | int(eger)? | (?:un)? signed (?:\s+int(eger)?)?) )? \s*? !\) \1 %ix REGEXP; $sql = preg_replace_callback($pattern, $callback, $sql); return $db->createCommand($sql, $params); }
php
public function createCommand($db = null) { /** @var DynamicActiveRecord $modelClass */ $modelClass = $this->modelClass; if ($db === null) { $db = $modelClass::getDb(); } if ($this->sql === null) { list ($sql, $params) = $db->getQueryBuilder()->build($this); } else { $sql = $this->sql; $params = $this->params; } $dynamicColumn = $modelClass::dynamicColumn(); $callback = function ($matches) use (&$params, $dynamicColumn) { $type = !empty($matches[3]) ? $matches[3] : 'CHAR'; $sql = $dynamicColumn; $parts = explode('.', $matches[2]); $lastPart = array_pop($parts); foreach ($parts as $column) { $placeholder = DynamicActiveRecord::placeholder(); $params[$placeholder] = $column; $sql = "COLUMN_GET($sql, $placeholder AS BINARY)"; } $placeholder = DynamicActiveRecord::placeholder(); $params[$placeholder] = $lastPart; $sql = "COLUMN_GET($sql, $placeholder AS $type)"; return $sql; }; $pattern = <<<'REGEXP' % (`?) \(! \s*? ( [a-z_\x7f-\xff][a-z0-9_\x7f-\xff]* (?: \. [^.|\s]+)* ) (?: \| (binary (?:\(\d+\))? | char (?:\(\d+\))? | time (?:\(\d+\))? | datetime (?:\(\d+\))? | date | decimal (?:\(\d\d?(?:,\d\d?)?\))? | double (?:\(\d\d?,\d\d?\))? | int(eger)? | (?:un)? signed (?:\s+int(eger)?)?) )? \s*? !\) \1 %ix REGEXP; $sql = preg_replace_callback($pattern, $callback, $sql); return $db->createCommand($sql, $params); }
[ "public", "function", "createCommand", "(", "$", "db", "=", "null", ")", "{", "/** @var DynamicActiveRecord $modelClass */", "$", "modelClass", "=", "$", "this", "->", "modelClass", ";", "if", "(", "$", "db", "===", "null", ")", "{", "$", "db", "=", "$", "modelClass", "::", "getDb", "(", ")", ";", "}", "if", "(", "$", "this", "->", "sql", "===", "null", ")", "{", "list", "(", "$", "sql", ",", "$", "params", ")", "=", "$", "db", "->", "getQueryBuilder", "(", ")", "->", "build", "(", "$", "this", ")", ";", "}", "else", "{", "$", "sql", "=", "$", "this", "->", "sql", ";", "$", "params", "=", "$", "this", "->", "params", ";", "}", "$", "dynamicColumn", "=", "$", "modelClass", "::", "dynamicColumn", "(", ")", ";", "$", "callback", "=", "function", "(", "$", "matches", ")", "use", "(", "&", "$", "params", ",", "$", "dynamicColumn", ")", "{", "$", "type", "=", "!", "empty", "(", "$", "matches", "[", "3", "]", ")", "?", "$", "matches", "[", "3", "]", ":", "'CHAR'", ";", "$", "sql", "=", "$", "dynamicColumn", ";", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "matches", "[", "2", "]", ")", ";", "$", "lastPart", "=", "array_pop", "(", "$", "parts", ")", ";", "foreach", "(", "$", "parts", "as", "$", "column", ")", "{", "$", "placeholder", "=", "DynamicActiveRecord", "::", "placeholder", "(", ")", ";", "$", "params", "[", "$", "placeholder", "]", "=", "$", "column", ";", "$", "sql", "=", "\"COLUMN_GET($sql, $placeholder AS BINARY)\"", ";", "}", "$", "placeholder", "=", "DynamicActiveRecord", "::", "placeholder", "(", ")", ";", "$", "params", "[", "$", "placeholder", "]", "=", "$", "lastPart", ";", "$", "sql", "=", "\"COLUMN_GET($sql, $placeholder AS $type)\"", ";", "return", "$", "sql", ";", "}", ";", "$", "pattern", "=", " <<<'REGEXP'\n % (`?) \\(! \\s*?\n ( [a-z_\\x7f-\\xff][a-z0-9_\\x7f-\\xff]* (?: \\. [^.|\\s]+)* )\n (?: \\| (binary (?:\\(\\d+\\))? | char (?:\\(\\d+\\))? | time (?:\\(\\d+\\))? | datetime (?:\\(\\d+\\))? | date\n | decimal (?:\\(\\d\\d?(?:,\\d\\d?)?\\))? | double (?:\\(\\d\\d?,\\d\\d?\\))?\n | int(eger)? | (?:un)? signed (?:\\s+int(eger)?)?) )?\n \\s*? !\\) \\1 %ix\nREGEXP", ";", "$", "sql", "=", "preg_replace_callback", "(", "$", "pattern", ",", "$", "callback", ",", "$", "sql", ")", ";", "return", "$", "db", "->", "createCommand", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Generate DB command from ActiveQuery with Maria-specific SQL for dynamic columns. User of DynamicActiveQuery should not normally need to use this method. #### History This implementation is the best I could manage. A dynamic attribute name can appear anywhere that a schema attribute name could appear (select, join, where, ...). It needs to be converted to the Maria SQL using COLUMN_CREATE('name', value, …) for accessing dynamic columns. Because SQL is statically-typed and there is no schema to refer to for dynamic attributes, the accessor SQL must specify the the dyn-col's type, e.g. ```sql WHERE COLUMN_GET(details, 'color' AS CHAR) = 'black' ``` In which details is the blob column containing all the dynamic columns, 'color' is the name of a dynamic column that may or may not appear in any given table record, and CHAR means the value should be cast to CHAR before it is compared with 'black'. `COLUMN_GET(details, 'color' AS CHAR)` is the "accessor SQL". So I faced two problems: 1. How to identify a dynamic attribute name in an ActiveQuery? 2. How to choose the type to which it should be cast in the SQL? The design prociple of DynamicAR is "an attribute that isn't an instance variable, a column and doesn't have a magic get-/setter is assumed to be a dynamic attribute". So, in order to infer from the properties of an AQ instance the attribute names that need to be converted to dynamic column accessor SQL, I need to go through the AQ to identify all the column names and remove those in the schema. But I don't know how to identify column names in an AQ instance. Even if I did, there's problem 2. The only way I can imagine to infer datatype from an AQ instance is to look at the context. If the attribute is compared with a bound parameter, that's a clue. If it is being used in an SQL function, e.g. CONCAT(), or being compared with a schema column, that suggests something. But if it is on its own in a SELECT then I am stuck. Also stuck if it is compared with another dynamic attribute. This seems fundamentally intractible. So I decided that the user needs to help DynamicActiveQuery by distinguishing the names of dynamic attributes and by explicitly specifying the type. The format for this: (!name|type!) Omitting type implies the default type: CHAR. Children of dynamic attributes, i.e. array elements, are separated from parents with `.` (period), e.g. `(!address.country|CHAR!)`. (Spaces are not alowed around the `|`.) So a user can do: $blueShirts = Product::find() ->where(['category' => Product::SHIRT, '(!color!)' => 'blue']) ->all(); $cheapShirts = Product::find() ->select( ['sale' => 'MAX((!cost|decimal(6,2)!), 0.75 * (!price.wholesale.12|decimal(6,2)!))'] ) ->where(['category' => Product::SHIRT]) ->andWhere('(!price.retail.unit|decimal(6,2)!) < 20.00') ->all(); The implementation is like db\Connection's quoting of [[string]] and {{string}}. Once the full SQL string is ready, `preg_repalce()` it. The regex pattern is a bit complex and the replacement callback isn't pretty either. Is there a better way to add to `$params` in the callback than this? And for the parameter placeholder counter `$i`? @param null|\yii\db\Connection $db The database connection @return \yii\db\Command the modified SQL statement
[ "Generate", "DB", "command", "from", "ActiveQuery", "with", "Maria", "-", "specific", "SQL", "for", "dynamic", "columns", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveQuery.php#L196-L240
train
tom--/yii2-dynamic-ar
DynamicActiveQuery.php
DynamicActiveQuery.getDotNotatedValue
protected function getDotNotatedValue($array, $attribute) { $pieces = explode('.', $attribute); foreach ($pieces as $piece) { if (!is_array($array) || !array_key_exists($piece, $array)) { return null; } $array = $array[$piece]; } return $array; }
php
protected function getDotNotatedValue($array, $attribute) { $pieces = explode('.', $attribute); foreach ($pieces as $piece) { if (!is_array($array) || !array_key_exists($piece, $array)) { return null; } $array = $array[$piece]; } return $array; }
[ "protected", "function", "getDotNotatedValue", "(", "$", "array", ",", "$", "attribute", ")", "{", "$", "pieces", "=", "explode", "(", "'.'", ",", "$", "attribute", ")", ";", "foreach", "(", "$", "pieces", "as", "$", "piece", ")", "{", "if", "(", "!", "is_array", "(", "$", "array", ")", "||", "!", "array_key_exists", "(", "$", "piece", ",", "$", "array", ")", ")", "{", "return", "null", ";", "}", "$", "array", "=", "$", "array", "[", "$", "piece", "]", ";", "}", "return", "$", "array", ";", "}" ]
Returns the value of the element in an array refereced by a dot-notated attribute name. @param array $array an array of attributes and values, possibly nested @param string $attribute the attribute name in dotted notation @return mixed|null the element in $array referenced by $attribute or null if no such element exists
[ "Returns", "the", "value", "of", "the", "element", "in", "an", "array", "refereced", "by", "a", "dot", "-", "notated", "attribute", "name", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveQuery.php#L251-L262
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.getAttribute
public function getAttribute($name) { try { return parent::__get($name); } catch (UnknownPropertyException $ignore) { } $path = explode('.', $name); $ref = &$this->_dynamicAttributes; foreach ($path as $key) { if (!isset($ref[$key])) { return null; } $ref = &$ref[$key]; } return $ref; }
php
public function getAttribute($name) { try { return parent::__get($name); } catch (UnknownPropertyException $ignore) { } $path = explode('.', $name); $ref = &$this->_dynamicAttributes; foreach ($path as $key) { if (!isset($ref[$key])) { return null; } $ref = &$ref[$key]; } return $ref; }
[ "public", "function", "getAttribute", "(", "$", "name", ")", "{", "try", "{", "return", "parent", "::", "__get", "(", "$", "name", ")", ";", "}", "catch", "(", "UnknownPropertyException", "$", "ignore", ")", "{", "}", "$", "path", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "ref", "=", "&", "$", "this", "->", "_dynamicAttributes", ";", "foreach", "(", "$", "path", "as", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "ref", "[", "$", "key", "]", ")", ")", "{", "return", "null", ";", "}", "$", "ref", "=", "&", "$", "ref", "[", "$", "key", "]", ";", "}", "return", "$", "ref", ";", "}" ]
Returns a model attribute value. @param string $name attribute name, use dotted notation for structured attributes. @return mixed|null the attribute value or null if the attribute does not exist
[ "Returns", "a", "model", "attribute", "value", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L121-L139
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.setAttribute
public function setAttribute($name, $value) { try { parent::__set($name, $value); return; } catch (UnknownPropertyException $ignore) { } $path = explode('.', $name); $ref = &$this->_dynamicAttributes; // Walk forwards through $path to find the deepest key already set. do { $key = $path[0]; if (isset($ref[$key])) { $ref = &$ref[$key]; array_shift($path); } else { break; } } while ($path); // If the whole path already existed then we can just set it. if (!$path) { $ref = $value; return; } // There is remaining path so we have to set a new leaf with the first // part of the remaining path as key. But first, if there is any path // beyond that then we need build an array to set as the new leaf value. while (count($path) > 1) { $key = array_pop($path); $value = [$key => $value]; } $ref[$path[0]] = $value; }
php
public function setAttribute($name, $value) { try { parent::__set($name, $value); return; } catch (UnknownPropertyException $ignore) { } $path = explode('.', $name); $ref = &$this->_dynamicAttributes; // Walk forwards through $path to find the deepest key already set. do { $key = $path[0]; if (isset($ref[$key])) { $ref = &$ref[$key]; array_shift($path); } else { break; } } while ($path); // If the whole path already existed then we can just set it. if (!$path) { $ref = $value; return; } // There is remaining path so we have to set a new leaf with the first // part of the remaining path as key. But first, if there is any path // beyond that then we need build an array to set as the new leaf value. while (count($path) > 1) { $key = array_pop($path); $value = [$key => $value]; } $ref[$path[0]] = $value; }
[ "public", "function", "setAttribute", "(", "$", "name", ",", "$", "value", ")", "{", "try", "{", "parent", "::", "__set", "(", "$", "name", ",", "$", "value", ")", ";", "return", ";", "}", "catch", "(", "UnknownPropertyException", "$", "ignore", ")", "{", "}", "$", "path", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "ref", "=", "&", "$", "this", "->", "_dynamicAttributes", ";", "// Walk forwards through $path to find the deepest key already set.", "do", "{", "$", "key", "=", "$", "path", "[", "0", "]", ";", "if", "(", "isset", "(", "$", "ref", "[", "$", "key", "]", ")", ")", "{", "$", "ref", "=", "&", "$", "ref", "[", "$", "key", "]", ";", "array_shift", "(", "$", "path", ")", ";", "}", "else", "{", "break", ";", "}", "}", "while", "(", "$", "path", ")", ";", "// If the whole path already existed then we can just set it.", "if", "(", "!", "$", "path", ")", "{", "$", "ref", "=", "$", "value", ";", "return", ";", "}", "// There is remaining path so we have to set a new leaf with the first", "// part of the remaining path as key. But first, if there is any path", "// beyond that then we need build an array to set as the new leaf value.", "while", "(", "count", "(", "$", "path", ")", ">", "1", ")", "{", "$", "key", "=", "array_pop", "(", "$", "path", ")", ";", "$", "value", "=", "[", "$", "key", "=>", "$", "value", "]", ";", "}", "$", "ref", "[", "$", "path", "[", "0", "]", "]", "=", "$", "value", ";", "}" ]
Sets a model attribute. @param string $name attribute name, use dotted notation for structured attributes. @param mixed $value the attribute value. A value of null effectively unsets the attribute.
[ "Sets", "a", "model", "attribute", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L147-L185
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.issetAttribute
public function issetAttribute($name) { try { if (parent::__get($name) !== null) { return true; } } catch (Exception $ignore) { } $path = explode('.', $name); $ref = &$this->_dynamicAttributes; foreach ($path as $key) { if (!isset($ref[$key])) { return false; } $ref = &$ref[$key]; } return true; }
php
public function issetAttribute($name) { try { if (parent::__get($name) !== null) { return true; } } catch (Exception $ignore) { } $path = explode('.', $name); $ref = &$this->_dynamicAttributes; foreach ($path as $key) { if (!isset($ref[$key])) { return false; } $ref = &$ref[$key]; } return true; }
[ "public", "function", "issetAttribute", "(", "$", "name", ")", "{", "try", "{", "if", "(", "parent", "::", "__get", "(", "$", "name", ")", "!==", "null", ")", "{", "return", "true", ";", "}", "}", "catch", "(", "Exception", "$", "ignore", ")", "{", "}", "$", "path", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "ref", "=", "&", "$", "this", "->", "_dynamicAttributes", ";", "foreach", "(", "$", "path", "as", "$", "key", ")", "{", "if", "(", "!", "isset", "(", "$", "ref", "[", "$", "key", "]", ")", ")", "{", "return", "false", ";", "}", "$", "ref", "=", "&", "$", "ref", "[", "$", "key", "]", ";", "}", "return", "true", ";", "}" ]
Returns if a model attribute is set. @param string $name attribute name, use dotted notation for structured attributes. @return bool true if the attribute is set
[ "Returns", "if", "a", "model", "attribute", "is", "set", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L194-L214
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.unsetAttribute
public function unsetAttribute($name) { try { parent::__unset($name); } catch (\Exception $ignore) { } if ($this->issetAttribute($name)) { $this->setAttribute($name, null); } }
php
public function unsetAttribute($name) { try { parent::__unset($name); } catch (\Exception $ignore) { } if ($this->issetAttribute($name)) { $this->setAttribute($name, null); } }
[ "public", "function", "unsetAttribute", "(", "$", "name", ")", "{", "try", "{", "parent", "::", "__unset", "(", "$", "name", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "ignore", ")", "{", "}", "if", "(", "$", "this", "->", "issetAttribute", "(", "$", "name", ")", ")", "{", "$", "this", "->", "setAttribute", "(", "$", "name", ",", "null", ")", ";", "}", "}" ]
Unset a model attribute. @param string $name attribute name, use dotted notation for structured attributes.
[ "Unset", "a", "model", "attribute", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L221-L231
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.dotKeyValues
protected static function dotKeyValues($prefix, $array) { $fields = []; foreach ($array as $key => $value) { if (is_string($key)) { $newPos = $prefix . '.' . $key; if (is_array($value)) { $fields = array_merge($fields, static::dotKeyValues($newPos, $value)); } else { $fields[$newPos] = $value; } } } return $fields; }
php
protected static function dotKeyValues($prefix, $array) { $fields = []; foreach ($array as $key => $value) { if (is_string($key)) { $newPos = $prefix . '.' . $key; if (is_array($value)) { $fields = array_merge($fields, static::dotKeyValues($newPos, $value)); } else { $fields[$newPos] = $value; } } } return $fields; }
[ "protected", "static", "function", "dotKeyValues", "(", "$", "prefix", ",", "$", "array", ")", "{", "$", "fields", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "key", ")", ")", "{", "$", "newPos", "=", "$", "prefix", ".", "'.'", ".", "$", "key", ";", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "fields", "=", "array_merge", "(", "$", "fields", ",", "static", "::", "dotKeyValues", "(", "$", "newPos", ",", "$", "value", ")", ")", ";", "}", "else", "{", "$", "fields", "[", "$", "newPos", "]", "=", "$", "value", ";", "}", "}", "}", "return", "$", "fields", ";", "}" ]
Convert a nested array to a map of dot-notation keys to values. @param string $prefix Prefix returned array keys with this string @param array $array Nested array of attributeName => value pairs @return array Map of keys in dotted notation to corresponding values
[ "Convert", "a", "nested", "array", "to", "a", "map", "of", "dot", "-", "notation", "keys", "to", "values", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L251-L266
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.dotAttributeNames
public function dotAttributeNames() { return array_merge( array_values(parent::fields()), array_keys(static::dotKeyValues(static::dynamicColumn(), $this->_dynamicAttributes)) ); }
php
public function dotAttributeNames() { return array_merge( array_values(parent::fields()), array_keys(static::dotKeyValues(static::dynamicColumn(), $this->_dynamicAttributes)) ); }
[ "public", "function", "dotAttributeNames", "(", ")", "{", "return", "array_merge", "(", "array_values", "(", "parent", "::", "fields", "(", ")", ")", ",", "array_keys", "(", "static", "::", "dotKeyValues", "(", "static", "::", "dynamicColumn", "(", ")", ",", "$", "this", "->", "_dynamicAttributes", ")", ")", ")", ";", "}" ]
Return a list of all model attribute names recursing structured dynamic attributes. @return array an array of all attribute names in dotted notation @throws Exception
[ "Return", "a", "list", "of", "all", "model", "attribute", "names", "recursing", "structured", "dynamic", "attributes", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L274-L280
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.columnExpression
public static function columnExpression($name, $type = 'char') { $sql = '[[' . static::dynamicColumn() . ']]'; $parts = explode('.', $name); $lastPart = array_pop($parts); foreach ($parts as $column) { $sql = "COLUMN_GET($sql, '$column' AS BINARY)"; } $sql = "COLUMN_GET($sql, '$lastPart' AS $type)"; return $sql; }
php
public static function columnExpression($name, $type = 'char') { $sql = '[[' . static::dynamicColumn() . ']]'; $parts = explode('.', $name); $lastPart = array_pop($parts); foreach ($parts as $column) { $sql = "COLUMN_GET($sql, '$column' AS BINARY)"; } $sql = "COLUMN_GET($sql, '$lastPart' AS $type)"; return $sql; }
[ "public", "static", "function", "columnExpression", "(", "$", "name", ",", "$", "type", "=", "'char'", ")", "{", "$", "sql", "=", "'[['", ".", "static", "::", "dynamicColumn", "(", ")", ".", "']]'", ";", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "name", ")", ";", "$", "lastPart", "=", "array_pop", "(", "$", "parts", ")", ";", "foreach", "(", "$", "parts", "as", "$", "column", ")", "{", "$", "sql", "=", "\"COLUMN_GET($sql, '$column' AS BINARY)\"", ";", "}", "$", "sql", "=", "\"COLUMN_GET($sql, '$lastPart' AS $type)\"", ";", "return", "$", "sql", ";", "}" ]
Generate an SQL expression referring to the given dynamic column. @param string $name Attribute name @param string $type SQL datatype type @return string a Maria COLUMN_GET expression
[ "Generate", "an", "SQL", "expression", "referring", "to", "the", "given", "dynamic", "column", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L304-L315
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.encodeForMaria
public static function encodeForMaria($value) { return is_string($value) && (!mb_check_encoding($value, 'UTF-8') || strpos($value, self::DATA_URI_PREFIX) === 0) ? self::DATA_URI_PREFIX . base64_encode($value) : $value; }
php
public static function encodeForMaria($value) { return is_string($value) && (!mb_check_encoding($value, 'UTF-8') || strpos($value, self::DATA_URI_PREFIX) === 0) ? self::DATA_URI_PREFIX . base64_encode($value) : $value; }
[ "public", "static", "function", "encodeForMaria", "(", "$", "value", ")", "{", "return", "is_string", "(", "$", "value", ")", "&&", "(", "!", "mb_check_encoding", "(", "$", "value", ",", "'UTF-8'", ")", "||", "strpos", "(", "$", "value", ",", "self", "::", "DATA_URI_PREFIX", ")", "===", "0", ")", "?", "self", "::", "DATA_URI_PREFIX", ".", "base64_encode", "(", "$", "value", ")", ":", "$", "value", ";", "}" ]
Encode as data URIs strings that JSON cannot express. @param mixed $value a value to encode @return string the encoded data URI
[ "Encode", "as", "data", "URIs", "strings", "that", "JSON", "cannot", "express", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L340-L346
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.decodeForMaria
public static function decodeForMaria($value) { return is_string($value) && strpos($value, self::DATA_URI_PREFIX) === 0 ? file_get_contents($value) : $value; }
php
public static function decodeForMaria($value) { return is_string($value) && strpos($value, self::DATA_URI_PREFIX) === 0 ? file_get_contents($value) : $value; }
[ "public", "static", "function", "decodeForMaria", "(", "$", "value", ")", "{", "return", "is_string", "(", "$", "value", ")", "&&", "strpos", "(", "$", "value", ",", "self", "::", "DATA_URI_PREFIX", ")", "===", "0", "?", "file_get_contents", "(", "$", "value", ")", ":", "$", "value", ";", "}" ]
Decode strings encoded as data URIs. @param string $value the data URI to decode @return string the decoded value
[ "Decode", "strings", "encoded", "as", "data", "URIs", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L355-L360
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.walk
protected static function walk(& $array, $method) { if (is_scalar($array)) { $array = static::$method($array); return; } $replacements = []; foreach ($array as $key => & $value) { if (is_scalar($value) || $value === null) { $value = static::$method($value); } else { static::walk($value, $method); } $newKey = static::$method($key); if ($newKey !== $key) { $replacements[$newKey] = $value; unset($array[$key]); } } foreach ($replacements as $key => $value2) { $array[$key] = $value2; } }
php
protected static function walk(& $array, $method) { if (is_scalar($array)) { $array = static::$method($array); return; } $replacements = []; foreach ($array as $key => & $value) { if (is_scalar($value) || $value === null) { $value = static::$method($value); } else { static::walk($value, $method); } $newKey = static::$method($key); if ($newKey !== $key) { $replacements[$newKey] = $value; unset($array[$key]); } } foreach ($replacements as $key => $value2) { $array[$key] = $value2; } }
[ "protected", "static", "function", "walk", "(", "&", "$", "array", ",", "$", "method", ")", "{", "if", "(", "is_scalar", "(", "$", "array", ")", ")", "{", "$", "array", "=", "static", "::", "$", "method", "(", "$", "array", ")", ";", "return", ";", "}", "$", "replacements", "=", "[", "]", ";", "foreach", "(", "$", "array", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "if", "(", "is_scalar", "(", "$", "value", ")", "||", "$", "value", "===", "null", ")", "{", "$", "value", "=", "static", "::", "$", "method", "(", "$", "value", ")", ";", "}", "else", "{", "static", "::", "walk", "(", "$", "value", ",", "$", "method", ")", ";", "}", "$", "newKey", "=", "static", "::", "$", "method", "(", "$", "key", ")", ";", "if", "(", "$", "newKey", "!==", "$", "key", ")", "{", "$", "replacements", "[", "$", "newKey", "]", "=", "$", "value", ";", "unset", "(", "$", "array", "[", "$", "key", "]", ")", ";", "}", "}", "foreach", "(", "$", "replacements", "as", "$", "key", "=>", "$", "value2", ")", "{", "$", "array", "[", "$", "key", "]", "=", "$", "value2", ";", "}", "}" ]
Replacement for PHP's array walk and map builtins. @param array $array An array to walk, which may be nested @param callable $method A method to map on the array
[ "Replacement", "for", "PHP", "s", "array", "walk", "and", "map", "builtins", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L368-L392
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.dynColSqlMaria
protected static function dynColSqlMaria(array $attrs, & $params) { $sql = []; foreach ($attrs as $key => $value) { if (is_object($value) && !($value instanceof ValueExpression)) { $value = method_exists($value, 'toArray') ? $value->toArray() : (array) $value; } if ($value === [] || $value === null) { continue; } $phKey = static::placeholder(); $phValue = static::placeholder(); $sql[] = $phKey; $params[$phKey] = $key; if ($value instanceof ValueExpression || is_float($value)) { $sql[] = $value; } elseif (is_scalar($value)) { $sql[] = $phValue; $params[$phValue] = $value; } elseif (is_array($value)) { $sql[] = static::dynColSqlMaria($value, $params); } } return $sql === [] ? 'null' : 'COLUMN_CREATE(' . implode(',', $sql) . ')'; }
php
protected static function dynColSqlMaria(array $attrs, & $params) { $sql = []; foreach ($attrs as $key => $value) { if (is_object($value) && !($value instanceof ValueExpression)) { $value = method_exists($value, 'toArray') ? $value->toArray() : (array) $value; } if ($value === [] || $value === null) { continue; } $phKey = static::placeholder(); $phValue = static::placeholder(); $sql[] = $phKey; $params[$phKey] = $key; if ($value instanceof ValueExpression || is_float($value)) { $sql[] = $value; } elseif (is_scalar($value)) { $sql[] = $phValue; $params[$phValue] = $value; } elseif (is_array($value)) { $sql[] = static::dynColSqlMaria($value, $params); } } return $sql === [] ? 'null' : 'COLUMN_CREATE(' . implode(',', $sql) . ')'; }
[ "protected", "static", "function", "dynColSqlMaria", "(", "array", "$", "attrs", ",", "&", "$", "params", ")", "{", "$", "sql", "=", "[", "]", ";", "foreach", "(", "$", "attrs", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", "&&", "!", "(", "$", "value", "instanceof", "ValueExpression", ")", ")", "{", "$", "value", "=", "method_exists", "(", "$", "value", ",", "'toArray'", ")", "?", "$", "value", "->", "toArray", "(", ")", ":", "(", "array", ")", "$", "value", ";", "}", "if", "(", "$", "value", "===", "[", "]", "||", "$", "value", "===", "null", ")", "{", "continue", ";", "}", "$", "phKey", "=", "static", "::", "placeholder", "(", ")", ";", "$", "phValue", "=", "static", "::", "placeholder", "(", ")", ";", "$", "sql", "[", "]", "=", "$", "phKey", ";", "$", "params", "[", "$", "phKey", "]", "=", "$", "key", ";", "if", "(", "$", "value", "instanceof", "ValueExpression", "||", "is_float", "(", "$", "value", ")", ")", "{", "$", "sql", "[", "]", "=", "$", "value", ";", "}", "elseif", "(", "is_scalar", "(", "$", "value", ")", ")", "{", "$", "sql", "[", "]", "=", "$", "phValue", ";", "$", "params", "[", "$", "phValue", "]", "=", "$", "value", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "sql", "[", "]", "=", "static", "::", "dynColSqlMaria", "(", "$", "value", ",", "$", "params", ")", ";", "}", "}", "return", "$", "sql", "===", "[", "]", "?", "'null'", ":", "'COLUMN_CREATE('", ".", "implode", "(", "','", ",", "$", "sql", ")", ".", "')'", ";", "}" ]
Creates the SQL and parameter bindings for setting dynamic attributes in a DB record as Dynamic Columns in Maria. @param array $attrs the dynamic attributes, which may be nested @param array $params expression parameters for binding, passed by reference @return string SQL for a DB Expression @throws \yii\base\Exception
[ "Creates", "the", "SQL", "and", "parameter", "bindings", "for", "setting", "dynamic", "attributes", "in", "a", "DB", "record", "as", "Dynamic", "Columns", "in", "Maria", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L424-L451
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.dynColExpression
public static function dynColExpression($attrs) { if (!$attrs) { return null; } $params = []; // todo For now we only have Maria. Add PgSQL and generic JSON. static::encodeArrayForMaria($attrs); $sql = static::dynColSqlMaria($attrs, $params); return new \yii\db\Expression($sql, $params); }
php
public static function dynColExpression($attrs) { if (!$attrs) { return null; } $params = []; // todo For now we only have Maria. Add PgSQL and generic JSON. static::encodeArrayForMaria($attrs); $sql = static::dynColSqlMaria($attrs, $params); return new \yii\db\Expression($sql, $params); }
[ "public", "static", "function", "dynColExpression", "(", "$", "attrs", ")", "{", "if", "(", "!", "$", "attrs", ")", "{", "return", "null", ";", "}", "$", "params", "=", "[", "]", ";", "// todo For now we only have Maria. Add PgSQL and generic JSON.", "static", "::", "encodeArrayForMaria", "(", "$", "attrs", ")", ";", "$", "sql", "=", "static", "::", "dynColSqlMaria", "(", "$", "attrs", ",", "$", "params", ")", ";", "return", "new", "\\", "yii", "\\", "db", "\\", "Expression", "(", "$", "sql", ",", "$", "params", ")", ";", "}" ]
Creates a dynamic column SQL expression representing the given attributes. @param array $attrs the dynamic attributes, which may be nested @return null|\yii\db\Expression
[ "Creates", "a", "dynamic", "column", "SQL", "expression", "representing", "the", "given", "attributes", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L460-L472
train
tom--/yii2-dynamic-ar
DynamicActiveRecord.php
DynamicActiveRecord.dynColDecode
public static function dynColDecode($encoded) { // Maria has a bug in its COLUMN_JSON funcion in which it fails to escape the // control characters U+0000 through U+001F. This causes JSON decoders to fail. // This workaround escapes those characters. $encoded = preg_replace_callback( '/[\x00-\x1f]/', function ($matches) { return sprintf('\u00%02x', ord($matches[0])); }, $encoded ); $decoded = json_decode($encoded, true); if ($decoded) { static::decodeArrayForMaria($decoded); } return $decoded; }
php
public static function dynColDecode($encoded) { // Maria has a bug in its COLUMN_JSON funcion in which it fails to escape the // control characters U+0000 through U+001F. This causes JSON decoders to fail. // This workaround escapes those characters. $encoded = preg_replace_callback( '/[\x00-\x1f]/', function ($matches) { return sprintf('\u00%02x', ord($matches[0])); }, $encoded ); $decoded = json_decode($encoded, true); if ($decoded) { static::decodeArrayForMaria($decoded); } return $decoded; }
[ "public", "static", "function", "dynColDecode", "(", "$", "encoded", ")", "{", "// Maria has a bug in its COLUMN_JSON funcion in which it fails to escape the", "// control characters U+0000 through U+001F. This causes JSON decoders to fail.", "// This workaround escapes those characters.", "$", "encoded", "=", "preg_replace_callback", "(", "'/[\\x00-\\x1f]/'", ",", "function", "(", "$", "matches", ")", "{", "return", "sprintf", "(", "'\\u00%02x'", ",", "ord", "(", "$", "matches", "[", "0", "]", ")", ")", ";", "}", ",", "$", "encoded", ")", ";", "$", "decoded", "=", "json_decode", "(", "$", "encoded", ",", "true", ")", ";", "if", "(", "$", "decoded", ")", "{", "static", "::", "decodeArrayForMaria", "(", "$", "decoded", ")", ";", "}", "return", "$", "decoded", ";", "}" ]
Decode a serialized blob of dynamic attributes. At present the only supported input format is JSON returned from Maria. It may work also for PostgreSQL. @param string $encoded Serialized array of attributes in DB-specific form @return array Dynamic attributes in name => value pairs (possibly nested)
[ "Decode", "a", "serialized", "blob", "of", "dynamic", "attributes", "." ]
d2fd52763fb92a5197b044917e924f58fb3e4e9a
https://github.com/tom--/yii2-dynamic-ar/blob/d2fd52763fb92a5197b044917e924f58fb3e4e9a/DynamicActiveRecord.php#L484-L503
train
crisu83/yii-auth
AuthModule.php
AuthModule.beforeControllerAction
public function beforeControllerAction($controller, $action) { if (parent::beforeControllerAction($controller, $action)) { $user = Yii::app()->getUser(); if ($user instanceof AuthWebUser) { if ($user->isAdmin) { return true; } elseif ($user->isGuest) { $user->loginRequired(); } } else { throw new CException('WebUser component is not an instance of AuthWebUser.'); } } throw new CHttpException(401, Yii::t('AuthModule.main', 'Access denied.')); }
php
public function beforeControllerAction($controller, $action) { if (parent::beforeControllerAction($controller, $action)) { $user = Yii::app()->getUser(); if ($user instanceof AuthWebUser) { if ($user->isAdmin) { return true; } elseif ($user->isGuest) { $user->loginRequired(); } } else { throw new CException('WebUser component is not an instance of AuthWebUser.'); } } throw new CHttpException(401, Yii::t('AuthModule.main', 'Access denied.')); }
[ "public", "function", "beforeControllerAction", "(", "$", "controller", ",", "$", "action", ")", "{", "if", "(", "parent", "::", "beforeControllerAction", "(", "$", "controller", ",", "$", "action", ")", ")", "{", "$", "user", "=", "Yii", "::", "app", "(", ")", "->", "getUser", "(", ")", ";", "if", "(", "$", "user", "instanceof", "AuthWebUser", ")", "{", "if", "(", "$", "user", "->", "isAdmin", ")", "{", "return", "true", ";", "}", "elseif", "(", "$", "user", "->", "isGuest", ")", "{", "$", "user", "->", "loginRequired", "(", ")", ";", "}", "}", "else", "{", "throw", "new", "CException", "(", "'WebUser component is not an instance of AuthWebUser.'", ")", ";", "}", "}", "throw", "new", "CHttpException", "(", "401", ",", "Yii", "::", "t", "(", "'AuthModule.main'", ",", "'Access denied.'", ")", ")", ";", "}" ]
The pre-filter for controller actions. @param CController $controller the controller. @param CAction $action the action. @return boolean whether the action should be executed. @throws CException|CHttpException if user is denied access.
[ "The", "pre", "-", "filter", "for", "controller", "actions", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/AuthModule.php#L113-L129
train
rdohms/dms-filter
src/DMS/Filter/Rules/Callback.php
Callback.getInputType
public function getInputType() { switch (true) { case $this->callback instanceof Closure: return self::CLOSURE_TYPE; case is_callable($this->callback, false): return self::CALLABLE_TYPE; case is_string($this->callback): return self::SELF_METHOD_TYPE; } throw new InvalidCallbackException( "The input provided for Callback filter is not supported or the callable not valid. Please refer to the class documentation." ); }
php
public function getInputType() { switch (true) { case $this->callback instanceof Closure: return self::CLOSURE_TYPE; case is_callable($this->callback, false): return self::CALLABLE_TYPE; case is_string($this->callback): return self::SELF_METHOD_TYPE; } throw new InvalidCallbackException( "The input provided for Callback filter is not supported or the callable not valid. Please refer to the class documentation." ); }
[ "public", "function", "getInputType", "(", ")", "{", "switch", "(", "true", ")", "{", "case", "$", "this", "->", "callback", "instanceof", "Closure", ":", "return", "self", "::", "CLOSURE_TYPE", ";", "case", "is_callable", "(", "$", "this", "->", "callback", ",", "false", ")", ":", "return", "self", "::", "CALLABLE_TYPE", ";", "case", "is_string", "(", "$", "this", "->", "callback", ")", ":", "return", "self", "::", "SELF_METHOD_TYPE", ";", "}", "throw", "new", "InvalidCallbackException", "(", "\"The input provided for Callback filter is not supported or the callable not valid.\n Please refer to the class documentation.\"", ")", ";", "}" ]
Figures out which type of input was provided @return string @throws \DMS\Filter\Exception\InvalidCallbackException
[ "Figures", "out", "which", "type", "of", "input", "was", "provided" ]
3eb0942a68fa023e0d7378fa825447e7a47219b1
https://github.com/rdohms/dms-filter/blob/3eb0942a68fa023e0d7378fa825447e7a47219b1/src/DMS/Filter/Rules/Callback.php#L42-L59
train
rdohms/dms-filter
src/DMS/Filter/ObjectWalker.php
ObjectWalker.applyFilterRules
public function applyFilterRules($property, $filterRules = array()) { foreach ($filterRules as $rule) { $this->applyFilterRule($property, $rule); } }
php
public function applyFilterRules($property, $filterRules = array()) { foreach ($filterRules as $rule) { $this->applyFilterRule($property, $rule); } }
[ "public", "function", "applyFilterRules", "(", "$", "property", ",", "$", "filterRules", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "filterRules", "as", "$", "rule", ")", "{", "$", "this", "->", "applyFilterRule", "(", "$", "property", ",", "$", "rule", ")", ";", "}", "}" ]
Applies the selected rules to a property in the object @param string $property @param array $filterRules
[ "Applies", "the", "selected", "rules", "to", "a", "property", "in", "the", "object" ]
3eb0942a68fa023e0d7378fa825447e7a47219b1
https://github.com/rdohms/dms-filter/blob/3eb0942a68fa023e0d7378fa825447e7a47219b1/src/DMS/Filter/ObjectWalker.php#L51-L56
train
rdohms/dms-filter
src/DMS/Filter/ObjectWalker.php
ObjectWalker.setPropertyValue
private function setPropertyValue($propertyName, $value) { $this->getAccessibleReflectionProperty($propertyName) ->setValue($this->object, $value); }
php
private function setPropertyValue($propertyName, $value) { $this->getAccessibleReflectionProperty($propertyName) ->setValue($this->object, $value); }
[ "private", "function", "setPropertyValue", "(", "$", "propertyName", ",", "$", "value", ")", "{", "$", "this", "->", "getAccessibleReflectionProperty", "(", "$", "propertyName", ")", "->", "setValue", "(", "$", "this", "->", "object", ",", "$", "value", ")", ";", "}" ]
Overrides the value of a property, overcoming visibility problems @param string$propertyName @param mixed $value
[ "Overrides", "the", "value", "of", "a", "property", "overcoming", "visibility", "problems" ]
3eb0942a68fa023e0d7378fa825447e7a47219b1
https://github.com/rdohms/dms-filter/blob/3eb0942a68fa023e0d7378fa825447e7a47219b1/src/DMS/Filter/ObjectWalker.php#L103-L107
train
rdohms/dms-filter
src/DMS/Filter/ObjectWalker.php
ObjectWalker.getAccessibleReflectionProperty
private function getAccessibleReflectionProperty($propertyName) { $property = $this->reflClass->getProperty($propertyName); $property->setAccessible(true); return $property; }
php
private function getAccessibleReflectionProperty($propertyName) { $property = $this->reflClass->getProperty($propertyName); $property->setAccessible(true); return $property; }
[ "private", "function", "getAccessibleReflectionProperty", "(", "$", "propertyName", ")", "{", "$", "property", "=", "$", "this", "->", "reflClass", "->", "getProperty", "(", "$", "propertyName", ")", ";", "$", "property", "->", "setAccessible", "(", "true", ")", ";", "return", "$", "property", ";", "}" ]
Retrieves a property from the object and makes it visible @param string $propertyName @return \ReflectionProperty
[ "Retrieves", "a", "property", "from", "the", "object", "and", "makes", "it", "visible" ]
3eb0942a68fa023e0d7378fa825447e7a47219b1
https://github.com/rdohms/dms-filter/blob/3eb0942a68fa023e0d7378fa825447e7a47219b1/src/DMS/Filter/ObjectWalker.php#L115-L121
train
crisu83/yii-auth
components/AuthController.php
AuthController.init
public function init() { parent::init(); $this->layout = $this->module->defaultLayout; $this->menu = $this->getSubMenu(); }
php
public function init() { parent::init(); $this->layout = $this->module->defaultLayout; $this->menu = $this->getSubMenu(); }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "$", "this", "->", "layout", "=", "$", "this", "->", "module", "->", "defaultLayout", ";", "$", "this", "->", "menu", "=", "$", "this", "->", "getSubMenu", "(", ")", ";", "}" ]
Initializes the controller.
[ "Initializes", "the", "controller", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthController.php#L28-L33
train
crisu83/yii-auth
components/AuthController.php
AuthController.getItemTypeText
public function getItemTypeText($type, $plural = false) { // todo: change the default value for $plural to false. $n = $plural ? 2 : 1; switch ($type) { case CAuthItem::TYPE_OPERATION: $name = Yii::t('AuthModule.main', 'operation|operations', $n); break; case CAuthItem::TYPE_TASK: $name = Yii::t('AuthModule.main', 'task|tasks', $n); break; case CAuthItem::TYPE_ROLE: $name = Yii::t('AuthModule.main', 'role|roles', $n); break; default: throw new CException('Auth item type "' . $type . '" is valid.'); } return $name; }
php
public function getItemTypeText($type, $plural = false) { // todo: change the default value for $plural to false. $n = $plural ? 2 : 1; switch ($type) { case CAuthItem::TYPE_OPERATION: $name = Yii::t('AuthModule.main', 'operation|operations', $n); break; case CAuthItem::TYPE_TASK: $name = Yii::t('AuthModule.main', 'task|tasks', $n); break; case CAuthItem::TYPE_ROLE: $name = Yii::t('AuthModule.main', 'role|roles', $n); break; default: throw new CException('Auth item type "' . $type . '" is valid.'); } return $name; }
[ "public", "function", "getItemTypeText", "(", "$", "type", ",", "$", "plural", "=", "false", ")", "{", "// todo: change the default value for $plural to false.", "$", "n", "=", "$", "plural", "?", "2", ":", "1", ";", "switch", "(", "$", "type", ")", "{", "case", "CAuthItem", "::", "TYPE_OPERATION", ":", "$", "name", "=", "Yii", "::", "t", "(", "'AuthModule.main'", ",", "'operation|operations'", ",", "$", "n", ")", ";", "break", ";", "case", "CAuthItem", "::", "TYPE_TASK", ":", "$", "name", "=", "Yii", "::", "t", "(", "'AuthModule.main'", ",", "'task|tasks'", ",", "$", "n", ")", ";", "break", ";", "case", "CAuthItem", "::", "TYPE_ROLE", ":", "$", "name", "=", "Yii", "::", "t", "(", "'AuthModule.main'", ",", "'role|roles'", ",", "$", "n", ")", ";", "break", ";", "default", ":", "throw", "new", "CException", "(", "'Auth item type \"'", ".", "$", "type", ".", "'\" is valid.'", ")", ";", "}", "return", "$", "name", ";", "}" ]
Returns the authorization item type as a string. @param string $type the item type (0=operation, 1=task, 2=role). @param boolean $plural whether to return the name in plural. @return string the text. @throws CException if the item type is invalid.
[ "Returns", "the", "authorization", "item", "type", "as", "a", "string", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthController.php#L42-L63
train
crisu83/yii-auth
components/AuthController.php
AuthController.getItemControllerId
public function getItemControllerId($type) { $controllerId = null; switch ($type) { case CAuthItem::TYPE_OPERATION: $controllerId = 'operation'; break; case CAuthItem::TYPE_TASK: $controllerId = 'task'; break; case CAuthItem::TYPE_ROLE: $controllerId = 'role'; break; default: throw new CException('Auth item type "' . $type . '" is valid.'); } return $controllerId; }
php
public function getItemControllerId($type) { $controllerId = null; switch ($type) { case CAuthItem::TYPE_OPERATION: $controllerId = 'operation'; break; case CAuthItem::TYPE_TASK: $controllerId = 'task'; break; case CAuthItem::TYPE_ROLE: $controllerId = 'role'; break; default: throw new CException('Auth item type "' . $type . '" is valid.'); } return $controllerId; }
[ "public", "function", "getItemControllerId", "(", "$", "type", ")", "{", "$", "controllerId", "=", "null", ";", "switch", "(", "$", "type", ")", "{", "case", "CAuthItem", "::", "TYPE_OPERATION", ":", "$", "controllerId", "=", "'operation'", ";", "break", ";", "case", "CAuthItem", "::", "TYPE_TASK", ":", "$", "controllerId", "=", "'task'", ";", "break", ";", "case", "CAuthItem", "::", "TYPE_ROLE", ":", "$", "controllerId", "=", "'role'", ";", "break", ";", "default", ":", "throw", "new", "CException", "(", "'Auth item type \"'", ".", "$", "type", ".", "'\" is valid.'", ")", ";", "}", "return", "$", "controllerId", ";", "}" ]
Returns the controllerId for the given authorization item. @param string $type the item type (0=operation, 1=task, 2=role). @return string the controllerId. @throws CException if the item type is invalid.
[ "Returns", "the", "controllerId", "for", "the", "given", "authorization", "item", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthController.php#L71-L91
train
crisu83/yii-auth
components/AuthController.php
AuthController.capitalize
public function capitalize($string) { if (!extension_loaded('mbstring')) { return ucfirst($string); } $encoding = Yii::app()->charset; $firstChar = mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding); return $firstChar . mb_substr($string, 1, mb_strlen($string, $encoding) - 1, $encoding); }
php
public function capitalize($string) { if (!extension_loaded('mbstring')) { return ucfirst($string); } $encoding = Yii::app()->charset; $firstChar = mb_strtoupper(mb_substr($string, 0, 1, $encoding), $encoding); return $firstChar . mb_substr($string, 1, mb_strlen($string, $encoding) - 1, $encoding); }
[ "public", "function", "capitalize", "(", "$", "string", ")", "{", "if", "(", "!", "extension_loaded", "(", "'mbstring'", ")", ")", "{", "return", "ucfirst", "(", "$", "string", ")", ";", "}", "$", "encoding", "=", "Yii", "::", "app", "(", ")", "->", "charset", ";", "$", "firstChar", "=", "mb_strtoupper", "(", "mb_substr", "(", "$", "string", ",", "0", ",", "1", ",", "$", "encoding", ")", ",", "$", "encoding", ")", ";", "return", "$", "firstChar", ".", "mb_substr", "(", "$", "string", ",", "1", ",", "mb_strlen", "(", "$", "string", ",", "$", "encoding", ")", "-", "1", ",", "$", "encoding", ")", ";", "}" ]
Capitalizes the first word in the given string. @param string $string the string to capitalize. @return string the capitalized string. @see http://stackoverflow.com/questions/2517947/ucfirst-function-for-multibyte-character-encodings
[ "Capitalizes", "the", "first", "word", "in", "the", "given", "string", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthController.php#L99-L108
train
crisu83/yii-auth
components/AuthController.php
AuthController.getSubMenu
protected function getSubMenu() { return array( array( 'label' => Yii::t('AuthModule.main', 'Assignments'), 'url' => array('/auth/assignment/index'), 'active' => $this instanceof AssignmentController, ), array( 'label' => $this->capitalize($this->getItemTypeText(CAuthItem::TYPE_ROLE, true)), 'url' => array('/auth/role/index'), 'active' => $this instanceof RoleController, ), array( 'label' => $this->capitalize($this->getItemTypeText(CAuthItem::TYPE_TASK, true)), 'url' => array('/auth/task/index'), 'active' => $this instanceof TaskController, ), array( 'label' => $this->capitalize($this->getItemTypeText(CAuthItem::TYPE_OPERATION, true)), 'url' => array('/auth/operation/index'), 'active' => $this instanceof OperationController, ), ); }
php
protected function getSubMenu() { return array( array( 'label' => Yii::t('AuthModule.main', 'Assignments'), 'url' => array('/auth/assignment/index'), 'active' => $this instanceof AssignmentController, ), array( 'label' => $this->capitalize($this->getItemTypeText(CAuthItem::TYPE_ROLE, true)), 'url' => array('/auth/role/index'), 'active' => $this instanceof RoleController, ), array( 'label' => $this->capitalize($this->getItemTypeText(CAuthItem::TYPE_TASK, true)), 'url' => array('/auth/task/index'), 'active' => $this instanceof TaskController, ), array( 'label' => $this->capitalize($this->getItemTypeText(CAuthItem::TYPE_OPERATION, true)), 'url' => array('/auth/operation/index'), 'active' => $this instanceof OperationController, ), ); }
[ "protected", "function", "getSubMenu", "(", ")", "{", "return", "array", "(", "array", "(", "'label'", "=>", "Yii", "::", "t", "(", "'AuthModule.main'", ",", "'Assignments'", ")", ",", "'url'", "=>", "array", "(", "'/auth/assignment/index'", ")", ",", "'active'", "=>", "$", "this", "instanceof", "AssignmentController", ",", ")", ",", "array", "(", "'label'", "=>", "$", "this", "->", "capitalize", "(", "$", "this", "->", "getItemTypeText", "(", "CAuthItem", "::", "TYPE_ROLE", ",", "true", ")", ")", ",", "'url'", "=>", "array", "(", "'/auth/role/index'", ")", ",", "'active'", "=>", "$", "this", "instanceof", "RoleController", ",", ")", ",", "array", "(", "'label'", "=>", "$", "this", "->", "capitalize", "(", "$", "this", "->", "getItemTypeText", "(", "CAuthItem", "::", "TYPE_TASK", ",", "true", ")", ")", ",", "'url'", "=>", "array", "(", "'/auth/task/index'", ")", ",", "'active'", "=>", "$", "this", "instanceof", "TaskController", ",", ")", ",", "array", "(", "'label'", "=>", "$", "this", "->", "capitalize", "(", "$", "this", "->", "getItemTypeText", "(", "CAuthItem", "::", "TYPE_OPERATION", ",", "true", ")", ")", ",", "'url'", "=>", "array", "(", "'/auth/operation/index'", ")", ",", "'active'", "=>", "$", "this", "instanceof", "OperationController", ",", ")", ",", ")", ";", "}" ]
Returns the sub menu configuration. @return array the configuration.
[ "Returns", "the", "sub", "menu", "configuration", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthController.php#L114-L138
train
ravage84/SwissPaymentSlip
src/OrangePaymentSlip.php
OrangePaymentSlip.setDefaults
protected function setDefaults() { parent::setDefaults(); $this->setReferenceNumberLeftAttr(3, 60, 50, 4, null, null, 8); $this->setReferenceNumberRightAttr(125, 33.5, 80, 4); $this->setCodeLineAttr(64, 85, 140, 4, null, 'OCRB10'); $this->setSlipBackground(__DIR__.'/Resources/img/ezs_orange.gif'); return $this; }
php
protected function setDefaults() { parent::setDefaults(); $this->setReferenceNumberLeftAttr(3, 60, 50, 4, null, null, 8); $this->setReferenceNumberRightAttr(125, 33.5, 80, 4); $this->setCodeLineAttr(64, 85, 140, 4, null, 'OCRB10'); $this->setSlipBackground(__DIR__.'/Resources/img/ezs_orange.gif'); return $this; }
[ "protected", "function", "setDefaults", "(", ")", "{", "parent", "::", "setDefaults", "(", ")", ";", "$", "this", "->", "setReferenceNumberLeftAttr", "(", "3", ",", "60", ",", "50", ",", "4", ",", "null", ",", "null", ",", "8", ")", ";", "$", "this", "->", "setReferenceNumberRightAttr", "(", "125", ",", "33.5", ",", "80", ",", "4", ")", ";", "$", "this", "->", "setCodeLineAttr", "(", "64", ",", "85", ",", "140", ",", "4", ",", "null", ",", "'OCRB10'", ")", ";", "$", "this", "->", "setSlipBackground", "(", "__DIR__", ".", "'/Resources/img/ezs_orange.gif'", ")", ";", "return", "$", "this", ";", "}" ]
Sets the default attributes of the elements for an orange slip @return $this The current instance for a fluent interface.
[ "Sets", "the", "default", "attributes", "of", "the", "elements", "for", "an", "orange", "slip" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/OrangePaymentSlip.php#L119-L130
train
ravage84/SwissPaymentSlip
src/OrangePaymentSlip.php
OrangePaymentSlip.setReferenceNumberLeftAttr
public function setReferenceNumberLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->referenceNumberLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setReferenceNumberLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->referenceNumberLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setReferenceNumberLeftAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "referenceNumberLeftAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the left reference number attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "left", "reference", "number", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/OrangePaymentSlip.php#L157-L184
train
ravage84/SwissPaymentSlip
src/OrangePaymentSlip.php
OrangePaymentSlip.setReferenceNumberRightAttr
public function setReferenceNumberRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { if ($textAlign === null) { $textAlign = 'R'; } $this->setAttributes( $this->referenceNumberRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setReferenceNumberRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { if ($textAlign === null) { $textAlign = 'R'; } $this->setAttributes( $this->referenceNumberRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setReferenceNumberRightAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "if", "(", "$", "textAlign", "===", "null", ")", "{", "$", "textAlign", "=", "'R'", ";", "}", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "referenceNumberRightAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the right reference number attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "right", "reference", "number", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/OrangePaymentSlip.php#L201-L232
train
ravage84/SwissPaymentSlip
src/OrangePaymentSlip.php
OrangePaymentSlip.setCodeLineAttr
public function setCodeLineAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { if ($textAlign === null) { $textAlign = 'R'; } $this->setAttributes( $this->codeLineAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setCodeLineAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { if ($textAlign === null) { $textAlign = 'R'; } $this->setAttributes( $this->codeLineAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setCodeLineAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "if", "(", "$", "textAlign", "===", "null", ")", "{", "$", "textAlign", "=", "'R'", ";", "}", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "codeLineAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the code line attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "code", "line", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/OrangePaymentSlip.php#L249-L280
train
ravage84/SwissPaymentSlip
src/OrangePaymentSlip.php
OrangePaymentSlip.setDisplayReferenceNr
public function setDisplayReferenceNr($displayReferenceNr = true) { $this->isBool($displayReferenceNr, 'displayReferenceNr'); $this->displayReferenceNr = $displayReferenceNr; return $this; }
php
public function setDisplayReferenceNr($displayReferenceNr = true) { $this->isBool($displayReferenceNr, 'displayReferenceNr'); $this->displayReferenceNr = $displayReferenceNr; return $this; }
[ "public", "function", "setDisplayReferenceNr", "(", "$", "displayReferenceNr", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "displayReferenceNr", ",", "'displayReferenceNr'", ")", ";", "$", "this", "->", "displayReferenceNr", "=", "$", "displayReferenceNr", ";", "return", "$", "this", ";", "}" ]
Set whether or not to display the reference number @param bool $displayReferenceNr True if yes, false if no @return $this The current instance for a fluent interface.
[ "Set", "whether", "or", "not", "to", "display", "the", "reference", "number" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/OrangePaymentSlip.php#L318-L324
train
ravage84/SwissPaymentSlip
src/OrangePaymentSlip.php
OrangePaymentSlip.setDisplayCodeLine
public function setDisplayCodeLine($displayCodeLine = true) { $this->isBool($displayCodeLine, 'displayCodeLine'); $this->displayCodeLine = $displayCodeLine; return $this; }
php
public function setDisplayCodeLine($displayCodeLine = true) { $this->isBool($displayCodeLine, 'displayCodeLine'); $this->displayCodeLine = $displayCodeLine; return $this; }
[ "public", "function", "setDisplayCodeLine", "(", "$", "displayCodeLine", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "displayCodeLine", ",", "'displayCodeLine'", ")", ";", "$", "this", "->", "displayCodeLine", "=", "$", "displayCodeLine", ";", "return", "$", "this", ";", "}" ]
Set whether or not to display the code line at the bottom @param bool $displayCodeLine True if yes, false if no @return $this The current instance for a fluent interface.
[ "Set", "whether", "or", "not", "to", "display", "the", "code", "line", "at", "the", "bottom" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/OrangePaymentSlip.php#L345-L351
train
ravage84/SwissPaymentSlip
src/OrangePaymentSlip.php
OrangePaymentSlip.getDisplayCodeLine
public function getDisplayCodeLine() { if ($this->getPaymentSlipData()->getWithAccountNumber() !== true || $this->getPaymentSlipData()->getWithReferenceNumber() !== true ) { return false; } return $this->displayCodeLine; }
php
public function getDisplayCodeLine() { if ($this->getPaymentSlipData()->getWithAccountNumber() !== true || $this->getPaymentSlipData()->getWithReferenceNumber() !== true ) { return false; } return $this->displayCodeLine; }
[ "public", "function", "getDisplayCodeLine", "(", ")", "{", "if", "(", "$", "this", "->", "getPaymentSlipData", "(", ")", "->", "getWithAccountNumber", "(", ")", "!==", "true", "||", "$", "this", "->", "getPaymentSlipData", "(", ")", "->", "getWithReferenceNumber", "(", ")", "!==", "true", ")", "{", "return", "false", ";", "}", "return", "$", "this", "->", "displayCodeLine", ";", "}" ]
Get whether or not to display the code line at the bottom Overwrites the parent method as it checks additional settings. @return bool True if yes, false if no.
[ "Get", "whether", "or", "not", "to", "display", "the", "code", "line", "at", "the", "bottom" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/OrangePaymentSlip.php#L406-L414
train
rdohms/dms-filter
src/DMS/Filter/Filters/Loader/FilterLoader.php
FilterLoader.getFilterForRule
public function getFilterForRule(Rule $rule) { $filterIdentifier = $rule->getFilter(); if (class_exists($filterIdentifier)) { return new $filterIdentifier; } $error = "Unable to locate filter for: $filterIdentifier defined in " . get_class($rule); throw new \UnexpectedValueException($error); }
php
public function getFilterForRule(Rule $rule) { $filterIdentifier = $rule->getFilter(); if (class_exists($filterIdentifier)) { return new $filterIdentifier; } $error = "Unable to locate filter for: $filterIdentifier defined in " . get_class($rule); throw new \UnexpectedValueException($error); }
[ "public", "function", "getFilterForRule", "(", "Rule", "$", "rule", ")", "{", "$", "filterIdentifier", "=", "$", "rule", "->", "getFilter", "(", ")", ";", "if", "(", "class_exists", "(", "$", "filterIdentifier", ")", ")", "{", "return", "new", "$", "filterIdentifier", ";", "}", "$", "error", "=", "\"Unable to locate filter for: $filterIdentifier defined in \"", ".", "get_class", "(", "$", "rule", ")", ";", "throw", "new", "\\", "UnexpectedValueException", "(", "$", "error", ")", ";", "}" ]
Finds the filter responsible for executing a specific rule @param Rule $rule @throws \UnexpectedValueException If filter can't be located @return BaseFilter
[ "Finds", "the", "filter", "responsible", "for", "executing", "a", "specific", "rule" ]
3eb0942a68fa023e0d7378fa825447e7a47219b1
https://github.com/rdohms/dms-filter/blob/3eb0942a68fa023e0d7378fa825447e7a47219b1/src/DMS/Filter/Filters/Loader/FilterLoader.php#L25-L35
train
crisu83/yii-auth
controllers/AssignmentController.php
AssignmentController.actionView
public function actionView($id) { $formModel = new AddAuthItemForm(); /* @var $am CAuthManager|AuthBehavior */ $am = Yii::app()->getAuthManager(); if (isset($_POST['AddAuthItemForm'])) { $formModel->attributes = $_POST['AddAuthItemForm']; if ($formModel->validate()) { if (!$am->isAssigned($formModel->items, $id)) { $am->assign($formModel->items, $id); if ($am instanceof CPhpAuthManager) { $am->save(); } if ($am instanceof ICachedAuthManager) { $am->flushAccess($formModel->items, $id); } } } } $model = CActiveRecord::model($this->module->userClass)->findByPk($id); $assignments = $am->getAuthAssignments($id); $authItems = $am->getItemsPermissions(array_keys($assignments)); $authItemDp = new AuthItemDataProvider(); $authItemDp->setAuthItems($authItems); $assignmentOptions = $this->getAssignmentOptions($id); if (!empty($assignmentOptions)) { $assignmentOptions = array_merge( array('' => Yii::t('AuthModule.main', 'Select item') . ' ...'), $assignmentOptions ); } $this->render( 'view', array( 'model' => $model, 'authItemDp' => $authItemDp, 'formModel' => $formModel, 'assignmentOptions' => $assignmentOptions, ) ); }
php
public function actionView($id) { $formModel = new AddAuthItemForm(); /* @var $am CAuthManager|AuthBehavior */ $am = Yii::app()->getAuthManager(); if (isset($_POST['AddAuthItemForm'])) { $formModel->attributes = $_POST['AddAuthItemForm']; if ($formModel->validate()) { if (!$am->isAssigned($formModel->items, $id)) { $am->assign($formModel->items, $id); if ($am instanceof CPhpAuthManager) { $am->save(); } if ($am instanceof ICachedAuthManager) { $am->flushAccess($formModel->items, $id); } } } } $model = CActiveRecord::model($this->module->userClass)->findByPk($id); $assignments = $am->getAuthAssignments($id); $authItems = $am->getItemsPermissions(array_keys($assignments)); $authItemDp = new AuthItemDataProvider(); $authItemDp->setAuthItems($authItems); $assignmentOptions = $this->getAssignmentOptions($id); if (!empty($assignmentOptions)) { $assignmentOptions = array_merge( array('' => Yii::t('AuthModule.main', 'Select item') . ' ...'), $assignmentOptions ); } $this->render( 'view', array( 'model' => $model, 'authItemDp' => $authItemDp, 'formModel' => $formModel, 'assignmentOptions' => $assignmentOptions, ) ); }
[ "public", "function", "actionView", "(", "$", "id", ")", "{", "$", "formModel", "=", "new", "AddAuthItemForm", "(", ")", ";", "/* @var $am CAuthManager|AuthBehavior */", "$", "am", "=", "Yii", "::", "app", "(", ")", "->", "getAuthManager", "(", ")", ";", "if", "(", "isset", "(", "$", "_POST", "[", "'AddAuthItemForm'", "]", ")", ")", "{", "$", "formModel", "->", "attributes", "=", "$", "_POST", "[", "'AddAuthItemForm'", "]", ";", "if", "(", "$", "formModel", "->", "validate", "(", ")", ")", "{", "if", "(", "!", "$", "am", "->", "isAssigned", "(", "$", "formModel", "->", "items", ",", "$", "id", ")", ")", "{", "$", "am", "->", "assign", "(", "$", "formModel", "->", "items", ",", "$", "id", ")", ";", "if", "(", "$", "am", "instanceof", "CPhpAuthManager", ")", "{", "$", "am", "->", "save", "(", ")", ";", "}", "if", "(", "$", "am", "instanceof", "ICachedAuthManager", ")", "{", "$", "am", "->", "flushAccess", "(", "$", "formModel", "->", "items", ",", "$", "id", ")", ";", "}", "}", "}", "}", "$", "model", "=", "CActiveRecord", "::", "model", "(", "$", "this", "->", "module", "->", "userClass", ")", "->", "findByPk", "(", "$", "id", ")", ";", "$", "assignments", "=", "$", "am", "->", "getAuthAssignments", "(", "$", "id", ")", ";", "$", "authItems", "=", "$", "am", "->", "getItemsPermissions", "(", "array_keys", "(", "$", "assignments", ")", ")", ";", "$", "authItemDp", "=", "new", "AuthItemDataProvider", "(", ")", ";", "$", "authItemDp", "->", "setAuthItems", "(", "$", "authItems", ")", ";", "$", "assignmentOptions", "=", "$", "this", "->", "getAssignmentOptions", "(", "$", "id", ")", ";", "if", "(", "!", "empty", "(", "$", "assignmentOptions", ")", ")", "{", "$", "assignmentOptions", "=", "array_merge", "(", "array", "(", "''", "=>", "Yii", "::", "t", "(", "'AuthModule.main'", ",", "'Select item'", ")", ".", "' ...'", ")", ",", "$", "assignmentOptions", ")", ";", "}", "$", "this", "->", "render", "(", "'view'", ",", "array", "(", "'model'", "=>", "$", "model", ",", "'authItemDp'", "=>", "$", "authItemDp", ",", "'formModel'", "=>", "$", "formModel", ",", "'assignmentOptions'", "=>", "$", "assignmentOptions", ",", ")", ")", ";", "}" ]
Displays the assignments for the user with the given id. @param string $id the user id.
[ "Displays", "the", "assignments", "for", "the", "user", "with", "the", "given", "id", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/controllers/AssignmentController.php#L34-L81
train
crisu83/yii-auth
controllers/AssignmentController.php
AssignmentController.actionRevoke
public function actionRevoke() { if (isset($_GET['itemName'], $_GET['userId'])) { $itemName = $_GET['itemName']; $userId = $_GET['userId']; /* @var $am CAuthManager|AuthBehavior */ $am = Yii::app()->getAuthManager(); if ($am->isAssigned($itemName, $userId)) { $am->revoke($itemName, $userId); if ($am instanceof CPhpAuthManager) { $am->save(); } if ($am instanceof ICachedAuthManager) { $am->flushAccess($itemName, $userId); } } if (!isset($_POST['ajax'])) { $this->redirect(array('view', 'id' => $userId)); } } else { throw new CHttpException(400, Yii::t('AuthModule.main', 'Invalid request.')); } }
php
public function actionRevoke() { if (isset($_GET['itemName'], $_GET['userId'])) { $itemName = $_GET['itemName']; $userId = $_GET['userId']; /* @var $am CAuthManager|AuthBehavior */ $am = Yii::app()->getAuthManager(); if ($am->isAssigned($itemName, $userId)) { $am->revoke($itemName, $userId); if ($am instanceof CPhpAuthManager) { $am->save(); } if ($am instanceof ICachedAuthManager) { $am->flushAccess($itemName, $userId); } } if (!isset($_POST['ajax'])) { $this->redirect(array('view', 'id' => $userId)); } } else { throw new CHttpException(400, Yii::t('AuthModule.main', 'Invalid request.')); } }
[ "public", "function", "actionRevoke", "(", ")", "{", "if", "(", "isset", "(", "$", "_GET", "[", "'itemName'", "]", ",", "$", "_GET", "[", "'userId'", "]", ")", ")", "{", "$", "itemName", "=", "$", "_GET", "[", "'itemName'", "]", ";", "$", "userId", "=", "$", "_GET", "[", "'userId'", "]", ";", "/* @var $am CAuthManager|AuthBehavior */", "$", "am", "=", "Yii", "::", "app", "(", ")", "->", "getAuthManager", "(", ")", ";", "if", "(", "$", "am", "->", "isAssigned", "(", "$", "itemName", ",", "$", "userId", ")", ")", "{", "$", "am", "->", "revoke", "(", "$", "itemName", ",", "$", "userId", ")", ";", "if", "(", "$", "am", "instanceof", "CPhpAuthManager", ")", "{", "$", "am", "->", "save", "(", ")", ";", "}", "if", "(", "$", "am", "instanceof", "ICachedAuthManager", ")", "{", "$", "am", "->", "flushAccess", "(", "$", "itemName", ",", "$", "userId", ")", ";", "}", "}", "if", "(", "!", "isset", "(", "$", "_POST", "[", "'ajax'", "]", ")", ")", "{", "$", "this", "->", "redirect", "(", "array", "(", "'view'", ",", "'id'", "=>", "$", "userId", ")", ")", ";", "}", "}", "else", "{", "throw", "new", "CHttpException", "(", "400", ",", "Yii", "::", "t", "(", "'AuthModule.main'", ",", "'Invalid request.'", ")", ")", ";", "}", "}" ]
Revokes an assignment from the given user. @throws CHttpException if the request is invalid.
[ "Revokes", "an", "assignment", "from", "the", "given", "user", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/controllers/AssignmentController.php#L87-L113
train
crisu83/yii-auth
controllers/AssignmentController.php
AssignmentController.getAssignmentOptions
protected function getAssignmentOptions($userId) { $options = array(); /* @var $am CAuthManager|AuthBehavior */ $am = Yii::app()->authManager; $assignments = $am->getAuthAssignments($userId); $assignedItems = array_keys($assignments); /* @var $authItems CAuthItem[] */ $authItems = $am->getAuthItems(); foreach ($authItems as $itemName => $item) { if (!in_array($itemName, $assignedItems)) { $options[$this->capitalize($this->getItemTypeText($item->type, true))][$itemName] = $item->description; } } return $options; }
php
protected function getAssignmentOptions($userId) { $options = array(); /* @var $am CAuthManager|AuthBehavior */ $am = Yii::app()->authManager; $assignments = $am->getAuthAssignments($userId); $assignedItems = array_keys($assignments); /* @var $authItems CAuthItem[] */ $authItems = $am->getAuthItems(); foreach ($authItems as $itemName => $item) { if (!in_array($itemName, $assignedItems)) { $options[$this->capitalize($this->getItemTypeText($item->type, true))][$itemName] = $item->description; } } return $options; }
[ "protected", "function", "getAssignmentOptions", "(", "$", "userId", ")", "{", "$", "options", "=", "array", "(", ")", ";", "/* @var $am CAuthManager|AuthBehavior */", "$", "am", "=", "Yii", "::", "app", "(", ")", "->", "authManager", ";", "$", "assignments", "=", "$", "am", "->", "getAuthAssignments", "(", "$", "userId", ")", ";", "$", "assignedItems", "=", "array_keys", "(", "$", "assignments", ")", ";", "/* @var $authItems CAuthItem[] */", "$", "authItems", "=", "$", "am", "->", "getAuthItems", "(", ")", ";", "foreach", "(", "$", "authItems", "as", "$", "itemName", "=>", "$", "item", ")", "{", "if", "(", "!", "in_array", "(", "$", "itemName", ",", "$", "assignedItems", ")", ")", "{", "$", "options", "[", "$", "this", "->", "capitalize", "(", "$", "this", "->", "getItemTypeText", "(", "$", "item", "->", "type", ",", "true", ")", ")", "]", "[", "$", "itemName", "]", "=", "$", "item", "->", "description", ";", "}", "}", "return", "$", "options", ";", "}" ]
Returns a list of possible assignments for the user with the given id. @param string $userId the user id. @return array the assignment options.
[ "Returns", "a", "list", "of", "possible", "assignments", "for", "the", "user", "with", "the", "given", "id", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/controllers/AssignmentController.php#L120-L139
train
rdohms/dms-filter
src/DMS/Filter/Rules/Rule.php
Rule.parseOptions
private function parseOptions($options) { $parseResult = new \stdClass(); $parseResult->invalidOptions = array(); $parseResult->missingOptions = array_flip((array)$this->getRequiredOptions()); //Doctrine parses constructor parameter into 'value' array param, restore it if (is_array($options) && count($options) == 1 && isset($options['value'])) { $options = $options['value']; } //Parse Option Array if (is_array($options) && count($options) > 0 && is_string(key($options))) { $this->parseOptionsArray($options, $parseResult); return $parseResult; } //Parse Single Value if (null !== $options && ! (is_array($options) && count($options) === 0)) { $this->parseSingleOption($options, $parseResult); return $parseResult; } return $parseResult; }
php
private function parseOptions($options) { $parseResult = new \stdClass(); $parseResult->invalidOptions = array(); $parseResult->missingOptions = array_flip((array)$this->getRequiredOptions()); //Doctrine parses constructor parameter into 'value' array param, restore it if (is_array($options) && count($options) == 1 && isset($options['value'])) { $options = $options['value']; } //Parse Option Array if (is_array($options) && count($options) > 0 && is_string(key($options))) { $this->parseOptionsArray($options, $parseResult); return $parseResult; } //Parse Single Value if (null !== $options && ! (is_array($options) && count($options) === 0)) { $this->parseSingleOption($options, $parseResult); return $parseResult; } return $parseResult; }
[ "private", "function", "parseOptions", "(", "$", "options", ")", "{", "$", "parseResult", "=", "new", "\\", "stdClass", "(", ")", ";", "$", "parseResult", "->", "invalidOptions", "=", "array", "(", ")", ";", "$", "parseResult", "->", "missingOptions", "=", "array_flip", "(", "(", "array", ")", "$", "this", "->", "getRequiredOptions", "(", ")", ")", ";", "//Doctrine parses constructor parameter into 'value' array param, restore it", "if", "(", "is_array", "(", "$", "options", ")", "&&", "count", "(", "$", "options", ")", "==", "1", "&&", "isset", "(", "$", "options", "[", "'value'", "]", ")", ")", "{", "$", "options", "=", "$", "options", "[", "'value'", "]", ";", "}", "//Parse Option Array", "if", "(", "is_array", "(", "$", "options", ")", "&&", "count", "(", "$", "options", ")", ">", "0", "&&", "is_string", "(", "key", "(", "$", "options", ")", ")", ")", "{", "$", "this", "->", "parseOptionsArray", "(", "$", "options", ",", "$", "parseResult", ")", ";", "return", "$", "parseResult", ";", "}", "//Parse Single Value", "if", "(", "null", "!==", "$", "options", "&&", "!", "(", "is_array", "(", "$", "options", ")", "&&", "count", "(", "$", "options", ")", "===", "0", ")", ")", "{", "$", "this", "->", "parseSingleOption", "(", "$", "options", ",", "$", "parseResult", ")", ";", "return", "$", "parseResult", ";", "}", "return", "$", "parseResult", ";", "}" ]
Parses provided options into their properties and returns results for the parsing process @param mixed $options @return \stdClass
[ "Parses", "provided", "options", "into", "their", "properties", "and", "returns", "results", "for", "the", "parsing", "process" ]
3eb0942a68fa023e0d7378fa825447e7a47219b1
https://github.com/rdohms/dms-filter/blob/3eb0942a68fa023e0d7378fa825447e7a47219b1/src/DMS/Filter/Rules/Rule.php#L68-L92
train
rdohms/dms-filter
src/DMS/Filter/Rules/Rule.php
Rule.parseOptionsArray
private function parseOptionsArray($options, \stdClass $result) { foreach ($options as $option => $value) { if (! property_exists($this, $option)) { $result->invalidOptions[] = $option; continue; } //Define Option $this->$option = $value; unset($result->missingOptions[$option]); } }
php
private function parseOptionsArray($options, \stdClass $result) { foreach ($options as $option => $value) { if (! property_exists($this, $option)) { $result->invalidOptions[] = $option; continue; } //Define Option $this->$option = $value; unset($result->missingOptions[$option]); } }
[ "private", "function", "parseOptionsArray", "(", "$", "options", ",", "\\", "stdClass", "$", "result", ")", "{", "foreach", "(", "$", "options", "as", "$", "option", "=>", "$", "value", ")", "{", "if", "(", "!", "property_exists", "(", "$", "this", ",", "$", "option", ")", ")", "{", "$", "result", "->", "invalidOptions", "[", "]", "=", "$", "option", ";", "continue", ";", "}", "//Define Option", "$", "this", "->", "$", "option", "=", "$", "value", ";", "unset", "(", "$", "result", "->", "missingOptions", "[", "$", "option", "]", ")", ";", "}", "}" ]
Parses Options in the array format @param array $options @param \stdClass $result
[ "Parses", "Options", "in", "the", "array", "format" ]
3eb0942a68fa023e0d7378fa825447e7a47219b1
https://github.com/rdohms/dms-filter/blob/3eb0942a68fa023e0d7378fa825447e7a47219b1/src/DMS/Filter/Rules/Rule.php#L100-L112
train
rdohms/dms-filter
src/DMS/Filter/Rules/Rule.php
Rule.parseSingleOption
private function parseSingleOption($options, \stdClass $result) { $option = $this->getDefaultOption(); //No Default set, unsure what to do if (null === $option) { throw new RuleDefinitionException( sprintf('No default option is configured for rule %s', get_class($this)) ); } //Default option points to invalid one if (! property_exists($this, $option)) { $result->invalidOptions[] = $option; return; } //Define Option $this->$option = $options; unset($result->missingOptions[$option]); }
php
private function parseSingleOption($options, \stdClass $result) { $option = $this->getDefaultOption(); //No Default set, unsure what to do if (null === $option) { throw new RuleDefinitionException( sprintf('No default option is configured for rule %s', get_class($this)) ); } //Default option points to invalid one if (! property_exists($this, $option)) { $result->invalidOptions[] = $option; return; } //Define Option $this->$option = $options; unset($result->missingOptions[$option]); }
[ "private", "function", "parseSingleOption", "(", "$", "options", ",", "\\", "stdClass", "$", "result", ")", "{", "$", "option", "=", "$", "this", "->", "getDefaultOption", "(", ")", ";", "//No Default set, unsure what to do", "if", "(", "null", "===", "$", "option", ")", "{", "throw", "new", "RuleDefinitionException", "(", "sprintf", "(", "'No default option is configured for rule %s'", ",", "get_class", "(", "$", "this", ")", ")", ")", ";", "}", "//Default option points to invalid one", "if", "(", "!", "property_exists", "(", "$", "this", ",", "$", "option", ")", ")", "{", "$", "result", "->", "invalidOptions", "[", "]", "=", "$", "option", ";", "return", ";", "}", "//Define Option", "$", "this", "->", "$", "option", "=", "$", "options", ";", "unset", "(", "$", "result", "->", "missingOptions", "[", "$", "option", "]", ")", ";", "}" ]
Parses single option received @param string $options @param \stdClass $result @throws \DMS\Filter\Exception\RuleDefinitionException
[ "Parses", "single", "option", "received" ]
3eb0942a68fa023e0d7378fa825447e7a47219b1
https://github.com/rdohms/dms-filter/blob/3eb0942a68fa023e0d7378fa825447e7a47219b1/src/DMS/Filter/Rules/Rule.php#L121-L141
train
rdohms/dms-filter
src/DMS/Filter/Filters/Zend.php
Zend.getZendInstance
public function getZendInstance($class, $options) { if (strpos($class, 'Zend\Filter') === false) { $class = "Zend\Filter\\".$class; } if (! class_exists($class)) { throw new InvalidZendFilterException("Could not find or autoload: $class"); } try { new \ReflectionMethod($class, 'setOptions'); $filter = new $class(); $filter->setOptions($options); return $filter; } catch (\ReflectionException $e) { return new $class($options); } }
php
public function getZendInstance($class, $options) { if (strpos($class, 'Zend\Filter') === false) { $class = "Zend\Filter\\".$class; } if (! class_exists($class)) { throw new InvalidZendFilterException("Could not find or autoload: $class"); } try { new \ReflectionMethod($class, 'setOptions'); $filter = new $class(); $filter->setOptions($options); return $filter; } catch (\ReflectionException $e) { return new $class($options); } }
[ "public", "function", "getZendInstance", "(", "$", "class", ",", "$", "options", ")", "{", "if", "(", "strpos", "(", "$", "class", ",", "'Zend\\Filter'", ")", "===", "false", ")", "{", "$", "class", "=", "\"Zend\\Filter\\\\\"", ".", "$", "class", ";", "}", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "throw", "new", "InvalidZendFilterException", "(", "\"Could not find or autoload: $class\"", ")", ";", "}", "try", "{", "new", "\\", "ReflectionMethod", "(", "$", "class", ",", "'setOptions'", ")", ";", "$", "filter", "=", "new", "$", "class", "(", ")", ";", "$", "filter", "->", "setOptions", "(", "$", "options", ")", ";", "return", "$", "filter", ";", "}", "catch", "(", "\\", "ReflectionException", "$", "e", ")", "{", "return", "new", "$", "class", "(", "$", "options", ")", ";", "}", "}" ]
Instantiates a configured Zend Filter, if it exists @param string $class @param array $options @return \Zend\Filter\FilterInterface @throws \DMS\Filter\Exception\InvalidZendFilterException
[ "Instantiates", "a", "configured", "Zend", "Filter", "if", "it", "exists" ]
3eb0942a68fa023e0d7378fa825447e7a47219b1
https://github.com/rdohms/dms-filter/blob/3eb0942a68fa023e0d7378fa825447e7a47219b1/src/DMS/Filter/Filters/Zend.php#L37-L57
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setDefaults
protected function setDefaults() { $this->setBankLeftAttr(3, 8, 50, 4); $this->setBankRightAttr(66, 8, 50, 4); $this->setRecipientLeftAttr(3, 23, 50, 4); $this->setRecipientRightAttr(66, 23, 50, 4); $this->setAccountLeftAttr(27, 43, 30, 4); $this->setAccountRightAttr(90, 43, 30, 4); $this->setAmountFrancsLeftAttr(5, 50.5, 35, 4); $this->setAmountFrancsRightAttr(66, 50.5, 35, 4); $this->setAmountCentsLeftAttr(50, 50.5, 6, 4); $this->setAmountCentsRightAttr(111, 50.5, 6, 4); $this->setPayerLeftAttr(3, 65, 50, 4); $this->setPayerRightAttr(125, 48, 50, 4); return $this; }
php
protected function setDefaults() { $this->setBankLeftAttr(3, 8, 50, 4); $this->setBankRightAttr(66, 8, 50, 4); $this->setRecipientLeftAttr(3, 23, 50, 4); $this->setRecipientRightAttr(66, 23, 50, 4); $this->setAccountLeftAttr(27, 43, 30, 4); $this->setAccountRightAttr(90, 43, 30, 4); $this->setAmountFrancsLeftAttr(5, 50.5, 35, 4); $this->setAmountFrancsRightAttr(66, 50.5, 35, 4); $this->setAmountCentsLeftAttr(50, 50.5, 6, 4); $this->setAmountCentsRightAttr(111, 50.5, 6, 4); $this->setPayerLeftAttr(3, 65, 50, 4); $this->setPayerRightAttr(125, 48, 50, 4); return $this; }
[ "protected", "function", "setDefaults", "(", ")", "{", "$", "this", "->", "setBankLeftAttr", "(", "3", ",", "8", ",", "50", ",", "4", ")", ";", "$", "this", "->", "setBankRightAttr", "(", "66", ",", "8", ",", "50", ",", "4", ")", ";", "$", "this", "->", "setRecipientLeftAttr", "(", "3", ",", "23", ",", "50", ",", "4", ")", ";", "$", "this", "->", "setRecipientRightAttr", "(", "66", ",", "23", ",", "50", ",", "4", ")", ";", "$", "this", "->", "setAccountLeftAttr", "(", "27", ",", "43", ",", "30", ",", "4", ")", ";", "$", "this", "->", "setAccountRightAttr", "(", "90", ",", "43", ",", "30", ",", "4", ")", ";", "$", "this", "->", "setAmountFrancsLeftAttr", "(", "5", ",", "50.5", ",", "35", ",", "4", ")", ";", "$", "this", "->", "setAmountFrancsRightAttr", "(", "66", ",", "50.5", ",", "35", ",", "4", ")", ";", "$", "this", "->", "setAmountCentsLeftAttr", "(", "50", ",", "50.5", ",", "6", ",", "4", ")", ";", "$", "this", "->", "setAmountCentsRightAttr", "(", "111", ",", "50.5", ",", "6", ",", "4", ")", ";", "$", "this", "->", "setPayerLeftAttr", "(", "3", ",", "65", ",", "50", ",", "4", ")", ";", "$", "this", "->", "setPayerRightAttr", "(", "125", ",", "48", ",", "50", ",", "4", ")", ";", "return", "$", "this", ";", "}" ]
Sets the common default attributes of the elements @return $this The current instance for a fluent interface.
[ "Sets", "the", "common", "default", "attributes", "of", "the", "elements" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L271-L287
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setSlipPosition
public function setSlipPosition($slipPosX, $slipPosY) { $this->setSlipPosX($slipPosX); $this->setSlipPosY($slipPosY); return $this; }
php
public function setSlipPosition($slipPosX, $slipPosY) { $this->setSlipPosX($slipPosX); $this->setSlipPosY($slipPosY); return $this; }
[ "public", "function", "setSlipPosition", "(", "$", "slipPosX", ",", "$", "slipPosY", ")", "{", "$", "this", "->", "setSlipPosX", "(", "$", "slipPosX", ")", ";", "$", "this", "->", "setSlipPosY", "(", "$", "slipPosY", ")", ";", "return", "$", "this", ";", "}" ]
Set the starting X & Y position of the slip @param float $slipPosX The starting X position of the slip. @param float $slipPosY The starting Y position of the slip @return $this The current instance for a fluent interface.
[ "Set", "the", "starting", "X", "&", "Y", "position", "of", "the", "slip" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L306-L312
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setSlipSize
public function setSlipSize($slipWidth, $slipHeight) { $this->setSlipHeight($slipHeight); $this->setSlipWidth($slipWidth); return $this; }
php
public function setSlipSize($slipWidth, $slipHeight) { $this->setSlipHeight($slipHeight); $this->setSlipWidth($slipWidth); return $this; }
[ "public", "function", "setSlipSize", "(", "$", "slipWidth", ",", "$", "slipHeight", ")", "{", "$", "this", "->", "setSlipHeight", "(", "$", "slipHeight", ")", ";", "$", "this", "->", "setSlipWidth", "(", "$", "slipWidth", ")", ";", "return", "$", "this", ";", "}" ]
Set the height & width of the slip @param float $slipWidth The width of the slip @param float $slipHeight The height of the slip @return $this The current instance for a fluent interface.
[ "Set", "the", "height", "&", "width", "of", "the", "slip" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L349-L355
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setAttributes
protected function setAttributes( &$element, $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { if ($posX) { $element['PosX'] = $posX; } elseif (!isset($element['PosX'])) { $element['PosX'] = 0; } if ($posY) { $element['PosY'] = $posY; } elseif (!isset($element['PosY'])) { $element['PosY'] = 0; } if ($width) { $element['Width'] = $width; } elseif (!isset($element['Width'])) { $element['Width'] = 0; } if ($height) { $element['Height'] = $height; } elseif (!isset($element['Height'])) { $element['Height'] = 0; } if (!empty($background)) { $element['Background'] = $background; } elseif (!isset($element['Background'])) { $element['Background'] = 'transparent'; } if (!empty($fontFamily)) { $element['FontFamily'] = $fontFamily; } elseif (!isset($element['FontFamily'])) { $element['FontFamily'] = $this->defaultFontFamily; } if ($fontSize) { $element['FontSize'] = $fontSize; } elseif (!isset($element['FontSize'])) { $element['FontSize'] = $this->defaultFontSize; } if (!empty($fontColor)) { $element['FontColor'] = $fontColor; } elseif (!isset($element['FontColor'])) { $element['FontColor'] = $this->defaultFontColor; } if ($lineHeight) { $element['LineHeight'] = $lineHeight; } elseif (!isset($element['LineHeight'])) { $element['LineHeight'] = $this->defaultLineHeight; } if (!empty($textAlign)) { $element['TextAlign'] = $textAlign; } elseif (!isset($element['TextAlign'])) { $element['TextAlign'] = $this->defaultTextAlign; } return $this; }
php
protected function setAttributes( &$element, $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { if ($posX) { $element['PosX'] = $posX; } elseif (!isset($element['PosX'])) { $element['PosX'] = 0; } if ($posY) { $element['PosY'] = $posY; } elseif (!isset($element['PosY'])) { $element['PosY'] = 0; } if ($width) { $element['Width'] = $width; } elseif (!isset($element['Width'])) { $element['Width'] = 0; } if ($height) { $element['Height'] = $height; } elseif (!isset($element['Height'])) { $element['Height'] = 0; } if (!empty($background)) { $element['Background'] = $background; } elseif (!isset($element['Background'])) { $element['Background'] = 'transparent'; } if (!empty($fontFamily)) { $element['FontFamily'] = $fontFamily; } elseif (!isset($element['FontFamily'])) { $element['FontFamily'] = $this->defaultFontFamily; } if ($fontSize) { $element['FontSize'] = $fontSize; } elseif (!isset($element['FontSize'])) { $element['FontSize'] = $this->defaultFontSize; } if (!empty($fontColor)) { $element['FontColor'] = $fontColor; } elseif (!isset($element['FontColor'])) { $element['FontColor'] = $this->defaultFontColor; } if ($lineHeight) { $element['LineHeight'] = $lineHeight; } elseif (!isset($element['LineHeight'])) { $element['LineHeight'] = $this->defaultLineHeight; } if (!empty($textAlign)) { $element['TextAlign'] = $textAlign; } elseif (!isset($element['TextAlign'])) { $element['TextAlign'] = $this->defaultTextAlign; } return $this; }
[ "protected", "function", "setAttributes", "(", "&", "$", "element", ",", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "if", "(", "$", "posX", ")", "{", "$", "element", "[", "'PosX'", "]", "=", "$", "posX", ";", "}", "elseif", "(", "!", "isset", "(", "$", "element", "[", "'PosX'", "]", ")", ")", "{", "$", "element", "[", "'PosX'", "]", "=", "0", ";", "}", "if", "(", "$", "posY", ")", "{", "$", "element", "[", "'PosY'", "]", "=", "$", "posY", ";", "}", "elseif", "(", "!", "isset", "(", "$", "element", "[", "'PosY'", "]", ")", ")", "{", "$", "element", "[", "'PosY'", "]", "=", "0", ";", "}", "if", "(", "$", "width", ")", "{", "$", "element", "[", "'Width'", "]", "=", "$", "width", ";", "}", "elseif", "(", "!", "isset", "(", "$", "element", "[", "'Width'", "]", ")", ")", "{", "$", "element", "[", "'Width'", "]", "=", "0", ";", "}", "if", "(", "$", "height", ")", "{", "$", "element", "[", "'Height'", "]", "=", "$", "height", ";", "}", "elseif", "(", "!", "isset", "(", "$", "element", "[", "'Height'", "]", ")", ")", "{", "$", "element", "[", "'Height'", "]", "=", "0", ";", "}", "if", "(", "!", "empty", "(", "$", "background", ")", ")", "{", "$", "element", "[", "'Background'", "]", "=", "$", "background", ";", "}", "elseif", "(", "!", "isset", "(", "$", "element", "[", "'Background'", "]", ")", ")", "{", "$", "element", "[", "'Background'", "]", "=", "'transparent'", ";", "}", "if", "(", "!", "empty", "(", "$", "fontFamily", ")", ")", "{", "$", "element", "[", "'FontFamily'", "]", "=", "$", "fontFamily", ";", "}", "elseif", "(", "!", "isset", "(", "$", "element", "[", "'FontFamily'", "]", ")", ")", "{", "$", "element", "[", "'FontFamily'", "]", "=", "$", "this", "->", "defaultFontFamily", ";", "}", "if", "(", "$", "fontSize", ")", "{", "$", "element", "[", "'FontSize'", "]", "=", "$", "fontSize", ";", "}", "elseif", "(", "!", "isset", "(", "$", "element", "[", "'FontSize'", "]", ")", ")", "{", "$", "element", "[", "'FontSize'", "]", "=", "$", "this", "->", "defaultFontSize", ";", "}", "if", "(", "!", "empty", "(", "$", "fontColor", ")", ")", "{", "$", "element", "[", "'FontColor'", "]", "=", "$", "fontColor", ";", "}", "elseif", "(", "!", "isset", "(", "$", "element", "[", "'FontColor'", "]", ")", ")", "{", "$", "element", "[", "'FontColor'", "]", "=", "$", "this", "->", "defaultFontColor", ";", "}", "if", "(", "$", "lineHeight", ")", "{", "$", "element", "[", "'LineHeight'", "]", "=", "$", "lineHeight", ";", "}", "elseif", "(", "!", "isset", "(", "$", "element", "[", "'LineHeight'", "]", ")", ")", "{", "$", "element", "[", "'LineHeight'", "]", "=", "$", "this", "->", "defaultLineHeight", ";", "}", "if", "(", "!", "empty", "(", "$", "textAlign", ")", ")", "{", "$", "element", "[", "'TextAlign'", "]", "=", "$", "textAlign", ";", "}", "elseif", "(", "!", "isset", "(", "$", "element", "[", "'TextAlign'", "]", ")", ")", "{", "$", "element", "[", "'TextAlign'", "]", "=", "$", "this", "->", "defaultTextAlign", ";", "}", "return", "$", "this", ";", "}" ]
Set the attributes for a given payment slip element @param array $element The element (attributes) to set. @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "attributes", "for", "a", "given", "payment", "slip", "element" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L418-L483
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setBankLeftAttr
public function setBankLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->bankLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setBankLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->bankLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setBankLeftAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "bankLeftAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the left bank attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "left", "bank", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L500-L527
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setBankRightAttr
public function setBankRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->bankRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setBankRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->bankRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setBankRightAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "bankRightAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the right bank attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "right", "bank", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L544-L571
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setRecipientLeftAttr
public function setRecipientLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->recipientLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setRecipientLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->recipientLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setRecipientLeftAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "recipientLeftAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the left recipient attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "left", "recipient", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L588-L615
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setRecipientRightAttr
public function setRecipientRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->recipientRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setRecipientRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->recipientRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setRecipientRightAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "recipientRightAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the right recipient attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "right", "recipient", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L632-L659
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setAccountLeftAttr
public function setAccountLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->accountLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setAccountLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->accountLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setAccountLeftAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "accountLeftAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the left account attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "left", "account", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L676-L703
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setAccountRightAttr
public function setAccountRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->accountRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setAccountRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->accountRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setAccountRightAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "accountRightAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the right account attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "right", "account", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L720-L747
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setAmountFrancsLeftAttr
public function setAmountFrancsLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { if ($textAlign === null) { $textAlign = 'R'; } $this->setAttributes( $this->amountFrancsLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setAmountFrancsLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { if ($textAlign === null) { $textAlign = 'R'; } $this->setAttributes( $this->amountFrancsLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setAmountFrancsLeftAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "if", "(", "$", "textAlign", "===", "null", ")", "{", "$", "textAlign", "=", "'R'", ";", "}", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "amountFrancsLeftAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the left francs amount attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "left", "francs", "amount", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L764-L795
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setAmountFrancsRightAttr
public function setAmountFrancsRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { if ($textAlign === null) { $textAlign = 'R'; } $this->setAttributes( $this->amountFrancsRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setAmountFrancsRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { if ($textAlign === null) { $textAlign = 'R'; } $this->setAttributes( $this->amountFrancsRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setAmountFrancsRightAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "if", "(", "$", "textAlign", "===", "null", ")", "{", "$", "textAlign", "=", "'R'", ";", "}", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "amountFrancsRightAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the right francs amount attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "right", "francs", "amount", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L812-L843
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setAmountCentsLeftAttr
public function setAmountCentsLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->amountCentsLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setAmountCentsLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->amountCentsLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setAmountCentsLeftAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "amountCentsLeftAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the left cents amount attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "left", "cents", "amount", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L860-L887
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setAmountCentsRightAttr
public function setAmountCentsRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->amountCentsRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setAmountCentsRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->amountCentsRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setAmountCentsRightAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "amountCentsRightAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the right cents amount attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "right", "cents", "amount", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L904-L931
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setPayerLeftAttr
public function setPayerLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->payerLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setPayerLeftAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->payerLeftAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setPayerLeftAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "payerLeftAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the left payer attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "left", "payer", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L948-L975
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setPayerRightAttr
public function setPayerRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->payerRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
php
public function setPayerRightAttr( $posX = null, $posY = null, $width = null, $height = null, $background = null, $fontFamily = null, $fontSize = null, $fontColor = null, $lineHeight = null, $textAlign = null ) { $this->setAttributes( $this->payerRightAttr, $posX, $posY, $width, $height, $background, $fontFamily, $fontSize, $fontColor, $lineHeight, $textAlign ); return $this; }
[ "public", "function", "setPayerRightAttr", "(", "$", "posX", "=", "null", ",", "$", "posY", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "background", "=", "null", ",", "$", "fontFamily", "=", "null", ",", "$", "fontSize", "=", "null", ",", "$", "fontColor", "=", "null", ",", "$", "lineHeight", "=", "null", ",", "$", "textAlign", "=", "null", ")", "{", "$", "this", "->", "setAttributes", "(", "$", "this", "->", "payerRightAttr", ",", "$", "posX", ",", "$", "posY", ",", "$", "width", ",", "$", "height", ",", "$", "background", ",", "$", "fontFamily", ",", "$", "fontSize", ",", "$", "fontColor", ",", "$", "lineHeight", ",", "$", "textAlign", ")", ";", "return", "$", "this", ";", "}" ]
Set the right payer attributes @param float|null $posX The X position. @param float|null $posY The Y Position. @param float|null $width The width. @param float|null $height The height. @param string|null $background The background. @param string|null $fontFamily The font family. @param float|null $fontSize The font size. @param string|null $fontColor The font color. @param float|null $lineHeight The line height. @param string|null $textAlign The text alignment. @return $this The current instance for a fluent interface.
[ "Set", "the", "right", "payer", "attributes" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L992-L1019
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setDisplayBackground
public function setDisplayBackground($displayBackground = true) { $this->isBool($displayBackground, 'displayBackground'); $this->displayBackground = $displayBackground; return $this; }
php
public function setDisplayBackground($displayBackground = true) { $this->isBool($displayBackground, 'displayBackground'); $this->displayBackground = $displayBackground; return $this; }
[ "public", "function", "setDisplayBackground", "(", "$", "displayBackground", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "displayBackground", ",", "'displayBackground'", ")", ";", "$", "this", "->", "displayBackground", "=", "$", "displayBackground", ";", "return", "$", "this", ";", "}" ]
Set whether or not to display the background @param bool $displayBackground True if yes, false if no. @return $this The current instance for a fluent interface..
[ "Set", "whether", "or", "not", "to", "display", "the", "background" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L1199-L1205
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setDisplayAccount
public function setDisplayAccount($displayAccount = true) { $this->isBool($displayAccount, 'displayAccount'); $this->displayAccount = $displayAccount; return $this; }
php
public function setDisplayAccount($displayAccount = true) { $this->isBool($displayAccount, 'displayAccount'); $this->displayAccount = $displayAccount; return $this; }
[ "public", "function", "setDisplayAccount", "(", "$", "displayAccount", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "displayAccount", ",", "'displayAccount'", ")", ";", "$", "this", "->", "displayAccount", "=", "$", "displayAccount", ";", "return", "$", "this", ";", "}" ]
Set whether or not to display the account @param bool $displayAccount True if yes, false if no. @return $this The current instance for a fluent interface..
[ "Set", "whether", "or", "not", "to", "display", "the", "account" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L1223-L1229
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setDisplayAmount
public function setDisplayAmount($displayAmount = true) { $this->isBool($displayAmount, 'displayAmount'); $this->displayAmount = $displayAmount; return $this; }
php
public function setDisplayAmount($displayAmount = true) { $this->isBool($displayAmount, 'displayAmount'); $this->displayAmount = $displayAmount; return $this; }
[ "public", "function", "setDisplayAmount", "(", "$", "displayAmount", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "displayAmount", ",", "'displayAmount'", ")", ";", "$", "this", "->", "displayAmount", "=", "$", "displayAmount", ";", "return", "$", "this", ";", "}" ]
Set whether or not to display the amount @param bool $displayAmount True if yes, false if no @return $this The current instance for a fluent interface.
[ "Set", "whether", "or", "not", "to", "display", "the", "amount" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L1250-L1256
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setDisplayBank
public function setDisplayBank($displayBank = true) { $this->isBool($displayBank, 'displayBank'); $this->displayBank = $displayBank; return $this; }
php
public function setDisplayBank($displayBank = true) { $this->isBool($displayBank, 'displayBank'); $this->displayBank = $displayBank; return $this; }
[ "public", "function", "setDisplayBank", "(", "$", "displayBank", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "displayBank", ",", "'displayBank'", ")", ";", "$", "this", "->", "displayBank", "=", "$", "displayBank", ";", "return", "$", "this", ";", "}" ]
Set whether or not to display the bank @param bool $displayBank True if yes, false if no @return $this The current instance for a fluent interface.
[ "Set", "whether", "or", "not", "to", "display", "the", "bank" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L1277-L1283
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setDisplayPayer
public function setDisplayPayer($displayPayer = true) { $this->isBool($displayPayer, 'displayPayer'); $this->displayPayer = $displayPayer; return $this; }
php
public function setDisplayPayer($displayPayer = true) { $this->isBool($displayPayer, 'displayPayer'); $this->displayPayer = $displayPayer; return $this; }
[ "public", "function", "setDisplayPayer", "(", "$", "displayPayer", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "displayPayer", ",", "'displayPayer'", ")", ";", "$", "this", "->", "displayPayer", "=", "$", "displayPayer", ";", "return", "$", "this", ";", "}" ]
Set whether or not to display the payer @param bool $displayPayer True if yes, false if no @return $this The current instance for a fluent interface.
[ "Set", "whether", "or", "not", "to", "display", "the", "payer" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L1304-L1310
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.setDisplayRecipient
public function setDisplayRecipient($displayRecipient = true) { $this->isBool($displayRecipient, 'displayRecipient'); $this->displayRecipient = $displayRecipient; return $this; }
php
public function setDisplayRecipient($displayRecipient = true) { $this->isBool($displayRecipient, 'displayRecipient'); $this->displayRecipient = $displayRecipient; return $this; }
[ "public", "function", "setDisplayRecipient", "(", "$", "displayRecipient", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "displayRecipient", ",", "'displayRecipient'", ")", ";", "$", "this", "->", "displayRecipient", "=", "$", "displayRecipient", ";", "return", "$", "this", ";", "}" ]
Set whether or not to display the recipient @param bool $displayRecipient True if yes, false if no @return $this The current instance for a fluent interface.
[ "Set", "whether", "or", "not", "to", "display", "the", "recipient" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L1331-L1337
train
ravage84/SwissPaymentSlip
src/PaymentSlip.php
PaymentSlip.isIntOrFloat
protected function isIntOrFloat($parameter, $varName) { if ((!is_int($parameter) && !is_float($parameter))) { throw new InvalidArgumentException( sprintf( '$%s is neither an integer nor a float.', $varName ) ); } }
php
protected function isIntOrFloat($parameter, $varName) { if ((!is_int($parameter) && !is_float($parameter))) { throw new InvalidArgumentException( sprintf( '$%s is neither an integer nor a float.', $varName ) ); } }
[ "protected", "function", "isIntOrFloat", "(", "$", "parameter", ",", "$", "varName", ")", "{", "if", "(", "(", "!", "is_int", "(", "$", "parameter", ")", "&&", "!", "is_float", "(", "$", "parameter", ")", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "'$%s is neither an integer nor a float.'", ",", "$", "varName", ")", ")", ";", "}", "}" ]
Verify that a given parameter is an integer or a float @param mixed $parameter The given parameter to validate. @param string $varName The name of the variable. @return true If the parameter is either an integer or a float. @throws InvalidArgumentException If the parameter is neither an integer nor a float.
[ "Verify", "that", "a", "given", "parameter", "is", "an", "integer", "or", "a", "float" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlip.php#L1480-L1490
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.setWithBank
public function setWithBank($withBank = true) { $this->isBool($withBank, 'withBank'); $this->withBank = $withBank; if ($withBank === false) { $this->bankName = ''; $this->bankCity = ''; } return $this; }
php
public function setWithBank($withBank = true) { $this->isBool($withBank, 'withBank'); $this->withBank = $withBank; if ($withBank === false) { $this->bankName = ''; $this->bankCity = ''; } return $this; }
[ "public", "function", "setWithBank", "(", "$", "withBank", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "withBank", ",", "'withBank'", ")", ";", "$", "this", "->", "withBank", "=", "$", "withBank", ";", "if", "(", "$", "withBank", "===", "false", ")", "{", "$", "this", "->", "bankName", "=", "''", ";", "$", "this", "->", "bankCity", "=", "''", ";", "}", "return", "$", "this", ";", "}" ]
Set if payment slip has a bank specified Resets the bank data when disabling. @param bool $withBank True for yes, false for no @return $this The current instance for a fluent interface.
[ "Set", "if", "payment", "slip", "has", "a", "bank", "specified" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L203-L214
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.setWithAccountNumber
public function setWithAccountNumber($withAccountNumber = true) { $this->isBool($withAccountNumber, 'withAccountNumber'); $this->withAccountNumber = $withAccountNumber; if ($withAccountNumber === false) { $this->accountNumber = ''; } return $this; }
php
public function setWithAccountNumber($withAccountNumber = true) { $this->isBool($withAccountNumber, 'withAccountNumber'); $this->withAccountNumber = $withAccountNumber; if ($withAccountNumber === false) { $this->accountNumber = ''; } return $this; }
[ "public", "function", "setWithAccountNumber", "(", "$", "withAccountNumber", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "withAccountNumber", ",", "'withAccountNumber'", ")", ";", "$", "this", "->", "withAccountNumber", "=", "$", "withAccountNumber", ";", "if", "(", "$", "withAccountNumber", "===", "false", ")", "{", "$", "this", "->", "accountNumber", "=", "''", ";", "}", "return", "$", "this", ";", "}" ]
Set if payment slip has an account number specified Resets the account number when disabling. @param bool $withAccountNumber True if yes, false if no. @return $this The current instance for a fluent interface.
[ "Set", "if", "payment", "slip", "has", "an", "account", "number", "specified" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L234-L244
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.setWithRecipient
public function setWithRecipient($withRecipient = true) { $this->isBool($withRecipient, 'withRecipient'); $this->withRecipient = $withRecipient; if ($withRecipient === false) { $this->recipientLine1 = ''; $this->recipientLine2 = ''; $this->recipientLine3 = ''; $this->recipientLine4 = ''; } return $this; }
php
public function setWithRecipient($withRecipient = true) { $this->isBool($withRecipient, 'withRecipient'); $this->withRecipient = $withRecipient; if ($withRecipient === false) { $this->recipientLine1 = ''; $this->recipientLine2 = ''; $this->recipientLine3 = ''; $this->recipientLine4 = ''; } return $this; }
[ "public", "function", "setWithRecipient", "(", "$", "withRecipient", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "withRecipient", ",", "'withRecipient'", ")", ";", "$", "this", "->", "withRecipient", "=", "$", "withRecipient", ";", "if", "(", "$", "withRecipient", "===", "false", ")", "{", "$", "this", "->", "recipientLine1", "=", "''", ";", "$", "this", "->", "recipientLine2", "=", "''", ";", "$", "this", "->", "recipientLine3", "=", "''", ";", "$", "this", "->", "recipientLine4", "=", "''", ";", "}", "return", "$", "this", ";", "}" ]
Set if payment slip has a recipient specified Resets the recipient data when disabling. @param bool $withRecipient True if yes, false if no. @return $this The current instance for a fluent interface.
[ "Set", "if", "payment", "slip", "has", "a", "recipient", "specified" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L264-L277
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.setWithAmount
public function setWithAmount($withAmount = true) { $this->isBool($withAmount, 'withAmount'); $this->withAmount = $withAmount; if ($withAmount === false) { $this->amount = 0.0; } return $this; }
php
public function setWithAmount($withAmount = true) { $this->isBool($withAmount, 'withAmount'); $this->withAmount = $withAmount; if ($withAmount === false) { $this->amount = 0.0; } return $this; }
[ "public", "function", "setWithAmount", "(", "$", "withAmount", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "withAmount", ",", "'withAmount'", ")", ";", "$", "this", "->", "withAmount", "=", "$", "withAmount", ";", "if", "(", "$", "withAmount", "===", "false", ")", "{", "$", "this", "->", "amount", "=", "0.0", ";", "}", "return", "$", "this", ";", "}" ]
Set if payment slip has an amount specified Resets the amount when disabling. @param bool $withAmount True for yes, false for no. @return $this The current instance for a fluent interface.
[ "Set", "if", "payment", "slip", "has", "an", "amount", "specified" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L297-L307
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.setWithPayer
public function setWithPayer($withPayer = true) { $this->isBool($withPayer, 'withPayer'); $this->withPayer = $withPayer; if ($withPayer === false) { $this->payerLine1 = ''; $this->payerLine2 = ''; $this->payerLine3 = ''; $this->payerLine4 = ''; } return $this; }
php
public function setWithPayer($withPayer = true) { $this->isBool($withPayer, 'withPayer'); $this->withPayer = $withPayer; if ($withPayer === false) { $this->payerLine1 = ''; $this->payerLine2 = ''; $this->payerLine3 = ''; $this->payerLine4 = ''; } return $this; }
[ "public", "function", "setWithPayer", "(", "$", "withPayer", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "withPayer", ",", "'withPayer'", ")", ";", "$", "this", "->", "withPayer", "=", "$", "withPayer", ";", "if", "(", "$", "withPayer", "===", "false", ")", "{", "$", "this", "->", "payerLine1", "=", "''", ";", "$", "this", "->", "payerLine2", "=", "''", ";", "$", "this", "->", "payerLine3", "=", "''", ";", "$", "this", "->", "payerLine4", "=", "''", ";", "}", "return", "$", "this", ";", "}" ]
Set if payment slip has a payer specified Resets the payer data when disabling. @param bool $withPayer True if yes, false if no. @return $this The current instance for a fluent interface.
[ "Set", "if", "payment", "slip", "has", "a", "payer", "specified" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L327-L340
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.setBankData
public function setBankData($bankName, $bankCity) { $this->setBankName($bankName); $this->setBankCity($bankCity); return $this; }
php
public function setBankData($bankName, $bankCity) { $this->setBankName($bankName); $this->setBankCity($bankCity); return $this; }
[ "public", "function", "setBankData", "(", "$", "bankName", ",", "$", "bankCity", ")", "{", "$", "this", "->", "setBankName", "(", "$", "bankName", ")", ";", "$", "this", "->", "setBankCity", "(", "$", "bankCity", ")", ";", "return", "$", "this", ";", "}" ]
Sets the name, city and account number of the bank @param string $bankName Name of the bank. @param string $bankCity City of the bank. @return $this The current instance for a fluent interface.
[ "Sets", "the", "name", "city", "and", "account", "number", "of", "the", "bank" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L359-L365
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.setRecipientData
public function setRecipientData($recipientLine1, $recipientLine2, $recipientLine3 = '', $recipientLine4 = '') { $this->setRecipientLine1($recipientLine1); $this->setRecipientLine2($recipientLine2); $this->setRecipientLine3($recipientLine3); $this->setRecipientLine4($recipientLine4); return $this; }
php
public function setRecipientData($recipientLine1, $recipientLine2, $recipientLine3 = '', $recipientLine4 = '') { $this->setRecipientLine1($recipientLine1); $this->setRecipientLine2($recipientLine2); $this->setRecipientLine3($recipientLine3); $this->setRecipientLine4($recipientLine4); return $this; }
[ "public", "function", "setRecipientData", "(", "$", "recipientLine1", ",", "$", "recipientLine2", ",", "$", "recipientLine3", "=", "''", ",", "$", "recipientLine4", "=", "''", ")", "{", "$", "this", "->", "setRecipientLine1", "(", "$", "recipientLine1", ")", ";", "$", "this", "->", "setRecipientLine2", "(", "$", "recipientLine2", ")", ";", "$", "this", "->", "setRecipientLine3", "(", "$", "recipientLine3", ")", ";", "$", "this", "->", "setRecipientLine4", "(", "$", "recipientLine4", ")", ";", "return", "$", "this", ";", "}" ]
Sets the four lines of the recipient @param string $recipientLine1 The first line of the recipient, e.g. "My Company Ltd.". @param string $recipientLine2 The second line of the recipient, e.g. "Examplestreet 61". @param string $recipientLine3 The third line of the recipient, e.g. "8000 Zürich". @param string $recipientLine4 The fourth line of the recipient, if needed. @return $this The current instance for a fluent interface.
[ "Sets", "the", "four", "lines", "of", "the", "recipient" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L475-L483
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.setPayerData
public function setPayerData($payerLine1, $payerLine2, $payerLine3 = '', $payerLine4 = '') { $this->setPayerLine1($payerLine1); $this->setPayerLine2($payerLine2); $this->setPayerLine3($payerLine3); $this->setPayerLine4($payerLine4); return $this; }
php
public function setPayerData($payerLine1, $payerLine2, $payerLine3 = '', $payerLine4 = '') { $this->setPayerLine1($payerLine1); $this->setPayerLine2($payerLine2); $this->setPayerLine3($payerLine3); $this->setPayerLine4($payerLine4); return $this; }
[ "public", "function", "setPayerData", "(", "$", "payerLine1", ",", "$", "payerLine2", ",", "$", "payerLine3", "=", "''", ",", "$", "payerLine4", "=", "''", ")", "{", "$", "this", "->", "setPayerLine1", "(", "$", "payerLine1", ")", ";", "$", "this", "->", "setPayerLine2", "(", "$", "payerLine2", ")", ";", "$", "this", "->", "setPayerLine3", "(", "$", "payerLine3", ")", ";", "$", "this", "->", "setPayerLine4", "(", "$", "payerLine4", ")", ";", "return", "$", "this", ";", "}" ]
Sets the four lines of the payer At least two lines are necessary. @param string $payerLine1 The first line of the payer, e.g. "Hans Mustermann". @param string $payerLine2 The second line of the payer, e.g. "Main Street 11". @param string $payerLine3 The third line of the payer, e.g. "4052 Basel". @param string $payerLine4 The fourth line of the payer, if needed. @return $this The current instance for a fluent interface.
[ "Sets", "the", "four", "lines", "of", "the", "payer" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L651-L659
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.getAccountDigits
protected function getAccountDigits() { if (!$this->getWithAccountNumber()) { throw new DisabledDataException('account number'); } if ($this->getNotForPayment()) { return 'XXXXXXXXX'; } $accountNumber = $this->getAccountNumber(); if ($accountNumber === '') { return $accountNumber; } $accountDigits = str_replace('-', '', $accountNumber, $replacedHyphens); if ($replacedHyphens != 2) { throw new PaymentSlipException('Invalid Account number. Does not contain two hyphens.'); } return $accountDigits; }
php
protected function getAccountDigits() { if (!$this->getWithAccountNumber()) { throw new DisabledDataException('account number'); } if ($this->getNotForPayment()) { return 'XXXXXXXXX'; } $accountNumber = $this->getAccountNumber(); if ($accountNumber === '') { return $accountNumber; } $accountDigits = str_replace('-', '', $accountNumber, $replacedHyphens); if ($replacedHyphens != 2) { throw new PaymentSlipException('Invalid Account number. Does not contain two hyphens.'); } return $accountDigits; }
[ "protected", "function", "getAccountDigits", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getWithAccountNumber", "(", ")", ")", "{", "throw", "new", "DisabledDataException", "(", "'account number'", ")", ";", "}", "if", "(", "$", "this", "->", "getNotForPayment", "(", ")", ")", "{", "return", "'XXXXXXXXX'", ";", "}", "$", "accountNumber", "=", "$", "this", "->", "getAccountNumber", "(", ")", ";", "if", "(", "$", "accountNumber", "===", "''", ")", "{", "return", "$", "accountNumber", ";", "}", "$", "accountDigits", "=", "str_replace", "(", "'-'", ",", "''", ",", "$", "accountNumber", ",", "$", "replacedHyphens", ")", ";", "if", "(", "$", "replacedHyphens", "!=", "2", ")", "{", "throw", "new", "PaymentSlipException", "(", "'Invalid Account number. Does not contain two hyphens.'", ")", ";", "}", "return", "$", "accountDigits", ";", "}" ]
Clear the account of the two hyphens @return string The account of the two hyphens, 'XXXXXXXXX' if not for payment or else false. @throws DisabledDataException If the data is disabled. @throws PaymentSlipException If account number does not contain two hyphens. @todo Cover the edge cases with tests
[ "Clear", "the", "account", "of", "the", "two", "hyphens" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L793-L810
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.getAmountFrancs
public function getAmountFrancs() { if ($this->getNotForPayment()) { return 'XXXXXXXX'; } $amount = $this->getAmount(); $francs = intval($amount); return $francs; }
php
public function getAmountFrancs() { if ($this->getNotForPayment()) { return 'XXXXXXXX'; } $amount = $this->getAmount(); $francs = intval($amount); return $francs; }
[ "public", "function", "getAmountFrancs", "(", ")", "{", "if", "(", "$", "this", "->", "getNotForPayment", "(", ")", ")", "{", "return", "'XXXXXXXX'", ";", "}", "$", "amount", "=", "$", "this", "->", "getAmount", "(", ")", ";", "$", "francs", "=", "intval", "(", "$", "amount", ")", ";", "return", "$", "francs", ";", "}" ]
Get the francs amount without cents @return bool|int Francs amount without cents.
[ "Get", "the", "francs", "amount", "without", "cents" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L817-L825
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.getAmountCents
public function getAmountCents() { if ($this->getNotForPayment()) { return 'XX'; } $amount = $this->getAmount(); $francs = intval($amount); $cents = round(($amount - $francs) * 100); return str_pad($cents, 2, '0', STR_PAD_LEFT); }
php
public function getAmountCents() { if ($this->getNotForPayment()) { return 'XX'; } $amount = $this->getAmount(); $francs = intval($amount); $cents = round(($amount - $francs) * 100); return str_pad($cents, 2, '0', STR_PAD_LEFT); }
[ "public", "function", "getAmountCents", "(", ")", "{", "if", "(", "$", "this", "->", "getNotForPayment", "(", ")", ")", "{", "return", "'XX'", ";", "}", "$", "amount", "=", "$", "this", "->", "getAmount", "(", ")", ";", "$", "francs", "=", "intval", "(", "$", "amount", ")", ";", "$", "cents", "=", "round", "(", "(", "$", "amount", "-", "$", "francs", ")", "*", "100", ")", ";", "return", "str_pad", "(", "$", "cents", ",", "2", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "}" ]
Get the zero filled, right padded, two digits long cents amount @return bool|string Amount of Cents, zero filled, right padded, two digits long.
[ "Get", "the", "zero", "filled", "right", "padded", "two", "digits", "long", "cents", "amount" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L832-L841
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.modulo10
protected function modulo10($number) { $next = 0; for ($i=0; $i < strlen($number); $i++) { $next = $this->moduloTable[($next + intval(substr($number, $i, 1))) % 10]; } return (10 - $next) % 10; }
php
protected function modulo10($number) { $next = 0; for ($i=0; $i < strlen($number); $i++) { $next = $this->moduloTable[($next + intval(substr($number, $i, 1))) % 10]; } return (10 - $next) % 10; }
[ "protected", "function", "modulo10", "(", "$", "number", ")", "{", "$", "next", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "number", ")", ";", "$", "i", "++", ")", "{", "$", "next", "=", "$", "this", "->", "moduloTable", "[", "(", "$", "next", "+", "intval", "(", "substr", "(", "$", "number", ",", "$", "i", ",", "1", ")", ")", ")", "%", "10", "]", ";", "}", "return", "(", "10", "-", "$", "next", ")", "%", "10", ";", "}" ]
Creates Modulo10 recursive check digit @copyright As found on http://www.developers-guide.net/forums/5431,modulo10-rekursiv (thanks, dude!) @param string $number Number to create recursive check digit off. @return int Recursive check digit.
[ "Creates", "Modulo10", "recursive", "check", "digit" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L893-L901
train
ravage84/SwissPaymentSlip
src/PaymentSlipData.php
PaymentSlipData.breakStringIntoBlocks
protected function breakStringIntoBlocks($string, $blockSize = 5, $alignFromRight = true) { // Lets reverse the string (because we want the block to be aligned from the right) if ($alignFromRight === true) { $string = strrev($string); } // Chop it into blocks $string = trim(chunk_split($string, $blockSize, ' ')); // Re-reverse if ($alignFromRight === true) { $string = strrev($string); } return $string; }
php
protected function breakStringIntoBlocks($string, $blockSize = 5, $alignFromRight = true) { // Lets reverse the string (because we want the block to be aligned from the right) if ($alignFromRight === true) { $string = strrev($string); } // Chop it into blocks $string = trim(chunk_split($string, $blockSize, ' ')); // Re-reverse if ($alignFromRight === true) { $string = strrev($string); } return $string; }
[ "protected", "function", "breakStringIntoBlocks", "(", "$", "string", ",", "$", "blockSize", "=", "5", ",", "$", "alignFromRight", "=", "true", ")", "{", "// Lets reverse the string (because we want the block to be aligned from the right)", "if", "(", "$", "alignFromRight", "===", "true", ")", "{", "$", "string", "=", "strrev", "(", "$", "string", ")", ";", "}", "// Chop it into blocks", "$", "string", "=", "trim", "(", "chunk_split", "(", "$", "string", ",", "$", "blockSize", ",", "' '", ")", ")", ";", "// Re-reverse", "if", "(", "$", "alignFromRight", "===", "true", ")", "{", "$", "string", "=", "strrev", "(", "$", "string", ")", ";", "}", "return", "$", "string", ";", "}" ]
Get a given string broken down in blocks of a certain size Example: 000000000000000 becomes more readable 00000 00000 00000 @param string $string The to be formatted string. @param int $blockSize The Block size of choice. @param bool $alignFromRight Right aligned, blocks are build from right. @return string Given string divided in blocks of given block size separated by one space.
[ "Get", "a", "given", "string", "broken", "down", "in", "blocks", "of", "a", "certain", "size" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/PaymentSlipData.php#L913-L929
train
OpenConext/Stepup-saml-bundle
src/DependencyInjection/SurfnetSamlExtension.php
SurfnetSamlExtension.parseHostedConfiguration
private function parseHostedConfiguration(array $configuration, ContainerBuilder $container) { $entityId = ['entity_id_route' => $configuration['metadata']['entity_id_route']]; $serviceProvider = array_merge($configuration['service_provider'], $entityId); $identityProvider = array_merge($configuration['identity_provider'], $entityId); $container ->getDefinition('surfnet_saml.saml.attribute_dictionary') ->replaceArgument(0, $configuration['attribute_dictionary']['ignore_unknown_attributes']); $this->parseHostedSpConfiguration($serviceProvider, $container); $this->parseHostedIdpConfiguration($identityProvider, $container); $this->parseMetadataConfiguration($configuration, $container); }
php
private function parseHostedConfiguration(array $configuration, ContainerBuilder $container) { $entityId = ['entity_id_route' => $configuration['metadata']['entity_id_route']]; $serviceProvider = array_merge($configuration['service_provider'], $entityId); $identityProvider = array_merge($configuration['identity_provider'], $entityId); $container ->getDefinition('surfnet_saml.saml.attribute_dictionary') ->replaceArgument(0, $configuration['attribute_dictionary']['ignore_unknown_attributes']); $this->parseHostedSpConfiguration($serviceProvider, $container); $this->parseHostedIdpConfiguration($identityProvider, $container); $this->parseMetadataConfiguration($configuration, $container); }
[ "private", "function", "parseHostedConfiguration", "(", "array", "$", "configuration", ",", "ContainerBuilder", "$", "container", ")", "{", "$", "entityId", "=", "[", "'entity_id_route'", "=>", "$", "configuration", "[", "'metadata'", "]", "[", "'entity_id_route'", "]", "]", ";", "$", "serviceProvider", "=", "array_merge", "(", "$", "configuration", "[", "'service_provider'", "]", ",", "$", "entityId", ")", ";", "$", "identityProvider", "=", "array_merge", "(", "$", "configuration", "[", "'identity_provider'", "]", ",", "$", "entityId", ")", ";", "$", "container", "->", "getDefinition", "(", "'surfnet_saml.saml.attribute_dictionary'", ")", "->", "replaceArgument", "(", "0", ",", "$", "configuration", "[", "'attribute_dictionary'", "]", "[", "'ignore_unknown_attributes'", "]", ")", ";", "$", "this", "->", "parseHostedSpConfiguration", "(", "$", "serviceProvider", ",", "$", "container", ")", ";", "$", "this", "->", "parseHostedIdpConfiguration", "(", "$", "identityProvider", ",", "$", "container", ")", ";", "$", "this", "->", "parseMetadataConfiguration", "(", "$", "configuration", ",", "$", "container", ")", ";", "}" ]
Creates and register MetadataConfiguration object based on the configuration given. @param array $configuration @param ContainerBuilder $container
[ "Creates", "and", "register", "MetadataConfiguration", "object", "based", "on", "the", "configuration", "given", "." ]
a20bea52de04a13d8f3aff32988e4036f720a159
https://github.com/OpenConext/Stepup-saml-bundle/blob/a20bea52de04a13d8f3aff32988e4036f720a159/src/DependencyInjection/SurfnetSamlExtension.php#L53-L66
train
rdohms/dms-filter
src/DMS/Filter/Filters/Callback.php
Callback.useObjectMethod
protected function useObjectMethod($method, $value) { $currentObject = $this->getCurrentObject(); if ($currentObject === null) { throw new FilterException( "The target object was not provided to the filter, can't execute method. Please report this." ); } if (! method_exists($currentObject, $method)) { throw new InvalidCallbackException( sprintf( "CallbackFilter: Method '%s' not found in object of type '%s'", $method, get_class($currentObject) ) ); } return $currentObject->$method($value); }
php
protected function useObjectMethod($method, $value) { $currentObject = $this->getCurrentObject(); if ($currentObject === null) { throw new FilterException( "The target object was not provided to the filter, can't execute method. Please report this." ); } if (! method_exists($currentObject, $method)) { throw new InvalidCallbackException( sprintf( "CallbackFilter: Method '%s' not found in object of type '%s'", $method, get_class($currentObject) ) ); } return $currentObject->$method($value); }
[ "protected", "function", "useObjectMethod", "(", "$", "method", ",", "$", "value", ")", "{", "$", "currentObject", "=", "$", "this", "->", "getCurrentObject", "(", ")", ";", "if", "(", "$", "currentObject", "===", "null", ")", "{", "throw", "new", "FilterException", "(", "\"The target object was not provided to the filter, can't execute method. Please report this.\"", ")", ";", "}", "if", "(", "!", "method_exists", "(", "$", "currentObject", ",", "$", "method", ")", ")", "{", "throw", "new", "InvalidCallbackException", "(", "sprintf", "(", "\"CallbackFilter: Method '%s' not found in object of type '%s'\"", ",", "$", "method", ",", "get_class", "(", "$", "currentObject", ")", ")", ")", ";", "}", "return", "$", "currentObject", "->", "$", "method", "(", "$", "value", ")", ";", "}" ]
Filters by executing a method in the object @param string $method @param mixed $value @throws \DMS\Filter\Exception\FilterException @throws \DMS\Filter\Exception\InvalidCallbackException @return mixed
[ "Filters", "by", "executing", "a", "method", "in", "the", "object" ]
3eb0942a68fa023e0d7378fa825447e7a47219b1
https://github.com/rdohms/dms-filter/blob/3eb0942a68fa023e0d7378fa825447e7a47219b1/src/DMS/Filter/Filters/Callback.php#L78-L99
train
ravage84/SwissPaymentSlip
src/OrangePaymentSlipData.php
OrangePaymentSlipData.setWithReferenceNumber
public function setWithReferenceNumber($withReferenceNumber = true) { $this->isBool($withReferenceNumber, 'withReferenceNumber'); $this->withReferenceNumber = $withReferenceNumber; if ($withReferenceNumber === false) { $this->referenceNumber = ''; } return $this; }
php
public function setWithReferenceNumber($withReferenceNumber = true) { $this->isBool($withReferenceNumber, 'withReferenceNumber'); $this->withReferenceNumber = $withReferenceNumber; if ($withReferenceNumber === false) { $this->referenceNumber = ''; } return $this; }
[ "public", "function", "setWithReferenceNumber", "(", "$", "withReferenceNumber", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "withReferenceNumber", ",", "'withReferenceNumber'", ")", ";", "$", "this", "->", "withReferenceNumber", "=", "$", "withReferenceNumber", ";", "if", "(", "$", "withReferenceNumber", "===", "false", ")", "{", "$", "this", "->", "referenceNumber", "=", "''", ";", "}", "return", "$", "this", ";", "}" ]
Set if payment slip has a reference number specified Resets the reference number when disabling. @param bool $withReferenceNumber True if yes, false if no. @return $this The current instance for a fluent interface.
[ "Set", "if", "payment", "slip", "has", "a", "reference", "number", "specified" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/OrangePaymentSlipData.php#L66-L76
train
ravage84/SwissPaymentSlip
src/OrangePaymentSlipData.php
OrangePaymentSlipData.setWithBankingCustomerId
public function setWithBankingCustomerId($withBankingCustomerId = true) { $this->isBool($withBankingCustomerId, 'withBankingCustomerId'); $this->withBankingCustomerId = $withBankingCustomerId; if ($withBankingCustomerId === false) { $this->bankingCustomerId = ''; } return $this; }
php
public function setWithBankingCustomerId($withBankingCustomerId = true) { $this->isBool($withBankingCustomerId, 'withBankingCustomerId'); $this->withBankingCustomerId = $withBankingCustomerId; if ($withBankingCustomerId === false) { $this->bankingCustomerId = ''; } return $this; }
[ "public", "function", "setWithBankingCustomerId", "(", "$", "withBankingCustomerId", "=", "true", ")", "{", "$", "this", "->", "isBool", "(", "$", "withBankingCustomerId", ",", "'withBankingCustomerId'", ")", ";", "$", "this", "->", "withBankingCustomerId", "=", "$", "withBankingCustomerId", ";", "if", "(", "$", "withBankingCustomerId", "===", "false", ")", "{", "$", "this", "->", "bankingCustomerId", "=", "''", ";", "}", "return", "$", "this", ";", "}" ]
Set if the payment slip's reference number should contain the banking customer ID Resets the banking customer ID when disabling. @param bool $withBankingCustomerId True if successful, else false. @return $this The current instance for a fluent interface.
[ "Set", "if", "the", "payment", "slip", "s", "reference", "number", "should", "contain", "the", "banking", "customer", "ID" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/OrangePaymentSlipData.php#L96-L106
train
ravage84/SwissPaymentSlip
src/OrangePaymentSlipData.php
OrangePaymentSlipData.getCompleteReferenceNumber
public function getCompleteReferenceNumber($formatted = true, $fillZeros = true) { $referenceNumber = $this->getReferenceNumber(); $notForPayment = $this->getNotForPayment(); $completeReferenceNumber = $referenceNumber; if ($notForPayment) { $completeReferenceNumber = str_pad($referenceNumber, 26, 'X', STR_PAD_LEFT); } elseif ($this->getWithBankingCustomerId()) { // Get reference number and fill with zeros $referenceNumber = str_pad($referenceNumber, 20, '0', STR_PAD_LEFT); // Prepend banking customer identification code $completeReferenceNumber = $this->getBankingCustomerId() . $referenceNumber; } elseif ($fillZeros) { // Get reference number and fill with zeros $completeReferenceNumber = str_pad($referenceNumber, 26, '0', STR_PAD_LEFT); } // Add check digit $completeReferenceNumber = $this->appendCheckDigit($completeReferenceNumber, $notForPayment); if ($formatted) { $completeReferenceNumber = $this->breakStringIntoBlocks($completeReferenceNumber); } return $completeReferenceNumber; }
php
public function getCompleteReferenceNumber($formatted = true, $fillZeros = true) { $referenceNumber = $this->getReferenceNumber(); $notForPayment = $this->getNotForPayment(); $completeReferenceNumber = $referenceNumber; if ($notForPayment) { $completeReferenceNumber = str_pad($referenceNumber, 26, 'X', STR_PAD_LEFT); } elseif ($this->getWithBankingCustomerId()) { // Get reference number and fill with zeros $referenceNumber = str_pad($referenceNumber, 20, '0', STR_PAD_LEFT); // Prepend banking customer identification code $completeReferenceNumber = $this->getBankingCustomerId() . $referenceNumber; } elseif ($fillZeros) { // Get reference number and fill with zeros $completeReferenceNumber = str_pad($referenceNumber, 26, '0', STR_PAD_LEFT); } // Add check digit $completeReferenceNumber = $this->appendCheckDigit($completeReferenceNumber, $notForPayment); if ($formatted) { $completeReferenceNumber = $this->breakStringIntoBlocks($completeReferenceNumber); } return $completeReferenceNumber; }
[ "public", "function", "getCompleteReferenceNumber", "(", "$", "formatted", "=", "true", ",", "$", "fillZeros", "=", "true", ")", "{", "$", "referenceNumber", "=", "$", "this", "->", "getReferenceNumber", "(", ")", ";", "$", "notForPayment", "=", "$", "this", "->", "getNotForPayment", "(", ")", ";", "$", "completeReferenceNumber", "=", "$", "referenceNumber", ";", "if", "(", "$", "notForPayment", ")", "{", "$", "completeReferenceNumber", "=", "str_pad", "(", "$", "referenceNumber", ",", "26", ",", "'X'", ",", "STR_PAD_LEFT", ")", ";", "}", "elseif", "(", "$", "this", "->", "getWithBankingCustomerId", "(", ")", ")", "{", "// Get reference number and fill with zeros", "$", "referenceNumber", "=", "str_pad", "(", "$", "referenceNumber", ",", "20", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "// Prepend banking customer identification code", "$", "completeReferenceNumber", "=", "$", "this", "->", "getBankingCustomerId", "(", ")", ".", "$", "referenceNumber", ";", "}", "elseif", "(", "$", "fillZeros", ")", "{", "// Get reference number and fill with zeros", "$", "completeReferenceNumber", "=", "str_pad", "(", "$", "referenceNumber", ",", "26", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "}", "// Add check digit", "$", "completeReferenceNumber", "=", "$", "this", "->", "appendCheckDigit", "(", "$", "completeReferenceNumber", ",", "$", "notForPayment", ")", ";", "if", "(", "$", "formatted", ")", "{", "$", "completeReferenceNumber", "=", "$", "this", "->", "breakStringIntoBlocks", "(", "$", "completeReferenceNumber", ")", ";", "}", "return", "$", "completeReferenceNumber", ";", "}" ]
Get complete reference number @param bool $formatted Should the returned reference be formatted in blocks of five (for better readability). @param bool $fillZeros Fill up with leading zeros, only applies to the case where no banking customer ID is used. @return string The complete (with/without bank customer ID), formatted reference number with check digit
[ "Get", "complete", "reference", "number" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/OrangePaymentSlipData.php#L213-L239
train
ravage84/SwissPaymentSlip
src/OrangePaymentSlipData.php
OrangePaymentSlipData.appendCheckDigit
protected function appendCheckDigit($referenceNumber, $notForPayment = false) { if ($notForPayment === true) { return $referenceNumber . 'X'; } return $referenceNumber . $this->modulo10($referenceNumber); }
php
protected function appendCheckDigit($referenceNumber, $notForPayment = false) { if ($notForPayment === true) { return $referenceNumber . 'X'; } return $referenceNumber . $this->modulo10($referenceNumber); }
[ "protected", "function", "appendCheckDigit", "(", "$", "referenceNumber", ",", "$", "notForPayment", "=", "false", ")", "{", "if", "(", "$", "notForPayment", "===", "true", ")", "{", "return", "$", "referenceNumber", ".", "'X'", ";", "}", "return", "$", "referenceNumber", ".", "$", "this", "->", "modulo10", "(", "$", "referenceNumber", ")", ";", "}" ]
Append the check digit to the reference number Simply appends an 'X' if the slip is not meant for payment. @param string $referenceNumber The reference number to calculate the prefix with. @param bool $notForPayment Whether the payment slip is not ment for payment. @return string The reference number with the appended check digit.
[ "Append", "the", "check", "digit", "to", "the", "reference", "number" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/OrangePaymentSlipData.php#L250-L256
train
ravage84/SwissPaymentSlip
src/OrangePaymentSlipData.php
OrangePaymentSlipData.getCodeLine
public function getCodeLine($fillZeros = true) { $referenceNumber = $this->getCompleteReferenceNumber(false, $fillZeros); $accountNumber = $this->getAccountDigits(); if ($this->getWithAmount()) { $francs = $this->getAmountFrancs(); $cents = $this->getAmountCents(); $francs = str_pad($francs, 8, '0', STR_PAD_LEFT); $cents = str_pad($cents, 2, '0', STR_PAD_RIGHT); $amountPrefix = '01'; $amountPart = $francs . $cents; $amountCheck = $this->modulo10($amountPrefix . $amountPart); } else { $amountPrefix = '04'; $amountPart = ''; $amountCheck = '2'; } if ($fillZeros) { $referenceNumberPart = str_pad($referenceNumber, 27, '0', STR_PAD_LEFT); } else { $referenceNumberPart = $referenceNumber; } $accountNumberPart = substr($accountNumber, 0, 2) . str_pad(substr($accountNumber, 2), 7, '0', STR_PAD_LEFT); if ($this->getNotForPayment()) { $amountPrefix = 'XX'; $amountCheck = 'X'; } $codeLine = sprintf( '%s%s%s>%s+ %s>', $amountPrefix, $amountPart, $amountCheck, $referenceNumberPart, $accountNumberPart ); return $codeLine; }
php
public function getCodeLine($fillZeros = true) { $referenceNumber = $this->getCompleteReferenceNumber(false, $fillZeros); $accountNumber = $this->getAccountDigits(); if ($this->getWithAmount()) { $francs = $this->getAmountFrancs(); $cents = $this->getAmountCents(); $francs = str_pad($francs, 8, '0', STR_PAD_LEFT); $cents = str_pad($cents, 2, '0', STR_PAD_RIGHT); $amountPrefix = '01'; $amountPart = $francs . $cents; $amountCheck = $this->modulo10($amountPrefix . $amountPart); } else { $amountPrefix = '04'; $amountPart = ''; $amountCheck = '2'; } if ($fillZeros) { $referenceNumberPart = str_pad($referenceNumber, 27, '0', STR_PAD_LEFT); } else { $referenceNumberPart = $referenceNumber; } $accountNumberPart = substr($accountNumber, 0, 2) . str_pad(substr($accountNumber, 2), 7, '0', STR_PAD_LEFT); if ($this->getNotForPayment()) { $amountPrefix = 'XX'; $amountCheck = 'X'; } $codeLine = sprintf( '%s%s%s>%s+ %s>', $amountPrefix, $amountPart, $amountCheck, $referenceNumberPart, $accountNumberPart ); return $codeLine; }
[ "public", "function", "getCodeLine", "(", "$", "fillZeros", "=", "true", ")", "{", "$", "referenceNumber", "=", "$", "this", "->", "getCompleteReferenceNumber", "(", "false", ",", "$", "fillZeros", ")", ";", "$", "accountNumber", "=", "$", "this", "->", "getAccountDigits", "(", ")", ";", "if", "(", "$", "this", "->", "getWithAmount", "(", ")", ")", "{", "$", "francs", "=", "$", "this", "->", "getAmountFrancs", "(", ")", ";", "$", "cents", "=", "$", "this", "->", "getAmountCents", "(", ")", ";", "$", "francs", "=", "str_pad", "(", "$", "francs", ",", "8", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "$", "cents", "=", "str_pad", "(", "$", "cents", ",", "2", ",", "'0'", ",", "STR_PAD_RIGHT", ")", ";", "$", "amountPrefix", "=", "'01'", ";", "$", "amountPart", "=", "$", "francs", ".", "$", "cents", ";", "$", "amountCheck", "=", "$", "this", "->", "modulo10", "(", "$", "amountPrefix", ".", "$", "amountPart", ")", ";", "}", "else", "{", "$", "amountPrefix", "=", "'04'", ";", "$", "amountPart", "=", "''", ";", "$", "amountCheck", "=", "'2'", ";", "}", "if", "(", "$", "fillZeros", ")", "{", "$", "referenceNumberPart", "=", "str_pad", "(", "$", "referenceNumber", ",", "27", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "}", "else", "{", "$", "referenceNumberPart", "=", "$", "referenceNumber", ";", "}", "$", "accountNumberPart", "=", "substr", "(", "$", "accountNumber", ",", "0", ",", "2", ")", ".", "str_pad", "(", "substr", "(", "$", "accountNumber", ",", "2", ")", ",", "7", ",", "'0'", ",", "STR_PAD_LEFT", ")", ";", "if", "(", "$", "this", "->", "getNotForPayment", "(", ")", ")", "{", "$", "amountPrefix", "=", "'XX'", ";", "$", "amountCheck", "=", "'X'", ";", "}", "$", "codeLine", "=", "sprintf", "(", "'%s%s%s>%s+ %s>'", ",", "$", "amountPrefix", ",", "$", "amountPart", ",", "$", "amountCheck", ",", "$", "referenceNumberPart", ",", "$", "accountNumberPart", ")", ";", "return", "$", "codeLine", ";", "}" ]
Get the full code line at the bottom of the ESR @param bool $fillZeros Whether to fill up the code line with leading zeros. @return string The full code line.
[ "Get", "the", "full", "code", "line", "at", "the", "bottom", "of", "the", "ESR" ]
3f5e23552e59ff486318c3af66b0374fa61a176f
https://github.com/ravage84/SwissPaymentSlip/blob/3f5e23552e59ff486318c3af66b0374fa61a176f/src/OrangePaymentSlipData.php#L264-L305
train
crisu83/yii-auth
components/AuthBehavior.php
AuthBehavior.getItems
public function getItems($itemName = null) { if ($itemName && isset($this->_items[$itemName])) { return $this->_items[$itemName]; } return $this->_items; }
php
public function getItems($itemName = null) { if ($itemName && isset($this->_items[$itemName])) { return $this->_items[$itemName]; } return $this->_items; }
[ "public", "function", "getItems", "(", "$", "itemName", "=", "null", ")", "{", "if", "(", "$", "itemName", "&&", "isset", "(", "$", "this", "->", "_items", "[", "$", "itemName", "]", ")", ")", "{", "return", "$", "this", "->", "_items", "[", "$", "itemName", "]", ";", "}", "return", "$", "this", "->", "_items", ";", "}" ]
Return thee parents and children of specific item or all items @param string $itemName name of the item. @return array
[ "Return", "thee", "parents", "and", "children", "of", "specific", "item", "or", "all", "items" ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthBehavior.php#L27-L34
train
crisu83/yii-auth
components/AuthBehavior.php
AuthBehavior.hasParent
public function hasParent($itemName, $parentName) { $parents = $this->getParents($itemName); if (in_array($parentName, $parents)) { return true; } return false; }
php
public function hasParent($itemName, $parentName) { $parents = $this->getParents($itemName); if (in_array($parentName, $parents)) { return true; } return false; }
[ "public", "function", "hasParent", "(", "$", "itemName", ",", "$", "parentName", ")", "{", "$", "parents", "=", "$", "this", "->", "getParents", "(", "$", "itemName", ")", ";", "if", "(", "in_array", "(", "$", "parentName", ",", "$", "parents", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns whether the given item has a specific parent. @param string $itemName name of the item. @param string $parentName name of the parent. @return boolean the result.
[ "Returns", "whether", "the", "given", "item", "has", "a", "specific", "parent", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthBehavior.php#L92-L99
train
crisu83/yii-auth
components/AuthBehavior.php
AuthBehavior.hasChild
public function hasChild($itemName, $childName) { $children = $this->getChildren($itemName); if (in_array($childName, $children)) { return true; } return false; }
php
public function hasChild($itemName, $childName) { $children = $this->getChildren($itemName); if (in_array($childName, $children)) { return true; } return false; }
[ "public", "function", "hasChild", "(", "$", "itemName", ",", "$", "childName", ")", "{", "$", "children", "=", "$", "this", "->", "getChildren", "(", "$", "itemName", ")", ";", "if", "(", "in_array", "(", "$", "childName", ",", "$", "children", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Returns whether the given item has a specific child. @param string $itemName name of the item. @param string $childName name of the child. @return boolean the result.
[ "Returns", "whether", "the", "given", "item", "has", "a", "specific", "child", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthBehavior.php#L107-L114
train
crisu83/yii-auth
components/AuthBehavior.php
AuthBehavior.hasAncestor
public function hasAncestor($itemName, $ancestorName) { $ancestors = $this->getAncestors($itemName); return isset($ancestors[$ancestorName]); }
php
public function hasAncestor($itemName, $ancestorName) { $ancestors = $this->getAncestors($itemName); return isset($ancestors[$ancestorName]); }
[ "public", "function", "hasAncestor", "(", "$", "itemName", ",", "$", "ancestorName", ")", "{", "$", "ancestors", "=", "$", "this", "->", "getAncestors", "(", "$", "itemName", ")", ";", "return", "isset", "(", "$", "ancestors", "[", "$", "ancestorName", "]", ")", ";", "}" ]
Returns whether the given item has a specific ancestor. @param string $itemName name of the item. @param string $ancestorName name of the ancestor. @return boolean the result.
[ "Returns", "whether", "the", "given", "item", "has", "a", "specific", "ancestor", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthBehavior.php#L122-L126
train
crisu83/yii-auth
components/AuthBehavior.php
AuthBehavior.hasDescendant
public function hasDescendant($itemName, $descendantName) { $descendants = $this->getDescendants($itemName); return isset($descendants[$descendantName]); }
php
public function hasDescendant($itemName, $descendantName) { $descendants = $this->getDescendants($itemName); return isset($descendants[$descendantName]); }
[ "public", "function", "hasDescendant", "(", "$", "itemName", ",", "$", "descendantName", ")", "{", "$", "descendants", "=", "$", "this", "->", "getDescendants", "(", "$", "itemName", ")", ";", "return", "isset", "(", "$", "descendants", "[", "$", "descendantName", "]", ")", ";", "}" ]
Returns whether the given item has a specific descendant. @param string $itemName name of the item. @param string $descendantName name of the descendant. @return boolean the result.
[ "Returns", "whether", "the", "given", "item", "has", "a", "specific", "descendant", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthBehavior.php#L134-L138
train
crisu83/yii-auth
components/AuthBehavior.php
AuthBehavior.getAncestor
public function getAncestor($itemName, $depth = 0) { $ancestors = array(); $parents = $this->getParents($itemName); if (empty($parents)) { $parents = $this->owner->db->createCommand() ->select('parent') ->from($this->owner->itemChildTable) ->where('child=:child', array(':child' => $itemName)) ->queryColumn(); $this->setItemParents($itemName, $parents); } foreach ($parents as $parent) { $ancestors[] = array( 'name' => $parent, 'item' => $this->owner->getAuthItem($parent), 'parents' => $this->getAncestor($parent, $depth + 1), 'depth' => $depth ); } return $ancestors; }
php
public function getAncestor($itemName, $depth = 0) { $ancestors = array(); $parents = $this->getParents($itemName); if (empty($parents)) { $parents = $this->owner->db->createCommand() ->select('parent') ->from($this->owner->itemChildTable) ->where('child=:child', array(':child' => $itemName)) ->queryColumn(); $this->setItemParents($itemName, $parents); } foreach ($parents as $parent) { $ancestors[] = array( 'name' => $parent, 'item' => $this->owner->getAuthItem($parent), 'parents' => $this->getAncestor($parent, $depth + 1), 'depth' => $depth ); } return $ancestors; }
[ "public", "function", "getAncestor", "(", "$", "itemName", ",", "$", "depth", "=", "0", ")", "{", "$", "ancestors", "=", "array", "(", ")", ";", "$", "parents", "=", "$", "this", "->", "getParents", "(", "$", "itemName", ")", ";", "if", "(", "empty", "(", "$", "parents", ")", ")", "{", "$", "parents", "=", "$", "this", "->", "owner", "->", "db", "->", "createCommand", "(", ")", "->", "select", "(", "'parent'", ")", "->", "from", "(", "$", "this", "->", "owner", "->", "itemChildTable", ")", "->", "where", "(", "'child=:child'", ",", "array", "(", "':child'", "=>", "$", "itemName", ")", ")", "->", "queryColumn", "(", ")", ";", "$", "this", "->", "setItemParents", "(", "$", "itemName", ",", "$", "parents", ")", ";", "}", "foreach", "(", "$", "parents", "as", "$", "parent", ")", "{", "$", "ancestors", "[", "]", "=", "array", "(", "'name'", "=>", "$", "parent", ",", "'item'", "=>", "$", "this", "->", "owner", "->", "getAuthItem", "(", "$", "parent", ")", ",", "'parents'", "=>", "$", "this", "->", "getAncestor", "(", "$", "parent", ",", "$", "depth", "+", "1", ")", ",", "'depth'", "=>", "$", "depth", ")", ";", "}", "return", "$", "ancestors", ";", "}" ]
Returns all ancestors for the given item recursively. @param string $itemName name of the item. @param integer $depth current depth. @return array the ancestors.
[ "Returns", "all", "ancestors", "for", "the", "given", "item", "recursively", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthBehavior.php#L157-L179
train
crisu83/yii-auth
components/AuthBehavior.php
AuthBehavior.getDescendant
public function getDescendant($itemName, $depth = 0) { $descendants = array(); $children = $this->getChildren($itemName); if (empty($children)) { $children = $this->owner->db->createCommand() ->select('child') ->from($this->owner->itemChildTable) ->where('parent=:parent', array(':parent' => $itemName)) ->queryColumn(); $this->setItemChildren($itemName, $children); } foreach ($children as $child) { $descendants[$child] = array( 'name' => $child, 'item' => $this->owner->getAuthItem($child), 'children' => $this->getDescendant($child, $depth + 1), 'depth' => $depth, ); } return $descendants; }
php
public function getDescendant($itemName, $depth = 0) { $descendants = array(); $children = $this->getChildren($itemName); if (empty($children)) { $children = $this->owner->db->createCommand() ->select('child') ->from($this->owner->itemChildTable) ->where('parent=:parent', array(':parent' => $itemName)) ->queryColumn(); $this->setItemChildren($itemName, $children); } foreach ($children as $child) { $descendants[$child] = array( 'name' => $child, 'item' => $this->owner->getAuthItem($child), 'children' => $this->getDescendant($child, $depth + 1), 'depth' => $depth, ); } return $descendants; }
[ "public", "function", "getDescendant", "(", "$", "itemName", ",", "$", "depth", "=", "0", ")", "{", "$", "descendants", "=", "array", "(", ")", ";", "$", "children", "=", "$", "this", "->", "getChildren", "(", "$", "itemName", ")", ";", "if", "(", "empty", "(", "$", "children", ")", ")", "{", "$", "children", "=", "$", "this", "->", "owner", "->", "db", "->", "createCommand", "(", ")", "->", "select", "(", "'child'", ")", "->", "from", "(", "$", "this", "->", "owner", "->", "itemChildTable", ")", "->", "where", "(", "'parent=:parent'", ",", "array", "(", "':parent'", "=>", "$", "itemName", ")", ")", "->", "queryColumn", "(", ")", ";", "$", "this", "->", "setItemChildren", "(", "$", "itemName", ",", "$", "children", ")", ";", "}", "foreach", "(", "$", "children", "as", "$", "child", ")", "{", "$", "descendants", "[", "$", "child", "]", "=", "array", "(", "'name'", "=>", "$", "child", ",", "'item'", "=>", "$", "this", "->", "owner", "->", "getAuthItem", "(", "$", "child", ")", ",", "'children'", "=>", "$", "this", "->", "getDescendant", "(", "$", "child", ",", "$", "depth", "+", "1", ")", ",", "'depth'", "=>", "$", "depth", ",", ")", ";", "}", "return", "$", "descendants", ";", "}" ]
Returns all the descendants for the given item recursively. @param string $itemName name of the item. @param integer $depth current depth. @return array the descendants.
[ "Returns", "all", "the", "descendants", "for", "the", "given", "item", "recursively", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthBehavior.php#L198-L220
train
crisu83/yii-auth
components/AuthBehavior.php
AuthBehavior.getPermissions
private function getPermissions($items = null, $depth = 0) { $permissions = array(); if ($items === null) { $items = $this->owner->getAuthItems(); } foreach ($items as $itemName => $item) { $permissions[$itemName] = array( 'name' => $itemName, 'item' => $item, 'children' => $this->getPermissions($item, $depth + 1), 'depth' => $depth, ); } return $permissions; }
php
private function getPermissions($items = null, $depth = 0) { $permissions = array(); if ($items === null) { $items = $this->owner->getAuthItems(); } foreach ($items as $itemName => $item) { $permissions[$itemName] = array( 'name' => $itemName, 'item' => $item, 'children' => $this->getPermissions($item, $depth + 1), 'depth' => $depth, ); } return $permissions; }
[ "private", "function", "getPermissions", "(", "$", "items", "=", "null", ",", "$", "depth", "=", "0", ")", "{", "$", "permissions", "=", "array", "(", ")", ";", "if", "(", "$", "items", "===", "null", ")", "{", "$", "items", "=", "$", "this", "->", "owner", "->", "getAuthItems", "(", ")", ";", "}", "foreach", "(", "$", "items", "as", "$", "itemName", "=>", "$", "item", ")", "{", "$", "permissions", "[", "$", "itemName", "]", "=", "array", "(", "'name'", "=>", "$", "itemName", ",", "'item'", "=>", "$", "item", ",", "'children'", "=>", "$", "this", "->", "getPermissions", "(", "$", "item", ",", "$", "depth", "+", "1", ")", ",", "'depth'", "=>", "$", "depth", ",", ")", ";", "}", "return", "$", "permissions", ";", "}" ]
Returns the permission tree for the given items. @param CAuthItem[] $items items to process. If omitted the complete tree will be returned. @param integer $depth current depth. @return array the permissions.
[ "Returns", "the", "permission", "tree", "for", "the", "given", "items", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthBehavior.php#L228-L246
train
crisu83/yii-auth
components/AuthBehavior.php
AuthBehavior.getItemPermissions
private function getItemPermissions($itemName) { $item = $this->owner->getAuthItem($itemName); return $item instanceof CAuthItem ? $this->getPermissions($item->getChildren()) : array(); }
php
private function getItemPermissions($itemName) { $item = $this->owner->getAuthItem($itemName); return $item instanceof CAuthItem ? $this->getPermissions($item->getChildren()) : array(); }
[ "private", "function", "getItemPermissions", "(", "$", "itemName", ")", "{", "$", "item", "=", "$", "this", "->", "owner", "->", "getAuthItem", "(", "$", "itemName", ")", ";", "return", "$", "item", "instanceof", "CAuthItem", "?", "$", "this", "->", "getPermissions", "(", "$", "item", "->", "getChildren", "(", ")", ")", ":", "array", "(", ")", ";", "}" ]
Builds the permissions for the given item. @param string $itemName name of the item. @return array the permissions.
[ "Builds", "the", "permissions", "for", "the", "given", "item", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthBehavior.php#L253-L257
train
crisu83/yii-auth
components/AuthBehavior.php
AuthBehavior.getItemsPermissions
public function getItemsPermissions($names) { $permissions = array(); $items = $this->getPermissions(); $flat = $this->flattenPermissions($items); foreach ($flat as $itemName => $item) { if (in_array($itemName, $names)) { $permissions[$itemName] = $item; } } return $permissions; }
php
public function getItemsPermissions($names) { $permissions = array(); $items = $this->getPermissions(); $flat = $this->flattenPermissions($items); foreach ($flat as $itemName => $item) { if (in_array($itemName, $names)) { $permissions[$itemName] = $item; } } return $permissions; }
[ "public", "function", "getItemsPermissions", "(", "$", "names", ")", "{", "$", "permissions", "=", "array", "(", ")", ";", "$", "items", "=", "$", "this", "->", "getPermissions", "(", ")", ";", "$", "flat", "=", "$", "this", "->", "flattenPermissions", "(", "$", "items", ")", ";", "foreach", "(", "$", "flat", "as", "$", "itemName", "=>", "$", "item", ")", "{", "if", "(", "in_array", "(", "$", "itemName", ",", "$", "names", ")", ")", "{", "$", "permissions", "[", "$", "itemName", "]", "=", "$", "item", ";", "}", "}", "return", "$", "permissions", ";", "}" ]
Returns the permissions for the items with the given names. @param string[] $names list of item names. @return array the permissions.
[ "Returns", "the", "permissions", "for", "the", "items", "with", "the", "given", "names", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthBehavior.php#L264-L278
train
crisu83/yii-auth
components/AuthBehavior.php
AuthBehavior.flattenPermissions
public function flattenPermissions($permissions) { $flattened = array(); foreach ($permissions as $itemName => $itemPermissions) { $flattened[$itemName] = $itemPermissions; if (isset($itemPermissions['children'])) { $children = $itemPermissions['children']; unset($itemPermissions['children']); // not needed in a flat tree $flattened = array_merge($flattened, $this->flattenPermissions($children)); } if (isset($itemPermissions['parents'])) { $parents = $itemPermissions['parents']; unset($itemPermissions['parents']); $flattened = array_merge($flattened, $this->flattenPermissions($parents)); } } return $flattened; }
php
public function flattenPermissions($permissions) { $flattened = array(); foreach ($permissions as $itemName => $itemPermissions) { $flattened[$itemName] = $itemPermissions; if (isset($itemPermissions['children'])) { $children = $itemPermissions['children']; unset($itemPermissions['children']); // not needed in a flat tree $flattened = array_merge($flattened, $this->flattenPermissions($children)); } if (isset($itemPermissions['parents'])) { $parents = $itemPermissions['parents']; unset($itemPermissions['parents']); $flattened = array_merge($flattened, $this->flattenPermissions($parents)); } } return $flattened; }
[ "public", "function", "flattenPermissions", "(", "$", "permissions", ")", "{", "$", "flattened", "=", "array", "(", ")", ";", "foreach", "(", "$", "permissions", "as", "$", "itemName", "=>", "$", "itemPermissions", ")", "{", "$", "flattened", "[", "$", "itemName", "]", "=", "$", "itemPermissions", ";", "if", "(", "isset", "(", "$", "itemPermissions", "[", "'children'", "]", ")", ")", "{", "$", "children", "=", "$", "itemPermissions", "[", "'children'", "]", ";", "unset", "(", "$", "itemPermissions", "[", "'children'", "]", ")", ";", "// not needed in a flat tree", "$", "flattened", "=", "array_merge", "(", "$", "flattened", ",", "$", "this", "->", "flattenPermissions", "(", "$", "children", ")", ")", ";", "}", "if", "(", "isset", "(", "$", "itemPermissions", "[", "'parents'", "]", ")", ")", "{", "$", "parents", "=", "$", "itemPermissions", "[", "'parents'", "]", ";", "unset", "(", "$", "itemPermissions", "[", "'parents'", "]", ")", ";", "$", "flattened", "=", "array_merge", "(", "$", "flattened", ",", "$", "this", "->", "flattenPermissions", "(", "$", "parents", ")", ")", ";", "}", "}", "return", "$", "flattened", ";", "}" ]
Flattens the given permission tree. @param array $permissions the permissions tree. @return array the permissions.
[ "Flattens", "the", "given", "permission", "tree", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthBehavior.php#L285-L304
train
crisu83/yii-auth
components/AuthWebUser.php
AuthWebUser.checkAccess
public function checkAccess($operation, $params = array(), $allowCaching = true) { if ($this->getIsAdmin()) { return true; } return parent::checkAccess($operation, $params, $allowCaching); }
php
public function checkAccess($operation, $params = array(), $allowCaching = true) { if ($this->getIsAdmin()) { return true; } return parent::checkAccess($operation, $params, $allowCaching); }
[ "public", "function", "checkAccess", "(", "$", "operation", ",", "$", "params", "=", "array", "(", ")", ",", "$", "allowCaching", "=", "true", ")", "{", "if", "(", "$", "this", "->", "getIsAdmin", "(", ")", ")", "{", "return", "true", ";", "}", "return", "parent", "::", "checkAccess", "(", "$", "operation", ",", "$", "params", ",", "$", "allowCaching", ")", ";", "}" ]
Performs access check for this user. @param string $operation the name of the operation that need access check. @param array $params name-value pairs that would be passed to business rules associated with the tasks and roles assigned to the user. @param boolean $allowCaching whether to allow caching the result of access check. @return boolean whether the operations can be performed by this user.
[ "Performs", "access", "check", "for", "this", "user", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/components/AuthWebUser.php#L57-L64
train
rdohms/dms-filter
src/DMS/Filter/Filter.php
Filter.walkObject
protected function walkObject($object, $limitProperty = null) { if ($object === null) { return; } $metadata = $this->metadataFactory->getClassMetadata(get_class($object)); //Get a Object Handler/Walker $walker = new ObjectWalker($object, $this->filterLoader); //Get all filtered properties or limit with selected $properties = ($limitProperty !== null) ? array($limitProperty) : $metadata->getFilteredProperties(); //Iterate over properties with filters foreach ($properties as $property) { $walker->applyFilterRules($property, $metadata->getPropertyRules($property)); } }
php
protected function walkObject($object, $limitProperty = null) { if ($object === null) { return; } $metadata = $this->metadataFactory->getClassMetadata(get_class($object)); //Get a Object Handler/Walker $walker = new ObjectWalker($object, $this->filterLoader); //Get all filtered properties or limit with selected $properties = ($limitProperty !== null) ? array($limitProperty) : $metadata->getFilteredProperties(); //Iterate over properties with filters foreach ($properties as $property) { $walker->applyFilterRules($property, $metadata->getPropertyRules($property)); } }
[ "protected", "function", "walkObject", "(", "$", "object", ",", "$", "limitProperty", "=", "null", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "return", ";", "}", "$", "metadata", "=", "$", "this", "->", "metadataFactory", "->", "getClassMetadata", "(", "get_class", "(", "$", "object", ")", ")", ";", "//Get a Object Handler/Walker", "$", "walker", "=", "new", "ObjectWalker", "(", "$", "object", ",", "$", "this", "->", "filterLoader", ")", ";", "//Get all filtered properties or limit with selected", "$", "properties", "=", "(", "$", "limitProperty", "!==", "null", ")", "?", "array", "(", "$", "limitProperty", ")", ":", "$", "metadata", "->", "getFilteredProperties", "(", ")", ";", "//Iterate over properties with filters", "foreach", "(", "$", "properties", "as", "$", "property", ")", "{", "$", "walker", "->", "applyFilterRules", "(", "$", "property", ",", "$", "metadata", "->", "getPropertyRules", "(", "$", "property", ")", ")", ";", "}", "}" ]
Iterates over annotated properties in an object filtering the selected values @param object $object @param string $limitProperty
[ "Iterates", "over", "annotated", "properties", "in", "an", "object", "filtering", "the", "selected", "values" ]
3eb0942a68fa023e0d7378fa825447e7a47219b1
https://github.com/rdohms/dms-filter/blob/3eb0942a68fa023e0d7378fa825447e7a47219b1/src/DMS/Filter/Filter.php#L91-L109
train
crisu83/yii-auth
controllers/AuthItemController.php
AuthItemController.actionIndex
public function actionIndex() { $dataProvider = new AuthItemDataProvider(); $dataProvider->type = $this->type; $this->render( 'index', array( 'dataProvider' => $dataProvider, ) ); }
php
public function actionIndex() { $dataProvider = new AuthItemDataProvider(); $dataProvider->type = $this->type; $this->render( 'index', array( 'dataProvider' => $dataProvider, ) ); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "dataProvider", "=", "new", "AuthItemDataProvider", "(", ")", ";", "$", "dataProvider", "->", "type", "=", "$", "this", "->", "type", ";", "$", "this", "->", "render", "(", "'index'", ",", "array", "(", "'dataProvider'", "=>", "$", "dataProvider", ",", ")", ")", ";", "}" ]
Displays a list of items of the given type.
[ "Displays", "a", "list", "of", "items", "of", "the", "given", "type", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/controllers/AuthItemController.php#L23-L34
train
crisu83/yii-auth
controllers/AuthItemController.php
AuthItemController.actionCreate
public function actionCreate() { $model = new AuthItemForm('create'); if (isset($_POST['AuthItemForm'])) { $model->attributes = $_POST['AuthItemForm']; if ($model->validate()) { /* @var $am CAuthManager|AuthBehavior */ $am = Yii::app()->getAuthManager(); if (($item = $am->getAuthItem($model->name)) === null) { $item = $am->createAuthItem($model->name, $model->type, $model->description); if ($am instanceof CPhpAuthManager) { $am->save(); } } $this->redirect(array('view', 'name' => $item->name)); } } $model->type = $this->type; $this->render( 'create', array( 'model' => $model, ) ); }
php
public function actionCreate() { $model = new AuthItemForm('create'); if (isset($_POST['AuthItemForm'])) { $model->attributes = $_POST['AuthItemForm']; if ($model->validate()) { /* @var $am CAuthManager|AuthBehavior */ $am = Yii::app()->getAuthManager(); if (($item = $am->getAuthItem($model->name)) === null) { $item = $am->createAuthItem($model->name, $model->type, $model->description); if ($am instanceof CPhpAuthManager) { $am->save(); } } $this->redirect(array('view', 'name' => $item->name)); } } $model->type = $this->type; $this->render( 'create', array( 'model' => $model, ) ); }
[ "public", "function", "actionCreate", "(", ")", "{", "$", "model", "=", "new", "AuthItemForm", "(", "'create'", ")", ";", "if", "(", "isset", "(", "$", "_POST", "[", "'AuthItemForm'", "]", ")", ")", "{", "$", "model", "->", "attributes", "=", "$", "_POST", "[", "'AuthItemForm'", "]", ";", "if", "(", "$", "model", "->", "validate", "(", ")", ")", "{", "/* @var $am CAuthManager|AuthBehavior */", "$", "am", "=", "Yii", "::", "app", "(", ")", "->", "getAuthManager", "(", ")", ";", "if", "(", "(", "$", "item", "=", "$", "am", "->", "getAuthItem", "(", "$", "model", "->", "name", ")", ")", "===", "null", ")", "{", "$", "item", "=", "$", "am", "->", "createAuthItem", "(", "$", "model", "->", "name", ",", "$", "model", "->", "type", ",", "$", "model", "->", "description", ")", ";", "if", "(", "$", "am", "instanceof", "CPhpAuthManager", ")", "{", "$", "am", "->", "save", "(", ")", ";", "}", "}", "$", "this", "->", "redirect", "(", "array", "(", "'view'", ",", "'name'", "=>", "$", "item", "->", "name", ")", ")", ";", "}", "}", "$", "model", "->", "type", "=", "$", "this", "->", "type", ";", "$", "this", "->", "render", "(", "'create'", ",", "array", "(", "'model'", "=>", "$", "model", ",", ")", ")", ";", "}" ]
Displays a form for creating a new item of the given type.
[ "Displays", "a", "form", "for", "creating", "a", "new", "item", "of", "the", "given", "type", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/controllers/AuthItemController.php#L39-L68
train
crisu83/yii-auth
controllers/AuthItemController.php
AuthItemController.actionUpdate
public function actionUpdate($name) { /* @var $am CAuthManager|AuthBehavior */ $am = Yii::app()->getAuthManager(); $item = $am->getAuthItem($name); if ($item === null) { throw new CHttpException(404, Yii::t('AuthModule.main', 'Page not found.')); } $model = new AuthItemForm('update'); if (isset($_POST['AuthItemForm'])) { $model->attributes = $_POST['AuthItemForm']; if ($model->validate()) { $item->description = $model->description; $am->saveAuthItem($item); if ($am instanceof CPhpAuthManager) { $am->save(); } $this->redirect(array('index')); } } $model->name = $name; $model->description = $item->description; $model->type = $item->type; $this->render( 'update', array( 'item' => $item, 'model' => $model, ) ); }
php
public function actionUpdate($name) { /* @var $am CAuthManager|AuthBehavior */ $am = Yii::app()->getAuthManager(); $item = $am->getAuthItem($name); if ($item === null) { throw new CHttpException(404, Yii::t('AuthModule.main', 'Page not found.')); } $model = new AuthItemForm('update'); if (isset($_POST['AuthItemForm'])) { $model->attributes = $_POST['AuthItemForm']; if ($model->validate()) { $item->description = $model->description; $am->saveAuthItem($item); if ($am instanceof CPhpAuthManager) { $am->save(); } $this->redirect(array('index')); } } $model->name = $name; $model->description = $item->description; $model->type = $item->type; $this->render( 'update', array( 'item' => $item, 'model' => $model, ) ); }
[ "public", "function", "actionUpdate", "(", "$", "name", ")", "{", "/* @var $am CAuthManager|AuthBehavior */", "$", "am", "=", "Yii", "::", "app", "(", ")", "->", "getAuthManager", "(", ")", ";", "$", "item", "=", "$", "am", "->", "getAuthItem", "(", "$", "name", ")", ";", "if", "(", "$", "item", "===", "null", ")", "{", "throw", "new", "CHttpException", "(", "404", ",", "Yii", "::", "t", "(", "'AuthModule.main'", ",", "'Page not found.'", ")", ")", ";", "}", "$", "model", "=", "new", "AuthItemForm", "(", "'update'", ")", ";", "if", "(", "isset", "(", "$", "_POST", "[", "'AuthItemForm'", "]", ")", ")", "{", "$", "model", "->", "attributes", "=", "$", "_POST", "[", "'AuthItemForm'", "]", ";", "if", "(", "$", "model", "->", "validate", "(", ")", ")", "{", "$", "item", "->", "description", "=", "$", "model", "->", "description", ";", "$", "am", "->", "saveAuthItem", "(", "$", "item", ")", ";", "if", "(", "$", "am", "instanceof", "CPhpAuthManager", ")", "{", "$", "am", "->", "save", "(", ")", ";", "}", "$", "this", "->", "redirect", "(", "array", "(", "'index'", ")", ")", ";", "}", "}", "$", "model", "->", "name", "=", "$", "name", ";", "$", "model", "->", "description", "=", "$", "item", "->", "description", ";", "$", "model", "->", "type", "=", "$", "item", "->", "type", ";", "$", "this", "->", "render", "(", "'update'", ",", "array", "(", "'item'", "=>", "$", "item", ",", "'model'", "=>", "$", "model", ",", ")", ")", ";", "}" ]
Displays a form for updating the item with the given name. @param string $name name of the item. @throws CHttpException if the authorization item is not found.
[ "Displays", "a", "form", "for", "updating", "the", "item", "with", "the", "given", "name", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/controllers/AuthItemController.php#L75-L113
train
crisu83/yii-auth
controllers/AuthItemController.php
AuthItemController.actionView
public function actionView($name) { $formModel = new AddAuthItemForm(); /* @var $am CAuthManager|AuthBehavior */ $am = Yii::app()->getAuthManager(); if (isset($_POST['AddAuthItemForm'])) { $formModel->attributes = $_POST['AddAuthItemForm']; if ($formModel->validate()) { if (!$am->hasItemChild($name, $formModel->items)) { $am->addItemChild($name, $formModel->items); if ($am instanceof CPhpAuthManager) { $am->save(); } } } } $item = $am->getAuthItem($name); $dpConfig = array( 'pagination' => false, 'sort' => array('defaultOrder' => 'depth asc'), ); $ancestors = $am->getAncestors($name); $ancestorDp = new PermissionDataProvider(array_values($ancestors), $dpConfig); $descendants = $am->getDescendants($name); $descendantDp = new PermissionDataProvider(array_values($descendants), $dpConfig); $childOptions = $this->getItemChildOptions($item->name); if (!empty($childOptions)) { $childOptions = array_merge(array('' => Yii::t('AuthModule.main', 'Select item') . ' ...'), $childOptions); } $this->render( 'view', array( 'item' => $item, 'ancestorDp' => $ancestorDp, 'descendantDp' => $descendantDp, 'formModel' => $formModel, 'childOptions' => $childOptions, ) ); }
php
public function actionView($name) { $formModel = new AddAuthItemForm(); /* @var $am CAuthManager|AuthBehavior */ $am = Yii::app()->getAuthManager(); if (isset($_POST['AddAuthItemForm'])) { $formModel->attributes = $_POST['AddAuthItemForm']; if ($formModel->validate()) { if (!$am->hasItemChild($name, $formModel->items)) { $am->addItemChild($name, $formModel->items); if ($am instanceof CPhpAuthManager) { $am->save(); } } } } $item = $am->getAuthItem($name); $dpConfig = array( 'pagination' => false, 'sort' => array('defaultOrder' => 'depth asc'), ); $ancestors = $am->getAncestors($name); $ancestorDp = new PermissionDataProvider(array_values($ancestors), $dpConfig); $descendants = $am->getDescendants($name); $descendantDp = new PermissionDataProvider(array_values($descendants), $dpConfig); $childOptions = $this->getItemChildOptions($item->name); if (!empty($childOptions)) { $childOptions = array_merge(array('' => Yii::t('AuthModule.main', 'Select item') . ' ...'), $childOptions); } $this->render( 'view', array( 'item' => $item, 'ancestorDp' => $ancestorDp, 'descendantDp' => $descendantDp, 'formModel' => $formModel, 'childOptions' => $childOptions, ) ); }
[ "public", "function", "actionView", "(", "$", "name", ")", "{", "$", "formModel", "=", "new", "AddAuthItemForm", "(", ")", ";", "/* @var $am CAuthManager|AuthBehavior */", "$", "am", "=", "Yii", "::", "app", "(", ")", "->", "getAuthManager", "(", ")", ";", "if", "(", "isset", "(", "$", "_POST", "[", "'AddAuthItemForm'", "]", ")", ")", "{", "$", "formModel", "->", "attributes", "=", "$", "_POST", "[", "'AddAuthItemForm'", "]", ";", "if", "(", "$", "formModel", "->", "validate", "(", ")", ")", "{", "if", "(", "!", "$", "am", "->", "hasItemChild", "(", "$", "name", ",", "$", "formModel", "->", "items", ")", ")", "{", "$", "am", "->", "addItemChild", "(", "$", "name", ",", "$", "formModel", "->", "items", ")", ";", "if", "(", "$", "am", "instanceof", "CPhpAuthManager", ")", "{", "$", "am", "->", "save", "(", ")", ";", "}", "}", "}", "}", "$", "item", "=", "$", "am", "->", "getAuthItem", "(", "$", "name", ")", ";", "$", "dpConfig", "=", "array", "(", "'pagination'", "=>", "false", ",", "'sort'", "=>", "array", "(", "'defaultOrder'", "=>", "'depth asc'", ")", ",", ")", ";", "$", "ancestors", "=", "$", "am", "->", "getAncestors", "(", "$", "name", ")", ";", "$", "ancestorDp", "=", "new", "PermissionDataProvider", "(", "array_values", "(", "$", "ancestors", ")", ",", "$", "dpConfig", ")", ";", "$", "descendants", "=", "$", "am", "->", "getDescendants", "(", "$", "name", ")", ";", "$", "descendantDp", "=", "new", "PermissionDataProvider", "(", "array_values", "(", "$", "descendants", ")", ",", "$", "dpConfig", ")", ";", "$", "childOptions", "=", "$", "this", "->", "getItemChildOptions", "(", "$", "item", "->", "name", ")", ";", "if", "(", "!", "empty", "(", "$", "childOptions", ")", ")", "{", "$", "childOptions", "=", "array_merge", "(", "array", "(", "''", "=>", "Yii", "::", "t", "(", "'AuthModule.main'", ",", "'Select item'", ")", ".", "' ...'", ")", ",", "$", "childOptions", ")", ";", "}", "$", "this", "->", "render", "(", "'view'", ",", "array", "(", "'item'", "=>", "$", "item", ",", "'ancestorDp'", "=>", "$", "ancestorDp", ",", "'descendantDp'", "=>", "$", "descendantDp", ",", "'formModel'", "=>", "$", "formModel", ",", "'childOptions'", "=>", "$", "childOptions", ",", ")", ")", ";", "}" ]
Displays the item with the given name. @param string $name name of the item.
[ "Displays", "the", "item", "with", "the", "given", "name", "." ]
c1b9108a41f78a46c77e073866410d10e283ac9a
https://github.com/crisu83/yii-auth/blob/c1b9108a41f78a46c77e073866410d10e283ac9a/controllers/AuthItemController.php#L119-L166
train