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

MeCardFormat::getText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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