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
grrr-amsterdam/garp3
library/Garp/Spawn/MySql/Table/Factory.php
Garp_Spawn_MySql_Table_Factory._renderCreateAbstract
protected function _renderCreateAbstract($tableName, array $fields, array $relations, $unique) { $lines = array(); foreach ($fields as $field) { $lines[] = Garp_Spawn_MySql_Column::renderFieldSql($field); } $primKeys = array(); $uniqueKeys = array(); if ($unique) { // This checks wether a single one-dimensional array is given: a collection of // columns combined into a unique key, or wether an array of arrays is given, meaning // multiple collections of columns combining into multiple unique keys per table. $isArrayOfArrays = count(array_filter($unique, 'is_array')) === count($unique); $unique = !$isArrayOfArrays ? array($unique) : $unique; $uniqueKeys = array_merge($uniqueKeys, $unique); } foreach ($fields as $field) { if ($field->primary) $primKeys[] = $field->name; if ($field->unique) $uniqueKeys[] = $field->name; } if ($primKeys) { $lines[] = Garp_Spawn_MySql_PrimaryKey::renderSqlDefinition($primKeys); } foreach ($uniqueKeys as $fieldName) { $lines[] = Garp_Spawn_MySql_UniqueKey::renderSqlDefinition($fieldName); } foreach ($relations as $rel) { if (($rel->type === 'hasOne' || $rel->type === 'belongsTo') && !$rel->multilingual) { $lines[] = Garp_Spawn_MySql_IndexKey::renderSqlDefinition($rel->column); } } // set indices that were configured in the Spawn model config foreach ($fields as $field) { if ($field->index) { $lines[] = Garp_Spawn_MySql_IndexKey::renderSqlDefinition($field->name); } } foreach ($relations as $relName => $rel) { if (($rel->type === 'hasOne' || $rel->type === 'belongsTo') && !$rel->multilingual) { $fkName = Garp_Spawn_MySql_ForeignKey::generateForeignKeyName($tableName, $relName); $lines[] = Garp_Spawn_MySql_ForeignKey::renderSqlDefinition( $fkName, $rel->column, $rel->model, $rel->type ); } } $out = "CREATE TABLE `{$tableName}` (\n"; $out.= implode(",\n", $lines); $out.= "\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; return $out; }
php
protected function _renderCreateAbstract($tableName, array $fields, array $relations, $unique) { $lines = array(); foreach ($fields as $field) { $lines[] = Garp_Spawn_MySql_Column::renderFieldSql($field); } $primKeys = array(); $uniqueKeys = array(); if ($unique) { // This checks wether a single one-dimensional array is given: a collection of // columns combined into a unique key, or wether an array of arrays is given, meaning // multiple collections of columns combining into multiple unique keys per table. $isArrayOfArrays = count(array_filter($unique, 'is_array')) === count($unique); $unique = !$isArrayOfArrays ? array($unique) : $unique; $uniqueKeys = array_merge($uniqueKeys, $unique); } foreach ($fields as $field) { if ($field->primary) $primKeys[] = $field->name; if ($field->unique) $uniqueKeys[] = $field->name; } if ($primKeys) { $lines[] = Garp_Spawn_MySql_PrimaryKey::renderSqlDefinition($primKeys); } foreach ($uniqueKeys as $fieldName) { $lines[] = Garp_Spawn_MySql_UniqueKey::renderSqlDefinition($fieldName); } foreach ($relations as $rel) { if (($rel->type === 'hasOne' || $rel->type === 'belongsTo') && !$rel->multilingual) { $lines[] = Garp_Spawn_MySql_IndexKey::renderSqlDefinition($rel->column); } } // set indices that were configured in the Spawn model config foreach ($fields as $field) { if ($field->index) { $lines[] = Garp_Spawn_MySql_IndexKey::renderSqlDefinition($field->name); } } foreach ($relations as $relName => $rel) { if (($rel->type === 'hasOne' || $rel->type === 'belongsTo') && !$rel->multilingual) { $fkName = Garp_Spawn_MySql_ForeignKey::generateForeignKeyName($tableName, $relName); $lines[] = Garp_Spawn_MySql_ForeignKey::renderSqlDefinition( $fkName, $rel->column, $rel->model, $rel->type ); } } $out = "CREATE TABLE `{$tableName}` (\n"; $out.= implode(",\n", $lines); $out.= "\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; return $out; }
[ "protected", "function", "_renderCreateAbstract", "(", "$", "tableName", ",", "array", "$", "fields", ",", "array", "$", "relations", ",", "$", "unique", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "fi...
Abstract method to render a CREATE TABLE statement. @param String $modelId The table name, usually the Model ID. @param Array $fields Numeric array of Garp_Spawn_Field objects. @param Array $relations Associative array, where the key is the name of the relation, and the value a Garp_Spawn_Relation object, or at least an object with properties column, model, type. @param Array $unique (optional) List of column names to be combined into a unique id. This is model-wide and supersedes the 'unique' property per field.
[ "Abstract", "method", "to", "render", "a", "CREATE", "TABLE", "statement", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Spawn/MySql/Table/Factory.php#L137-L196
train
grrr-amsterdam/garp3
library/Garp/File/Storage/Local.php
Garp_File_Storage_Local.getList
public function getList(): array { $list = array(); $dir = $this->_docRoot . $this->_path; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (substr($file, 0, 1) !== '.' && strpos($file, '.') !== false ) { $list[] = $file; } } closedir($dh); } } else { throw new Exception($dir . ' is not a directory.'); } return $list; }
php
public function getList(): array { $list = array(); $dir = $this->_docRoot . $this->_path; if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (substr($file, 0, 1) !== '.' && strpos($file, '.') !== false ) { $list[] = $file; } } closedir($dh); } } else { throw new Exception($dir . ' is not a directory.'); } return $list; }
[ "public", "function", "getList", "(", ")", ":", "array", "{", "$", "list", "=", "array", "(", ")", ";", "$", "dir", "=", "$", "this", "->", "_docRoot", ".", "$", "this", "->", "_path", ";", "if", "(", "is_dir", "(", "$", "dir", ")", ")", "{", ...
Lists all valid files in the upload directory. @return array
[ "Lists", "all", "valid", "files", "in", "the", "upload", "directory", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/File/Storage/Local.php#L77-L96
train
grrr-amsterdam/garp3
library/Garp/Application/Resource/Acl.php
Garp_Application_Resource_Acl.init
public function init() { $options = $this->getOptions(); if ($options['enabled']) { $this->getAcl(); $this->store(); } return $this->_acl; }
php
public function init() { $options = $this->getOptions(); if ($options['enabled']) { $this->getAcl(); $this->store(); } return $this->_acl; }
[ "public", "function", "init", "(", ")", "{", "$", "options", "=", "$", "this", "->", "getOptions", "(", ")", ";", "if", "(", "$", "options", "[", "'enabled'", "]", ")", "{", "$", "this", "->", "getAcl", "(", ")", ";", "$", "this", "->", "store", ...
Defined by Zend_Application_Resource_Resource @return Zend_Acl
[ "Defined", "by", "Zend_Application_Resource_Resource" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Resource/Acl.php#L35-L42
train
grrr-amsterdam/garp3
library/Garp/Application/Resource/Acl.php
Garp_Application_Resource_Acl.getOptions
public function getOptions() { $options = parent::getOptions(); if (!array_key_exists('enabled', $options)) { $options['enabled'] = true; } if ($options['enabled']) { $config = Garp_Config_Ini::getCached(APPLICATION_PATH . '/configs/acl.ini'); $aclOptions = $config->acl->toArray(); $options = array_merge($options, $aclOptions); } return $options; }
php
public function getOptions() { $options = parent::getOptions(); if (!array_key_exists('enabled', $options)) { $options['enabled'] = true; } if ($options['enabled']) { $config = Garp_Config_Ini::getCached(APPLICATION_PATH . '/configs/acl.ini'); $aclOptions = $config->acl->toArray(); $options = array_merge($options, $aclOptions); } return $options; }
[ "public", "function", "getOptions", "(", ")", "{", "$", "options", "=", "parent", "::", "getOptions", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "'enabled'", ",", "$", "options", ")", ")", "{", "$", "options", "[", "'enabled'", "]", "=", ...
Overwrite cause we want to store the options elsewhere @return array
[ "Overwrite", "cause", "we", "want", "to", "store", "the", "options", "elsewhere" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Resource/Acl.php#L49-L60
train
grrr-amsterdam/garp3
library/Garp/Application/Resource/Acl.php
Garp_Application_Resource_Acl.getAcl
public function getAcl() { $options = $this->getOptions(); if ($this->_acl === null) { $this->_acl = Zend_Registry::isRegistered(self::DEFAULT_REGISTRY_KEY) ? Zend_Registry::get(self::DEFAULT_REGISTRY_KEY) : new Zend_Acl(); $roles = array(); $resources = array(); if (isset($options['roles'])) { $roles = $options['roles']; } if (isset($options['resources'])) { $resources = $options['resources']; } $this->_addRoles($roles); $this->_addResources($resources); } return $this->_acl; }
php
public function getAcl() { $options = $this->getOptions(); if ($this->_acl === null) { $this->_acl = Zend_Registry::isRegistered(self::DEFAULT_REGISTRY_KEY) ? Zend_Registry::get(self::DEFAULT_REGISTRY_KEY) : new Zend_Acl(); $roles = array(); $resources = array(); if (isset($options['roles'])) { $roles = $options['roles']; } if (isset($options['resources'])) { $resources = $options['resources']; } $this->_addRoles($roles); $this->_addResources($resources); } return $this->_acl; }
[ "public", "function", "getAcl", "(", ")", "{", "$", "options", "=", "$", "this", "->", "getOptions", "(", ")", ";", "if", "(", "$", "this", "->", "_acl", "===", "null", ")", "{", "$", "this", "->", "_acl", "=", "Zend_Registry", "::", "isRegistered", ...
Retrieve ACL object @return Zend_Acl
[ "Retrieve", "ACL", "object" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Resource/Acl.php#L67-L90
train
grrr-amsterdam/garp3
library/Garp/Application/Resource/Acl.php
Garp_Application_Resource_Acl.store
public function store() { $options = $this->getOptions(); $key = self::DEFAULT_REGISTRY_KEY; if (isset($options['storage']['registry']['key']) && !empty($options['storage']['registry']['key']) ) { $key = $options['storage']['registry']['key']; } Zend_Registry::set($key, $this->_acl); }
php
public function store() { $options = $this->getOptions(); $key = self::DEFAULT_REGISTRY_KEY; if (isset($options['storage']['registry']['key']) && !empty($options['storage']['registry']['key']) ) { $key = $options['storage']['registry']['key']; } Zend_Registry::set($key, $this->_acl); }
[ "public", "function", "store", "(", ")", "{", "$", "options", "=", "$", "this", "->", "getOptions", "(", ")", ";", "$", "key", "=", "self", "::", "DEFAULT_REGISTRY_KEY", ";", "if", "(", "isset", "(", "$", "options", "[", "'storage'", "]", "[", "'regi...
Stores ACL in registry @return void
[ "Stores", "ACL", "in", "registry" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Resource/Acl.php#L97-L108
train
grrr-amsterdam/garp3
library/Garp/Application/Resource/Acl.php
Garp_Application_Resource_Acl._addRoles
protected function _addRoles(array $roles) { foreach ($roles as $roleName => $properties) { // If the properties aren't set as an array, then we will consider // the value as the role ID. if (!is_array($properties)) { $properties = array('id' => $properties); } $id = $properties['id']; if (is_null($id) || empty($id)) { throw new Zend_Application_Resource_Exception( sprintf( $this->_missingPropertyMessage, 'ID', 'role', $roleName ) ); } $this->_addRoleById($roles, $id); } }
php
protected function _addRoles(array $roles) { foreach ($roles as $roleName => $properties) { // If the properties aren't set as an array, then we will consider // the value as the role ID. if (!is_array($properties)) { $properties = array('id' => $properties); } $id = $properties['id']; if (is_null($id) || empty($id)) { throw new Zend_Application_Resource_Exception( sprintf( $this->_missingPropertyMessage, 'ID', 'role', $roleName ) ); } $this->_addRoleById($roles, $id); } }
[ "protected", "function", "_addRoles", "(", "array", "$", "roles", ")", "{", "foreach", "(", "$", "roles", "as", "$", "roleName", "=>", "$", "properties", ")", "{", "// If the properties aren't set as an array, then we will consider", "// the value as the role ID.", "if"...
Method used to add our specified roles to our ACL instance. @param array $roles @return void
[ "Method", "used", "to", "add", "our", "specified", "roles", "to", "our", "ACL", "instance", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Resource/Acl.php#L116-L135
train
grrr-amsterdam/garp3
library/Garp/Application/Resource/Acl.php
Garp_Application_Resource_Acl._addResources
protected function _addResources(array $resources) { foreach ($resources as $resourceName => $properties) { // If the properties aren't set as an array, then we will consider // the value as the resource ID. if (!is_array($properties)) { $properties = array('id' => $properties); } $resourceName = strtolower($resourceName); $id = $properties['id']; if ($resourceName === 'all') { $id = 'all'; } if (is_null($id) || empty($id)) { throw new Zend_Application_Resource_Exception( sprintf( $this->_missingPropertyMessage, 'ID', 'resource', $resourceName ) ); } $this->_addResourceById($resources, $id); } }
php
protected function _addResources(array $resources) { foreach ($resources as $resourceName => $properties) { // If the properties aren't set as an array, then we will consider // the value as the resource ID. if (!is_array($properties)) { $properties = array('id' => $properties); } $resourceName = strtolower($resourceName); $id = $properties['id']; if ($resourceName === 'all') { $id = 'all'; } if (is_null($id) || empty($id)) { throw new Zend_Application_Resource_Exception( sprintf( $this->_missingPropertyMessage, 'ID', 'resource', $resourceName ) ); } $this->_addResourceById($resources, $id); } }
[ "protected", "function", "_addResources", "(", "array", "$", "resources", ")", "{", "foreach", "(", "$", "resources", "as", "$", "resourceName", "=>", "$", "properties", ")", "{", "// If the properties aren't set as an array, then we will consider", "// the value as the r...
Method used to add our specified resources to our ACL instance and create any rules if specified. @param array $resources @return void
[ "Method", "used", "to", "add", "our", "specified", "resources", "to", "our", "ACL", "instance", "and", "create", "any", "rules", "if", "specified", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Resource/Acl.php#L187-L212
train
grrr-amsterdam/garp3
library/Garp/Application/Resource/Acl.php
Garp_Application_Resource_Acl._addRules
protected function _addRules($type, array $rules, $resource, $resourceName) { if (!$type) { $type = Zend_Acl::TYPE_ALLOW; } foreach ($rules as $privilege => $ruleProperties) { // If the user sets the privilege value to a string, we will consider // this as the list of roles. if (!is_array($ruleProperties)) { $ruleProperties = array('roles' => $ruleProperties); } if ($privilege === 'all') { $privilege = null; } $roles = $ruleProperties['roles']; if (is_null($roles) || empty($roles)) { $section = 'rules'; if ($type === Zend_Acl::TYPE_ALLOW) { $section = 'allow ' . $section; } else { $section = 'deny ' . $section; } throw new Zend_Application_Resource_Exception( sprintf( $this->_missingPropertyMessage, 'roles', $section, 'resource ' . $resourceName ) ); } $roles = explode(',', $roles); if ($roles[0] === 'all') { $roles = null; } $assert = null; if (isset($ruleProperties['assert']) && !empty($ruleProperties['assert'])) { $assert = $ruleProperties['assert']; $assert = new $assert(); } $this->_acl->setRule( Zend_Acl::OP_ADD, $type, $roles, $resource, $privilege, $assert ); } }
php
protected function _addRules($type, array $rules, $resource, $resourceName) { if (!$type) { $type = Zend_Acl::TYPE_ALLOW; } foreach ($rules as $privilege => $ruleProperties) { // If the user sets the privilege value to a string, we will consider // this as the list of roles. if (!is_array($ruleProperties)) { $ruleProperties = array('roles' => $ruleProperties); } if ($privilege === 'all') { $privilege = null; } $roles = $ruleProperties['roles']; if (is_null($roles) || empty($roles)) { $section = 'rules'; if ($type === Zend_Acl::TYPE_ALLOW) { $section = 'allow ' . $section; } else { $section = 'deny ' . $section; } throw new Zend_Application_Resource_Exception( sprintf( $this->_missingPropertyMessage, 'roles', $section, 'resource ' . $resourceName ) ); } $roles = explode(',', $roles); if ($roles[0] === 'all') { $roles = null; } $assert = null; if (isset($ruleProperties['assert']) && !empty($ruleProperties['assert'])) { $assert = $ruleProperties['assert']; $assert = new $assert(); } $this->_acl->setRule( Zend_Acl::OP_ADD, $type, $roles, $resource, $privilege, $assert ); } }
[ "protected", "function", "_addRules", "(", "$", "type", ",", "array", "$", "rules", ",", "$", "resource", ",", "$", "resourceName", ")", "{", "if", "(", "!", "$", "type", ")", "{", "$", "type", "=", "Zend_Acl", "::", "TYPE_ALLOW", ";", "}", "foreach"...
Method used to add rules to the specified resource. @param string $type @param array $rules @param string $resource @param string $resourceName @return void
[ "Method", "used", "to", "add", "rules", "to", "the", "specified", "resource", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Application/Resource/Acl.php#L291-L348
train
grrr-amsterdam/garp3
library/Garp/Content/Import/Factory.php
Garp_Content_Import_Factory.getImporter
public static function getImporter($dataFile) { $type = self::mapExtensionToType($dataFile); // normalize type $className = 'Garp_Content_Import_'.ucfirst($type); $obj = new $className($dataFile); if (!$obj instanceof Garp_Content_Import_Abstract) { throw new Garp_Content_Import_Exception("Class $className does not implement Garp_Content_Import_Abstract."); } return $obj; }
php
public static function getImporter($dataFile) { $type = self::mapExtensionToType($dataFile); // normalize type $className = 'Garp_Content_Import_'.ucfirst($type); $obj = new $className($dataFile); if (!$obj instanceof Garp_Content_Import_Abstract) { throw new Garp_Content_Import_Exception("Class $className does not implement Garp_Content_Import_Abstract."); } return $obj; }
[ "public", "static", "function", "getImporter", "(", "$", "dataFile", ")", "{", "$", "type", "=", "self", "::", "mapExtensionToType", "(", "$", "dataFile", ")", ";", "// normalize type", "$", "className", "=", "'Garp_Content_Import_'", ".", "ucfirst", "(", "$",...
Return instance of Garp_Content_Import_Abstract @param String $dataFile Filename of the datafile @return Garp_Content_import_Abstract
[ "Return", "instance", "of", "Garp_Content_Import_Abstract" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Import/Factory.php#L18-L28
train
grrr-amsterdam/garp3
library/Garp/Content/Import/Factory.php
Garp_Content_Import_Factory.mapExtensionToType
public static function mapExtensionToType($dataFile) { $ext = substr(strrchr($dataFile, '.'), 1); $ext = strtolower($ext); switch ($ext) { case 'xls': case 'xlsx': return 'Excel'; break; case 'json': return 'Json'; break; default: throw new Garp_Content_Import_Exception("Could not find importer for type $ext"); break; } }
php
public static function mapExtensionToType($dataFile) { $ext = substr(strrchr($dataFile, '.'), 1); $ext = strtolower($ext); switch ($ext) { case 'xls': case 'xlsx': return 'Excel'; break; case 'json': return 'Json'; break; default: throw new Garp_Content_Import_Exception("Could not find importer for type $ext"); break; } }
[ "public", "static", "function", "mapExtensionToType", "(", "$", "dataFile", ")", "{", "$", "ext", "=", "substr", "(", "strrchr", "(", "$", "dataFile", ",", "'.'", ")", ",", "1", ")", ";", "$", "ext", "=", "strtolower", "(", "$", "ext", ")", ";", "s...
Map a file extension to a type of importer @param String $dataFile Filename of the datafile @return String
[ "Map", "a", "file", "extension", "to", "a", "type", "of", "importer" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Content/Import/Factory.php#L35-L50
train
grrr-amsterdam/garp3
library/Garp/Service/ActiveTickets.php
Garp_Service_ActiveTickets.convertTimestampUnixToSoap
public function convertTimestampUnixToSoap($timestamp = null) { if (is_null($timestamp)) { return strftime(self::DATETIME_FORMAT); } /** * @todo: timezone erachter? */ return strftime(self::DATETIME_FORMAT, $timestamp); }
php
public function convertTimestampUnixToSoap($timestamp = null) { if (is_null($timestamp)) { return strftime(self::DATETIME_FORMAT); } /** * @todo: timezone erachter? */ return strftime(self::DATETIME_FORMAT, $timestamp); }
[ "public", "function", "convertTimestampUnixToSoap", "(", "$", "timestamp", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "timestamp", ")", ")", "{", "return", "strftime", "(", "self", "::", "DATETIME_FORMAT", ")", ";", "}", "/**\n * @todo: tim...
Converts a timestamp to a date format AT accepts. @param Int $timestamp Unix timestamp @return String SOAP timestamp
[ "Converts", "a", "timestamp", "to", "a", "date", "format", "AT", "accepts", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Service/ActiveTickets.php#L39-L47
train
grrr-amsterdam/garp3
library/Garp/Store/Factory.php
Garp_Store_Factory.getStore
public static function getStore($namespace, $type = null) { $ini = Zend_Registry::get('config'); if (is_null($type)) { $type = !empty($ini->store->type) ? $ini->store->type : 'Cookie'; } $type = ucfirst($type); if (!in_array($type, array('Session', 'Cookie'))) { throw new Garp_Store_Exception( 'Invalid Store type selected. Must be Session or Cookie.' ); } $duration = false; if (isset($ini->store->lifetime)) { $duration = $ini->store->lifetime; } $className = 'Garp_Store_' . $type; $obj = new $className($namespace, $duration); return $obj; }
php
public static function getStore($namespace, $type = null) { $ini = Zend_Registry::get('config'); if (is_null($type)) { $type = !empty($ini->store->type) ? $ini->store->type : 'Cookie'; } $type = ucfirst($type); if (!in_array($type, array('Session', 'Cookie'))) { throw new Garp_Store_Exception( 'Invalid Store type selected. Must be Session or Cookie.' ); } $duration = false; if (isset($ini->store->lifetime)) { $duration = $ini->store->lifetime; } $className = 'Garp_Store_' . $type; $obj = new $className($namespace, $duration); return $obj; }
[ "public", "static", "function", "getStore", "(", "$", "namespace", ",", "$", "type", "=", "null", ")", "{", "$", "ini", "=", "Zend_Registry", "::", "get", "(", "'config'", ")", ";", "if", "(", "is_null", "(", "$", "type", ")", ")", "{", "$", "type"...
Get store based on application.ini @param string $namespace A global namespace for your data. @param string $type Pick a type of store manually @return Garp_Store_Interface
[ "Get", "store", "based", "on", "application", ".", "ini" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/library/Garp/Store/Factory.php#L17-L37
train
grrr-amsterdam/garp3
application/modules/g/views/helpers/Snippet.php
G_View_Helper_Snippet.getField
public function getField($identifier, $fieldName) { $snippetModel = $this->_getSnippetModel(); $snippet = $snippetModel->fetchByIdentifier($identifier); if (!isset($snippet->{$fieldName})) { throw new Exception(sprintf(self::EXCEPTION_MISSING_FIELD, $snippet->id, $fieldName)); } return $snippet->{$fieldName}; }
php
public function getField($identifier, $fieldName) { $snippetModel = $this->_getSnippetModel(); $snippet = $snippetModel->fetchByIdentifier($identifier); if (!isset($snippet->{$fieldName})) { throw new Exception(sprintf(self::EXCEPTION_MISSING_FIELD, $snippet->id, $fieldName)); } return $snippet->{$fieldName}; }
[ "public", "function", "getField", "(", "$", "identifier", ",", "$", "fieldName", ")", "{", "$", "snippetModel", "=", "$", "this", "->", "_getSnippetModel", "(", ")", ";", "$", "snippet", "=", "$", "snippetModel", "->", "fetchByIdentifier", "(", "$", "ident...
Returns a specific field without rendering any partials or magical Snippet data. @param string $identifier @param string $fieldName @return string
[ "Returns", "a", "specific", "field", "without", "rendering", "any", "partials", "or", "magical", "Snippet", "data", "." ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Snippet.php#L47-L55
train
grrr-amsterdam/garp3
application/modules/g/views/helpers/Snippet.php
G_View_Helper_Snippet.render
public function render( Zend_Db_Table_Row_Abstract $snippet, $partial = false, array $params = array() ) { $module = $partial ? 'default' : 'g'; $partial = $partial ?: 'partials/snippet.phtml'; $params['snippet'] = $snippet; return $this->view->partial($partial, $module, $params); }
php
public function render( Zend_Db_Table_Row_Abstract $snippet, $partial = false, array $params = array() ) { $module = $partial ? 'default' : 'g'; $partial = $partial ?: 'partials/snippet.phtml'; $params['snippet'] = $snippet; return $this->view->partial($partial, $module, $params); }
[ "public", "function", "render", "(", "Zend_Db_Table_Row_Abstract", "$", "snippet", ",", "$", "partial", "=", "false", ",", "array", "$", "params", "=", "array", "(", ")", ")", "{", "$", "module", "=", "$", "partial", "?", "'default'", ":", "'g'", ";", ...
Render the snippet @param Zend_Db_Table_Row_Abstract $snippet @param string $partial Path to the partial that renders this snippet. @param array $params Optional extra parameters to pass to the partial. @return string
[ "Render", "the", "snippet" ]
ee6fa716406047568bc5227670748d3b1dd7290d
https://github.com/grrr-amsterdam/garp3/blob/ee6fa716406047568bc5227670748d3b1dd7290d/application/modules/g/views/helpers/Snippet.php#L65-L73
train
awslabs/aws-sdk-php-resources
src/Aws.php
Aws.respondsTo
public function respondsTo($name = null) { static $services; if (!$services) { $services = []; foreach (glob(__DIR__ . "/models/*.resources.php") as $file) { $services[] = substr(basename($file), 0, -25); } $services = array_unique($services); } return $name ? in_array($name, $services, true) : $services; }
php
public function respondsTo($name = null) { static $services; if (!$services) { $services = []; foreach (glob(__DIR__ . "/models/*.resources.php") as $file) { $services[] = substr(basename($file), 0, -25); } $services = array_unique($services); } return $name ? in_array($name, $services, true) : $services; }
[ "public", "function", "respondsTo", "(", "$", "name", "=", "null", ")", "{", "static", "$", "services", ";", "if", "(", "!", "$", "services", ")", "{", "$", "services", "=", "[", "]", ";", "foreach", "(", "glob", "(", "__DIR__", ".", "\"/models/*.res...
Introspects which resources are accessible to call on this object. @param string|null $name @return array|bool
[ "Introspects", "which", "resources", "are", "accessible", "to", "call", "on", "this", "object", "." ]
e231b33a4c61c6ac9ff0eaf26b07471c637e0517
https://github.com/awslabs/aws-sdk-php-resources/blob/e231b33a4c61c6ac9ff0eaf26b07471c637e0517/src/Aws.php#L73-L86
train
awslabs/aws-sdk-php-resources
src/Resource.php
Resource.respondsTo
public function respondsTo($name = null) { if ($name) { return isset($this->meta['methods'][$name]); } else { return array_keys($this->meta['methods']); } }
php
public function respondsTo($name = null) { if ($name) { return isset($this->meta['methods'][$name]); } else { return array_keys($this->meta['methods']); } }
[ "public", "function", "respondsTo", "(", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "meta", "[", "'methods'", "]", "[", "$", "name", "]", ")", ";", "}", "else", "{", "return", ...
Introspects which resources and actions are accessible on this resource. @param string|null $name @return array|bool
[ "Introspects", "which", "resources", "and", "actions", "are", "accessible", "on", "this", "resource", "." ]
e231b33a4c61c6ac9ff0eaf26b07471c637e0517
https://github.com/awslabs/aws-sdk-php-resources/blob/e231b33a4c61c6ac9ff0eaf26b07471c637e0517/src/Resource.php#L94-L101
train
cpliakas/jira-client
src/Jira/JiraClient.php
JiraClient.login
public function login($username, $password) { $args = array($username, $password); $token = $this->_soapAdapter->call('login', $args); $this->setToken($token); return $token; }
php
public function login($username, $password) { $args = array($username, $password); $token = $this->_soapAdapter->call('login', $args); $this->setToken($token); return $token; }
[ "public", "function", "login", "(", "$", "username", ",", "$", "password", ")", "{", "$", "args", "=", "array", "(", "$", "username", ",", "$", "password", ")", ";", "$", "token", "=", "$", "this", "->", "_soapAdapter", "->", "call", "(", "'login'", ...
Logs in to JIRA and sets the authentication token. @param string $username The JIRA user's username. @param string $password The JIRA user's password. @return string The JIRA authentication token.
[ "Logs", "in", "to", "JIRA", "and", "sets", "the", "authentication", "token", "." ]
e339ec556a9e147b4865b554c7eaca6486e02f92
https://github.com/cpliakas/jira-client/blob/e339ec556a9e147b4865b554c7eaca6486e02f92/src/Jira/JiraClient.php#L143-L149
train
cpliakas/jira-client
src/Jira/JiraClient.php
JiraClient.call
public function call($method) { $args = func_get_args(); $args[0] = $this->_token; return $this->_soapAdapter->call($method, $args); }
php
public function call($method) { $args = func_get_args(); $args[0] = $this->_token; return $this->_soapAdapter->call($method, $args); }
[ "public", "function", "call", "(", "$", "method", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "$", "args", "[", "0", "]", "=", "$", "this", "->", "_token", ";", "return", "$", "this", "->", "_soapAdapter", "->", "call", "(", "$", ...
Executes an RPC call to JIRA, passes the token as the first argument. Most authenticated RPC calls require passing the token as the first param. This method automatically appends the token as the first param so that the application doesn't have to worry about it. @param string $method The method being invoked. @param ... All additional arguments after the authentication token passed as the parameters to the RPC call. @return mixed The data returned by the RPC call.
[ "Executes", "an", "RPC", "call", "to", "JIRA", "passes", "the", "token", "as", "the", "first", "argument", "." ]
e339ec556a9e147b4865b554c7eaca6486e02f92
https://github.com/cpliakas/jira-client/blob/e339ec556a9e147b4865b554c7eaca6486e02f92/src/Jira/JiraClient.php#L289-L294
train
cpliakas/jira-client
src/Jira/Remote/RemoteObject.php
RemoteObject.buildObjectArray
public function buildObjectArray(array $data, $classname) { $objects = array(); foreach ($data as $object) { $objects[] = new $classname($object); } return $objects; }
php
public function buildObjectArray(array $data, $classname) { $objects = array(); foreach ($data as $object) { $objects[] = new $classname($object); } return $objects; }
[ "public", "function", "buildObjectArray", "(", "array", "$", "data", ",", "$", "classname", ")", "{", "$", "objects", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "object", ")", "{", "$", "objects", "[", "]", "=", "new", "$"...
Helper function that builds an array of objects. @param array $data The raw data returned by Request::call(). @param string $classname The name of the class used to create the objects. @return array Returns an array of $classname objects.
[ "Helper", "function", "that", "builds", "an", "array", "of", "objects", "." ]
e339ec556a9e147b4865b554c7eaca6486e02f92
https://github.com/cpliakas/jira-client/blob/e339ec556a9e147b4865b554c7eaca6486e02f92/src/Jira/Remote/RemoteObject.php#L64-L71
train
cpliakas/jira-client
src/Jira/Request/JiraRequest.php
JiraRequest.returnObjectArray
public function returnObjectArray(array $data, $classname, $key = null) { $objects = array(); foreach ($data as $object) { if (null === $key) { $objects[] = new $classname($object); } else { $objects[$object->$key] = new $classname($object); } } return $objects; }
php
public function returnObjectArray(array $data, $classname, $key = null) { $objects = array(); foreach ($data as $object) { if (null === $key) { $objects[] = new $classname($object); } else { $objects[$object->$key] = new $classname($object); } } return $objects; }
[ "public", "function", "returnObjectArray", "(", "array", "$", "data", ",", "$", "classname", ",", "$", "key", "=", "null", ")", "{", "$", "objects", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "object", ")", "{", "if", "(",...
Helper function that returns an array of objects. @param array $data The raw data returned by JiraRequest::call(). @param string $classname The name of the class used to create the objects. @param string|null $key Optionally specify a property whose value should be used as the array key. @return array Returns an array of $classname objects.
[ "Helper", "function", "that", "returns", "an", "array", "of", "objects", "." ]
e339ec556a9e147b4865b554c7eaca6486e02f92
https://github.com/cpliakas/jira-client/blob/e339ec556a9e147b4865b554c7eaca6486e02f92/src/Jira/Request/JiraRequest.php#L109-L120
train
cpliakas/jira-client
src/Jira/Request/ProjectRequest.php
ProjectRequest.getAvatars
public function getAvatars($include_system_avatars = true) { $data = $this->call('getProjectAvatars', $include_system_avatars); return $this->returnObjectArray($data, '\Jira\Remote\RemoteAvatar'); }
php
public function getAvatars($include_system_avatars = true) { $data = $this->call('getProjectAvatars', $include_system_avatars); return $this->returnObjectArray($data, '\Jira\Remote\RemoteAvatar'); }
[ "public", "function", "getAvatars", "(", "$", "include_system_avatars", "=", "true", ")", "{", "$", "data", "=", "$", "this", "->", "call", "(", "'getProjectAvatars'", ",", "$", "include_system_avatars", ")", ";", "return", "$", "this", "->", "returnObjectArra...
Retrieves the avatars for the project. @param bool $include_system_avatars If false, only custom avatars will be included in the returned array. Defaults to TRUE. @return array An array of RemoteAvatar objects. @see http://docs.atlassian.com/rpc-jira-plugin/latest/com/atlassian/jira/rpc/soap/JiraSoapService.html#getProjectAvatars(java.lang.String, java.lang.String, boolean)
[ "Retrieves", "the", "avatars", "for", "the", "project", "." ]
e339ec556a9e147b4865b554c7eaca6486e02f92
https://github.com/cpliakas/jira-client/blob/e339ec556a9e147b4865b554c7eaca6486e02f92/src/Jira/Request/ProjectRequest.php#L112-L116
train
SonarSoftware/customer_portal_framework
src/Helpers/HttpHelper.php
HttpHelper.cleanEndpoint
private function cleanEndpoint($endpoint) { $endpoint = ltrim($endpoint,"/"); $endpoint = rtrim($endpoint,"/"); return getenv('SONAR_URL') . "/api/v1/" . $endpoint; }
php
private function cleanEndpoint($endpoint) { $endpoint = ltrim($endpoint,"/"); $endpoint = rtrim($endpoint,"/"); return getenv('SONAR_URL') . "/api/v1/" . $endpoint; }
[ "private", "function", "cleanEndpoint", "(", "$", "endpoint", ")", "{", "$", "endpoint", "=", "ltrim", "(", "$", "endpoint", ",", "\"/\"", ")", ";", "$", "endpoint", "=", "rtrim", "(", "$", "endpoint", ",", "\"/\"", ")", ";", "return", "getenv", "(", ...
Remove leading or trailing forward slashes from the endpoint. @param $endpoint @return string
[ "Remove", "leading", "or", "trailing", "forward", "slashes", "from", "the", "endpoint", "." ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Helpers/HttpHelper.php#L190-L195
train
SonarSoftware/customer_portal_framework
src/Helpers/HttpHelper.php
HttpHelper.transformErrorToMessage
private function transformErrorToMessage($jsonDecodedObject) { if (property_exists($jsonDecodedObject,"error")) { $message = $jsonDecodedObject->error->message; if (!is_object($message)) { return $message; } else { $messageArray = []; foreach ($message as $key => $value) { array_push($messageArray,$value); } return implode(", ",$messageArray); } } return null; }
php
private function transformErrorToMessage($jsonDecodedObject) { if (property_exists($jsonDecodedObject,"error")) { $message = $jsonDecodedObject->error->message; if (!is_object($message)) { return $message; } else { $messageArray = []; foreach ($message as $key => $value) { array_push($messageArray,$value); } return implode(", ",$messageArray); } } return null; }
[ "private", "function", "transformErrorToMessage", "(", "$", "jsonDecodedObject", ")", "{", "if", "(", "property_exists", "(", "$", "jsonDecodedObject", ",", "\"error\"", ")", ")", "{", "$", "message", "=", "$", "jsonDecodedObject", "->", "error", "->", "message"...
Transform a JSON error response into a string message @param $jsonDecodedObject @return null|string
[ "Transform", "a", "JSON", "error", "response", "into", "a", "string", "message" ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Helpers/HttpHelper.php#L202-L222
train
SonarSoftware/customer_portal_framework
src/Models/PhoneNumber.php
PhoneNumber.setNumber
public function setNumber($number) { if (!is_numeric($number) && $number != null) { throw new InvalidArgumentException("Number is not numeric."); } $this->number = preg_replace('/\D/', '', $number); }
php
public function setNumber($number) { if (!is_numeric($number) && $number != null) { throw new InvalidArgumentException("Number is not numeric."); } $this->number = preg_replace('/\D/', '', $number); }
[ "public", "function", "setNumber", "(", "$", "number", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "number", ")", "&&", "$", "number", "!=", "null", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Number is not numeric.\"", ")", ";", "}...
Set the phone number. @param $number @return mixed
[ "Set", "the", "phone", "number", "." ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Models/PhoneNumber.php#L60-L67
train
SonarSoftware/customer_portal_framework
src/Models/PhoneNumber.php
PhoneNumber.setType
public function setType($type) { if (!in_array($type,[$this::WORK, $this::HOME, $this::MOBILE, $this::FAX])) { throw new InvalidArgumentException("Type is not a valid type. You must use one of the constants in the PhoneNumber class as the type."); } $this->type = $type; }
php
public function setType($type) { if (!in_array($type,[$this::WORK, $this::HOME, $this::MOBILE, $this::FAX])) { throw new InvalidArgumentException("Type is not a valid type. You must use one of the constants in the PhoneNumber class as the type."); } $this->type = $type; }
[ "public", "function", "setType", "(", "$", "type", ")", "{", "if", "(", "!", "in_array", "(", "$", "type", ",", "[", "$", "this", "::", "WORK", ",", "$", "this", "::", "HOME", ",", "$", "this", "::", "MOBILE", ",", "$", "this", "::", "FAX", "]"...
Set the type. @param $type @return mixed
[ "Set", "the", "type", "." ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Models/PhoneNumber.php#L74-L81
train
SonarSoftware/customer_portal_framework
src/Models/Contact.php
Contact.getPhoneNumber
public function getPhoneNumber($type) { if (!in_array($type, [PhoneNumber::WORK, PhoneNumber::HOME, PhoneNumber::FAX, PhoneNumber::MOBILE])) { throw new InvalidArgumentException($type . " is not a valid phone number type."); } return $this->phoneNumbers[$type]; }
php
public function getPhoneNumber($type) { if (!in_array($type, [PhoneNumber::WORK, PhoneNumber::HOME, PhoneNumber::FAX, PhoneNumber::MOBILE])) { throw new InvalidArgumentException($type . " is not a valid phone number type."); } return $this->phoneNumbers[$type]; }
[ "public", "function", "getPhoneNumber", "(", "$", "type", ")", "{", "if", "(", "!", "in_array", "(", "$", "type", ",", "[", "PhoneNumber", "::", "WORK", ",", "PhoneNumber", "::", "HOME", ",", "PhoneNumber", "::", "FAX", ",", "PhoneNumber", "::", "MOBILE"...
Get a specific type of phone number @param $type @return mixed
[ "Get", "a", "specific", "type", "of", "phone", "number" ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Models/Contact.php#L96-L104
train
SonarSoftware/customer_portal_framework
src/Models/Contact.php
Contact.getPhoneNumbersFormatted
public function getPhoneNumbersFormatted() { $formattedArray = []; foreach ($this->phoneNumbers as $key => $phoneNumber) { $formattedArray[$key] = [ 'number' => $phoneNumber->getNumber(), 'extension' => null ]; } return $formattedArray; }
php
public function getPhoneNumbersFormatted() { $formattedArray = []; foreach ($this->phoneNumbers as $key => $phoneNumber) { $formattedArray[$key] = [ 'number' => $phoneNumber->getNumber(), 'extension' => null ]; } return $formattedArray; }
[ "public", "function", "getPhoneNumbersFormatted", "(", ")", "{", "$", "formattedArray", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "phoneNumbers", "as", "$", "key", "=>", "$", "phoneNumber", ")", "{", "$", "formattedArray", "[", "$", "key", "...
Format the phone numbers for the API. @return array
[ "Format", "the", "phone", "numbers", "for", "the", "API", "." ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Models/Contact.php#L110-L122
train
SonarSoftware/customer_portal_framework
src/Models/Contact.php
Contact.setContactID
public function setContactID($contactID) { if (trim($contactID) == null) { throw new InvalidArgumentException("You must supply a contact ID."); } if (!is_numeric($contactID)) { throw new InvalidArgumentException("Contact ID must be numeric."); } $this->contactID = intval($contactID); }
php
public function setContactID($contactID) { if (trim($contactID) == null) { throw new InvalidArgumentException("You must supply a contact ID."); } if (!is_numeric($contactID)) { throw new InvalidArgumentException("Contact ID must be numeric."); } $this->contactID = intval($contactID); }
[ "public", "function", "setContactID", "(", "$", "contactID", ")", "{", "if", "(", "trim", "(", "$", "contactID", ")", "==", "null", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"You must supply a contact ID.\"", ")", ";", "}", "if", "(", "!",...
Set the contact ID @param $contactID @return mixed
[ "Set", "the", "contact", "ID" ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Models/Contact.php#L129-L141
train
SonarSoftware/customer_portal_framework
src/Models/Contact.php
Contact.setAccountID
public function setAccountID($accountID) { if (trim($accountID) == null) { throw new InvalidArgumentException("You must supply an account ID."); } if (!is_numeric($accountID)) { throw new InvalidArgumentException("Account ID must be numeric."); } $this->accountID = intval($accountID); }
php
public function setAccountID($accountID) { if (trim($accountID) == null) { throw new InvalidArgumentException("You must supply an account ID."); } if (!is_numeric($accountID)) { throw new InvalidArgumentException("Account ID must be numeric."); } $this->accountID = intval($accountID); }
[ "public", "function", "setAccountID", "(", "$", "accountID", ")", "{", "if", "(", "trim", "(", "$", "accountID", ")", "==", "null", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"You must supply an account ID.\"", ")", ";", "}", "if", "(", "!"...
Set the account ID @param $accountID @return mixed
[ "Set", "the", "account", "ID" ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Models/Contact.php#L148-L160
train
SonarSoftware/customer_portal_framework
src/Models/Contact.php
Contact.setPhoneNumber
public function setPhoneNumber(PhoneNumber $phoneNumber) { if (!is_a($phoneNumber, PhoneNumber::class, false)) { throw new InvalidArgumentException("The phone number is not an instance of the PhoneNumber class."); } $this->phoneNumbers[$phoneNumber->getType()] = $phoneNumber; }
php
public function setPhoneNumber(PhoneNumber $phoneNumber) { if (!is_a($phoneNumber, PhoneNumber::class, false)) { throw new InvalidArgumentException("The phone number is not an instance of the PhoneNumber class."); } $this->phoneNumbers[$phoneNumber->getType()] = $phoneNumber; }
[ "public", "function", "setPhoneNumber", "(", "PhoneNumber", "$", "phoneNumber", ")", "{", "if", "(", "!", "is_a", "(", "$", "phoneNumber", ",", "PhoneNumber", "::", "class", ",", "false", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"The...
Set a phone number on the contact. @param PhoneNumber $phoneNumber @return array
[ "Set", "a", "phone", "number", "on", "the", "contact", "." ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Models/Contact.php#L209-L217
train
SonarSoftware/customer_portal_framework
src/Controllers/ContactController.php
ContactController.updateContact
public function updateContact(Contact $contact) { return $this->httpHelper->patch("accounts/" . $contact->getAccountID() . "/contacts/" . $contact->getContactID(), [ 'name' => $contact->getName(), 'role' => $contact->getRole(), 'email_address' => $contact->getEmailAddress(), 'phone_numbers' => $contact->getPhoneNumbersFormatted(), ]); }
php
public function updateContact(Contact $contact) { return $this->httpHelper->patch("accounts/" . $contact->getAccountID() . "/contacts/" . $contact->getContactID(), [ 'name' => $contact->getName(), 'role' => $contact->getRole(), 'email_address' => $contact->getEmailAddress(), 'phone_numbers' => $contact->getPhoneNumbersFormatted(), ]); }
[ "public", "function", "updateContact", "(", "Contact", "$", "contact", ")", "{", "return", "$", "this", "->", "httpHelper", "->", "patch", "(", "\"accounts/\"", ".", "$", "contact", "->", "getAccountID", "(", ")", ".", "\"/contacts/\"", ".", "$", "contact", ...
Update an existing contact @param Contact $contact @return mixed @throws \SonarSoftware\CustomerPortalFramework\Exceptions\ApiException
[ "Update", "an", "existing", "contact" ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Controllers/ContactController.php#L71-L79
train
SonarSoftware/customer_portal_framework
src/Controllers/ContactController.php
ContactController.updateContactPassword
public function updateContactPassword(Contact $contact, $newPassword) { return $this->httpHelper->patch("accounts/" . $contact->getAccountID() . "/contacts/" . $contact->getContactID(), [ 'password' => $newPassword, ]); }
php
public function updateContactPassword(Contact $contact, $newPassword) { return $this->httpHelper->patch("accounts/" . $contact->getAccountID() . "/contacts/" . $contact->getContactID(), [ 'password' => $newPassword, ]); }
[ "public", "function", "updateContactPassword", "(", "Contact", "$", "contact", ",", "$", "newPassword", ")", "{", "return", "$", "this", "->", "httpHelper", "->", "patch", "(", "\"accounts/\"", ".", "$", "contact", "->", "getAccountID", "(", ")", ".", "\"/co...
Update the password for a contact @param Contact $contact @param $newPassword @return mixed @throws \SonarSoftware\CustomerPortalFramework\Exceptions\ApiException
[ "Update", "the", "password", "for", "a", "contact" ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Controllers/ContactController.php#L88-L93
train
SonarSoftware/customer_portal_framework
src/Controllers/AccountTicketController.php
AccountTicketController.createTicket
public function createTicket(Ticket $ticket, $author, $authorEmail) { if (filter_var($authorEmail, FILTER_VALIDATE_EMAIL) === false) { throw new InvalidArgumentException($authorEmail . " is not a valid email address."); } $result = $this->httpHelper->post("/tickets", [ 'subject' => $ticket->getSubject(), 'type' => 'public', 'inbound_email_account_id' => $ticket->getInboundEmailAccountID(), 'ticket_group_id' => $ticket->getTicketGroupID(), 'user_id' => $ticket->getUserID(), 'assignee' => 'accounts', 'assignee_id' => $ticket->getAccountID(), 'email_address' => $ticket->getEmailAddress(), 'priority' => $ticket->getPriority(), 'comment' => "Created via the customer portal framework.", ]); $this->httpHelper->post("/tickets/" . $result->id . "/ticket_replies", [ 'text' => $ticket->getDescription(), 'incoming' => true, 'author' => $author, 'author_email' => $authorEmail, ]); return $result; }
php
public function createTicket(Ticket $ticket, $author, $authorEmail) { if (filter_var($authorEmail, FILTER_VALIDATE_EMAIL) === false) { throw new InvalidArgumentException($authorEmail . " is not a valid email address."); } $result = $this->httpHelper->post("/tickets", [ 'subject' => $ticket->getSubject(), 'type' => 'public', 'inbound_email_account_id' => $ticket->getInboundEmailAccountID(), 'ticket_group_id' => $ticket->getTicketGroupID(), 'user_id' => $ticket->getUserID(), 'assignee' => 'accounts', 'assignee_id' => $ticket->getAccountID(), 'email_address' => $ticket->getEmailAddress(), 'priority' => $ticket->getPriority(), 'comment' => "Created via the customer portal framework.", ]); $this->httpHelper->post("/tickets/" . $result->id . "/ticket_replies", [ 'text' => $ticket->getDescription(), 'incoming' => true, 'author' => $author, 'author_email' => $authorEmail, ]); return $result; }
[ "public", "function", "createTicket", "(", "Ticket", "$", "ticket", ",", "$", "author", ",", "$", "authorEmail", ")", "{", "if", "(", "filter_var", "(", "$", "authorEmail", ",", "FILTER_VALIDATE_EMAIL", ")", "===", "false", ")", "{", "throw", "new", "Inval...
Create a new ticket. The first input from the customer will be posted as an incoming reply. @param Ticket $ticket @param $author @param $authorEmail @return mixed @throws \SonarSoftware\CustomerPortalFramework\Exceptions\ApiException
[ "Create", "a", "new", "ticket", ".", "The", "first", "input", "from", "the", "customer", "will", "be", "posted", "as", "an", "incoming", "reply", "." ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Controllers/AccountTicketController.php#L83-L111
train
SonarSoftware/customer_portal_framework
src/Controllers/AccountTicketController.php
AccountTicketController.postReply
public function postReply(Ticket $ticket, $replyText, $author, $authorEmail) { if (filter_var($authorEmail, FILTER_VALIDATE_EMAIL) === false) { throw new InvalidArgumentException($authorEmail . " is not a valid email address."); } try { $this->httpHelper->patch("/tickets/{$ticket->getTicketID()}",[ 'open' => true, ]); } catch (Exception $e) { // } return $this->httpHelper->post("/tickets/{$ticket->getTicketID()}/ticket_replies",[ 'text' => $replyText, 'incoming' => true, 'author' => $author, 'author_email' => $authorEmail, ]); }
php
public function postReply(Ticket $ticket, $replyText, $author, $authorEmail) { if (filter_var($authorEmail, FILTER_VALIDATE_EMAIL) === false) { throw new InvalidArgumentException($authorEmail . " is not a valid email address."); } try { $this->httpHelper->patch("/tickets/{$ticket->getTicketID()}",[ 'open' => true, ]); } catch (Exception $e) { // } return $this->httpHelper->post("/tickets/{$ticket->getTicketID()}/ticket_replies",[ 'text' => $replyText, 'incoming' => true, 'author' => $author, 'author_email' => $authorEmail, ]); }
[ "public", "function", "postReply", "(", "Ticket", "$", "ticket", ",", "$", "replyText", ",", "$", "author", ",", "$", "authorEmail", ")", "{", "if", "(", "filter_var", "(", "$", "authorEmail", ",", "FILTER_VALIDATE_EMAIL", ")", "===", "false", ")", "{", ...
Post a reply to an existing ticket @param Ticket $ticket @param $replyText @param $author @param $authorEmail @return mixed @throws \SonarSoftware\CustomerPortalFramework\Exceptions\ApiException
[ "Post", "a", "reply", "to", "an", "existing", "ticket" ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Controllers/AccountTicketController.php#L122-L145
train
SonarSoftware/customer_portal_framework
src/Controllers/ContractController.php
ContractController.getContracts
public function getContracts(int $accountID, int $page = 1) { $result = $this->httpHelper->get("/accounts/" . intval($accountID) . "/contracts", $page); $contracts = []; foreach ($result as $datum) { $contract = new Contract((array)$datum); array_push($contracts,$contract); } return $contracts; }
php
public function getContracts(int $accountID, int $page = 1) { $result = $this->httpHelper->get("/accounts/" . intval($accountID) . "/contracts", $page); $contracts = []; foreach ($result as $datum) { $contract = new Contract((array)$datum); array_push($contracts,$contract); } return $contracts; }
[ "public", "function", "getContracts", "(", "int", "$", "accountID", ",", "int", "$", "page", "=", "1", ")", "{", "$", "result", "=", "$", "this", "->", "httpHelper", "->", "get", "(", "\"/accounts/\"", ".", "intval", "(", "$", "accountID", ")", ".", ...
This returns an array of 'Contract' objects @param int $accountID @param int $page @return array
[ "This", "returns", "an", "array", "of", "Contract", "objects" ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Controllers/ContractController.php#L25-L37
train
SonarSoftware/customer_portal_framework
src/Models/CreditCard.php
CreditCard.storeInput
private function storeInput($values) { $this->name = trim($values['name']); $this->number = trim(str_replace(" ","",$values['number'])); $this->expiration_month = sprintf("%02d", $values['expiration_month']); $this->expiration_year = trim($values['expiration_year']); $this->line1 = trim($values['line1']); $this->city = trim($values['city']); $this->state = isset($values['state']) ? trim($values['state']) : null; $this->zip = trim($values['zip']); $this->country = trim($values['country']); $this->cvc = trim($values['cvc']); }
php
private function storeInput($values) { $this->name = trim($values['name']); $this->number = trim(str_replace(" ","",$values['number'])); $this->expiration_month = sprintf("%02d", $values['expiration_month']); $this->expiration_year = trim($values['expiration_year']); $this->line1 = trim($values['line1']); $this->city = trim($values['city']); $this->state = isset($values['state']) ? trim($values['state']) : null; $this->zip = trim($values['zip']); $this->country = trim($values['country']); $this->cvc = trim($values['cvc']); }
[ "private", "function", "storeInput", "(", "$", "values", ")", "{", "$", "this", "->", "name", "=", "trim", "(", "$", "values", "[", "'name'", "]", ")", ";", "$", "this", "->", "number", "=", "trim", "(", "str_replace", "(", "\" \"", ",", "\"\"", ",...
Store the input to private vars @param $values
[ "Store", "the", "input", "to", "private", "vars" ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Models/CreditCard.php#L213-L225
train
SonarSoftware/customer_portal_framework
src/Controllers/AccountAuthenticationController.php
AccountAuthenticationController.createUser
public function createUser($accountID, $contactID, $username, $password) { try { return $this->httpHelper->patch("accounts/" . intval($accountID) . "/contacts/" . intval($contactID),[ 'username' => $username, 'password' => $password ]); } catch (ApiException $e) { throw new InvalidArgumentException($e->getMessage()); } }
php
public function createUser($accountID, $contactID, $username, $password) { try { return $this->httpHelper->patch("accounts/" . intval($accountID) . "/contacts/" . intval($contactID),[ 'username' => $username, 'password' => $password ]); } catch (ApiException $e) { throw new InvalidArgumentException($e->getMessage()); } }
[ "public", "function", "createUser", "(", "$", "accountID", ",", "$", "contactID", ",", "$", "username", ",", "$", "password", ")", "{", "try", "{", "return", "$", "this", "->", "httpHelper", "->", "patch", "(", "\"accounts/\"", ".", "intval", "(", "$", ...
Create a username and password for a contact @param $accountID @param $contactID @param $username @param $password @return mixed
[ "Create", "a", "username", "and", "password", "for", "a", "contact" ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Controllers/AccountAuthenticationController.php#L67-L80
train
SonarSoftware/customer_portal_framework
src/Models/Ticket.php
Ticket.setSubject
public function setSubject($value) { if (trim($value) == null) { throw new InvalidArgumentException("Subject cannot be empty."); } $this->subject = trim($value); }
php
public function setSubject($value) { if (trim($value) == null) { throw new InvalidArgumentException("Subject cannot be empty."); } $this->subject = trim($value); }
[ "public", "function", "setSubject", "(", "$", "value", ")", "{", "if", "(", "trim", "(", "$", "value", ")", "==", "null", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Subject cannot be empty.\"", ")", ";", "}", "$", "this", "->", "subject"...
Set the subject. @param $value
[ "Set", "the", "subject", "." ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Models/Ticket.php#L41-L48
train
SonarSoftware/customer_portal_framework
src/Models/Ticket.php
Ticket.setLastReplyIncoming
public function setLastReplyIncoming($value) { if (!is_bool($value)) { throw new InvalidArgumentException($value . " must be true or false."); } $this->lastReplyIncoming = (boolean)$value; }
php
public function setLastReplyIncoming($value) { if (!is_bool($value)) { throw new InvalidArgumentException($value . " must be true or false."); } $this->lastReplyIncoming = (boolean)$value; }
[ "public", "function", "setLastReplyIncoming", "(", "$", "value", ")", "{", "if", "(", "!", "is_bool", "(", "$", "value", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "$", "value", ".", "\" must be true or false.\"", ")", ";", "}", "$", "...
Set the last reply incoming value @param $value
[ "Set", "the", "last", "reply", "incoming", "value" ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Models/Ticket.php#L259-L266
train
SonarSoftware/customer_portal_framework
src/Models/Ticket.php
Ticket.storeInput
private function storeInput($values) { $requiredKeys = [ 'subject', 'account_id', 'inbound_email_account_id', 'email_address', ]; foreach ($requiredKeys as $key) { if (!array_key_exists($key, $values)) { throw new InvalidArgumentException("$key is a required key in the input array."); } } foreach ($values as $key => $value) { if ($value === null) { continue; } $function = ucwords(StringFormatter::camelCase($key)); try { call_user_func([$this, "set$function"], $value); } catch (Exception $e) { continue; } } }
php
private function storeInput($values) { $requiredKeys = [ 'subject', 'account_id', 'inbound_email_account_id', 'email_address', ]; foreach ($requiredKeys as $key) { if (!array_key_exists($key, $values)) { throw new InvalidArgumentException("$key is a required key in the input array."); } } foreach ($values as $key => $value) { if ($value === null) { continue; } $function = ucwords(StringFormatter::camelCase($key)); try { call_user_func([$this, "set$function"], $value); } catch (Exception $e) { continue; } } }
[ "private", "function", "storeInput", "(", "$", "values", ")", "{", "$", "requiredKeys", "=", "[", "'subject'", ",", "'account_id'", ",", "'inbound_email_account_id'", ",", "'email_address'", ",", "]", ";", "foreach", "(", "$", "requiredKeys", "as", "$", "key",...
Store the input from the constructor @param $values
[ "Store", "the", "input", "from", "the", "constructor" ]
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Models/Ticket.php#L272-L304
train
SonarSoftware/customer_portal_framework
src/Controllers/AccountBillingController.php
AccountBillingController.makeCreditCardPayment
public function makeCreditCardPayment($accountID, CreditCard $creditCard, $amount, $saveAndMakeAuto = false) { $result = $this->httpHelper->post("/accounts/" . intval($accountID) . "/transactions/one_time_credit_card_payment", [ 'number' => $creditCard->getNumber(), 'expiration_month' => $creditCard->getExpirationMonth(), 'expiration_year' => $creditCard->getExpirationYear(), 'amount' => trim($amount), 'name_on_account' => $creditCard->getName(), 'line1' => $creditCard->getLine1(), 'city' => $creditCard->getCity(), 'state' => $creditCard->getState(), 'zip' => $creditCard->getZip(), 'country' => $creditCard->getCountry(), 'cvc' => $creditCard->getCvc(), ]); if ($result->success === true && $saveAndMakeAuto === true) { try { $this->createCreditCard($accountID, $creditCard); } catch (Exception $e) { //Not much we can do here, the payment has already been run. Very unlikely payment will work and saving will fail. } } unset($creditCard); return $result; }
php
public function makeCreditCardPayment($accountID, CreditCard $creditCard, $amount, $saveAndMakeAuto = false) { $result = $this->httpHelper->post("/accounts/" . intval($accountID) . "/transactions/one_time_credit_card_payment", [ 'number' => $creditCard->getNumber(), 'expiration_month' => $creditCard->getExpirationMonth(), 'expiration_year' => $creditCard->getExpirationYear(), 'amount' => trim($amount), 'name_on_account' => $creditCard->getName(), 'line1' => $creditCard->getLine1(), 'city' => $creditCard->getCity(), 'state' => $creditCard->getState(), 'zip' => $creditCard->getZip(), 'country' => $creditCard->getCountry(), 'cvc' => $creditCard->getCvc(), ]); if ($result->success === true && $saveAndMakeAuto === true) { try { $this->createCreditCard($accountID, $creditCard); } catch (Exception $e) { //Not much we can do here, the payment has already been run. Very unlikely payment will work and saving will fail. } } unset($creditCard); return $result; }
[ "public", "function", "makeCreditCardPayment", "(", "$", "accountID", ",", "CreditCard", "$", "creditCard", ",", "$", "amount", ",", "$", "saveAndMakeAuto", "=", "false", ")", "{", "$", "result", "=", "$", "this", "->", "httpHelper", "->", "post", "(", "\"...
Make a one time payment with a credit card and, optionally, save it as a future automatic payment method. This should not be used to pay with an existing payment method. @param $accountID - The account ID in Sonar @param CreditCard $creditCard - A CreditCard object @param $amount - The amount in the currency used in Sonar as a float @param bool $saveAndMakeAuto - If this is true, save the card if it successfully runs @return mixed @throws ApiException
[ "Make", "a", "one", "time", "payment", "with", "a", "credit", "card", "and", "optionally", "save", "it", "as", "a", "future", "automatic", "payment", "method", ".", "This", "should", "not", "be", "used", "to", "pay", "with", "an", "existing", "payment", ...
0af9b3f2b6e6f609a189d63e0f7b565d85a649d7
https://github.com/SonarSoftware/customer_portal_framework/blob/0af9b3f2b6e6f609a189d63e0f7b565d85a649d7/src/Controllers/AccountBillingController.php#L176-L205
train
psliwa/PHPPdf
lib/PHPPdf/Core/Parser/XmlDocumentParser.php
XmlDocumentParser.parse
public function parse($content, StylesheetConstraint $stylesheetConstraint = null) { if($stylesheetConstraint !== null) { $this->setStylesheetConstraint($stylesheetConstraint); } $pageCollection = parent::parse($content); $this->fireOnEndParsing($pageCollection); $this->initialize(); return $pageCollection; }
php
public function parse($content, StylesheetConstraint $stylesheetConstraint = null) { if($stylesheetConstraint !== null) { $this->setStylesheetConstraint($stylesheetConstraint); } $pageCollection = parent::parse($content); $this->fireOnEndParsing($pageCollection); $this->initialize(); return $pageCollection; }
[ "public", "function", "parse", "(", "$", "content", ",", "StylesheetConstraint", "$", "stylesheetConstraint", "=", "null", ")", "{", "if", "(", "$", "stylesheetConstraint", "!==", "null", ")", "{", "$", "this", "->", "setStylesheetConstraint", "(", "$", "style...
Parses document and build graph of Node @return PageCollection Root of node's graph
[ "Parses", "document", "and", "build", "graph", "of", "Node" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Parser/XmlDocumentParser.php#L150-L164
train
psliwa/PHPPdf
lib/PHPPdf/Core/Parser/BagContainer.php
BagContainer.merge
public static function merge(array $containers) { $attributeBags = array(); $weight = 0; foreach($containers as $container) { $weight = max($weight, $container->getWeight()); $attributeBags[] = $container->getAttributeBag(); } $container = new static(); $container->attributeBag = AttributeBag::merge($attributeBags); $container->weight = $weight; return $container; }
php
public static function merge(array $containers) { $attributeBags = array(); $weight = 0; foreach($containers as $container) { $weight = max($weight, $container->getWeight()); $attributeBags[] = $container->getAttributeBag(); } $container = new static(); $container->attributeBag = AttributeBag::merge($attributeBags); $container->weight = $weight; return $container; }
[ "public", "static", "function", "merge", "(", "array", "$", "containers", ")", "{", "$", "attributeBags", "=", "array", "(", ")", ";", "$", "weight", "=", "0", ";", "foreach", "(", "$", "containers", "as", "$", "container", ")", "{", "$", "weight", "...
Marge couple of BagContainers into one object. Result of merging always is BagContainer. @param array $containers @return BagContainer Result of merging
[ "Marge", "couple", "of", "BagContainers", "into", "one", "object", "." ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Parser/BagContainer.php#L127-L143
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/NodeFactory.php
NodeFactory.create
public function create($name) { $name = $this->resolveName($name); $prototype = $this->getPrototype($name); $product = $prototype->copy(); foreach($this->invocationsMethodsOnCreate[$name] as $methodName => $argTag) { if(isset($this->invokeArgs[$argTag])) { $arg = $this->invokeArgs[$argTag]; $product->$methodName($arg); } } return $product; }
php
public function create($name) { $name = $this->resolveName($name); $prototype = $this->getPrototype($name); $product = $prototype->copy(); foreach($this->invocationsMethodsOnCreate[$name] as $methodName => $argTag) { if(isset($this->invokeArgs[$argTag])) { $arg = $this->invokeArgs[$argTag]; $product->$methodName($arg); } } return $product; }
[ "public", "function", "create", "(", "$", "name", ")", "{", "$", "name", "=", "$", "this", "->", "resolveName", "(", "$", "name", ")", ";", "$", "prototype", "=", "$", "this", "->", "getPrototype", "(", "$", "name", ")", ";", "$", "product", "=", ...
Create copy of node stored under passed name @param string Name/key of prototype @return Node Deep copy of node stored under passed name @throws PHPPdf\Exception\UnregisteredNodeException If prototype with passed name dosn't exist
[ "Create", "copy", "of", "node", "stored", "under", "passed", "name" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/NodeFactory.php#L103-L120
train
psliwa/PHPPdf
lib/PHPPdf/Core/FacadeBuilder.php
FacadeBuilder.build
public function build() { $documentParser = $this->createDocumentParser(); $stylesheetParser = new StylesheetParser(); $stylesheetParser->setComplexAttributeFactory($this->configurationLoader->createComplexAttributeFactory()); $engine = $this->engineFactory->createEngine($this->engineType, $this->engineOptions); $document = new Document($engine); $this->addStringFiltersTo($document); $facade = new Facade($this->configurationLoader, $document, $documentParser, $stylesheetParser); $this->addStringFiltersTo($facade); $facade->setEngineType($this->engineType); if($documentParser instanceof FacadeAware) { $documentParser->setFacade($facade); } $facade->setUseCacheForStylesheetConstraint($this->useCacheForStylesheetConstraint); if($this->cacheType && $this->cacheType !== 'Null') { $cache = new CacheImpl($this->cacheType, $this->cacheOptions); $facade->setCache($cache); if($this->useCacheForConfigurationLoader) { $this->configurationLoader->setCache($cache); } } return $facade; }
php
public function build() { $documentParser = $this->createDocumentParser(); $stylesheetParser = new StylesheetParser(); $stylesheetParser->setComplexAttributeFactory($this->configurationLoader->createComplexAttributeFactory()); $engine = $this->engineFactory->createEngine($this->engineType, $this->engineOptions); $document = new Document($engine); $this->addStringFiltersTo($document); $facade = new Facade($this->configurationLoader, $document, $documentParser, $stylesheetParser); $this->addStringFiltersTo($facade); $facade->setEngineType($this->engineType); if($documentParser instanceof FacadeAware) { $documentParser->setFacade($facade); } $facade->setUseCacheForStylesheetConstraint($this->useCacheForStylesheetConstraint); if($this->cacheType && $this->cacheType !== 'Null') { $cache = new CacheImpl($this->cacheType, $this->cacheOptions); $facade->setCache($cache); if($this->useCacheForConfigurationLoader) { $this->configurationLoader->setCache($cache); } } return $facade; }
[ "public", "function", "build", "(", ")", "{", "$", "documentParser", "=", "$", "this", "->", "createDocumentParser", "(", ")", ";", "$", "stylesheetParser", "=", "new", "StylesheetParser", "(", ")", ";", "$", "stylesheetParser", "->", "setComplexAttributeFactory...
Create Facade object @return Facade
[ "Create", "Facade", "object" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/FacadeBuilder.php#L117-L151
train
psliwa/PHPPdf
lib/PHPPdf/Core/FacadeBuilder.php
FacadeBuilder.setCache
public function setCache($type, array $options = array()) { $this->cacheType = $type; $this->cacheOptions = $options; return $this; }
php
public function setCache($type, array $options = array()) { $this->cacheType = $type; $this->cacheOptions = $options; return $this; }
[ "public", "function", "setCache", "(", "$", "type", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "this", "->", "cacheType", "=", "$", "type", ";", "$", "this", "->", "cacheOptions", "=", "$", "options", ";", "return", "$", "...
Set cache type and options for facade @param string $type Type of cache, see {@link PHPPdf\Cache\CacheImpl} engine constants @param array $options Options for cache @return FacadeBuilder
[ "Set", "cache", "type", "and", "options", "for", "facade" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/FacadeBuilder.php#L183-L189
train
psliwa/PHPPdf
lib/PHPPdf/Core/Parser/StylesheetConstraint.php
StylesheetConstraint.addConstraint
public function addConstraint($tag, StylesheetConstraint $constraint) { $tag = (string) $tag; $constraint->setTag($tag); $this->constraints[] = $constraint; }
php
public function addConstraint($tag, StylesheetConstraint $constraint) { $tag = (string) $tag; $constraint->setTag($tag); $this->constraints[] = $constraint; }
[ "public", "function", "addConstraint", "(", "$", "tag", ",", "StylesheetConstraint", "$", "constraint", ")", "{", "$", "tag", "=", "(", "string", ")", "$", "tag", ";", "$", "constraint", "->", "setTag", "(", "$", "tag", ")", ";", "$", "this", "->", "...
Adds constraints with given tag @param string Constraint tag @param StylesheetConstraint Constraint to add
[ "Adds", "constraints", "with", "given", "tag" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Parser/StylesheetConstraint.php#L86-L92
train
psliwa/PHPPdf
lib/PHPPdf/Core/Parser/StylesheetConstraint.php
StylesheetConstraint.find
public function find(array $query) { if(count($query) === 0) { return new BagContainer($this->getAll()); } $containers = array(); while($queryElement = array_shift($query)) { $tag = $this->getTagFromQueryElement($queryElement); $classes = $this->getClassesFromQueryElement($queryElement); foreach($this->constraints as $order => $constraint) { $matchingIndex = $this->getMatchingIndex($constraint, $tag, $classes); if($matchingIndex > 0) { $container = $constraint->find($query); $container->addWeight($matchingIndex); $container->setOrder($order); $containers[] = $container; } } } usort($containers, function($container1, $container2){ $result = $container1->getWeight() - $container2->getWeight(); if($result == 0) { $result = $container1->getOrder() - $container2->getOrder(); } return $result; }); return BagContainer::merge($containers); }
php
public function find(array $query) { if(count($query) === 0) { return new BagContainer($this->getAll()); } $containers = array(); while($queryElement = array_shift($query)) { $tag = $this->getTagFromQueryElement($queryElement); $classes = $this->getClassesFromQueryElement($queryElement); foreach($this->constraints as $order => $constraint) { $matchingIndex = $this->getMatchingIndex($constraint, $tag, $classes); if($matchingIndex > 0) { $container = $constraint->find($query); $container->addWeight($matchingIndex); $container->setOrder($order); $containers[] = $container; } } } usort($containers, function($container1, $container2){ $result = $container1->getWeight() - $container2->getWeight(); if($result == 0) { $result = $container1->getOrder() - $container2->getOrder(); } return $result; }); return BagContainer::merge($containers); }
[ "public", "function", "find", "(", "array", "$", "query", ")", "{", "if", "(", "count", "(", "$", "query", ")", "===", "0", ")", "{", "return", "new", "BagContainer", "(", "$", "this", "->", "getAll", "(", ")", ")", ";", "}", "$", "containers", "...
Find attributes by specyfic criteria $query should be array in format: * array( * array('tag' => 'first-tag', 'classes' => array('class1', 'class2')), * array('tag' => 'second-tag', 'classes' => array()), * ) Above example is equivalent to css selector: "first-tag.class1.class2 second-tag" @param array $query Criteria of constraint @return BagContainer Container with specyfic attributes
[ "Find", "attributes", "by", "specyfic", "criteria" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Parser/StylesheetConstraint.php#L122-L160
train
psliwa/PHPPdf
lib/PHPPdf/Core/Boundary.php
Boundary.setNext
public function setNext($param1, $param2 = null) { if($this->closed) { throw new LogicException('Boundary has been already closed.'); } $numberOfArgs = func_num_args(); if($numberOfArgs === 2) { $point = Point::getInstance($param1, $param2); } elseif($param1 instanceof Point) { $point = $param1; } else { throw new InvalidArgumentException('Passed argument(s) should be coordinations or Point object.'); } $oldNumberOfPoints = $this->numberOfPoints; $this->points[$oldNumberOfPoints] = $point; $this->numberOfPoints++; $diagonalPoint = $this->getDiagonalPoint(); if(!$diagonalPoint || $diagonalPoint->compareYCoord($point) >= 0) { $this->diagonalPointYIndex = $oldNumberOfPoints; } if(!$diagonalPoint || $diagonalPoint->compareXCoord($point) <= 0) { $this->diagonalPointXIndex = $oldNumberOfPoints; } return $this; }
php
public function setNext($param1, $param2 = null) { if($this->closed) { throw new LogicException('Boundary has been already closed.'); } $numberOfArgs = func_num_args(); if($numberOfArgs === 2) { $point = Point::getInstance($param1, $param2); } elseif($param1 instanceof Point) { $point = $param1; } else { throw new InvalidArgumentException('Passed argument(s) should be coordinations or Point object.'); } $oldNumberOfPoints = $this->numberOfPoints; $this->points[$oldNumberOfPoints] = $point; $this->numberOfPoints++; $diagonalPoint = $this->getDiagonalPoint(); if(!$diagonalPoint || $diagonalPoint->compareYCoord($point) >= 0) { $this->diagonalPointYIndex = $oldNumberOfPoints; } if(!$diagonalPoint || $diagonalPoint->compareXCoord($point) <= 0) { $this->diagonalPointXIndex = $oldNumberOfPoints; } return $this; }
[ "public", "function", "setNext", "(", "$", "param1", ",", "$", "param2", "=", "null", ")", "{", "if", "(", "$", "this", "->", "closed", ")", "{", "throw", "new", "LogicException", "(", "'Boundary has been already closed.'", ")", ";", "}", "$", "numberOfArg...
Add next point to boundary @return Boundary Self
[ "Add", "next", "point", "to", "boundary" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Boundary.php#L35-L74
train
psliwa/PHPPdf
lib/PHPPdf/Core/Boundary.php
Boundary.close
public function close() { if($this->numberOfPoints <= 2) { throw new LogicException('Boundary must have at last three points.'); } $this->points[$this->numberOfPoints] = $this->getFirstPoint(); $this->numberOfPoints++; $this->closed = true; }
php
public function close() { if($this->numberOfPoints <= 2) { throw new LogicException('Boundary must have at last three points.'); } $this->points[$this->numberOfPoints] = $this->getFirstPoint(); $this->numberOfPoints++; $this->closed = true; }
[ "public", "function", "close", "(", ")", "{", "if", "(", "$", "this", "->", "numberOfPoints", "<=", "2", ")", "{", "throw", "new", "LogicException", "(", "'Boundary must have at last three points.'", ")", ";", "}", "$", "this", "->", "points", "[", "$", "t...
Close boundary. Adding next points occurs LogicException
[ "Close", "boundary", ".", "Adding", "next", "points", "occurs", "LogicException" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Boundary.php#L79-L90
train
psliwa/PHPPdf
lib/PHPPdf/Core/Boundary.php
Boundary.intersects
public function intersects(Boundary $boundary) { $firstPoint = $this->getFirstPoint(); $diagonalPoint = $this->getDiagonalPoint(); $compareFirstPoint = $boundary->getFirstPoint(); $compareDiagonalPoint = $boundary->getDiagonalPoint(); foreach($boundary->points as $point) { if($this->contains($point)) { return true; } } foreach($this->points as $point) { if($boundary->contains($point)) { return true; } } $centerPoint = $this->getPointBetween($firstPoint, $diagonalPoint); if($boundary->contains($centerPoint)) { return true; } $centerPoint = $this->getPointBetween($compareFirstPoint, $compareDiagonalPoint); if($this->contains($centerPoint)) { return true; } $centerPoint = $this->getPointBetween($firstPoint, $compareDiagonalPoint); if($this->contains($centerPoint) && $boundary->contains($centerPoint)) { return true; } $centerPoint = $this->getPointBetween($compareFirstPoint, $diagonalPoint); if($this->contains($centerPoint) && $boundary->contains($centerPoint)) { return true; } return false; }
php
public function intersects(Boundary $boundary) { $firstPoint = $this->getFirstPoint(); $diagonalPoint = $this->getDiagonalPoint(); $compareFirstPoint = $boundary->getFirstPoint(); $compareDiagonalPoint = $boundary->getDiagonalPoint(); foreach($boundary->points as $point) { if($this->contains($point)) { return true; } } foreach($this->points as $point) { if($boundary->contains($point)) { return true; } } $centerPoint = $this->getPointBetween($firstPoint, $diagonalPoint); if($boundary->contains($centerPoint)) { return true; } $centerPoint = $this->getPointBetween($compareFirstPoint, $compareDiagonalPoint); if($this->contains($centerPoint)) { return true; } $centerPoint = $this->getPointBetween($firstPoint, $compareDiagonalPoint); if($this->contains($centerPoint) && $boundary->contains($centerPoint)) { return true; } $centerPoint = $this->getPointBetween($compareFirstPoint, $diagonalPoint); if($this->contains($centerPoint) && $boundary->contains($centerPoint)) { return true; } return false; }
[ "public", "function", "intersects", "(", "Boundary", "$", "boundary", ")", "{", "$", "firstPoint", "=", "$", "this", "->", "getFirstPoint", "(", ")", ";", "$", "diagonalPoint", "=", "$", "this", "->", "getDiagonalPoint", "(", ")", ";", "$", "compareFirstPo...
Checks if boundaries have common points @param Boundary $boundary @return boolean
[ "Checks", "if", "boundaries", "have", "common", "points" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Boundary.php#L98-L151
train
psliwa/PHPPdf
lib/PHPPdf/Core/Boundary.php
Boundary.reset
public function reset() { $this->closed = false; $this->points = array(); $this->rewind(); $this->numberOfPoints = 0; $this->diagonalPointXIndex = null; $this->diagonalPointYIndex = null; }
php
public function reset() { $this->closed = false; $this->points = array(); $this->rewind(); $this->numberOfPoints = 0; $this->diagonalPointXIndex = null; $this->diagonalPointYIndex = null; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "closed", "=", "false", ";", "$", "this", "->", "points", "=", "array", "(", ")", ";", "$", "this", "->", "rewind", "(", ")", ";", "$", "this", "->", "numberOfPoints", "=", "0", ";"...
Clears points and status of the object
[ "Clears", "points", "and", "status", "of", "the", "object" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Boundary.php#L302-L310
train
psliwa/PHPPdf
lib/PHPPdf/Core/Facade.php
Facade.render
public function render($documentContent, $stylesheetContents = array(), $colorPaletteContent = null) { $colorPalette = new ColorPalette((array) $this->configurationLoader->createColorPalette()); if($colorPaletteContent) { $colorPalette->merge($this->parseColorPalette($colorPaletteContent)); } $this->document->setColorPalette($colorPalette); $complexAttributeFactory = $this->configurationLoader->createComplexAttributeFactory(); $this->getDocument()->setComplexAttributeFactory($complexAttributeFactory); $fontDefinitions = $this->configurationLoader->createFontRegistry($this->engineType); $this->getDocument()->addFontDefinitions($fontDefinitions); $this->getDocumentParser()->setComplexAttributeFactory($complexAttributeFactory); $this->getDocumentParser()->setNodeFactory($this->configurationLoader->createNodeFactory()); $stylesheetConstraint = $this->retrieveStylesheetConstraint($stylesheetContents); foreach($this->stringFilters as $filter) { $documentContent = $filter->filter($documentContent); } $pageCollection = $this->getDocumentParser()->parse($documentContent, $stylesheetConstraint); $this->updateStylesheetConstraintCacheIfNecessary($stylesheetConstraint); unset($stylesheetConstraint); return $this->doRender($pageCollection); }
php
public function render($documentContent, $stylesheetContents = array(), $colorPaletteContent = null) { $colorPalette = new ColorPalette((array) $this->configurationLoader->createColorPalette()); if($colorPaletteContent) { $colorPalette->merge($this->parseColorPalette($colorPaletteContent)); } $this->document->setColorPalette($colorPalette); $complexAttributeFactory = $this->configurationLoader->createComplexAttributeFactory(); $this->getDocument()->setComplexAttributeFactory($complexAttributeFactory); $fontDefinitions = $this->configurationLoader->createFontRegistry($this->engineType); $this->getDocument()->addFontDefinitions($fontDefinitions); $this->getDocumentParser()->setComplexAttributeFactory($complexAttributeFactory); $this->getDocumentParser()->setNodeFactory($this->configurationLoader->createNodeFactory()); $stylesheetConstraint = $this->retrieveStylesheetConstraint($stylesheetContents); foreach($this->stringFilters as $filter) { $documentContent = $filter->filter($documentContent); } $pageCollection = $this->getDocumentParser()->parse($documentContent, $stylesheetConstraint); $this->updateStylesheetConstraintCacheIfNecessary($stylesheetConstraint); unset($stylesheetConstraint); return $this->doRender($pageCollection); }
[ "public", "function", "render", "(", "$", "documentContent", ",", "$", "stylesheetContents", "=", "array", "(", ")", ",", "$", "colorPaletteContent", "=", "null", ")", "{", "$", "colorPalette", "=", "new", "ColorPalette", "(", "(", "array", ")", "$", "this...
Convert text document to pdf document @param string|DataSource $documentContent Source document content @param DataSource[]|string[]|DataSource|string $stylesheetContents Stylesheet source(s) @param string|DataSource $colorPaletteContent Palette of colors source @return string Content of pdf document @throws PHPPdf\Exception\Exception
[ "Convert", "text", "document", "to", "pdf", "document" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Facade.php#L150-L181
train
psliwa/PHPPdf
lib/PHPPdf/Util.php
Util.convertAngleValue
public static function convertAngleValue($value) { if($value !== null && strpos($value, 'deg') !== false) { $value = (float) $value; $value = deg2rad($value); } return $value !== null ? ((float) $value) : null; }
php
public static function convertAngleValue($value) { if($value !== null && strpos($value, 'deg') !== false) { $value = (float) $value; $value = deg2rad($value); } return $value !== null ? ((float) $value) : null; }
[ "public", "static", "function", "convertAngleValue", "(", "$", "value", ")", "{", "if", "(", "$", "value", "!==", "null", "&&", "strpos", "(", "$", "value", ",", "'deg'", ")", "!==", "false", ")", "{", "$", "value", "=", "(", "float", ")", "$", "va...
Converts angle value to radians. When value is "deg" suffixed, it means value is in degrees. @return float|null angle in radians or null
[ "Converts", "angle", "value", "to", "radians", "." ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Util.php#L39-L48
train
psliwa/PHPPdf
lib/PHPPdf/Core/Document.php
Document.getComplexAttributes
public function getComplexAttributes(AttributeBag $bag) { $complexAttributes = array(); if($this->complexAttributeFactory !== null) { foreach($bag->getAll() as $id => $parameters) { if(!isset($parameters['name'])) { throw new InvalidArgumentException('"name" attribute is required.'); } $name = $parameters['name']; unset($parameters['name']); $complexAttribute = $this->complexAttributeFactory->create($name, $parameters); if(!$complexAttribute->isEmpty()) { $complexAttributes[] = $complexAttribute; } } } return $complexAttributes; }
php
public function getComplexAttributes(AttributeBag $bag) { $complexAttributes = array(); if($this->complexAttributeFactory !== null) { foreach($bag->getAll() as $id => $parameters) { if(!isset($parameters['name'])) { throw new InvalidArgumentException('"name" attribute is required.'); } $name = $parameters['name']; unset($parameters['name']); $complexAttribute = $this->complexAttributeFactory->create($name, $parameters); if(!$complexAttribute->isEmpty()) { $complexAttributes[] = $complexAttribute; } } } return $complexAttributes; }
[ "public", "function", "getComplexAttributes", "(", "AttributeBag", "$", "bag", ")", "{", "$", "complexAttributes", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "complexAttributeFactory", "!==", "null", ")", "{", "foreach", "(", "$", "bag", "-...
Create complexAttributes objects depends on bag content @return array Array of ComplexAttribute objects
[ "Create", "complexAttributes", "objects", "depends", "on", "bag", "content" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Document.php#L71-L97
train
psliwa/PHPPdf
lib/PHPPdf/Core/Document.php
Document.draw
public function draw($pages) { if($this->isProcessed()) { throw new LogicException(sprintf('Pdf has alredy been drawed.')); } $this->processed = true; if(is_array($pages)) { $pageCollection = new PageCollection(); foreach($pages as $page) { if(!$page instanceof Page) { throw new DrawingException(sprintf('Not all elements of passed array are PHPPdf\Core\Node\Page type. One of them is "%s".', get_class($page))); } $pageCollection->add($page); } } elseif($pages instanceof PageCollection) { $pageCollection = $pages; } else { throw new InvalidArgumentException(sprintf('Argument of draw method must be an array of pages or PageCollection object, "%s" given.', get_class($pages))); } $pageCollection->format($this); $tasks = $pageCollection->getAllDrawingTasks($this); $this->invokeTasks($tasks); }
php
public function draw($pages) { if($this->isProcessed()) { throw new LogicException(sprintf('Pdf has alredy been drawed.')); } $this->processed = true; if(is_array($pages)) { $pageCollection = new PageCollection(); foreach($pages as $page) { if(!$page instanceof Page) { throw new DrawingException(sprintf('Not all elements of passed array are PHPPdf\Core\Node\Page type. One of them is "%s".', get_class($page))); } $pageCollection->add($page); } } elseif($pages instanceof PageCollection) { $pageCollection = $pages; } else { throw new InvalidArgumentException(sprintf('Argument of draw method must be an array of pages or PageCollection object, "%s" given.', get_class($pages))); } $pageCollection->format($this); $tasks = $pageCollection->getAllDrawingTasks($this); $this->invokeTasks($tasks); }
[ "public", "function", "draw", "(", "$", "pages", ")", "{", "if", "(", "$", "this", "->", "isProcessed", "(", ")", ")", "{", "throw", "new", "LogicException", "(", "sprintf", "(", "'Pdf has alredy been drawed.'", ")", ")", ";", "}", "$", "this", "->", "...
Invokes drawing procedure. Formats each of node, retreives drawing tasks and executes them. @param array $pages Array of pages to draw
[ "Invokes", "drawing", "procedure", "." ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Document.php#L154-L191
train
psliwa/PHPPdf
lib/PHPPdf/Core/AttributeBag.php
AttributeBag.merge
public static function merge(array $bags) { $mergedBag = new static(); foreach($bags as $bag) { foreach($bag->getAll() as $name => $value) { $mergedBag->add($name, $value); } } return $mergedBag; }
php
public static function merge(array $bags) { $mergedBag = new static(); foreach($bags as $bag) { foreach($bag->getAll() as $name => $value) { $mergedBag->add($name, $value); } } return $mergedBag; }
[ "public", "static", "function", "merge", "(", "array", "$", "bags", ")", "{", "$", "mergedBag", "=", "new", "static", "(", ")", ";", "foreach", "(", "$", "bags", "as", "$", "bag", ")", "{", "foreach", "(", "$", "bag", "->", "getAll", "(", ")", "a...
Merge couple of bags into one. Type of return object depends on invocation context. Return object is as same type as class used in invocation (late state binding). @param array $bags Array of Bag objects @return Bag Single Bag object contains merged data
[ "Merge", "couple", "of", "bags", "into", "one", "." ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/AttributeBag.php#L71-L84
train
psliwa/PHPPdf
lib/PHPPdf/Core/Point.php
Point.compareYCoord
public function compareYCoord(Point $point, $precision = 1000) { return $this->compare($this->y, $point->y, $precision); }
php
public function compareYCoord(Point $point, $precision = 1000) { return $this->compare($this->y, $point->y, $precision); }
[ "public", "function", "compareYCoord", "(", "Point", "$", "point", ",", "$", "precision", "=", "1000", ")", "{", "return", "$", "this", "->", "compare", "(", "$", "this", "->", "y", ",", "$", "point", "->", "y", ",", "$", "precision", ")", ";", "}"...
Compares y coord in given precision @param Point $point Point to compare @param integer $precision Precision of comparision @return integer Positive number if y coord of owner is greater, 0 if values are equal or negative integer if owner is less
[ "Compares", "y", "coord", "in", "given", "precision" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Point.php#L77-L80
train
psliwa/PHPPdf
lib/PHPPdf/Core/Point.php
Point.compareXCoord
public function compareXCoord(Point $point, $precision = 1000) { return $this->compare($this->x, $point->x, $precision); }
php
public function compareXCoord(Point $point, $precision = 1000) { return $this->compare($this->x, $point->x, $precision); }
[ "public", "function", "compareXCoord", "(", "Point", "$", "point", ",", "$", "precision", "=", "1000", ")", "{", "return", "$", "this", "->", "compare", "(", "$", "this", "->", "x", ",", "$", "point", "->", "x", ",", "$", "precision", ")", ";", "}"...
Compares x coord in given precision @param Point $point Point to compare @param integer $precision Precision of comparision @return integer Positive number if x coord of owner is greater, 0 if values are equal or negative integer if owner is less
[ "Compares", "x", "coord", "in", "given", "precision" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Point.php#L117-L120
train
psliwa/PHPPdf
lib/PHPPdf/Parser/XmlParser.php
XmlParser.read
protected function read(\XMLReader $reader) { libxml_clear_errors(); $status = @$reader->read(); $error = libxml_get_last_error(); if($error) { libxml_clear_errors(); throw new Exceptions\ParseException(sprintf('Xml parsing error "%s" in file "%s" on line %s on column %s', $error->message, $error->file, $error->line, $error->column)); } return $status; }
php
protected function read(\XMLReader $reader) { libxml_clear_errors(); $status = @$reader->read(); $error = libxml_get_last_error(); if($error) { libxml_clear_errors(); throw new Exceptions\ParseException(sprintf('Xml parsing error "%s" in file "%s" on line %s on column %s', $error->message, $error->file, $error->line, $error->column)); } return $status; }
[ "protected", "function", "read", "(", "\\", "XMLReader", "$", "reader", ")", "{", "libxml_clear_errors", "(", ")", ";", "$", "status", "=", "@", "$", "reader", "->", "read", "(", ")", ";", "$", "error", "=", "libxml_get_last_error", "(", ")", ";", "if"...
Converts XMLReader's error on ParseException
[ "Converts", "XMLReader", "s", "error", "on", "ParseException" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Parser/XmlParser.php#L111-L125
train
psliwa/PHPPdf
lib/PHPPdf/Core/ComplexAttribute/ComplexAttributeFactory.php
ComplexAttributeFactory.create
public function create($name, array $parameters = array()) { $key = $this->getInstanceKey($name, $parameters); if(!isset($this->instances[$key])) { $this->instances[$key] = $this->createInstance($name, $parameters); } return $this->instances[$key]; }
php
public function create($name, array $parameters = array()) { $key = $this->getInstanceKey($name, $parameters); if(!isset($this->instances[$key])) { $this->instances[$key] = $this->createInstance($name, $parameters); } return $this->instances[$key]; }
[ "public", "function", "create", "(", "$", "name", ",", "array", "$", "parameters", "=", "array", "(", ")", ")", "{", "$", "key", "=", "$", "this", "->", "getInstanceKey", "(", "$", "name", ",", "$", "parameters", ")", ";", "if", "(", "!", "isset", ...
Return instance of ComplexAttribute registered under passed named and parameters. Internally this method uses Flyweight pattern to reuse complexAttribute's objects @param string $name Name of complexAttribute @param array $parameters Parameters of complexAttribute @return PHPPdf\Core\ComplexAttribute\ComplexAttribute
[ "Return", "instance", "of", "ComplexAttribute", "registered", "under", "passed", "named", "and", "parameters", "." ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/ComplexAttribute/ComplexAttributeFactory.php#L124-L134
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/BasicList.php
BasicList.setType
public function setType($type) { $const = sprintf('%s::TYPE_%s', __CLASS__, strtoupper($type)); if(defined($const)) { $type = constant($const); } $this->setAttributeDirectly('type', $type); $this->enumerationStrategy = null; }
php
public function setType($type) { $const = sprintf('%s::TYPE_%s', __CLASS__, strtoupper($type)); if(defined($const)) { $type = constant($const); } $this->setAttributeDirectly('type', $type); $this->enumerationStrategy = null; }
[ "public", "function", "setType", "(", "$", "type", ")", "{", "$", "const", "=", "sprintf", "(", "'%s::TYPE_%s'", ",", "__CLASS__", ",", "strtoupper", "(", "$", "type", ")", ")", ";", "if", "(", "defined", "(", "$", "const", ")", ")", "{", "$", "typ...
Sets list type Implementation of this method also clears enumeration strategy property @param string List type
[ "Sets", "list", "type" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/BasicList.php#L83-L95
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.getComplexAttributes
public function getComplexAttributes($name = null) { if($name === null) { return $this->complexAttributeBag->getAll(); } return $this->complexAttributeBag->get($name); }
php
public function getComplexAttributes($name = null) { if($name === null) { return $this->complexAttributeBag->getAll(); } return $this->complexAttributeBag->get($name); }
[ "public", "function", "getComplexAttributes", "(", "$", "name", "=", "null", ")", "{", "if", "(", "$", "name", "===", "null", ")", "{", "return", "$", "this", "->", "complexAttributeBag", "->", "getAll", "(", ")", ";", "}", "return", "$", "this", "->",...
Get all complexAttribute data or data of complexAttribute with passed name @param string $name Name of complexAttribute to get @return array If $name is null, data of all complexAttributes will be returned, otherwise data of complexAttribute with passed name will be returned.
[ "Get", "all", "complexAttribute", "data", "or", "data", "of", "complexAttribute", "with", "passed", "name" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L268-L276
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.getAncestorByType
public function getAncestorByType($type) { $current = $this; do { $parent = $current->parent; $current = $parent; } while($parent && !$parent instanceof $type); return $parent; }
php
public function getAncestorByType($type) { $current = $this; do { $parent = $current->parent; $current = $parent; } while($parent && !$parent instanceof $type); return $parent; }
[ "public", "function", "getAncestorByType", "(", "$", "type", ")", "{", "$", "current", "=", "$", "this", ";", "do", "{", "$", "parent", "=", "$", "current", "->", "parent", ";", "$", "current", "=", "$", "parent", ";", "}", "while", "(", "$", "pare...
Gets ancestor with passed type. If ancestor has not been found, null will be returned. @param string $type Full class name with namespace @return PHPPdf\Core\Node\Node Nearest ancestor in $type
[ "Gets", "ancestor", "with", "passed", "type", ".", "If", "ancestor", "has", "not", "been", "found", "null", "will", "be", "returned", "." ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L383-L394
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.getFont
public function getFont(Document $document) { $fontType = $this->getRecurseAttribute('font-type'); if($fontType) { $font = $document->getFont($fontType); $fontStyle = $this->getRecurseAttribute('font-style'); if($fontStyle) { $font->setStyle($fontStyle); } return $font; } return null; }
php
public function getFont(Document $document) { $fontType = $this->getRecurseAttribute('font-type'); if($fontType) { $font = $document->getFont($fontType); $fontStyle = $this->getRecurseAttribute('font-style'); if($fontStyle) { $font->setStyle($fontStyle); } return $font; } return null; }
[ "public", "function", "getFont", "(", "Document", "$", "document", ")", "{", "$", "fontType", "=", "$", "this", "->", "getRecurseAttribute", "(", "'font-type'", ")", ";", "if", "(", "$", "fontType", ")", "{", "$", "font", "=", "$", "document", "->", "g...
Gets font object associated with current object @return Font
[ "Gets", "font", "object", "associated", "with", "current", "object" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L462-L480
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.setWidth
public function setWidth($width) { $width = $this->convertUnit($width); $this->setAttributeDirectly('width', $width); if(\strpos($width, '%') !== false) { $this->setRelativeWidth($width); } return $this; }
php
public function setWidth($width) { $width = $this->convertUnit($width); $this->setAttributeDirectly('width', $width); if(\strpos($width, '%') !== false) { $this->setRelativeWidth($width); } return $this; }
[ "public", "function", "setWidth", "(", "$", "width", ")", "{", "$", "width", "=", "$", "this", "->", "convertUnit", "(", "$", "width", ")", ";", "$", "this", "->", "setAttributeDirectly", "(", "'width'", ",", "$", "width", ")", ";", "if", "(", "\\", ...
Set target width @param int|null $width
[ "Set", "target", "width" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L538-L549
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.setHeight
public function setHeight($height) { $height = $this->convertUnit($height); $this->setAttributeDirectly('height', $height); return $this; }
php
public function setHeight($height) { $height = $this->convertUnit($height); $this->setAttributeDirectly('height', $height); return $this; }
[ "public", "function", "setHeight", "(", "$", "height", ")", "{", "$", "height", "=", "$", "this", "->", "convertUnit", "(", "$", "height", ")", ";", "$", "this", "->", "setAttributeDirectly", "(", "'height'", ",", "$", "height", ")", ";", "return", "$"...
Set target height @param int|null $height
[ "Set", "target", "height" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L633-L639
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.setMargin
public function setMargin() { $margins = \func_get_args(); if(count($margins) === 1 && is_string(current($margins))) { $margins = explode(' ', current($margins)); } $marginLabels = array('margin-top', 'margin-right', 'margin-bottom', 'margin-left'); $this->setComposeAttribute($marginLabels, $margins); return $this; }
php
public function setMargin() { $margins = \func_get_args(); if(count($margins) === 1 && is_string(current($margins))) { $margins = explode(' ', current($margins)); } $marginLabels = array('margin-top', 'margin-right', 'margin-bottom', 'margin-left'); $this->setComposeAttribute($marginLabels, $margins); return $this; }
[ "public", "function", "setMargin", "(", ")", "{", "$", "margins", "=", "\\", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "margins", ")", "===", "1", "&&", "is_string", "(", "current", "(", "$", "margins", ")", ")", ")", "{", "$", ...
Setting "css style" margins
[ "Setting", "css", "style", "margins" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L739-L752
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.setPadding
public function setPadding() { $paddings = \func_get_args(); if(count($paddings) === 1 && is_string(current($paddings))) { $paddings = explode(' ', current($paddings)); } $paddingLabels = array('padding-top', 'padding-right', 'padding-bottom', 'padding-left'); $this->setComposeAttribute($paddingLabels, $paddings); return $this; }
php
public function setPadding() { $paddings = \func_get_args(); if(count($paddings) === 1 && is_string(current($paddings))) { $paddings = explode(' ', current($paddings)); } $paddingLabels = array('padding-top', 'padding-right', 'padding-bottom', 'padding-left'); $this->setComposeAttribute($paddingLabels, $paddings); return $this; }
[ "public", "function", "setPadding", "(", ")", "{", "$", "paddings", "=", "\\", "func_get_args", "(", ")", ";", "if", "(", "count", "(", "$", "paddings", ")", "===", "1", "&&", "is_string", "(", "current", "(", "$", "paddings", ")", ")", ")", "{", "...
Set "css style" paddings
[ "Set", "css", "style", "paddings" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L779-L793
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.setAttribute
public function setAttribute($name, $value) { $this->throwExceptionIfAttributeDosntExist($name); $class = get_class($this); if(isset(self::$attributeSetters[$class][$name])) { $methodName = self::$attributeSetters[$class][$name]; $this->$methodName($value); } else { $this->setAttributeDirectly($name, $value); } return $this; }
php
public function setAttribute($name, $value) { $this->throwExceptionIfAttributeDosntExist($name); $class = get_class($this); if(isset(self::$attributeSetters[$class][$name])) { $methodName = self::$attributeSetters[$class][$name]; $this->$methodName($value); } else { $this->setAttributeDirectly($name, $value); } return $this; }
[ "public", "function", "setAttribute", "(", "$", "name", ",", "$", "value", ")", "{", "$", "this", "->", "throwExceptionIfAttributeDosntExist", "(", "$", "name", ")", ";", "$", "class", "=", "get_class", "(", "$", "this", ")", ";", "if", "(", "isset", "...
Sets attribute value @param string $name Name of attribute @param mixed $value Value of attribute @throws InvalidAttributeException If attribute isn't supported by this node @return Node Self reference
[ "Sets", "attribute", "value" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L938-L954
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.getAttribute
public function getAttribute($name) { $this->throwExceptionIfAttributeDosntExist($name); $class = get_class($this); if(isset(self::$attributeGetters[$class][$name])) { $methodName = self::$attributeGetters[$class][$name]; return $this->$methodName(); } else { return $this->getAttributeDirectly($name); } }
php
public function getAttribute($name) { $this->throwExceptionIfAttributeDosntExist($name); $class = get_class($this); if(isset(self::$attributeGetters[$class][$name])) { $methodName = self::$attributeGetters[$class][$name]; return $this->$methodName(); } else { return $this->getAttributeDirectly($name); } }
[ "public", "function", "getAttribute", "(", "$", "name", ")", "{", "$", "this", "->", "throwExceptionIfAttributeDosntExist", "(", "$", "name", ")", ";", "$", "class", "=", "get_class", "(", "$", "this", ")", ";", "if", "(", "isset", "(", "self", "::", "...
Returns attribute value @param string $name Name of attribute @throws InvalidAttributeException If attribute isn't supported by this node @return mixed Value of attribute
[ "Returns", "attribute", "value" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L1064-L1078
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.getRecurseAttribute
public function getRecurseAttribute($name) { $value = $this->getAttribute($name); $parent = $this->parent; if($value === null && $parent) { $value = $parent->getRecurseAttribute($name); $this->setAttribute($name, $value); return $value; } return $value; }
php
public function getRecurseAttribute($name) { $value = $this->getAttribute($name); $parent = $this->parent; if($value === null && $parent) { $value = $parent->getRecurseAttribute($name); $this->setAttribute($name, $value); return $value; } return $value; }
[ "public", "function", "getRecurseAttribute", "(", "$", "name", ")", "{", "$", "value", "=", "$", "this", "->", "getAttribute", "(", "$", "name", ")", ";", "$", "parent", "=", "$", "this", "->", "parent", ";", "if", "(", "$", "value", "===", "null", ...
Getting attribute from this node or parents. If value of attribute is null, this method is recurse invoking on parent.
[ "Getting", "attribute", "from", "this", "node", "or", "parents", ".", "If", "value", "of", "attribute", "is", "null", "this", "method", "is", "recurse", "invoking", "on", "parent", "." ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L1084-L1096
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.makeAttributesSnapshot
public function makeAttributesSnapshot(array $attributeNames = null) { if($attributeNames === null) { $attributeNames = array_keys($this->attributes); } $class = get_class($this); $this->attributesSnapshot = array_intersect_key($this->attributes + self::$defaultAttributes[$class], array_flip($attributeNames)); }
php
public function makeAttributesSnapshot(array $attributeNames = null) { if($attributeNames === null) { $attributeNames = array_keys($this->attributes); } $class = get_class($this); $this->attributesSnapshot = array_intersect_key($this->attributes + self::$defaultAttributes[$class], array_flip($attributeNames)); }
[ "public", "function", "makeAttributesSnapshot", "(", "array", "$", "attributeNames", "=", "null", ")", "{", "if", "(", "$", "attributeNames", "===", "null", ")", "{", "$", "attributeNames", "=", "array_keys", "(", "$", "this", "->", "attributes", ")", ";", ...
Make snapshot of attribute's map
[ "Make", "snapshot", "of", "attribute", "s", "map" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L1101-L1109
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.collectOrderedDrawingTasks
public function collectOrderedDrawingTasks(Document $document, DrawingTaskHeap $tasks) { try { $this->preDraw($document, $tasks); $this->doDraw($document, $tasks); $this->postDraw($document, $tasks); } catch(\Exception $e) { throw new \PHPPdf\Core\Exception\DrawingException(sprintf('Error while drawing node "%s"', get_class($this)), 0, $e); } }
php
public function collectOrderedDrawingTasks(Document $document, DrawingTaskHeap $tasks) { try { $this->preDraw($document, $tasks); $this->doDraw($document, $tasks); $this->postDraw($document, $tasks); } catch(\Exception $e) { throw new \PHPPdf\Core\Exception\DrawingException(sprintf('Error while drawing node "%s"', get_class($this)), 0, $e); } }
[ "public", "function", "collectOrderedDrawingTasks", "(", "Document", "$", "document", ",", "DrawingTaskHeap", "$", "tasks", ")", "{", "try", "{", "$", "this", "->", "preDraw", "(", "$", "document", ",", "$", "tasks", ")", ";", "$", "this", "->", "doDraw", ...
Returns array of PHPPdf\Core\DrawingTask objects. Those objects encapsulate drawing function. @return array Array of PHPPdf\Core\DrawingTask objects
[ "Returns", "array", "of", "PHPPdf", "\\", "Core", "\\", "DrawingTask", "objects", ".", "Those", "objects", "encapsulate", "drawing", "function", "." ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L1124-L1136
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.translate
public function translate($x, $y) { if(!$x && !$y) { return; } $this->getBoundary()->translate($x, $y); }
php
public function translate($x, $y) { if(!$x && !$y) { return; } $this->getBoundary()->translate($x, $y); }
[ "public", "function", "translate", "(", "$", "x", ",", "$", "y", ")", "{", "if", "(", "!", "$", "x", "&&", "!", "$", "y", ")", "{", "return", ";", "}", "$", "this", "->", "getBoundary", "(", ")", "->", "translate", "(", "$", "x", ",", "$", ...
Translates position of this node @param float $x X coord of translation vector @param float $y Y coord of translation vector
[ "Translates", "position", "of", "this", "node" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L1347-L1355
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.resize
public function resize($x, $y) { if(!$x && !$y) { return; } $diagonalXCoord = $this->getDiagonalPoint()->getX() - $this->getPaddingRight(); $firstXCoord = $this->getFirstPoint()->getX() + $this->getPaddingLeft(); $this->getBoundary()->pointTranslate(1, $x, 0); $this->getBoundary()->pointTranslate(2, $x, $y); $this->getBoundary()->pointTranslate(3, 0, $y); $this->setHeight($this->getHeight() + $y); $this->setWidth($this->getWidth() + $x); foreach($this->getChildren() as $child) { if($child->getFloat() === Node::FLOAT_RIGHT) { $child->translate($x - $this->getPaddingRight(), 0); } else { $childDiagonalXCoord = $child->getDiagonalPoint()->getX() + $child->getMarginRight(); $childFirstXCoord = $child->getFirstPoint()->getX(); $relativeWidth = $child->getRelativeWidth(); if($relativeWidth !== null) { $relativeWidth = ($x + $diagonalXCoord - $firstXCoord)*((int) $relativeWidth)/100; $childResize = (($childFirstXCoord + $relativeWidth) + $child->getMarginRight()) - $childDiagonalXCoord; } else { $childResize = $x + ($diagonalXCoord - $childDiagonalXCoord); $childResize = $childResize < 0 ? $childResize : 0; } if($childResize != 0) { $child->resize($childResize, 0); } } } }
php
public function resize($x, $y) { if(!$x && !$y) { return; } $diagonalXCoord = $this->getDiagonalPoint()->getX() - $this->getPaddingRight(); $firstXCoord = $this->getFirstPoint()->getX() + $this->getPaddingLeft(); $this->getBoundary()->pointTranslate(1, $x, 0); $this->getBoundary()->pointTranslate(2, $x, $y); $this->getBoundary()->pointTranslate(3, 0, $y); $this->setHeight($this->getHeight() + $y); $this->setWidth($this->getWidth() + $x); foreach($this->getChildren() as $child) { if($child->getFloat() === Node::FLOAT_RIGHT) { $child->translate($x - $this->getPaddingRight(), 0); } else { $childDiagonalXCoord = $child->getDiagonalPoint()->getX() + $child->getMarginRight(); $childFirstXCoord = $child->getFirstPoint()->getX(); $relativeWidth = $child->getRelativeWidth(); if($relativeWidth !== null) { $relativeWidth = ($x + $diagonalXCoord - $firstXCoord)*((int) $relativeWidth)/100; $childResize = (($childFirstXCoord + $relativeWidth) + $child->getMarginRight()) - $childDiagonalXCoord; } else { $childResize = $x + ($diagonalXCoord - $childDiagonalXCoord); $childResize = $childResize < 0 ? $childResize : 0; } if($childResize != 0) { $child->resize($childResize, 0); } } } }
[ "public", "function", "resize", "(", "$", "x", ",", "$", "y", ")", "{", "if", "(", "!", "$", "x", "&&", "!", "$", "y", ")", "{", "return", ";", "}", "$", "diagonalXCoord", "=", "$", "this", "->", "getDiagonalPoint", "(", ")", "->", "getX", "(",...
Resizes node by passed sizes @param float $x Value of width's resize @param float $y Value of height's resize
[ "Resizes", "node", "by", "passed", "sizes" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L1363-L1410
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.getChild
public function getChild($index) { $children = $this->getChildren(); if(!isset($children[$index])) { throw new OutOfBoundsException(sprintf('Child "%s" dosn\'t exist.', $index)); } return $children[$index]; }
php
public function getChild($index) { $children = $this->getChildren(); if(!isset($children[$index])) { throw new OutOfBoundsException(sprintf('Child "%s" dosn\'t exist.', $index)); } return $children[$index]; }
[ "public", "function", "getChild", "(", "$", "index", ")", "{", "$", "children", "=", "$", "this", "->", "getChildren", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "children", "[", "$", "index", "]", ")", ")", "{", "throw", "new", "OutOfBounds...
Gets child under passed index @param integer Index of child @return Node @throws OutOfBoundsException Child dosn't exist
[ "Gets", "child", "under", "passed", "index" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L1558-L1568
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.format
public function format(Document $document) { $this->preFormat($document); foreach($this->getChildren() as $child) { $child->format($document); } $this->postFormat($document); }
php
public function format(Document $document) { $this->preFormat($document); foreach($this->getChildren() as $child) { $child->format($document); } $this->postFormat($document); }
[ "public", "function", "format", "(", "Document", "$", "document", ")", "{", "$", "this", "->", "preFormat", "(", "$", "document", ")", ";", "foreach", "(", "$", "this", "->", "getChildren", "(", ")", "as", "$", "child", ")", "{", "$", "child", "->", ...
Format node by given formatters.
[ "Format", "node", "by", "given", "formatters", "." ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L1599-L1607
train
psliwa/PHPPdf
lib/PHPPdf/Core/Node/Node.php
Node.flush
public function flush() { $this->ancestorWithFontSize = null; $this->ancestorWithRotation = null; $this->closestAncestorWithPosition = null; foreach($this->getChildren() as $child) { $child->flush(); } $this->removeAll(); }
php
public function flush() { $this->ancestorWithFontSize = null; $this->ancestorWithRotation = null; $this->closestAncestorWithPosition = null; foreach($this->getChildren() as $child) { $child->flush(); } $this->removeAll(); }
[ "public", "function", "flush", "(", ")", "{", "$", "this", "->", "ancestorWithFontSize", "=", "null", ";", "$", "this", "->", "ancestorWithRotation", "=", "null", ";", "$", "this", "->", "closestAncestorWithPosition", "=", "null", ";", "foreach", "(", "$", ...
Free references to other object, after this method invocation Node is in invalid state!
[ "Free", "references", "to", "other", "object", "after", "this", "method", "invocation", "Node", "is", "in", "invalid", "state!" ]
2e38a658117b6a0465ac2b89bd169e90a4151cff
https://github.com/psliwa/PHPPdf/blob/2e38a658117b6a0465ac2b89bd169e90a4151cff/lib/PHPPdf/Core/Node/Node.php#L1878-L1890
train
hiqdev/hidev
src/base/Binary.php
Binary.passthru
public function passthru($args = []) { $command = $this->prepareCommand($args); Yii::info("> $command"); passthru($command, $exitcode); return $exitcode; }
php
public function passthru($args = []) { $command = $this->prepareCommand($args); Yii::info("> $command"); passthru($command, $exitcode); return $exitcode; }
[ "public", "function", "passthru", "(", "$", "args", "=", "[", "]", ")", "{", "$", "command", "=", "$", "this", "->", "prepareCommand", "(", "$", "args", ")", ";", "Yii", "::", "info", "(", "\"> $command\"", ")", ";", "passthru", "(", "$", "command", ...
Prepares and runs with passthru, returns exit code. @param string|array $args @return int exit code
[ "Prepares", "and", "runs", "with", "passthru", "returns", "exit", "code", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/base/Binary.php#L73-L80
train
hiqdev/hidev
src/base/Binary.php
Binary.exec
public function exec($args = [], $returnExitCode = false) { $command = $this->prepareCommand($args); Yii::info("& $command"); exec($command, $array, $exitcode); return $returnExitCode ? $exitcode : $array; }
php
public function exec($args = [], $returnExitCode = false) { $command = $this->prepareCommand($args); Yii::info("& $command"); exec($command, $array, $exitcode); return $returnExitCode ? $exitcode : $array; }
[ "public", "function", "exec", "(", "$", "args", "=", "[", "]", ",", "$", "returnExitCode", "=", "false", ")", "{", "$", "command", "=", "$", "this", "->", "prepareCommand", "(", "$", "args", ")", ";", "Yii", "::", "info", "(", "\"& $command\"", ")", ...
Prepares and runs with exec, returns stdout array. @param string|array $args @param bool $returnExitCode default false @return array|int stdout or exit code
[ "Prepares", "and", "runs", "with", "exec", "returns", "stdout", "array", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/base/Binary.php#L88-L95
train
hiqdev/hidev
src/base/Binary.php
Binary.prepareCommand
public function prepareCommand($args) { $command = $this->getCommand(); if (is_string($args)) { return $command . ' ' . trim($args); } foreach ($args as $arg) { if ($arg instanceof ModifierInterface) { $command = $arg->modify($command); } else { $command .= ' ' . escapeshellarg($arg); } } return $command; }
php
public function prepareCommand($args) { $command = $this->getCommand(); if (is_string($args)) { return $command . ' ' . trim($args); } foreach ($args as $arg) { if ($arg instanceof ModifierInterface) { $command = $arg->modify($command); } else { $command .= ' ' . escapeshellarg($arg); } } return $command; }
[ "public", "function", "prepareCommand", "(", "$", "args", ")", "{", "$", "command", "=", "$", "this", "->", "getCommand", "(", ")", ";", "if", "(", "is_string", "(", "$", "args", ")", ")", "{", "return", "$", "command", ".", "' '", ".", "trim", "("...
Prepare full command line ready for execution. @param string|array $args @return string
[ "Prepare", "full", "command", "line", "ready", "for", "execution", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/base/Binary.php#L102-L118
train
hiqdev/hidev
src/base/Binary.php
Binary.getPath
public function getPath() { if (!$this->_path) { $this->_path = $this->detectPath($this->name); } return $this->_path; }
php
public function getPath() { if (!$this->_path) { $this->_path = $this->detectPath($this->name); } return $this->_path; }
[ "public", "function", "getPath", "(", ")", "{", "if", "(", "!", "$", "this", "->", "_path", ")", "{", "$", "this", "->", "_path", "=", "$", "this", "->", "detectPath", "(", "$", "this", "->", "name", ")", ";", "}", "return", "$", "this", "->", ...
Getter for path. @return string
[ "Getter", "for", "path", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/base/Binary.php#L138-L145
train
hiqdev/hidev
src/console/CommonBehavior.php
CommonBehavior.runRequest
public function runRequest($query) { $request = Yii::createObject([ 'class' => Request::class, 'params' => is_array($query) ? $query : array_filter(explode(' ', $query)), ]); return Yii::$app->handleRequest($request); }
php
public function runRequest($query) { $request = Yii::createObject([ 'class' => Request::class, 'params' => is_array($query) ? $query : array_filter(explode(' ', $query)), ]); return Yii::$app->handleRequest($request); }
[ "public", "function", "runRequest", "(", "$", "query", ")", "{", "$", "request", "=", "Yii", "::", "createObject", "(", "[", "'class'", "=>", "Request", "::", "class", ",", "'params'", "=>", "is_array", "(", "$", "query", ")", "?", "$", "query", ":", ...
Run request. @param string|array $query @return Response
[ "Run", "request", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/console/CommonBehavior.php#L84-L92
train
hiqdev/hidev
src/handlers/BaseHandler.php
BaseHandler.read
public function read($path, $asArray = false) { if (file_exists($path)) { Yii::info('Read file: ' . $path, 'file'); return $asArray ? file($path) : file_get_contents($path); } else { Yii::warning('Couldn\'t read file: ' . $path, 'file'); return; } }
php
public function read($path, $asArray = false) { if (file_exists($path)) { Yii::info('Read file: ' . $path, 'file'); return $asArray ? file($path) : file_get_contents($path); } else { Yii::warning('Couldn\'t read file: ' . $path, 'file'); return; } }
[ "public", "function", "read", "(", "$", "path", ",", "$", "asArray", "=", "false", ")", "{", "if", "(", "file_exists", "(", "$", "path", ")", ")", "{", "Yii", "::", "info", "(", "'Read file: '", ".", "$", "path", ",", "'file'", ")", ";", "return", ...
Read file into a string or array. @param string $path @param bool $asArray @return string|array
[ "Read", "file", "into", "a", "string", "or", "array", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/handlers/BaseHandler.php#L137-L148
train
hiqdev/hidev
src/components/File.php
File.getFile
public function getFile() { if (!is_object($this->_file)) { $this->_file = Yii::createObject(array_merge([ 'class' => FileObj::class, 'template' => $this->getTemplate(), 'goal' => $this, 'path' => $this->_path ?: $this->id, ], is_string($this->_file) ? ['path' => $this->_file] : (array) $this->_file )); } return $this->_file; }
php
public function getFile() { if (!is_object($this->_file)) { $this->_file = Yii::createObject(array_merge([ 'class' => FileObj::class, 'template' => $this->getTemplate(), 'goal' => $this, 'path' => $this->_path ?: $this->id, ], is_string($this->_file) ? ['path' => $this->_file] : (array) $this->_file )); } return $this->_file; }
[ "public", "function", "getFile", "(", ")", "{", "if", "(", "!", "is_object", "(", "$", "this", "->", "_file", ")", ")", "{", "$", "this", "->", "_file", "=", "Yii", "::", "createObject", "(", "array_merge", "(", "[", "'class'", "=>", "FileObj", "::",...
Returns the file object. Instantiates it if necessary. @return FileObj
[ "Returns", "the", "file", "object", ".", "Instantiates", "it", "if", "necessary", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/components/File.php#L98-L113
train
hiqdev/hidev
src/base/Controller.php
Controller.runActions
public function runActions($actions) { foreach ($this->normalizeTasks($actions) as $action => $enabled) { if ($enabled) { $res = $this->runAction($action); if (!Helper::isResponseOk($res)) { return $res; } } } return 0; }
php
public function runActions($actions) { foreach ($this->normalizeTasks($actions) as $action => $enabled) { if ($enabled) { $res = $this->runAction($action); if (!Helper::isResponseOk($res)) { return $res; } } } return 0; }
[ "public", "function", "runActions", "(", "$", "actions", ")", "{", "foreach", "(", "$", "this", "->", "normalizeTasks", "(", "$", "actions", ")", "as", "$", "action", "=>", "$", "enabled", ")", "{", "if", "(", "$", "enabled", ")", "{", "$", "res", ...
Runs list of actions. @param null|string|array $actions @return int|Response exit code
[ "Runs", "list", "of", "actions", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/base/Controller.php#L60-L72
train
hiqdev/hidev
src/base/GettersTrait.php
GettersTrait.exec
public function exec($name, $args = '', $returnExitCode = false) { return $this->take('binaries')->execBinary($name, $args, $returnExitCode); }
php
public function exec($name, $args = '', $returnExitCode = false) { return $this->take('binaries')->execBinary($name, $args, $returnExitCode); }
[ "public", "function", "exec", "(", "$", "name", ",", "$", "args", "=", "''", ",", "$", "returnExitCode", "=", "false", ")", "{", "return", "$", "this", "->", "take", "(", "'binaries'", ")", "->", "execBinary", "(", "$", "name", ",", "$", "args", ",...
Runs given binary with given arguments. Returns stdout array. @param string $name @param string $args @param bool $returnExitCode, default false @return array|int stdout or exitcode
[ "Runs", "given", "binary", "with", "given", "arguments", ".", "Returns", "stdout", "array", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/base/GettersTrait.php#L61-L64
train
hiqdev/hidev
src/base/Starter.php
Starter.requireAll
private function requireAll() { $vendors = []; $plugins = $this->goals['plugins']; if ($plugins) { $file = File::create('.hidev/composer.json'); $data = ArrayHelper::merge($file->load(), ['require' => $plugins]); if ($file->save($data) || !is_dir('.hidev/vendor')) { $this->updateDotHidev(); } $vendors[] = $this->buildRootPath('.hidev/vendor'); } if ($this->needsComposerInstall()) { if ($this->passthru('composer', ['install', '--ansi'])) { throw new InvalidParamException('Failed initialize project with composer install'); } } $vendors[] = $this->buildRootPath('vendor'); foreach ($vendors as $vendor) { foreach (['console', 'hidev'] as $name) { $path = ConfigPlugin::path($name, $vendor); if (file_exists($path)) { $this->appFiles[] = $path; } } } }
php
private function requireAll() { $vendors = []; $plugins = $this->goals['plugins']; if ($plugins) { $file = File::create('.hidev/composer.json'); $data = ArrayHelper::merge($file->load(), ['require' => $plugins]); if ($file->save($data) || !is_dir('.hidev/vendor')) { $this->updateDotHidev(); } $vendors[] = $this->buildRootPath('.hidev/vendor'); } if ($this->needsComposerInstall()) { if ($this->passthru('composer', ['install', '--ansi'])) { throw new InvalidParamException('Failed initialize project with composer install'); } } $vendors[] = $this->buildRootPath('vendor'); foreach ($vendors as $vendor) { foreach (['console', 'hidev'] as $name) { $path = ConfigPlugin::path($name, $vendor); if (file_exists($path)) { $this->appFiles[] = $path; } } } }
[ "private", "function", "requireAll", "(", ")", "{", "$", "vendors", "=", "[", "]", ";", "$", "plugins", "=", "$", "this", "->", "goals", "[", "'plugins'", "]", ";", "if", "(", "$", "plugins", ")", "{", "$", "file", "=", "File", "::", "create", "(...
- install configured plugins and register their app config - install project dependencies and register - register application config files.
[ "-", "install", "configured", "plugins", "and", "register", "their", "app", "config", "-", "install", "project", "dependencies", "and", "register", "-", "register", "application", "config", "files", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/base/Starter.php#L236-L263
train
hiqdev/hidev
src/base/Starter.php
Starter.includeAll
private function includeAll() { $config = $this->readConfig(); $files = array_merge( (array) $this->goals['include'], (array) $config['components']['include'] ); $this->includeGoals($files); }
php
private function includeAll() { $config = $this->readConfig(); $files = array_merge( (array) $this->goals['include'], (array) $config['components']['include'] ); $this->includeGoals($files); }
[ "private", "function", "includeAll", "(", ")", "{", "$", "config", "=", "$", "this", "->", "readConfig", "(", ")", ";", "$", "files", "=", "array_merge", "(", "(", "array", ")", "$", "this", "->", "goals", "[", "'include'", "]", ",", "(", "array", ...
Include all configured includes.
[ "Include", "all", "configured", "includes", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/base/Starter.php#L322-L330
train
hiqdev/hidev
src/base/Starter.php
Starter.moreConfig
private function moreConfig() { $paths = $this->goals['config']; foreach ((array) $paths as $path) { if ($path) { $this->appFiles[] = $path; } } }
php
private function moreConfig() { $paths = $this->goals['config']; foreach ((array) $paths as $path) { if ($path) { $this->appFiles[] = $path; } } }
[ "private", "function", "moreConfig", "(", ")", "{", "$", "paths", "=", "$", "this", "->", "goals", "[", "'config'", "]", ";", "foreach", "(", "(", "array", ")", "$", "paths", "as", "$", "path", ")", "{", "if", "(", "$", "path", ")", "{", "$", "...
Registers more application config to load.
[ "Registers", "more", "application", "config", "to", "load", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/base/Starter.php#L335-L343
train
hiqdev/hidev
src/base/Starter.php
Starter.findRootDir
private function findRootDir() { $configFile = 'hidev.yml'; for ($i = 0; $i < 9; ++$i) { if (file_exists($configFile)) { return getcwd(); } chdir('..'); } throw new InvalidParamException("Not a hidev project (or any of the parent directories).\nUse `hidev init` to initialize hidev project."); }
php
private function findRootDir() { $configFile = 'hidev.yml'; for ($i = 0; $i < 9; ++$i) { if (file_exists($configFile)) { return getcwd(); } chdir('..'); } throw new InvalidParamException("Not a hidev project (or any of the parent directories).\nUse `hidev init` to initialize hidev project."); }
[ "private", "function", "findRootDir", "(", ")", "{", "$", "configFile", "=", "'hidev.yml'", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "9", ";", "++", "$", "i", ")", "{", "if", "(", "file_exists", "(", "$", "configFile", ")", ")", ...
Chdirs to project's root by looking for config file in the current directory and up. @throws InvalidParamException when failed to find @return string path to the root directory of hidev project
[ "Chdirs", "to", "project", "s", "root", "by", "looking", "for", "config", "file", "in", "the", "current", "directory", "and", "up", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/base/Starter.php#L364-L374
train
hiqdev/hidev
src/console/DumpController.php
DumpController.actionComponent
public function actionComponent($name = null) { $data = Yii::$app->getComponents(); if ($name) { if (empty($data[$name])) { Yii::error("'$name' not defined"); return; } $data = [$name => $data[$name]]; } echo Yaml::dump($data, 4); }
php
public function actionComponent($name = null) { $data = Yii::$app->getComponents(); if ($name) { if (empty($data[$name])) { Yii::error("'$name' not defined"); return; } $data = [$name => $data[$name]]; } echo Yaml::dump($data, 4); }
[ "public", "function", "actionComponent", "(", "$", "name", "=", "null", ")", "{", "$", "data", "=", "Yii", "::", "$", "app", "->", "getComponents", "(", ")", ";", "if", "(", "$", "name", ")", "{", "if", "(", "empty", "(", "$", "data", "[", "$", ...
Dump defined components. @param string $name component name
[ "Dump", "defined", "components", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/console/DumpController.php#L27-L39
train
hiqdev/hidev
src/console/DumpController.php
DumpController.actionController
public function actionController($name = null) { $data = Yii::$app->controllerMap; if ($name) { if (empty($data[$name])) { Yii::error("'$name' not defined"); return; } $data = [$name => $data[$name]]; } echo Yaml::dump($data, 4); }
php
public function actionController($name = null) { $data = Yii::$app->controllerMap; if ($name) { if (empty($data[$name])) { Yii::error("'$name' not defined"); return; } $data = [$name => $data[$name]]; } echo Yaml::dump($data, 4); }
[ "public", "function", "actionController", "(", "$", "name", "=", "null", ")", "{", "$", "data", "=", "Yii", "::", "$", "app", "->", "controllerMap", ";", "if", "(", "$", "name", ")", "{", "if", "(", "empty", "(", "$", "data", "[", "$", "name", "]...
Dump defined controllers. @param string $name controller name
[ "Dump", "defined", "controllers", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/console/DumpController.php#L45-L57
train
hiqdev/hidev
src/console/DumpController.php
DumpController.actionAlias
public function actionAlias($alias = null) { $data = Yii::$aliases; if ($alias) { $dest = Yii::getAlias($alias, false); if (empty($dest)) { Yii::error("'$alias' not defined"); return; } $data = [$alias => $dest]; } echo Yaml::dump($data, 4); }
php
public function actionAlias($alias = null) { $data = Yii::$aliases; if ($alias) { $dest = Yii::getAlias($alias, false); if (empty($dest)) { Yii::error("'$alias' not defined"); return; } $data = [$alias => $dest]; } echo Yaml::dump($data, 4); }
[ "public", "function", "actionAlias", "(", "$", "alias", "=", "null", ")", "{", "$", "data", "=", "Yii", "::", "$", "aliases", ";", "if", "(", "$", "alias", ")", "{", "$", "dest", "=", "Yii", "::", "getAlias", "(", "$", "alias", ",", "false", ")",...
Dump defined aliases. @param string $alias alias to resolve
[ "Dump", "defined", "aliases", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/console/DumpController.php#L63-L76
train
hiqdev/hidev
src/components/Binaries.php
Binaries.execBinary
public function execBinary($name, $args = '', $returnExitCode = false) { return $this->get($name)->exec($args, $returnExitCode); }
php
public function execBinary($name, $args = '', $returnExitCode = false) { return $this->get($name)->exec($args, $returnExitCode); }
[ "public", "function", "execBinary", "(", "$", "name", ",", "$", "args", "=", "''", ",", "$", "returnExitCode", "=", "false", ")", "{", "return", "$", "this", "->", "get", "(", "$", "name", ")", "->", "exec", "(", "$", "args", ",", "$", "returnExitC...
Prepares and runs with exec. Returns stdout string. @param string $name binary @param string $args @return array stdout
[ "Prepares", "and", "runs", "with", "exec", ".", "Returns", "stdout", "string", "." ]
ac089c8307f68ff7afc2876caa0b6625dd9eb5c7
https://github.com/hiqdev/hidev/blob/ac089c8307f68ff7afc2876caa0b6625dd9eb5c7/src/components/Binaries.php#L62-L65
train
ramsey/rhumsaa-uuid
src/Uuid.php
Uuid.getInteger
public function getInteger() { if (!self::hasBigNumber()) { throw new Exception\UnsatisfiedDependencyException( 'Cannot call ' . __METHOD__ . ' without support for large ' . 'integers, since integer is an unsigned ' . '128-bit integer; Moontoast\Math\BigNumber is required' . '; consider calling getHex instead' ); } $number = \Moontoast\Math\BigNumber::baseConvert( $this->getHex(), 16, 10 ); return new \Moontoast\Math\BigNumber($number); }
php
public function getInteger() { if (!self::hasBigNumber()) { throw new Exception\UnsatisfiedDependencyException( 'Cannot call ' . __METHOD__ . ' without support for large ' . 'integers, since integer is an unsigned ' . '128-bit integer; Moontoast\Math\BigNumber is required' . '; consider calling getHex instead' ); } $number = \Moontoast\Math\BigNumber::baseConvert( $this->getHex(), 16, 10 ); return new \Moontoast\Math\BigNumber($number); }
[ "public", "function", "getInteger", "(", ")", "{", "if", "(", "!", "self", "::", "hasBigNumber", "(", ")", ")", "{", "throw", "new", "Exception", "\\", "UnsatisfiedDependencyException", "(", "'Cannot call '", ".", "__METHOD__", ".", "' without support for large '"...
Returns the integer value of the UUID, represented as a BigNumber @return \Moontoast\Math\BigNumber BigNumber representation of the unsigned 128-bit integer value @throws Exception\UnsatisfiedDependencyException if Moontoast\Math\BigNumber is not present
[ "Returns", "the", "integer", "value", "of", "the", "UUID", "represented", "as", "a", "BigNumber" ]
5d2f77a21d42ad82180d57fead8a7401ac2aa0be
https://github.com/ramsey/rhumsaa-uuid/blob/5d2f77a21d42ad82180d57fead8a7401ac2aa0be/src/Uuid.php#L437-L455
train
ramsey/rhumsaa-uuid
src/Uuid.php
Uuid.fromInteger
public static function fromInteger($integer) { if (!self::hasBigNumber()) { throw new Exception\UnsatisfiedDependencyException( 'Cannot call ' . __METHOD__ . ' without support for large ' . 'integers, since integer is an unsigned ' . '128-bit integer; Moontoast\Math\BigNumber is required. ' ); } if (!$integer instanceof \Moontoast\Math\BigNumber) { $integer = new \Moontoast\Math\BigNumber($integer); } $hex = \Moontoast\Math\BigNumber::baseConvert($integer, 10, 16); $hex = str_pad($hex, 32, '0', STR_PAD_LEFT); return self::fromString($hex); }
php
public static function fromInteger($integer) { if (!self::hasBigNumber()) { throw new Exception\UnsatisfiedDependencyException( 'Cannot call ' . __METHOD__ . ' without support for large ' . 'integers, since integer is an unsigned ' . '128-bit integer; Moontoast\Math\BigNumber is required. ' ); } if (!$integer instanceof \Moontoast\Math\BigNumber) { $integer = new \Moontoast\Math\BigNumber($integer); } $hex = \Moontoast\Math\BigNumber::baseConvert($integer, 10, 16); $hex = str_pad($hex, 32, '0', STR_PAD_LEFT); return self::fromString($hex); }
[ "public", "static", "function", "fromInteger", "(", "$", "integer", ")", "{", "if", "(", "!", "self", "::", "hasBigNumber", "(", ")", ")", "{", "throw", "new", "Exception", "\\", "UnsatisfiedDependencyException", "(", "'Cannot call '", ".", "__METHOD__", ".", ...
Creates a UUID from either the UUID as a 128-bit integer string or a Moontoast\Math\BigNumber object. @param string|\Moontoast\Math\BigNumber $integer String/BigNumber representation of UUID integer @throws Exception\UnsatisfiedDependencyException If Moontoast\Math\BigNumber is not present @return \Rhumsaa\Uuid\Uuid
[ "Creates", "a", "UUID", "from", "either", "the", "UUID", "as", "a", "128", "-", "bit", "integer", "string", "or", "a", "Moontoast", "\\", "Math", "\\", "BigNumber", "object", "." ]
5d2f77a21d42ad82180d57fead8a7401ac2aa0be
https://github.com/ramsey/rhumsaa-uuid/blob/5d2f77a21d42ad82180d57fead8a7401ac2aa0be/src/Uuid.php#L897-L915
train
ramsey/rhumsaa-uuid
src/Console/Command/GenerateCommand.php
GenerateCommand.createUuid
protected function createUuid($version, $namespace = null, $name = null) { switch ((int) $version) { case 1: $uuid = Uuid::uuid1(); break; case 4: $uuid = Uuid::uuid4(); break; case 3: case 5: $ns = $this->validateNamespace($namespace); if (empty($name)) { throw new Exception('The name argument is required for version 3 or 5 UUIDs'); } if ($version == 3) { $uuid = Uuid::uuid3($ns, $name); } else { $uuid = Uuid::uuid5($ns, $name); } break; default: throw new Exception('Invalid UUID version. Supported are version "1", "3", "4", and "5".'); } return $uuid; }
php
protected function createUuid($version, $namespace = null, $name = null) { switch ((int) $version) { case 1: $uuid = Uuid::uuid1(); break; case 4: $uuid = Uuid::uuid4(); break; case 3: case 5: $ns = $this->validateNamespace($namespace); if (empty($name)) { throw new Exception('The name argument is required for version 3 or 5 UUIDs'); } if ($version == 3) { $uuid = Uuid::uuid3($ns, $name); } else { $uuid = Uuid::uuid5($ns, $name); } break; default: throw new Exception('Invalid UUID version. Supported are version "1", "3", "4", and "5".'); } return $uuid; }
[ "protected", "function", "createUuid", "(", "$", "version", ",", "$", "namespace", "=", "null", ",", "$", "name", "=", "null", ")", "{", "switch", "(", "(", "int", ")", "$", "version", ")", "{", "case", "1", ":", "$", "uuid", "=", "Uuid", "::", "...
Creates the requested UUID @param int $version @param string $namespace @param string $name @return Uuid
[ "Creates", "the", "requested", "UUID" ]
5d2f77a21d42ad82180d57fead8a7401ac2aa0be
https://github.com/ramsey/rhumsaa-uuid/blob/5d2f77a21d42ad82180d57fead8a7401ac2aa0be/src/Console/Command/GenerateCommand.php#L106-L132
train