Description
This module will support create user with : name, age, location, level, todo. This module is Builder Pattern of PHP
-------- first build -------
Array ( [name] => Steve Lee [age] => 11 [location] => HCM, Viet Nam [level] => Technical Leader [todo] => Array ( [post] => Array ( [update] => 1 [delete] => 1 [create] => 1 [view_all] => 1 ) [page] => Array ( [update] => 1 [delete] => 1 [create] => 1 [view_all] => 1 ) [setting] => Array ( [update] => 1 [create] => 1 ) ) )
-------- next build -------
Array ( [name] => Steve Job [age] => 11 [location] => Silicon valley, US [level] => Technical Leader [todo] => Array ( [post] => Array ( [update] => 1 [delete] => [create] => 1 [view_all] => ) [page] => Array ( [update] => 1 [delete] => [create] => 1 [view_all] => ) [setting] => Array ( [update] => [create] => ) ) )
-------- next build -------
Array ( [name] => Bill gates [age] => 11 [location] => Silicon valley, US [level] => Technical Leader [todo] => Array ( [post] => Array ( [update] => 1 [delete] => [create] => 1 [view_all] => ) [page] => Array ( [update] => 1 [delete] => [create] => 1 [view_all] => ) [setting] => Array ( [update] => [create] => ) ) )
install composer
php composer.phar install
Unit Test
./vendor/bin/phpunit test/UserTest.php
How to use ?
setName('Steve Lee')
->setAge(11)
->setLocation('HCM, Viet Nam')
->setLevel('Technical Leader')
->setTodo('admin');
print_r('
-------- first build -------
'); print_r($admin->build()); print_r('
-------- next build -------
'); $admin->setName('Steve Jobs') ->setLocation('Silicon valley, US') ->setTodo('member'); print_r($admin->build()); print_r('
-------- next build -------
'); $admin->setName('Bill Gates') ->setTodo('member'); print_r($admin->build()); } catch (\Exception $e) { echo "Debug
"; print_r($e); }">
-------- first build -------
'); print_r($admin->build()); print_r('
-------- next build -------
'); $admin->setName('Steve Jobs') ->setLocation('Silicon valley, US') ->setTodo('member'); print_r($admin->build()); print_r('
-------- next build -------
'); $admin->setName('Bill Gates') ->setTodo('member'); print_r($admin->build()); } catch (\Exception $e) { echo "Debug
"; print_r($e); }">
try {
require_once dirname(__FILE__) . '/UserBuilder.php';
$admin = new UserBuilder;
$admin->setName('Steve Lee')
->setAge(11)
->setLocation('HCM, Viet Nam')
->setLevel('Technical Leader')
->setTodo('admin');
print_r('
-------- first build -------
');
print_r($admin->build());
print_r('
-------- next build -------
');
$admin->setName('Steve Jobs')
->setLocation('Silicon valley, US')
->setTodo('member');
print_r($admin->build());
print_r('
-------- next build -------
');
$admin->setName('Bill Gates')
->setTodo('member');
print_r($admin->build());
} catch (\Exception $e) {
echo "Debug
";
print_r($e);
}