👉 Go to Summary
There is no wrong or right way, there is our way.
-- Someone
.
.
.
Magic number
WTF!?
class Costumer
{
public float $amount;
public function something()
{
// Ok, and WTF means 98.45 ?
if ($this->amount > 98.45) {
...
}
}
}
Nice!
class Costumer
{
public float $amount;
public const LIMIT = 98.45
public function something()
{
if ($this->amount > self::LIMIT) {
...
}
}
}
Nice!
// If LIMIT is used across codebase put it on `.env`
LIMIT = 98.45
public function something()
{
if ($this->amount > config("app.limit")) {
...
}
}
Top comments (0)