Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F11726507
IPv4.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
904 B
Referenced Files
None
Subscribers
None
IPv4.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Keruald\OmniTools\Network
;
use
InvalidArgumentException
;
class
IPv4
extends
IP
{
///
/// Constants
///
const
DOMAIN
=
2
;
// AF_INET
///
/// Properties
///
private
string
$ip
;
///
/// Constructors
///
public
function
__construct
(
string
$ip
)
{
$this
->
ip
=
$ip
;
}
public
static
function
from
(
string
$ip
)
:
self
{
$ipv4
=
new
self
(
$ip
);
if
(!
$ipv4
->
isValid
())
{
throw
new
InvalidArgumentException
(
"Address is not a valid IPv4."
);
}
return
$ipv4
;
}
public
function
isValid
()
:
bool
{
return
IP
::
isIPv4
(
$this
->
ip
);
}
public
function
getDomain
()
:
int
{
return
self
::
DOMAIN
;
// AF_INET
}
///
/// Magic methods
///
public
function
__toString
()
:
string
{
return
$this
->
ip
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Sep 19, 03:44 (1 d, 3 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2992193
Default Alt Text
IPv4.php (904 B)
Attached To
Mode
rKOT Keruald OmniTools
Attached
Detach File
Event Timeline
Log In to Comment