Completed
Push — master ( 6ffc3f...4609e3 )
by Antonio
51:14 queued 46:44
created

BookMarkFormat::init()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 0
crap 6
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/yii2-qrcode-component project.
5
 *
6
 * (c) 2amigOS! <http://2amigos.us/>
7
 *
8
 * For the full copyright and license information, please view
9
 * the LICENSE file that was distributed with this source code.
10
 */
11
12
namespace Da\QrCode\Format;
13
14
use Da\QrCode\Exception\InvalidConfigException;
15
use Da\QrCode\Traits\UrlTrait;
16
17
/**
18
 * Class BookMark formats a string to properly create a Bookmark QrCode
19
 *
20
 * @author Antonio Ramirez <[email protected]>
21
 * @link http://www.ramirezcobos.com/
22
 * @link http://www.2amigos.us/
23
 * @package Da\QrCode\Format
24
 */
25
class BookMarkFormat extends AbstractFormat
26
{
27
    use UrlTrait;
28
29
    /**
30
     * @var string bookmark title
31
     */
32
    public $title;
33
34
    /**
35
     * @inheritdoc
36
     * @throws InvalidConfigException
37
     */
38
    public function init()
39
    {
40
        if ($this->url === null) {
41
            throw new InvalidConfigException("'url' cannot be empty.");
42
        }
43
    }
44
45
    /**
46
     * @inheritdoc
47
     */
48
    public function getText()
49
    {
50
        return "MEBKM:TITLE:{$this->title};URL:{$this->url};;";
51
    }
52
}
53