O.C.P

This code is following O.C.P?
mail@pastecode.io avatar
unknown
php
a month ago
726 B
17
Indexable
Never
<?php

class Game
{
    private function move(string $direction)
    {
        // loop logic that needs a index for different directions
    }

    private function getIndexFromDirection(int $counter1, int $counter2): int
    {
        return match ($direction) {
            'up' => , // logic
            'down' => , // logic
            'left' => , // logic
            'right' => , // logic
            default => , // exception
        };
    }

    public function up()
    {
        $this->move('up');
    }

    public function down()
    {
        $this->move('down');
    }

    public function left()
    {
        $this->move('left');
    }

    public function right()
    {
        $this->move('right');
    }
}
Leave a Comment