Skip to content

Commit

Permalink
Clear code first step (#1120)
Browse files Browse the repository at this point in the history
  • Loading branch information
ReenExe authored and ruflin committed Jun 21, 2016
1 parent 16339d4 commit 3e042da
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 32 deletions.
10 changes: 3 additions & 7 deletions lib/Elastica/Cluster/Settings.php
Expand Up @@ -154,13 +154,9 @@ public function setReadOnly($readOnly = true, $persistent = false)
{
$key = 'cluster.blocks.read_only';

if ($persistent) {
$response = $this->setPersistent($key, $readOnly);
} else {
$response = $this->setTransient($key, $readOnly);
}

return $response;
return $persistent
? $this->setPersistent($key, $readOnly)
: $this->setTransient($key, $readOnly);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/Elastica/Index/Settings.php
Expand Up @@ -193,9 +193,9 @@ public function getBlocksMetadata()
if (strpos($e->getMessage(), 'ClusterBlockException') !== false) {
// hacky way to test if the metadata is blocked since bug 9203 is not fixed
return true;
} else {
throw $e;
}

throw $e;
}
}

Expand Down
8 changes: 3 additions & 5 deletions lib/Elastica/Multi/ResultSet.php
Expand Up @@ -84,11 +84,9 @@ public function hasError()
*/
public function current()
{
if ($this->valid()) {
return $this->_resultSets[$this->key()];
} else {
return false;
}
return $this->valid()
? $this->_resultSets[$this->key()]
: false;
}

/**
Expand Down
4 changes: 0 additions & 4 deletions lib/Elastica/Query.php
Expand Up @@ -348,10 +348,6 @@ public function addScriptField($name, AbstractScript $script)
*/
public function addAggregation(AbstractAggregation $agg)
{
if (!array_key_exists('aggs', $this->_params)) {
$this->_params['aggs'] = array();
}

$this->_params['aggs'][] = $agg;

return $this;
Expand Down
2 changes: 1 addition & 1 deletion lib/Elastica/Query/SimpleQueryString.php
Expand Up @@ -18,7 +18,7 @@ class SimpleQueryString extends AbstractQuery
public function __construct($query, array $fields = array())
{
$this->setQuery($query);
if (sizeof($fields)) {
if (count($fields)) {
$this->setFields($fields);
}
}
Expand Down
8 changes: 4 additions & 4 deletions lib/Elastica/Result.php
Expand Up @@ -148,10 +148,10 @@ public function getVersion()
*/
public function getData()
{
if (isset($this->_hit['fields']) && !isset($this->_hit['_source'])) {
return $this->getFields();
} elseif (isset($this->_hit['fields']) && isset($this->_hit['_source'])) {
return array_merge($this->getFields(), $this->getSource());
if (isset($this->_hit['fields'])) {
return isset($this->_hit['_source'])
? array_merge($this->getFields(), $this->getSource())
: $this->getFields();
}

return $this->getSource();
Expand Down
4 changes: 0 additions & 4 deletions lib/Elastica/Search.php
Expand Up @@ -235,10 +235,6 @@ public function addOption($key, $value)
{
$this->_validateOption($key);

if (!isset($this->_options[$key])) {
$this->_options[$key] = array();
}

$this->_options[$key][] = $value;

return $this;
Expand Down
4 changes: 0 additions & 4 deletions lib/Elastica/Suggest/Phrase.php
Expand Up @@ -174,10 +174,6 @@ public function toArray()
$keys = array_keys($generator);
$values = array_values($generator);

if (!isset($array[$baseName][$keys[0]])) {
$array[$baseName][$keys[0]] = array();
}

$array[$baseName][$keys[0]][] = $values[0];
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Elastica/Type.php
Expand Up @@ -545,6 +545,6 @@ public function exists()
$response = $this->getIndex()->request($this->getName(), Request::HEAD);
$info = $response->getTransferInfo();

return (bool) ($info['http_code'] == 200);
return $info['http_code'] == 200;
}
}

0 comments on commit 3e042da

Please sign in to comment.