Example #1
0
File: Day.php Project: geissler/csl
 /**
  * Render a day.
  *
  * @param string|integer $data
  * @return string
  */
 public function render($data)
 {
     // use always numeric value for sorting
     if (Container::getContext()->in('sort') == true) {
         if ($data !== '') {
             $data = (int) $data;
             if ($data < 10) {
                 return '0' . $data;
             }
             return $data;
         }
         return 00;
     }
     switch ($this->form) {
         case 'numeric-leading-zeros':
             if ((int) $data < 10) {
                 return '0' . (int) $data;
             }
             return $this->format($data);
             break;
         case 'ordinal':
             return $this->format(Ordinal::render($data, true));
             break;
         case 'numeric':
         default:
             return $this->format((int) $data);
             break;
     }
 }
Example #2
0
 /**
  * .
  *
  * @param string|array $data
  * @return string|array
  */
 public function render($data)
 {
     $variable = Container::getData()->getVariable($this->variable);
     $isNumeric = new IsNumeric($this->variable);
     if ($isNumeric->validate() == true) {
         $variable = $this->formatDelimiter($variable);
         switch ($this->form) {
             case 'numeric':
                 $return = $variable;
                 break;
             case 'ordinal':
                 $return = Ordinal::render($variable);
                 break;
             case 'long-ordinal':
                 $return = Ordinal::renderLong($variable);
                 break;
             case 'roman':
                 if (preg_match('/[A-z]/', $variable) == 0) {
                     $return = $this->calcRoman($variable);
                 } else {
                     $return = $variable;
                 }
                 break;
         }
         $return = $this->affix->render($return);
         $return = $this->display->render($return);
         $return = $this->formating->render($return);
         return $this->textCase->render($return);
     }
     return $variable;
 }