Code Duplication    Length = 15-15 lines in 2 locations

src/IntString.php 2 locations

@@ 42-56 (lines=15) @@
39
    {
40
        unset($this->IntValue, $this->StringValue);
41
42
        if (!(is_integer($intValue) || $intValue === null)) {
43
            $args = [
44
                'position' => '1st',
45
                'expected' => typeof(0).'" or "'.typeof(null),
46
                'actual'   => typeof($intValue),
47
            ];
48
49
            $msg = msg('Invalid argument type.');
50
            $msg .= msg(
51
                ' {position} parameter must to be an instance of "{expected}"; "{actual}" given.',
52
                $args
53
            );
54
55
            throw new InvalidArgumentException($msg);
56
        }
57
58
        if (!typeof($stringValue)->canBeString()) {
59
            $args = [
@@ 58-72 (lines=15) @@
55
            throw new InvalidArgumentException($msg);
56
        }
57
58
        if (!typeof($stringValue)->canBeString()) {
59
            $args = [
60
                'position' => '2nd',
61
                'expected' => typeof('string').'", "'.typeof(null).'" or "any object convertible to string',
62
                'actual'   => typeof($stringValue),
63
            ];
64
65
            $msg = msg('Invalid argument type.');
66
            $msg .= msg(
67
                ' {position} parameter must to be an instance of "{expected}"; "{actual}" given.',
68
                $args
69
            );
70
71
            throw new InvalidArgumentException($msg);
72
        }
73
74
        $this->intValue = (integer) $intValue;
75
        $this->stringValue = (string) $stringValue;