BatchResult   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A createFromAddress() 0 7 1
A newInstance() 0 10 1
1
<?php
2
3
/*
4
 * This file is part of the Geotools library.
5
 *
6
 * (c) Antoine Corcy <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace League\Geotools\Batch;
13
14
use Geocoder\Location;
15
16
/**
17
 * BatchResult class
18
 *
19
 * @author Antoine Corcy <[email protected]>
20
 */
21
class BatchResult
22
{
23
    /**
24
     * The name of the provider.
25
     *
26
     * @var string
27
     */
28
    protected $providerName;
29
30
    /**
31
     * The query.
32
     *
33
     * @var string
34
     */
35
    protected $query;
36
37
    /**
38
     * The exception message.
39
     *
40
     * @var string
41
     */
42
    protected $exception;
43
44
45
    /**
46
     * Construct a Geocoded object with the provider name, its query and exception if any.
47
     *
48
     * @param string $providerName The name of the provider.
49
     * @param string $query        The query.
50
     * @param string $exception    The exception message if any.
51
     */
52 16
    public function __construct($providerName, $query, $exception = '')
53
    {
54 16
        $this->providerName = $providerName;
55 16
        $this->query        = $query;
56 16
        $this->exception    = $exception;
57 16
    }
58
59
    /**
60
     * {@inheritDoc}
61
     */
62 8
    public function createFromAddress(Location $address)
63
    {
64 8
        $result = $this->newInstance();
65 8
        $result->setAddress($address);
66
67 8
        return $result;
68
    }
69
70
    /**
71
     * {@inheritDoc}
72
     */
73 16
    public function newInstance()
74
    {
75 16
        $batchGeocoded = new BatchGeocoded;
76
77 16
        $batchGeocoded->setProviderName($this->providerName);
78 16
        $batchGeocoded->setQuery($this->query);
79 16
        $batchGeocoded->setExceptionMessage($this->exception);
80
81 16
        return $batchGeocoded;
82
    }
83
}
84