Completed
Push — master ( 7942ad...1c8947 )
by WEBEWEB
01:50
created

DoubleUtility::parseString()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
/**
4
 * This file is part of the core-library package.
5
 *
6
 * (c) 2017 WEBEWEB
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace WBW\Library\Core\Utility\Argument;
13
14
use WBW\Library\Core\Exception\Argument\DoubleArgumentException;
15
use WBW\Library\Core\Exception\Argument\FloatArgumentException;
16
17
/**
18
 * Double utility.
19
 *
20
 * @author webeweb <https://github.com/webeweb/>
21
 * @package WBW\Library\Core\Utility\Argument
22
 * @final
23
 */
24
final class DoubleUtility {
25
26
    /**
27
     * Parse a string.
28
     *
29
     * @param string $value The string value.
30
     * @return double Returns the double represented by the string value.
31
     * @throws DoubleArgumentException Throws a double argument exception if the string value does not represent a double.
32
     */
33
    public static function parseString($value) {
34
        try {
35
            return FloatUtility::parseString($value);
36
        } catch (FloatArgumentException $ex) {
37
            throw new DoubleArgumentException($value, $ex);
38
        }
39
    }
40
41
}
42