@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param null|array $hostsArray The list of hosts that you have received for the service |
| 33 | 33 | * @param array $options |
| 34 | 34 | */ |
| 35 | - public function __construct($applicationId, $apiKey, $hostsArray = null, $options = []) |
|
| 35 | + public function __construct ($applicationId, $apiKey, $hostsArray = null, $options = []) |
|
| 36 | 36 | { |
| 37 | 37 | $this->applicationId = $applicationId; |
| 38 | 38 | $this->apiKey = $apiKey; |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | /** |
| 44 | 44 | * @return string |
| 45 | 45 | */ |
| 46 | - public function getApplicationId() |
|
| 46 | + public function getApplicationId () |
|
| 47 | 47 | { |
| 48 | 48 | return $this->applicationId; |
| 49 | 49 | } |
@@ -51,7 +51,7 @@ discard block |
||
| 51 | 51 | /** |
| 52 | 52 | * @return string |
| 53 | 53 | */ |
| 54 | - public function getApiKey() |
|
| 54 | + public function getApiKey () |
|
| 55 | 55 | { |
| 56 | 56 | return $this->apiKey; |
| 57 | 57 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | /** |
| 60 | 60 | * @return array|null |
| 61 | 61 | */ |
| 62 | - public function getHostsArray() |
|
| 62 | + public function getHostsArray () |
|
| 63 | 63 | { |
| 64 | 64 | return $this->hostsArray; |
| 65 | 65 | } |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | /** |
| 68 | 68 | * @return array |
| 69 | 69 | */ |
| 70 | - public function getOptions() |
|
| 70 | + public function getOptions () |
|
| 71 | 71 | { |
| 72 | 72 | return $this->options; |
| 73 | 73 | } |
@@ -9,19 +9,19 @@ |
||
| 9 | 9 | * |
| 10 | 10 | * @return array |
| 11 | 11 | */ |
| 12 | - public function getIndices(); |
|
| 12 | + public function getIndices (); |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * Returns the model in an Algolia friendly array form. |
| 16 | 16 | * |
| 17 | 17 | * @return array |
| 18 | 18 | */ |
| 19 | - public function getAlgoliaRecord(); |
|
| 19 | + public function getAlgoliaRecord (); |
|
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * Returns an unique identifier for the Model. |
| 23 | 23 | * |
| 24 | 24 | * @return int |
| 25 | 25 | */ |
| 26 | - public function getObjectID(); |
|
| 26 | + public function getObjectID (); |
|
| 27 | 27 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | * |
| 16 | 16 | * @return array |
| 17 | 17 | */ |
| 18 | - public function chunk(ActiveQueryInterface $query, $size, callable $callback) |
|
| 18 | + public function chunk (ActiveQueryInterface $query, $size, callable $callback) |
|
| 19 | 19 | { |
| 20 | 20 | $pageNumber = 1; |
| 21 | 21 | $records = $this->paginateRecords($query, $pageNumber, $size)->all(); |
@@ -53,7 +53,7 @@ discard block |
||
| 53 | 53 | * |
| 54 | 54 | * @return ActiveQueryInterface |
| 55 | 55 | */ |
| 56 | - private function paginateRecords(ActiveQueryInterface $query, $pageNumber, $count) |
|
| 56 | + private function paginateRecords (ActiveQueryInterface $query, $pageNumber, $count) |
|
| 57 | 57 | { |
| 58 | 58 | $offset = ($pageNumber - 1) * $count; |
| 59 | 59 | $limit = $count; |
@@ -13,9 +13,9 @@ |
||
| 13 | 13 | * |
| 14 | 14 | * @return ActiveRecordInterface |
| 15 | 15 | */ |
| 16 | - public function make($className) |
|
| 16 | + public function make ($className) |
|
| 17 | 17 | { |
| 18 | - if (! (new \ReflectionClass($className))->implementsInterface(ActiveRecordInterface::class)) { |
|
| 18 | + if ( ! (new \ReflectionClass($className))->implementsInterface(ActiveRecordInterface::class)) { |
|
| 19 | 19 | throw new \InvalidArgumentException("Cannot initiate a class ({$className}) which doesn't implement \\yii\\db\\ActiveRecordInterface"); |
| 20 | 20 | } |
| 21 | 21 | |
@@ -34,7 +34,7 @@ |
||
| 34 | 34 | /** |
| 35 | 35 | * {@inheritdoc} |
| 36 | 36 | */ |
| 37 | - public function events() |
|
| 37 | + public function events () |
|
| 38 | 38 | { |
| 39 | 39 | return [ |
| 40 | 40 | ActiveRecord::EVENT_AFTER_INSERT => function (Event $event) { |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | * |
| 14 | 14 | * @return Client |
| 15 | 15 | */ |
| 16 | - public function make(AlgoliaConfig $config) |
|
| 16 | + public function make (AlgoliaConfig $config) |
|
| 17 | 17 | { |
| 18 | 18 | return new Client( |
| 19 | 19 | $config->getApplicationId(), |
@@ -30,9 +30,9 @@ discard block |
||
| 30 | 30 | * |
| 31 | 31 | * @return SearchableInterface |
| 32 | 32 | */ |
| 33 | - public function makeSearchableObject($className) |
|
| 33 | + public function makeSearchableObject ($className) |
|
| 34 | 34 | { |
| 35 | - if (! (new \ReflectionClass($className))->implementsInterface(SearchableInterface::class)) { |
|
| 35 | + if ( ! (new \ReflectionClass($className))->implementsInterface(SearchableInterface::class)) { |
|
| 36 | 36 | throw new \InvalidArgumentException("Cannot initiate a class ({$className}) which doesn't implement leinonen\\Yii2Algolia\\SearchableInterface"); |
| 37 | 37 | } |
| 38 | 38 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | * @param ActiveQueryChunker $activeQueryChunker |
| 102 | 102 | * @param array $config |
| 103 | 103 | */ |
| 104 | - public function __construct( |
|
| 104 | + public function __construct ( |
|
| 105 | 105 | AlgoliaFactory $algoliaFactory, |
| 106 | 106 | ActiveRecordFactory $activeRecordFactory, |
| 107 | 107 | ActiveQueryChunker $activeQueryChunker, |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | * |
| 120 | 120 | * @param Application $app the application currently running |
| 121 | 121 | */ |
| 122 | - public function bootstrap($app) |
|
| 122 | + public function bootstrap ($app) |
|
| 123 | 123 | { |
| 124 | 124 | Yii::$container->set(AlgoliaManager::class, function () { |
| 125 | 125 | return $this->createManager(); |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | /** |
| 130 | 130 | * {@inheritdoc} |
| 131 | 131 | */ |
| 132 | - public function init() |
|
| 132 | + public function init () |
|
| 133 | 133 | { |
| 134 | 134 | $this->manager = $this->createManager(); |
| 135 | 135 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @return AlgoliaManager |
| 141 | 141 | */ |
| 142 | - protected function createManager() |
|
| 142 | + protected function createManager () |
|
| 143 | 143 | { |
| 144 | 144 | $config = $this->generateConfig(); |
| 145 | 145 | $client = $this->algoliaFactory->make($config); |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * |
| 159 | 159 | * @return mixed |
| 160 | 160 | */ |
| 161 | - public function __call($method, $parameters) |
|
| 161 | + public function __call ($method, $parameters) |
|
| 162 | 162 | { |
| 163 | 163 | return call_user_func_array([$this->manager, $method], $parameters); |
| 164 | 164 | } |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * @return AlgoliaConfig |
| 170 | 170 | * @throws \Exception |
| 171 | 171 | */ |
| 172 | - private function generateConfig() |
|
| 172 | + private function generateConfig () |
|
| 173 | 173 | { |
| 174 | 174 | if (empty($this->applicationId) || empty($this->apiKey)) { |
| 175 | 175 | throw new \Exception('applicationId and apiKey are required'); |
@@ -17,14 +17,14 @@ discard block |
||
| 17 | 17 | * @param array $expand |
| 18 | 18 | * @param bool $recursive |
| 19 | 19 | */ |
| 20 | - abstract public function toArray(array $fields = [], array $expand = [], $recursive = true); |
|
| 20 | + abstract public function toArray (array $fields = [], array $expand = [], $recursive = true); |
|
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * @see \yii\db\BaseActiveRecord::getPrimaryKey() |
| 24 | 24 | * |
| 25 | 25 | * @param bool $asArray |
| 26 | 26 | */ |
| 27 | - abstract public function getPrimaryKey($asArray = false); |
|
| 27 | + abstract public function getPrimaryKey ($asArray = false); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * An array of indices that this model uses. If none specified |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * |
| 33 | 33 | * @return array |
| 34 | 34 | */ |
| 35 | - public function indices() |
|
| 35 | + public function indices () |
|
| 36 | 36 | { |
| 37 | 37 | return []; |
| 38 | 38 | } |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | * |
| 43 | 43 | * @return array |
| 44 | 44 | */ |
| 45 | - public function getIndices() |
|
| 45 | + public function getIndices () |
|
| 46 | 46 | { |
| 47 | 47 | $indices = $this->indices(); |
| 48 | 48 | |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * |
| 61 | 61 | * @return array |
| 62 | 62 | */ |
| 63 | - public function getAlgoliaRecord() |
|
| 63 | + public function getAlgoliaRecord () |
|
| 64 | 64 | { |
| 65 | 65 | $record = $this->toArray(); |
| 66 | 66 | |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | * |
| 73 | 73 | * @return int |
| 74 | 74 | */ |
| 75 | - public function getObjectID() |
|
| 75 | + public function getObjectID () |
|
| 76 | 76 | { |
| 77 | 77 | return $this->getPrimaryKey(); |
| 78 | 78 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * |
| 83 | 83 | * @return array |
| 84 | 84 | */ |
| 85 | - public function index() |
|
| 85 | + public function index () |
|
| 86 | 86 | { |
| 87 | 87 | $manager = $this->getAlgoliaManager(); |
| 88 | 88 | |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * |
| 95 | 95 | * @return array |
| 96 | 96 | */ |
| 97 | - public function removeFromIndices() |
|
| 97 | + public function removeFromIndices () |
|
| 98 | 98 | { |
| 99 | 99 | $manager = $this->getAlgoliaManager(); |
| 100 | 100 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | * |
| 107 | 107 | * @return array |
| 108 | 108 | */ |
| 109 | - public function updateInIndices() |
|
| 109 | + public function updateInIndices () |
|
| 110 | 110 | { |
| 111 | 111 | $manager = $this->getAlgoliaManager(); |
| 112 | 112 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * |
| 119 | 119 | * @return array |
| 120 | 120 | */ |
| 121 | - public static function reindex() |
|
| 121 | + public static function reindex () |
|
| 122 | 122 | { |
| 123 | 123 | $manager = static::getAlgoliaManager(); |
| 124 | 124 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * |
| 131 | 131 | * @return array |
| 132 | 132 | */ |
| 133 | - public static function clearIndices() |
|
| 133 | + public static function clearIndices () |
|
| 134 | 134 | { |
| 135 | 135 | $manager = static::getAlgoliaManager(); |
| 136 | 136 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * |
| 146 | 146 | * @return array |
| 147 | 147 | */ |
| 148 | - public static function search($query, array $searchParameters = null) |
|
| 148 | + public static function search ($query, array $searchParameters = null) |
|
| 149 | 149 | { |
| 150 | 150 | $manager = static::getAlgoliaManager(); |
| 151 | 151 | |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @return AlgoliaManager |
| 159 | 159 | * @throws \yii\base\InvalidConfigException |
| 160 | 160 | */ |
| 161 | - private static function getAlgoliaManager() |
|
| 161 | + private static function getAlgoliaManager () |
|
| 162 | 162 | { |
| 163 | 163 | return Yii::$container->get(AlgoliaManager::class); |
| 164 | 164 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * @param ActiveRecordFactory $activeRecordFactory |
| 81 | 81 | * @param ActiveQueryChunker $activeQueryChunker |
| 82 | 82 | */ |
| 83 | - public function __construct( |
|
| 83 | + public function __construct ( |
|
| 84 | 84 | Client $client, |
| 85 | 85 | ActiveRecordFactory $activeRecordFactory, |
| 86 | 86 | ActiveQueryChunker $activeQueryChunker |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | * |
| 96 | 96 | * @return Client |
| 97 | 97 | */ |
| 98 | - public function getClient() |
|
| 98 | + public function getClient () |
|
| 99 | 99 | { |
| 100 | 100 | return $this->client; |
| 101 | 101 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * |
| 106 | 106 | * @param string $env |
| 107 | 107 | */ |
| 108 | - public function setEnv($env) |
|
| 108 | + public function setEnv ($env) |
|
| 109 | 109 | { |
| 110 | 110 | $this->env = $env; |
| 111 | 111 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * |
| 116 | 116 | * @return null|string |
| 117 | 117 | */ |
| 118 | - public function getEnv() |
|
| 118 | + public function getEnv () |
|
| 119 | 119 | { |
| 120 | 120 | return $this->env; |
| 121 | 121 | } |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | * |
| 128 | 128 | * @return array |
| 129 | 129 | */ |
| 130 | - public function pushToIndices(SearchableInterface $searchableModel) |
|
| 130 | + public function pushToIndices (SearchableInterface $searchableModel) |
|
| 131 | 131 | { |
| 132 | 132 | $indices = $this->initIndices($searchableModel); |
| 133 | 133 | $response = []; |
@@ -147,7 +147,7 @@ discard block |
||
| 147 | 147 | * |
| 148 | 148 | * @return array |
| 149 | 149 | */ |
| 150 | - public function pushMultipleToIndices(array $searchableModels) |
|
| 150 | + public function pushMultipleToIndices (array $searchableModels) |
|
| 151 | 151 | { |
| 152 | 152 | $algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels); |
| 153 | 153 | $indices = $this->initIndices($searchableModels[0]); |
@@ -169,7 +169,7 @@ discard block |
||
| 169 | 169 | * |
| 170 | 170 | * @return array |
| 171 | 171 | */ |
| 172 | - public function updateInIndices(SearchableInterface $searchableModel) |
|
| 172 | + public function updateInIndices (SearchableInterface $searchableModel) |
|
| 173 | 173 | { |
| 174 | 174 | $indices = $this->initIndices($searchableModel); |
| 175 | 175 | $response = []; |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | * |
| 191 | 191 | * @return array |
| 192 | 192 | */ |
| 193 | - public function updateMultipleInIndices(array $searchableModels) |
|
| 193 | + public function updateMultipleInIndices (array $searchableModels) |
|
| 194 | 194 | { |
| 195 | 195 | $algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels); |
| 196 | 196 | $indices = $this->initIndices($searchableModels[0]); |
@@ -213,7 +213,7 @@ discard block |
||
| 213 | 213 | * @return array |
| 214 | 214 | * @throws \InvalidArgumentException |
| 215 | 215 | */ |
| 216 | - public function removeFromIndices(SearchableInterface $searchableModel) |
|
| 216 | + public function removeFromIndices (SearchableInterface $searchableModel) |
|
| 217 | 217 | { |
| 218 | 218 | $indices = $indices = $this->initIndices($searchableModel); |
| 219 | 219 | $response = []; |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | * @return array |
| 235 | 235 | * @throws \InvalidArgumentException |
| 236 | 236 | */ |
| 237 | - public function removeMultipleFromIndices(array $searchableModels) |
|
| 237 | + public function removeMultipleFromIndices (array $searchableModels) |
|
| 238 | 238 | { |
| 239 | 239 | $algoliaRecords = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels); |
| 240 | 240 | $indices = $this->initIndices($searchableModels[0]); |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | * |
| 260 | 260 | * @return array |
| 261 | 261 | */ |
| 262 | - public function reindex($className) |
|
| 262 | + public function reindex ($className) |
|
| 263 | 263 | { |
| 264 | 264 | $this->checkImplementsSearchableInterface($className); |
| 265 | 265 | $activeRecord = $this->activeRecordFactory->make($className); |
@@ -292,7 +292,7 @@ discard block |
||
| 292 | 292 | * @throws \InvalidArgumentException |
| 293 | 293 | * @return array |
| 294 | 294 | */ |
| 295 | - public function reindexOnly(array $searchableModels) |
|
| 295 | + public function reindexOnly (array $searchableModels) |
|
| 296 | 296 | { |
| 297 | 297 | $records = $this->getAlgoliaRecordsFromSearchableModelArray($searchableModels); |
| 298 | 298 | $indices = $this->initIndices($searchableModels[0]); |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | * |
| 315 | 315 | * @return array |
| 316 | 316 | */ |
| 317 | - public function reindexByActiveQuery(ActiveQueryInterface $activeQuery) |
|
| 317 | + public function reindexByActiveQuery (ActiveQueryInterface $activeQuery) |
|
| 318 | 318 | { |
| 319 | 319 | $indices = null; |
| 320 | 320 | |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | * @throws \InvalidArgumentException |
| 352 | 352 | * @return array |
| 353 | 353 | */ |
| 354 | - public function clearIndices($className) |
|
| 354 | + public function clearIndices ($className) |
|
| 355 | 355 | { |
| 356 | 356 | $this->checkImplementsSearchableInterface($className); |
| 357 | 357 | $activeRecord = $this->activeRecordFactory->make($className); |
@@ -376,7 +376,7 @@ discard block |
||
| 376 | 376 | * |
| 377 | 377 | * @return array |
| 378 | 378 | */ |
| 379 | - public function search($className, $query, array $searchParameters = null) |
|
| 379 | + public function search ($className, $query, array $searchParameters = null) |
|
| 380 | 380 | { |
| 381 | 381 | $this->checkImplementsSearchableInterface($className); |
| 382 | 382 | $activeRecord = $this->activeRecordFactory->make($className); |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | * |
| 401 | 401 | * @return mixed |
| 402 | 402 | */ |
| 403 | - public function __call($method, $parameters) |
|
| 403 | + public function __call ($method, $parameters) |
|
| 404 | 404 | { |
| 405 | 405 | return call_user_func_array([$this->getClient(), $method], $parameters); |
| 406 | 406 | } |
@@ -410,11 +410,11 @@ discard block |
||
| 410 | 410 | * |
| 411 | 411 | * @param string $class Either name or instance of the class to be checked. |
| 412 | 412 | */ |
| 413 | - private function checkImplementsSearchableInterface($class) |
|
| 413 | + private function checkImplementsSearchableInterface ($class) |
|
| 414 | 414 | { |
| 415 | 415 | $reflectionClass = new \ReflectionClass($class); |
| 416 | 416 | |
| 417 | - if (! $reflectionClass->implementsInterface(SearchableInterface::class)) { |
|
| 417 | + if ( ! $reflectionClass->implementsInterface(SearchableInterface::class)) { |
|
| 418 | 418 | throw new \InvalidArgumentException("The class: {$reflectionClass->name} doesn't implement leinonen\\Yii2Algolia\\SearchableInterface"); |
| 419 | 419 | } |
| 420 | 420 | } |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | * |
| 427 | 427 | * @return Index[] |
| 428 | 428 | */ |
| 429 | - private function initIndices(SearchableInterface $searchableModel) |
|
| 429 | + private function initIndices (SearchableInterface $searchableModel) |
|
| 430 | 430 | { |
| 431 | 431 | $indexNames = $searchableModel->getIndices(); |
| 432 | 432 | |
@@ -448,7 +448,7 @@ discard block |
||
| 448 | 448 | * |
| 449 | 449 | * @return array |
| 450 | 450 | */ |
| 451 | - private function getAlgoliaRecordsFromSearchableModelArray(array $searchableModels) |
|
| 451 | + private function getAlgoliaRecordsFromSearchableModelArray (array $searchableModels) |
|
| 452 | 452 | { |
| 453 | 453 | if (empty($searchableModels)) { |
| 454 | 454 | throw new \InvalidArgumentException('The given array should not be empty'); |
@@ -459,7 +459,7 @@ discard block |
||
| 459 | 459 | $this->checkImplementsSearchableInterface($arrayType); |
| 460 | 460 | |
| 461 | 461 | $algoliaRecords = array_map(function (SearchableInterface $searchableModel) use ($arrayType) { |
| 462 | - if (! $searchableModel instanceof $arrayType) { |
|
| 462 | + if ( ! $searchableModel instanceof $arrayType) { |
|
| 463 | 463 | throw new \InvalidArgumentException('The given array should not contain multiple different classes'); |
| 464 | 464 | } |
| 465 | 465 | |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | * |
| 481 | 481 | * @return mixed |
| 482 | 482 | */ |
| 483 | - private function reindexAtomically(Index $index, array $algoliaRecords) |
|
| 483 | + private function reindexAtomically (Index $index, array $algoliaRecords) |
|
| 484 | 484 | { |
| 485 | 485 | $temporaryIndexName = 'tmp_' . $index->indexName; |
| 486 | 486 | |