Match.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Framework\Search\Request\Query;
  7. use Magento\Framework\Search\Request\QueryInterface;
  8. /**
  9. * Match Query
  10. * @api
  11. * @since 100.0.2
  12. */
  13. class Match implements QueryInterface
  14. {
  15. /**
  16. * Name
  17. *
  18. * @var string
  19. */
  20. protected $name;
  21. /**
  22. * Value
  23. *
  24. * @var string
  25. */
  26. protected $value;
  27. /**
  28. * Boost
  29. *
  30. * @var int|null
  31. */
  32. protected $boost;
  33. /**
  34. * Match query array
  35. * Possible structure:
  36. * array(
  37. * ['field' => 'some_field', 'boost' => 'some_boost'],
  38. * ['field' => 'some_field', 'boost' => 'some_boost'],
  39. * )
  40. *
  41. * @var array
  42. */
  43. protected $matches = [];
  44. /**
  45. * @param string $name
  46. * @param string $value
  47. * @param int|null $boost
  48. * @param array $matches
  49. * @codeCoverageIgnore
  50. */
  51. public function __construct($name, $value, $boost, array $matches)
  52. {
  53. $this->name = $name;
  54. $this->value = $value;
  55. $this->boost = $boost;
  56. $this->matches = $matches;
  57. }
  58. /**
  59. * @return string
  60. */
  61. public function getValue()
  62. {
  63. return $this->value;
  64. }
  65. /**
  66. * {@inheritdoc}
  67. * @codeCoverageIgnore
  68. */
  69. public function getType()
  70. {
  71. return QueryInterface::TYPE_MATCH;
  72. }
  73. /**
  74. * {@inheritdoc}
  75. * @codeCoverageIgnore
  76. */
  77. public function getName()
  78. {
  79. return $this->name;
  80. }
  81. /**
  82. * {@inheritdoc}
  83. * @codeCoverageIgnore
  84. */
  85. public function getBoost()
  86. {
  87. return $this->boost;
  88. }
  89. /**
  90. * Get Matches
  91. *
  92. * @return array
  93. * @codeCoverageIgnore
  94. */
  95. public function getMatches()
  96. {
  97. return $this->matches;
  98. }
  99. }