Completed
Push — master ( e6cea0...5c122a )
by Marcin
01:53
created

ElemBitmap::getXml()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
crap 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\Components;
16
17
18
use mrcnpdlk\Grandstream\XMLApp\Application\ModelInterface;
19
use mrcnpdlk\Grandstream\XMLApp\MyXML;
20
21
/**
22
 * Class ElemBitmap
23
 *
24
 * This element is to display a bitmap picture on the screen. Inside the <Bitmap> tag of the XML document,
25
 * the picture must be encoded in base64 format already. There are plenty of base64 encoder online
26
 * provided for encoding the .bmp picture. Please make sure the original .bmp picture is in monochrome grey
27
 * level 8 before encoding
28
 *
29
 * <ElemBitmap isfile="true/false" isflash=”true/false”>
30
 * <Bitmap> Bitmap file encoded in base64 format </Bitmap>
31
 * <X> X location </X>
32
 * <Y> Y location </Y>
33
 * </ElemBitmap
34
 *
35
 * @package mrcnpdlk\Grandstream\XMLApp\Application\Model\Components
36
 */
37
class ElemBitmap extends ElemAbstract implements ModelInterface, ElemInterface
38
{
39
    /**
40
     * @var boolean
41
     */
42
    private $isFile;
43
    /**
44
     * @var boolean
45
     */
46
    private $isFlash;
47
    /**
48
     * @var string
49
     */
50
    private $sBitmap;
51
52
    /**
53
     * ElemBitmap constructor.
54
     *
55
     * @param string $sBitmap
56
     */
57
    public function __construct(string $sBitmap)
58
    {
59
        parent::__construct();
60
        $this->sBitmap = $sBitmap;
61
        $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...
62
        $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...
63
64
    }
65
66
    /**
67
     * @return \mrcnpdlk\Grandstream\XMLApp\MyXML
68
     */
69
    public function getXml(): MyXML
70
    {
71
        $oXml = new MyXML('Bitmap');
72
73
        $oXml->asObject()->addAttribute('isfile', $this->isFile);
74
        $oXml->asObject()->addAttribute('isflash', $this->isFlash);
75
        $oXml->asObject()->addChild('X', $this->getPoint()->getX());
76
        $oXml->asObject()->addChild('Y', $this->getPoint()->getX());
77
        $oXml->asObject()->addChild('Bitmap', $this->sBitmap);
78
79
        return $oXml;
80
    }
81
}
82