BackgroundNode.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /*
  3. * This file is part of the Behat Gherkin.
  4. * (c) Konstantin Kudryashov <ever.zet@gmail.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. namespace Behat\Gherkin\Node;
  10. /**
  11. * Represents Gherkin Background.
  12. *
  13. * @author Konstantin Kudryashov <ever.zet@gmail.com>
  14. */
  15. class BackgroundNode implements ScenarioLikeInterface
  16. {
  17. /**
  18. * @var string
  19. */
  20. private $title;
  21. /**
  22. * @var StepNode[]
  23. */
  24. private $steps = array();
  25. /**
  26. * @var string
  27. */
  28. private $keyword;
  29. /**
  30. * @var integer
  31. */
  32. private $line;
  33. /**
  34. * Initializes background.
  35. *
  36. * @param null|string $title
  37. * @param StepNode[] $steps
  38. * @param string $keyword
  39. * @param integer $line
  40. */
  41. public function __construct($title, array $steps, $keyword, $line)
  42. {
  43. $this->title = $title;
  44. $this->steps = $steps;
  45. $this->keyword = $keyword;
  46. $this->line = $line;
  47. }
  48. /**
  49. * Returns node type string
  50. *
  51. * @return string
  52. */
  53. public function getNodeType()
  54. {
  55. return 'Background';
  56. }
  57. /**
  58. * Returns background title.
  59. *
  60. * @return null|string
  61. */
  62. public function getTitle()
  63. {
  64. return $this->title;
  65. }
  66. /**
  67. * Checks if background has steps.
  68. *
  69. * @return Boolean
  70. */
  71. public function hasSteps()
  72. {
  73. return 0 < count($this->steps);
  74. }
  75. /**
  76. * Returns background steps.
  77. *
  78. * @return StepNode[]
  79. */
  80. public function getSteps()
  81. {
  82. return $this->steps;
  83. }
  84. /**
  85. * Returns background keyword.
  86. *
  87. * @return string
  88. */
  89. public function getKeyword()
  90. {
  91. return $this->keyword;
  92. }
  93. /**
  94. * Returns background declaration line number.
  95. *
  96. * @return integer
  97. */
  98. public function getLine()
  99. {
  100. return $this->line;
  101. }
  102. }