Completed
Push — master ( baf846...d56647 )
by Kirill
11s
created

GetGitterRoomId   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 29
rs 10
wmc 2
lcom 0
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 0 11 2
1
<?php
2
3
/**
4
 * This file is part of GitterBot package.
5
 *
6
 * @author butschster <[email protected]>
7
 * @date 20.07.2016 14:44
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Interfaces\Console\Commands;
14
15
use Gitter\Client;
16
use Illuminate\Console\Command;
17
18
/**
19
 * Class StartGitterBot
20
 */
21
class GetGitterRoomId extends Command
22
{
23
    /**
24
     * The name and signature of the console command.
25
     *
26
     * @var string
27
     */
28
    protected $signature = 'gitter:get-room-id {room}';
29
30
31
    /**
32
     * The console command description.
33
     *
34
     * @var string
35
     */
36
    protected $description = 'Get gitter room id by name.';
37
38
    public function handle()
39
    {
40
        $client = new Client(\Config::get('gitter.token'));
41
42
        try {
43
            $result = $client->http->getRoomByUri($this->argument('room'))->wait();
0 ignored issues
show
Bug introduced by
It seems like $this->argument('room') targeting Illuminate\Console\Command::argument() can also be of type array; however, Gitter\Bus\HttpBus::getRoomByUri() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
44
            $this->info("Room ID: {$result->id}");
45
        } catch (\Exception $e) {
46
            $this->info('Room not found');
47
        }
48
    }
49
}