PyStringNode.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 PyString argument.
  12. *
  13. * @author Konstantin Kudryashov <ever.zet@gmail.com>
  14. */
  15. class PyStringNode implements ArgumentInterface
  16. {
  17. /**
  18. * @var array
  19. */
  20. private $strings = array();
  21. /**
  22. * @var integer
  23. */
  24. private $line;
  25. /**
  26. * Initializes PyString.
  27. *
  28. * @param array $strings String in form of [$stringLine]
  29. * @param integer $line Line number where string been started
  30. */
  31. public function __construct(array $strings, $line)
  32. {
  33. $this->strings = $strings;
  34. $this->line = $line;
  35. }
  36. /**
  37. * Returns node type.
  38. *
  39. * @return string
  40. */
  41. public function getNodeType()
  42. {
  43. return 'PyString';
  44. }
  45. /**
  46. * Returns entire PyString lines set.
  47. *
  48. * @return array
  49. */
  50. public function getStrings()
  51. {
  52. return $this->strings;
  53. }
  54. /**
  55. * Returns raw string.
  56. *
  57. * @return string
  58. */
  59. public function getRaw()
  60. {
  61. return implode("\n", $this->strings);
  62. }
  63. /**
  64. * Converts PyString into string.
  65. *
  66. * @return string
  67. */
  68. public function __toString()
  69. {
  70. return $this->getRaw();
  71. }
  72. /**
  73. * Returns line number at which PyString was started.
  74. *
  75. * @return integer
  76. */
  77. public function getLine()
  78. {
  79. return $this->line;
  80. }
  81. }