vendredi 3 avril 2015

Is there any Design Pattern for calling object methods statically

Basically I am trying to make a library for handling files and directories.


The idea is there will be separate classes for FileFinding, FileReading, FileWriting etc.


What I am trying to search is there any design pattern to achieve something like :


There is just once class lets say



<?php namespace vendor/FileHandler;

class FileHandler {}


Now in the library I have specific classes let say



<?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;
}
}


Now I want my library users to call the FileFinder::findFilesByType() by using the main class FileHandler::findFilesByType();


Please note: The FileFinder::findFilesByType() is not static method but I want it to be utilized as static method from class FileHanlder


Thanks


Aucun commentaire:

Enregistrer un commentaire