fork download
  1. <?php
  2.  
  3. class EmployeesFactory
  4. {
  5. public static function create(Profession $profession, int $amount, int $rank): array
  6. {
  7. if ($amount < 1) {
  8. throw new InvalidArgumentException();
  9. }
  10.  
  11. $employees = [];
  12.  
  13. for ($count = 0; $count < $amount; $count++) {
  14. $employees[] = new Employee($profession, $rank);
  15. }
  16.  
  17. return $employees;
  18. }
  19. }
  20.  
  21. $company = new Company('ООО Вектор');
  22.  
  23. $manager = ProfessionFactory('Manager');
  24.  
  25. $department1 = new Department('Рекламы');
  26. $department1->addEmployees(EmployessFactory::create($manager, 20, 1));
  27. //...
  28.  
  29. $company->addDepartment($department1);
Runtime error #stdin #stdout #stderr 0s 82560KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
PHP Fatal error:  Uncaught Error: Class 'Company' not found in /home/cjW1gu/prog.php:21
Stack trace:
#0 {main}
  thrown in /home/cjW1gu/prog.php on line 21