Update status attribute

This commit is contained in:
Romain Neutron
2012-09-21 15:51:10 +02:00
parent ab8d2fd6b4
commit c79dd8ba6f

View File

@@ -17,7 +17,7 @@ class Status implements AttributeInterface
{
protected $status;
public function __construct($status)
public function __construct(Application $app, $status)
{
/**
* We store a binary string
@@ -29,11 +29,11 @@ class Status implements AttributeInterface
} elseif (ctype_digit($status)) {
$status = decbin((int) $status);
} elseif (strpos($status, '0x') === 0 && ctype_xdigit(substr($status, 2))) {
$status = \databox_status::hex2bin($status);
$status = \databox_status::hex2bin($app, $status);
} elseif (strpos($status, '0b') === 0 && preg_match('/^[01]+$/', substr($status, 2))) {
$status = substr($status, 2);
} elseif (ctype_xdigit($status)) {
$status = \databox_status::hex2bin($status);
$status = \databox_status::hex2bin($app, $status);
} else {
throw new \InvalidArgumentException('Invalid status argument');
}
@@ -58,6 +58,6 @@ class Status implements AttributeInterface
public static function loadFromString(Application $app, $string)
{
return new static($string);
return new static($app, $string);
}
}