repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
squareproton/Bond
src/Bond/Pg/Result.php
Result.getFetchOptions
public function getFetchOptions( &$humanReadable = null ) { // aid to result fetching debugging // get fetch options in a human readable format if( func_num_args() ) { $humanReadable = []; $refl = new \ReflectionClass( __CLASS__ ); foreach( $refl->getConstants() as $name => $value ) { if( $value & $this->fetchOptions and strpos( $name, 'DEFAULT' ) === false ) { $humanReadable[] = $name; } } } return $this->fetchOptions; }
php
public function getFetchOptions( &$humanReadable = null ) { // aid to result fetching debugging // get fetch options in a human readable format if( func_num_args() ) { $humanReadable = []; $refl = new \ReflectionClass( __CLASS__ ); foreach( $refl->getConstants() as $name => $value ) { if( $value & $this->fetchOptions and strpos( $name, 'DEFAULT' ) === false ) { $humanReadable[] = $name; } } } return $this->fetchOptions; }
[ "public", "function", "getFetchOptions", "(", "&", "$", "humanReadable", "=", "null", ")", "{", "// aid to result fetching debugging", "// get fetch options in a human readable format", "if", "(", "func_num_args", "(", ")", ")", "{", "$", "humanReadable", "=", "[", "]...
Return the bitmask @return
[ "Return", "the", "bitmask" ]
train
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Result.php#L255-L269
squareproton/Bond
src/Bond/Pg/Result.php
Result.fetch
public function fetch( $options = null, $keyResultsByColumn = null ) { $this->setFetchOptions( $options ); // caching if( $this->fetchOptions & self::CACHE ) { // get a cache key for the passed options (we only care about those options that will modify the returned result) $cacheKey = $this->fetchOptions & ( self::TYPE_DETECT | self::TYPE_AGNOSTIC | self::FLATTEN_IF_POSSIBLE | self::FLATTEN_PREVENT | self::STYLE_ASSOC | self::STYLE_NUM | self::FETCH_SINGLE | self::FETCH_MULTIPLE ); if( isset( $this->cacheFetch[$cacheKey] ) ) { return $this->cacheFetch[$cacheKey]; } } // build output $output = array(); // build output array // slight repetition of code here to help us avoid the isset( $types ) check for every row (there might be a __lot__ of rows so this adds up). pg_result_seek( $this->resource, 0 ); if( null === $keyResultsByColumn ) { while( $row = pg_fetch_array( $this->resource, NULL, $this->fetchType ) ) { $output[] = call_user_func( $this->fetchCallback, $row ); } } else { while( $row = pg_fetch_array( $this->resource, NULL, $this->fetchType ) ) { $row = call_user_func( $this->fetchCallback, $row ); $output[$row[$keyResultsByColumn]] = $row; } } // populate the numRows cache as we've now got this information as standard if( !isset( $this->numRows ) ) { $this->numRows = count( $output ); } $this->fetchRowNumber = $this->numRows; // single result behaviour if( $this->fetchOptions & self::FETCH_SINGLE ) { if( $this->numRows() == 0 and $this->numFields() > 1 ) { $output = array(); } elseif( $this->numRows() <= 1 ) { $output = array_pop( $output ); // perhaps we should be returning a exception you call $singleResult and there is > 1 rows returned from the db } else { throw new MoreThanOneRowReturnedException( "{$this->numRows()} returned, FETCH_SINGLE doesn't apply here." ); } } // cache population if( isset($cacheKey) ) { $this->cacheFetch[$cacheKey] = $output; } return $output; }
php
public function fetch( $options = null, $keyResultsByColumn = null ) { $this->setFetchOptions( $options ); // caching if( $this->fetchOptions & self::CACHE ) { // get a cache key for the passed options (we only care about those options that will modify the returned result) $cacheKey = $this->fetchOptions & ( self::TYPE_DETECT | self::TYPE_AGNOSTIC | self::FLATTEN_IF_POSSIBLE | self::FLATTEN_PREVENT | self::STYLE_ASSOC | self::STYLE_NUM | self::FETCH_SINGLE | self::FETCH_MULTIPLE ); if( isset( $this->cacheFetch[$cacheKey] ) ) { return $this->cacheFetch[$cacheKey]; } } // build output $output = array(); // build output array // slight repetition of code here to help us avoid the isset( $types ) check for every row (there might be a __lot__ of rows so this adds up). pg_result_seek( $this->resource, 0 ); if( null === $keyResultsByColumn ) { while( $row = pg_fetch_array( $this->resource, NULL, $this->fetchType ) ) { $output[] = call_user_func( $this->fetchCallback, $row ); } } else { while( $row = pg_fetch_array( $this->resource, NULL, $this->fetchType ) ) { $row = call_user_func( $this->fetchCallback, $row ); $output[$row[$keyResultsByColumn]] = $row; } } // populate the numRows cache as we've now got this information as standard if( !isset( $this->numRows ) ) { $this->numRows = count( $output ); } $this->fetchRowNumber = $this->numRows; // single result behaviour if( $this->fetchOptions & self::FETCH_SINGLE ) { if( $this->numRows() == 0 and $this->numFields() > 1 ) { $output = array(); } elseif( $this->numRows() <= 1 ) { $output = array_pop( $output ); // perhaps we should be returning a exception you call $singleResult and there is > 1 rows returned from the db } else { throw new MoreThanOneRowReturnedException( "{$this->numRows()} returned, FETCH_SINGLE doesn't apply here." ); } } // cache population if( isset($cacheKey) ) { $this->cacheFetch[$cacheKey] = $output; } return $output; }
[ "public", "function", "fetch", "(", "$", "options", "=", "null", ",", "$", "keyResultsByColumn", "=", "null", ")", "{", "$", "this", "->", "setFetchOptions", "(", "$", "options", ")", ";", "// caching", "if", "(", "$", "this", "->", "fetchOptions", "&", ...
Here be the magic! @param int Bitmask of the options @param mixed The column name we want our output to be keyed by @return mixed
[ "Here", "be", "the", "magic!" ]
train
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Result.php#L277-L344
squareproton/Bond
src/Bond/Pg/Result.php
Result.getFieldTypeCallbacks
public function getFieldTypeCallbacks() { $types = array(); $numFields = $this->numFields(); for( $i = 0; $i < $numFields; $i++ ) { $types[pg_field_name( $this->resource, $i )] = TypeConversionFactory::get( pg_field_type( $this->resource, $i ), $this ); } return $types; }
php
public function getFieldTypeCallbacks() { $types = array(); $numFields = $this->numFields(); for( $i = 0; $i < $numFields; $i++ ) { $types[pg_field_name( $this->resource, $i )] = TypeConversionFactory::get( pg_field_type( $this->resource, $i ), $this ); } return $types; }
[ "public", "function", "getFieldTypeCallbacks", "(", ")", "{", "$", "types", "=", "array", "(", ")", ";", "$", "numFields", "=", "$", "this", "->", "numFields", "(", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "numFields", "...
Return a array of php callbacks to be applied to a result set @param array $types
[ "Return", "a", "array", "of", "php", "callbacks", "to", "be", "applied", "to", "a", "result", "set" ]
train
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Result.php#L350-L363
squareproton/Bond
src/Bond/Pg/Result.php
Result.numFields
public function numFields() { if( !isset( $this->numFields ) ) { $this->numFields = pg_num_fields( $this->resource ); } return $this->numFields; }
php
public function numFields() { if( !isset( $this->numFields ) ) { $this->numFields = pg_num_fields( $this->resource ); } return $this->numFields; }
[ "public", "function", "numFields", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "numFields", ")", ")", "{", "$", "this", "->", "numFields", "=", "pg_num_fields", "(", "$", "this", "->", "resource", ")", ";", "}", "return", "$", "...
Caching wrapper for pg_num_fields() @return int
[ "Caching", "wrapper", "for", "pg_num_fields", "()" ]
train
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Result.php#L369-L375
squareproton/Bond
src/Bond/Pg/Result.php
Result.numRows
public function numRows() { if( !isset( $this->numRows ) ) { $this->numRows = pg_num_rows( $this->resource ); } return $this->numRows; }
php
public function numRows() { if( !isset( $this->numRows ) ) { $this->numRows = pg_num_rows( $this->resource ); } return $this->numRows; }
[ "public", "function", "numRows", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "numRows", ")", ")", "{", "$", "this", "->", "numRows", "=", "pg_num_rows", "(", "$", "this", "->", "resource", ")", ";", "}", "return", "$", "this", ...
Caching wrapper for pg_num_rows() @return int
[ "Caching", "wrapper", "for", "pg_num_rows", "()" ]
train
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Result.php#L381-L387
squareproton/Bond
src/Bond/Pg/Result.php
Result.numAffectedRows
public function numAffectedRows() { if( !isset( $this->affectedRows ) ) { $this->affectedRows = pg_affected_rows( $this->resource ); } return $this->affectedRows; }
php
public function numAffectedRows() { if( !isset( $this->affectedRows ) ) { $this->affectedRows = pg_affected_rows( $this->resource ); } return $this->affectedRows; }
[ "public", "function", "numAffectedRows", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "affectedRows", ")", ")", "{", "$", "this", "->", "affectedRows", "=", "pg_affected_rows", "(", "$", "this", "->", "resource", ")", ";", "}", "retu...
Caching wrapper for pg_affected_rows() This appears bugged in php 5.3 and postgres 9.1 returning the number of rows modified by a statement @return int
[ "Caching", "wrapper", "for", "pg_affected_rows", "()", "This", "appears", "bugged", "in", "php", "5", ".", "3", "and", "postgres", "9", ".", "1", "returning", "the", "number", "of", "rows", "modified", "by", "a", "statement" ]
train
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Result.php#L403-L409
squareproton/Bond
src/Bond/Pg/Result.php
Result.current
public function current() { return call_user_func( $this->fetchCallback, pg_fetch_array( $this->resource, $this->fetchRowNumber, $this->fetchType ) ); }
php
public function current() { return call_user_func( $this->fetchCallback, pg_fetch_array( $this->resource, $this->fetchRowNumber, $this->fetchType ) ); }
[ "public", "function", "current", "(", ")", "{", "return", "call_user_func", "(", "$", "this", "->", "fetchCallback", ",", "pg_fetch_array", "(", "$", "this", "->", "resource", ",", "$", "this", "->", "fetchRowNumber", ",", "$", "this", "->", "fetchType", "...
Return the current element
[ "Return", "the", "current", "element" ]
train
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Result.php#L426-L432
squareproton/Bond
src/Bond/Pg/Result.php
Result.offsetGet
public function offsetGet( $index ) { return call_user_func( $this->fetchCallback, pg_fetch_array( $this->resource, $index, $this->fetchType ) ); }
php
public function offsetGet( $index ) { return call_user_func( $this->fetchCallback, pg_fetch_array( $this->resource, $index, $this->fetchType ) ); }
[ "public", "function", "offsetGet", "(", "$", "index", ")", "{", "return", "call_user_func", "(", "$", "this", "->", "fetchCallback", ",", "pg_fetch_array", "(", "$", "this", "->", "resource", ",", "$", "index", ",", "$", "this", "->", "fetchType", ")", "...
Returns the value at the specified index.
[ "Returns", "the", "value", "at", "the", "specified", "index", "." ]
train
https://github.com/squareproton/Bond/blob/a04ad9dd1a35adeaec98237716c2a41ce02b4f1a/src/Bond/Pg/Result.php#L487-L493
swiftphp/config
src/internal/ObjectFactory.php
ObjectFactory.create
public function create($objectId) { //对象配置信息 $objInfo=$this->getObjInfo($objectId); if($objInfo==null){ throw new \Exception("Call to undefined object '".$objectId."'"); } //如果单例模式且对象已经存在,直接返回 if($objInfo->singleton && array_key_exists($objectId, $this->m_singletonObjMap)){ return $this->m_singletonObjMap[$objectId]; } //创建对象 if(!class_exists($objInfo->class)){ throw new \Exception("Class '".$objInfo->class."' not found"); } $obj=$this->newInstance($objInfo->class,$objInfo->constructorArgs); //注入全局属性(全局属性只有值类型) foreach ($this->m_config->getConfigValues(BuiltInConst::GLOBAL_CONFIG_SESSION) as $name=>$value){ $this->setProperty($obj, $name, $value); } //注入属性 foreach ($objInfo->propertyInfos as $name=>$value){ $this->setProperty($obj, $name, $value); } //如果为单态模式,则保存到缓存 if($objInfo->singleton){ $this->m_singletonObjMap[$objectId]=$obj; } //通过配置接口注入配置实例 if($obj instanceof IConfigurable){ $obj->setConfiguration($this->m_config); } //返回对象 return $obj; }
php
public function create($objectId) { //对象配置信息 $objInfo=$this->getObjInfo($objectId); if($objInfo==null){ throw new \Exception("Call to undefined object '".$objectId."'"); } //如果单例模式且对象已经存在,直接返回 if($objInfo->singleton && array_key_exists($objectId, $this->m_singletonObjMap)){ return $this->m_singletonObjMap[$objectId]; } //创建对象 if(!class_exists($objInfo->class)){ throw new \Exception("Class '".$objInfo->class."' not found"); } $obj=$this->newInstance($objInfo->class,$objInfo->constructorArgs); //注入全局属性(全局属性只有值类型) foreach ($this->m_config->getConfigValues(BuiltInConst::GLOBAL_CONFIG_SESSION) as $name=>$value){ $this->setProperty($obj, $name, $value); } //注入属性 foreach ($objInfo->propertyInfos as $name=>$value){ $this->setProperty($obj, $name, $value); } //如果为单态模式,则保存到缓存 if($objInfo->singleton){ $this->m_singletonObjMap[$objectId]=$obj; } //通过配置接口注入配置实例 if($obj instanceof IConfigurable){ $obj->setConfiguration($this->m_config); } //返回对象 return $obj; }
[ "public", "function", "create", "(", "$", "objectId", ")", "{", "//对象配置信息\r", "$", "objInfo", "=", "$", "this", "->", "getObjInfo", "(", "$", "objectId", ")", ";", "if", "(", "$", "objInfo", "==", "null", ")", "{", "throw", "new", "\\", "Exception", ...
根据对象ID创建实例 @param string $objectId 对象ID
[ "根据对象ID创建实例" ]
train
https://github.com/swiftphp/config/blob/c93e1a45d0aa9fdcb7d583f3eadfc60785c039df/src/internal/ObjectFactory.php#L98-L139
swiftphp/config
src/internal/ObjectFactory.php
ObjectFactory.createByClass
public function createByClass($class,$constructorArgs=[],$singleton=true) { //使用类型名代替ID创建对象,异常代表类型未配置,无需抛出 try{ $obj=$this->create($class); return $obj; }catch (\Exception $ex){} //单例模式下,尝试从缓存获取 if($singleton && array_key_exists($class, $this->m_singletonObjMap)){ $obj=$this->m_singletonObjMap[$class]; if(!is_null($obj)){ return $obj; } } //直接从类型名创建对象 if(!class_exists($class)){ throw new \Exception("Class '".$class."' not found"); } $obj=$this->newInstance($class,$constructorArgs); //注入全局属性(全局属性只有值类型) foreach ($this->m_config->getConfigValues(BuiltInConst::GLOBAL_CONFIG_SESSION) as $name=>$value){ $this->setProperty($obj, $name, $value); } //通过配置接口注入配置实例 if($obj instanceof IConfigurable){ $obj->setConfiguration($this->m_config); } //如果为单态模式,则保存到缓存 if($singleton){ $this->m_singletonObjMap[$class]=$obj; } //返回对象 return $obj; }
php
public function createByClass($class,$constructorArgs=[],$singleton=true) { //使用类型名代替ID创建对象,异常代表类型未配置,无需抛出 try{ $obj=$this->create($class); return $obj; }catch (\Exception $ex){} //单例模式下,尝试从缓存获取 if($singleton && array_key_exists($class, $this->m_singletonObjMap)){ $obj=$this->m_singletonObjMap[$class]; if(!is_null($obj)){ return $obj; } } //直接从类型名创建对象 if(!class_exists($class)){ throw new \Exception("Class '".$class."' not found"); } $obj=$this->newInstance($class,$constructorArgs); //注入全局属性(全局属性只有值类型) foreach ($this->m_config->getConfigValues(BuiltInConst::GLOBAL_CONFIG_SESSION) as $name=>$value){ $this->setProperty($obj, $name, $value); } //通过配置接口注入配置实例 if($obj instanceof IConfigurable){ $obj->setConfiguration($this->m_config); } //如果为单态模式,则保存到缓存 if($singleton){ $this->m_singletonObjMap[$class]=$obj; } //返回对象 return $obj; }
[ "public", "function", "createByClass", "(", "$", "class", ",", "$", "constructorArgs", "=", "[", "]", ",", "$", "singleton", "=", "true", ")", "{", "//使用类型名代替ID创建对象,异常代表类型未配置,无需抛出\r", "try", "{", "$", "obj", "=", "$", "this", "->", "create", "(", "$", "c...
根据类型名创建实例 @param string $class 类型名称 @param array $constructorArgs 构造参数(对于已配置的类型,该参数忽略) @param bool $singleton 是否单例模式,默认为单例模式(对于已配置的类型,该参数忽略)
[ "根据类型名创建实例" ]
train
https://github.com/swiftphp/config/blob/c93e1a45d0aa9fdcb7d583f3eadfc60785c039df/src/internal/ObjectFactory.php#L147-L186
swiftphp/config
src/internal/ObjectFactory.php
ObjectFactory.newInstance
public function newInstance($forClass,$constructorArgs=[]) { $class = new \ReflectionClass($forClass); $constructor = $class->getConstructor(); //无构造函数 if($constructor==null){ return new $forClass(); } //有构造函数 $parameters=$constructor->getParameters(); $paramValues=[]; for($i=0;$i<count($parameters);$i++){ $parameter=$parameters[$i]; $name=$parameter->name; $isDefaultValueAvailable=$parameter->isDefaultValueAvailable(); // $allowsNull=$parameter->allowsNull(); // $isArray=$parameter->isArray(); // $isOptional=$parameter->isOptional(); //参数取值:配置>默认 if(array_key_exists($name, $constructorArgs)){ //按参数名取值 $paramValues[]=$this->getPropertyValue($constructorArgs[$name]); }else if(array_key_exists($i, $constructorArgs)){ //按顺序取值 $paramValues[]=$this->getPropertyValue($constructorArgs[$i]); }else if($isDefaultValueAvailable){ $paramValues[]=$parameter->getDefaultValue(); }else{ throw new \Exception("Too few arguments to function ".$forClass."::__construct()"); } } //创建实例 $obj = $class->newInstanceArgs($paramValues); return $obj; }
php
public function newInstance($forClass,$constructorArgs=[]) { $class = new \ReflectionClass($forClass); $constructor = $class->getConstructor(); //无构造函数 if($constructor==null){ return new $forClass(); } //有构造函数 $parameters=$constructor->getParameters(); $paramValues=[]; for($i=0;$i<count($parameters);$i++){ $parameter=$parameters[$i]; $name=$parameter->name; $isDefaultValueAvailable=$parameter->isDefaultValueAvailable(); // $allowsNull=$parameter->allowsNull(); // $isArray=$parameter->isArray(); // $isOptional=$parameter->isOptional(); //参数取值:配置>默认 if(array_key_exists($name, $constructorArgs)){ //按参数名取值 $paramValues[]=$this->getPropertyValue($constructorArgs[$name]); }else if(array_key_exists($i, $constructorArgs)){ //按顺序取值 $paramValues[]=$this->getPropertyValue($constructorArgs[$i]); }else if($isDefaultValueAvailable){ $paramValues[]=$parameter->getDefaultValue(); }else{ throw new \Exception("Too few arguments to function ".$forClass."::__construct()"); } } //创建实例 $obj = $class->newInstanceArgs($paramValues); return $obj; }
[ "public", "function", "newInstance", "(", "$", "forClass", ",", "$", "constructorArgs", "=", "[", "]", ")", "{", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "$", "forClass", ")", ";", "$", "constructor", "=", "$", "class", "->", "getConstruct...
创建对象实例 @param string $forClass 类名 @param array $constructorArgs 构造参数 @return object @throws \Exception
[ "创建对象实例" ]
train
https://github.com/swiftphp/config/blob/c93e1a45d0aa9fdcb7d583f3eadfc60785c039df/src/internal/ObjectFactory.php#L195-L233
swiftphp/config
src/internal/ObjectFactory.php
ObjectFactory.getObjInfo
private function getObjInfo($objectId) { //映射不存在 ,则先创建 if(empty($this->m_objectInfoMap)){ $configData=$this->m_config->getConfigValues($this->m_configSection); $this->m_objectInfoMap=$this->loadObjMap($configData); } //对象信息 if(array_key_exists($objectId, $this->m_objectInfoMap)){ return $this->m_objectInfoMap[$objectId]; } return null; }
php
private function getObjInfo($objectId) { //映射不存在 ,则先创建 if(empty($this->m_objectInfoMap)){ $configData=$this->m_config->getConfigValues($this->m_configSection); $this->m_objectInfoMap=$this->loadObjMap($configData); } //对象信息 if(array_key_exists($objectId, $this->m_objectInfoMap)){ return $this->m_objectInfoMap[$objectId]; } return null; }
[ "private", "function", "getObjInfo", "(", "$", "objectId", ")", "{", "//映射不存在 ,则先创建\r", "if", "(", "empty", "(", "$", "this", "->", "m_objectInfoMap", ")", ")", "{", "$", "configData", "=", "$", "this", "->", "m_config", "->", "getConfigValues", "(", "$", ...
根据ID获取对象消息 @param string $objectId 对象ID @return ObjectInfo
[ "根据ID获取对象消息" ]
train
https://github.com/swiftphp/config/blob/c93e1a45d0aa9fdcb7d583f3eadfc60785c039df/src/internal/ObjectFactory.php#L240-L253
swiftphp/config
src/internal/ObjectFactory.php
ObjectFactory.loadObjMap
private function loadObjMap(array $configData) { $infos=[]; foreach ($configData as $cfg){ if(array_key_exists(self::OBJECT_CONFIG_KEY_CLASS, $cfg)){ $info=new ObjectInfo(); $info->class=$cfg[self::OBJECT_CONFIG_KEY_CLASS]; $info->id=array_key_exists(self::OBJECT_CONFIG_KEY_ID, $cfg)?$cfg[self::OBJECT_CONFIG_KEY_ID]:$cfg[self::OBJECT_CONFIG_KEY_CLASS]; //属性 $info->propertyInfos=[]; foreach ($cfg as $key=>$value){ if($key!=self::OBJECT_CONFIG_KEY_ID && $key!=self::OBJECT_CONFIG_KEY_CLASS && $key!=self::OBJECT_CONFIG_KEY_SINGLETON && $key!=self::OBJECT_CONFIG_KEY_CONSTRUCTOR_ARGS){ $info->propertyInfos[$key]=$value; } } //单例模式 $info->singleton=true; if(array_key_exists(self::OBJECT_CONFIG_KEY_SINGLETON, $cfg)){ $val=$cfg[self::OBJECT_CONFIG_KEY_SINGLETON]; if($val=="0"||strtolower($val)=="false"){ $info->singleton=false; } } //构造器参数 $info->constructorArgs=[]; if(array_key_exists(self::OBJECT_CONFIG_KEY_CONSTRUCTOR_ARGS, $cfg)){ $args=$cfg[self::OBJECT_CONFIG_KEY_CONSTRUCTOR_ARGS]; foreach ($args as $key=>$value){ $info->constructorArgs[$key]=$value; } } $infos[$info->id]=$info; } } return $infos; }
php
private function loadObjMap(array $configData) { $infos=[]; foreach ($configData as $cfg){ if(array_key_exists(self::OBJECT_CONFIG_KEY_CLASS, $cfg)){ $info=new ObjectInfo(); $info->class=$cfg[self::OBJECT_CONFIG_KEY_CLASS]; $info->id=array_key_exists(self::OBJECT_CONFIG_KEY_ID, $cfg)?$cfg[self::OBJECT_CONFIG_KEY_ID]:$cfg[self::OBJECT_CONFIG_KEY_CLASS]; //属性 $info->propertyInfos=[]; foreach ($cfg as $key=>$value){ if($key!=self::OBJECT_CONFIG_KEY_ID && $key!=self::OBJECT_CONFIG_KEY_CLASS && $key!=self::OBJECT_CONFIG_KEY_SINGLETON && $key!=self::OBJECT_CONFIG_KEY_CONSTRUCTOR_ARGS){ $info->propertyInfos[$key]=$value; } } //单例模式 $info->singleton=true; if(array_key_exists(self::OBJECT_CONFIG_KEY_SINGLETON, $cfg)){ $val=$cfg[self::OBJECT_CONFIG_KEY_SINGLETON]; if($val=="0"||strtolower($val)=="false"){ $info->singleton=false; } } //构造器参数 $info->constructorArgs=[]; if(array_key_exists(self::OBJECT_CONFIG_KEY_CONSTRUCTOR_ARGS, $cfg)){ $args=$cfg[self::OBJECT_CONFIG_KEY_CONSTRUCTOR_ARGS]; foreach ($args as $key=>$value){ $info->constructorArgs[$key]=$value; } } $infos[$info->id]=$info; } } return $infos; }
[ "private", "function", "loadObjMap", "(", "array", "$", "configData", ")", "{", "$", "infos", "=", "[", "]", ";", "foreach", "(", "$", "configData", "as", "$", "cfg", ")", "{", "if", "(", "array_key_exists", "(", "self", "::", "OBJECT_CONFIG_KEY_CLASS", ...
加载对象信息 @param array $configData
[ "加载对象信息" ]
train
https://github.com/swiftphp/config/blob/c93e1a45d0aa9fdcb7d583f3eadfc60785c039df/src/internal/ObjectFactory.php#L259-L301
swiftphp/config
src/internal/ObjectFactory.php
ObjectFactory.setProperty
private function setProperty($obj,$name,$valueInfo) { //setter不存在,直接返回 $setter = "set" . ucfirst($name); if (!method_exists($obj, $setter)) { return; } $obj->$setter($this->getPropertyValue($valueInfo)); }
php
private function setProperty($obj,$name,$valueInfo) { //setter不存在,直接返回 $setter = "set" . ucfirst($name); if (!method_exists($obj, $setter)) { return; } $obj->$setter($this->getPropertyValue($valueInfo)); }
[ "private", "function", "setProperty", "(", "$", "obj", ",", "$", "name", ",", "$", "valueInfo", ")", "{", "//setter不存在,直接返回\r", "$", "setter", "=", "\"set\"", ".", "ucfirst", "(", "$", "name", ")", ";", "if", "(", "!", "method_exists", "(", "$", "obj",...
设置对象属性 @param object $obj 对象 @param string $name 属性名 @param mixed $valueInfo 属性值描述 @param bool $singleton 是否为单态模式调用
[ "设置对象属性" ]
train
https://github.com/swiftphp/config/blob/c93e1a45d0aa9fdcb7d583f3eadfc60785c039df/src/internal/ObjectFactory.php#L310-L318
swiftphp/config
src/internal/ObjectFactory.php
ObjectFactory.getPropertyValue
private function getPropertyValue($valueInfo) { //属性值类型 $value=$valueInfo; //如果值为数组,则递归创建元素值 if(is_array($value)){ $values=[]; foreach ($value as $k => $v){ $key=$this->replacePlaceHolder($k); $values[$key]=$this->getPropertyValue($v); } return $values; } //字符串类型的描述 if(strtolower($value)=="true"){ $value=true; }else if(strtolower($value)=="false"){ $value=false; }else if(strpos(strtolower($value), "ref:")===0){ //对象引用,递归创建对象 $refObjId=substr($value, 4); $value=$this->create($refObjId); }else{ $value=$this->replacePlaceHolder($value); } return $value; }
php
private function getPropertyValue($valueInfo) { //属性值类型 $value=$valueInfo; //如果值为数组,则递归创建元素值 if(is_array($value)){ $values=[]; foreach ($value as $k => $v){ $key=$this->replacePlaceHolder($k); $values[$key]=$this->getPropertyValue($v); } return $values; } //字符串类型的描述 if(strtolower($value)=="true"){ $value=true; }else if(strtolower($value)=="false"){ $value=false; }else if(strpos(strtolower($value), "ref:")===0){ //对象引用,递归创建对象 $refObjId=substr($value, 4); $value=$this->create($refObjId); }else{ $value=$this->replacePlaceHolder($value); } return $value; }
[ "private", "function", "getPropertyValue", "(", "$", "valueInfo", ")", "{", "//属性值类型\r", "$", "value", "=", "$", "valueInfo", ";", "//如果值为数组,则递归创建元素值\r", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "values", "=", "[", "]", ";", "foreach...
根据属性值描述创建属性 @param mixed $valueInfo 属性值描述
[ "根据属性值描述创建属性" ]
train
https://github.com/swiftphp/config/blob/c93e1a45d0aa9fdcb7d583f3eadfc60785c039df/src/internal/ObjectFactory.php#L324-L352
swiftphp/config
src/internal/ObjectFactory.php
ObjectFactory.replacePlaceHolder
private function replacePlaceHolder($value) { $value=str_replace(self::OBJECT_CONFIG_BASE_DIR_PLACE_HOLDER, $this->m_config->getBaseDir(), $value); $value=str_replace(self::OBJECT_CONFIG_USER_DIR_PLACE_HOLDER, $this->m_config->getUserDir(), $value); $value=str_replace(self::OBJECT_CONFIG_CONFIG_DIR_PLACE_HOLDER, $this->m_config->getConfigDir(), $value); return $value; }
php
private function replacePlaceHolder($value) { $value=str_replace(self::OBJECT_CONFIG_BASE_DIR_PLACE_HOLDER, $this->m_config->getBaseDir(), $value); $value=str_replace(self::OBJECT_CONFIG_USER_DIR_PLACE_HOLDER, $this->m_config->getUserDir(), $value); $value=str_replace(self::OBJECT_CONFIG_CONFIG_DIR_PLACE_HOLDER, $this->m_config->getConfigDir(), $value); return $value; }
[ "private", "function", "replacePlaceHolder", "(", "$", "value", ")", "{", "$", "value", "=", "str_replace", "(", "self", "::", "OBJECT_CONFIG_BASE_DIR_PLACE_HOLDER", ",", "$", "this", "->", "m_config", "->", "getBaseDir", "(", ")", ",", "$", "value", ")", ";...
替换占位符 @param string $value
[ "替换占位符" ]
train
https://github.com/swiftphp/config/blob/c93e1a45d0aa9fdcb7d583f3eadfc60785c039df/src/internal/ObjectFactory.php#L358-L364
linpax/microphp-framework
src/cli/CliResolver.php
CliResolver.getOption
public function getOption($char = '', $name = '', $required = null) { if (!$char && !$name) { return false; } if ($char && (1 < strlen($char) || 1 !== preg_match('/^\w$/', $char))) { return false; } if ($name && (1 !== preg_match('/^\w+$/', $name))) { return false; } switch ($required) { case true: $char = $char ? $char.':' : $char; $name = $name ? $name.':' : $name; break; case false: $char = $char ? $char.'::' : $char; $name = $name ? $name.'::' : $name; break; } $argv = ($opts = getopt($char, [$name])) ? array_shift($opts) : []; return is_array($argv) ? array_shift($argv) : $argv; }
php
public function getOption($char = '', $name = '', $required = null) { if (!$char && !$name) { return false; } if ($char && (1 < strlen($char) || 1 !== preg_match('/^\w$/', $char))) { return false; } if ($name && (1 !== preg_match('/^\w+$/', $name))) { return false; } switch ($required) { case true: $char = $char ? $char.':' : $char; $name = $name ? $name.':' : $name; break; case false: $char = $char ? $char.'::' : $char; $name = $name ? $name.'::' : $name; break; } $argv = ($opts = getopt($char, [$name])) ? array_shift($opts) : []; return is_array($argv) ? array_shift($argv) : $argv; }
[ "public", "function", "getOption", "(", "$", "char", "=", "''", ",", "$", "name", "=", "''", ",", "$", "required", "=", "null", ")", "{", "if", "(", "!", "$", "char", "&&", "!", "$", "name", ")", "{", "return", "false", ";", "}", "if", "(", "...
Get arguments from command line @access public @param string $char -a .. -z option char @param string $name --optionName_string @param bool|null $required Required value? @return mixed
[ "Get", "arguments", "from", "command", "line" ]
train
https://github.com/linpax/microphp-framework/blob/11f3370f3f64c516cce9b84ecd8276c6e9ae8df9/src/cli/CliResolver.php#L58-L81
webignition/css-validator-output-parser
src/OutputParser.php
OutputParser.parse
public function parse(string $validatorOutput, int $flags = Flags::NONE): OutputInterface { $sanitizer = new Sanitizer(); $validatorOutput = trim($sanitizer->getSanitizedOutput($validatorOutput)); $headerBodyParts = explode("\n", $validatorOutput, 2); $header = trim($headerBodyParts[0]); $body = trim($headerBodyParts[1]); if (ExceptionOutputParser::is($body)) { return ExceptionOutputParser::parse($body); } if ($this->isIncorrectUsageOutput($header)) { return new IncorrectUsageOutput(); } $bodyXmlContent = $this->extractXmlContentFromBody($body); if (null === $bodyXmlContent) { throw new InvalidValidatorOutputException($validatorOutput); } $optionsParser = new OptionsParser(); $options = $optionsParser->parse($header); if (null === $options) { $options = new Options( false, 'ucn', 'en', 2, 'all', 'css3' ); } $bodyDom = new \DOMDocument(); $bodyDom->loadXML($bodyXmlContent); $observationResponseElement = $bodyDom->getElementsByTagName('observationresponse')->item(0); $observationResponseParser = new ObservationResponseParser(); $observationResponse = $observationResponseParser->parse($observationResponseElement, $flags); return new ValidationOutput($options, $observationResponse); }
php
public function parse(string $validatorOutput, int $flags = Flags::NONE): OutputInterface { $sanitizer = new Sanitizer(); $validatorOutput = trim($sanitizer->getSanitizedOutput($validatorOutput)); $headerBodyParts = explode("\n", $validatorOutput, 2); $header = trim($headerBodyParts[0]); $body = trim($headerBodyParts[1]); if (ExceptionOutputParser::is($body)) { return ExceptionOutputParser::parse($body); } if ($this->isIncorrectUsageOutput($header)) { return new IncorrectUsageOutput(); } $bodyXmlContent = $this->extractXmlContentFromBody($body); if (null === $bodyXmlContent) { throw new InvalidValidatorOutputException($validatorOutput); } $optionsParser = new OptionsParser(); $options = $optionsParser->parse($header); if (null === $options) { $options = new Options( false, 'ucn', 'en', 2, 'all', 'css3' ); } $bodyDom = new \DOMDocument(); $bodyDom->loadXML($bodyXmlContent); $observationResponseElement = $bodyDom->getElementsByTagName('observationresponse')->item(0); $observationResponseParser = new ObservationResponseParser(); $observationResponse = $observationResponseParser->parse($observationResponseElement, $flags); return new ValidationOutput($options, $observationResponse); }
[ "public", "function", "parse", "(", "string", "$", "validatorOutput", ",", "int", "$", "flags", "=", "Flags", "::", "NONE", ")", ":", "OutputInterface", "{", "$", "sanitizer", "=", "new", "Sanitizer", "(", ")", ";", "$", "validatorOutput", "=", "trim", "...
@param string $validatorOutput @param int $flags @return OutputInterface @throws InvalidValidatorOutputException
[ "@param", "string", "$validatorOutput", "@param", "int", "$flags" ]
train
https://github.com/webignition/css-validator-output-parser/blob/66cb21ca1c340ed017fe3bf29d1d99f0a1992acd/src/OutputParser.php#L20-L65
stubbles/stubbles-streams
src/main/php/filter/FilteredOutputStream.php
FilteredOutputStream.write
public function write(string $bytes): int { $isAcceptable = $this->predicate; if ($isAcceptable($bytes)) { return $this->outputStream->write($bytes); } return 0; }
php
public function write(string $bytes): int { $isAcceptable = $this->predicate; if ($isAcceptable($bytes)) { return $this->outputStream->write($bytes); } return 0; }
[ "public", "function", "write", "(", "string", "$", "bytes", ")", ":", "int", "{", "$", "isAcceptable", "=", "$", "this", "->", "predicate", ";", "if", "(", "$", "isAcceptable", "(", "$", "bytes", ")", ")", "{", "return", "$", "this", "->", "outputStr...
writes given bytes @param string $bytes @return int amount of written bytes
[ "writes", "given", "bytes" ]
train
https://github.com/stubbles/stubbles-streams/blob/99b0dace5fcf71584d1456b4b5408017b896bdf5/src/main/php/filter/FilteredOutputStream.php#L46-L54
stubbles/stubbles-streams
src/main/php/filter/FilteredOutputStream.php
FilteredOutputStream.writeLine
public function writeLine(string $bytes): int { $isAcceptable = $this->predicate; if ($isAcceptable($bytes)) { return $this->outputStream->writeLine($bytes); } return 0; }
php
public function writeLine(string $bytes): int { $isAcceptable = $this->predicate; if ($isAcceptable($bytes)) { return $this->outputStream->writeLine($bytes); } return 0; }
[ "public", "function", "writeLine", "(", "string", "$", "bytes", ")", ":", "int", "{", "$", "isAcceptable", "=", "$", "this", "->", "predicate", ";", "if", "(", "$", "isAcceptable", "(", "$", "bytes", ")", ")", "{", "return", "$", "this", "->", "outpu...
writes given bytes and appends a line break @param string $bytes @return int amount of written bytes
[ "writes", "given", "bytes", "and", "appends", "a", "line", "break" ]
train
https://github.com/stubbles/stubbles-streams/blob/99b0dace5fcf71584d1456b4b5408017b896bdf5/src/main/php/filter/FilteredOutputStream.php#L62-L70
stubbles/stubbles-streams
src/main/php/filter/FilteredOutputStream.php
FilteredOutputStream.writeLines
public function writeLines(array $bytes): int { $bytesWritten = 0; foreach ($bytes as $line) { $bytesWritten += $this->writeLine($line); } return $bytesWritten; }
php
public function writeLines(array $bytes): int { $bytesWritten = 0; foreach ($bytes as $line) { $bytesWritten += $this->writeLine($line); } return $bytesWritten; }
[ "public", "function", "writeLines", "(", "array", "$", "bytes", ")", ":", "int", "{", "$", "bytesWritten", "=", "0", ";", "foreach", "(", "$", "bytes", "as", "$", "line", ")", "{", "$", "bytesWritten", "+=", "$", "this", "->", "writeLine", "(", "$", ...
writes given bytes and appends a line break after each one @param string[] $bytes @return int amount of written bytes @since 3.2.0
[ "writes", "given", "bytes", "and", "appends", "a", "line", "break", "after", "each", "one" ]
train
https://github.com/stubbles/stubbles-streams/blob/99b0dace5fcf71584d1456b4b5408017b896bdf5/src/main/php/filter/FilteredOutputStream.php#L79-L87
Eden-PHP/Block
Field/Wysiwyg.php
Wysiwyg.getVariables
public function getVariables() { if(isset($this->attributes['class'])) { $this->attributes['class'] = trim($this ->attributes['class'].' eden-field-wysiwyg form-control'); } else { $this->attributes['class'] = 'eden-field-wysiwyg form-control'; } $loaded = self::$loaded; self::$loaded = true; return array( 'loaded' => $loaded, 'options' => $this->options, 'attributes' => $this->attributes, 'value' => $this->value); }
php
public function getVariables() { if(isset($this->attributes['class'])) { $this->attributes['class'] = trim($this ->attributes['class'].' eden-field-wysiwyg form-control'); } else { $this->attributes['class'] = 'eden-field-wysiwyg form-control'; } $loaded = self::$loaded; self::$loaded = true; return array( 'loaded' => $loaded, 'options' => $this->options, 'attributes' => $this->attributes, 'value' => $this->value); }
[ "public", "function", "getVariables", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "attributes", "[", "'class'", "]", ")", ")", "{", "$", "this", "->", "attributes", "[", "'class'", "]", "=", "trim", "(", "$", "this", "->", "attributes"...
Returns the template variables in key value format @param array data @return array
[ "Returns", "the", "template", "variables", "in", "key", "value", "format" ]
train
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field/Wysiwyg.php#L32-L49
Eden-PHP/Block
Field/Wysiwyg.php
Wysiwyg.setOptions
public function setOptions($option, $value = null) { Argument::i() ->test(1, 'array', 'string') ->test(2, 'scalar', 'null'); if(is_array($option)) { $this->options = $option; return $this; } $this->options[$option] = $value; return $this; }
php
public function setOptions($option, $value = null) { Argument::i() ->test(1, 'array', 'string') ->test(2, 'scalar', 'null'); if(is_array($option)) { $this->options = $option; return $this; } $this->options[$option] = $value; return $this; }
[ "public", "function", "setOptions", "(", "$", "option", ",", "$", "value", "=", "null", ")", "{", "Argument", "::", "i", "(", ")", "->", "test", "(", "1", ",", "'array'", ",", "'string'", ")", "->", "test", "(", "2", ",", "'scalar'", ",", "'null'",...
Set Options @param string|array @param scalar @return this
[ "Set", "Options" ]
train
https://github.com/Eden-PHP/Block/blob/681b9f01dd118612d0fced84d2f702167b52109b/Field/Wysiwyg.php#L69-L82
swiftphp/http
src/FilterChain.php
FilterChain.filter
public function filter(Context $context) { $this->index++; if(empty($this->m_filters) || $this->index >= count($this->m_filters)) return; $filter=$this->m_filters[$this->index]; return $filter->filter($context,$this); }
php
public function filter(Context $context) { $this->index++; if(empty($this->m_filters) || $this->index >= count($this->m_filters)) return; $filter=$this->m_filters[$this->index]; return $filter->filter($context,$this); }
[ "public", "function", "filter", "(", "Context", "$", "context", ")", "{", "$", "this", "->", "index", "++", ";", "if", "(", "empty", "(", "$", "this", "->", "m_filters", ")", "||", "$", "this", "->", "index", ">=", "count", "(", "$", "this", "->", ...
执行过滤 @param Context $context
[ "执行过滤" ]
train
https://github.com/swiftphp/http/blob/8be9dc5b8bfad4736f6b086a1954e28637a46eb2/src/FilterChain.php#L45-L52
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.getContactName
public function getContactName() { $contactName = $this->getContact()->getName(); if (!$contactName) { $contactName = $this->getOwner()->getContactName(); } return $contactName; }
php
public function getContactName() { $contactName = $this->getContact()->getName(); if (!$contactName) { $contactName = $this->getOwner()->getContactName(); } return $contactName; }
[ "public", "function", "getContactName", "(", ")", "{", "$", "contactName", "=", "$", "this", "->", "getContact", "(", ")", "->", "getName", "(", ")", ";", "if", "(", "!", "$", "contactName", ")", "{", "$", "contactName", "=", "$", "this", "->", "getO...
Get contact Name @Serializer\VirtualProperty @Serializer\Type("string") @Serializer\SerializedName("contact_name") @Serializer\Groups({"ui", "ui-admin", "api"}) @return string
[ "Get", "contact", "Name" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L224-L233
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.setCreatedBy
public function setCreatedBy(\WobbleCode\UserBundle\Document\User $createdBy) { $this->createdBy = $createdBy; return $this; }
php
public function setCreatedBy(\WobbleCode\UserBundle\Document\User $createdBy) { $this->createdBy = $createdBy; return $this; }
[ "public", "function", "setCreatedBy", "(", "\\", "WobbleCode", "\\", "UserBundle", "\\", "Document", "\\", "User", "$", "createdBy", ")", "{", "$", "this", "->", "createdBy", "=", "$", "createdBy", ";", "return", "$", "this", ";", "}" ]
Set createdBy @param WobbleCode\UserBundle\Document\User $createdBy @return self
[ "Set", "createdBy" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L427-L431
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.setOwner
public function setOwner(\WobbleCode\UserBundle\Document\User $owner) { $this->owner = $owner; return $this; }
php
public function setOwner(\WobbleCode\UserBundle\Document\User $owner) { $this->owner = $owner; return $this; }
[ "public", "function", "setOwner", "(", "\\", "WobbleCode", "\\", "UserBundle", "\\", "Document", "\\", "User", "$", "owner", ")", "{", "$", "this", "->", "owner", "=", "$", "owner", ";", "return", "$", "this", ";", "}" ]
Set owner @param WobbleCode\UserBundle\Document\User $owner @return self
[ "Set", "owner" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L493-L497
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.setInvitations
public function setInvitations(\WobbleCode\UserBundle\Document\Invitation $invitations) { $this->invitations = $invitations; return $this; }
php
public function setInvitations(\WobbleCode\UserBundle\Document\Invitation $invitations) { $this->invitations = $invitations; return $this; }
[ "public", "function", "setInvitations", "(", "\\", "WobbleCode", "\\", "UserBundle", "\\", "Document", "\\", "Invitation", "$", "invitations", ")", "{", "$", "this", "->", "invitations", "=", "$", "invitations", ";", "return", "$", "this", ";", "}" ]
Set invitations @param WobbleCode\UserBundle\Document\Invitation $invitations @return self
[ "Set", "invitations" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L515-L519
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.setRoles
public function setRoles(\WobbleCode\UserBundle\Document\Role $roles) { $this->roles = $roles; return $this; }
php
public function setRoles(\WobbleCode\UserBundle\Document\Role $roles) { $this->roles = $roles; return $this; }
[ "public", "function", "setRoles", "(", "\\", "WobbleCode", "\\", "UserBundle", "\\", "Document", "\\", "Role", "$", "roles", ")", "{", "$", "this", "->", "roles", "=", "$", "roles", ";", "return", "$", "this", ";", "}" ]
Set roles @param WobbleCode\UserBundle\Document\Role $roles @return self
[ "Set", "roles" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L537-L542
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.setContact
public function setContact(\WobbleCode\UserBundle\Document\Contact $contact) { $this->contact = $contact; return $this; }
php
public function setContact(\WobbleCode\UserBundle\Document\Contact $contact) { $this->contact = $contact; return $this; }
[ "public", "function", "setContact", "(", "\\", "WobbleCode", "\\", "UserBundle", "\\", "Document", "\\", "Contact", "$", "contact", ")", "{", "$", "this", "->", "contact", "=", "$", "contact", ";", "return", "$", "this", ";", "}" ]
Set contact @param WobbleCode\UserBundle\Document\Contact $contact @return self
[ "Set", "contact" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L560-L565
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.setPaymentProfiles
public function setPaymentProfiles(\WobbleCode\BillingBundle\Document\PaymentProfile $paymentProfiles) { $this->paymentProfiles = $paymentProfiles; return $this; }
php
public function setPaymentProfiles(\WobbleCode\BillingBundle\Document\PaymentProfile $paymentProfiles) { $this->paymentProfiles = $paymentProfiles; return $this; }
[ "public", "function", "setPaymentProfiles", "(", "\\", "WobbleCode", "\\", "BillingBundle", "\\", "Document", "\\", "PaymentProfile", "$", "paymentProfiles", ")", "{", "$", "this", "->", "paymentProfiles", "=", "$", "paymentProfiles", ";", "return", "$", "this", ...
Set paymentProfiles @param WobbleCode\BillingBundle\Document\PaymentProfile $paymentProfiles @return self
[ "Set", "paymentProfiles" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L583-L587
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.setInvoiceProfile
public function setInvoiceProfile(\WobbleCode\BillingBundle\Document\InvoiceProfile $invoiceProfile) { $this->invoiceProfile = $invoiceProfile; return $this; }
php
public function setInvoiceProfile(\WobbleCode\BillingBundle\Document\InvoiceProfile $invoiceProfile) { $this->invoiceProfile = $invoiceProfile; return $this; }
[ "public", "function", "setInvoiceProfile", "(", "\\", "WobbleCode", "\\", "BillingBundle", "\\", "Document", "\\", "InvoiceProfile", "$", "invoiceProfile", ")", "{", "$", "this", "->", "invoiceProfile", "=", "$", "invoiceProfile", ";", "return", "$", "this", ";"...
Set invoiceProfile @param WobbleCode\BillingBundle\Document\InvoiceProfile $invoiceProfile @return self
[ "Set", "invoiceProfile" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L605-L609
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.setActiveUsers
public function setActiveUsers(\WobbleCode\UserBundle\Document\User $activeUsers) { $this->activeUsers = $activeUsers; return $this; }
php
public function setActiveUsers(\WobbleCode\UserBundle\Document\User $activeUsers) { $this->activeUsers = $activeUsers; return $this; }
[ "public", "function", "setActiveUsers", "(", "\\", "WobbleCode", "\\", "UserBundle", "\\", "Document", "\\", "User", "$", "activeUsers", ")", "{", "$", "this", "->", "activeUsers", "=", "$", "activeUsers", ";", "return", "$", "this", ";", "}" ]
Set activeUsers @param WobbleCode\UserBundle\Document\User $activeUsers @return self
[ "Set", "activeUsers" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L627-L631
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.removeUser
public function removeUser(\WobbleCode\UserBundle\Document\User $user) { $this->users->removeElement($user); }
php
public function removeUser(\WobbleCode\UserBundle\Document\User $user) { $this->users->removeElement($user); }
[ "public", "function", "removeUser", "(", "\\", "WobbleCode", "\\", "UserBundle", "\\", "Document", "\\", "User", "$", "user", ")", "{", "$", "this", "->", "users", "->", "removeElement", "(", "$", "user", ")", ";", "}" ]
Remove user @param WobbleCode\UserBundle\Document\User $user
[ "Remove", "user" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L658-L661
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.removeInvitation
public function removeInvitation(\WobbleCode\UserBundle\Document\Invitation $invitation) { $this->invitations->removeElement($invitation); }
php
public function removeInvitation(\WobbleCode\UserBundle\Document\Invitation $invitation) { $this->invitations->removeElement($invitation); }
[ "public", "function", "removeInvitation", "(", "\\", "WobbleCode", "\\", "UserBundle", "\\", "Document", "\\", "Invitation", "$", "invitation", ")", "{", "$", "this", "->", "invitations", "->", "removeElement", "(", "$", "invitation", ")", ";", "}" ]
Remove invitation @param WobbleCode\UserBundle\Document\Invitation $invitation
[ "Remove", "invitation" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L688-L691
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.removeRole
public function removeRole(\WobbleCode\UserBundle\Document\Role $role) { $this->roles->removeElement($role); }
php
public function removeRole(\WobbleCode\UserBundle\Document\Role $role) { $this->roles->removeElement($role); }
[ "public", "function", "removeRole", "(", "\\", "WobbleCode", "\\", "UserBundle", "\\", "Document", "\\", "Role", "$", "role", ")", "{", "$", "this", "->", "roles", "->", "removeElement", "(", "$", "role", ")", ";", "}" ]
Remove role @param WobbleCode\UserBundle\Document\Role $role
[ "Remove", "role" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L708-L711
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.removePaymentProfile
public function removePaymentProfile(\WobbleCode\BillingBundle\Document\PaymentProfile $paymentProfile) { $this->paymentProfiles->removeElement($paymentProfile); }
php
public function removePaymentProfile(\WobbleCode\BillingBundle\Document\PaymentProfile $paymentProfile) { $this->paymentProfiles->removeElement($paymentProfile); }
[ "public", "function", "removePaymentProfile", "(", "\\", "WobbleCode", "\\", "BillingBundle", "\\", "Document", "\\", "PaymentProfile", "$", "paymentProfile", ")", "{", "$", "this", "->", "paymentProfiles", "->", "removeElement", "(", "$", "paymentProfile", ")", "...
Remove paymentProfile @param WobbleCode\BillingBundle\Document\PaymentProfile $paymentProfile
[ "Remove", "paymentProfile" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L728-L731
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.removeInvoiceProfile
public function removeInvoiceProfile(\WobbleCode\BillingBundle\Document\InvoiceProfile $invoiceProfile) { $this->invoiceProfile->removeElement($invoiceProfile); }
php
public function removeInvoiceProfile(\WobbleCode\BillingBundle\Document\InvoiceProfile $invoiceProfile) { $this->invoiceProfile->removeElement($invoiceProfile); }
[ "public", "function", "removeInvoiceProfile", "(", "\\", "WobbleCode", "\\", "BillingBundle", "\\", "Document", "\\", "InvoiceProfile", "$", "invoiceProfile", ")", "{", "$", "this", "->", "invoiceProfile", "->", "removeElement", "(", "$", "invoiceProfile", ")", ";...
Remove invoiceProfile @param WobbleCode\BillingBundle\Document\InvoiceProfile $invoiceProfile
[ "Remove", "invoiceProfile" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L748-L751
wobblecode/WobbleCodeUserBundle
Document/Organization.php
Organization.removeActiveUser
public function removeActiveUser(\WobbleCode\UserBundle\Document\User $activeUser) { $this->activeUsers->removeElement($activeUser); }
php
public function removeActiveUser(\WobbleCode\UserBundle\Document\User $activeUser) { $this->activeUsers->removeElement($activeUser); }
[ "public", "function", "removeActiveUser", "(", "\\", "WobbleCode", "\\", "UserBundle", "\\", "Document", "\\", "User", "$", "activeUser", ")", "{", "$", "this", "->", "activeUsers", "->", "removeElement", "(", "$", "activeUser", ")", ";", "}" ]
Remove activeUser @param WobbleCode\UserBundle\Document\User $activeUser
[ "Remove", "activeUser" ]
train
https://github.com/wobblecode/WobbleCodeUserBundle/blob/7b8206f8b4a50fbc61f7bfe4f83eb466cad96440/Document/Organization.php#L768-L771
gplcart/export
controllers/Settings.php
Settings.editSettings
public function editSettings() { $this->setTitleEditSettings(); $this->setBreadcrumbEditSettings(); $this->setData('settings', $this->module->getSettings('export')); $this->submitSettings(); $this->setDataEditSettings(); $this->outputEditSettings(); }
php
public function editSettings() { $this->setTitleEditSettings(); $this->setBreadcrumbEditSettings(); $this->setData('settings', $this->module->getSettings('export')); $this->submitSettings(); $this->setDataEditSettings(); $this->outputEditSettings(); }
[ "public", "function", "editSettings", "(", ")", "{", "$", "this", "->", "setTitleEditSettings", "(", ")", ";", "$", "this", "->", "setBreadcrumbEditSettings", "(", ")", ";", "$", "this", "->", "setData", "(", "'settings'", ",", "$", "this", "->", "module",...
Route page callback to display the module settings page
[ "Route", "page", "callback", "to", "display", "the", "module", "settings", "page" ]
train
https://github.com/gplcart/export/blob/b4d93c7a2bd6653f12231fb30d36601ea00fc926/controllers/Settings.php#L23-L32
gplcart/export
controllers/Settings.php
Settings.setDataEditSettings
protected function setDataEditSettings() { $header = $this->getData('settings.header'); if (is_array($header)) { $string = ''; foreach ($header as $key => $value) { $string .= "$key $value" . PHP_EOL; } $this->setData('settings.header', trim($string)); } }
php
protected function setDataEditSettings() { $header = $this->getData('settings.header'); if (is_array($header)) { $string = ''; foreach ($header as $key => $value) { $string .= "$key $value" . PHP_EOL; } $this->setData('settings.header', trim($string)); } }
[ "protected", "function", "setDataEditSettings", "(", ")", "{", "$", "header", "=", "$", "this", "->", "getData", "(", "'settings.header'", ")", ";", "if", "(", "is_array", "(", "$", "header", ")", ")", "{", "$", "string", "=", "''", ";", "foreach", "("...
Prepare data before rendering
[ "Prepare", "data", "before", "rendering" ]
train
https://github.com/gplcart/export/blob/b4d93c7a2bd6653f12231fb30d36601ea00fc926/controllers/Settings.php#L37-L50
gplcart/export
controllers/Settings.php
Settings.submitSettings
protected function submitSettings() { if ($this->isPosted('reset')) { $this->updateSettings(array()); } else if ($this->isPosted('save') && $this->validateSettings()) { $this->updateSettings($this->getSubmitted()); } }
php
protected function submitSettings() { if ($this->isPosted('reset')) { $this->updateSettings(array()); } else if ($this->isPosted('save') && $this->validateSettings()) { $this->updateSettings($this->getSubmitted()); } }
[ "protected", "function", "submitSettings", "(", ")", "{", "if", "(", "$", "this", "->", "isPosted", "(", "'reset'", ")", ")", "{", "$", "this", "->", "updateSettings", "(", "array", "(", ")", ")", ";", "}", "else", "if", "(", "$", "this", "->", "is...
Saves the submitted settings
[ "Saves", "the", "submitted", "settings" ]
train
https://github.com/gplcart/export/blob/b4d93c7a2bd6653f12231fb30d36601ea00fc926/controllers/Settings.php#L84-L91
gplcart/export
controllers/Settings.php
Settings.validateSettings
protected function validateSettings() { $this->setSubmitted('settings'); $this->validateElement('limit', 'numeric'); $this->validateElement('limit', 'required'); $this->validateElement('multiple', 'required'); $this->validateElement('delimiter', 'required'); $this->validateHeaderSettings(); return !$this->hasErrors(); }
php
protected function validateSettings() { $this->setSubmitted('settings'); $this->validateElement('limit', 'numeric'); $this->validateElement('limit', 'required'); $this->validateElement('multiple', 'required'); $this->validateElement('delimiter', 'required'); $this->validateHeaderSettings(); return !$this->hasErrors(); }
[ "protected", "function", "validateSettings", "(", ")", "{", "$", "this", "->", "setSubmitted", "(", "'settings'", ")", ";", "$", "this", "->", "validateElement", "(", "'limit'", ",", "'numeric'", ")", ";", "$", "this", "->", "validateElement", "(", "'limit'"...
Validate submitted module settings
[ "Validate", "submitted", "module", "settings" ]
train
https://github.com/gplcart/export/blob/b4d93c7a2bd6653f12231fb30d36601ea00fc926/controllers/Settings.php#L96-L108
gplcart/export
controllers/Settings.php
Settings.validateHeaderSettings
protected function validateHeaderSettings() { $errors = $header = array(); $lines = gplcart_string_explode_multiline($this->getSubmitted('header', '')); foreach ($lines as $pos => $line) { $pos++; $data = array_filter(array_map('trim', explode(' ', $line, 2))); if (count($data) != 2) { $errors[] = $pos; continue; } list($key, $label) = $data; if (preg_match('/^[a-z_]+$/', $key) !== 1) { $errors[] = $pos; continue; } $header[$key] = $label; } if (empty($errors)) { $this->setSubmitted('header', $header); } else { $vars = array('@num' => implode(',', $errors)); $this->setError('header', $this->text('Error on line @num', $vars)); } }
php
protected function validateHeaderSettings() { $errors = $header = array(); $lines = gplcart_string_explode_multiline($this->getSubmitted('header', '')); foreach ($lines as $pos => $line) { $pos++; $data = array_filter(array_map('trim', explode(' ', $line, 2))); if (count($data) != 2) { $errors[] = $pos; continue; } list($key, $label) = $data; if (preg_match('/^[a-z_]+$/', $key) !== 1) { $errors[] = $pos; continue; } $header[$key] = $label; } if (empty($errors)) { $this->setSubmitted('header', $header); } else { $vars = array('@num' => implode(',', $errors)); $this->setError('header', $this->text('Error on line @num', $vars)); } }
[ "protected", "function", "validateHeaderSettings", "(", ")", "{", "$", "errors", "=", "$", "header", "=", "array", "(", ")", ";", "$", "lines", "=", "gplcart_string_explode_multiline", "(", "$", "this", "->", "getSubmitted", "(", "'header'", ",", "''", ")", ...
Validate header mapping
[ "Validate", "header", "mapping" ]
train
https://github.com/gplcart/export/blob/b4d93c7a2bd6653f12231fb30d36601ea00fc926/controllers/Settings.php#L113-L144
gplcart/export
controllers/Settings.php
Settings.updateSettings
protected function updateSettings(array $settings) { $this->controlAccess('module_edit'); $this->module->setSettings('export', $settings); $this->redirect('', $this->text('Settings have been updated'), 'success'); }
php
protected function updateSettings(array $settings) { $this->controlAccess('module_edit'); $this->module->setSettings('export', $settings); $this->redirect('', $this->text('Settings have been updated'), 'success'); }
[ "protected", "function", "updateSettings", "(", "array", "$", "settings", ")", "{", "$", "this", "->", "controlAccess", "(", "'module_edit'", ")", ";", "$", "this", "->", "module", "->", "setSettings", "(", "'export'", ",", "$", "settings", ")", ";", "$", ...
Update module settings @param array $settings
[ "Update", "module", "settings" ]
train
https://github.com/gplcart/export/blob/b4d93c7a2bd6653f12231fb30d36601ea00fc926/controllers/Settings.php#L150-L156
sndsgd/http
src/http/request/BodyDecoder.php
BodyDecoder.addDecoder
public static function addDecoder(string $class, string ...$contentTypes) { $interface = decoder\DecoderInterface::class; if (!is_subclass_of($class, $interface)) { throw new \InvalidArgumentException( "invalid value provided for 'class'; ". "expecting the name of a class that implements '$interface'" ); } foreach ($contentTypes as $type) { static::$decoders[$class] = $type; } }
php
public static function addDecoder(string $class, string ...$contentTypes) { $interface = decoder\DecoderInterface::class; if (!is_subclass_of($class, $interface)) { throw new \InvalidArgumentException( "invalid value provided for 'class'; ". "expecting the name of a class that implements '$interface'" ); } foreach ($contentTypes as $type) { static::$decoders[$class] = $type; } }
[ "public", "static", "function", "addDecoder", "(", "string", "$", "class", ",", "string", "...", "$", "contentTypes", ")", "{", "$", "interface", "=", "decoder", "\\", "DecoderInterface", "::", "class", ";", "if", "(", "!", "is_subclass_of", "(", "$", "cla...
Replace existing decoders, or add additional decoders @param string $class The nme of the decoder class @param string ...$contentTypes The content types the decoder can handle
[ "Replace", "existing", "decoders", "or", "add", "additional", "decoders" ]
train
https://github.com/sndsgd/http/blob/e7f82010a66c6d3241a24ea82baf4593130c723b/src/http/request/BodyDecoder.php#L27-L40
sndsgd/http
src/http/request/BodyDecoder.php
BodyDecoder.getDecoder
protected function getDecoder( string $stream, string $contentType, int $contentLength, decoder\DecoderOptions $options ) { $type = \sndsgd\Str::before($contentType, ";"); if (!isset(static::$decoders[$type])) { throw new exception\BadRequestException( "failed to decode request body; ". "unknown content-type '$contentType'" ); } $class = static::$decoders[$type]; return new $class($stream, $contentType, $contentLength, $options); }
php
protected function getDecoder( string $stream, string $contentType, int $contentLength, decoder\DecoderOptions $options ) { $type = \sndsgd\Str::before($contentType, ";"); if (!isset(static::$decoders[$type])) { throw new exception\BadRequestException( "failed to decode request body; ". "unknown content-type '$contentType'" ); } $class = static::$decoders[$type]; return new $class($stream, $contentType, $contentLength, $options); }
[ "protected", "function", "getDecoder", "(", "string", "$", "stream", ",", "string", "$", "contentType", ",", "int", "$", "contentLength", ",", "decoder", "\\", "DecoderOptions", "$", "options", ")", "{", "$", "type", "=", "\\", "sndsgd", "\\", "Str", "::",...
Stubbable method for creating a decoder instance @param string $stream @param string $contentType @param int $contentLength @param \sndsgd\http\data\DecoderOptions $options @return \sndsgd\http\data\decoder\DecoderInterface @throws \sndsgd\http\exception\BadRequestException
[ "Stubbable", "method", "for", "creating", "a", "decoder", "instance" ]
train
https://github.com/sndsgd/http/blob/e7f82010a66c6d3241a24ea82baf4593130c723b/src/http/request/BodyDecoder.php#L81-L98
sndsgd/http
src/http/request/BodyDecoder.php
BodyDecoder.parsePost
protected function parsePost() { $ret = $_POST ?: []; if (isset($_FILES)) { foreach ($_FILES as $name => $info) { if (is_array($info["name"])) { $len = count($info["name"]); for ($i = 0; $i < $len; $i++) { $file = $this->createUploadedFile([ "name" => $info["name"][$i] ?? "", "type" => $info["type"][$i] ?? "", "tmp_name" => $info["tmp_name"][$i] ?? "", "error" => $info["error"][$i] ?? 0, "size" => $info["size"][$i] ?? 0, ]); \sndsgd\Arr::addValue($ret, $name, $file); } } else { $file = $this->createUploadedFile($info); \sndsgd\Arr::addValue($ret, $name, $file); } } } return $ret; }
php
protected function parsePost() { $ret = $_POST ?: []; if (isset($_FILES)) { foreach ($_FILES as $name => $info) { if (is_array($info["name"])) { $len = count($info["name"]); for ($i = 0; $i < $len; $i++) { $file = $this->createUploadedFile([ "name" => $info["name"][$i] ?? "", "type" => $info["type"][$i] ?? "", "tmp_name" => $info["tmp_name"][$i] ?? "", "error" => $info["error"][$i] ?? 0, "size" => $info["size"][$i] ?? 0, ]); \sndsgd\Arr::addValue($ret, $name, $file); } } else { $file = $this->createUploadedFile($info); \sndsgd\Arr::addValue($ret, $name, $file); } } } return $ret; }
[ "protected", "function", "parsePost", "(", ")", "{", "$", "ret", "=", "$", "_POST", "?", ":", "[", "]", ";", "if", "(", "isset", "(", "$", "_FILES", ")", ")", "{", "foreach", "(", "$", "_FILES", "as", "$", "name", "=>", "$", "info", ")", "{", ...
Process the $_POST superglobal to spoof the results of a decoder @return array
[ "Process", "the", "$_POST", "superglobal", "to", "spoof", "the", "results", "of", "a", "decoder" ]
train
https://github.com/sndsgd/http/blob/e7f82010a66c6d3241a24ea82baf4593130c723b/src/http/request/BodyDecoder.php#L105-L129
kherge-abandoned/php-cli-app
src/lib/Herrera/Cli/Provider/ConsoleServiceProvider.php
ConsoleServiceProvider.register
public function register(Container $container) { $container['console.defaults'] = $container->once( function (Container $container) { $defaults = array( 'app.name' => 'UNKNOWN', 'app.version' => 'UNKNOWN', 'console.auto_exit' => true, 'console.input.argv' => null, 'console.input.definition' => null, 'console.output.verbosity' => ConsoleOutput::VERBOSITY_NORMAL, 'console.output.decorated' => null, ); foreach ($defaults as $key => $value) { if (false === isset($container[$key])) { $container[$key] = $value; } } } ); $container['console'] = $container->once( function (Container $container) { $container['console.defaults']; $console = new Application( $container['app.name'], $container['app.version'] ); $console->setAutoExit($container['console.auto_exit']); /** @var HelperInterface $container */ $console->getHelperSet()->set($container); return $console; } ); $container['console.command_factory'] = $container->many( function ($name, $callback) { $command = new Command($name); $command->setCode($callback); return $command; } ); $container['console.input'] = $container->once( function (Container $container) { $container['console.defaults']; return new ArgvInput( $container['console.input.argv'], $container['console.input.definition'] ); } ); $container['console.output'] = $container->once( function (Container $container) { $container['console.defaults']; return new ConsoleOutput( $container['console.output.verbosity'], $container['console.output.decorated'], $container['console.output.formatter'] ); } ); $container['console.output.formatter'] = $container->once( function () { return new OutputFormatter(); } ); $container['console.run'] = $container->many( function () use ($container) { return $container['console']->run( $container['console.input'], $container['console.output'] ); } ); }
php
public function register(Container $container) { $container['console.defaults'] = $container->once( function (Container $container) { $defaults = array( 'app.name' => 'UNKNOWN', 'app.version' => 'UNKNOWN', 'console.auto_exit' => true, 'console.input.argv' => null, 'console.input.definition' => null, 'console.output.verbosity' => ConsoleOutput::VERBOSITY_NORMAL, 'console.output.decorated' => null, ); foreach ($defaults as $key => $value) { if (false === isset($container[$key])) { $container[$key] = $value; } } } ); $container['console'] = $container->once( function (Container $container) { $container['console.defaults']; $console = new Application( $container['app.name'], $container['app.version'] ); $console->setAutoExit($container['console.auto_exit']); /** @var HelperInterface $container */ $console->getHelperSet()->set($container); return $console; } ); $container['console.command_factory'] = $container->many( function ($name, $callback) { $command = new Command($name); $command->setCode($callback); return $command; } ); $container['console.input'] = $container->once( function (Container $container) { $container['console.defaults']; return new ArgvInput( $container['console.input.argv'], $container['console.input.definition'] ); } ); $container['console.output'] = $container->once( function (Container $container) { $container['console.defaults']; return new ConsoleOutput( $container['console.output.verbosity'], $container['console.output.decorated'], $container['console.output.formatter'] ); } ); $container['console.output.formatter'] = $container->once( function () { return new OutputFormatter(); } ); $container['console.run'] = $container->many( function () use ($container) { return $container['console']->run( $container['console.input'], $container['console.output'] ); } ); }
[ "public", "function", "register", "(", "Container", "$", "container", ")", "{", "$", "container", "[", "'console.defaults'", "]", "=", "$", "container", "->", "once", "(", "function", "(", "Container", "$", "container", ")", "{", "$", "defaults", "=", "arr...
{@inheritDoc}
[ "{" ]
train
https://github.com/kherge-abandoned/php-cli-app/blob/04ad5c4e805f4cf9e1282a1f869005504d42a9ee/src/lib/Herrera/Cli/Provider/ConsoleServiceProvider.php#L24-L110
ezra-obiwale/dSCore
src/Form/Filterer.php
Filterer.checkMessage
private function checkMessage($defMsg, array $options) { if (is_array($options) && isset($options['message'])) return $options['message'] ? $options['message'] : null; return $defMsg; }
php
private function checkMessage($defMsg, array $options) { if (is_array($options) && isset($options['message'])) return $options['message'] ? $options['message'] : null; return $defMsg; }
[ "private", "function", "checkMessage", "(", "$", "defMsg", ",", "array", "$", "options", ")", "{", "if", "(", "is_array", "(", "$", "options", ")", "&&", "isset", "(", "$", "options", "[", "'message'", "]", ")", ")", "return", "$", "options", "[", "'...
Checks if a custom message exists or returns the default @param string $defMsg Default message of the filter @param array $options Element filter Options @return string
[ "Checks", "if", "a", "custom", "message", "exists", "or", "returns", "the", "default" ]
train
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Form/Filterer.php#L75-L80
ezra-obiwale/dSCore
src/Form/Filterer.php
Filterer.required
public function required($options) { if ((is_array($options) || (!is_array($options) && $options))) { if ((is_array($this->elementData) && (empty($this->elementData) || (empty($this->elementData[0]) && count($this->elementData) === 1))) || (!is_array($this->elementData) && trim($this->elementData) === '')) { if (is_bool($options)) $this->addError('Field is required'); else if (is_array($options) && isset($options['message'])) { $this->addError($options['message']); } else $this->addError((!is_array($options) && !is_object($options)) ? $options : 'Field is required'); return false; } return true; } return true; }
php
public function required($options) { if ((is_array($options) || (!is_array($options) && $options))) { if ((is_array($this->elementData) && (empty($this->elementData) || (empty($this->elementData[0]) && count($this->elementData) === 1))) || (!is_array($this->elementData) && trim($this->elementData) === '')) { if (is_bool($options)) $this->addError('Field is required'); else if (is_array($options) && isset($options['message'])) { $this->addError($options['message']); } else $this->addError((!is_array($options) && !is_object($options)) ? $options : 'Field is required'); return false; } return true; } return true; }
[ "public", "function", "required", "(", "$", "options", ")", "{", "if", "(", "(", "is_array", "(", "$", "options", ")", "||", "(", "!", "is_array", "(", "$", "options", ")", "&&", "$", "options", ")", ")", ")", "{", "if", "(", "(", "is_array", "("...
Makes an element required @param string $name Name of the element to filter @param boolean|string|array $options Boolean indicates required or not. String indicates required with custom message. Array indicates required and has options @return boolean
[ "Makes", "an", "element", "required" ]
train
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Form/Filterer.php#L90-L105
ezra-obiwale/dSCore
src/Form/Filterer.php
Filterer.match
public function match(array $options) { if (isset($options['element'])) { if (isset($this->data[$options['element']])) { if ($this->elementData == $this->data[$options['element']]) { return true; } } else { return true; } } else if (isset($options['value'])) { if ($this->elementData == $options['value']) { return true; } } $this->addError($this->checkMessage('Values mismatch', $options)); return false; }
php
public function match(array $options) { if (isset($options['element'])) { if (isset($this->data[$options['element']])) { if ($this->elementData == $this->data[$options['element']]) { return true; } } else { return true; } } else if (isset($options['value'])) { if ($this->elementData == $options['value']) { return true; } } $this->addError($this->checkMessage('Values mismatch', $options)); return false; }
[ "public", "function", "match", "(", "array", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'element'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "options", "[", "'element'", "]", ...
Checks if the value of the element matches the given option @param string $name Name of the element to filter @param array $options Keys may include [message] @return boolean @throws \Exception
[ "Checks", "if", "the", "value", "of", "the", "element", "matches", "the", "given", "option" ]
train
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Form/Filterer.php#L114-L131
ezra-obiwale/dSCore
src/Form/Filterer.php
Filterer.email
public function email(array $options) { if (empty($this->elementData) || filter_var($this->elementData, FILTER_VALIDATE_EMAIL)) { $this->elementData = filter_var($this->elementData, FILTER_SANITIZE_EMAIL); return true; } $this->addError($this->checkMessage('Invalid email adddress', $options)); return false; }
php
public function email(array $options) { if (empty($this->elementData) || filter_var($this->elementData, FILTER_VALIDATE_EMAIL)) { $this->elementData = filter_var($this->elementData, FILTER_SANITIZE_EMAIL); return true; } $this->addError($this->checkMessage('Invalid email adddress', $options)); return false; }
[ "public", "function", "email", "(", "array", "$", "options", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "elementData", ")", "||", "filter_var", "(", "$", "this", "->", "elementData", ",", "FILTER_VALIDATE_EMAIL", ")", ")", "{", "$", "this", ...
Checks if the value of the element is a valid email address @param string $name Name of the element to filter @param array $options Keys may include [message] @return boolean
[ "Checks", "if", "the", "value", "of", "the", "element", "is", "a", "valid", "email", "address" ]
train
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Form/Filterer.php#L165-L173
ezra-obiwale/dSCore
src/Form/Filterer.php
Filterer.url
public function url(array $options) { if (empty($this->elementData) || filter_var($this->elementData, FILTER_VALIDATE_URL)) { $this->elementData = filter_var($this->elementData, FILTER_SANITIZE_URL); return true; } $this->addError($this->checkMessage('Value is not a valid url', $options)); return false; }
php
public function url(array $options) { if (empty($this->elementData) || filter_var($this->elementData, FILTER_VALIDATE_URL)) { $this->elementData = filter_var($this->elementData, FILTER_SANITIZE_URL); return true; } $this->addError($this->checkMessage('Value is not a valid url', $options)); return false; }
[ "public", "function", "url", "(", "array", "$", "options", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "elementData", ")", "||", "filter_var", "(", "$", "this", "->", "elementData", ",", "FILTER_VALIDATE_URL", ")", ")", "{", "$", "this", "->"...
Checks if the values of the element is a valid url @param string $name Name of the element to filter @param array $options Keys may include [message] @return boolean
[ "Checks", "if", "the", "values", "of", "the", "element", "is", "a", "valid", "url" ]
train
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Form/Filterer.php#L181-L189
ezra-obiwale/dSCore
src/Form/Filterer.php
Filterer.alpha
public function alpha(array $options) { if (!$options['regex']) $options['regex'] = ($options['acceptSpace']) ? '/[^a-zA-Z\s]/' : '/[^a-zA-Z]/'; if (!preg_match($options['regex'], $this->elementData)) return true; $this->addError($this->checkMessage('Value can only contain alphabets', $options)); return false; }
php
public function alpha(array $options) { if (!$options['regex']) $options['regex'] = ($options['acceptSpace']) ? '/[^a-zA-Z\s]/' : '/[^a-zA-Z]/'; if (!preg_match($options['regex'], $this->elementData)) return true; $this->addError($this->checkMessage('Value can only contain alphabets', $options)); return false; }
[ "public", "function", "alpha", "(", "array", "$", "options", ")", "{", "if", "(", "!", "$", "options", "[", "'regex'", "]", ")", "$", "options", "[", "'regex'", "]", "=", "(", "$", "options", "[", "'acceptSpace'", "]", ")", "?", "'/[^a-zA-Z\\s]/'", "...
Checks if the contents of the element are all alphabets @param string $name Name of the element to filter @param array $options Keys may include [message] @return boolean
[ "Checks", "if", "the", "contents", "of", "the", "element", "are", "all", "alphabets" ]
train
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Form/Filterer.php#L197-L205
ezra-obiwale/dSCore
src/Form/Filterer.php
Filterer.decimal
public function decimal(array $options) { if (ctype_digit($this->elementData)) return true; $this->addError($this->checkMessage('Value can only contain numbers and a dot', $options)); return false; }
php
public function decimal(array $options) { if (ctype_digit($this->elementData)) return true; $this->addError($this->checkMessage('Value can only contain numbers and a dot', $options)); return false; }
[ "public", "function", "decimal", "(", "array", "$", "options", ")", "{", "if", "(", "ctype_digit", "(", "$", "this", "->", "elementData", ")", ")", "return", "true", ";", "$", "this", "->", "addError", "(", "$", "this", "->", "checkMessage", "(", "'Val...
Checks if the content of the element is decimal @param string $name Name of the element to filter @param array $options Keys may include [message] @return boolean
[ "Checks", "if", "the", "content", "of", "the", "element", "is", "decimal" ]
train
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Form/Filterer.php#L229-L235
ezra-obiwale/dSCore
src/Form/Filterer.php
Filterer.greaterThan
public function greaterThan(array $options) { if (isset($options['element'])) { if (isset($this->data[$options['element']])) { $than = ' "' . $this->cleanElement($options['element']) . '"'; if ($this->elementData > $this->data[$options['element']] || (empty($this->elementData) && $this->elementData !== 0)) { return true; } } } else if (isset($options['value'])) { $than = $options['value']; if ($this->elementData > $options['value']) { return true; } } $this->addError($this->checkMessage('Value must be greater than ' . $than, $options)); return false; }
php
public function greaterThan(array $options) { if (isset($options['element'])) { if (isset($this->data[$options['element']])) { $than = ' "' . $this->cleanElement($options['element']) . '"'; if ($this->elementData > $this->data[$options['element']] || (empty($this->elementData) && $this->elementData !== 0)) { return true; } } } else if (isset($options['value'])) { $than = $options['value']; if ($this->elementData > $options['value']) { return true; } } $this->addError($this->checkMessage('Value must be greater than ' . $than, $options)); return false; }
[ "public", "function", "greaterThan", "(", "array", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'element'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "options", "[", "'element'", "...
Checks if the value of the element is greater than the given value @param string $name Name of the element to filter @param array $options Keys may include [message] @return boolean
[ "Checks", "if", "the", "value", "of", "the", "element", "is", "greater", "than", "the", "given", "value" ]
train
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Form/Filterer.php#L258-L275
ezra-obiwale/dSCore
src/Form/Filterer.php
Filterer.lessThan
public function lessThan(array $options) { if (isset($options['element'])) { if (isset($this->data[$options['element']])) { $than = ' "' . $this->cleanElement($options['element']) . '"'; if ($this->elementData < $this->data[$options['element']]) { return true; } } } else if (isset($options['value'])) { $than = $options['value']; if ($this->elementData < $options['value']) { return true; } } $this->addError($this->checkMessage('Value must be less than ' . $than, $options)); return false; }
php
public function lessThan(array $options) { if (isset($options['element'])) { if (isset($this->data[$options['element']])) { $than = ' "' . $this->cleanElement($options['element']) . '"'; if ($this->elementData < $this->data[$options['element']]) { return true; } } } else if (isset($options['value'])) { $than = $options['value']; if ($this->elementData < $options['value']) { return true; } } $this->addError($this->checkMessage('Value must be less than ' . $than, $options)); return false; }
[ "public", "function", "lessThan", "(", "array", "$", "options", ")", "{", "if", "(", "isset", "(", "$", "options", "[", "'element'", "]", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "$", "options", "[", "'element'", "]",...
Checks if the value of the element is less than the given value @param string $name Name of the element to filter @param array $options Keys may include [message] @return boolean
[ "Checks", "if", "the", "value", "of", "the", "element", "is", "less", "than", "the", "given", "value" ]
train
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Form/Filterer.php#L283-L300
ezra-obiwale/dSCore
src/Form/Filterer.php
Filterer.minLength
public function minLength(array $options) { if ($options['value'] && strlen($this->elementData) >= $options['value']) return true; $this->addError($this->checkMessage('Length must not be less than ' . $options['value'], $options)); return false; }
php
public function minLength(array $options) { if ($options['value'] && strlen($this->elementData) >= $options['value']) return true; $this->addError($this->checkMessage('Length must not be less than ' . $options['value'], $options)); return false; }
[ "public", "function", "minLength", "(", "array", "$", "options", ")", "{", "if", "(", "$", "options", "[", "'value'", "]", "&&", "strlen", "(", "$", "this", "->", "elementData", ")", ">=", "$", "options", "[", "'value'", "]", ")", "return", "true", "...
Checks if the length of the value of the element is not less than the required length @param string $name Name of the element to filter @param array $options Keys may include [message] @return boolean
[ "Checks", "if", "the", "length", "of", "the", "value", "of", "the", "element", "is", "not", "less", "than", "the", "required", "length" ]
train
https://github.com/ezra-obiwale/dSCore/blob/dd51246e0dc2c64d4d44de7992d7ff1b5165ab2d/src/Form/Filterer.php#L308-L314
CodeBlastr/queue
src/Shell/QueueShell.php
QueueShell.initialize
public function initialize() { $paths = App::path('Shell/Task', 'CodeBlastrQueue'); foreach ($paths as $path) { $Folder = new Folder($path); $res = array_merge($this->tasks, $Folder->find('Queue.+\.php')); foreach ($res as &$r) { $r = 'CodeBlastrQueue.' . basename($r, 'Task.php'); } $this->tasks = $res; } parent::initialize(); }
php
public function initialize() { $paths = App::path('Shell/Task', 'CodeBlastrQueue'); foreach ($paths as $path) { $Folder = new Folder($path); $res = array_merge($this->tasks, $Folder->find('Queue.+\.php')); foreach ($res as &$r) { $r = 'CodeBlastrQueue.' . basename($r, 'Task.php'); } $this->tasks = $res; } parent::initialize(); }
[ "public", "function", "initialize", "(", ")", "{", "$", "paths", "=", "App", "::", "path", "(", "'Shell/Task'", ",", "'CodeBlastrQueue'", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "$", "Folder", "=", "new", "Folder", "(", "...
Initialize method
[ "Initialize", "method" ]
train
https://github.com/CodeBlastr/queue/blob/8bc37c429406cce1b99c2c9e9dc1a83ad2b0b435/src/Shell/QueueShell.php#L33-L45
CodeBlastr/queue
src/Shell/QueueShell.php
QueueShell.main
public function main() { $this->out('CodeBlastr Queue Plugin:'); $this->hr(); $this->out('Usage:'); $this->out(' cake CodeBlastr.Queue help'); $this->out(' -> Display this Help message'); // $this->out(' cake Queue.Queue add <taskname>'); // $this->out(' -> Try to call the cli add() function on a task'); // $this->out(' -> tasks may or may not provide this functionality.'); $this->out(' cake Queue.Queue runworker'); $this->out(' -> run a queue worker, which will look for a pending task it can execute.'); $this->out(' -> the worker will always try to find jobs matching its installed Tasks'); $this->out(' -> see "Available Tasks" below.'); $this->out(' cake Queue.Queue runworker'); $this->out(' -> run a queue worker, which will look for a pending task it can execute.'); $this->out(' -> the worker will always try to find jobs matching its installed Tasks'); $this->out(' -> see "Available Tasks" below.'); $this->out(' cake Queue.Queue stats'); $this->out(' -> Display some general Statistics.'); $this->out(' cake Queue.Queue clean'); $this->out(' -> Manually call cleanup function to delete task data of completed tasks.'); }
php
public function main() { $this->out('CodeBlastr Queue Plugin:'); $this->hr(); $this->out('Usage:'); $this->out(' cake CodeBlastr.Queue help'); $this->out(' -> Display this Help message'); // $this->out(' cake Queue.Queue add <taskname>'); // $this->out(' -> Try to call the cli add() function on a task'); // $this->out(' -> tasks may or may not provide this functionality.'); $this->out(' cake Queue.Queue runworker'); $this->out(' -> run a queue worker, which will look for a pending task it can execute.'); $this->out(' -> the worker will always try to find jobs matching its installed Tasks'); $this->out(' -> see "Available Tasks" below.'); $this->out(' cake Queue.Queue runworker'); $this->out(' -> run a queue worker, which will look for a pending task it can execute.'); $this->out(' -> the worker will always try to find jobs matching its installed Tasks'); $this->out(' -> see "Available Tasks" below.'); $this->out(' cake Queue.Queue stats'); $this->out(' -> Display some general Statistics.'); $this->out(' cake Queue.Queue clean'); $this->out(' -> Manually call cleanup function to delete task data of completed tasks.'); }
[ "public", "function", "main", "(", ")", "{", "$", "this", "->", "out", "(", "'CodeBlastr Queue Plugin:'", ")", ";", "$", "this", "->", "hr", "(", ")", ";", "$", "this", "->", "out", "(", "'Usage:'", ")", ";", "$", "this", "->", "out", "(", "'\tcake...
Output some basic usage Info. @return void
[ "Output", "some", "basic", "usage", "Info", "." ]
train
https://github.com/CodeBlastr/queue/blob/8bc37c429406cce1b99c2c9e9dc1a83ad2b0b435/src/Shell/QueueShell.php#L52-L74
spiral/console
src/Command.php
Command.execute
protected function execute(InputInterface $input, OutputInterface $output) { $container = ContainerScope::getContainer(); if (empty($container)) { throw new ScopeException("Unable to run SpiralCommand outside of IoC scope."); } $reflection = new \ReflectionMethod($this, 'perform'); $reflection->setAccessible(true); /** @var ResolverInterface $resolver */ $resolver = $container->get(ResolverInterface::class); try { list($this->input, $this->output) = [$input, $output]; //Executing perform method with method injection return $reflection->invokeArgs($this, $resolver->resolveArguments( $reflection, compact('input', 'output') )); } finally { list($this->input, $this->output) = [null, null]; } }
php
protected function execute(InputInterface $input, OutputInterface $output) { $container = ContainerScope::getContainer(); if (empty($container)) { throw new ScopeException("Unable to run SpiralCommand outside of IoC scope."); } $reflection = new \ReflectionMethod($this, 'perform'); $reflection->setAccessible(true); /** @var ResolverInterface $resolver */ $resolver = $container->get(ResolverInterface::class); try { list($this->input, $this->output) = [$input, $output]; //Executing perform method with method injection return $reflection->invokeArgs($this, $resolver->resolveArguments( $reflection, compact('input', 'output') )); } finally { list($this->input, $this->output) = [null, null]; } }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "container", "=", "ContainerScope", "::", "getContainer", "(", ")", ";", "if", "(", "empty", "(", "$", "container", ")", ")", "{"...
{@inheritdoc} Pass execution to "perform" method using container to resolve method dependencies.
[ "{", "@inheritdoc", "}" ]
train
https://github.com/spiral/console/blob/c3d99450ddd32bcc6f87e2b2ed40821054a93da3/src/Command.php#L46-L70
spiral/console
src/Command.php
Command.configure
protected function configure() { $this->setName(static::NAME); $this->setDescription(static::DESCRIPTION); foreach ($this->defineOptions() as $option) { call_user_func_array([$this, 'addOption'], $option); } foreach ($this->defineArguments() as $argument) { call_user_func_array([$this, 'addArgument'], $argument); } }
php
protected function configure() { $this->setName(static::NAME); $this->setDescription(static::DESCRIPTION); foreach ($this->defineOptions() as $option) { call_user_func_array([$this, 'addOption'], $option); } foreach ($this->defineArguments() as $argument) { call_user_func_array([$this, 'addArgument'], $argument); } }
[ "protected", "function", "configure", "(", ")", "{", "$", "this", "->", "setName", "(", "static", "::", "NAME", ")", ";", "$", "this", "->", "setDescription", "(", "static", "::", "DESCRIPTION", ")", ";", "foreach", "(", "$", "this", "->", "defineOptions...
Configures the command.
[ "Configures", "the", "command", "." ]
train
https://github.com/spiral/console/blob/c3d99450ddd32bcc6f87e2b2ed40821054a93da3/src/Command.php#L75-L87
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.dispose
public final function dispose() { if ( $this->disposed ) { return; } if ( \is_resource( $this->r ) ) { \imagedestroy( $this->r ); } $this->r = null; $this->size = null; $this->colors = []; $this->mimeType = null; $this->_file = null; $this->disposed = true; }
php
public final function dispose() { if ( $this->disposed ) { return; } if ( \is_resource( $this->r ) ) { \imagedestroy( $this->r ); } $this->r = null; $this->size = null; $this->colors = []; $this->mimeType = null; $this->_file = null; $this->disposed = true; }
[ "public", "final", "function", "dispose", "(", ")", "{", "if", "(", "$", "this", "->", "disposed", ")", "{", "return", ";", "}", "if", "(", "\\", "is_resource", "(", "$", "this", "->", "r", ")", ")", "{", "\\", "imagedestroy", "(", "$", "this", "...
Disposes the current image resource.
[ "Disposes", "the", "current", "image", "resource", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L77-L97
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.save
public final function save( string $file = null, int $quality = 75 ) { if ( ! empty( $file ) ) { $this->_file = $file; } if ( empty( $this->_file ) ) { throw new IOError( 'Drawing.Image', $file, 'Saving a GdImage instance fails! No file is defined.' ); } $fMime = MimeTypeTool::GetByFileName( $this->_file ); if ( $fMime != $this->mimeType ) { $tmp = \explode( '/', $fMime ); $ext = $tmp[ 1 ]; if ( $ext == 'jpeg' ) { $ext = 'jpg'; } $this->_file = File::ChangeExtension( $this->_file, $ext ); $this->mimeType = $fMime; } switch ( $this->mimeType ) { case 'image/png': \imagepng( $this->r, $this->_file ); break; case 'image/gif': \imagegif( $this->r, $this->_file ); break; default: \imagejpeg( $this->r, $this->_file, $quality ); break; } }
php
public final function save( string $file = null, int $quality = 75 ) { if ( ! empty( $file ) ) { $this->_file = $file; } if ( empty( $this->_file ) ) { throw new IOError( 'Drawing.Image', $file, 'Saving a GdImage instance fails! No file is defined.' ); } $fMime = MimeTypeTool::GetByFileName( $this->_file ); if ( $fMime != $this->mimeType ) { $tmp = \explode( '/', $fMime ); $ext = $tmp[ 1 ]; if ( $ext == 'jpeg' ) { $ext = 'jpg'; } $this->_file = File::ChangeExtension( $this->_file, $ext ); $this->mimeType = $fMime; } switch ( $this->mimeType ) { case 'image/png': \imagepng( $this->r, $this->_file ); break; case 'image/gif': \imagegif( $this->r, $this->_file ); break; default: \imagejpeg( $this->r, $this->_file, $quality ); break; } }
[ "public", "final", "function", "save", "(", "string", "$", "file", "=", "null", ",", "int", "$", "quality", "=", "75", ")", "{", "if", "(", "!", "empty", "(", "$", "file", ")", ")", "{", "$", "this", "->", "_file", "=", "$", "file", ";", "}", ...
Saves the current image to defined image file. If no image file is defined the internally defined image file path is used. If its also not defined a {@see \Beluga\IO\Exception} is thrown. @param string $file Path of image file to save the current image instance. (Must be only defined if the instance does not define a path. @param integer $quality Image quality if it is saved as an JPEG image. (1-100) @throws \Beluga\IO\IOError
[ "Saves", "the", "current", "image", "to", "defined", "image", "file", ".", "If", "no", "image", "file", "is", "defined", "the", "internally", "defined", "image", "file", "path", "is", "used", ".", "If", "its", "also", "not", "defined", "a", "{", "@see", ...
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L193-L236
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.output
public final function output( int $quality = 60, string $filename = null ) { \header( 'Expires: 0' ); \header( 'Cache-Control: private' ); \header( 'Pragma: cache' ); if ( empty( $filename ) ) { $filename = \basename( $this->_file ); } else { $filename = \basename( $filename ); } if ( ! empty( $filename ) ) { \header( "Content-Disposition: inline; filename=\"{$filename}\"" ); $mime = MimeTypeTool::GetByFileName( $filename ); \header( "Content-Type: {$mime}" ); switch ( $mime ) { case 'image/png': \imagepng( $this->r ); break; case 'image/gif': \imagegif( $this->r ); break; default: \imagejpeg( $this->r, null, $quality ); break; } exit; } \header( "Content-Type: {$this->mimeType}" ); switch ( $this->mimeType ) { case 'image/png': \imagepng( $this->r ); break; case 'image/gif': \imagegif( $this->r ); break; default: \imagejpeg( $this->r, null, $quality ); break; } exit; }
php
public final function output( int $quality = 60, string $filename = null ) { \header( 'Expires: 0' ); \header( 'Cache-Control: private' ); \header( 'Pragma: cache' ); if ( empty( $filename ) ) { $filename = \basename( $this->_file ); } else { $filename = \basename( $filename ); } if ( ! empty( $filename ) ) { \header( "Content-Disposition: inline; filename=\"{$filename}\"" ); $mime = MimeTypeTool::GetByFileName( $filename ); \header( "Content-Type: {$mime}" ); switch ( $mime ) { case 'image/png': \imagepng( $this->r ); break; case 'image/gif': \imagegif( $this->r ); break; default: \imagejpeg( $this->r, null, $quality ); break; } exit; } \header( "Content-Type: {$this->mimeType}" ); switch ( $this->mimeType ) { case 'image/png': \imagepng( $this->r ); break; case 'image/gif': \imagegif( $this->r ); break; default: \imagejpeg( $this->r, null, $quality ); break; } exit; }
[ "public", "final", "function", "output", "(", "int", "$", "quality", "=", "60", ",", "string", "$", "filename", "=", "null", ")", "{", "\\", "header", "(", "'Expires: 0'", ")", ";", "\\", "header", "(", "'Cache-Control: private'", ")", ";", "\\", "header...
Outputs the current image, including all required HTTP headers and exit the script. @param integer $quality Image quality if it is an JPEG image. (1-100) @param string $filename Output image file name for HTTP headers.
[ "Outputs", "the", "current", "image", "including", "all", "required", "HTTP", "headers", "and", "exit", "the", "script", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L244-L297
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.rotateSquarely
public final function rotateSquarely( int $angle = 90, $fillColor = null, bool $internal = true ) : IImage { if ( ( $angle % 90 ) != 0 ) { throw new ArgumentError( 'angle', $angle, 'Drawing.Image', 'Only 90° and multiplications of it are allowed values for square image rotations.' ); } $fillColor = $this->getGdColorObject( $fillColor, 'rotate_fillcolor' ); $tmpR = \imagerotate( $this->r, $angle, $fillColor->getGdValue() ); if ( $internal ) { \imagedestroy( $this->r ); $this->r = $tmpR; $this->size = new Size( \imagesx( $this->r ), \imagesy( $this->r ) ); return $this; } $res = new GdImage( $tmpR, new Size( \imagesx( $tmpR ), \imagesy( $tmpR ) ), $this->mimeType, $this->_file ); $res->colors = $this->colors; return $res; }
php
public final function rotateSquarely( int $angle = 90, $fillColor = null, bool $internal = true ) : IImage { if ( ( $angle % 90 ) != 0 ) { throw new ArgumentError( 'angle', $angle, 'Drawing.Image', 'Only 90° and multiplications of it are allowed values for square image rotations.' ); } $fillColor = $this->getGdColorObject( $fillColor, 'rotate_fillcolor' ); $tmpR = \imagerotate( $this->r, $angle, $fillColor->getGdValue() ); if ( $internal ) { \imagedestroy( $this->r ); $this->r = $tmpR; $this->size = new Size( \imagesx( $this->r ), \imagesy( $this->r ) ); return $this; } $res = new GdImage( $tmpR, new Size( \imagesx( $tmpR ), \imagesy( $tmpR ) ), $this->mimeType, $this->_file ); $res->colors = $this->colors; return $res; }
[ "public", "final", "function", "rotateSquarely", "(", "int", "$", "angle", "=", "90", ",", "$", "fillColor", "=", "null", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "if", "(", "(", "$", "angle", "%", "90", ")", "!=", "0", ...
Rotate the image in 90° steps (90° or a multiple of it) @param integer $angle 90, 180, 270, -90, -180, -270 @param string|\Beluga\Drawing\Color|\Beluga\Drawing\ColorGD $fillColor Fill collor by need @param boolean $internal Dont create a new instance for it? @return \Beluga\Drawing\Image\IImage @throws \Beluga\ArgumentError If $angle is mot a multiple of 90.
[ "Rotate", "the", "image", "in", "90°", "steps", "(", "90°", "or", "a", "multiple", "of", "it", ")" ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L331-L369
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.negate
public final function negate( bool $internal = false ) : GdImage { if ( ! $internal ) { $clon = clone $this; return $clon->negate( true ); } $w = $this->getWidth(); $h = $this->getHeight(); $im = \imagecreatetruecolor( $w, $h ); for ( $y = 0; $y < $h; ++$y ) { for ( $x = 0; $x < $w; $x++ ) { $colors = \imagecolorsforindex( $this->r, \imagecolorat( $this->r, $x, $y ) ); $r = 255 - $colors[ 'red' ]; $g = 255 - $colors[ 'green' ]; $b = 255 - $colors[ 'blue' ]; $newColor = \imagecolorallocate( $im, $r, $g, $b ); \imagesetpixel( $im, $x, $y, $newColor ); } } \imagedestroy( $this->r ); $this->r = null; $this->r = $im; return $this; }
php
public final function negate( bool $internal = false ) : GdImage { if ( ! $internal ) { $clon = clone $this; return $clon->negate( true ); } $w = $this->getWidth(); $h = $this->getHeight(); $im = \imagecreatetruecolor( $w, $h ); for ( $y = 0; $y < $h; ++$y ) { for ( $x = 0; $x < $w; $x++ ) { $colors = \imagecolorsforindex( $this->r, \imagecolorat( $this->r, $x, $y ) ); $r = 255 - $colors[ 'red' ]; $g = 255 - $colors[ 'green' ]; $b = 255 - $colors[ 'blue' ]; $newColor = \imagecolorallocate( $im, $r, $g, $b ); \imagesetpixel( $im, $x, $y, $newColor ); } } \imagedestroy( $this->r ); $this->r = null; $this->r = $im; return $this; }
[ "public", "final", "function", "negate", "(", "bool", "$", "internal", "=", "false", ")", ":", "GdImage", "{", "if", "(", "!", "$", "internal", ")", "{", "$", "clon", "=", "clone", "$", "this", ";", "return", "$", "clon", "->", "negate", "(", "true...
Creates a negative of current image. @param boolean $internal Do not create a new instance? @return \Beluga\Drawing\Image\GdImage
[ "Creates", "a", "negative", "of", "current", "image", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L377-L413
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.crop
public final function crop( int $width, int $height, int $gravity = Gravity::TOP_LEFT, bool $internal = true ) : IImage { // Check if width and height is valid, and regulate the finally used values $this->cropCheck( $width, $height ); if ( $this->hasSameSize( $width, $height ) ) { // No size change needed return $internal ? $this : clone $this; } $rect = null; # <editor-fold desc="Rectangle anlegen"> switch ( $gravity ) { case Gravity::TOP_LEFT: $rect = Rectangle::Init( 0, 0, $width, $height ); break; case Gravity::TOP_CENTER: $rect = Rectangle::Init( (int) \floor( ( $this->getWidth() / 2.0 ) - ( $width / 2.0 ) ), 0, $width, $height ); break; case Gravity::TOP_RIGHT: $rect = Rectangle::Init( $this->getWidth() - $width, 0, $width, $height ); break; case Gravity::MIDDLE_LEFT: $rect = Rectangle::Init( 0, (int) \floor( ( $this->getHeight() / 2.0 ) - ( $height / 2.0 ) ), $width, $height ); break; case Gravity::MIDDLE_RIGHT: $rect = Rectangle::Init( $this->getWidth() - $width, (int) \floor( ( $this->getHeight() / 2.0 ) - ( $height / 2.0 ) ), $width, $height ); break; case Gravity::BOTTOM_LEFT: $rect = Rectangle::Init( 0, $this->getHeight() - $height, $width, $height ); break; case Gravity::BOTTOM_CENTER: $rect = Rectangle::Init( (int) \floor( ( $this->getWidth() / 2.0 ) - ( $width / 2.0 ) ), $this->getHeight() - $height, $width, $height ); break; case Gravity::BOTTOM_RIGHT: $rect = Rectangle::Init( $this->getWidth() - $width, $this->getHeight() - $height, $width, $height ); break; default: #case Gravity::MIDDLE_CENTER: $rect = Rectangle::Init( (int) \floor( ( $this->getWidth() / 2.0 ) - ( $width / 2.0 ) ), (int) \floor( ( $this->getHeight() / 2.0 ) - ( $height / 2.0 ) ), $width, $height ); break; } // </editor-fold> return $this->cropRect( $rect, $internal ); }
php
public final function crop( int $width, int $height, int $gravity = Gravity::TOP_LEFT, bool $internal = true ) : IImage { // Check if width and height is valid, and regulate the finally used values $this->cropCheck( $width, $height ); if ( $this->hasSameSize( $width, $height ) ) { // No size change needed return $internal ? $this : clone $this; } $rect = null; # <editor-fold desc="Rectangle anlegen"> switch ( $gravity ) { case Gravity::TOP_LEFT: $rect = Rectangle::Init( 0, 0, $width, $height ); break; case Gravity::TOP_CENTER: $rect = Rectangle::Init( (int) \floor( ( $this->getWidth() / 2.0 ) - ( $width / 2.0 ) ), 0, $width, $height ); break; case Gravity::TOP_RIGHT: $rect = Rectangle::Init( $this->getWidth() - $width, 0, $width, $height ); break; case Gravity::MIDDLE_LEFT: $rect = Rectangle::Init( 0, (int) \floor( ( $this->getHeight() / 2.0 ) - ( $height / 2.0 ) ), $width, $height ); break; case Gravity::MIDDLE_RIGHT: $rect = Rectangle::Init( $this->getWidth() - $width, (int) \floor( ( $this->getHeight() / 2.0 ) - ( $height / 2.0 ) ), $width, $height ); break; case Gravity::BOTTOM_LEFT: $rect = Rectangle::Init( 0, $this->getHeight() - $height, $width, $height ); break; case Gravity::BOTTOM_CENTER: $rect = Rectangle::Init( (int) \floor( ( $this->getWidth() / 2.0 ) - ( $width / 2.0 ) ), $this->getHeight() - $height, $width, $height ); break; case Gravity::BOTTOM_RIGHT: $rect = Rectangle::Init( $this->getWidth() - $width, $this->getHeight() - $height, $width, $height ); break; default: #case Gravity::MIDDLE_CENTER: $rect = Rectangle::Init( (int) \floor( ( $this->getWidth() / 2.0 ) - ( $width / 2.0 ) ), (int) \floor( ( $this->getHeight() / 2.0 ) - ( $height / 2.0 ) ), $width, $height ); break; } // </editor-fold> return $this->cropRect( $rect, $internal ); }
[ "public", "final", "function", "crop", "(", "int", "$", "width", ",", "int", "$", "height", ",", "int", "$", "gravity", "=", "Gravity", "::", "TOP_LEFT", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "// Check if width and height is v...
Crops the defined image part. @param integer $width The width @param integer $height The height @param integer $gravity The gravity. Use one of the constants from {@see \Beluga\Drawing\Gravity}. @param boolean $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage
[ "Crops", "the", "defined", "image", "part", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L429-L525
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.crop2
public final function crop2( int $width, int $height, ContentAlign $align, bool $internal = true ) : IImage { $this->cropCheck( $width, $height ); if ( $this->hasSameSize( $width, $height ) ) { return $internal ? $this : clone $this; } $rect = null; # <editor-fold desc="Rectangle anlegen"> switch ( $align->value ) { case ContentAlign::TOP_LEFT: $rect = Rectangle::Init( 0, 0, $width, $height ); break; case ContentAlign::TOP: $rect = Rectangle::Init( (int) \floor( ( $this->getWidth() / 2.0 ) - ( $width / 2.0 ) ), 0, $width, $height ); break; case ContentAlign::TOP_RIGHT: $rect = Rectangle::Init( $this->getWidth() - $width, 0, $width, $height ); break; case ContentAlign::MIDDLE_LEFT: $rect = Rectangle::Init( 0, (int) \floor( ( $this->getHeight() / 2.0 ) - ( $height / 2.0 ) ), $width, $height ); break; case ContentAlign::MIDDLE_RIGHT: $rect = Rectangle::Init( $this->getWidth() - $width, (int) \floor( ( $this->getHeight() / 2.0 ) - ( $height / 2.0 ) ), $width, $height ); break; case ContentAlign::BOTTOM_LEFT: $rect = Rectangle::Init( 0, $this->getHeight() - $height, $width, $height ); break; case ContentAlign::BOTTOM: $rect = Rectangle::Init( (int) \floor( ( $this->getWidth() / 2.0 ) - ( $width / 2.0 ) ), $this->getHeight() - $height, $width, $height ); break; case ContentAlign::BOTTOM_RIGHT: $rect = Rectangle::Init( $this->getWidth() - $width, $this->getHeight() - $height, $width, $height ); break; default: #case \GRAVITY_CENTER: $rect = Rectangle::Init( (int) \floor( ( $this->getWidth() / 2.0 ) - ( $width / 2.0 ) ), (int) \floor( ( $this->getHeight() / 2.0 ) - ( $height / 2.0 ) ), $width, $height ); break; } // </editor-fold> return $this->cropRect( $rect, $internal ); }
php
public final function crop2( int $width, int $height, ContentAlign $align, bool $internal = true ) : IImage { $this->cropCheck( $width, $height ); if ( $this->hasSameSize( $width, $height ) ) { return $internal ? $this : clone $this; } $rect = null; # <editor-fold desc="Rectangle anlegen"> switch ( $align->value ) { case ContentAlign::TOP_LEFT: $rect = Rectangle::Init( 0, 0, $width, $height ); break; case ContentAlign::TOP: $rect = Rectangle::Init( (int) \floor( ( $this->getWidth() / 2.0 ) - ( $width / 2.0 ) ), 0, $width, $height ); break; case ContentAlign::TOP_RIGHT: $rect = Rectangle::Init( $this->getWidth() - $width, 0, $width, $height ); break; case ContentAlign::MIDDLE_LEFT: $rect = Rectangle::Init( 0, (int) \floor( ( $this->getHeight() / 2.0 ) - ( $height / 2.0 ) ), $width, $height ); break; case ContentAlign::MIDDLE_RIGHT: $rect = Rectangle::Init( $this->getWidth() - $width, (int) \floor( ( $this->getHeight() / 2.0 ) - ( $height / 2.0 ) ), $width, $height ); break; case ContentAlign::BOTTOM_LEFT: $rect = Rectangle::Init( 0, $this->getHeight() - $height, $width, $height ); break; case ContentAlign::BOTTOM: $rect = Rectangle::Init( (int) \floor( ( $this->getWidth() / 2.0 ) - ( $width / 2.0 ) ), $this->getHeight() - $height, $width, $height ); break; case ContentAlign::BOTTOM_RIGHT: $rect = Rectangle::Init( $this->getWidth() - $width, $this->getHeight() - $height, $width, $height ); break; default: #case \GRAVITY_CENTER: $rect = Rectangle::Init( (int) \floor( ( $this->getWidth() / 2.0 ) - ( $width / 2.0 ) ), (int) \floor( ( $this->getHeight() / 2.0 ) - ( $height / 2.0 ) ), $width, $height ); break; } // </editor-fold> return $this->cropRect( $rect, $internal ); }
[ "public", "final", "function", "crop2", "(", "int", "$", "width", ",", "int", "$", "height", ",", "ContentAlign", "$", "align", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "$", "this", "->", "cropCheck", "(", "$", "width", ","...
Crops the defined image part. @param integer $width @param integer $height @param ContentAlign $align @param boolean $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage @throws \Beluga\ArgumentError If width and/or height is lower than 1
[ "Crops", "the", "defined", "image", "part", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L537-L631
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.cropRect
public final function cropRect( Rectangle $rect, bool $internal = true ) : IImage { $thumb = \imagecreatetruecolor( $rect->size->getWidth(), $rect->size->getHeight() ); if ( $this->mimeType == 'image/gif' || $this->mimeType == 'image/png') { \imagealphablending( $thumb, false ); \imagesavealpha( $thumb, true ); } \imagecopyresampled( $thumb, # $dst_image $this->r, # $src_image 0, # $dst_x 0, # $dst_y $rect->point->x, # $src_x $rect->point->y, # $src_y $rect->size->getWidth(), # $dst_w $rect->size->getHeight(), # $dst_h $rect->size->getWidth(), # $src_w $rect->size->getHeight() # $src_h ); if ( $internal ) { $this->size->setHeight( $rect->size->getHeight() ); $this->size->setWidth ( $rect->size->getWidth() ); if ( \is_resource( $this->r ) ) { \imagedestroy( $this->r ); $this->r = null; } $this->r = $thumb; return $this; } return new GdImage( $thumb, $rect->size, $this->mimeType, $this->_file ); }
php
public final function cropRect( Rectangle $rect, bool $internal = true ) : IImage { $thumb = \imagecreatetruecolor( $rect->size->getWidth(), $rect->size->getHeight() ); if ( $this->mimeType == 'image/gif' || $this->mimeType == 'image/png') { \imagealphablending( $thumb, false ); \imagesavealpha( $thumb, true ); } \imagecopyresampled( $thumb, # $dst_image $this->r, # $src_image 0, # $dst_x 0, # $dst_y $rect->point->x, # $src_x $rect->point->y, # $src_y $rect->size->getWidth(), # $dst_w $rect->size->getHeight(), # $dst_h $rect->size->getWidth(), # $src_w $rect->size->getHeight() # $src_h ); if ( $internal ) { $this->size->setHeight( $rect->size->getHeight() ); $this->size->setWidth ( $rect->size->getWidth() ); if ( \is_resource( $this->r ) ) { \imagedestroy( $this->r ); $this->r = null; } $this->r = $thumb; return $this; } return new GdImage( $thumb, $rect->size, $this->mimeType, $this->_file ); }
[ "public", "final", "function", "cropRect", "(", "Rectangle", "$", "rect", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "$", "thumb", "=", "\\", "imagecreatetruecolor", "(", "$", "rect", "->", "size", "->", "getWidth", "(", ")", "...
Crop the defined image part and returns the current or new image instance. @param \Beluga\Drawing\Rectangle $rect @param boolean $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage
[ "Crop", "the", "defined", "image", "part", "and", "returns", "the", "current", "or", "new", "image", "instance", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L640-L680
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.cropQuadratic
public final function cropQuadratic( int $gravity = Gravity::MIDDLE_CENTER, bool $internal = true ) : IImage { if ( $this->size->isLandscape() ) { return $this->crop( $this->getHeight(), $this->getHeight(), $gravity, $internal ); } return $this->crop( $this->getWidth(), $this->getWidth(), $gravity, $internal ); }
php
public final function cropQuadratic( int $gravity = Gravity::MIDDLE_CENTER, bool $internal = true ) : IImage { if ( $this->size->isLandscape() ) { return $this->crop( $this->getHeight(), $this->getHeight(), $gravity, $internal ); } return $this->crop( $this->getWidth(), $this->getWidth(), $gravity, $internal ); }
[ "public", "final", "function", "cropQuadratic", "(", "int", "$", "gravity", "=", "Gravity", "::", "MIDDLE_CENTER", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "if", "(", "$", "this", "->", "size", "->", "isLandscape", "(", ")", ...
Crop the max usable quadratic image part from declared position and returns the current or new image instance. @param integer|string $gravity The gravity. Use one of the constants from {@see \Beluga\Drawing\Gravity}. @param boolean $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage
[ "Crop", "the", "max", "usable", "quadratic", "image", "part", "from", "declared", "position", "and", "returns", "the", "current", "or", "new", "image", "instance", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L689-L700
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.cropQuadratic2
public final function cropQuadratic2( ContentAlign $align, bool $internal = true ) : IImage { if ( $this->size->isLandscape() ) { return $this->crop2( $this->getHeight(), $this->getHeight(), $align, $internal ); } return $this->crop2( $this->getWidth(), $this->getWidth(), $align, $internal ); }
php
public final function cropQuadratic2( ContentAlign $align, bool $internal = true ) : IImage { if ( $this->size->isLandscape() ) { return $this->crop2( $this->getHeight(), $this->getHeight(), $align, $internal ); } return $this->crop2( $this->getWidth(), $this->getWidth(), $align, $internal ); }
[ "public", "final", "function", "cropQuadratic2", "(", "ContentAlign", "$", "align", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "if", "(", "$", "this", "->", "size", "->", "isLandscape", "(", ")", ")", "{", "return", "$", "this"...
Crop the max usable quadratic image part from declared position and returns the current or new image instance. @param ContentAlign $align @param boolean $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage
[ "Crop", "the", "max", "usable", "quadratic", "image", "part", "from", "declared", "position", "and", "returns", "the", "current", "or", "new", "image", "instance", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L709-L720
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.contract
public final function contract( int $percent, bool $internal = true ) : IImage { if ( $percent < 1 || $percent >= 100 ) { throw new ArgumentError( 'percent', $percent, 'Drawing.Image', 'Image dimension contraction must produce a smaller, non zero sized image!' ); } $newWidth = \intval( \floor( $this->getWidth() * $percent / 100 ) ); $newHeight = \intval( \floor( $this->getHeight() * $percent / 100 ) ); if ( $this->isTrueColor() ) { $dst = \imagecreatetruecolor( $newWidth, $newHeight ); } else { $dst = \imagecreate( $newWidth, $newHeight ); } if ( $this->canUseTransparency() ) { \imagealphablending( $dst, false ); \imagesavealpha( $dst, true ); } \imagecopyresized( $dst, $this->r, 0, 0, 0, 0, $newWidth, $newHeight, $this->getWidth(), $this->getHeight() ); if ( $internal ) { if ( ! \is_null( $this->r ) ) { \imagedestroy( $this->r ); $this->r = null; } $this->r = $dst; $this->size->setWidth( $newWidth ); $this->size->setHeight( $newHeight ); return $this; } return new GdImage( $dst, new Size( $newWidth, $newHeight ), $this->mimeType, $this->_file ); }
php
public final function contract( int $percent, bool $internal = true ) : IImage { if ( $percent < 1 || $percent >= 100 ) { throw new ArgumentError( 'percent', $percent, 'Drawing.Image', 'Image dimension contraction must produce a smaller, non zero sized image!' ); } $newWidth = \intval( \floor( $this->getWidth() * $percent / 100 ) ); $newHeight = \intval( \floor( $this->getHeight() * $percent / 100 ) ); if ( $this->isTrueColor() ) { $dst = \imagecreatetruecolor( $newWidth, $newHeight ); } else { $dst = \imagecreate( $newWidth, $newHeight ); } if ( $this->canUseTransparency() ) { \imagealphablending( $dst, false ); \imagesavealpha( $dst, true ); } \imagecopyresized( $dst, $this->r, 0, 0, 0, 0, $newWidth, $newHeight, $this->getWidth(), $this->getHeight() ); if ( $internal ) { if ( ! \is_null( $this->r ) ) { \imagedestroy( $this->r ); $this->r = null; } $this->r = $dst; $this->size->setWidth( $newWidth ); $this->size->setHeight( $newHeight ); return $this; } return new GdImage( $dst, new Size( $newWidth, $newHeight ), $this->mimeType, $this->_file ); }
[ "public", "final", "function", "contract", "(", "int", "$", "percent", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "if", "(", "$", "percent", "<", "1", "||", "$", "percent", ">=", "100", ")", "{", "throw", "new", "ArgumentErro...
Reduce the original image size by the specified percentage value. @param int $percent The percentage value. @param bool $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage @throws \Beluga\ArgumentError If $percent is lower than 1 oder greater than 99.
[ "Reduce", "the", "original", "image", "size", "by", "the", "specified", "percentage", "value", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L735-L789
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.contractToMaxSize
public final function contractToMaxSize( Size $maxsize, bool $internal = true ) : IImage { if ( $maxsize->getWidth() >= $this->size->getWidth() && $maxsize->getHeight() >= $this->size->getHeight() ) { return $this->returnSelf( $internal ); } $newSize = new Size( $this->size->getWidth(), $this->size->getHeight() ); $newSize->reduceToMaxSize( $maxsize ); return $this->createImageAfterResize( $newSize, $internal ); }
php
public final function contractToMaxSize( Size $maxsize, bool $internal = true ) : IImage { if ( $maxsize->getWidth() >= $this->size->getWidth() && $maxsize->getHeight() >= $this->size->getHeight() ) { return $this->returnSelf( $internal ); } $newSize = new Size( $this->size->getWidth(), $this->size->getHeight() ); $newSize->reduceToMaxSize( $maxsize ); return $this->createImageAfterResize( $newSize, $internal ); }
[ "public", "final", "function", "contractToMaxSize", "(", "Size", "$", "maxsize", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "if", "(", "$", "maxsize", "->", "getWidth", "(", ")", ">=", "$", "this", "->", "size", "->", "getWidth...
Reduce the original image size by holding the image size proportion, to fit best the declared maximum size. @param \Beluga\Drawing\Size $maxsize @param bool $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage @throws \Beluga\ArgumentError If $maxsize is empty. or bigger than current image
[ "Reduce", "the", "original", "image", "size", "by", "holding", "the", "image", "size", "proportion", "to", "fit", "best", "the", "declared", "maximum", "size", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L800-L815
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.contractToMaxSide
public final function contractToMaxSide( int $maxSideLandscape, int $maxSidePortrait, bool $internal = true ) : IImage { $isPortrait = $this->size->isPortrait(); if ( ( $isPortrait && ( $this->size->getHeight() <= $maxSidePortrait ) ) || ( ! $isPortrait && ( $this->size->getWidth() <= $maxSideLandscape ) ) ) { return $this->returnSelf( $internal ); } $newSize = clone $this->size; $newSize->reduceMaxSideTo2( $maxSideLandscape, $maxSidePortrait ); return $this->createImageAfterResize( $newSize, $internal ); }
php
public final function contractToMaxSide( int $maxSideLandscape, int $maxSidePortrait, bool $internal = true ) : IImage { $isPortrait = $this->size->isPortrait(); if ( ( $isPortrait && ( $this->size->getHeight() <= $maxSidePortrait ) ) || ( ! $isPortrait && ( $this->size->getWidth() <= $maxSideLandscape ) ) ) { return $this->returnSelf( $internal ); } $newSize = clone $this->size; $newSize->reduceMaxSideTo2( $maxSideLandscape, $maxSidePortrait ); return $this->createImageAfterResize( $newSize, $internal ); }
[ "public", "final", "function", "contractToMaxSide", "(", "int", "$", "maxSideLandscape", ",", "int", "$", "maxSidePortrait", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "$", "isPortrait", "=", "$", "this", "->", "size", "->", "isPor...
Reduce the original image size by holding the image size proportion. The longer image side will be reduced to a length, defined by $maxSideLandscape or $maxSidePortrait, depending to the format of the current image @param int $maxSideLandscape The max. longer side length of landscape format images. @param int $maxSidePortrait The max. longer side length of portrait/quadratic format images. @param bool $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage @throws \Beluga\ArgumentError If $maxSideLandscape or $maxSidePortrait is empty.
[ "Reduce", "the", "original", "image", "size", "by", "holding", "the", "image", "size", "proportion", ".", "The", "longer", "image", "side", "will", "be", "reduced", "to", "a", "length", "defined", "by", "$maxSideLandscape", "or", "$maxSidePortrait", "depending",...
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L828-L845
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.contractToMinSide
public final function contractToMinSide( int $maxSideLandscape, int $maxSidePortrait, bool $internal = true ) : IImage { $isPortrait = $this->size->isPortrait(); if ( ( $isPortrait && ( $this->size->getWidth() <= $maxSidePortrait ) ) || ( ! $isPortrait && ( $this->size->getHeight() <= $maxSideLandscape ) ) ) { return $this->returnSelf( $internal ); } $newSize = clone $this->size; $newSize->reduceMinSideTo2( $maxSideLandscape, $maxSidePortrait ); return $this->createImageAfterResize( $newSize, $internal ); }
php
public final function contractToMinSide( int $maxSideLandscape, int $maxSidePortrait, bool $internal = true ) : IImage { $isPortrait = $this->size->isPortrait(); if ( ( $isPortrait && ( $this->size->getWidth() <= $maxSidePortrait ) ) || ( ! $isPortrait && ( $this->size->getHeight() <= $maxSideLandscape ) ) ) { return $this->returnSelf( $internal ); } $newSize = clone $this->size; $newSize->reduceMinSideTo2( $maxSideLandscape, $maxSidePortrait ); return $this->createImageAfterResize( $newSize, $internal ); }
[ "public", "final", "function", "contractToMinSide", "(", "int", "$", "maxSideLandscape", ",", "int", "$", "maxSidePortrait", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "$", "isPortrait", "=", "$", "this", "->", "size", "->", "isPor...
Reduce the original image size by holding the image size proportion. The shorter image side will be reduced to a length, defined by $maxSideLandscape or $maxSidePortrait, depending to the format of the current image @param int $maxSideLandscape The max. shorter side length of landscape format images. @param int $maxSidePortrait The max. shorter side length of portrait/quadratic format images. @param bool $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage @throws \Beluga\ArgumentError If $maxSideLandscape or $maxSidePortrait is empty.
[ "Reduce", "the", "original", "image", "size", "by", "holding", "the", "image", "size", "proportion", ".", "The", "shorter", "image", "side", "will", "be", "reduced", "to", "a", "length", "defined", "by", "$maxSideLandscape", "or", "$maxSidePortrait", "depending"...
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L858-L875
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.place
public final function place( IImage $placement, Point $point, int $opacity = 100, bool $internal = true ) : IImage { if ( ! ( $placement instanceof GdImage ) ) { throw new ArgumentError( 'placement', $placement, 'Drawing.Image', 'Can not place an image that is not of type GdImage' ); } if ( ! $internal ) { $res = clone $this; if ( $placement->canUseTransparency() && $opacity < 100 ) { \imagecopymerge( $res->r, $placement->r, $point->x, $point->y, 0, 0, $placement->getWidth(), $placement->getHeight(), $opacity ); } else { \imagecopy( $res->r, $placement->r, $point->x, $point->y, 0, 0, $placement->getWidth(), $placement->getHeight() ); } return $res; } if ( $placement->canUseTransparency() && $opacity < 100 ) { \imagecopymerge( $this->r, $placement->r, $point->x, $point->y, 0, 0, $placement->getWidth(), $placement->getHeight(), $opacity ); } else { \imagecopy( $this->r, $placement->r, $point->x, $point->y, 0, 0, $placement->getWidth(), $placement->getHeight() ); } return $this; }
php
public final function place( IImage $placement, Point $point, int $opacity = 100, bool $internal = true ) : IImage { if ( ! ( $placement instanceof GdImage ) ) { throw new ArgumentError( 'placement', $placement, 'Drawing.Image', 'Can not place an image that is not of type GdImage' ); } if ( ! $internal ) { $res = clone $this; if ( $placement->canUseTransparency() && $opacity < 100 ) { \imagecopymerge( $res->r, $placement->r, $point->x, $point->y, 0, 0, $placement->getWidth(), $placement->getHeight(), $opacity ); } else { \imagecopy( $res->r, $placement->r, $point->x, $point->y, 0, 0, $placement->getWidth(), $placement->getHeight() ); } return $res; } if ( $placement->canUseTransparency() && $opacity < 100 ) { \imagecopymerge( $this->r, $placement->r, $point->x, $point->y, 0, 0, $placement->getWidth(), $placement->getHeight(), $opacity ); } else { \imagecopy( $this->r, $placement->r, $point->x, $point->y, 0, 0, $placement->getWidth(), $placement->getHeight() ); } return $this; }
[ "public", "final", "function", "place", "(", "IImage", "$", "placement", ",", "Point", "$", "point", ",", "int", "$", "opacity", "=", "100", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "if", "(", "!", "(", "$", "placement", ...
Places the defined $placement image inside the current image. @param \Beluga\Drawing\Image\IImage $placement The image that should be placed @param Point $point The top left point of the placement @param int $opacity The opacity of the placement in % (1-100) @param bool $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage @throws \Beluga\ArgumentError
[ "Places", "the", "defined", "$placement", "image", "inside", "the", "current", "image", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L892-L960
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.placeWithGravity
public final function placeWithGravity( IImage $placement, int $padding, $gravity = Gravity::MIDDLE_CENTER, int $opacity = 100, bool $internal = true ) : IImage { # <editor-fold desc="X + Y zuweisen"> switch ( $gravity ) { case Gravity::TOP_LEFT: $x = $padding; $y = $padding; break; case Gravity::TOP_CENTER: $x = \intval( \floor( ( $this->getWidth() / 2 ) - ( $placement->getWidth() / 2 ) ) ); $y = $padding; break; case Gravity::TOP_RIGHT: $x = $this->getWidth() - $placement->getWidth() - $padding; $y = $padding; break; case Gravity::MIDDLE_LEFT: $x = $padding; $y = \intval( \floor( ( $this->getHeight() / 2 ) - ( $placement->getHeight() / 2 ) ) ); break; case Gravity::MIDDLE_RIGHT: $x = $this->getWidth() - $placement->getWidth() - $padding; $y = \intval( \floor( ( $this->getHeight() / 2 ) - ( $placement->getHeight() / 2 ) ) ); break; case Gravity::BOTTOM_LEFT: $x = $padding; $y = $this->getHeight() - $placement->getHeight() - $padding; break; case Gravity::BOTTOM_CENTER: $x = \intval( \floor( ( $this->getWidth() / 2 ) - ( $placement->getWidth() / 2 ) ) ); $y = $this->getHeight() - $placement->getHeight() - $padding; break; case Gravity::BOTTOM_RIGHT: $x = $this->getWidth() - $placement->getWidth() - $padding; $y = $this->getHeight() - $placement->getHeight() - $padding; break; default: # case Gravity::MIDDLE_CENTER: $x = \intval( \floor( ( $this->getWidth() / 2 ) - ( $placement->getWidth() / 2 ) ) ); $y = \intval( \floor( ( $this->getHeight() / 2 ) - ( $placement->getHeight() / 2 ) ) ); break; } // </editor-fold> return $this->place( $placement, new Point( $x, $y ), $opacity, $internal ); }
php
public final function placeWithGravity( IImage $placement, int $padding, $gravity = Gravity::MIDDLE_CENTER, int $opacity = 100, bool $internal = true ) : IImage { # <editor-fold desc="X + Y zuweisen"> switch ( $gravity ) { case Gravity::TOP_LEFT: $x = $padding; $y = $padding; break; case Gravity::TOP_CENTER: $x = \intval( \floor( ( $this->getWidth() / 2 ) - ( $placement->getWidth() / 2 ) ) ); $y = $padding; break; case Gravity::TOP_RIGHT: $x = $this->getWidth() - $placement->getWidth() - $padding; $y = $padding; break; case Gravity::MIDDLE_LEFT: $x = $padding; $y = \intval( \floor( ( $this->getHeight() / 2 ) - ( $placement->getHeight() / 2 ) ) ); break; case Gravity::MIDDLE_RIGHT: $x = $this->getWidth() - $placement->getWidth() - $padding; $y = \intval( \floor( ( $this->getHeight() / 2 ) - ( $placement->getHeight() / 2 ) ) ); break; case Gravity::BOTTOM_LEFT: $x = $padding; $y = $this->getHeight() - $placement->getHeight() - $padding; break; case Gravity::BOTTOM_CENTER: $x = \intval( \floor( ( $this->getWidth() / 2 ) - ( $placement->getWidth() / 2 ) ) ); $y = $this->getHeight() - $placement->getHeight() - $padding; break; case Gravity::BOTTOM_RIGHT: $x = $this->getWidth() - $placement->getWidth() - $padding; $y = $this->getHeight() - $placement->getHeight() - $padding; break; default: # case Gravity::MIDDLE_CENTER: $x = \intval( \floor( ( $this->getWidth() / 2 ) - ( $placement->getWidth() / 2 ) ) ); $y = \intval( \floor( ( $this->getHeight() / 2 ) - ( $placement->getHeight() / 2 ) ) ); break; } // </editor-fold> return $this->place( $placement, new Point( $x, $y ), $opacity, $internal ); }
[ "public", "final", "function", "placeWithGravity", "(", "IImage", "$", "placement", ",", "int", "$", "padding", ",", "$", "gravity", "=", "Gravity", "::", "MIDDLE_CENTER", ",", "int", "$", "opacity", "=", "100", ",", "bool", "$", "internal", "=", "true", ...
Places the defined $placement image inside the current image. @param \Beluga\Drawing\Image\IImage $placement The image that should be placed @param int $padding The min. padding around the placement @param int $gravity The placement gravity inside the current image (see {@see \Beluga\Drawing\Image\Gravity}::* constants) @param int $opacity The opacity of the placement in % (1-100) @param bool $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage @throws \Beluga\ArgumentError
[ "Places", "the", "defined", "$placement", "image", "inside", "the", "current", "image", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L974-L1034
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.placeWithContentAlign
public final function placeWithContentAlign( IImage $placement, int $padding, ContentAlign $align, int $opacity = 100, bool $internal = true ) : IImage { # <editor-fold desc="X + Y"> switch ( $align->value ) { case ContentAlign::TOP_LEFT: $x = $padding; $y = $padding; break; case ContentAlign::TOP: $x = \intval( \floor( ( $this->getWidth() / 2 ) - ( $placement->getWidth() / 2 ) ) ); $y = $padding; break; case ContentAlign::TOP_RIGHT: $x = $this->getWidth() - $placement->getWidth() - $padding; $y = $padding; break; case ContentAlign::MIDDLE_LEFT: $x = $padding; $y = \intval( \floor( ( $this->getHeight() / 2 ) - ( $placement->getHeight() / 2 ) ) ); break; case ContentAlign::MIDDLE_RIGHT: $x = $this->getWidth() - $placement->getWidth() - $padding; $y = \intval( \floor( ( $this->getHeight() / 2 ) - ( $placement->getHeight() / 2 ) ) ); break; case ContentAlign::BOTTOM_LEFT: $x = $padding; $y = $this->getHeight() - $placement->getHeight() - $padding; break; case ContentAlign::BOTTOM: $x = \intval( \floor( ( $this->getWidth() / 2 ) - ( $placement->getWidth() / 2 ) ) ); $y = $this->getHeight() - $placement->getHeight() - $padding; break; case ContentAlign::BOTTOM_RIGHT: $x = $this->getWidth() - $placement->getWidth() - $padding; $y = $this->getHeight() - $placement->getHeight() - $padding; break; default: # case \GRAVITY_CENTER: $x = \intval( \floor( ( $this->getWidth() / 2 ) - ( $placement->getWidth() / 2 ) ) ); $y = \intval( \floor( ( $this->getHeight() / 2 ) - ( $placement->getHeight() / 2 ) ) ); break; } // </editor-fold> return $this->place( $placement, new Point( $x, $y ), $opacity, $internal ); }
php
public final function placeWithContentAlign( IImage $placement, int $padding, ContentAlign $align, int $opacity = 100, bool $internal = true ) : IImage { # <editor-fold desc="X + Y"> switch ( $align->value ) { case ContentAlign::TOP_LEFT: $x = $padding; $y = $padding; break; case ContentAlign::TOP: $x = \intval( \floor( ( $this->getWidth() / 2 ) - ( $placement->getWidth() / 2 ) ) ); $y = $padding; break; case ContentAlign::TOP_RIGHT: $x = $this->getWidth() - $placement->getWidth() - $padding; $y = $padding; break; case ContentAlign::MIDDLE_LEFT: $x = $padding; $y = \intval( \floor( ( $this->getHeight() / 2 ) - ( $placement->getHeight() / 2 ) ) ); break; case ContentAlign::MIDDLE_RIGHT: $x = $this->getWidth() - $placement->getWidth() - $padding; $y = \intval( \floor( ( $this->getHeight() / 2 ) - ( $placement->getHeight() / 2 ) ) ); break; case ContentAlign::BOTTOM_LEFT: $x = $padding; $y = $this->getHeight() - $placement->getHeight() - $padding; break; case ContentAlign::BOTTOM: $x = \intval( \floor( ( $this->getWidth() / 2 ) - ( $placement->getWidth() / 2 ) ) ); $y = $this->getHeight() - $placement->getHeight() - $padding; break; case ContentAlign::BOTTOM_RIGHT: $x = $this->getWidth() - $placement->getWidth() - $padding; $y = $this->getHeight() - $placement->getHeight() - $padding; break; default: # case \GRAVITY_CENTER: $x = \intval( \floor( ( $this->getWidth() / 2 ) - ( $placement->getWidth() / 2 ) ) ); $y = \intval( \floor( ( $this->getHeight() / 2 ) - ( $placement->getHeight() / 2 ) ) ); break; } // </editor-fold> return $this->place( $placement, new Point( $x, $y ), $opacity, $internal ); }
[ "public", "final", "function", "placeWithContentAlign", "(", "IImage", "$", "placement", ",", "int", "$", "padding", ",", "ContentAlign", "$", "align", ",", "int", "$", "opacity", "=", "100", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", ...
Places the defined $placement image inside the current image. @param \Beluga\Drawing\Image\IImage $placement The image that should be placed @param int $padding The min. padding around the placement @param ContentAlign $align The placement align inside the current image @param int $opacity The opacity of the placement in % (1-100) @param bool $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage @throws \Beluga\ArgumentError
[ "Places", "the", "defined", "$placement", "image", "inside", "the", "current", "image", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L1047-L1107
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.drawSingleBorder
public final function drawSingleBorder( $borderColor, bool $internal = true ) : IImage { $borderColor = $this->getGdColorObject( $borderColor, 'bordercolor' ); if ( $internal ) { \imagerectangle( $this->r, 1, 1, $this->getWidth() - 2, $this->getHeight() - 2, $borderColor->getGdValue() ); return $this; } $res = clone $this; \imagerectangle( $res->r, 1, 1, $this->getWidth() - 2, $this->getHeight() - 2, $borderColor->getGdValue() ); return $res; }
php
public final function drawSingleBorder( $borderColor, bool $internal = true ) : IImage { $borderColor = $this->getGdColorObject( $borderColor, 'bordercolor' ); if ( $internal ) { \imagerectangle( $this->r, 1, 1, $this->getWidth() - 2, $this->getHeight() - 2, $borderColor->getGdValue() ); return $this; } $res = clone $this; \imagerectangle( $res->r, 1, 1, $this->getWidth() - 2, $this->getHeight() - 2, $borderColor->getGdValue() ); return $res; }
[ "public", "final", "function", "drawSingleBorder", "(", "$", "borderColor", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "$", "borderColor", "=", "$", "this", "->", "getGdColorObject", "(", "$", "borderColor", ",", "'bordercolor'", ")"...
Draws a single border with defined color around the image. @param string|array|\Beluga\Drawing\ColorGD|\Beluga\Drawing\Color $borderColor @param bool $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage
[ "Draws", "a", "single", "border", "with", "defined", "color", "around", "the", "image", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L1121-L1141
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.drawDoubleBorder
public final function drawDoubleBorder( $innerBorderColor, $outerBorderColor, bool $internal = true) : IImage { $innerBorderColor = $this->getGdColorObject( $innerBorderColor, 'bordercolor' ); $outerBorderColor = $this->getGdColorObject( $outerBorderColor, 'outerbordercolor' ); if ( $internal ) { \imagerectangle( $this->r, 0, 0, $this->getWidth() - 1, $this->getHeight() - 1, $outerBorderColor->getGdValue() ); \imagerectangle( $this->r, 1, 1, $this->getWidth() - 2, $this->getHeight() - 2, $innerBorderColor->getGdValue() ); return $this; } $res = clone $this; \imagerectangle( $res->r, 0, 0, $this->getWidth() - 1, $this->getHeight() - 1, $outerBorderColor->getGdValue() ); \imagerectangle( $res->r, 1, 1, $this->getWidth() - 2, $this->getHeight() - 2, $innerBorderColor->getGdValue() ); return $res; }
php
public final function drawDoubleBorder( $innerBorderColor, $outerBorderColor, bool $internal = true) : IImage { $innerBorderColor = $this->getGdColorObject( $innerBorderColor, 'bordercolor' ); $outerBorderColor = $this->getGdColorObject( $outerBorderColor, 'outerbordercolor' ); if ( $internal ) { \imagerectangle( $this->r, 0, 0, $this->getWidth() - 1, $this->getHeight() - 1, $outerBorderColor->getGdValue() ); \imagerectangle( $this->r, 1, 1, $this->getWidth() - 2, $this->getHeight() - 2, $innerBorderColor->getGdValue() ); return $this; } $res = clone $this; \imagerectangle( $res->r, 0, 0, $this->getWidth() - 1, $this->getHeight() - 1, $outerBorderColor->getGdValue() ); \imagerectangle( $res->r, 1, 1, $this->getWidth() - 2, $this->getHeight() - 2, $innerBorderColor->getGdValue() ); return $res; }
[ "public", "final", "function", "drawDoubleBorder", "(", "$", "innerBorderColor", ",", "$", "outerBorderColor", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "$", "innerBorderColor", "=", "$", "this", "->", "getGdColorObject", "(", "$", ...
Draws a double border with defined colors around the image. @param string|array|\Beluga\Drawing\ColorGD|\Beluga\Drawing\Color $innerBorderColor @param string|array|\Beluga\Drawing\ColorGD|\Beluga\Drawing\Color $outerBorderColor @param bool $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage
[ "Draws", "a", "double", "border", "with", "defined", "colors", "around", "the", "image", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L1151-L1166
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.drawText
public final function drawText( string $text, $font, $fontSize, $color, Point $point, bool $internal = true ) : IImage { $color = $this->getGdColorObject( $color, 'textcolor' ); if ( ! empty( $font ) && \file_exists( $font ) ) { if ( $internal ) { \imagettftext( $this->r, $fontSize, 0, $point->x, $point->y, $color->getGdValue(), $font, $text ); return $this; } $res = clone $this; \imagettftext( $res->r, $fontSize, 0, $point->x, $point->y, $color->getGdValue(), $font, $text ); return $res; } if ( $internal ) { \imagestring( $this->r, $fontSize, $point->x, $point->y, $text, $color->getGdValue() ); return $this; } $res = clone $this; \imagestring( $res->r, $fontSize, $point->x, $point->y, $text, $color->getGdValue() ); return $res; }
php
public final function drawText( string $text, $font, $fontSize, $color, Point $point, bool $internal = true ) : IImage { $color = $this->getGdColorObject( $color, 'textcolor' ); if ( ! empty( $font ) && \file_exists( $font ) ) { if ( $internal ) { \imagettftext( $this->r, $fontSize, 0, $point->x, $point->y, $color->getGdValue(), $font, $text ); return $this; } $res = clone $this; \imagettftext( $res->r, $fontSize, 0, $point->x, $point->y, $color->getGdValue(), $font, $text ); return $res; } if ( $internal ) { \imagestring( $this->r, $fontSize, $point->x, $point->y, $text, $color->getGdValue() ); return $this; } $res = clone $this; \imagestring( $res->r, $fontSize, $point->x, $point->y, $text, $color->getGdValue() ); return $res; }
[ "public", "final", "function", "drawText", "(", "string", "$", "text", ",", "$", "font", ",", "$", "fontSize", ",", "$", "color", ",", "Point", "$", "point", ",", "bool", "$", "internal", "=", "true", ")", ":", "IImage", "{", "$", "color", "=", "$"...
Draws a text at declared position into current image. @param string $text The text that should be drawn. @param string $font The font that should be used. For example: For GdImage you can define here the path of the *.ttf font file or NULL. If you define null the parameter $fontSize declares the size + font (1-4). If a path is defined here $fontSize should declare the size in points. @param int $fontSize The size of the font. @param string|array|\Beluga\Drawing\Color|\Beluga\Drawing\ColorGD $color The text color @param \Beluga\Drawing\Point $point The top left point where to start the text @param bool $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage
[ "Draws", "a", "text", "at", "declared", "position", "into", "current", "image", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L1187-L1217
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.drawTextWithGravity
public final function drawTextWithGravity( string $text, $font, $fontSize, $color, int $padding, int $gravity, bool $internal = true ) : IImage { if ( ! empty( $font ) && \file_exists( $font ) ) { return $this->drawText( $text, $font, $fontSize, $color, $this->imageTtfPoint( $fontSize, 0, $font, $text, $gravity, $this->size, $padding ), $internal ); } if ( ! \is_int( $fontSize ) ) { $fontSize = 2; } if ( $fontSize < 1 ) { $fontSize = 1; } else if ( $fontSize > 4 ) { $fontSize = 4; } $textSize = $this->imageMeasureString( $fontSize, $text ); #$textSize->setHeight( $textSize->getHeight() - 2 ); #$textSize->setWidth ( $textSize->getWidth() + 1 ); $point = null; # Get the insertion point by gravity switch ( $gravity ) { case Gravity::BOTTOM_LEFT: $point = new Point( $padding, $this->getHeight() - $textSize->getHeight() - $padding ); break; case Gravity::BOTTOM_CENTER: $point = new Point( \intval( \floor( ( $this->getWidth() / 2 ) - ( $textSize->getWidth() / 2 ) ) ), $this->getHeight() - $textSize->getHeight() - $padding ); break; case Gravity::BOTTOM_RIGHT: $point = new Point( $this->getWidth() - $textSize->getWidth() - $padding, $this->getHeight() - $textSize->getHeight() - $padding ); break; case Gravity::MIDDLE_LEFT: $point = new Point( $padding, \intval( \floor( ( $this->getHeight() / 2 ) - ( $textSize->getHeight() / 2 ) ) ) ); break; case Gravity::MIDDLE_RIGHT: $point = new Point( $this->getWidth() - $textSize->getWidth() - $padding, \intval( \floor( ( $this->getHeight() / 2 ) - ( $textSize->getHeight() / 2 ) ) ) ); break; case Gravity::TOP_LEFT: $point = new Point( $padding, $padding ); break; case Gravity::TOP_CENTER: $point = new Point( \intval( \floor( ( $this->getWidth() / 2 ) - ( $textSize->getWidth() / 2 ) ) ), $padding ); break; case Gravity::TOP_RIGHT: $point = new Point( $this->getWidth() - $textSize->getWidth() - $padding, $padding ); break; default: #case \GRAVITY_CENTER: $point = new Point( \intval( \floor( ( $this->getWidth() / 2 ) - ( $textSize->getWidth() / 2 ) ) ), \intval( \floor( ( $this->getHeight() / 2 ) - ( $textSize->getHeight() / 2) ) ) ); break; } return $this->drawText( $text, $font, $fontSize, $color, $point, $internal ); }
php
public final function drawTextWithGravity( string $text, $font, $fontSize, $color, int $padding, int $gravity, bool $internal = true ) : IImage { if ( ! empty( $font ) && \file_exists( $font ) ) { return $this->drawText( $text, $font, $fontSize, $color, $this->imageTtfPoint( $fontSize, 0, $font, $text, $gravity, $this->size, $padding ), $internal ); } if ( ! \is_int( $fontSize ) ) { $fontSize = 2; } if ( $fontSize < 1 ) { $fontSize = 1; } else if ( $fontSize > 4 ) { $fontSize = 4; } $textSize = $this->imageMeasureString( $fontSize, $text ); #$textSize->setHeight( $textSize->getHeight() - 2 ); #$textSize->setWidth ( $textSize->getWidth() + 1 ); $point = null; # Get the insertion point by gravity switch ( $gravity ) { case Gravity::BOTTOM_LEFT: $point = new Point( $padding, $this->getHeight() - $textSize->getHeight() - $padding ); break; case Gravity::BOTTOM_CENTER: $point = new Point( \intval( \floor( ( $this->getWidth() / 2 ) - ( $textSize->getWidth() / 2 ) ) ), $this->getHeight() - $textSize->getHeight() - $padding ); break; case Gravity::BOTTOM_RIGHT: $point = new Point( $this->getWidth() - $textSize->getWidth() - $padding, $this->getHeight() - $textSize->getHeight() - $padding ); break; case Gravity::MIDDLE_LEFT: $point = new Point( $padding, \intval( \floor( ( $this->getHeight() / 2 ) - ( $textSize->getHeight() / 2 ) ) ) ); break; case Gravity::MIDDLE_RIGHT: $point = new Point( $this->getWidth() - $textSize->getWidth() - $padding, \intval( \floor( ( $this->getHeight() / 2 ) - ( $textSize->getHeight() / 2 ) ) ) ); break; case Gravity::TOP_LEFT: $point = new Point( $padding, $padding ); break; case Gravity::TOP_CENTER: $point = new Point( \intval( \floor( ( $this->getWidth() / 2 ) - ( $textSize->getWidth() / 2 ) ) ), $padding ); break; case Gravity::TOP_RIGHT: $point = new Point( $this->getWidth() - $textSize->getWidth() - $padding, $padding ); break; default: #case \GRAVITY_CENTER: $point = new Point( \intval( \floor( ( $this->getWidth() / 2 ) - ( $textSize->getWidth() / 2 ) ) ), \intval( \floor( ( $this->getHeight() / 2 ) - ( $textSize->getHeight() / 2) ) ) ); break; } return $this->drawText( $text, $font, $fontSize, $color, $point, $internal ); }
[ "public", "final", "function", "drawTextWithGravity", "(", "string", "$", "text", ",", "$", "font", ",", "$", "fontSize", ",", "$", "color", ",", "int", "$", "padding", ",", "int", "$", "gravity", ",", "bool", "$", "internal", "=", "true", ")", ":", ...
Draws a text by using {@see \Beluga\Drawing\Gravity} into current image. @param string $text The text that should be drawn. @param string $font The font that should be used. For example: For GdImage you can define here the path of the *.ttf font file or NULL. If you define null the parameter $fontSize declares the size + font (1-4). If a path is defined here $fontSize should declare the size in points. @param int $fontSize The size of the font. @param string|array|\Beluga\Drawing\Color|\Beluga\Drawing\ColorGD $color The text color @param int $padding The padding around the text. @param int $gravity The gravity of the text inside the Image. (see {@see \Beluga\Drawing\Gravity}::*) @param bool $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage
[ "Draws", "a", "text", "by", "using", "{", "@see", "\\", "Beluga", "\\", "Drawing", "\\", "Gravity", "}", "into", "current", "image", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L1234-L1332
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.drawTextWithAlign
public final function drawTextWithAlign( string $text, $font, $fontSize, $color, int $padding, ContentAlign $align, bool $internal = true ) : IImage { if ( ! empty( $font ) && \file_exists( $font ) ) { return $this->drawText( $text, $font, $fontSize, $color, $this->imageTtfPoint2( $fontSize, 0, $font, $text, $align, $this->size, $padding ), $internal ); } if ( ! \is_int( $fontSize ) ) { $fontSize = 2; } if ( $fontSize < 1 ) { $fontSize = 1; } else if ( $fontSize > 4 ) { $fontSize = 4; } $textSize = $this->imageMeasureString( $fontSize, $text ); $textSize->setHeight( $textSize->getHeight() - 2 ); $textSize->setWidth ( $textSize->getWidth() + 1 ); $point = null; # <editor-fold desc="Ausrichtung"> switch ( $align->value ) { case ContentAlign::BOTTOM_LEFT: $point = new Point( $padding, $this->getHeight() - $textSize->getHeight() - $padding ); break; case ContentAlign::BOTTOM: $point = new Point( \intval( \floor( ( $this->getWidth() / 2 ) - ( $textSize->getWidth() / 2 ) ) ), $this->getHeight() - $textSize->getHeight() - $padding ); break; case ContentAlign::BOTTOM_RIGHT: $point = new Point( $this->getWidth() - $textSize->getWidth() - $padding, $this->getHeight() - $textSize->getHeight() - $padding ); break; case ContentAlign::MIDDLE_LEFT: $point = new Point( $padding, \intval( \floor( ( $this->getHeight() / 2 ) - ( $textSize->getHeight() / 2 ) ) ) ); break; case ContentAlign::MIDDLE_RIGHT: $point = new Point( $this->getWidth() - $textSize->getWidth() - $padding, \intval( \floor( ( $this->getHeight() / 2 ) - ( $textSize->getHeight() / 2 ) ) ) ); break; case ContentAlign::TOP_LEFT: $point = new Point( $padding, $padding ); break; case ContentAlign::TOP: $point = new Point( \intval( \floor( ( $this->getWidth() / 2 ) - ( $textSize->getWidth() / 2 ) ) ), $padding ); break; case ContentAlign::TOP_RIGHT: $point = new Point( $this->getWidth() - $textSize->getWidth() - $padding, $padding ); break; default: $point = new Point( \intval( \floor( ( $this->getWidth() / 2 ) - ( $textSize->getWidth() / 2 ) ) ), \intval( \floor( ( $this->getHeight() / 2 ) - ( $textSize->getHeight() / 2) ) ) ); break; } // </editor-fold> return $this->drawText( $text, $font, $fontSize, $color, $point, $internal ); }
php
public final function drawTextWithAlign( string $text, $font, $fontSize, $color, int $padding, ContentAlign $align, bool $internal = true ) : IImage { if ( ! empty( $font ) && \file_exists( $font ) ) { return $this->drawText( $text, $font, $fontSize, $color, $this->imageTtfPoint2( $fontSize, 0, $font, $text, $align, $this->size, $padding ), $internal ); } if ( ! \is_int( $fontSize ) ) { $fontSize = 2; } if ( $fontSize < 1 ) { $fontSize = 1; } else if ( $fontSize > 4 ) { $fontSize = 4; } $textSize = $this->imageMeasureString( $fontSize, $text ); $textSize->setHeight( $textSize->getHeight() - 2 ); $textSize->setWidth ( $textSize->getWidth() + 1 ); $point = null; # <editor-fold desc="Ausrichtung"> switch ( $align->value ) { case ContentAlign::BOTTOM_LEFT: $point = new Point( $padding, $this->getHeight() - $textSize->getHeight() - $padding ); break; case ContentAlign::BOTTOM: $point = new Point( \intval( \floor( ( $this->getWidth() / 2 ) - ( $textSize->getWidth() / 2 ) ) ), $this->getHeight() - $textSize->getHeight() - $padding ); break; case ContentAlign::BOTTOM_RIGHT: $point = new Point( $this->getWidth() - $textSize->getWidth() - $padding, $this->getHeight() - $textSize->getHeight() - $padding ); break; case ContentAlign::MIDDLE_LEFT: $point = new Point( $padding, \intval( \floor( ( $this->getHeight() / 2 ) - ( $textSize->getHeight() / 2 ) ) ) ); break; case ContentAlign::MIDDLE_RIGHT: $point = new Point( $this->getWidth() - $textSize->getWidth() - $padding, \intval( \floor( ( $this->getHeight() / 2 ) - ( $textSize->getHeight() / 2 ) ) ) ); break; case ContentAlign::TOP_LEFT: $point = new Point( $padding, $padding ); break; case ContentAlign::TOP: $point = new Point( \intval( \floor( ( $this->getWidth() / 2 ) - ( $textSize->getWidth() / 2 ) ) ), $padding ); break; case ContentAlign::TOP_RIGHT: $point = new Point( $this->getWidth() - $textSize->getWidth() - $padding, $padding ); break; default: $point = new Point( \intval( \floor( ( $this->getWidth() / 2 ) - ( $textSize->getWidth() / 2 ) ) ), \intval( \floor( ( $this->getHeight() / 2 ) - ( $textSize->getHeight() / 2) ) ) ); break; } // </editor-fold> return $this->drawText( $text, $font, $fontSize, $color, $point, $internal ); }
[ "public", "final", "function", "drawTextWithAlign", "(", "string", "$", "text", ",", "$", "font", ",", "$", "fontSize", ",", "$", "color", ",", "int", "$", "padding", ",", "ContentAlign", "$", "align", ",", "bool", "$", "internal", "=", "true", ")", ":...
Draws a text by using a gravity into current image. @param string $text The text that should be drawn. @param string $font The font that should be used. For example: For GdImage you can define here the path of the *.ttf font file or NULL. If you define null the parameter $fontSize declares the size + font (1-4). If a path is defined here $fontSize should declare the size in points. @param int $fontSize The size of the font. @param string|array|\Beluga\Drawing\Color|\Beluga\Drawing\ColorGD $color The text color @param int $padding The padding around the text. @param \Beluga\Drawing\ContentAlign $align @param bool $internal Do not create a new instance? @return \Beluga\Drawing\Image\IImage
[ "Draws", "a", "text", "by", "using", "a", "gravity", "into", "current", "image", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L1481-L1583
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.Create
public static function Create( int $width, int $height, $backColor, string $type = 'image/gif', bool $transparent = false ) : GdImage { $img = \imagecreatetruecolor( $width, $height ); if ( false === ( $rgb = ColorTool::Color2Rgb( $backColor ) ) ) { $rgb = [ 0, 0, 0 ]; } $bgColor = null; $mime = null; switch ( $type ) { case 'image/gif': \imagealphablending( $img, false ); if ( $transparent ) { $bgColor = \imagecolorallocatealpha( $img, $rgb[ 0 ], $rgb[ 1 ], $rgb[ 2 ], 127 ); } else { $bgColor = \imagecolorallocate( $img, $rgb[ 0 ], $rgb[ 1 ], $rgb[ 2 ] ); } \imagefill( $img, 0, 0, $bgColor ); $mime = 'image/gif'; break; case 'image/png': \imagealphablending( $img, false ); if ( $transparent ) { $bgColor = \imagecolorallocatealpha( $img, $rgb[ 0 ], $rgb[ 1 ], $rgb[ 2 ], 127 ); } else { $bgColor = \imagecolorallocate( $img, $rgb[ 0 ], $rgb[ 1 ], $rgb[ 2 ] ); } \imagesavealpha( $img, true ); \imagefill( $img, 0, 0, $bgColor ); $mime = 'image/png'; break; default: $mime = 'image/jpeg'; $bgColor = \imagecolorallocate( $img, $rgb[ 0 ], $rgb[ 1 ], $rgb[ 2 ] ); \imagefill( $img, 0, 0, $bgColor ); break; } $result = new GdImage( $img, new Size( $width, $height ), $mime ); $result->addUserColor( 'background', $bgColor ); return $result; }
php
public static function Create( int $width, int $height, $backColor, string $type = 'image/gif', bool $transparent = false ) : GdImage { $img = \imagecreatetruecolor( $width, $height ); if ( false === ( $rgb = ColorTool::Color2Rgb( $backColor ) ) ) { $rgb = [ 0, 0, 0 ]; } $bgColor = null; $mime = null; switch ( $type ) { case 'image/gif': \imagealphablending( $img, false ); if ( $transparent ) { $bgColor = \imagecolorallocatealpha( $img, $rgb[ 0 ], $rgb[ 1 ], $rgb[ 2 ], 127 ); } else { $bgColor = \imagecolorallocate( $img, $rgb[ 0 ], $rgb[ 1 ], $rgb[ 2 ] ); } \imagefill( $img, 0, 0, $bgColor ); $mime = 'image/gif'; break; case 'image/png': \imagealphablending( $img, false ); if ( $transparent ) { $bgColor = \imagecolorallocatealpha( $img, $rgb[ 0 ], $rgb[ 1 ], $rgb[ 2 ], 127 ); } else { $bgColor = \imagecolorallocate( $img, $rgb[ 0 ], $rgb[ 1 ], $rgb[ 2 ] ); } \imagesavealpha( $img, true ); \imagefill( $img, 0, 0, $bgColor ); $mime = 'image/png'; break; default: $mime = 'image/jpeg'; $bgColor = \imagecolorallocate( $img, $rgb[ 0 ], $rgb[ 1 ], $rgb[ 2 ] ); \imagefill( $img, 0, 0, $bgColor ); break; } $result = new GdImage( $img, new Size( $width, $height ), $mime ); $result->addUserColor( 'background', $bgColor ); return $result; }
[ "public", "static", "function", "Create", "(", "int", "$", "width", ",", "int", "$", "height", ",", "$", "backColor", ",", "string", "$", "type", "=", "'image/gif'", ",", "bool", "$", "transparent", "=", "false", ")", ":", "GdImage", "{", "$", "img", ...
Creates a new image with defined dimension and the background color. If the image is a GIF or PNG image tha background color is set to transparent, if $transparent is (bool) TRUE. @param int $width The image width. @param int $height The image height. @param string|array $backColor The image background color @param string $type The image mime type (default='image/gif') @param bool $transparent Should the GIF or PNG uses a transparent background? @return \Beluga\Drawing\Image\GdImage @throws \Beluga\ArgumentError
[ "Creates", "a", "new", "image", "with", "defined", "dimension", "and", "the", "background", "color", ".", "If", "the", "image", "is", "a", "GIF", "or", "PNG", "image", "tha", "background", "color", "is", "set", "to", "transparent", "if", "$transparent", "i...
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L1897-L1957
SagittariusX/Beluga.Drawing
src/Beluga/Drawing/Image/GdImage.php
GdImage.LoadFile
public static function LoadFile( string $imageFile ) : GdImage { if ( ! \file_exists( $imageFile ) ) { throw new FileNotFoundError( 'Drawing.Image', $imageFile, 'Loading a \Beluga\Drawing\Image\GdImage Resource from this file fails.' ); } $imageInfo = null; try { if ( false === ( $imageInfo = \getimagesize( $imageFile ) ) ) { throw new \Exception( 'Defined imagefile uses a unknown file format!' ); } } catch ( \Throwable $ex ) { throw new FileAccessError( 'Drawing.Image', $imageFile, FileAccessError::ACCESS_READ, $ex->getMessage() ); } $img = null; $mime = null; switch ( $imageInfo[ 'mime' ] ) { case 'image/png': $img = \imagecreatefrompng( $imageFile ); $mime = 'image/png'; break; case 'image/gif': $img = \imagecreatefromgif( $imageFile ); $mime = 'image/gif'; break; default: $img = \imagecreatefromjpeg( $imageFile ); $mime = 'image/jpeg'; break; } return new GdImage( $img, new Size( $imageInfo[ 0 ], $imageInfo[ 1 ] ), $mime, $imageFile ); }
php
public static function LoadFile( string $imageFile ) : GdImage { if ( ! \file_exists( $imageFile ) ) { throw new FileNotFoundError( 'Drawing.Image', $imageFile, 'Loading a \Beluga\Drawing\Image\GdImage Resource from this file fails.' ); } $imageInfo = null; try { if ( false === ( $imageInfo = \getimagesize( $imageFile ) ) ) { throw new \Exception( 'Defined imagefile uses a unknown file format!' ); } } catch ( \Throwable $ex ) { throw new FileAccessError( 'Drawing.Image', $imageFile, FileAccessError::ACCESS_READ, $ex->getMessage() ); } $img = null; $mime = null; switch ( $imageInfo[ 'mime' ] ) { case 'image/png': $img = \imagecreatefrompng( $imageFile ); $mime = 'image/png'; break; case 'image/gif': $img = \imagecreatefromgif( $imageFile ); $mime = 'image/gif'; break; default: $img = \imagecreatefromjpeg( $imageFile ); $mime = 'image/jpeg'; break; } return new GdImage( $img, new Size( $imageInfo[ 0 ], $imageInfo[ 1 ] ), $mime, $imageFile ); }
[ "public", "static", "function", "LoadFile", "(", "string", "$", "imageFile", ")", ":", "GdImage", "{", "if", "(", "!", "\\", "file_exists", "(", "$", "imageFile", ")", ")", "{", "throw", "new", "FileNotFoundError", "(", "'Drawing.Image'", ",", "$", "imageF...
Loads the defined image file to a new {@see \Beluga\Drawing\Image\GdImage} instance. @param string $imageFile @return \Beluga\Drawing\Image\GdImage @throws \Beluga\IO\FileNotFoundError @throws \Beluga\IO\FileAccessError
[ "Loads", "the", "defined", "image", "file", "to", "a", "new", "{", "@see", "\\", "Beluga", "\\", "Drawing", "\\", "Image", "\\", "GdImage", "}", "instance", "." ]
train
https://github.com/SagittariusX/Beluga.Drawing/blob/9c82874cf4ec68cb0af78757b65f19783540004a/src/Beluga/Drawing/Image/GdImage.php#L1967-L2023
net-tools/core
src/Containers/PersistentCache.php
PersistentCache.commit
public function commit() { if ( $this->_initialized && $this->_dirty ) { $this->_saveCache(); $this->_dirty = false; } }
php
public function commit() { if ( $this->_initialized && $this->_dirty ) { $this->_saveCache(); $this->_dirty = false; } }
[ "public", "function", "commit", "(", ")", "{", "if", "(", "$", "this", "->", "_initialized", "&&", "$", "this", "->", "_dirty", ")", "{", "$", "this", "->", "_saveCache", "(", ")", ";", "$", "this", "->", "_dirty", "=", "false", ";", "}", "}" ]
Commit cache content updates to storage
[ "Commit", "cache", "content", "updates", "to", "storage" ]
train
https://github.com/net-tools/core/blob/51446641cee22c0cf53d2b409c76cc8bd1a187e7/src/Containers/PersistentCache.php#L157-L164
k3ssen/BaseAdminBundle
Controller/CrudController.php
CrudController.redirectToRoute
protected function redirectToRoute(string $route, $parameters = [], int $status = 302): RedirectResponse { return $this->redirect($this->generateUrl($route, $parameters), $status); }
php
protected function redirectToRoute(string $route, $parameters = [], int $status = 302): RedirectResponse { return $this->redirect($this->generateUrl($route, $parameters), $status); }
[ "protected", "function", "redirectToRoute", "(", "string", "$", "route", ",", "$", "parameters", "=", "[", "]", ",", "int", "$", "status", "=", "302", ")", ":", "RedirectResponse", "{", "return", "$", "this", "->", "redirect", "(", "$", "this", "->", "...
Returns a RedirectResponse to the given route with the given parameters. Overwrites Controller-trait to allow parameters as object as well.
[ "Returns", "a", "RedirectResponse", "to", "the", "given", "route", "with", "the", "given", "parameters", ".", "Overwrites", "Controller", "-", "trait", "to", "allow", "parameters", "as", "object", "as", "well", "." ]
train
https://github.com/k3ssen/BaseAdminBundle/blob/d0af699b097f48d92883713eafd36ee9069460bb/Controller/CrudController.php#L36-L39
k3ssen/BaseAdminBundle
Controller/CrudController.php
CrudController.isDeletable
protected function isDeletable($object): bool { $em = $this->getEntityManager(); $em->beginTransaction(); try { // if an object is softdeleteable, then set 'deletedAt' first, so that a 'hard-delete' will be attempted. if ($object instanceof SoftDeleteableInterface) { $object->setDeletedAt(new \DateTime()); } $em->remove($object); $em->flush(); $em->rollback(); return true; } catch (ForeignKeyConstraintViolationException $exception) { $em->rollback(); return false; } }
php
protected function isDeletable($object): bool { $em = $this->getEntityManager(); $em->beginTransaction(); try { // if an object is softdeleteable, then set 'deletedAt' first, so that a 'hard-delete' will be attempted. if ($object instanceof SoftDeleteableInterface) { $object->setDeletedAt(new \DateTime()); } $em->remove($object); $em->flush(); $em->rollback(); return true; } catch (ForeignKeyConstraintViolationException $exception) { $em->rollback(); return false; } }
[ "protected", "function", "isDeletable", "(", "$", "object", ")", ":", "bool", "{", "$", "em", "=", "$", "this", "->", "getEntityManager", "(", ")", ";", "$", "em", "->", "beginTransaction", "(", ")", ";", "try", "{", "// if an object is softdeleteable, then ...
Tries to delete an object without actually deleting it. Returns false if ForeignKeyConstraintViolationException would be thrown; true otherwise.
[ "Tries", "to", "delete", "an", "object", "without", "actually", "deleting", "it", ".", "Returns", "false", "if", "ForeignKeyConstraintViolationException", "would", "be", "thrown", ";", "true", "otherwise", "." ]
train
https://github.com/k3ssen/BaseAdminBundle/blob/d0af699b097f48d92883713eafd36ee9069460bb/Controller/CrudController.php#L111-L128
rutger-speksnijder/restphp
src/RestPHP/Configuration.php
Configuration.createFromFile
public function createFromFile($file) { // Check if the file exists if (!$file || !file_exists($file)) { throw new \Exception("Configuration file \"{$file}\" could not be found."); } // Include the file while suppressing warnings // - so we can check if we could include it $config = @include($file); if (!$config) { throw new \Exception("Configuration file \"{$file}\" could not be included."); } // Set the properties $this->useAuthorization = $config['useAuthorization']; $this->authorizationMode = $config['authorizationMode']; $this->redirectAuthorization = $config['redirectAuthorization']; $this->authorizationForm = $config['authorizationForm']; $this->dsn = $config['dsn']; $this->username = $config['username']; $this->password = $config['password']; $this->responseType = $config['responseType']; $this->clientResponseType = $config['clientResponseType']; return $this; }
php
public function createFromFile($file) { // Check if the file exists if (!$file || !file_exists($file)) { throw new \Exception("Configuration file \"{$file}\" could not be found."); } // Include the file while suppressing warnings // - so we can check if we could include it $config = @include($file); if (!$config) { throw new \Exception("Configuration file \"{$file}\" could not be included."); } // Set the properties $this->useAuthorization = $config['useAuthorization']; $this->authorizationMode = $config['authorizationMode']; $this->redirectAuthorization = $config['redirectAuthorization']; $this->authorizationForm = $config['authorizationForm']; $this->dsn = $config['dsn']; $this->username = $config['username']; $this->password = $config['password']; $this->responseType = $config['responseType']; $this->clientResponseType = $config['clientResponseType']; return $this; }
[ "public", "function", "createFromFile", "(", "$", "file", ")", "{", "// Check if the file exists", "if", "(", "!", "$", "file", "||", "!", "file_exists", "(", "$", "file", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Configuration file \\\"{$file}...
Creates a configuration object by loading the parameters from a file. This file has to be a PHP file returning an array with the parameters. @param string $file The path to the file. @throws Exception Throws an exception if the file can't be found. @throws Exception Throws an exception if the file could not be included. @return $this The current object.
[ "Creates", "a", "configuration", "object", "by", "loading", "the", "parameters", "from", "a", "file", ".", "This", "file", "has", "to", "be", "a", "PHP", "file", "returning", "an", "array", "with", "the", "parameters", "." ]
train
https://github.com/rutger-speksnijder/restphp/blob/326a7c0d79b266bbdd8a27ff1c8021caf9d28a3d/src/RestPHP/Configuration.php#L123-L148
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Template.php
Template.get
public function get($name) { if(isset($this->tVar[$name])) return $this->tVar[$name]; else return false; }
php
public function get($name) { if(isset($this->tVar[$name])) return $this->tVar[$name]; else return false; }
[ "public", "function", "get", "(", "$", "name", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "tVar", "[", "$", "name", "]", ")", ")", "return", "$", "this", "->", "tVar", "[", "$", "name", "]", ";", "else", "return", "false", ";", "}" ]
模板变量获取和设置
[ "模板变量获取和设置" ]
train
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Template.php#L55-L60
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Template.php
Template.compiler
protected function compiler($tmplContent) { //模板解析 $tmplContent = $this->parse($tmplContent); // 还原被替换的Literal标签 $tmplContent = preg_replace_callback('/<!--###literal(\d+)###-->/is', array($this, 'restoreLiteral'), $tmplContent); // 添加安全代码 $tmplContent = '<?php if (!defined(\'THINK_PATH\')) exit();?>'.$tmplContent; // 优化生成的php代码 $tmplContent = str_replace('?><?php','',$tmplContent); // 模版编译过滤标签 Hook::listen('template_filter',$tmplContent); return strip_whitespace($tmplContent); }
php
protected function compiler($tmplContent) { //模板解析 $tmplContent = $this->parse($tmplContent); // 还原被替换的Literal标签 $tmplContent = preg_replace_callback('/<!--###literal(\d+)###-->/is', array($this, 'restoreLiteral'), $tmplContent); // 添加安全代码 $tmplContent = '<?php if (!defined(\'THINK_PATH\')) exit();?>'.$tmplContent; // 优化生成的php代码 $tmplContent = str_replace('?><?php','',$tmplContent); // 模版编译过滤标签 Hook::listen('template_filter',$tmplContent); return strip_whitespace($tmplContent); }
[ "protected", "function", "compiler", "(", "$", "tmplContent", ")", "{", "//模板解析", "$", "tmplContent", "=", "$", "this", "->", "parse", "(", "$", "tmplContent", ")", ";", "// 还原被替换的Literal标签", "$", "tmplContent", "=", "preg_replace_callback", "(", "'/<!--###liter...
编译模板文件内容 @access protected @param mixed $tmplContent 模板内容 @return string
[ "编译模板文件内容" ]
train
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Template.php#L124-L136
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Template.php
Template.parse
public function parse($content) { // 内容为空不解析 if(empty($content)) return ''; $begin = $this->config['taglib_begin']; $end = $this->config['taglib_end']; // 检查include语法 $content = $this->parseInclude($content); // 检查PHP语法 $content = $this->parsePhp($content); // 首先替换literal标签内容 $content = preg_replace_callback('/'.$begin.'literal'.$end.'(.*?)'.$begin.'\/literal'.$end.'/is', array($this, 'parseLiteral'),$content); // 获取需要引入的标签库列表 // 标签库只需要定义一次,允许引入多个一次 // 一般放在文件的最前面 // 格式:<taglib name="html,mytag..." /> // 当TAGLIB_LOAD配置为true时才会进行检测 if(C('TAGLIB_LOAD')) { $this->getIncludeTagLib($content); if(!empty($this->tagLib)) { // 对导入的TagLib进行解析 foreach($this->tagLib as $tagLibName) { $this->parseTagLib($tagLibName,$content); } } } // 预先加载的标签库 无需在每个模板中使用taglib标签加载 但必须使用标签库XML前缀 if(C('TAGLIB_PRE_LOAD')) { $tagLibs = explode(',',C('TAGLIB_PRE_LOAD')); foreach ($tagLibs as $tag){ $this->parseTagLib($tag,$content); } } // 内置标签库 无需使用taglib标签导入就可以使用 并且不需使用标签库XML前缀 $tagLibs = explode(',',C('TAGLIB_BUILD_IN')); foreach ($tagLibs as $tag){ $this->parseTagLib($tag,$content,true); } //解析普通模板标签 {$tagName} $content = preg_replace_callback('/('.$this->config['tmpl_begin'].')([^\d\w\s'.$this->config['tmpl_begin'].$this->config['tmpl_end'].'].+?)('.$this->config['tmpl_end'].')/is', array($this, 'parseTag'),$content); return $content; }
php
public function parse($content) { // 内容为空不解析 if(empty($content)) return ''; $begin = $this->config['taglib_begin']; $end = $this->config['taglib_end']; // 检查include语法 $content = $this->parseInclude($content); // 检查PHP语法 $content = $this->parsePhp($content); // 首先替换literal标签内容 $content = preg_replace_callback('/'.$begin.'literal'.$end.'(.*?)'.$begin.'\/literal'.$end.'/is', array($this, 'parseLiteral'),$content); // 获取需要引入的标签库列表 // 标签库只需要定义一次,允许引入多个一次 // 一般放在文件的最前面 // 格式:<taglib name="html,mytag..." /> // 当TAGLIB_LOAD配置为true时才会进行检测 if(C('TAGLIB_LOAD')) { $this->getIncludeTagLib($content); if(!empty($this->tagLib)) { // 对导入的TagLib进行解析 foreach($this->tagLib as $tagLibName) { $this->parseTagLib($tagLibName,$content); } } } // 预先加载的标签库 无需在每个模板中使用taglib标签加载 但必须使用标签库XML前缀 if(C('TAGLIB_PRE_LOAD')) { $tagLibs = explode(',',C('TAGLIB_PRE_LOAD')); foreach ($tagLibs as $tag){ $this->parseTagLib($tag,$content); } } // 内置标签库 无需使用taglib标签导入就可以使用 并且不需使用标签库XML前缀 $tagLibs = explode(',',C('TAGLIB_BUILD_IN')); foreach ($tagLibs as $tag){ $this->parseTagLib($tag,$content,true); } //解析普通模板标签 {$tagName} $content = preg_replace_callback('/('.$this->config['tmpl_begin'].')([^\d\w\s'.$this->config['tmpl_begin'].$this->config['tmpl_end'].'].+?)('.$this->config['tmpl_end'].')/is', array($this, 'parseTag'),$content); return $content; }
[ "public", "function", "parse", "(", "$", "content", ")", "{", "// 内容为空不解析", "if", "(", "empty", "(", "$", "content", ")", ")", "return", "''", ";", "$", "begin", "=", "$", "this", "->", "config", "[", "'taglib_begin'", "]", ";", "$", "end", "=", "$...
模板解析入口 支持普通标签和TagLib解析 支持自定义标签库 @access public @param string $content 要解析的模板内容 @return string
[ "模板解析入口", "支持普通标签和TagLib解析", "支持自定义标签库" ]
train
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Template.php#L145-L186
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Template.php
Template.parseLayout
protected function parseLayout($content) { // 读取模板中的布局标签 $find = preg_match('/'.$this->config['taglib_begin'].'layout\s(.+?)\s*?\/'.$this->config['taglib_end'].'/is',$content,$matches); if($find) { //替换Layout标签 $content = str_replace($matches[0],'',$content); //解析Layout标签 $array = $this->parseXmlAttrs($matches[1]); if(!C('LAYOUT_ON') || C('LAYOUT_NAME') !=$array['name'] ) { // 读取布局模板 $layoutFile = THEME_PATH.$array['name'].$this->config['template_suffix']; $replace = isset($array['replace'])?$array['replace']:$this->config['layout_item']; // 替换布局的主体内容 $content = str_replace($replace,$content,file_get_contents($layoutFile)); } }else{ $content = str_replace('{__NOLAYOUT__}','',$content); } return $content; }
php
protected function parseLayout($content) { // 读取模板中的布局标签 $find = preg_match('/'.$this->config['taglib_begin'].'layout\s(.+?)\s*?\/'.$this->config['taglib_end'].'/is',$content,$matches); if($find) { //替换Layout标签 $content = str_replace($matches[0],'',$content); //解析Layout标签 $array = $this->parseXmlAttrs($matches[1]); if(!C('LAYOUT_ON') || C('LAYOUT_NAME') !=$array['name'] ) { // 读取布局模板 $layoutFile = THEME_PATH.$array['name'].$this->config['template_suffix']; $replace = isset($array['replace'])?$array['replace']:$this->config['layout_item']; // 替换布局的主体内容 $content = str_replace($replace,$content,file_get_contents($layoutFile)); } }else{ $content = str_replace('{__NOLAYOUT__}','',$content); } return $content; }
[ "protected", "function", "parseLayout", "(", "$", "content", ")", "{", "// 读取模板中的布局标签", "$", "find", "=", "preg_match", "(", "'/'", ".", "$", "this", "->", "config", "[", "'taglib_begin'", "]", ".", "'layout\\s(.+?)\\s*?\\/'", ".", "$", "this", "->", "config...
解析模板中的布局标签
[ "解析模板中的布局标签" ]
train
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Template.php#L202-L221
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Template.php
Template.parseInclude
protected function parseInclude($content, $extend = true) { // 解析继承 if($extend) $content = $this->parseExtend($content); // 解析布局 $content = $this->parseLayout($content); // 读取模板中的include标签 $find = preg_match_all('/'.$this->config['taglib_begin'].'include\s(.+?)\s*?\/'.$this->config['taglib_end'].'/is',$content,$matches); if($find) { for($i=0;$i<$find;$i++) { $include = $matches[1][$i]; $array = $this->parseXmlAttrs($include); $file = $array['file']; unset($array['file']); $content = str_replace($matches[0][$i],$this->parseIncludeItem($file,$array,$extend),$content); } } return $content; }
php
protected function parseInclude($content, $extend = true) { // 解析继承 if($extend) $content = $this->parseExtend($content); // 解析布局 $content = $this->parseLayout($content); // 读取模板中的include标签 $find = preg_match_all('/'.$this->config['taglib_begin'].'include\s(.+?)\s*?\/'.$this->config['taglib_end'].'/is',$content,$matches); if($find) { for($i=0;$i<$find;$i++) { $include = $matches[1][$i]; $array = $this->parseXmlAttrs($include); $file = $array['file']; unset($array['file']); $content = str_replace($matches[0][$i],$this->parseIncludeItem($file,$array,$extend),$content); } } return $content; }
[ "protected", "function", "parseInclude", "(", "$", "content", ",", "$", "extend", "=", "true", ")", "{", "// 解析继承", "if", "(", "$", "extend", ")", "$", "content", "=", "$", "this", "->", "parseExtend", "(", "$", "content", ")", ";", "// 解析布局", "$", "...
解析模板中的include标签
[ "解析模板中的include标签" ]
train
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Template.php#L224-L242
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Template.php
Template.parseExtend
protected function parseExtend($content) { $begin = $this->config['taglib_begin']; $end = $this->config['taglib_end']; // 读取模板中的继承标签 $find = preg_match('/'.$begin.'extend\s(.+?)\s*?\/'.$end.'/is',$content,$matches); if($find) { //替换extend标签 $content = str_replace($matches[0],'',$content); // 记录页面中的block标签 preg_replace_callback('/'.$begin.'block\sname=[\'"](.+?)[\'"]\s*?'.$end.'(.*?)'.$begin.'\/block'.$end.'/is', array($this, 'parseBlock'),$content); // 读取继承模板 $array = $this->parseXmlAttrs($matches[1]); $content = $this->parseTemplateName($array['name']); $content = $this->parseInclude($content, false); //对继承模板中的include进行分析 // 替换block标签 $content = $this->replaceBlock($content); }else{ $content = preg_replace_callback('/'.$begin.'block\sname=[\'"](.+?)[\'"]\s*?'.$end.'(.*?)'.$begin.'\/block'.$end.'/is', function($match){return stripslashes($match[2]);}, $content); } return $content; }
php
protected function parseExtend($content) { $begin = $this->config['taglib_begin']; $end = $this->config['taglib_end']; // 读取模板中的继承标签 $find = preg_match('/'.$begin.'extend\s(.+?)\s*?\/'.$end.'/is',$content,$matches); if($find) { //替换extend标签 $content = str_replace($matches[0],'',$content); // 记录页面中的block标签 preg_replace_callback('/'.$begin.'block\sname=[\'"](.+?)[\'"]\s*?'.$end.'(.*?)'.$begin.'\/block'.$end.'/is', array($this, 'parseBlock'),$content); // 读取继承模板 $array = $this->parseXmlAttrs($matches[1]); $content = $this->parseTemplateName($array['name']); $content = $this->parseInclude($content, false); //对继承模板中的include进行分析 // 替换block标签 $content = $this->replaceBlock($content); }else{ $content = preg_replace_callback('/'.$begin.'block\sname=[\'"](.+?)[\'"]\s*?'.$end.'(.*?)'.$begin.'\/block'.$end.'/is', function($match){return stripslashes($match[2]);}, $content); } return $content; }
[ "protected", "function", "parseExtend", "(", "$", "content", ")", "{", "$", "begin", "=", "$", "this", "->", "config", "[", "'taglib_begin'", "]", ";", "$", "end", "=", "$", "this", "->", "config", "[", "'taglib_end'", "]", ";", "// 读取模板中的继承标签", "$", "...
解析模板中的extend标签
[ "解析模板中的extend标签" ]
train
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Template.php#L245-L265
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Template.php
Template.parseXmlAttrs
private function parseXmlAttrs($attrs) { $xml = '<tpl><tag '.$attrs.' /></tpl>'; $xml = simplexml_load_string($xml); if(!$xml) E(L('_XML_TAG_ERROR_')); $xml = (array)($xml->tag->attributes()); $array = array_change_key_case($xml['@attributes']); return $array; }
php
private function parseXmlAttrs($attrs) { $xml = '<tpl><tag '.$attrs.' /></tpl>'; $xml = simplexml_load_string($xml); if(!$xml) E(L('_XML_TAG_ERROR_')); $xml = (array)($xml->tag->attributes()); $array = array_change_key_case($xml['@attributes']); return $array; }
[ "private", "function", "parseXmlAttrs", "(", "$", "attrs", ")", "{", "$", "xml", "=", "'<tpl><tag '", ".", "$", "attrs", ".", "' /></tpl>'", ";", "$", "xml", "=", "simplexml_load_string", "(", "$", "xml", ")", ";", "if", "(", "!", "$", "xml", ")", "E...
分析XML属性 @access private @param string $attrs XML属性字符串 @return array
[ "分析XML属性" ]
train
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Template.php#L273-L281
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Template.php
Template.parseBlock
private function parseBlock($name,$content = '') { if(is_array($name)){ $content = $name[2]; $name = $name[1]; } $this->block[$name] = $content; return ''; }
php
private function parseBlock($name,$content = '') { if(is_array($name)){ $content = $name[2]; $name = $name[1]; } $this->block[$name] = $content; return ''; }
[ "private", "function", "parseBlock", "(", "$", "name", ",", "$", "content", "=", "''", ")", "{", "if", "(", "is_array", "(", "$", "name", ")", ")", "{", "$", "content", "=", "$", "name", "[", "2", "]", ";", "$", "name", "=", "$", "name", "[", ...
记录当前页面中的block标签 @access private @param string $name block名称 @param string $content 模板内容 @return string
[ "记录当前页面中的block标签" ]
train
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Template.php#L321-L328
KDF5000/EasyThink
src/ThinkPHP/Library/Think/Template.php
Template.getIncludeTagLib
public function getIncludeTagLib(& $content) { //搜索是否有TagLib标签 $find = preg_match('/'.$this->config['taglib_begin'].'taglib\s(.+?)(\s*?)\/'.$this->config['taglib_end'].'\W/is',$content,$matches); if($find) { //替换TagLib标签 $content = str_replace($matches[0],'',$content); //解析TagLib标签 $array = $this->parseXmlAttrs($matches[1]); $this->tagLib = explode(',',$array['name']); } return; }
php
public function getIncludeTagLib(& $content) { //搜索是否有TagLib标签 $find = preg_match('/'.$this->config['taglib_begin'].'taglib\s(.+?)(\s*?)\/'.$this->config['taglib_end'].'\W/is',$content,$matches); if($find) { //替换TagLib标签 $content = str_replace($matches[0],'',$content); //解析TagLib标签 $array = $this->parseXmlAttrs($matches[1]); $this->tagLib = explode(',',$array['name']); } return; }
[ "public", "function", "getIncludeTagLib", "(", "&", "$", "content", ")", "{", "//搜索是否有TagLib标签", "$", "find", "=", "preg_match", "(", "'/'", ".", "$", "this", "->", "config", "[", "'taglib_begin'", "]", ".", "'taglib\\s(.+?)(\\s*?)\\/'", ".", "$", "this", "-...
搜索模板页面中包含的TagLib库 并返回列表 @access public @param string $content 模板内容 @return string|false
[ "搜索模板页面中包含的TagLib库", "并返回列表" ]
train
https://github.com/KDF5000/EasyThink/blob/86efc9c8a0d504e01e2fea55868227fdc8928841/src/ThinkPHP/Library/Think/Template.php#L367-L378