StaffCoder
PHP
PHPPHP 8
10 modules · 49 challengesSign up
Module 6 of 10 · 5 challenges

PHP Inheritance and Interfaces

Learn how to share behaviour through abstract parent classes, define contracts with interfaces, reuse code across unrelated classes with traits, treat different objects the same way through one interface, and send order notifications over several channels.
Finish every challenge, or complete the star challenge, to complete the module.

Challenges

5 challenges

Shipping Cost Classes

Sign up to unlock
—No data yetmedium
About this challenge

The express shipping option computes its price on its own, apart from the standard option it is supposed to build on, so express quotes no longer equal the standard price plus the surcharge, and nothing stops someone from creating a shipment that has no price rule at all.

Solved in a browser IDE and graded by tests. Sign up to solve

Refundable Payments

Sign up to unlock
—No data yetmedium
About this challenge

Customer service decides which payments can be refunded by guessing from the payment type, and last week a cash-on-delivery order was refunded money the shop never collected.

Solved in a browser IDE and graded by tests. Sign up to solve

Shared Money Formatting

Sign up to unlock
—No data yetmedium
About this challenge

Invoices and receipts are unrelated documents that now need the same money formatting, and the last time each got its own formatting code the two printed the same amount differently.

Solved in a browser IDE and graded by tests. Sign up to solve

Stackable Price Rules

Sign up to unlock
—No data yetmedium
About this challenge

The checkout has a separate total function for every combination of discounts, a partner team cannot add its own rule without editing all of them, and someone changed the maths of a discount by subclassing it.

Solved in a browser IDE and graded by tests. Sign up to solve

Order Notification Channels

STAR
Solving it completes the module
—No data yetmedium
About this challenge

The order service sends shipping updates by email, by SMS and to an audit log through three unrelated pieces of code that word the same update differently, send to addresses that cannot work, and bill SMS messages nobody adds up; the team wants one way to send an update to any set of channels and know what it cost.

Solved in a browser IDE and graded by tests. Sign up to solve

We use cookies that are necessary to run Staffcoder, and optional analytics cookies to see which pages get used. Analytics stays off unless you accept. Read our Cookie Policy.