Example code:
<?php
class MyClass {
public $bar = array('a', 'b', 'c');
public function getBar() {return $this->bar;}
public function execute(array $fooArray) {
foreach ($fooArray as $foo) {
echo $foo.":".$this->checkBar($foo, $this->getBar())." ";// PASSED IN//
//echo $foo.":".$this->checkBar($foo)." ";// RETRIEVED //
}
}
// PASSED IN //
public function checkBar($foo, array $fooCheck) {
return in_array($foo, $fooCheck);
}
// RETRIEVED //
/*public function checkBar($foo) {
$fooCheck = $this->getBar();
return in_array($foo, $fooCheck);
}*/
}
$someClass = new MyClass();
$someClass->execute(array('a','f','c','g'));
?>
Are there any performance considerations to passing $fooCheck
in as a variable into checkBar
vs having MyClass::checkBar()
handle calling the function itself?