Skip to content

Commit

Permalink
Update Docblock
Browse files Browse the repository at this point in the history
  • Loading branch information
kamshory committed Nov 26, 2024
1 parent fcee997 commit 723139f
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 33 deletions.
54 changes: 27 additions & 27 deletions src/Geometry/LatLngBounds.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ class LatLngBounds
/**
* @var LatBounds The latitude bounds of the bounding box.
*/
protected $_LatBounds; // NOSONAR
protected $_latBounds; // NOSONAR

/**
* @var LngBounds The longitude bounds of the bounding box.
*/
protected $_LngBounds; // NOSONAR
protected $_lngBounds; // NOSONAR

/**
* LatLngBounds constructor.
Expand All @@ -48,26 +48,26 @@ public function __construct($latLngSw = null, $tatLngNe = null)
{
$sw = SphericalGeometry::clampLatitude($latLngSw->getLat());
$ne = SphericalGeometry::clampLatitude($tatLngNe->getLat());
$this->_LatBounds = new LatBounds($sw, $ne);
$this->_latBounds = new LatBounds($sw, $ne);

$sw = $latLngSw->getLng();
$ne = $tatLngNe->getLng();

if ($ne - $sw >= 360)
{
$this->_LngBounds = new LngBounds(-180, 180);
$this->_lngBounds = new LngBounds(-180, 180);
}
else
{
$sw = SphericalGeometry::wrapLongitude($latLngSw->getLng());
$ne = SphericalGeometry::wrapLongitude($tatLngNe->getLng());
$this->_LngBounds = new LngBounds($sw, $ne);
$this->_lngBounds = new LngBounds($sw, $ne);
}
}
else
{
$this->_LatBounds = new LatBounds(1, -1);
$this->_LngBounds = new LngBounds(180, -180);
$this->_latBounds = new LatBounds(1, -1);
$this->_lngBounds = new LngBounds(180, -180);
}
}

Expand All @@ -78,7 +78,7 @@ public function __construct($latLngSw = null, $tatLngNe = null)
*/
public function getLatBounds()
{
return $this->_LatBounds;
return $this->_latBounds;
}

/**
Expand All @@ -88,7 +88,7 @@ public function getLatBounds()
*/
public function getLngBounds()
{
return $this->_LngBounds;
return $this->_lngBounds;
}

/**
Expand All @@ -98,7 +98,7 @@ public function getLngBounds()
*/
public function getCenter()
{
return new LatLng($this->_LatBounds->getMidpoint(), $this->_LngBounds->getMidpoint());
return new LatLng($this->_latBounds->getMidpoint(), $this->_lngBounds->getMidpoint());
}

/**
Expand All @@ -108,7 +108,7 @@ public function getCenter()
*/
public function isEmpty()
{
return $this->_LatBounds->isEmpty() || $this->_LngBounds->isEmpty();
return $this->_latBounds->isEmpty() || $this->_lngBounds->isEmpty();
}

/**
Expand All @@ -118,7 +118,7 @@ public function isEmpty()
*/
public function getSouthWest()
{
return new LatLng($this->_LatBounds->getSw(), $this->_LngBounds->getSw(), true);
return new LatLng($this->_latBounds->getSw(), $this->_lngBounds->getSw(), true);
}

/**
Expand All @@ -128,7 +128,7 @@ public function getSouthWest()
*/
public function getNorthEast()
{
return new LatLng($this->_LatBounds->getNe(), $this->_LngBounds->getNe(), true);
return new LatLng($this->_latBounds->getNe(), $this->_lngBounds->getNe(), true);
}

/**
Expand All @@ -138,19 +138,19 @@ public function getNorthEast()
*/
public function toSpan()
{
if ($this->_LatBounds->isEmpty()) {
if ($this->_latBounds->isEmpty()) {
$lat = 0;
} else {
$lat = $this->_LatBounds->getNe() - $this->_LatBounds->getSw();
$lat = $this->_latBounds->getNe() - $this->_latBounds->getSw();
}

if ($this->_LngBounds->isEmpty()) {
if ($this->_lngBounds->isEmpty()) {
$lng = 0;
} else {
if ($this->_LngBounds->getSw() > $this->_LngBounds->getNe()) {
$lng = 360 - ($this->_LngBounds->getSw() - $this->_LngBounds->getNe());
if ($this->_lngBounds->getSw() > $this->_lngBounds->getNe()) {
$lng = 360 - ($this->_lngBounds->getSw() - $this->_lngBounds->getNe());
} else {
$lng = $this->_LngBounds->getNe() - $this->_LngBounds->getSw();
$lng = $this->_lngBounds->getNe() - $this->_lngBounds->getSw();
}
}

Expand Down Expand Up @@ -190,8 +190,8 @@ public function equals($latLngBounds)
{
return !$latLngBounds
? false
: $this->_LatBounds->equals($latLngBounds->getLatBounds())
&& $this->_LngBounds->equals($latLngBounds->getLngBounds());
: $this->_latBounds->equals($latLngBounds->getLatBounds())
&& $this->_lngBounds->equals($latLngBounds->getLngBounds());
}

/**
Expand All @@ -202,8 +202,8 @@ public function equals($latLngBounds)
*/
public function intersects($latLngBounds)
{
return $this->_LatBounds->intersects($latLngBounds->getLatBounds())
&& $this->_LngBounds->intersects($latLngBounds->getLngBounds());
return $this->_latBounds->intersects($latLngBounds->getLatBounds())
&& $this->_lngBounds->intersects($latLngBounds->getLngBounds());
}

/**
Expand All @@ -227,8 +227,8 @@ public function union($latLngBounds)
*/
public function contains($latLng)
{
return $this->_LatBounds->contains($latLng->getLat())
&& $this->_LngBounds->contains($latLng->getLng());
return $this->_latBounds->contains($latLng->getLat())
&& $this->_lngBounds->contains($latLng->getLng());
}

/**
Expand All @@ -239,8 +239,8 @@ public function contains($latLng)
*/
public function extend($latLng)
{
$this->_LatBounds->extend($latLng->getLat());
$this->_LngBounds->extend($latLng->getLng());
$this->_latBounds->extend($latLng->getLat());
$this->_lngBounds->extend($latLng->getLng());
return $this;
}
}
6 changes: 4 additions & 2 deletions src/Geometry/Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace MagicObject\Geometry;

use InvalidArgumentException;

/**
* Class representing a Line with two Point objects.
*
Expand Down Expand Up @@ -33,11 +35,11 @@ class Line {
*
* @param Point $a Point A.
* @param Point $b Point B.
* @throws \InvalidArgumentException If the parameters are not instances of Point.
* @throws InvalidArgumentException If the parameters are not instances of Point.
*/
public function __construct($a, $b) {
if (!$a instanceof Point || !$b instanceof Point) {
throw new \InvalidArgumentException('Both parameters must be instances of Point.');
throw new InvalidArgumentException('Both parameters must be instances of Point.');
}
$this->a = $a;
$this->b = $b;
Expand Down
6 changes: 4 additions & 2 deletions src/Geometry/Point.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace MagicObject\Geometry;

use InvalidArgumentException;

/**
* Class representing a Point with x and y coordinates.
*
Expand Down Expand Up @@ -48,13 +50,13 @@ public function __construct($x, $y)
*
* @param Point $p Another Point.
* @return float The distance between the two Points.
* @throws \InvalidArgumentException If the argument is not of type Point.
* @throws InvalidArgumentException If the argument is not of type Point.
*/
public function distanceFrom($p)
{
// Ensure $p is an instance of Point
if (!$p instanceof Point) {
throw new \InvalidArgumentException('Argument must be of type Point.');
throw new InvalidArgumentException('Argument must be of type Point.');
}

$dx = $this->x - $p->x;
Expand Down
3 changes: 2 additions & 1 deletion src/Util/PicoYamlUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use RecursiveArrayIterator;
use RecursiveIteratorIterator;
use Symfony\Component\Yaml\Yaml;
use Symfony\Component\Yaml\Exception\InvalidTypeException;

/**
* Class PicoYamlUtil
Expand Down Expand Up @@ -85,7 +86,7 @@ public static function arrayDepth($array) {
* @param int $flags A bit field of DUMP_* constants to customize the dumped YAML string.
*
* @return string A YAML string representing the original PHP value.
* @throws \Symfony\Component\Yaml\Exception\InvalidTypeException If the input is an unsupported type.
* @throws InvalidTypeException If the input is an unsupported type.
*/
public static function dump($input, $inline, $indent, $flags)
{
Expand Down
1 change: 0 additions & 1 deletion src/Util/TextConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ private function prepareMap()
return call_user_func_array('array_merge', $maps);
}


/**
* Maps an associative array using a callback function.
*
Expand Down

0 comments on commit 723139f

Please sign in to comment.