Skip to content

Commit 21c7315

Browse files
Kirill Naumenkojbelien
authored andcommitted
Location "kind" added (#914)
1 parent 5e354bf commit 21c7315

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

Model/YandexAddress.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@ final class YandexAddress extends Address
3131
*/
3232
private $name;
3333

34+
/**
35+
* The kind of this location.
36+
*
37+
* @var string|null
38+
*/
39+
private $kind;
40+
3441
/**
3542
* @return null|string
3643
*/
@@ -72,4 +79,25 @@ public function withName(string $name = null): self
7279

7380
return $new;
7481
}
82+
83+
/**
84+
* @return string|null
85+
*/
86+
public function getKind(): string
87+
{
88+
return $this->kind;
89+
}
90+
91+
/**
92+
* @param string|null $kind
93+
*
94+
* @return YandexAddress
95+
*/
96+
public function withKind(string $kind = null): self
97+
{
98+
$new = clone $this;
99+
$new->kind = $kind;
100+
101+
return $new;
102+
}
75103
}

Tests/YandexTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,5 +416,6 @@ public function testReverseMetroStationToGetName()
416416
/** @var YandexAddress $first */
417417
$first = $results->first();
418418
$this->assertEquals('метро Озерки', $first->getName());
419+
$this->assertEquals('metro', $first->getKind());
419420
}
420421
}

Yandex.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ function ($value, $key) use (&$flatArray) {
168168
$location = $builder->build(YandexAddress::class);
169169
$location = $location->withPrecision(isset($flatArray['precision']) ? $flatArray['precision'] : null);
170170
$location = $location->withName(isset($flatArray['name']) ? $flatArray['name'] : null);
171+
$location = $location->withKind($flatArray['kind'] ?? null);
171172
$locations[] = $location;
172173
}
173174

0 commit comments

Comments
 (0)