forked from jkapuscik2/design-patterns-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo.php
More file actions
29 lines (20 loc) · 718 Bytes
/
demo.php
File metadata and controls
29 lines (20 loc) · 718 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
namespace Structural\Composite;
require(__DIR__ . '/../../vendor/autoload.php');
$company = new Department("Global");
$accounting = new Department("Accounting");
$emmy = new Employee("Emmy", 5000);
$emma = new Employee("Emma", 15000);
$accounting->addDependent($emmy);
$accounting->addDependent($emma);
$it = new Department("IT");
$sara = new Employee("Sara", 10000);
$john = new Employee("John", 5000);
$it->addDependent($sara);
$it->addDependent($john);
$devops = new Department("Devops");
$johny = new Employee("Johny", 15000);
$devops->addDependent($johny);
$company->addDependent($accounting);
$company->addDependent($it);
echo("Total company salaries: \${$company->calculateBudget()}" . PHP_EOL);