[ticket/416] Also use array mapping for string to constant conversion
B3P-416
This commit is contained in:
@@ -11,6 +11,7 @@ namespace board3\portal\portal;
|
|||||||
|
|
||||||
class columns
|
class columns
|
||||||
{
|
{
|
||||||
|
/** @var array Column string to number map */
|
||||||
protected $column_map = array(
|
protected $column_map = array(
|
||||||
'left' => 1,
|
'left' => 1,
|
||||||
'center' => 2,
|
'center' => 2,
|
||||||
@@ -19,6 +20,15 @@ class columns
|
|||||||
'bottom' => 5,
|
'bottom' => 5,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/** @var array Column string to constant map */
|
||||||
|
protected $constant_map = array(
|
||||||
|
'top' => 1,
|
||||||
|
'left' => 2,
|
||||||
|
'center' => 4,
|
||||||
|
'right' => 8,
|
||||||
|
'bottom' => 16,
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert column number to string equivalent
|
* Convert column number to string equivalent
|
||||||
*
|
*
|
||||||
@@ -52,20 +62,6 @@ class columns
|
|||||||
*/
|
*/
|
||||||
public function string_to_constant($column)
|
public function string_to_constant($column)
|
||||||
{
|
{
|
||||||
switch ($column)
|
return (isset($this->constant_map[$column])) ? $this->constant_map[$column] : 0;
|
||||||
{
|
|
||||||
case 'top':
|
|
||||||
return 1;
|
|
||||||
case 'left':
|
|
||||||
return 2;
|
|
||||||
case 'center':
|
|
||||||
return 4;
|
|
||||||
case 'right':
|
|
||||||
return 8;
|
|
||||||
case 'bottom':
|
|
||||||
return 16;
|
|
||||||
default:
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user