Item.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /**
  3. *
  4. * Copyright © Magento, Inc. All rights reserved.
  5. * See COPYING.txt for license details.
  6. */
  7. namespace Magento\Framework\ObjectManager\Profiler\Tree;
  8. class Item
  9. {
  10. /**
  11. * @var string
  12. */
  13. protected $class;
  14. /**
  15. * @var Item|null
  16. */
  17. protected $parent = null;
  18. /**
  19. * @var string
  20. */
  21. protected $hash = null;
  22. /**
  23. * @var array
  24. */
  25. protected $children = [];
  26. /**
  27. * @param string $class
  28. * @param Item $parent
  29. */
  30. public function __construct($class, Item $parent = null)
  31. {
  32. $this->class = $class;
  33. $this->parent = $parent;
  34. if ($parent) {
  35. $parent->addChild($this);
  36. }
  37. }
  38. /**
  39. * Retrieve class
  40. *
  41. * @return string
  42. */
  43. public function getClass()
  44. {
  45. return $this->class;
  46. }
  47. /**
  48. * Add child
  49. *
  50. * @param Item $item
  51. * @return void
  52. */
  53. public function addChild(Item $item)
  54. {
  55. $this->children[] = $item;
  56. }
  57. /**
  58. * Retrieve list of children
  59. *
  60. * @return array[Item]
  61. */
  62. public function getChildren()
  63. {
  64. return $this->children;
  65. }
  66. /**
  67. * Retrieve parent
  68. *
  69. * @return Item|null
  70. */
  71. public function getParent()
  72. {
  73. return $this->parent;
  74. }
  75. /**
  76. * Set hash
  77. *
  78. * @param string $hash
  79. * @return void
  80. */
  81. public function setHash($hash)
  82. {
  83. $this->hash = $hash;
  84. }
  85. /**
  86. * Retrieve hash
  87. *
  88. * @return string
  89. */
  90. public function getHash()
  91. {
  92. return $this->hash;
  93. }
  94. }