Hi,
I'm wondering when private/protected methods should work on the class it's variables (like $this->_results
) and when such methods should be used as if they were functions (like $this->_method($results)
). Examples below:
Work on class properties
<?php
class TestA
{
protected $_results;
public function getResults()
{
$this->_results = getFromWebservice();
$this->_filterResults();
}
protected function _filterResults()
{
$this->_results = doMagic($this->_results);
}
}
Work "as function"
<?php
class TestB
{
protected $_results;
public function getResults()
{
$results = getFromWebservice();
$this->_results = $this->_filterResults($results);
}
protected function _filterResults($results)
{
return doMagic($results);
}
}
Any help would be greatly appreciated.
Adriaan