CS: Fix violations for overdue files

refs #4586
This commit is contained in:
Eric Lippmann 2013-09-02 17:33:12 +02:00 committed by Jannis Moßhammer
parent 8a062ff3e5
commit 092c5780ea
6 changed files with 35 additions and 22 deletions

View File

@ -127,13 +127,15 @@ class DbBackendForm extends BaseBackendForm
{ {
try { try {
$name = $this->getBackendName(); $name = $this->getBackendName();
$dbBackend = new DbUserBackend(new Zend_Config( $dbBackend = new DbUserBackend(
array( new Zend_Config(
'backend' => 'db', array(
'target' => 'user', 'backend' => 'db',
'resource' => $this->getValue('backend_' . $this->filterName($name) . '_resource'), 'target' => 'user',
'resource' => $this->getValue('backend_' . $this->filterName($name) . '_resource'),
)
) )
)); );
if ($dbBackend->getUserCount() < 1) { if ($dbBackend->getUserCount() < 1) {
$this->addErrorMessage("No users found under the specified database backend"); $this->addErrorMessage("No users found under the specified database backend");
return false; return false;

View File

@ -30,6 +30,7 @@ namespace Icinga\Protocol\Statusdat;
use Icinga\Protocol; use Icinga\Protocol;
use Icinga\Data\AbstractQuery; use Icinga\Data\AbstractQuery;
/** /**
* Class Query * Class Query
* @package Icinga\Protocol\Statusdat * @package Icinga\Protocol\Statusdat
@ -398,5 +399,4 @@ class Query extends AbstractQuery
} }
return $result; return $result;
} }
} }

View File

@ -30,9 +30,10 @@ namespace Icinga\Protocol\Statusdat;
use Icinga\Data\DatasourceInterface; use Icinga\Data\DatasourceInterface;
use Icinga\Exception as Exception; use Icinga\Exception;
use Icinga\Benchmark as Benchmark; use Icinga\Benchmark;
use Icinga\Protocol\Statusdat\View\MonitoringObjectList; use Icinga\Protocol\Statusdat\View\MonitoringObjectList;
/** /**
* Class Reader * Class Reader
* @package Icinga\Protocol\Statusdat * @package Icinga\Protocol\Statusdat
@ -319,5 +320,4 @@ class Reader implements IReader, DatasourceInterface
{ {
return isset($this->lastState[$type]) ? array_keys($this->lastState[$type]) : null; return isset($this->lastState[$type]) ? array_keys($this->lastState[$type]) : null;
} }
} }

View File

@ -11,15 +11,21 @@
* If the dataset contains arrays instead of objects, they will be cast to objects. * If the dataset contains arrays instead of objects, they will be cast to objects.
* *
*/ */
namespace Icinga\Protocol\Statusdat\View; namespace Icinga\Protocol\Statusdat\View;
class MonitoringObjectList implements \Iterator, \Countable, \ArrayAccess use \Iterator;
use \Countable;
use \ArrayAccess;
use \Exception;
class MonitoringObjectList implements Iterator, Countable, ArrayAccess
{ {
private $dataSet = array(); private $dataSet = array();
private $position = 0; private $position = 0;
private $dataView = null; private $dataView = null;
function __construct(array &$dataset, AccessorStrategy $dataView = null) public function __construct(array &$dataset, AccessorStrategy $dataView = null)
{ {
$this->dataSet = $dataset; $this->dataSet = $dataset;
$this->position = 0; $this->position = 0;
@ -44,8 +50,9 @@ class MonitoringObjectList implements \Iterator, \Countable, \ArrayAccess
*/ */
public function current() public function current()
{ {
if ($this->dataView) if ($this->dataView) {
return $this; return $this;
}
return $this->dataSet[$this->position]; return $this->dataSet[$this->position];
} }
@ -96,17 +103,17 @@ class MonitoringObjectList implements \Iterator, \Countable, \ArrayAccess
public function __isset($name) public function __isset($name)
{ {
return $this->dataView->exists($this->dataSet[$this->position],$name); return $this->dataView->exists($this->dataSet[$this->position], $name);
} }
function __get($name) public function __get($name)
{ {
return $this->dataView->get($this->dataSet[$this->position],$name); return $this->dataView->get($this->dataSet[$this->position], $name);
} }
function __set($name, $value) public function __set($name, $value)
{ {
throw new \Exception("Setting is currently not available for objects"); throw new Exception("Setting is currently not available for objects");
} }
public function offsetExists($offset) public function offsetExists($offset)
@ -130,5 +137,4 @@ class MonitoringObjectList implements \Iterator, \Countable, \ArrayAccess
{ {
// non mutable // non mutable
} }
} }

View File

@ -99,8 +99,9 @@ class ObjectRemappingView implements AccessorStrategy
private function applyPropertyFunction($function, $value) private function applyPropertyFunction($function, $value)
{ {
if (!isset($this->functionMap[$function])) if (!isset($this->functionMap[$function])) {
return $value; return $value;
}
$fn = $this->functionMap[$function]; $fn = $this->functionMap[$function];
return $this->$fn($value); return $this->$fn($value);

View File

@ -48,7 +48,9 @@ class Format
public static function duration($duration) public static function duration($duration)
{ {
if (! $duration) return '-'; if (! $duration) {
return '-';
}
return self::showHourMin($duration); return self::showHourMin($duration);
} }
@ -67,7 +69,9 @@ class Format
public static function timeSince($timestamp) public static function timeSince($timestamp)
{ {
if (! $timestamp) return '-'; if (! $timestamp) {
return '-';
}
$duration = time() - $timestamp; $duration = time() - $timestamp;
$prefix = ''; $prefix = '';
if ($duration < 0) { if ($duration < 0) {