Skip to content
Dimitri Robiere PerrietD. R. PerrietCaen, FR — --:--:--EN · FR

MyDigitalHorse, object-oriented programming in PHP

○ Archived
Client
MyDigitalSchool
Role
PHP developer
Duration
6 weeks
Year
2022
Stack
PHP · POO · Composer · Docker · git-php
MyDigitalHorse, object-oriented programming in PHP — illustration
Fig. 01 — MyDigitalHorse, object-oriented programming in PHP, illustration
(00) — In short

An object-oriented PHP assessment: modelling a competition stable (riders, equines, events) with business rules enforced through exceptions, following SOLID.

(01)

Context

MyDigitalHorse is MyDigitalSchool’s object-oriented programming exam from autumn 2022. The brief describes a competition stable: a manager, riders, horses, ponies and Shetlands, and events to enter them in.

Around the same time, I ran another PHP experiment: a small web interface, bolted onto a WordPress install, for switching Git branches and merging from the browser using the git-php library.

(02)

Challenge

The assessment was about business rules more than display. A rider cannot have more than five equines, a horse cannot enter PoneyGames, the same equine cannot be entered twice in an event, and each event has a limited water capacity that must not be exceeded.

The grader had to be able to check everything by running the script once, and every check had to go through exceptions, following SOLID principles.

(03)

Approach

I built a class hierarchy (abstract Human and Animal, Rider, Manager, Equine and its categories, Capability, Event) organised by namespace. Equine IDs are generated using the required pattern, colours became dedicated classes and setters are private wherever possible. A commented test script with expected results walks through every case.

For the Git interface, I used git-php to list a repository’s branches, show the current one, switch between them and run a merge, with a configurable list of repository paths. That second project stayed at the experiment stage.

(04) — Results

Key figures
70
commits across both repositories
4
business rules enforced by exceptions
3
equine categories
2022
year
← Previous project35 · Headless online shop with Strapi and ReactNext project01Custom Next.js intranet for a web agency