1 | <?php |
||
34 | class SimpleNumberConverter implements NumberConverterInterface |
||
35 | { |
||
36 | |||
37 | /** |
||
38 | * The subject configuraiton instance. |
||
39 | * |
||
40 | * @var \TechDivision\Import\Configuration\SubjectConfigurationInterface |
||
41 | */ |
||
42 | private $subjectConfiguration; |
||
43 | |||
44 | /** |
||
45 | * The target number formatter. |
||
46 | * |
||
47 | * @var \NumberFormatter |
||
48 | */ |
||
49 | private $formatter; |
||
50 | |||
51 | /** |
||
52 | * Initialize the number converter instance. |
||
53 | */ |
||
54 | 9 | public function __construct() |
|
58 | |||
59 | /** |
||
60 | * Sets the subject configuration instance. |
||
61 | * |
||
62 | * @param \TechDivision\Import\Configuration\SubjectConfigurationInterface $subjectConfiguration The subject configuration |
||
63 | * |
||
64 | * @return void |
||
65 | */ |
||
66 | public function setSubjectConfiguration(SubjectConfigurationInterface $subjectConfiguration) |
||
70 | |||
71 | /** |
||
72 | * Returns the subject configuration instance. |
||
73 | * |
||
74 | * @return \TechDivision\Import\Configuration\SubjectConfigurationInterface The subject configuration |
||
75 | */ |
||
76 | public function getSubjectConfiguration() |
||
80 | |||
81 | /** |
||
82 | * Returns the number converter configuration instance. |
||
83 | * |
||
84 | * @return \TechDivision\Import\Configuration\Subject\NumberConverterConfigurationInterface The number converter configuration |
||
85 | */ |
||
86 | 2 | protected function getNumberConverterConfiguration() |
|
90 | |||
91 | /** |
||
92 | * Returns the target number formatter instance. |
||
93 | * |
||
94 | * @return \NumberFormatter The target number formatter instance |
||
95 | */ |
||
96 | protected function getFormatter() |
||
100 | |||
101 | /** |
||
102 | * Converts the passed number into a float value. |
||
103 | * |
||
104 | * @param string $number The number to parse |
||
105 | * |
||
106 | * @return float The float value of the number |
||
107 | */ |
||
108 | public function convert($number) |
||
112 | |||
113 | /** |
||
114 | * Parse a string into a number using the current formatter rules. |
||
115 | * |
||
116 | * @param string $value The value to be converted |
||
117 | * @param integer $type The formatting type to use, by default NumberFormatter::TYPE_DOUBLE is used |
||
118 | * @param integer $position The offset in the string at which to begin parsing, on return this value will hold the offset at which parsing ended |
||
119 | * |
||
120 | * @return float The value of the parsed number or FALSE on error |
||
121 | */ |
||
122 | 2 | public function parse($value, $type = \NumberFormatter::TYPE_DOUBLE, &$position = null) |
|
126 | } |
||
127 |