Completed
Push — master ( 5edef7...e95395 )
by Mattias
02:05
created

BotFactory::createWithToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 9
rs 9.6666
c 1
b 0
f 1
ccs 4
cts 4
cp 1
cc 1
eloc 4
nc 1
nop 1
crap 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