You have an immediate problem here, regardless of SRP: $this->internalFoo
is going to error because internalFoo
is private.
Without a clearer example, it’s difficult to tell, but this doesn’t look like an SRP problem to me, however I have a few suggestions:
- Favour composition over inheritance:
class Child
{
public function __construct(Parent $parent)
{
$this->parent = $parent;
}
public function foo($parameter1, $parameter2)
{
/* do some logic to manipulate (and basically also validate) parameters for the method internalFoo() */
$this->parent->internalFoo([$parameter1, $this->parent->someMethod($parameter2)])
return $this;
}
}
- Here
/* do some logic to manipulate (and basically also validate) parameters for the method internalFoo() */
Why can’tinternalFoo
do its own validation? If this method needs to accept only valid inputs, the checks should he inside the method, imho.