Skip to content

Commit

Permalink
Put important public methods at top of class
Browse files Browse the repository at this point in the history
  • Loading branch information
JeroenDeDauw committed Oct 25, 2018
1 parent bcdac30 commit 254eb14
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 87 deletions.
118 changes: 59 additions & 59 deletions src/Values/GlobeCoordinateValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use InvalidArgumentException;

/**
* Represents a latitude-longitude pair with a certain precision on a certain globe.
* Value Object representing a latitude-longitude pair with a certain precision on a certain globe.
*
* @since 0.1
*
Expand Down Expand Up @@ -65,6 +65,64 @@ private function assertIsPrecision( ?float $precision ) {
}
}

public function getLatLong(): LatLongValue {
return $this->latLong;
}

/**
* Returns the precision of the coordinate in degrees, e.g. 0.01.
*/
public function getPrecision(): ?float {
return $this->precision;
}

/**
* Returns the IRI of the globe on which the location resides.
*/
public function getGlobe(): string {
return $this->globe;
}

public function getLatitude(): float {
return $this->latLong->getLatitude();
}

public function getLongitude(): float {
return $this->latLong->getLongitude();
}

/**
* @see \Comparable::equals
*/
public function equals( $target ): bool {
return $target instanceof self
&& $this->latLong->equals( $target->latLong )
&& $this->precision === $target->precision
&& $this->globe === $target->globe;
}

public function getCopy(): self {
return new self(
$this->latLong,
$this->precision,
$this->globe
);
}

/**
* @see Hashable::getHash
*
* @since 2.0
*/
public function getHash(): string {
return md5(
$this->latLong->getLatitude() . '|'
. $this->latLong->getLongitude() . '|'
. $this->precision . '|'
. $this->globe
);
}

/**
* @see Serializable::serialize
*
Expand Down Expand Up @@ -100,53 +158,13 @@ public function getSortKey(): float {
return $this->getLatitude();
}

public function getLatitude(): float {
return $this->latLong->getLatitude();
}

public function getLongitude(): float {
return $this->latLong->getLongitude();
}

/**
* @see DataValue::getValue
*/
public function getValue(): self {
return $this;
}

public function getLatLong(): LatLongValue {
return $this->latLong;
}

/**
* Returns the precision of the coordinate in degrees, e.g. 0.01.
*/
public function getPrecision(): ?float {
return $this->precision;
}

/**
* Returns the IRI of the globe on which the location resides.
*/
public function getGlobe(): string {
return $this->globe;
}

/**
* @see Hashable::getHash
*
* @since 2.0
*/
public function getHash(): string {
return md5(
$this->latLong->getLatitude() . '|'
. $this->latLong->getLongitude() . '|'
. $this->precision . '|'
. $this->globe
);
}

/**
* @see DataValue::getArrayValue
*/
Expand All @@ -164,24 +182,6 @@ public function getArrayValue(): array {
];
}

/**
* @see \Comparable::equals
*/
public function equals( $target ): bool {
return $target instanceof self
&& $this->latLong->equals( $target->latLong )
&& $this->precision === $target->precision
&& $this->globe === $target->globe;
}

public function getCopy(): self {
return new self(
$this->latLong,
$this->precision,
$this->globe
);
}

public function toArray(): array {
return [
'value' => $this->getArrayValue(),
Expand Down
56 changes: 28 additions & 28 deletions src/Values/LatLongValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,34 @@ private function assertIsLongitude( float $longitude ) {
}
}

public function getLatitude(): float {
return $this->latitude;
}

public function getLongitude(): float {
return $this->longitude;
}

/**
* @see \Comparable::equals
*/
public function equals( $target ): bool {
return $target instanceof self
&& $this->latitude === $target->latitude
&& $this->longitude === $target->longitude;
}

/**
* @see \Hashable::getHash
*/
public function getHash(): string {
return md5( serialize( $this ) );
}

public function getCopy(): self {
return new self( $this->latitude, $this->longitude );
}

/**
* @see Serializable::serialize
*
Expand Down Expand Up @@ -93,14 +121,6 @@ public function getValue(): self {
return $this;
}

public function getLatitude(): float {
return $this->latitude;
}

public function getLongitude(): float {
return $this->longitude;
}

/**
* @return float[]
*/
Expand Down Expand Up @@ -139,24 +159,4 @@ public function toArray(): array {
];
}

/**
* @see \Hashable::getHash
*/
public function getHash(): string {
return md5( serialize( $this ) );
}

/**
* @see \Comparable::equals
*/
public function equals( $target ): bool {
return $target instanceof self
&& $this->latitude === $target->latitude
&& $this->longitude === $target->longitude;
}

public function getCopy(): self {
return new self( $this->latitude, $this->longitude );
}

}

0 comments on commit 254eb14

Please sign in to comment.