예제 #1
0
 public function testUnion()
 {
     $foo = new DeclarationSet();
     $foo->addDeclaration(new Declaration('margin-top', '10px'));
     $foo->addDeclaration(new Declaration('margin-top', '1px'));
     $foo->createDeclaration('margin-bottom', '3px');
     $bar = new DeclarationSet();
     $bar->addDeclaration(new Declaration('margin-left', '4px'));
     $bar->createDeclaration('margin-bottom', '30px');
     $bar->createDeclaration('margin-right', '2px');
     $baz = $foo->union($bar);
     $this->assertEquals('margin-bottom: 3px; margin-left: 4px; margin-right: 2px; margin-top: 1px', strval($baz));
 }
예제 #2
0
 /**
  * Calculates the set union of $this and an $other DeclarationSet.
  * For properties present in both DeclarationSets Declarations from $this
  * DeclarationSet take precedence over those in the $other DeclarationSet.
  *
  * @param DeclarationSet $other
  * @return DeclarationSet  Union of $this and $other
  */
 public function union(DeclarationSet $other)
 {
     $result = new DeclarationSet($other->declarations);
     foreach ($this->declarations as $property => $declaration) {
         $result->addDeclaration($declaration);
     }
     return $result;
 }