<?php

namespace App\Service\Utils;

class GetIpAddressAndNetmaskFromCIDRService
{
    public function __invoke(string $cidr): array
    {
        list($ip, $prefix) = explode('/', $cidr);

        $mask = long2ip((~(2 ** (32 - $prefix) - 1)) & 0xFFFFFFFF);

        return [
            'ip' => $ip,
            'mask' => $mask
        ];
    }
}