MeCardFormat   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getText() 0 17 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\Traits\EmailTrait;
15
use Da\QrCode\Traits\UrlTrait;
16
17
/**
18
 * Class MeCard formats a string to properly create a meCard 4.0 QrCode
19
 *
20
 * @property string $email
21
 *
22
* @author Antonio Ramirez <[email protected]>
23
 * @link https://www.2amigos.us/
24
 * @see https://www.nttdocomo.co.jp/english/service/developer/make/content/barcode/function/application/addressbook/index.html
25
 * @package Da\QrCode\Format
26
 *
27
 */
28
class MeCardFormat extends AbstractFormat
29
{
30
    use EmailTrait;
31
    use UrlTrait;
32
33
    /**
34
     * @var string the name
35
     */
36
    public $firstName;
37
    /**
38
     * @var string the full name
39
     */
40
    public $lastName;
41
    /**
42
     * @var string the nickname
43
     */
44
    public $nickName;
45
    /**
46
     * @var string the address
47
     */
48
    public $address;
49
    /**
50
     * @var string designates a text string to be set as the telephone number in the phonebook. (1 to 24 digits)
51
     */
52
    public $phone;
53
    /**
54
     * @var string designates a text string to be set as the videophone number in the phonebook. (1 to 24 digits)
55
     */
56
    public $videoPhone;
57
    /**
58
     * @var string a date in the format YYYY-MM-DD or ISO 860
59
     */
60
    public $birthday;
61
    /**
62
     * @var string designates a text string to be set as the memo in the phonebook. (0 or more characters)
63
     */
64
    public $note;
65
    /**
66
     * @var string designates a text string to be set as the kana name in the phonebook. (0 or more characters)
67
     */
68
    public $sound;
69
70
    /**
71
     * @return string
72
     */
73
    public function getText(): string
74
    {
75
        $data = [];
76
        $data[] = 'MECARD:';
77
        $data[] = "N:{$this->lastName} {$this->firstName};";
78
        $data[] = "SOUND:{$this->sound};";
79
        $data[] = "TEL:{$this->phone};";
80
        $data[] = "TEL-AV:{$this->videoPhone};";
81
        $data[] = "EMAIL:{$this->email};";
82
        $data[] = "NOTE:{$this->note};";
83
        $data[] = "BDAY:{$this->birthday};";
84
        $data[] = "ADR:{$this->address};";
85
        $data[] = "URL:{$this->url};";
86
        $data[] = "NICKNAME:{$this->nickName};;";
87
88
        return implode($data);
89
    }
90
}
91