Commit a15ce323 authored by Bas de Nooijer's avatar Bas de Nooijer

Styling fixes

parent 9e4ae9e3
...@@ -91,7 +91,7 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter ...@@ -91,7 +91,7 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter
$ch = curl_init(); $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION , true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $options['timeout']); curl_setopt($ch, CURLOPT_TIMEOUT, $options['timeout']);
if (!isset($options['headers']['Content-Type'])) { if (!isset($options['headers']['Content-Type'])) {
...@@ -101,7 +101,7 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter ...@@ -101,7 +101,7 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter
$options['headers']['Content-Type'] = 'text/xml; charset=utf-8'; $options['headers']['Content-Type'] = 'text/xml; charset=utf-8';
} }
if(count($options['headers'])) { if (count($options['headers'])) {
$arr = array(); $arr = array();
foreach ($options['headers'] as $k => $v) { foreach ($options['headers'] as $k => $v) {
$arr[] = $k . ": " . $v; $arr[] = $k . ": " . $v;
...@@ -125,7 +125,7 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter ...@@ -125,7 +125,7 @@ class Solarium_Client_Adapter_Curl extends Solarium_Client_Adapter
$headers = array(); $data = ''; $headers = array(); $data = '';
if($httpResponse !== false) { if ($httpResponse !== false) {
$data = $httpResponse; $data = $httpResponse;
$info = curl_getinfo($ch); $info = curl_getinfo($ch);
$headers = array(); $headers = array();
......
...@@ -69,23 +69,34 @@ class Solarium_Client_ResponseParser_Select_Component_Grouping ...@@ -69,23 +69,34 @@ class Solarium_Client_ResponseParser_Select_Component_Grouping
$valueGroups = array(); $valueGroups = array();
foreach ($result['groups'] as $valueGroupResult) { foreach ($result['groups'] as $valueGroupResult) {
$value = (isset($valueGroupResult['groupValue'])) ? $valueGroupResult['groupValue'] : null; $value = (isset($valueGroupResult['groupValue'])) ?
$numFound = (isset($valueGroupResult['doclist']['numFound'])) ? $valueGroupResult['doclist']['numFound'] : null; $valueGroupResult['groupValue'] : null;
$start = (isset($valueGroupResult['doclist']['start'])) ? $valueGroupResult['doclist']['start'] : null;
$numFound = (isset($valueGroupResult['doclist']['numFound'])) ?
$valueGroupResult['doclist']['numFound'] : null;
$start = (isset($valueGroupResult['doclist']['start'])) ?
$valueGroupResult['doclist']['start'] : null;
// create document instances // create document instances
$documentClass = $query->getOption('documentclass'); $documentClass = $query->getOption('documentclass');
$documents = array(); $documents = array();
if (isset($valueGroupResult['doclist']['docs']) && is_array($valueGroupResult['doclist']['docs'])) { if (isset($valueGroupResult['doclist']['docs']) &&
is_array($valueGroupResult['doclist']['docs'])) {
foreach ($valueGroupResult['doclist']['docs'] as $doc) { foreach ($valueGroupResult['doclist']['docs'] as $doc) {
$documents[] = new $documentClass($doc); $documents[] = new $documentClass($doc);
} }
} }
$valueGroups[] = new Solarium_Result_Select_Grouping_ValueGroup($value, $numFound, $start, $documents); $valueGroups[] = new Solarium_Result_Select_Grouping_ValueGroup(
$value, $numFound, $start, $documents
);
} }
$groups[$field] = new Solarium_Result_Select_Grouping_FieldGroup($matches, $groupCount, $valueGroups); $groups[$field] = new Solarium_Result_Select_Grouping_FieldGroup(
$matches, $groupCount, $valueGroups
);
} }
} }
...@@ -110,7 +121,9 @@ class Solarium_Client_ResponseParser_Select_Component_Grouping ...@@ -110,7 +121,9 @@ class Solarium_Client_ResponseParser_Select_Component_Grouping
} }
// create a group result object // create a group result object
$group = new Solarium_Result_Select_Grouping_QueryGroup($matches, $numFound, $start, $maxScore, $documents); $group = new Solarium_Result_Select_Grouping_QueryGroup(
$matches, $numFound, $start, $maxScore, $documents
);
$groups[$groupQuery] = $group; $groups[$groupQuery] = $group;
} }
} }
......
...@@ -61,7 +61,7 @@ class Solarium_Client_ResponseParser_Select_Component_Stats ...@@ -61,7 +61,7 @@ class Solarium_Client_ResponseParser_Select_Component_Stats
$statResults = $data['stats']['stats_fields']; $statResults = $data['stats']['stats_fields'];
foreach ($statResults AS $field => $stats) { foreach ($statResults AS $field => $stats) {
if (isset($stats['facets'])) { if (isset($stats['facets'])) {
foreach($stats['facets'] as $facetField => $values) { foreach ($stats['facets'] as $facetField => $values) {
foreach ($values as $value => $valueStats) { foreach ($values as $value => $valueStats) {
$stats['facets'][$facetField][$value] = new Solarium_Result_Select_Stats_FacetValue($value, $valueStats); $stats['facets'][$facetField][$value] = new Solarium_Result_Select_Stats_FacetValue($value, $valueStats);
} }
......
...@@ -238,7 +238,7 @@ class Solarium_Plugin_CustomizeRequest extends Solarium_Plugin_Abstract ...@@ -238,7 +238,7 @@ class Solarium_Plugin_CustomizeRequest extends Solarium_Plugin_Abstract
// first validate // first validate
if (!$customization->isValid()) { if (!$customization->isValid()) {
throw new Solarium_Exception('Request customization with key "' . $key . '" is invalid' ); throw new Solarium_Exception('Request customization with key "' . $key . '" is invalid');
} }
// apply to request, depending on type // apply to request, depending on type
......
...@@ -199,7 +199,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract ...@@ -199,7 +199,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* @param int $weight Must be a positive number * @param int $weight Must be a positive number
* @return self Provides fluent interface * @return self Provides fluent interface
*/ */
public function addServer($key, $options, $weight = 1) { public function addServer($key, $options, $weight = 1)
{
if (array_key_exists($key, $this->_servers)) { if (array_key_exists($key, $this->_servers)) {
throw new Solarium_Exception('A server for the loadbalancer plugin must have a unique key'); throw new Solarium_Exception('A server for the loadbalancer plugin must have a unique key');
} else { } else {
...@@ -330,7 +331,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract ...@@ -330,7 +331,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* *
* @return array * @return array
*/ */
public function getBlockedQueryTypes() { public function getBlockedQueryTypes()
{
return array_keys($this->_blockedQueryTypes); return array_keys($this->_blockedQueryTypes);
} }
...@@ -342,7 +344,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract ...@@ -342,7 +344,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* @param array $types Use an array with the constants defined in Solarium_Client as values * @param array $types Use an array with the constants defined in Solarium_Client as values
* @return self Provides fluent interface * @return self Provides fluent interface
*/ */
public function setBlockedQueryTypes($types) { public function setBlockedQueryTypes($types)
{
$this->clearBlockedQueryTypes(); $this->clearBlockedQueryTypes();
$this->addBlockedQueryTypes($types); $this->addBlockedQueryTypes($types);
return $this; return $this;
...@@ -354,7 +357,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract ...@@ -354,7 +357,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* @param string $type Use one of the constants defined in Solarium_Client * @param string $type Use one of the constants defined in Solarium_Client
* @return self Provides fluent interface * @return self Provides fluent interface
*/ */
public function addBlockedQueryType($type) { public function addBlockedQueryType($type)
{
if (!array_key_exists($type, $this->_blockedQueryTypes)) { if (!array_key_exists($type, $this->_blockedQueryTypes)) {
$this->_blockedQueryTypes[$type] = true; $this->_blockedQueryTypes[$type] = true;
} }
...@@ -370,7 +374,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract ...@@ -370,7 +374,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* @param array $types Use an array with the constants defined in Solarium_Client as values * @param array $types Use an array with the constants defined in Solarium_Client as values
* @return self Provides fluent interface * @return self Provides fluent interface
*/ */
public function addBlockedQueryTypes($types) { public function addBlockedQueryTypes($types)
{
foreach ($types AS $type) { foreach ($types AS $type) {
$this->addBlockedQueryType($type); $this->addBlockedQueryType($type);
} }
...@@ -382,7 +387,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract ...@@ -382,7 +387,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* @param string $type * @param string $type
* @return void * @return void
*/ */
public function removeBlockedQueryType($type) { public function removeBlockedQueryType($type)
{
if (array_key_exists($type, $this->_blockedQueryTypes)) { if (array_key_exists($type, $this->_blockedQueryTypes)) {
unset($this->_blockedQueryTypes[$type]); unset($this->_blockedQueryTypes[$type]);
} }
...@@ -393,7 +399,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract ...@@ -393,7 +399,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* *
* @return self Provides fluent interface * @return self Provides fluent interface
*/ */
public function clearBlockedQueryTypes() { public function clearBlockedQueryTypes()
{
$this->_blockedQueryTypes = array(); $this->_blockedQueryTypes = array();
} }
...@@ -462,7 +469,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract ...@@ -462,7 +469,8 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
* @param Solarium_Client_Request $request * @param Solarium_Client_Request $request
* @return Solarium_Client_Response $response * @return Solarium_Client_Response $response
*/ */
protected function _getLoadbalancedResponse($request) { protected function _getLoadbalancedResponse($request)
{
$this->_serverExcludes = array(); // reset for each query $this->_serverExcludes = array(); // reset for each query
$adapter = $this->_client->getAdapter(); $adapter = $this->_client->getAdapter();
...@@ -471,7 +479,7 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract ...@@ -471,7 +479,7 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
$e = new Solarium_Exception('Maximum number of loadbalancer retries reached'); $e = new Solarium_Exception('Maximum number of loadbalancer retries reached');
for($i=0; $i<=$this->getFailoverMaxRetries(); $i++) { for ($i=0; $i<=$this->getFailoverMaxRetries(); $i++) {
$options = $this->_getRandomServerOptions(); $options = $this->_getRandomServerOptions();
$adapter->setOptions($options); $adapter->setOptions($options);
try { try {
...@@ -524,7 +532,7 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract ...@@ -524,7 +532,7 @@ class Solarium_Plugin_Loadbalancer extends Solarium_Plugin_Abstract
{ {
if ($this->_randomizer === null) { if ($this->_randomizer === null) {
$choices = array(); $choices = array();
foreach($this->_servers AS $key => $settings) { foreach ($this->_servers AS $key => $settings) {
$choices[$key] = $settings['weight']; $choices[$key] = $settings['weight'];
} }
$this->_randomizer = new Solarium_Plugin_Loadbalancer_WeightedRandomChoice($choices); $this->_randomizer = new Solarium_Plugin_Loadbalancer_WeightedRandomChoice($choices);
......
...@@ -75,7 +75,7 @@ class Solarium_Plugin_Loadbalancer_WeightedRandomChoice ...@@ -75,7 +75,7 @@ class Solarium_Plugin_Loadbalancer_WeightedRandomChoice
public function __construct($choices) public function __construct($choices)
{ {
$i = 0; $i = 0;
foreach($choices AS $key => $weight) { foreach ($choices AS $key => $weight) {
if ($weight <= 0) throw new Solarium_Exception('Weight must be greater than zero'); if ($weight <= 0) throw new Solarium_Exception('Weight must be greater than zero');
$this->_totalWeight += $weight; $this->_totalWeight += $weight;
...@@ -100,7 +100,7 @@ class Solarium_Plugin_Loadbalancer_WeightedRandomChoice ...@@ -100,7 +100,7 @@ class Solarium_Plugin_Loadbalancer_WeightedRandomChoice
// continue until a non-excluded value is found // continue until a non-excluded value is found
// @todo optimize? // @todo optimize?
while(1) { while (1) {
$result = $this->_values[$this->_getKey()]; $result = $this->_values[$this->_getKey()];
if(!in_array($result, $excludes)) return $result; if(!in_array($result, $excludes)) return $result;
} }
...@@ -113,7 +113,7 @@ class Solarium_Plugin_Loadbalancer_WeightedRandomChoice ...@@ -113,7 +113,7 @@ class Solarium_Plugin_Loadbalancer_WeightedRandomChoice
*/ */
protected function _getKey() protected function _getKey()
{ {
$random = mt_rand(1, $this->_totalWeight); $random = mt_rand(1, $this->_totalWeight);
$high = count($this->_lookup)-1; $high = count($this->_lookup)-1;
$low = 0; $low = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment