lundi 15 juin 2015

How to extract business logic in this example

The following method filters a data collection based on order statuses. Im wondering what would be the best way to extract the business logic held within about the order statuses. For example, say the order statuses were to change down the line i.e. ('in_transit', 'at_courier') then this method, and associated tests would all need amended:

interface extractor {
    public function extract();
}

class ShippedOrderExtractor implements extractor {

    public function extract()
    {
        $dataCollection = $this->source->filter(
            array(
                'state_one' => 'shipped',
                'state_two' => 'with_courier'
            )
        );

        return $dataCollection;
    }
}

Aucun commentaire:

Enregistrer un commentaire