Response::getInfo()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of the Amplexor\XConnect library
4
 *
5
 * @license http://opensource.org/licenses/MIT
6
 * @link https://github.com/amplexor-drupal/xconnect/
7
 * @version 1.0.0
8
 * @package Amplexor.XConnect
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Amplexor\XConnect;
15
16
use Amplexor\XConnect\Response\Info;
17
use Amplexor\XConnect\Response\File\FileInterface;
18
use Amplexor\XConnect\Response\Translations;
19
20
/**
21
 * Class representing a translation response.
22
 */
23
class Response
24
{
25
    /**
26
     * The file that represents the response.
27
     *
28
     * @var FileInterface
29
     */
30
    private $file;
31
32
    /**
33
     * We cache the translations internally.
34
     *
35
     * @var Translations
36
     */
37
    private $translations;
38
39
40
    /**
41
     * Create a new response object by passing the file into it.
42
     *
43
     * @param FileInterface $file
44
     */
45 6
    public function __construct(FileInterface $file)
46
    {
47 6
        $this->file = $file;
48 6
    }
49
50
    /**
51
     * Get the information attached to the response.
52
     *
53
     * @return Info
54
     */
55 3
    public function getInfo()
56
    {
57 3
        return $this->file->getInfo();
58
    }
59
60
    /**
61
     * Get the translations attached to the response.
62
     *
63
     * @return Translations
64
     */
65 3
    public function getTranslations()
66
    {
67 3
        if (!$this->translations) {
68 3
            $this->translations = new Translations($this->file);
69 3
        }
70
71 3
        return $this->translations;
72
    }
73
}
74