Completed
Pull Request — develop (#241)
by ANTHONIUS
07:36
created
module/Solr/src/Solr/Paginator/PaginatorFactoryAbstract.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@
 block discarded – undo
24 24
 
25 25
     /**
26 26
      * @param ServiceLocatorInterface $serviceLocator
27
-     * @return mixed|Paginator
27
+     * @return Paginator
28 28
      */
29 29
     public function createService(ServiceLocatorInterface $serviceLocator)
30 30
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
 use Zend\ServiceManager\MutableCreationOptionsInterface;
16 16
 use Zend\ServiceManager\ServiceLocatorInterface;
17 17
 
18
-abstract class PaginatorFactoryAbstract implements FactoryInterface,MutableCreationOptionsInterface
18
+abstract class PaginatorFactoryAbstract implements FactoryInterface, MutableCreationOptionsInterface
19 19
 {
20 20
     protected $options = [];
21 21
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $connectPath        = $this->getConnectPath();
48 48
         $solrClient         = $serviceLocator->getServiceLocator()->get('Solr/Manager')->getClient($connectPath);
49 49
         $resultConverter    = $serviceLocator->getServiceLocator()->get('Solr/ResultConverter');
50
-        $adapter            = new SolrAdapter($solrClient,$filter,$resultConverter,$this->options);
50
+        $adapter            = new SolrAdapter($solrClient, $filter, $resultConverter, $this->options);
51 51
         $service            = new Paginator($adapter);
52 52
 
53 53
         $this->setCreationOptions([]);
Please login to merge, or discard this patch.
module/Solr/src/Solr/Bridge/ResultConverter.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -42,17 +42,17 @@  discard block
 block discarded – undo
42 42
         $propertiesMap = $filter->getPropertiesMap();
43 43
         $class = $filter->getEntityClass();
44 44
         $entities = [];
45
-        foreach($response['response']['docs'] as $doc){
45
+        foreach ($response['response']['docs'] as $doc) {
46 46
             $ob = new $class();
47 47
             $properties = $doc->getPropertyNames();
48
-            foreach($properties as $name){
48
+            foreach ($properties as $name) {
49 49
                 $setter = 'set'.$name;
50 50
                 $value = $doc->$name;
51 51
                 $value = $this->validateDate($value);
52
-                if(method_exists($ob,$setter)){
53
-                    call_user_func(array($ob,$setter),$value);
54
-                }elseif(isset($propertiesMap[$name])){
55
-                    $this->handleMappedProperty($propertiesMap[$name],$ob,$value);
52
+                if (method_exists($ob, $setter)) {
53
+                    call_user_func(array($ob, $setter), $value);
54
+                }elseif (isset($propertiesMap[$name])) {
55
+                    $this->handleMappedProperty($propertiesMap[$name], $ob, $value);
56 56
                 }
57 57
 
58 58
             }
@@ -69,11 +69,11 @@  discard block
 block discarded – undo
69 69
      * @param $object
70 70
      * @param $value
71 71
      */
72
-    public function handleMappedProperty($property,$object,$value)
72
+    public function handleMappedProperty($property, $object, $value)
73 73
     {
74
-        $callback = array($this->filter,$property);
75
-        if(is_callable($callback)){
76
-            call_user_func($callback,$object,$value);
74
+        $callback = array($this->filter, $property);
75
+        if (is_callable($callback)) {
76
+            call_user_func($callback, $object, $value);
77 77
         }
78 78
     }
79 79
 
@@ -86,11 +86,11 @@  discard block
 block discarded – undo
86 86
     public function validateDate($value)
87 87
     {
88 88
         $value = trim($value);
89
-        $date = \DateTime::createFromFormat(Manager::SOLR_DATE_FORMAT,$value);
89
+        $date = \DateTime::createFromFormat(Manager::SOLR_DATE_FORMAT, $value);
90 90
         $check = $date && ($date->format(Manager::SOLR_DATE_FORMAT) === $value);
91
-        if($check){
91
+        if ($check) {
92 92
             return $date;
93
-        }else{
93
+        } else {
94 94
             return $value;
95 95
         }
96 96
     }
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
                 $value = $this->validateDate($value);
52 52
                 if(method_exists($ob,$setter)){
53 53
                     call_user_func(array($ob,$setter),$value);
54
-                }elseif(isset($propertiesMap[$name])){
54
+                } elseif(isset($propertiesMap[$name])){
55 55
                     $this->handleMappedProperty($propertiesMap[$name],$ob,$value);
56 56
                 }
57 57
 
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         $check = $date && ($date->format(Manager::SOLR_DATE_FORMAT) === $value);
91 91
         if($check){
92 92
             return $date;
93
-        }else{
93
+        } else{
94 94
             return $value;
95 95
         }
96 96
     }
Please login to merge, or discard this patch.
module/Solr/src/Solr/Bridge/Manager.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
         $this->connectOption = $connectOption;
30 30
     }
31 31
 
32
-    public function getClient($path='/solr')
32
+    public function getClient($path = '/solr')
33 33
     {
34 34
         $connectOption = $this->connectOption;
35 35
         $options = [
@@ -48,15 +48,15 @@  discard block
 block discarded – undo
48 48
      * @param \SolrInputDocument $document
49 49
      * @param string $path
50 50
      */
51
-    public function addDocument(\SolrInputDocument $document,$path='/solr')
51
+    public function addDocument(\SolrInputDocument $document, $path = '/solr')
52 52
     {
53 53
         $client = $this->getClient($path);
54
-        try{
54
+        try {
55 55
             $client->addDocument($document);
56 56
             $client->commit();
57 57
             $client->optimize();
58
-        }catch (\Exception $e){
59
-            throw new ServerException('Can not add document to server!',$e->getCode(),$e);
58
+        } catch (\Exception $e) {
59
+            throw new ServerException('Can not add document to server!', $e->getCode(), $e);
60 60
         }
61 61
     }
62 62
     
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
             $client->addDocument($document);
56 56
             $client->commit();
57 57
             $client->optimize();
58
-        }catch (\Exception $e){
58
+        } catch (\Exception $e){
59 59
             throw new ServerException('Can not add document to server!',$e->getCode(),$e);
60 60
         }
61 61
     }
Please login to merge, or discard this patch.
module/Solr/src/Solr/Paginator/Adapter/SolrAdapter.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
      * @param   ResultConverter             $resultConverter
62 62
      * @param   array                       $params
63 63
      */
64
-    public function __construct($client,$filter,$resultConverter,$params=array())
64
+    public function __construct($client, $filter, $resultConverter, $params = array())
65 65
     {
66 66
         $this->client           = $client;
67 67
         $this->filter           = $filter;
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     {
77 77
         return $this->resultConverter->convert(
78 78
             $this->filter,
79
-            $this->getResponse($offset,$itemCountPerPage)
79
+            $this->getResponse($offset, $itemCountPerPage)
80 80
         );
81 81
     }
82 82
 
@@ -99,18 +99,18 @@  discard block
 block discarded – undo
99 99
      * @return  \SolrQueryResponse
100 100
      * @throws  \Exception
101 101
      */
102
-    protected function getResponse($offset=0,$itemCountPerPage=5)
102
+    protected function getResponse($offset = 0, $itemCountPerPage = 5)
103 103
     {
104
-        if(!is_object($this->response)){
104
+        if (!is_object($this->response)) {
105 105
             $query = new \SolrQuery();
106
-            $query = $this->filter->filter($this->params,$query);
106
+            $query = $this->filter->filter($this->params, $query);
107 107
             $query->setStart($offset);
108 108
             $query->setRows($itemCountPerPage);
109
-            try{
109
+            try {
110 110
                 $this->response = $this->client->query($query);
111
-            }catch (\Exception $e){
111
+            } catch (\Exception $e) {
112 112
                 $message = 'Failed to process query';
113
-                throw new ServerException($message,$e->getCode(),$e);
113
+                throw new ServerException($message, $e->getCode(), $e);
114 114
             }
115 115
         }
116 116
         return $this->response;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -108,7 +108,7 @@
 block discarded – undo
108 108
             $query->setRows($itemCountPerPage);
109 109
             try{
110 110
                 $this->response = $this->client->query($query);
111
-            }catch (\Exception $e){
111
+            } catch (\Exception $e){
112 112
                 $message = 'Failed to process query';
113 113
                 throw new ServerException($message,$e->getCode(),$e);
114 114
             }
Please login to merge, or discard this patch.
module/Solr/src/Solr/Filter/JobBoardPaginationQuery.php 2 patches
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -36,27 +36,27 @@  discard block
 block discarded – undo
36 36
      */
37 37
     public function createQuery(array $params, $query)
38 38
     {
39
-        $search = isset($params['search']) ? $params['search']:'';
39
+        $search = isset($params['search']) ? $params['search'] : '';
40 40
 
41
-        if(!empty($search)){
41
+        if (!empty($search)) {
42 42
             $q = 'title:'.$search.' OR organizationName:'.$search;
43
-        }else{
43
+        } else {
44 44
             $q = '*:*';
45 45
         }
46 46
 
47 47
         $query->setQuery($q);
48 48
         
49
-        if(isset($params['sort'])){
49
+        if (isset($params['sort'])) {
50 50
             $sorts = $this->filterSort($params['sort']);
51
-            foreach($sorts as $field=>$order){
52
-                $query->addSortField($field,$order);
51
+            foreach ($sorts as $field=>$order) {
52
+                $query->addSortField($field, $order);
53 53
             }
54 54
         }
55 55
 
56
-        if(isset($params['location'])){
56
+        if (isset($params['location'])) {
57 57
             /* @var Location $location */
58 58
             $location = $params['location'];
59
-            if(!is_null($location->getCoordinates())){
59
+            if (!is_null($location->getCoordinates())) {
60 60
                 $coordinates = $location->getCoordinates()->getCoordinates();
61 61
                 $query->addFilterQuery(sprintf(
62 62
                     "{!geofilt pt=%s sfield=latLon d=%s}",
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
      * @param Job       $ob
83 83
      * @param string    $value
84 84
      */
85
-    public function convertOrganizationName($ob,$value)
85
+    public function convertOrganizationName($ob, $value)
86 86
     {
87
-        if(!is_object($ob->getOrganization())){
87
+        if (!is_object($ob->getOrganization())) {
88 88
             $ob->setOrganization(new Organization());
89 89
         }
90 90
         $orgName = new OrganizationName($value);
@@ -96,12 +96,12 @@  discard block
 block discarded – undo
96 96
      * @param   Job     $ob
97 97
      * @param   mixed   $value
98 98
      */
99
-    public function convertCompanyLogo($ob,$value)
99
+    public function convertCompanyLogo($ob, $value)
100 100
     {
101
-        if(!is_object($ob->getOrganization())){
101
+        if (!is_object($ob->getOrganization())) {
102 102
             $ob->setOrganization(new Organization());
103 103
         }
104
-        $exp    = explode('/',$value);
104
+        $exp    = explode('/', $value);
105 105
         $id     = $exp[3];
106 106
         $name   = $exp[4];
107 107
         $image = new OrganizationImage();
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@
 block discarded – undo
62 62
             if ($this->value['params']['status'] != 'all'){
63 63
                 $queryBuilder->field('status.name')->equals($this->value['params']['status']);
64 64
             }
65
-        }else{
65
+        } else{
66 66
             $queryBuilder->field('status.name')->equals(Status::CREATED);
67 67
         }
68 68
 
Please login to merge, or discard this patch.
module/Solr/src/Solr/Filter/AbstractPaginationQuery.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
         $query = new \SolrQuery();
46 46
         
47
-        return $this->createQuery($value,$query);
47
+        return $this->createQuery($value, $query);
48 48
     }
49 49
 
50 50
     /**
@@ -101,5 +101,5 @@  discard block
 block discarded – undo
101 101
      * @param   \SolrQuery $query
102 102
      * @return  \SolrQuery
103 103
      */
104
-    abstract public function createQuery(array $params,$query);
104
+    abstract public function createQuery(array $params, $query);
105 105
 }
106 106
\ No newline at end of file
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -55,7 +55,7 @@
 block discarded – undo
55 55
     /**
56 56
      * Filter query based on given value
57 57
      *
58
-     * @param mixed $value
58
+     * @param \Zend\Stdlib\Parameters $value
59 59
      * @return \SolrQuery
60 60
      */
61 61
     public function filter($value)
Please login to merge, or discard this patch.
module/Solr/src/Solr/Listener/JobEventSubscriber.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -74,7 +74,7 @@
 block discarded – undo
74 74
 
75 75
     /**
76 76
      * @param ServiceLocatorInterface $serviceLocator
77
-     * @return mixed
77
+     * @return JobEventSubscriber
78 78
      */
79 79
     static public function factory(ServiceLocatorInterface $serviceLocator)
80 80
     {
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -65,9 +65,9 @@  discard block
 block discarded – undo
65 65
         }
66 66
 
67 67
         $solrDoc = $this->generateInputDocument($document, new \SolrInputDocument());
68
-        try{
69
-            $this->solrManager->addDocument($solrDoc,'/solr/YawikJobs');
70
-        }catch (\Exception $e){
68
+        try {
69
+            $this->solrManager->addDocument($solrDoc, '/solr/YawikJobs');
70
+        } catch (\Exception $e) {
71 71
             // @TODO: What to do when the process failed?
72 72
         }
73 73
     }
@@ -84,10 +84,10 @@  discard block
 block discarded – undo
84 84
             return;
85 85
         }
86 86
 
87
-        $solrDoc = $this->generateInputDocument($document,new \SolrInputDocument());
88
-        try{
89
-            $this->solrManager->addDocument($solrDoc,'/solr/YawikJobs');
90
-        }catch (\Exception $e){
87
+        $solrDoc = $this->generateInputDocument($document, new \SolrInputDocument());
88
+        try {
89
+            $this->solrManager->addDocument($solrDoc, '/solr/YawikJobs');
90
+        } catch (\Exception $e) {
91 91
             // @TODO: What to do when the process failed?
92 92
         }
93 93
     }
@@ -111,38 +111,38 @@  discard block
 block discarded – undo
111 111
      */
112 112
     public function generateInputDocument(Job $job, $document)
113 113
     {
114
-        $document->addField('id',$job->getId());
115
-        $document->addField('title',$job->getTitle());
116
-        $document->addField('applicationEmail',$job->getContactEmail());
114
+        $document->addField('id', $job->getId());
115
+        $document->addField('title', $job->getTitle());
116
+        $document->addField('applicationEmail', $job->getContactEmail());
117 117
 
118
-        if($job->getDateCreated()){
118
+        if ($job->getDateCreated()) {
119 119
             $document->addField('dateCreated',
120 120
                 $job->getDateCreated()->setTimezone(new \DateTimeZone('UTC'))->format(Manager::SOLR_DATE_FORMAT)
121 121
             );
122 122
         }
123
-        if($job->getDateModified()){
123
+        if ($job->getDateModified()) {
124 124
             $document->addField('dateModified',
125 125
                 $job->getDateModified()->setTimezone(new \DateTimeZone('UTC'))->format(Manager::SOLR_DATE_FORMAT)
126 126
             );
127 127
         }
128
-        if($job->getDatePublishStart()){
128
+        if ($job->getDatePublishStart()) {
129 129
             $document->addField('datePublishStart',
130 130
                 $job->getDatePublishStart()->setTimezone(new \DateTimeZone('UTC'))->format(Manager::SOLR_DATE_FORMAT)
131 131
             );
132 132
         }
133 133
 
134
-        if($job->getDatePublishEnd()){
134
+        if ($job->getDatePublishEnd()) {
135 135
             $document->addField('datePublishEnd',
136 136
                 $job->getDatePublishEnd()->setTimezone(new \DateTimeZone('UTC'))->format(Manager::SOLR_DATE_FORMAT)
137 137
             );
138 138
         }
139 139
 
140
-        $document->addField('isActive',$job->isActive());
141
-        $document->addField('lang',$job->getLanguage());
140
+        $document->addField('isActive', $job->isActive());
141
+        $document->addField('lang', $job->getLanguage());
142 142
 
143
-        $this->processLocation($job,$document);
144
-        if(!is_null($job->getOrganization())){
145
-            $this->processOrganization($job,$document);
143
+        $this->processLocation($job, $document);
144
+        if (!is_null($job->getOrganization())) {
145
+            $this->processOrganization($job, $document);
146 146
         }
147 147
         return $document;
148 148
     }
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
      * @param Job                   $job
154 154
      * @param \SolrInputDocument    $document
155 155
      */
156
-    public function processOrganization(Job $job,$document)
156
+    public function processOrganization(Job $job, $document)
157 157
     {
158
-        if(!is_null($job->getOrganization()->getImage())){
158
+        if (!is_null($job->getOrganization()->getImage())) {
159 159
             $uri = $job->getOrganization()->getImage()->getUri();
160
-            $document->addField('companyLogo',$uri);
160
+            $document->addField('companyLogo', $uri);
161 161
         }
162
-        $document->addField('organizationName',$job->getOrganization()->getOrganizationName()->getName());
163
-        $document->addField('organizationId',$job->getOrganization()->getId());
162
+        $document->addField('organizationName', $job->getOrganization()->getOrganizationName()->getName());
163
+        $document->addField('organizationId', $job->getOrganization()->getId());
164 164
     }
165 165
 
166 166
     /**
@@ -168,16 +168,16 @@  discard block
 block discarded – undo
168 168
      * @param Job                $job
169 169
      * @param \SolrInputDocument $document
170 170
      */
171
-    public function processLocation(Job $job,$document)
171
+    public function processLocation(Job $job, $document)
172 172
     {
173 173
         /* @var \Jobs\Entity\Location $location */
174
-        foreach($job->getLocations() as $location){
174
+        foreach ($job->getLocations() as $location) {
175 175
             $coord = $location->getCoordinates()->getCoordinates();
176
-            $document->addField('latLon',doubleval($coord[0]).','.doubleval($coord[1]));
177
-            $document->addField('postCode',$location->getPostalCode());
178
-            $document->addField('regionText',$location->getRegion());
176
+            $document->addField('latLon', doubleval($coord[0]).','.doubleval($coord[1]));
177
+            $document->addField('postCode', $location->getPostalCode());
178
+            $document->addField('regionText', $location->getRegion());
179 179
         }
180 180
 
181
-        $document->addField('location',$job->getLocation());
181
+        $document->addField('location', $job->getLocation());
182 182
     }
183 183
 }
184 184
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
         $solrDoc = $this->generateInputDocument($document, new \SolrInputDocument());
53 53
         try{
54 54
             $this->solrManager->addDocument($solrDoc,'/solr/YawikJobs');
55
-        }catch (\Exception $e){
55
+        } catch (\Exception $e){
56 56
             // @TODO: What to do when the process failed?
57 57
         }
58 58
     }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $solrDoc = $this->generateInputDocument($document,new \SolrInputDocument());
68 68
         try{
69 69
             $this->solrManager->addDocument($solrDoc,'/solr/YawikJobs');
70
-        }catch (\Exception $e){
70
+        } catch (\Exception $e){
71 71
             // @TODO: What to do when the process failed?
72 72
         }
73 73
     }
Please login to merge, or discard this patch.
module/Solr/Module.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@
 block discarded – undo
40 40
         return array(
41 41
             'Zend\Loader\StandardAutoloader' => array(
42 42
                 'namespaces' => array(
43
-                    __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
43
+                    __NAMESPACE__ => __DIR__.'/src/'.__NAMESPACE__,
44 44
                 ),
45 45
             ),
46 46
         );
Please login to merge, or discard this patch.
module/Solr/src/Solr/Listener/CreatePaginatorListener.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -31,10 +31,10 @@
 block discarded – undo
31 31
         $paginatorName = $event->getPaginatorName();
32 32
         $paginators = $event->getPaginators();
33 33
         $serviceName = 'Solr/'.$paginatorName;
34
-        if($paginators->has($serviceName)){
34
+        if ($paginators->has($serviceName)) {
35 35
             /* @var \Zend\Paginator\Paginator $paginator */
36 36
             // yes, we have that solr paginator to replace $paginatorName
37
-            $paginator = $paginators->get($serviceName,$params);
37
+            $paginator = $paginators->get($serviceName, $params);
38 38
             $event->setPaginator($paginator);
39 39
         }
40 40
     }
Please login to merge, or discard this patch.