Skip to content

Commit 9dc0b73

Browse files
committed
add illustration pic and README for facade pattern
1 parent a1e27f3 commit 9dc0b73

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

app/Controller/StructuralController.php

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,9 @@ public function osAdapter()
1414
(new \App\Patterns\Structural\AdapterPattern\OperatingSystems\Application)->render();
1515
}
1616

17-
public function facade()
17+
public function facadeQuickbooks()
1818
{
19-
$facade = new \App\Patterns\Structural\Facade\Quickbooks\QuickbooksFacade('test123');
20-
21-
$response = $facade->createItem(['name' => 'cement', 'costcode' => 'ABE-222']);
22-
23-
if(!$response) {
24-
throw new \Exception('item could not be created');
25-
}
26-
echo "<br/>item has been creatd successfully!";
27-
28-
$item = $facade->showItem(0);
29-
echo "<br/>Item name: {$item['name']} <br/> Costcode: {$item['costcode']}";
30-
31-
$updatdItem = ['name' => 'cement', 'costcode' => 'ABE-223'];
32-
$facade->updateItem(0, $updatdItem);
33-
echo "<br/>Item '0' has been successfully updated<br/>";
34-
35-
$facade->showItem(0);
36-
echo "<br/>Item name: {$updatdItem['name']} <br/> Costcode: {$updatdItem['costcode']}";
37-
38-
$facade->deleteItem(0);
39-
echo "<br/>Item '0' has been successfully deleted<br/>";
19+
(new \App\Patterns\Structural\Facade\Quickbooks\Application)->render();
4020
}
4121

4222
public function bridgeFlights()
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php namespace App\Patterns\Structural\Facade\Quickbooks;
2+
3+
class Application
4+
{
5+
public function render()
6+
{
7+
$facade = new \App\Patterns\Structural\Facade\Quickbooks\QuickbooksFacade('test123');
8+
9+
$response = $facade->createItem(['name' => 'cement', 'costcode' => 'ABE-222']);
10+
11+
if(!$response) {
12+
throw new \Exception('item could not be created');
13+
}
14+
echo "<br/>item has been creatd successfully!";
15+
16+
$item = $facade->showItem(0);
17+
echo "<br/>Item name: {$item['name']} <br/> Costcode: {$item['costcode']}";
18+
19+
$updatdItem = ['name' => 'cement', 'costcode' => 'ABE-223'];
20+
$facade->updateItem(0, $updatdItem);
21+
echo "<br/>Item '0' has been successfully updated<br/>";
22+
23+
$facade->showItem(0);
24+
echo "<br/>Item name: {$updatdItem['name']} <br/> Costcode: {$updatdItem['costcode']}";
25+
26+
$facade->deleteItem(0);
27+
echo "<br/>Item '0' has been successfully deleted<br/>";
28+
}
29+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Quickbooks Facade
2+
![Illustration](./illustration.png)
Loading

bootstraps/routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
// structural routes
1515
['GET', '/human-adapter', ['App\Controller\StructuralController', 'humanAdapter']],
1616
['GET', '/os-adapter', ['App\Controller\StructuralController', 'osAdapter']],
17-
['GET', '/structural/facade', ['App\Controller\StructuralController', 'facade']],
17+
['GET', '/facade-quickbooks', ['App\Controller\StructuralController', 'facadeQuickbooks']],
1818
['GET', '/bridge-flights', ['App\Controller\StructuralController', 'bridgeFlights']],
1919
['GET', '/composite-form', ['App\Controller\StructuralController', 'compositeForm']],
2020
['GET', '/decorator-active-record', ['App\Controller\StructuralController', 'decoratorActiveRecord']],

0 commit comments

Comments
 (0)