/**
  * Return the digest realm
  * 
  * @return string
  * 
  * @throws AuthManagerException
  */
 protected function realm()
 {
     if (is_null($this->realm)) {
         throw new AuthManagerException('No Realm set');
     }
     return $this->realm->get();
 }
예제 #2
0
 /**
  * Render Currency class definition and save to target outDir
  *
  * @param BuilderInterface $builder Builder to be used for rendering
  * @return string Text of class that was built
  */
 public function render(BuilderInterface $builder)
 {
     list($code, $name, $symbol, $displayFormat, $locale, $precision, $value) = array_values($builder->getResult());
     $tpl = file_get_contents(__DIR__ . '/CurrencyClass.tpl');
     $out = str_replace(array('<namespace>', '<name>', '<code>', '<value>', '<symbol>', '<precision>', '<displayFormat>', '<locale>'), array($this->namespace->get(), $name, $code, $value, $symbol, $precision, $displayFormat, $locale), $tpl);
     file_put_contents($this->outDir->get() . "/{$code}.php", $out);
     return $out;
 }
예제 #3
0
 /**
  * Get chart definition as a DOMDocument
  *
  * @return \DOMDocument
  * @throws AccountsException
  */
 public function getDefinition()
 {
     set_error_handler(function ($number, $error) {
         if (preg_match('/^DOMDocument::load\\(\\): (.+)$/', $error, $m) === 1) {
             throw new AccountsException($m[1]);
         }
     });
     $dom = new \DOMDocument();
     $dom->load($this->xmlFileName->get());
     if (!$dom->schemaValidate(__DIR__ . '/definitions/chart-definition.xsd')) {
         throw new AccountsException('Definition does not validate');
     }
     restore_error_handler();
     return $dom;
 }
예제 #4
0
 /**
  * Return currency amount formatted for display
  *
  * @return StringType
  */
 public function display()
 {
     $formatter = new \NumberFormatter($this->locale->get(), \NumberFormatter::CURRENCY);
     $formatter->setSymbol(\NumberFormatter::CURRENCY_SYMBOL, $this->symbol->get());
     $formatter->setAttribute(\NumberFormatter::FRACTION_DIGITS, $this->precision->get());
     return new StringType(sprintf($this->displayFormat, $formatter->format($this->getAsFloat())));
 }
예제 #5
0
 /**
  * Get journal definition as Dom
  *
  * @return \DOMDocument
  * @throws AccountsException
  */
 protected function getDom()
 {
     $dom = new \DOMDocument();
     $dom->load($this->journalPath->get());
     $schemaPath = realpath(__DIR__ . '/../../definitions/journal-definition.xsd');
     libxml_use_internal_errors(true);
     if (!$dom->schemaValidate($schemaPath)) {
         $err = libxml_get_last_error()->message;
         libxml_clear_errors();
         libxml_use_internal_errors(false);
         throw new AccountsException('Definition does not validate: ' . $err);
     }
     libxml_use_internal_errors(false);
     return $dom;
 }
예제 #6
0
 public function testStringTypeProxiesMagicInvokeToGet()
 {
     $t = new StringType('foo');
     $this->assertEquals($t(), $t->get());
 }