mardi 11 août 2020

Collect temp values in other functions

I develop the application with Symfony framework ( use Dependency Injection), assuming that I have three services:

<?php

class ServiceA 
{
    public function funcInServiceA($input) 
    {
        $result = 'something';
        $tempValueA = $input + 'something';
        return $result;
    }
}


class ServiceB
{
    public function funcInServiceB($input) 
    {
        $result = 'something';
        $tempValueB = $input + 'something';
        return $result;
    }
}

class ServiceC
{
    public function funcInServiceC()
    {
        $resultFromA = $this->serviceA->funcInServiceA('input');
        $resultFromB = $this->serviceB->funcInServiceB($resultFromA);
        return $resultFromB;
    }
}

I need to collect $tempValueA, $tempValueB, $resultFromA, $resultFromB for logging, Is there any design pattern or best practice to do that?

Regards,

Aucun commentaire:

Enregistrer un commentaire