Test Failed
Push — master ( a5a28b...999969 )
by Marcin
02:51
created

DisplayBitmap::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
/**
3
 * Grandstream-XMLApp
4
 *
5
 * Copyright (c) 2017 pudelek.org.pl
6
 *
7
 * @license MIT License (MIT)
8
 *
9
 * For the full copyright and license information, please view source file
10
 * that is bundled with this package in the file LICENSE
11
 *
12
 * @author  Marcin Pudełek <[email protected]>
13
 */
14
15
namespace mrcnpdlk\Grandstream\XMLApp\Application\Model\Display;
16
17
18
use mrcnpdlk\Grandstream\XMLApp\Application\Model\ModelInterface;
19
use mrcnpdlk\Grandstream\XMLApp\Helper\Bitmap;
20
use mrcnpdlk\Grandstream\XMLApp\Helper\Point;
21
use mrcnpdlk\Grandstream\XMLApp\MyXML;
22
23
class DisplayBitmap extends DisplayAbstract implements ModelInterface
24
{
25
    /**
26
     * @var boolean
27
     */
28
    private $isFile;
29
    /**
30
     * @var boolean
31
     */
32
    private $isFlash;
33
    /**
34
     * @var Bitmap
35
     */
36
    private $oBitmap;
37
38
    /**
39
     * DisplayBitmap constructor.
40
     *
41
     * @param \mrcnpdlk\Grandstream\XMLApp\Helper\Point|null $oPoint
42
     * @param Bitmap                                         $oBitmap
43
     */
44
    public function __construct(Point $oPoint = null, Bitmap $oBitmap)
45
    {
46
        parent::__construct($oPoint);
47
        $this->oBitmap = $oBitmap;
48
        $this->isFile  = "false";
0 ignored issues
show
Documentation Bug introduced by
The property $isFile was declared of type boolean, but 'false' is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
49
        $this->isFlash = "false";
0 ignored issues
show
Documentation Bug introduced by
The property $isFlash was declared of type boolean, but 'false' is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
50
51
    }
52
53
    /**
54
     * @return \mrcnpdlk\Grandstream\XMLApp\MyXML
55
     */
56
    public function getXml() : MyXML
57
    {
58
        $oXml = new MyXML('DisplayBitmap');
59
60
        $oXml->asObject()->addAttribute('isfile', $this->isFile);
61
        $oXml->asObject()->addAttribute('isflash', $this->isFlash);
62
        $oXml->asObject()->addChild('X', $this->getPoint()->getX());
63
        $oXml->asObject()->addChild('Y', $this->getPoint()->getX());
64
        $oXml->asObject()->addChild('Bitmap', $this->oBitmap->get());
65
66
        return $oXml;
67
    }
68
}
69