Пример #1
0
 public function testAddPart()
 {
     // Arrange
     $badge = new Badge();
     $part = $this->getMockBuilder('PHP\\Badge\\Part')->disableOriginalConstructor()->getMock();
     // Act
     $badge->addPart($part);
     // Assert
     $this->assertCount(1, $badge->getParts());
     $this->assertEquals(array($part), $badge->getParts());
 }
Пример #2
0
 private function renderLabels(Badge $badge)
 {
     $result = '';
     $x = 0;
     $y = 15;
     foreach ($badge->getParts() as $part) {
         $boxWidth = $this->calculateWidth($part);
         $result .= sprintf('<text x="%d" y="%d" fill="%s" font-family="%s" font-size="%d" fill-opacity="%s">%s</text>', $x + $boxWidth / 2, $y, '#010101', $part->getFont()->getName(), $part->getFont()->getSize(), '0.3', $part->getText());
         $result .= sprintf('<text x="%d" y="%d" fill="%s" font-family="%s" font-size="%d">%s</text>', $x + $boxWidth / 2, $y - 1, $part->getForeColor(), $part->getFont()->getName(), $part->getFont()->getSize(), $part->getText());
         $x += $boxWidth;
     }
     return '<g text-anchor="middle">' . $result . '</g>';
 }