V
V
Vladimir P.2017-03-28 18:06:51
PHP
Vladimir P., 2017-03-28 18:06:51

How to properly name and where to store files with interfaces?

I am programming in PHP.
When developing the system, I ran into the question of where to store and how to name files with interfaces.
There are two approaches (with and without "Interface"):

namespace Illuminate\Contracts\Auth\Access;

interface Authorizable
{
    /**
     * Determine if the entity has a given ability.
     *
     * @param  string  $ability
     * @param  array|mixed  $arguments
     * @return bool
     */
    public function can($ability, $arguments = []);
}

and
namespace Symfony\Component\Translation\Dumper;

use Symfony\Component\Translation\MessageCatalogue;

interface DumperInterface
{
    /**
     * Dumps the message catalogue.
     *
     * @param MessageCatalogue $messages The message catalogue
     * @param array            $options  Options that are used by the dumper
     */
    public function dump(MessageCatalogue $messages, $options = array());
}

Advise also on the location of interfaces in the file system: store them next to the implemented class, in a separate "Interfaces" folder, or something else?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
McBernar, 2017-03-28
@McBernar

As you wish. You can put it separately in a folder / folders, since you are unlikely to return to them often - this is not an ordinary class.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question