Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F13141727
File.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
File.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Keruald\OmniTools\IO
;
class
File
{
/**
* @var string
*/
private
$path
;
///
/// Constructors
///
public
function
__construct
(
string
$path
=
null
)
{
$this
->
path
=
$path
;
}
public
static
function
from
(
string
$path
)
:
self
{
return
new
self
(
$path
);
}
///
/// Getters and setters
///
public
function
getPath
()
:
string
{
return
$this
->
path
;
}
public
function
setPath
(
string
$path
)
:
self
{
$this
->
path
=
$path
;
return
$this
;
}
///
/// File properties methods
///
public
function
exists
()
:
bool
{
return
file_exists
(
$this
->
path
);
}
public
function
isReadable
()
:
bool
{
return
is_readable
(
$this
->
path
);
}
public
function
getPathInfo
()
:
array
{
return
pathinfo
(
$this
->
path
);
}
public
function
getDirectory
()
:
string
{
return
pathinfo
(
$this
->
path
,
PATHINFO_DIRNAME
);
}
public
function
getFileName
()
:
string
{
return
pathinfo
(
$this
->
path
,
PATHINFO_BASENAME
);
}
public
function
getFileNameWithoutExtension
()
:
string
{
return
pathinfo
(
$this
->
path
,
PATHINFO_FILENAME
);
}
public
function
getExtension
()
:
string
{
return
pathinfo
(
$this
->
path
,
PATHINFO_EXTENSION
);
}
///
/// Include methods
///
public
function
tryInclude
()
:
bool
{
if
(!
$this
->
canBeIncluded
())
{
return
false
;
}
include
(
$this
->
path
);
return
true
;
}
public
function
canBeIncluded
()
:
bool
{
return
$this
->
exists
()
&&
$this
->
isReadable
();
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Nov 21, 16:02 (57 m, 42 s)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3153717
Default Alt Text
File.php (1 KB)
Attached To
Mode
rKOT Keruald OmniTools
Attached
Detach File
Event Timeline
Log In to Comment