Consider this... I am writing a class named Cache which will accept either a path to a file/url or a string. I am going to use PHP's functions such as parse_url()
and is_file()
to determine which input I am receiving.
here is my example, in PHP
class Cache {
public function __construct($pathUriOrString) {
}
}
What is the best practice for naming this argument? Is this even a valid way of creating an class, or should this be a base class and have separate classes that extend it?
I got this idea from php image where the construct either receives one argument (a path) or 2 arguments (a width and height).
So, am I on the right track, and if so, what is best practice for naming an argument which takes different inputs (and won't confuse another developer down the track?)