@@ -27,7 +27,6 @@ |
||
27 | 27 | |
28 | 28 | /** |
29 | 29 | * Создать новый скрипт |
30 | - * @param string $language=painless |
|
31 | 30 | */ |
32 | 31 | public function __construct($language='painless') |
33 | 32 | { |
@@ -29,7 +29,7 @@ |
||
29 | 29 | * Создать новый скрипт |
30 | 30 | * @param string $language=painless |
31 | 31 | */ |
32 | - public function __construct($language='painless') |
|
32 | + public function __construct($language = 'painless') |
|
33 | 33 | { |
34 | 34 | $this->language = $language; |
35 | 35 | } |
@@ -85,7 +85,9 @@ |
||
85 | 85 | ]; |
86 | 86 | |
87 | 87 | // because ES |
88 | - if (empty($script['script']['params'])) unset($script['script']['params']); |
|
88 | + if (empty($script['script']['params'])) { |
|
89 | + unset($script['script']['params']); |
|
90 | + } |
|
89 | 91 | |
90 | 92 | return $script; |
91 | 93 | } |
@@ -2,8 +2,6 @@ |
||
2 | 2 | |
3 | 3 | namespace Bardex\Elastic; |
4 | 4 | |
5 | -use Bardex\Elastic\SearchResult; |
|
6 | - |
|
7 | 5 | |
8 | 6 | /** |
9 | 7 | * Fluent interface for ElasticSearch |
@@ -71,7 +71,7 @@ |
||
71 | 71 | $query = $this->getQuery(); |
72 | 72 | |
73 | 73 | // send query to elastic |
74 | - $start = microtime(1); |
|
74 | + $start = microtime(1); |
|
75 | 75 | |
76 | 76 | try { |
77 | 77 | $result = $this->executeQuery($query); |
@@ -78,8 +78,7 @@ |
||
78 | 78 | $time = round((microtime(1) - $start) * 1000); |
79 | 79 | $this->triggerSuccess($query, $result, $time); |
80 | 80 | return $result; |
81 | - } |
|
82 | - catch (\Exception $e) { |
|
81 | + } catch (\Exception $e) { |
|
83 | 82 | $this->triggerError($query, $e); |
84 | 83 | throw $e; |
85 | 84 | } |
@@ -15,17 +15,17 @@ discard block |
||
15 | 15 | /** |
16 | 16 | * @var bool логировать все запросы |
17 | 17 | */ |
18 | - protected $logAllQueries=true; |
|
18 | + protected $logAllQueries = true; |
|
19 | 19 | |
20 | 20 | /** |
21 | 21 | * @var bool логировать запросы с ошибками |
22 | 22 | */ |
23 | - protected $logErrorQueries=true; |
|
23 | + protected $logErrorQueries = true; |
|
24 | 24 | |
25 | 25 | /** |
26 | 26 | * @var bool логировать медленные запросы |
27 | 27 | */ |
28 | - protected $logSlowQueries=true; |
|
28 | + protected $logSlowQueries = true; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * @var int лимит времени выполнения запроса после которого он считается медленным (мс) |
@@ -42,10 +42,10 @@ discard block |
||
42 | 42 | */ |
43 | 43 | public function __construct( |
44 | 44 | LoggerInterface $logger, |
45 | - $logAllQueries=true, |
|
46 | - $logErrorQueries=true, |
|
47 | - $logSlowQueries=true, |
|
48 | - $slowQueryLimitMs=1000) |
|
45 | + $logAllQueries = true, |
|
46 | + $logErrorQueries = true, |
|
47 | + $logSlowQueries = true, |
|
48 | + $slowQueryLimitMs = 1000) |
|
49 | 49 | { |
50 | 50 | $this->logger = $logger; |
51 | 51 | $this->logAllQueries = $logAllQueries; |
@@ -145,12 +145,26 @@ |
||
145 | 145 | |
146 | 146 | protected function getTimeRange($time) |
147 | 147 | { |
148 | - if ($time <= 10) return '0-10 ms'; |
|
149 | - if ($time <= 30) return '10-30 ms'; |
|
150 | - if ($time <= 50) return '30-50 ms'; |
|
151 | - if ($time <= 100) return '50-100 ms'; |
|
152 | - if ($time <= 500) return '100-500 ms'; |
|
153 | - if ($time <= 1000) return '500-1000 ms'; |
|
154 | - if ($time > 1000) return '> 1000 ms'; |
|
148 | + if ($time <= 10) { |
|
149 | + return '0-10 ms'; |
|
150 | + } |
|
151 | + if ($time <= 30) { |
|
152 | + return '10-30 ms'; |
|
153 | + } |
|
154 | + if ($time <= 50) { |
|
155 | + return '30-50 ms'; |
|
156 | + } |
|
157 | + if ($time <= 100) { |
|
158 | + return '50-100 ms'; |
|
159 | + } |
|
160 | + if ($time <= 500) { |
|
161 | + return '100-500 ms'; |
|
162 | + } |
|
163 | + if ($time <= 1000) { |
|
164 | + return '500-1000 ms'; |
|
165 | + } |
|
166 | + if ($time > 1000) { |
|
167 | + return '> 1000 ms'; |
|
168 | + } |
|
155 | 169 | } |
156 | 170 | } |
157 | 171 | \ No newline at end of file |
@@ -115,7 +115,7 @@ |
||
115 | 115 | } |
116 | 116 | |
117 | 117 | |
118 | - protected function range($params, $dateFormat=null) |
|
118 | + protected function range($params, $dateFormat = null) |
|
119 | 119 | { |
120 | 120 | if ($dateFormat) $params['format'] = $dateFormat; |
121 | 121 | $this->query->addFilter('range', [$this->field => $params]); |
@@ -117,7 +117,9 @@ |
||
117 | 117 | |
118 | 118 | protected function range($params, $dateFormat=null) |
119 | 119 | { |
120 | - if ($dateFormat) $params['format'] = $dateFormat; |
|
120 | + if ($dateFormat) { |
|
121 | + $params['format'] = $dateFormat; |
|
122 | + } |
|
121 | 123 | $this->query->addFilter('range', [$this->field => $params]); |
122 | 124 | return $this->query; |
123 | 125 | } |