PHP extending a class

oop, php

Solution

Yes, unless those 1 or 2 things happen to be at the beginning or the end. You can call the parent function via

parent::WithWayTooMuchCode();

Which you can place anywhere in the child/overridden method.

If it doesn't feel DRY, consider splitting the function into smaller methods.

Problem

I have a question about extending a class in PHP. The examples I see on the php site just have 1 line of code in the method...is it the same if the method has tons of code?? If this is the base class: ``` class BaseClass { public function WithWayTooMuchCode { // like 100 lines of code here } } ``` Then do I have to copy all the code over if I want to use the same method, but change only 1 or 2 things? ``` class MyOwnClass extends BaseClass { public function WithWayTooMuchCode { // like 100 lines of code here // do I have to copy all of the other code and then add my code?? } } ``` This seems a little not DRY to me...

Original source