I have a number of classes (and interfaces) which 'code to an interface'
interface File
{
...
}
interface FileConverter {
public function convert(File $file); //coding to an interface
public function success($message);
public function failure($message);
}
I feel I can make the FileConverter interface even more generic by removing the File class type-hint in this interface to allow conversion between strings, arrays etc rather than just classes that implement File;
interface Converter {
public function convert($input);
public function success($message);
public function failure($message);
}
However, if I do this, I feel I loose the 'coding to an interface' aspect - even though none of my classes directly use the FileConverter interface. Is this a wise choice or should I create a different interface? ie;
interface StringConverter {
public function convert(string $string); //PHP 7
public function success($message);
public function failure($message);
}