I currently follow PSR-2 and PSR-4. I'm running into a small dilemma when trying to name a few classes. Here's an example.
I have a base REST client, \Vendor\RestClient\AbstractClient
. I have two implementations of this Abstract Client:
\Vendor\GoogleClient\GoogleClient
\Vendor\GithubClient\GithubClient
Is the naming of the client classes redundant since the namespace already specifies the domain? Should I instead name my classes:
\Vendor\GoogleClient\Client
\Vendor\GithubClient\Client
This would mean client code would always use something like:
use Vendor\GoogleClient\Client;
$client = new Client();
This is a little less verbose than:
use Vendor\GoogleClient\GoogleClient;
$client = new GoogleClient();
But the first option allows us to easily swap out implementations by only changing the use statement.
PSR4 specifies that Interfaces
and AbstractClasses
should be suffixed with Interface
and prefixed with Abstract
respectively, but it says nothing about domain specific prefixes/suffixes. Any opinions/suggestions?