Issues (16)

src/Converters/DecimalIPv4AddressConverter.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Acamposm\IPv4AddressConverter\Converters;
4
5
use Acamposm\IPv4AddressConverter\Enums\IPAddressFormatEnum as IPAddressFormat;
6
use Acamposm\IPv4AddressConverter\Traits\MutableIPv4AddressTrait as MutableIPv4Address;
7
8
class DecimalIPv4AddressConverter extends BaseAddressConverter
9
{
10
    use MutableIPv4Address;
11
12
    /**
13
     * Performs the conversion from the input format to Binary string.
14
     *
15
     * @return int|string
16
     */
17
    public function convert(): int | string
18
    {
19
        return match ($this->inputFormat) {
20
            IPAddressFormat::BINARY      => $this->fromBinaryToDecimal($this->address),
21
            IPAddressFormat::HEXADECIMAL => $this->fromHexadecimalToDecimal($this->address),
22
            IPAddressFormat::LONG        => $this->fromLongToDecimal($this->address),
0 ignored issues
show
It seems like $this->address can also be of type string; however, parameter $address of Acamposm\IPv4AddressConv...er::fromLongToDecimal() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
            IPAddressFormat::LONG        => $this->fromLongToDecimal(/** @scrutinizer ignore-type */ $this->address),
Loading history...
23
            default                      => $this->address,
24
        };
25
    }
26
}
27