<?php

namespace FullyBaked\Pslackr\Messages;

class CustomMessage implements Message
{
    protected $text;

    protected $optionalFields = [];

    public function __construct($messageText)
    {
        $this->text = $messageText;
    }
    public function asJson()
    {
        $message = ['text' => 'This is a test message'];

        $message = array_merge($message, $this->optionalFields);

        return json_encode($message);
    }

    public function channel($channelName)
    {
        $this->optionalFields['channel'] = $channelName;
    }

    public function username($username)
    {
        $this->optionalFields['username'] = $username;
    }

    public function iconEmoji($token)
    {
        $this->optionalFields['icon_emoji'] = $token;
    }

    public function iconUrl($url)
    {
        $this->optionalFields['icon_url'] = $url;
    }
}

<?php

namespace FullyBaked\Pslackr\Messages;

class CustomMessage implements Message
{
    protected $text;

    public function asJson()
    {
        $message = [
            'text' => $this->text
        ];
        return json_encode($message);
    }

    public function text($text)
    {
        $this->text = $text;
    }


}

--- 
+++ 
@@ -6,18 +6,38 @@
 {
     protected $text;
 
+    protected $optionalFields = [];
+
+    public function __construct($messageText)
+    {
+        $this->text = $messageText;
+    }
     public function asJson()
     {
-        $message = [
-            'text' => $this->text
-        ];
+        $message = ['text' => 'This is a test message'];
+
+        $message = array_merge($message, $this->optionalFields);
+
         return json_encode($message);
     }
 
-    public function text($text)
+    public function channel($channelName)
     {
-        $this->text = $text;
+        $this->optionalFields['channel'] = $channelName;
     }
 
+    public function username($username)
+    {
+        $this->optionalFields['username'] = $username;
+    }
 
+    public function iconEmoji($token)
+    {
+        $this->optionalFields['icon_emoji'] = $token;
+    }
+
+    public function iconUrl($url)
+    {
+        $this->optionalFields['icon_url'] = $url;
+    }
 }
Implement setter methods for optional params
