Side note: would you add js at the end of the first triple backticks for each code block? It makes them a little easier to read.
Without it:
private function validate(): void
{
if ($this->car->getColour() !== 'black') {
throw new OrderException('You must order a black car');
}
if ($this->car->getWheelCount() !== 4) {
throw new OrderException('You must order a car with 4 wheels');
}
if ($this->car->getDoorCount() !== 5 && $this->car->getDoorCount() !== 3) {
throw new OrderException('You must order a car with 5 or 3 doors');
}
}
With it:
privatefunctionvalidate():void{if($this->car->getColour()!=='black'){thrownewOrderException('You must order a black car');}if($this->car->getWheelCount()!==4){thrownewOrderException('You must order a car with 4 wheels');}if($this->car->getDoorCount()!==5&&$this->car->getDoorCount()!==3){thrownewOrderException('You must order a car with 5 or 3 doors');}}
I am a developer with a passion for testing. I've been coding for 14 years and I want to share my experience and learnings with other developers to help them write better software.
Thanks for sharing this Rob!
The more I learn about TDD, the more I <3 it.
Side note: would you add
js
at the end of the first triple backticks for each code block? It makes them a little easier to read.Without it:
With it:
Thanks, the back tick thing is strange I noticed it but assumed that it was the styling for the site.
Normally I just put three back ticks followed by php. Maybe that doesn't work on this site. I'll update it to js.
Ah yeah, I also tried using
php
but seems like is not supported yet.