Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf67d698

Browse files
committed
Creating interfaces to be more SOLID
1 parent7e5cad1 commitf67d698

File tree

47 files changed

+561
-218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+561
-218
lines changed

‎src/Geocoder/Dumper/Dumper.php‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespaceGeocoder\Dumper;
1212

1313
useGeocoder\Model\Address;
14+
useGeocoder\Model\Position;
1415

1516
/**
1617
* @author William Durand <william.durand1@gmail.com>
@@ -21,9 +22,9 @@ interface Dumper
2122
* Dumps an `Address` object as a string representation of
2223
* the implemented format.
2324
*
24-
* @paramAddress $address
25+
* @paramPosition $address
2526
*
2627
* @return string
2728
*/
28-
publicfunctiondump(Address$address);
29+
publicfunctiondump(Position$address);
2930
}

‎src/Geocoder/Dumper/GeoJson.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespaceGeocoder\Dumper;
1212

1313
useGeocoder\Model\Address;
14+
useGeocoder\Model\Position;
1415

1516
/**
1617
* @author Jan Sorgalla <jsorgalla@googlemail.com>
@@ -20,7 +21,7 @@ class GeoJson implements Dumper
2021
/**
2122
* {@inheritDoc}
2223
*/
23-
publicfunctiondump(Address$address)
24+
publicfunctiondump(Position$address)
2425
{
2526
$properties =array_filter($address->toArray(),function ($value) {
2627
return !empty($value);

‎src/Geocoder/Dumper/Gpx.php‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,19 @@
1212

1313
useGeocoder\Geocoder;
1414
useGeocoder\Model\Address;
15+
useGeocoder\Model\Position;
1516

1617
/**
1718
* @author William Durand <william.durand1@gmail.com>
1819
*/
1920
class Gpximplements Dumper
2021
{
2122
/**
22-
* @paramAddress $address
23+
* @paramPosition $address
2324
*
2425
* @return string
2526
*/
26-
publicfunctiondump(Address$address)
27+
publicfunctiondump(Position$address)
2728
{
2829
$gpx =sprintf(<<<GPX
2930
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
@@ -63,11 +64,11 @@ public function dump(Address $address)
6364
}
6465

6566
/**
66-
* @paramAddress $address
67+
* @paramPosition $address
6768
*
6869
* @return string
6970
*/
70-
protectedfunctionformatName(Address$address)
71+
protectedfunctionformatName(Position$address)
7172
{
7273
$name = [];
7374
$array =$address->toArray();

‎src/Geocoder/Dumper/Kml.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespaceGeocoder\Dumper;
1212

1313
useGeocoder\Model\Address;
14+
useGeocoder\Model\Position;
1415

1516
/**
1617
* @author Jan Sorgalla <jsorgalla@googlemail.com>
@@ -20,7 +21,7 @@ class Kml extends Gpx implements Dumper
2021
/**
2122
* {@inheritDoc}
2223
*/
23-
publicfunctiondump(Address$address)
24+
publicfunctiondump(Position$address)
2425
{
2526
$name =$this->formatName($address);
2627
$kml =<<<KML

‎src/Geocoder/Dumper/Wkb.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespaceGeocoder\Dumper;
1212

1313
useGeocoder\Model\Address;
14+
useGeocoder\Model\Position;
1415

1516
/**
1617
* @author Jan Sorgalla <jsorgalla@googlemail.com>
@@ -20,7 +21,7 @@ class Wkb implements Dumper
2021
/**
2122
* {@inheritDoc}
2223
*/
23-
publicfunctiondump(Address$address)
24+
publicfunctiondump(Position$address)
2425
{
2526
returnpack('cLdd',1,1,$address->getLongitude(),$address->getLatitude());
2627
}

‎src/Geocoder/Dumper/Wkt.php‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
namespaceGeocoder\Dumper;
1212

1313
useGeocoder\Model\Address;
14+
useGeocoder\Model\Position;
1415

1516
/**
1617
* @author Jan Sorgalla <jsorgalla@googlemail.com>
@@ -20,7 +21,7 @@ class Wkt implements Dumper
2021
/**
2122
* {@inheritDoc}
2223
*/
23-
publicfunctiondump(Address$address)
24+
publicfunctiondump(Position$address)
2425
{
2526
returnsprintf('POINT(%F %F)',$address->getLongitude(),$address->getLatitude());
2627
}

‎src/Geocoder/Formatter/StringFormatter.php‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@
1111
namespaceGeocoder\Formatter;
1212

1313
useGeocoder\Model\Address;
14+
useGeocoder\Model\Position;
1415
useGeocoder\Model\AdminLevel;
15-
useGeocoder\Model\AdminLevelCollection;
16+
useGeocoder\Model\AdminLevelCollectionInterface;
1617

1718
/**
1819
* @author William Durand <william.durand1@gmail.com>
@@ -42,12 +43,12 @@ class StringFormatter
4243
/**
4344
* Transform an `Address` instance into a string representation.
4445
*
45-
* @paramAddress $address
46-
* @param string$format
46+
* @paramPosition $address
47+
* @param string $format
4748
*
4849
* @return string
4950
*/
50-
publicfunctionformat(Address$address,$format)
51+
publicfunctionformat(Position$address,$format)
5152
{
5253
$replace = [
5354
self::STREET_NUMBER =>$address->getStreetNumber(),
@@ -60,7 +61,7 @@ public function format(Address $address, $format)
6061
self::TIMEZONE =>$address->getTimezone(),
6162
];
6263

63-
for ($level =1;$level <=AdminLevelCollection::MAX_LEVEL_DEPTH;$level ++) {
64+
for ($level =1;$level <=AdminLevelCollectionInterface::MAX_LEVEL_DEPTH;$level ++) {
6465
$replace[self::ADMIN_LEVEL .$level] =null;
6566
$replace[self::ADMIN_LEVEL_CODE .$level] =null;
6667
}

‎src/Geocoder/Geocoder.php‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
namespaceGeocoder;
1212

13-
useGeocoder\Model\AddressCollection;
14-
1513
/**
1614
* @author William Durand <william.durand1@gmail.com>
1715
*/
@@ -27,7 +25,7 @@ interface Geocoder
2725
*
2826
* @param string $value
2927
*
30-
* @returnAddressCollection
28+
* @returnGeocoderResult
3129
* @throws Geocoder\Exception\Exception
3230
*/
3331
publicfunctiongeocode($value);
@@ -38,7 +36,7 @@ public function geocode($value);
3836
* @param double $latitude
3937
* @param double $longitude
4038
*
41-
* @returnAddressCollection
39+
* @returnGeocoderResult
4240
* @throws Geocoder\Exception\Exception
4341
*/
4442
publicfunctionreverse($latitude,$longitude);

‎src/Geocoder/GeocoderResult.php‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?php
2+
namespaceGeocoder;
3+
4+
useGeocoder\Model\Position;
5+
6+
/**
7+
* This is the interface that is always return from a geocoder.
8+
*/
9+
interface GeocoderResultextends \IteratorAggregate, \Countable
10+
{
11+
/**
12+
* {@inheritDoc}
13+
*/
14+
publicfunctiongetIterator();
15+
16+
/**
17+
* {@inheritDoc}
18+
*/
19+
publicfunctioncount();
20+
21+
/**
22+
* @return Position
23+
*/
24+
publicfunctionfirst();
25+
26+
/**
27+
* @return Position[]
28+
*/
29+
publicfunctionslice($offset,$length =null);
30+
31+
/**
32+
* @return bool
33+
*/
34+
publicfunctionhas($index);
35+
36+
/**
37+
* @return Position
38+
* @throws \OutOfBoundsException
39+
*/
40+
publicfunctionget($index);
41+
42+
/**
43+
* @return Position[]
44+
*/
45+
publicfunctionall();
46+
}

‎src/Geocoder/Model/Address.php‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@
1313
/**
1414
* @author William Durand <william.durand1@gmail.com>
1515
*/
16-
finalclass Address
16+
finalclass Addressimplements Position
1717
{
1818
/**
19-
* @varCoordinates
19+
* @varCoordinatesInterface
2020
*/
2121
private$coordinates;
2222

2323
/**
24-
* @varBounds
24+
* @varBoundsInterface
2525
*/
2626
private$bounds;
2727

@@ -51,12 +51,12 @@ final class Address
5151
private$postalCode;
5252

5353
/**
54-
* @varAdminLevelCollection
54+
* @varAdminLevelCollectionInterface
5555
*/
5656
private$adminLevels;
5757

5858
/**
59-
* @varCountry
59+
* @varCountryInterface
6060
*/
6161
private$country;
6262

@@ -73,15 +73,15 @@ final class Address
7373
* @param string $subLocality
7474
*/
7575
publicfunction__construct(
76-
Coordinates$coordinates =null,
77-
Bounds$bounds =null,
76+
CoordinatesInterface$coordinates =null,
77+
BoundsInterface$bounds =null,
7878
$streetNumber =null,
7979
$streetName =null,
8080
$postalCode =null,
8181
$locality =null,
8282
$subLocality =null,
83-
AdminLevelCollection$adminLevels =null,
84-
Country$country =null,
83+
AdminLevelCollectionInterface$adminLevels =null,
84+
CountryInterface$country =null,
8585
$timezone =null
8686
) {
8787
$this->coordinates =$coordinates;
@@ -99,7 +99,7 @@ public function __construct(
9999
/**
100100
* Returns an array of coordinates (latitude, longitude).
101101
*
102-
* @returnCoordinates
102+
* @returnCoordinatesInterface
103103
*/
104104
publicfunctiongetCoordinates()
105105
{
@@ -137,7 +137,7 @@ public function getLongitude()
137137
/**
138138
* Returns the bounds value.
139139
*
140-
* @returnBounds
140+
* @returnBoundsInterface
141141
*/
142142
publicfunctiongetBounds()
143143
{
@@ -198,7 +198,7 @@ public function getSubLocality()
198198
/**
199199
* Returns the administrative levels.
200200
*
201-
* @returnAdminLevelCollection
201+
* @returnAdminLevelCollectionInterface
202202
*/
203203
publicfunctiongetAdminLevels()
204204
{
@@ -208,7 +208,7 @@ public function getAdminLevels()
208208
/**
209209
* Returns the country value.
210210
*
211-
* @returnCountry
211+
* @returnCountryInterface
212212
*/
213213
publicfunctiongetCountry()
214214
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp