It depends on the scope/definition of the application. But traditionally, your functions are used in may places $object->doSomething() does just that. By relying on validation in there, you prevent the ability to doSomething() of your OWN acccord, ya know?
Too, if you keep validation outside you can easily manage it. No need to hunt it down in that particular internal function. Keep it OOP, but more like
$data = $validator->sanitizeSomething($data);
$object->doSomething($data);
this keeps your validation rules separate and easy to manaage as well as your internal functions.
To elaborate, say you have a db object that adds an array to the table:
class db {
function addRow($table, $associativeArray) {
// primitive i know, just an example
}
}
would you want your validation in there?
function addRow($table, $associativeArray) {
if( isset( $assiciativeArray['description'] ) {
// validate
}
}
would be silly - you'd want that in the object you're working in
class product {
function update() {
if( $this->validate() ) {
$this->db->addRow($this->toArray()); // or something, you get the idea, ya?
}
}
function validate() {
if( $this->description != "") {
return true;
}
return false;
}
}