darling / php-file-system-paths
定义了用于在PHP中操作文件系统的类。
v1.0.0
2023-12-07 22:50 UTC
Requires
- php: ^8.1
- darling/php-darling-dev-tools: ^1.0
- darling/php-text-types: ^1.1
- darling/php-unit-test-utilities: ^1.0
Requires (Dev)
This package is auto-updated.
Last update: 2024-09-27 04:02:17 UTC
README
PHPFileSystemPaths定义了用于在PHP中处理文件系统路径的类。
\Darling\PHPFileSystemPaths\classes\paths\PathToExistingDirectory
当需要现有目录的路径时,可以使用PathToExisitingDirectory。
可以使用__toString()方法来获取目录的路径。
如果指定的SafeTextCollection可以映射到现有目录,它将被用于构造由__toString()方法返回的路径。
但是,如果指定的SafeTextCollection不能映射到现有目录,则__toString()方法将返回由PHP的sys_get_temp_dir()函数返回的路径。
方法
/**
* Return the SafeTextCollection that defines the parts of this
* PathToExistingDirectory.
*
* @return SafeTextCollection
*
*/
public function safeTextCollection(): SafeTextCollection;
/**
* Return the path to the existing directory.
*
* @return string
*
*/
public function __toString(): string;
\Darling\PHPFileSystemPaths\classes\paths\PathToExistingFile
当需要现有文件的路径时,可以使用PathToExistingFile。
可以使用__toString()方法来获取文件的路径。
如果指定的PathToExistingDirectory和Name可以映射到现有文件,它们将被用于构造由__toString()方法返回的路径。
但是,如果指定的PathToExistingDirectory和Name不能映射到现有文件,则__toString()方法将返回与PHP的sys_get_temp_dir()函数返回的路径匹配的目录中的临时文件的路径。
临时文件名始终为:PHPFileSystemPathsEmptyTmpFile
如果需要,将创建临时文件。
方法
/**
* Return the PathToExisitingDirectory that defines the path where
* the file is expected to be located.
*
* @return PathToExistingDirectory
*
*/
public function pathToExistingDirectory(): PathToExistingDirectory;
/**
* Return the Name of the file.
*
* @return Name
*
*/
public function name(): Name;
/**
* Return the path to the file.
*
* @return string
*
*/
public function __toString(): string;