From 2ee9a6d0e711c3dda40197667ae290127c6e9901 Mon Sep 17 00:00:00 2001 From: Steve Lee <55998182+steveleetn91@users.noreply.github.com> Date: Mon, 13 Dec 2021 21:39:03 +0700 Subject: [PATCH 1/4] Create LICENSE.md --- LICENSE.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1 @@ + From 0a71ce794a97f173d0d11e8d5ee6cb2d1221ce64 Mon Sep 17 00:00:00 2001 From: Steve Lee <55998182+steveleetn91@users.noreply.github.com> Date: Mon, 13 Dec 2021 21:41:23 +0700 Subject: [PATCH 2/4] Update LICENSE.md --- LICENSE.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/LICENSE.md b/LICENSE.md index 8b13789..f3a7d1c 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1 +1,9 @@ +Copyright <2021> + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + From 6510dec827fdf0af866e942be02b32b0a96cb54e Mon Sep 17 00:00:00 2001 From: CEO Date: Tue, 14 Dec 2021 10:02:01 +0700 Subject: [PATCH 3/4] Update example code and readme --- README.md | 51 ++++++++++++++++++++++++++++++++------------------- index.php | 31 +++++++++++++++++-------------- 2 files changed, 49 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 44e4dd2..e1a582f 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,14 @@ # Description This module will support create user with : name, age, location, level, todo. This module is Builder Pattern of PHP - - Array ( [name] => Hoang Lee [age] => 29 [location] => HCM, Viet Nam [level] => Technical Leader [todo] => { "post": { "update": true, "delete": true, "create": true, "view_all": true }, "page": { "update": true, "delete": true, "create": true, "view_all": true }, "setting": { "update": true, "create": true } } ) - + + -------- 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 @@ -17,19 +22,27 @@ # How to use ? - `print_r('
-------- First build -------
'); - require_once dirname(__FILE__) . '/UserBuilder.php'; - $admin = $user = new UserBuilder; - $admin->setName('Hoang Lee') - ->setAge(29) - ->setLocation('HCM, Viet Nam') - ->setLevel('Technical Leader') - ->setTodo('admin'); - print_r($admin->build()); - print_r('
-------- Next build -------
'); - $user->setName('Hoang Lee 2') - ->setAge(30) - ->setLocation('HCM, Viet Nam') - ->setLevel('Technical Leader 2') - ->setTodo('member'); - print_r($admin->build());` \ No newline at end of file + 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); + } + diff --git a/index.php b/index.php index ec2f7ec..7f6d6da 100644 --- a/index.php +++ b/index.php @@ -1,21 +1,24 @@ -setName('Hoang Lee') - ->setAge(11) - ->setLocation('HCM, Viet Nam') - ->setLevel('Technical Leader') - ->setTodo('admin'); - print_r($admin->build()); + $admin = new UserBuilder; + $admin->setName('Steve Lee') + ->setAge(11) + ->setLocation('HCM, Viet Nam') + ->setLevel('Technical Leader') + ->setTodo('admin'); print_r('
-------- first build -------
'); - $user->setName('Hoang Lee 2') - ->setAge(30) - ->setLocation('HCM, Viet Nam') - ->setLevel('Technical Leader 2') - ->setTodo('member'); print_r($admin->build()); -}catch(\Exception $e) { + 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); } From 63dd7544a0bace3caa303311dda86b2b05f42c23 Mon Sep 17 00:00:00 2001 From: CEO Date: Tue, 14 Dec 2021 10:04:43 +0700 Subject: [PATCH 4/4] Update readme --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e1a582f..a0bd60d 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,18 @@ # 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