M
M
Max Khrichtchatyi2016-08-17 13:53:29
PHP
Max Khrichtchatyi, 2016-08-17 13:53:29

How to correctly connect a library from composer to your global class?

Greetings!
There is a global class for validating various objects, which has a validEmail() method. We have included
a library with awesome validation of email addresses in composer, but I want to somehow standardize and throw new features into an existing method. How to do it right?
pull not

$validator = new EmailValidator();
$multipleValidations = new MultipleValidationWithAnd([
    new RFCValidation(),
    new DNSCheckValidation()
]);
$validator->isValid("[email protected]", $multipleValidations); //true

but more understandable for the whole team
$validator = new Validation();
$validation->isValidEmail("[email protected]");

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2016-08-17
@MrBikus

Implement the "Adapter" pattern. Create a single interface with the isValidEmail method and implement it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question