BookMarkFormat   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 3
dl 0
loc 28
ccs 0
cts 10
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 6 2
A getText() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the 2amigos/qrcode-library 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 https://www.2amigos.us/
22
 * @package Da\QrCode\Format
23
 */
24
class BookMarkFormat extends AbstractFormat
25
{
26
    use UrlTrait;
27
28
    /**
29
     * @var string bookmark title
30
     */
31
    public $title;
32
33
    /**
34
     * @inheritdoc
35
     * @throws InvalidConfigException
36
     */
37
    public function init(): void
38
    {
39
        if ($this->url === null) {
40
            throw new InvalidConfigException("'url' cannot be empty.");
41
        }
42
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47
    public function getText(): string
48
    {
49
        return "MEBKM:TITLE:{$this->title};URL:{$this->url};;";
50
    }
51
}
52