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

PHP Enums

Learn how to replace loose status strings with pure and backed enums, convert stored values safely with from and tryFrom, give enums their own methods and constants, make them implement interfaces, and drive an order through its allowed status changes.
Finish every challenge, or complete the star challenge, to complete the module.

Challenges

5 challenges

Shipping Method Choices

Sign up to unlock
—No data yetmedium
About this challenge

Shipping methods are passed around as plain strings, so an order saved with a misspelled method quietly gets the slowest delivery and no tracking number.

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

Payment Status Codes

Sign up to unlock
—No data yetmedium
About this challenge

Payment statuses arrive as text from two places: the live payment webhook must refuse any code it does not know, while the legacy import has to keep going and treat blank or unknown codes as still pending.

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

Shirt Size Picker

Sign up to unlock
—No data yetmedium
About this challenge

The size picker on the shirt page shows raw codes like XL, and every page that needs the default size or the sizes above a chosen one keeps its own copy of that logic.

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

Gift Wrap Extras

Sign up to unlock
—No data yetmedium
About this challenge

Checkout adds up optional extras such as insurance, but gift wrapping is kept as a separate set of codes, so its price never reaches the order total.

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

Order Status Workflow

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

Orders should move from pending through paid and shipped to delivered, or be cancelled before shipping; a delivered order must never be cancelled and order history must not be replayed from corrupt stored status text, while the order list must still show orders with a missing or unreadable status as new.

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.