Code Duplication    Length = 16-16 lines in 2 locations

src/Commands/CommandBus.php 1 location

@@ 74-89 (lines=16) @@
71
     */
72
    public function addCommand($command)
73
    {
74
        if (!is_object($command)) {
75
            if (!class_exists($command)) {
76
                throw new TelegramSDKException(
77
                    sprintf(
78
                        'Command class "%s" not found! Please make sure the class exists.',
79
                        $command
80
                    )
81
                );
82
            }
83
84
            if ($this->telegram->hasContainer()) {
85
                $command = $this->buildDependencyInjectedAnswer($command);
86
            } else {
87
                $command = new $command();
88
            }
89
        }
90
91
        if ($command instanceof CommandInterface) {
92

src/Conversations/ConversationBus.php 1 location

@@ 59-74 (lines=16) @@
56
     */
57
    public function addConversation($conversation)
58
    {
59
        if (!is_object($conversation)) {
60
            if (!class_exists($conversation)) {
61
                throw new TelegramSDKException(
62
                    sprintf(
63
                        'Conversation class "%s" not found! Please make sure the class exists.',
64
                        $conversation
65
                    )
66
                );
67
            }
68
69
            if ($this->telegram->hasContainer()) {
70
                $conversation = $this->buildDependencyInjectedAnswer($conversation);
71
            } else {
72
                $conversation = new $conversation();
73
            }
74
        }
75
76
        if ($conversation instanceof ConversationInterface) {
77
            /*