fork download
  1. <?php
  2. class Blueprint {
  3. private $blueprintName;
  4. private $blueprintId;
  5. private $components;
  6. private $ME;
  7. private $PE;
  8. private $manufacturingTime;
  9. private $researchingTime;
  10. private $copyingTime;
  11.  
  12.  
  13. public function __construct($bluePrintName, $bpId){
  14.  
  15. $this->blueprintId = $bpId;
  16. $this->blueprintName = $bluePrintName;
  17. $this->components = $this->setBPComponents($this->blueprintId);
  18. echo "Объект создан";
  19.  
  20.  
  21. }
  22.  
  23. public function setBPComponents($bpId){
  24. // Берем компоненты из базы
  25. $components = array('id'=>'count');
  26. return $components;
  27. }
  28.  
  29. static private function setBluePrintId($bluePrintName){
  30. if ($bluePrintName == "test"){
  31. $bpId = 5;
  32. return $bpId;
  33. };
  34.  
  35. }
  36.  
  37.  
  38.  
  39. public static function checBP($blueprintName){
  40. $bpId = self::setBluePrintId($blueprintName);
  41.  
  42. if (isset($bpId)){
  43. $object = new Blueprint($blueprintName, $bpId);
  44. return $object;
  45. } else {
  46. echo "Нет такого БП";
  47. return false;
  48. }
  49. }
  50. }
  51.  
  52. $a = Blueprint::checBP("test");
  53.  
  54.  
  55.  
  56.  
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Объект создан