コード例 #1
0
ファイル: BagContainer.php プロジェクト: zhangxiaoliu/PHPPdf
 public function __construct(array $attributes = array(), $weight = 0)
 {
     $attributeBag = new AttributeBag();
     foreach ($attributes as $name => $value) {
         $attributeBag->add($name, $value);
     }
     $this->attributeBag = $attributeBag;
     $this->weight = (double) $weight;
 }
コード例 #2
0
 /**
  * @test
  */
 public function mergeBags()
 {
     $bags = array();
     $expected = array();
     for ($i = 0; $i < 10; $i++) {
         $bag = new AttributeBag();
         $attributes = array('someName' . $i => $i, 'anotherSomeName' . $i => $i);
         foreach ($attributes as $name => $value) {
             $bag->add($name, $value);
         }
         $bags[] = $bag;
         $expected = array_merge($attributes, $expected);
     }
     $bag = AttributeBag::merge($bags);
     $this->assertEquals($expected, $bag->getAll());
 }