Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
DecimalParser
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 setMsgContent
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * @author: Doug Wilbourne (dougwilbourne@gmail.com)
5 */
6declare(strict_types=1);
7
8namespace pvc\parser\numeric;
9
10use NumberFormatter;
11use pvc\interfaces\intl\LocaleInterface;
12use pvc\interfaces\msg\MsgInterface;
13
14/**
15 * Class DecimalParser
16 * @extends NumericParser<float>
17 *
18 * You can set the min and max number of permitted fractional digits in the string to be parsed as well as the
19 * rounding mode for the remaining portion of the input string.
20 *
21 * The underlying NumberFormatter object ensures that the min fractional digits are always less than or equal to the
22 * max fractional digits.
23 */
24class DecimalParser extends NumericParser
25{
26
27    public function __construct(MsgInterface $msg, LocaleInterface $locale)
28    {
29        $frmtr = new NumberFormatter((string)$locale, NumberFormatter::DECIMAL);
30        parent::__construct($msg, $locale, $frmtr);
31        $this->setReturnType(NumberFormatter::TYPE_DOUBLE);
32    }
33
34
35    protected function setMsgContent(MsgInterface $msg): void
36    {
37        $msgId = 'not_decimal';
38        $msgParameters = [];
39        $msg->setContent($this->getMsgDomain(), $msgId, $msgParameters);
40    }
41}