- PHP 5.4 or later.
- Composer
After cloning this repository, go to its root folder and run this command:
composer install
Include composer autoloader:
include_once "ginger-payments-php-assignment/vendor/autoload.php";
Then create a new Address Book:
use \GingerPayments\AddressBook;
$addressBook = new AddressBook\AddressBook("My Address Book");
To add a person, you can do this:
$person = $addressBook->addPerson("Lucas", "Araujo");
To add a group, it's as easy as adding a person:
$group = $addressBook->addGroup("Just a test group");
$group->getPersons();
$person->getGroups();
$addressBook->getPersonByName("Lucas");
$addressBook->getPersonByName("", "Araujo");
$addressBook->getPersonByEmail("luksde.ara");
$addressBook->getPersonByEmail("luk");
You should run these commands:
composer install --dev
./vendor/bin/phpunit
- Find person by email address (can supply any substring, ie. "comp" should work assuming "alexander@company.com" is an email address in the address book) - discuss how you would implement this without coding the solution.
I would use PHP's native function strpos(). It searches in a string in a similar way to "LIKE '%STRING%'" in MySQL. It fits perfectly.