Skip to content

Commit

Permalink
Update to php 7.0 and Raja yoga class
Browse files Browse the repository at this point in the history
  • Loading branch information
kunjara committed Feb 1, 2017
1 parent 77a574b commit 393801b
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 11 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
You can do the following calculations:

* calculation of natal chart and varga charts;
* drawing of natal chart and varga charts;
* calculation of bala: Ashtakavarga, Rashi bala, Graha bala;
* calculation of dasha: Vimshotari, Ashtottari;
* calculation Panchanga: Nakshatra, Yoga, Tithi, Vara, Karana;
Expand All @@ -16,7 +15,7 @@ You can do the following calculations:

## System Requirements

Jyotish library requires PHP 5.6 or later.
Jyotish library requires PHP 7.0 or later and [Swiss Ephemeris](https://github.com/kunjara/swetest).

## License

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
}
],
"require": {
"php": ">=5.6",
"php": ">=7.0",
"kunjara/swetest": "1.0"
},
"require-dev": {
Expand Down
46 changes: 40 additions & 6 deletions src/Yoga/Type/Raja.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,63 @@ class Raja extends YogaBase
protected $yogaType = Yoga::TYPE_RAJA;

/**
* Generate list of Raja yogas.
* Combinations list.
*
* @return \Iterator
* @var array
*/
protected $yogas = [
'Yogakaraka',
'LKnTrPac',
];

/**
* If one and the same graha gets the lordships of a Trikon, as well as a Kendra.
*
* @return bool|string
* @see Maharishi Parashara. Brihat Parashara Hora Shastra. Chapter 34, Verse 13.
*/
public function hasYogakaraka()
{
foreach (Graha::listGraha(Graha::LIST_SAPTA) as $key => $name) {
$Graha = Graha::getInstance($key);
$Graha->setEnvironment($this->Data);
if ($Graha->isYogakaraka()) {
return $key;
}
}
return false;
}

/**
* Lords of Kendras and Trikonas Related.
*
* @return array
* @see Maharishi Parashara. Brihat Parashara Hora Shastra. Chapter 41, Verse 28.
*/
public function generateYoga()
public function hasLKnTrPac()
{
$Analysis = new Analysis($this->Data);

$bhavaKendra = Bhava::$bhavaKendra;
array_shift($bhavaKendra);
$kendraRulers = $Analysis->getBhavaRulers($bhavaKendra);
$trikonaRulers = $Analysis->getBhavaRulers(Bhava::$bhavaTrikona);
$result = [];

foreach ($kendraRulers as $kendraRuler) {
foreach ($trikonaRulers as $trikonaRuler) {
if ($trikonaRuler == $kendraRuler) {
continue;
}

$KendraRuler = Graha::getInstance($kendraRuler);
$KendraRuler->setEnvironment($this->Data);
$TrikonaRuler = Graha::getInstance($trikonaRuler);
$TrikonaRuler->setEnvironment($this->Data);

// Parivarthana
if ($this->hasParivarthana($kendraRuler, $trikonaRuler)) {
yield [
$result[] = [
'kendra' => $kendraRuler,
'trikona' => $trikonaRuler,
'interplay' => Yoga::INTERPLAY_PARIVARTHANA,
Expand All @@ -59,7 +92,7 @@ public function generateYoga()
// Conjunct
$kendraRulerIsConjuncted = $KendraRuler->isConjuncted();
if (isset($kendraRulerIsConjuncted[$trikonaRuler])) {
yield [
$result[] = [
'kendra' => $kendraRuler,
'trikona' => $trikonaRuler,
'interplay' => Yoga::INTERPLAY_CONJUNCT,
Expand All @@ -73,13 +106,14 @@ public function generateYoga()
$kendraRulerIsAspected[$trikonaRuler] == 1 &&
$trikonaRulerIsAspected[$kendraRuler] == 1
) {
yield [
$result[] = [
'kendra' => $kendraRuler,
'trikona' => $trikonaRuler,
'interplay' => Yoga::INTERPLAY_ASPECT,
];
}
}
}
return $result;
}
}
8 changes: 6 additions & 2 deletions src/Yoga/Type/YogaBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,13 @@ public function hasMahapurusha($key)
public function generateYoga()
{
foreach ($this->yogas as $yoga) {
$hasYoga = 'has'.$yoga;
$hasYoga = 'has' . $yoga;

if ($this->$hasYoga()) {
if (is_array($this->$hasYoga())) {
yield from $this->$hasYoga();
} elseif (is_string($this->$hasYoga())) {
yield $yoga . $this->$hasYoga();
} elseif ($this->$hasYoga()) {
yield $yoga;
}
}
Expand Down

0 comments on commit 393801b

Please sign in to comment.