Exemplo n.º 1
0
 public function toArray()
 {
     $authors = [];
     foreach ($this->authors as $author) {
         $authors[] = $author->toArray();
     }
     $keys = ['name', 'description', 'type', 'license', 'keywords', 'authors', 'autoload', 'require', 'require-dev', 'extra'];
     $arr = array_merge(array_flip($keys), $this->data->toArray());
     $arr['name'] = $this->fullName;
     $arr['description'] = $this->description;
     $arr['type'] = $this->type;
     $arr['license'] = $this->license;
     $arr['keywords'] = $this->keywords->toArray();
     $arr['authors'] = $authors;
     $arr['autoload'] = $this->autoload->toArray();
     $arr['require'] = $this->require->toArray();
     $arr['require-dev'] = $this->requireDev->toArray();
     $arr['extra'] = array_map(function ($v) {
         if (is_object($v) && method_exists($v, 'toArray')) {
             return $v->toArray();
         }
         return $v;
     }, $this->extra->toArray());
     $keeko = $this->keeko->toArray();
     if (count($keeko) > 0) {
         $arr['extra']['keeko'] = $keeko;
     }
     if (count($arr['keywords']) == 0) {
         unset($arr['keywords']);
     }
     if (count($arr['extra']) == 0) {
         unset($arr['extra']);
     }
     return $arr;
 }
Exemplo n.º 2
0
 public function toArray()
 {
     $arr = ['title' => $this->title, 'description' => $this->description, 'class' => $this->class, 'acl' => $this->acl->toArray(), 'responder' => $this->responder->toArray(), 'l10n' => $this->l10n->toArray(), 'scripts' => $this->scripts->toArray(), 'styles' => $this->styles->toArray()];
     $ret = [];
     foreach ($arr as $k => $v) {
         if (!empty($v)) {
             $ret[$k] = $v;
         }
     }
     return $ret;
 }
Exemplo n.º 3
0
 public function toArray()
 {
     $arr = ['title' => $this->title, 'class' => $this->class];
     if ($this->extensionPoints->size() > 0) {
         $arr['extension-points'] = $this->extensionPoints->toArray();
     }
     if ($this->extensions->size() > 0) {
         $extensions = [];
         foreach ($this->extensions->keys() as $key) {
             $extensions[$key] = array_map(function ($v) {
                 if (is_object($v) && method_exists($v, 'toArray')) {
                     return $v->toArray();
                 }
                 return $v;
             }, $this->extensions->get($key)->toArray());
         }
         $arr['extensions'] = $extensions;
     }
     return $arr;
 }
Exemplo n.º 4
0
 public function testEach()
 {
     $result = [];
     $map = new Map(['b' => 'bval', 'a' => 'aval', 'c' => 'cval']);
     $map->each(function ($key, $value) use(&$result) {
         $result[$key] = $value;
     });
     $this->assertEquals($map->toArray(), $result);
 }
Exemplo n.º 5
0
 /**
  * @return Skill[]
  */
 public function getDescendents()
 {
     $descendents = new Map();
     $add = function (Skill $skill) use($descendents) {
         if ($skill->isMultiple() || $skill->isTransition()) {
             return;
         }
         $descendents->set($skill->getId(), $skill);
         $descendents->setAll($skill->getDescendents());
     };
     foreach ($this->getVariations() as $variation) {
         $add($variation);
     }
     foreach ($this->getChildren() as $child) {
         $add($child);
     }
     return $descendents->toArray();
 }