arsenalibek/addressbook

There is no license information available for the latest version (dev-master) of this package.

Test lib for Address Book

dev-master 2020-01-18 09:04 UTC

This package is not auto-updated.

Last update: 2025-06-15 20:21:01 UTC


README

This is AddressBook extension

Installation

The preferred way to install the AddressBook extension is through Composer

Documentation and features

config

config/config.php can be use as pre set data for default address book

$config = [
'groups' => [...],
'persons' => [...],
'groupHasPerson' => [...]
];

Can be used few configs for different types of address books

AddressBook have $id and $name fields for scale features

Init AddressBook

require_once './vendor/addressBook/config/config.php';
use vendor\addressBook\AddressBook;
$addressBook = new AddressBook($config);

Add a person to the address book.

$addressBook = new AddressBook(); $personConfig = [
'id' => '1',
'firstName' => 'David A',
'lastName' => 'Johnson',
'addresses' => [
[
'line1' => '5659 Centerville Prospect Rd',
'line2' => '',
'zip' => '43342',
'city' => 'Prospect',
'state' => 'OH',
'countryCode' => 'US'
],
],
'phoneNumbers' => [
'+1(740) 494-2030'
],
'emails' => [
'davidAjohnson@email.fake'
],
];
$person = new Person($personConfig);
$addressBook->addPerson($person);

Add new group to AddressBook

$addressBook = new AddressBook();
$groupConfig = [
'1' => [ 'id' => '1', 'name' => 'Group1' ],
];
$group = new Group($groupConfig);
$addressBook->addGroup($group);

Given a group we want to easily find its members.

$addressBook = new AddressBook($config);
$groupId = '1';
$persons = $addressBook->findPersonsByGroup($groupId);

Given a person we want to easily find the groups the person belongs to.

$addressBook = new AddressBook($config);
$groupId = '1';
$groups = $addressBook->findGroupsByPerson($groupId);

Find person by name (can supply either first name, last name, or both).

$addressBook = new AddressBook($config);
$persons = $addressBook->findPersonByName('John');

Find person by email address

$addressBook = new AddressBook($config);
$persons = $addressBook->findPersonByEmail('john');