diff --git a/README.md b/README.md index d09ace4..f46059c 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,22 @@ ## Prayer Times Library (PHP) -This is a PHP edition of the Prayer Times Library (v2.3) originally written in JavaScript by Hamid Zarrabi-Zadeh of PrayTimes.org and available on http://praytimes.org/code/v2/js/PrayTimes.js. +This is a PHP edition of the Prayer Times Library (v2.3) originally written in JavaScript by Hamid Zarrabi-Zadeh of PrayTimes.org and available on http://praytimes.org/code/v2/js/PrayTimes.js. It has divulged much from the original since it was first written, so please don't use it as a 'like for like' substitute - the method names, among others things, are different.. ## How to Use this Library -This is not a composer package, so you need to, for the time being, manually include it in your script. +The library is a composer package, so to install it, run: ``` +composer require meezaan/prayer-times +``` + +Using it is rather simple: + +```php getTimes(DateTime $date, $latitude, $longitude, $elevation = null, $pt->tune($imsak = 0, $fajr= 0, $sunrise = 0, $dhuhr = 0, $asr = 0, $maghrib = 0, $sunset = 0, $isha = 0, $midnight = 0); +// Finally, you can also create your own methods: +$method = new Method('My Custom Method'); +$method->setFajrAngle(18); +$method->setMaghribAngleOrMins(19.5); +$method->setIshaAngleOrMins('90 min'); +$method->tuneZhuhr('5 min'); +// And then: +$pt = new PrayerTimes(PrayerTimes::METHOD_CUSTOM); +$pt->setCustomMethod($method); +// And then the same as before: +$times = $pt->getTimesForToday($latitude, $longitude, $timezone, $elevation = null, $latitudeAdjustmentMethod = self::LATITUDE_ADJUSTMENT_METHOD_ANGLE, $midnightMode = self::MIDNIGHT_MODE_STANDARD, $format = self::TIME_FORMAT_24H); + ``` -## Motivation +## Methods + +The following methods are currently supported: -AlAdhan.com uses version one of the PrayerTimes Library from PrayTimes.org. It will now use this updated version. +### Understanding Methods + +For a discussion on methods, see (URL coming soon)). ## Tests @@ -45,4 +67,4 @@ Hamid Zarrabi-Zadeh, Meezaan-ud-Din Abdu Dhil-Jalali Wal-Ikram Same as the original - License: GNU LGPL v3.0, which effectively means: ``` Permission is granted to use this code, with or without modification, in any website or application provided that credit is given to the original work with a link back to PrayTimes.org. -``` \ No newline at end of file +``` diff --git a/src/PrayerTimes/Method.php b/src/PrayerTimes/Method.php index 193dbfe..505474c 100644 --- a/src/PrayerTimes/Method.php +++ b/src/PrayerTimes/Method.php @@ -6,12 +6,28 @@ class Method { + /** + * [$name description] + * @var [type] + */ public $name; + /** + * [$params description] + * @var array + */ public $params = []; + /** + * [$offset description] + * @var array + */ public $offset = []; + /** + * [__construct description] + * @param string $name [description] + */ public function __construct($name = 'Custom') { $this->name = $name; @@ -34,65 +50,30 @@ public function __construct($name = 'Custom') ]; } + /** + * [setFajrAngle description] + * @param [type] $angle [description] + */ public function setFajrAngle($angle) { $this->params[PrayerTimes::FAJR] = $angle; } + /** + * [setMaghribAngleOrMins description] + * @param [type] $angleOrMinsAfterSunset [description] + */ public function setMaghribAngleOrMins($angleOrMinsAfterSunset) { $this->params[PrayerTimes::MAGHRIB] = $angleOrMinsAfterSunset; } + /** + * [setIshaAngleOrMins description] + * @param [type] $angleOrMinsAfterMaghrib [description] + */ public function setIshaAngleOrMins($angleOrMinsAfterMaghrib) { $this->params[PrayerTimes::ISHA] = $angleOrMinsAfterMaghrib; } - /* - public function tuneFajr($mins) - { - $this->offset[PrayerTimes::FAJR] = $mins; - } - - public function tuneZhuhr($mins) - { - $this->offset[PrayerTimes::ZHUHR] = $mins; - } - - public function tuneAsr($mins) - { - $this->offset[PrayerTimes::ASR] = $mins; - } - - public function tuneMaghrib($mins) - { - $this->offset[PrayerTimes::MAGHRIB] = $mins; - } - - public function tuneIsha($mins) - { - $this->offset[PrayerTimes::ISHA] = $mins; - } - - public function tuneSunset($mins) - { - $this->offset[PrayerTimes::SUNSET] = $mins; - } - - public function tuneSunrise($mins) - { - $this->offset[PrayerTimes::SUNRISE] = $mins; - } - - public function tuneImsak($mins) - { - $this->offset[PrayerTimes::IMSAK] = $mins; - - } - - public function tuneMidnight($mins) - { - $this->offset[PrayerTimes::MIDNIGHT] = $mins; - } - */ } diff --git a/src/PrayerTimes/PrayerTimes.php b/src/PrayerTimes/PrayerTimes.php index c11a816..9d4d5c2 100644 --- a/src/PrayerTimes/PrayerTimes.php +++ b/src/PrayerTimes/PrayerTimes.php @@ -172,6 +172,10 @@ public function __construct($method = self::METHOD_MWL, $school = self::SCHOOL_S $this->loadSettings(); } + /** + * [setCustomMethod description] + * @param Method $method [description] + */ public function setCustomMethod(Method $method) { $this->setMethod(self::METHOD_CUSTOM); @@ -181,7 +185,8 @@ public function setCustomMethod(Method $method) } /** - * + * [loadSettings description] + * @return [type] [description] */ private function loadSettings() { @@ -849,16 +854,28 @@ public function loadMethods() ]; } + /** + * [getMethods description] + * @return [type] [description] + */ public function getMethods() { return $this->methods; } + /** + * [getMethod description] + * @return [type] [description] + */ public function getMethod() { return $this->method; } + /** + * [getMeta description] + * @return [type] [description] + */ public function getMeta() { $result = [