Passed
Push — master ( 01e76a...f881c5 )
by Leo
01:36
created

Session   A

Complexity

Total Complexity 25

Size/Duplication

Total Lines 117
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 25
dl 0
loc 117
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
D mapSubObjects() 0 48 25
1
<?php
2
3
namespace leocata\M1\Types;
4
5
use leocata\M1\Abstracts\Types;
6
7
/**
8
 * Class Session
9
 * @package leocata\M1\Types
10
 */
11
class Session extends Types
12
{
13
14
    /**
15
     * Session identifier
16
     * @var string
17
     */
18
    public $id;
19
20
    /**
21
     * Session name
22
     * @var string
23
     */
24
    public $name;
25
26
    /**
27
     * Timestamp of session’s start (in milliseconds since 01.01.1970)
28
     * @var integer
29
     */
30
    public $created;
31
32
    /**
33
     * Timestamp of session parameters modification (in milliseconds since 01.01.1970)
34
     * @var integer
35
     */
36
    public $updated;
37
38
    /**
39
     * List of User IDs - current session's members
40
     * @var array
41
     */
42
    public $parties;
43
44
    /**
45
     * User status concerning this session
46
     * @var integer
47
     */
48
    public $status;
49
50
    /**
51
     * List of Admin IDs
52
     * @var array
53
     */
54
    public $admins;
55
56
    /**
57
     * total number of messages in chat
58
     * @var integer
59
     */
60
    public $count;
61
    /**
62
     * Number of new messages
63
     * @var integer
64
     */
65
    public $new;
66
67
    /**
68
     * Timestamp of last message (in milliseconds since 01.01.1970)
69
     * @var integer
70
     */
71
    public $time;
72
73
    /**
74
     * A message may contain one or more subobjects, map them always in this function
75
     *
76
     * @param string $key
77
     * @param array $data
78
     * @return Types
79
     */
80
    protected function mapSubObjects(string $key, array $data): Types
81
    {
82
        switch ($key) {
83
            case 'from':
84
            case 'forward_from':
85
            case 'new_chat_member':
86
            case 'left_chat_member':
87
                return new User($data, $this->logger);
0 ignored issues
show
Bug Best Practice introduced by
The property logger does not exist on leocata\M1\Types\Session. Did you maybe forget to declare it?
Loading history...
Bug introduced by
The type leocata\M1\Types\User was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
88
            case 'new_chat_members':
89
                return new UserArray($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\UserArray was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
90
            case 'photo':
91
            case 'new_chat_photo':
92
                return new PhotoSizeArray($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\PhotoSizeArray was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
93
            case 'chat':
94
            case 'forward_from_chat':
95
                return new Chat($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\Chat was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
96
            case 'reply_to_message':
97
            case 'pinned_message':
98
                return new Message($data, $this->logger);
0 ignored issues
show
Unused Code introduced by
The call to leocata\M1\Types\Message::__construct() has too many arguments starting with $this->logger. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

98
                return /** @scrutinizer ignore-call */ new Message($data, $this->logger);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
99
            case 'entities':
100
                return new MessageEntityArray($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\MessageEntityArray was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
101
            case 'audio':
102
                return new Audio($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\Audio was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
103
            case 'document':
104
                return new Document($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\Document was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
105
            case 'game':
106
                return new Game($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\Game was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
107
            case 'sticker':
108
                return new Sticker($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\Sticker was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
109
            case 'video':
110
                return new Video($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\Video was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
111
            case 'voice':
112
                return new Voice($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\Voice was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
113
            case 'video_note':
114
                return new VideoNote($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\VideoNote was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
115
            case 'contact':
116
                return new Contact($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\Contact was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
117
            case 'location':
118
                return new Location($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\Location was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
119
            case 'venue':
120
                return new Venue($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\Venue was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
121
            case 'invoice':
122
                return new Invoice($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\Invoice was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
123
            case 'successful_payment':
124
                return new SuccessfulPayment($data, $this->logger);
0 ignored issues
show
Bug introduced by
The type leocata\M1\Types\SuccessfulPayment was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
125
        }
126
        // Return always null if none of the objects above matches
127
        return parent::mapSubObjects($key, $data);
128
    }
129
}
130