dazzz1er / confer

Easy real-time chat for laravel 5 based websites and applications
133 stars 47 forks source link

Pointless if else in Message Class for getEventData #21

Closed ericp1337 closed 8 years ago

ericp1337 commented 8 years ago

why is there an if else statement here when both arrays are the same data?

public function getEventData($type = 'private')
    {
        return $type === 'global' ? [
            'conversation' => $this->conversation,
            'message' => $this,
            'sender' => $this->sender
        ] : [
            'conversation' => $this->conversation,
            'message' => $this,
            'sender' => $this->sender
        ];
    }
dazzz1er commented 8 years ago

It's one of those cases where I believe I was originally supplying different data for the conversation types, and when it eventually came about that they send the same data I decided to leave the statement in, as future upgrades to the package will likely force the if else to appear again.

You could definitely argue it is inefficient, wasteful code, and I would agree... but I like the reminder that this is where I can - and where I intend to - differentiate the data in future. It's a form of forward planning for me.