when using doctrine i stumble upon these 2 words: accessor and mutator.
are these only used in doctrine or are they specific for php?
and what do they mean?
thanks
when using doctrine i stumble upon these 2 words: accessor and mutator.
are these only used in doctrine or are they specific for php?
and what do they mean?
thanks
They're just fancy terms for getters and setters.
class MyClass
{
private $prop;
// Accessor (or Getter)
public function getProp()
{
return $this->prop;
}
// Mutator (or Setter)
public function setProp($value)
{
$this->prop = $value;
}
}
If I understand you correctly these 2 are specific to I guess any object oriented programming language. The point is that accessor is a method or a function which provides access to private fields in your class and mutator method allows to modify the private fields. I can go on writing about this, but I suggest you just google these, and you'll get lots of information about it. Its all about encapsulation <- suggest you to look up that term as well.