Ejemplo n.º 1
0
 /**
  * Build a file package Attribute
  *
  * @param  Application               $app        Application context
  * @param  string                    $name       The name of the attribute, one of the
  *                                               AttributeInterface::NAME_* constants
  * @param  string                    $serialized The serialized value of the attribute
  *                                               (AttributeInterface::asString result)
  * @return AttributeInterface        The attribute
  * @throws \InvalidArgumentException
  */
 public static function getFileAttribute(Application $app, $name, $serialized)
 {
     switch ($name) {
         case AttributeInterface::NAME_METADATA:
             return Metadata::loadFromString($app, $serialized);
             break;
         case AttributeInterface::NAME_STORY:
             return Story::loadFromString($app, $serialized);
             break;
         case AttributeInterface::NAME_METAFIELD:
             return MetaField::loadFromString($app, $serialized);
             break;
         case AttributeInterface::NAME_STATUS:
             return Status::loadFromString($app, $serialized);
             break;
     }
     throw new \InvalidArgumentException(sprintf('Unknown attribute %s', $name));
 }
Ejemplo n.º 2
0
 /**
  * @covers Alchemy\Phrasea\Border\Attribute\Status::loadFromString
  */
 public function testLoadFromString()
 {
     $status = new Status(self::$DI['app'], 12345);
     $this->assertEquals($status, Status::loadFromString(self::$DI['app'], $status->asString()));
 }