示例#1
0
 /**
  * Add a new style, if it doesnt exists yet.
  *
  * @param Style $style
  */
 public function addStyle(Style $style)
 {
     if (null === $style->getId()) {
         $this->register($style->getFont(), $this->fonts);
         $this->register($style->getFill(), $this->fills);
         $this->register($style->getBorder(), $this->borders);
         $this->register($style, $this->styles);
         $style->lock();
     }
 }
示例#2
0
 public function testLock()
 {
     $styler = new Styler();
     $style = new Style();
     $unlockedFont = $style->getFont();
     $unlockedFill = $style->getFill();
     $unlockedBorder = $style->getBorder();
     $styler->addStyle($style);
     $lockedFont = $style->getFont()->setColor('abcdef');
     $this->assertEquals($unlockedFont, $style->getFont());
     $this->assertNotEquals($unlockedFont, $lockedFont);
     $lockedFill = $style->setFillColor('abcdef');
     $this->assertEquals($unlockedFill, $style->getFill());
     $this->assertNotEquals($unlockedFill, $lockedFill);
     $lockedBorder = $style->setSurroundingBorder();
     $this->assertEquals($unlockedBorder, $style->getBorder());
     $this->assertNotEquals($unlockedBorder, $lockedBorder);
 }