Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F4793091
Directory.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
Directory.php
View Options
<?php
namespace
Keruald\OmniTools\IO
;
class
Directory
{
///
/// Constructors
///
public
function
__construct
(
private
string
$path
,
)
{}
///
/// Getters and setters
///
public
function
getPath
()
:
string
{
return
$this
->
path
;
}
public
function
setPath
(
string
$path
)
:
self
{
$this
->
path
=
$path
;
return
$this
;
}
///
/// Directory properties methods
///
public
function
exists
()
:
bool
{
return
is_dir
(
$this
->
path
);
}
public
function
isReadable
()
:
bool
{
return
is_readable
(
$this
->
path
);
}
public
function
isWritable
()
:
bool
{
return
is_writable
(
$this
->
path
);
}
/**
* @return array<string, string>
*/
public
function
getPathInfo
()
:
array
{
return
pathinfo
(
$this
->
path
);
}
public
function
getParentDirectory
()
:
string
{
return
pathinfo
(
$this
->
path
,
PATHINFO_DIRNAME
);
}
public
function
getDirectoryName
()
:
string
{
return
pathinfo
(
$this
->
path
,
PATHINFO_BASENAME
);
}
///
/// Search files
///
/**
* Gets files in the directory matching a specific pattern,
* using the PHP glob function.
*
* @return File[]
*/
public
function
glob
(
string
$pattern
)
:
array
{
return
array_map
(
function
(
$file
)
{
return
new
File
(
$file
);
},
glob
(
"$this->path/$pattern"
)
);
}
/**
* @return Directory[]
*/
public
function
getSubdirectories
()
:
array
{
return
array_map
(
function
(
$dir
)
{
return
new
Directory
(
$dir
);
},
glob
(
"$this->path/*"
,
GLOB_ONLYDIR
)
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Fri, Feb 28, 21:39 (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2436617
Default Alt Text
Directory.php (1 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment