Skip to content

Commit

Permalink
Introduce setters/getters
Browse files Browse the repository at this point in the history
  • Loading branch information
CloCkWeRX committed Dec 4, 2011
1 parent 3106f31 commit 14e0f06
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
22 changes: 17 additions & 5 deletions Net/Monitor.php
Expand Up @@ -160,6 +160,16 @@ public function __construct($services = array(), $alerts = array(), $options = a
}
}

public function getResults()
{
return $this->_results;
}

public function setResults($results)
{
$this->_results = $results;
}

/**
* function setOptions
*
Expand Down Expand Up @@ -236,11 +246,12 @@ public function setAlerts($alerts)
*/
public function checkAll()
{
//initialize the _results and _results_diff arrays
$this->_results = array();
//initialize the results and _results_diff arrays
$results = array();
$this->setResults($results);
$this->_results_diff = array();

//check all services and populate the _results array
//check all services and populate the results array
if (is_array($this->_services) && sizeof($this->_services) > 0) {

//load client objects once and only once per service
Expand All @@ -250,15 +261,16 @@ public function checkAll()
foreach ($services as $service) {
$result = $this->check($server, $service);
if ($result) {
$this->_results[$server][$service] = $result;
$results[$server][$service] = $result;
$this->setResults($results);
}
}
}
} else {
throw new Net_Monitor_Excepton('No services found to check.');
}

if (is_array($this->_results) && sizeof($this->_results) > 0) {
if (is_array($results) && sizeof($results) > 0) {
$last_state = $this->getState();
$this->saveState();
$this->_results_diff = $this->stateDiff($last_state);
Expand Down
2 changes: 1 addition & 1 deletion tests/diff.phpt
Expand Up @@ -43,7 +43,7 @@ $secondary = array(
* bar.example.com HTTP changed from down to 404 (send notice)
*/
$monitor = new Net_Monitor();
$monitor->_results = $primary;
$monitor->setResults($primary);
$result = $monitor->stateDiff($secondary);
print_r($result);
/* Should produce:
Expand Down

0 comments on commit 14e0f06

Please sign in to comment.