基本上我試圖做一個庫來處理文件和目錄。是否有靜態調用對象方法的任何設計模式
的想法是將有單獨的類FileFinding
,FileReading
,FileWriting
等
我試圖尋找是否有任何的設計模式來實現類似:
只是有一次班讓說
<?php namespace vendor/FileHandler;
class FileHandler {}
現在在圖書館裏我有具體的課程讓說
<?php namespace vendor/FileHandler;
class FileFinder
{
/**
* Find files by their types
*
* @param string $path path to find files in.
* @param mixed $type string or array of file type/types (extensions).
* @return array array of file names.
*/
public function findFilesByType($path, $type)
{
// do logic here.
return $files;
}
}
現在,我希望我的圖書館用戶通過使用主類調用FileFinder::findFilesByType()
FileHandler::findFilesByType();
請注意:FileFinder::findFilesByType()
不是靜態方法,但我希望它被用作靜態方法從class FileHanlder
更新: 我上面提到的問題似乎與Laravel的Facade模式相似。但他們的實施超越了我的頭腦。即使我不確定Facade模式是否會做到這一點。
visit -http://php.net/manual/en/language.oop5.static.php – 2015-04-03 10:01:04
另一個 - > http://stackoverflow.com/questions/14382206/php-uses-static-methods-in -object-context – 2015-04-03 10:01:44
@SagarNaliyapara你的鏈接不能回答我的問題。 – 2015-04-03 10:03:28