Permalink
Browse files

Introduce setters/getters

  • Loading branch information...
1 parent 3106f31 commit 14e0f06917dff37233715fb33b2f38b17ca410f4 @CloCkWeRX CloCkWeRX committed Dec 4, 2011
Showing with 18 additions and 6 deletions.
  1. +17 −5 Net/Monitor.php
  2. +1 −1 tests/diff.phpt
View
@@ -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
*
@@ -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
@@ -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);
View
@@ -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:

0 comments on commit 14e0f06

Please sign in to comment.