Completed
Push — feature/improve-code ( e986a1...36787d )
by Avtandil
14:14
created

PhotoSize   A

Complexity

Total Complexity 12

Size/Duplication

Total Lines 89
Duplicated Lines 60.67 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 75%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 12
c 3
b 0
f 0
lcom 0
cbo 2
dl 54
loc 89
rs 10
ccs 9
cts 12
cp 0.75

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFileId() 0 4 1
A getWidth() 0 4 1
A getHeight() 0 4 1
A getFileSize() 0 4 1
B __construct() 20 20 8

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * This file is part of the TelegramBot package.
4
 *
5
 * (c) Avtandil Kikabidze aka LONGMAN <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Longman\TelegramBot\Entities;
12
13
use Longman\TelegramBot\Exception\TelegramException;
14
15 View Code Duplication
class PhotoSize extends Entity
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    /**
18
     * @var mixed|null
19
     */
20
    protected $file_id;
21
22
    /**
23
     * @var mixed|null
24
     */
25
    protected $width;
26
27
    /**
28
     * @var mixed|null
29
     */
30
    protected $height;
31
32
    /**
33
     * @var mixed|null
34
     */
35
    protected $file_size;
36
37
    /**
38
     * PhotoSize constructor.
39
     *
40
     * @param array $data
41
     * @throws \Longman\TelegramBot\Exception\TelegramException
42
     */
43 1
    public function __construct(array $data)
44
    {
45
46 1
        $this->file_id = isset($data['file_id']) ? $data['file_id'] : null;
47 1
        if (empty($this->file_id)) {
48
            throw new TelegramException('file_id is empty!');
49
        }
50
51 1
        $this->width = isset($data['width']) ? $data['width'] : null;
52 1
        if (empty($this->width)) {
53
            throw new TelegramException('width is empty!');
54
        }
55
56 1
        $this->height = isset($data['height']) ? $data['height'] : null;
57 1
        if (empty($this->height)) {
58
            throw new TelegramException('height is empty!');
59
        }
60
61 1
        $this->file_size = isset($data['file_size']) ? $data['file_size'] : null;
62 1
    }
63
64
    /**
65
     * Get file id
66
     *
67
     * @return mixed|null
68
     */
69
    public function getFileId()
70
    {
71
        return $this->file_id;
72
    }
73
74
    /**
75
     * Get width
76
     *
77
     * @return mixed|null
78
     */
79
    public function getWidth()
80
    {
81
        return $this->width;
82
    }
83
84
    /**
85
     * Get height
86
     *
87
     * @return mixed|null
88
     */
89
    public function getHeight()
90
    {
91
        return $this->height;
92
    }
93
94
    /**
95
     * Get file size
96
     *
97
     * @return mixed|null
98
     */
99
    public function getFileSize()
100
    {
101
        return $this->file_size;
102
    }
103
}
104