示例#1
0
 /**
  * Convert twip value
  *
  * @param int|float $value
  * @param int|float $default
  * @return int|float
  */
 protected function convertTwip($value, $default = 0)
 {
     $unit = Settings::getMeasurementUnit();
     if ($unit == Settings::UNIT_TWIP || $value == $default) {
         return $value;
     } else {
         return $value * $unit;
     }
 }
示例#2
0
 /**
  * Convert twip value
  *
  * @param int|float $value
  * @param int $default (int|float)
  * @return int|float
  */
 protected function convertTwip($value, $default = 0)
 {
     $factors = array(Settings::UNIT_CM => 567, Settings::UNIT_MM => 56.7, Settings::UNIT_INCH => 1440, Settings::UNIT_POINT => 20, Settings::UNIT_PICA => 240);
     $unit = Settings::getMeasurementUnit();
     $factor = 1;
     if (in_array($unit, $factors) && $value != $default) {
         $factor = $factors[$unit];
     }
     return $value * $factor;
 }
示例#3
0
 /**
  * Test set/get measurement unit
  */
 public function testSetGetMeasurementUnit()
 {
     $this->assertEquals(Settings::UNIT_TWIP, Settings::getMeasurementUnit());
     $this->assertTrue(Settings::setMeasurementUnit(Settings::UNIT_INCH));
     $this->assertFalse(Settings::setMeasurementUnit('foo'));
 }