From 8eb502a2bda48d6b557daa2b090588fed287a43a Mon Sep 17 00:00:00 2001
From: Mantas <marc.mantas@gmail.com>
Date: Tue, 12 Jul 2016 09:20:56 +0300
Subject: [PATCH] added getters and setters and parameter trait

---
 src/Query/Span/SpanContainingQuery.php       | 54 +++++++++++++++++---
 tests/Query/Span/SpanContainingQueryTest.php | 10 ++--
 2 files changed, 51 insertions(+), 13 deletions(-)

diff --git a/src/Query/Span/SpanContainingQuery.php b/src/Query/Span/SpanContainingQuery.php
index 233d272..eaf1496 100644
--- a/src/Query/Span/SpanContainingQuery.php
+++ b/src/Query/Span/SpanContainingQuery.php
@@ -11,6 +11,8 @@
 
 namespace ONGR\ElasticsearchDSL\Query\Span;
 
+use ONGR\ElasticsearchDSL\ParametersTrait;
+
 /**
  * Elasticsearch span containing query.
  *
@@ -18,26 +20,60 @@ namespace ONGR\ElasticsearchDSL\Query\Span;
  */
 class SpanContainingQuery implements SpanQueryInterface
 {
+    use ParametersTrait;
+
     /**
      * @param SpanQueryInterface
      */
-    private $big;
+    private $little;
 
     /**
      * @param SpanQueryInterface
      */
-    private $little;
+    private $big;
 
     /**
+     * @param SpanQueryInterface $little
      * @param SpanQueryInterface $big
+     */
+    public function __construct(SpanQueryInterface $little, SpanQueryInterface $big)
+    {
+        $this->setLittle($little);
+        $this->setBig($big);
+    }
+
+    /**
+     * @return SpanQueryInterface
+     */
+    public function getLittle()
+    {
+        return $this->little;
+    }
+
+    /**
      * @param SpanQueryInterface $little
      */
-    public function __construct(SpanQueryInterface $big, SpanQueryInterface $little)
+    public function setLittle(SpanQueryInterface $little)
     {
-        $this->big = $big;
         $this->little = $little;
     }
 
+    /**
+     * @return SpanQueryInterface
+     */
+    public function getBig()
+    {
+        return $this->big;
+    }
+
+    /**
+     * @param SpanQueryInterface $big
+     */
+    public function setBig(SpanQueryInterface $big)
+    {
+        $this->big = $big;
+    }
+
     /**
      * {@inheritdoc}
      */
@@ -51,11 +87,13 @@ class SpanContainingQuery implements SpanQueryInterface
      */
     public function toArray()
     {
-        $out = [
-            'little' => $this->little->toArray(),
-            'big' => $this->big->toArray(),
+        $output = [
+            'little' => $this->getLittle()->toArray(),
+            'big' => $this->getBig()->toArray(),
         ];
 
-        return [$this->getType() => $out];
+        $output = $this->processArray($output);
+
+        return [$this->getType() => $output];
     }
 }
diff --git a/tests/Query/Span/SpanContainingQueryTest.php b/tests/Query/Span/SpanContainingQueryTest.php
index 328ffc3..d3a934b 100644
--- a/tests/Query/Span/SpanContainingQueryTest.php
+++ b/tests/Query/Span/SpanContainingQueryTest.php
@@ -24,16 +24,16 @@ class SpanContainingQueryTest extends \PHPUnit_Framework_TestCase
     public function testToArray()
     {
         $query = new SpanContainingQuery(
-            $this->getSpanQueryMack('foo'),
-            $this->getSpanQueryMack('bar')
+            $this->getSpanQueryMock('foo'),
+            $this->getSpanQueryMock('bar')
         );
         $result = [
             'span_containing' => [
                 'little' => [
-                    'span_term' => ['user' => 'bar'],
+                    'span_term' => ['user' => 'foo'],
                 ],
                 'big' => [
-                    'span_term' => ['user' => 'foo'],
+                    'span_term' => ['user' => 'bar'],
                 ],
             ],
         ];
@@ -45,7 +45,7 @@ class SpanContainingQueryTest extends \PHPUnit_Framework_TestCase
      *
      * @returns \PHPUnit_Framework_MockObject_MockObject
      */
-    private function getSpanQueryMack($value)
+    private function getSpanQueryMock($value)
     {
         $mock = $this->getMock('ONGR\ElasticsearchDSL\Query\Span\SpanQueryInterface');
         $mock
-- 
GitLab