Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/steveleetn91/php-user-pattern
User Pattern Of PHP
https://github.com/steveleetn91/php-user-pattern
design-patterns hoanglee oops oops-in-php php php7 phpcore phpcore-framework stevelee vietnam
Last synced: about 1 month ago
JSON representation
User Pattern Of PHP
- Host: GitHub
- URL: https://github.com/steveleetn91/php-user-pattern
- Owner: steveleetn91
- License: mit
- Created: 2020-06-26T18:59:28.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-12-14T03:04:53.000Z (about 3 years ago)
- Last Synced: 2024-05-07T18:05:07.855Z (8 months ago)
- Topics: design-patterns, hoanglee, oops, oops-in-php, php, php7, phpcore, phpcore-framework, stevelee, vietnam
- Language: PHP
- Homepage:
- Size: 1.45 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# 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 ?
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);
}