Fakoli Framework
NumberTypeRenderer Class Reference
+ Inheritance diagram for NumberTypeRenderer:
+ Collaboration diagram for NumberTypeRenderer:

Public Member Functions

 NumberTypeRenderer ()
 
- Public Member Functions inherited from AbstractTypeRenderer
 AbstractTypeRenderer ()
 

Static Public Member Functions

static format ($value, $template="")
 
- Static Public Member Functions inherited from AbstractTypeRenderer
static format ($value, $template="")
 
static translationDateTemplate ($template, $includeTime=true)
 

Detailed Description

Definition at line 37 of file number_type_renderer.inc.

Member Function Documentation

◆ format()

static NumberTypeRenderer::format (   $value,
  $template = "" 
)
static

Definition at line 43 of file number_type_renderer.inc.

44  {
45  $template = trim($template);
46 
47  if ($value == "" || !is_numeric($value))
48  {
49  $value = "0";
50  }
51 
52  if (startsWith($template, "blankZero"))
53  {
54  if ($value == 0.0)
55  {
56  $text = "";
57  }
58  else if (startsWith($template, "blankZero,"))
59  {
60  $places = substr($template, 10);
61  $text = number_format($value, $places, ".", "");
62  }
63  else
64  {
65  $text = $value;
66  }
67  }
68 
69  else if ($template == "numeric")
70  {
71  $text = number_format($value, 2, ".", "");
72  }
73  else if (startsWith($template, "numeric,"))
74  {
75  $places = substr($template, 8);
76  $text = number_format($value, $places, ".", "");
77  }
78  else if ($template != "" && is_numeric($template))
79  {
80  $text = number_format($value, $template);
81  }
82  else
83  {
84  $text = $value;
85  }
86 
87 
88  return $text;
89  }
startsWith($text, $start)
Tests whether a string starts with a given sub-string.
Definition: functions.inc:1419

◆ NumberTypeRenderer()

NumberTypeRenderer::NumberTypeRenderer ( )

Definition at line 39 of file number_type_renderer.inc.

40  {
41  }

The documentation for this class was generated from the following file: