Skip to content

add support for PHP 7.4 compatabilty #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,4 @@
<directory suffix=".php">./src</directory>
</whitelist>
</filter>

<logging>
<log type="coverage-html"
target="./tests/logs/coverage"
charset="UTF-8"
yui="true"
highlight="true"
lowUpperBound="50"
highLowerBound="80"/>
</logging>
</phpunit>
29 changes: 15 additions & 14 deletions src/Base/Object.php → src/Base/BaseObject.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

/**
* @link http://github.com/kunjara/jyotish for the canonical source repository
* @license GNU General Public License version 2 or later
Expand All @@ -11,71 +12,71 @@
*
* @author Kunjara Lila das <[email protected]>
*/
class Object
class BaseObject
{
use \Jyotish\Base\Traits\GetTrait;
use \Jyotish\Base\Traits\OptionTrait;

/**
* Type of object.
*
*
* @var string
*/
protected $objectType = null;

/**
* Abbreviation of the object.
*
*
* @var string|int
*/
protected $objectKey = null;

/**
* Main name of the object.
*
*
* @var string
*/
protected $objectName = null;

/**
* Alternative names of the object.
*
*
* @var array
*/
protected $objectNames = [];

/**
* Constructor
*
*
* @param null|array $options Options to set
*/
public function __construct($options)
{
$this->setOptions($options);

$this->setObjectName();
$this->setObjectNames();
}

/**
* Set main name of the object.
*
*
* @return void
*/
protected function setObjectName()
{
$objectType = $this->objectType;
$objectName = ucfirst($objectType);
$className = 'Jyotish\\' . $objectName . '\\' . $objectName;

$list = $className::$$objectType;

$this->objectName = $list[$this->objectKey];
}

/**
* Set names of the object.
*
*
* @return void
*/
protected function setObjectNames()
Expand Down
54 changes: 27 additions & 27 deletions src/Base/Traits/EnvironmentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,35 +12,35 @@

/**
* EnvironmentTrait provides operations with environment.
*
*
* @author Kunjara Lila das <[email protected]>
*/
trait EnvironmentTrait
{
/**
* Instance of Data.
*
*
* @var \Jyotish\Base\Data
*/
protected $Data = null;

/**
* Rashi, where object is located.
*
*
* @var int
*/
protected $objectRashi = null;

/**
* Set environment.
*
*
* @param \Jyotish\Base\Data $Data
* @return \Jyotish\Base\Object
* @return \Jyotish\Base\BaseObject
*/
public function setEnvironment(\Jyotish\Base\Data $Data)
{
$this->Data = $Data;

if (!isset($this->Data->getData()['graha'])) {
$this->Data->calcParams();
}
Expand All @@ -50,23 +50,23 @@ public function setEnvironment(\Jyotish\Base\Data $Data)
} else {
$this->objectRashi = $this->Data->getData()[$this->objectType][$this->objectKey]['rashi'];
}

return $this;
}

/**
* Get environment.
*
*
* @return array
*/
public function getEnvironment()
{
return $this->Data->getData();
}

/**
* Get aspect by grahas.
*
*
* @param null|array $options Options to set (optional)
* @return array
*/
Expand All @@ -78,10 +78,10 @@ public function isAspectedByGraha($options = null)
$grahaDrishti = $Graha->grahaDrishti;

$distanse = Math::distanceInCycle(
$this->getEnvironment()['graha'][$key]['rashi'],
$this->getEnvironment()['graha'][$key]['rashi'],
$this->objectRashi
);

if ($key == $this->objectKey || !isset($grahaDrishti[$distanse])) {
$isAspected[$key] = null;
} else {
Expand All @@ -90,28 +90,28 @@ public function isAspectedByGraha($options = null)
}
return $isAspected;
}

/**
* Get aspect by rashis.
*
*
* @return array
*/
public function isAspectedByRashi()
{
$isAspected = [];

$isAspected['rashi'] = [];
foreach (Rashi::$rashi as $key => $name) {
if ($key == $this->objectKey) continue;

$Rashi = Rashi::getInstance($key);
$rashiDrishti = $Rashi->rashiDrishti;

if (isset($rashiDrishti[$this->objectRashi])) {
$isAspected['rashi'][$key] = $rashiDrishti[$this->objectRashi];
}
}

$isAspected['graha'] = [];
foreach (Graha::$graha as $key => $name) {
$grahaRashi = $this->getEnvironment()['graha'][$key]['rashi'];
Expand All @@ -124,7 +124,7 @@ public function isAspectedByRashi()

/**
* Get conjunct with other grahas.
*
*
* @return array
*/
public function isConjuncted()
Expand All @@ -143,7 +143,7 @@ public function isConjuncted()

/**
* Returns an array of hemming grahas.
*
*
* @return array
*/
public function isHemmed()
Expand All @@ -169,10 +169,10 @@ public function isHemmed()

return $isHemmed;
}

/**
* Determine if the jyotish object is affected.
*
*
* @param null|string $feature Feature of graha (optional)
* @param null|string $value Value of feature (optional)
* @return bool|array
Expand All @@ -184,22 +184,22 @@ public function isAffected($feature = null, $value = null)
} else {
$grahas = Graha::listGrahaByFeature($feature, $value);
}

$grahaAspected = array_intersect_key($this->isAspectedByGraha(), $grahas);
$grahaAspected1 = array_intersect($grahaAspected, [1]);
if (count($grahaAspected1)) {
$isAspected = $grahaAspected1;
} else {
$isAspected = false;
}

$grahaConjuncted = array_intersect_key($this->isConjuncted(), $grahas);
if (count($grahaConjuncted)) {
$isConjuncted = $grahaConjuncted;
} else {
$isConjuncted = false;
}

$grahaHemmed = array_intersect_key($this->isHemmed(), $grahas);
if (array_search('prev', $grahaHemmed) && array_search('next', $grahaHemmed)) {
$isHemmed = $grahaHemmed;
Expand Down
14 changes: 7 additions & 7 deletions src/Bhava/Object/B1.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
*
* @author Kunjara Lila das <[email protected]>
*/
class B1 extends BhavaObject
class B1 extends BhavaBaseObject
{
/**
* Bhava key
*
*
* @var int
*/
protected $objectKey = 1;

/**
* Names of the bhava.
*
*
* @var array
* @see Varahamihira. Brihat Jataka. Chapter 1, Verse 15-16.
*/
Expand All @@ -34,7 +34,7 @@ class B1 extends BhavaObject

/**
* Indications of bhava.
*
*
* @var array
* @see Maharishi Parashara. Brihat Parashara Hora Shastra. Chapter 11, Verse 2.
*/
Expand All @@ -51,8 +51,8 @@ class B1 extends BhavaObject

/**
* Purushartha of bhava.
*
*
* @var string
*/
protected $bhavaPurushartha = Manusha::PURUSHARTHA_DHARMA;
}
}
14 changes: 7 additions & 7 deletions src/Bhava/Object/B10.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@
*
* @author Kunjara Lila das <[email protected]>
*/
class B10 extends BhavaObject
class B10 extends BhavaBaseObject
{
/**
* Bhava key
*
*
* @var int
*/
protected $objectKey = 10;

/**
* Names of the bhava.
*
*
* @var array
* @see Varahamihira. Brihat Jataka. Chapter 1, Verse 15-16.
*/
Expand All @@ -35,7 +35,7 @@ class B10 extends BhavaObject

/**
* Indications of bhava.
*
*
* @var array
* @see Maharishi Parashara. Brihat Parashara Hora Shastra. Chapter 11, Verse 11.
*/
Expand All @@ -51,8 +51,8 @@ class B10 extends BhavaObject

/**
* Purushartha of bhava.
*
*
* @var string
*/
protected $bhavaPurushartha = Manusha::PURUSHARTHA_ARTHA;
}
}
Loading