Completed
Push — develop ( db9af5...942a5f )
by Mattias
05:43
created

BotFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 25
rs 10
c 1
b 0
f 1
ccs 11
cts 11
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A createWithToken() 0 9 1
1
<?php
2
3
namespace TelegramBot;
4
5
class BotFactory
6
{
7
8 2
    public function __construct($loop)
9
    {
10 2
      $this->resolverFactory = new \React\Dns\Resolver\Factory();
0 ignored issues
show
Bug introduced by
The property resolverFactory does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
11 2
      $this->resolver = $this->resolverFactory->create('8.8.8.8', $loop);
0 ignored issues
show
Bug introduced by
The property resolver does not seem to exist. Did you mean resolverFactory?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
12 2
      $this->HttpClient = (new \React\HttpClient\Factory)->create(
0 ignored issues
show
Bug introduced by
The property HttpClient does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
13 2
        $loop,
14 2
        $this->resolver
0 ignored issues
show
Bug introduced by
The property resolver does not seem to exist. Did you mean resolverFactory?

An attempt at access to an undefined property has been detected. This may either be a typographical error or the property has been renamed but there are still references to its old name.

If you really want to allow access to undefined properties, you can define magic methods to allow access. See the php core documentation on Overloading.

Loading history...
15
      );
16
17 2
    }
18
19
20 1
    public function createWithToken($token)
21
    {
22
23 1
      $apiClient = new APIPollClient($token, $this->HttpClient);
24
25 1
      $bot = new Bot($apiClient);
26
27 1
      return $bot;
28
    }
29
}
30