Skip to content
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

fixed for work php version 7 #12

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
85 changes: 85 additions & 0 deletions src/Base/BaseObject.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php
/**
* @link http://github.com/kunjara/jyotish for the canonical source repository
* @license GNU General Public License version 2 or later
*/

namespace Jyotish\Base;

/**
* Base class for Jyotish objects.
*
* @author Kunjara Lila das <[email protected]>
*/
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()
{
$this->objectNames = array_merge([$this->objectName], $this->objectNames);
}
}
2 changes: 1 addition & 1 deletion src/Base/Traits/EnvironmentTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ trait EnvironmentTrait
* Set environment.
*
* @param \Jyotish\Base\Data $Data
* @return \Jyotish\Base\Object
* @return \Jyotish\Base\BaseObject
*/
public function setEnvironment(\Jyotish\Base\Data $Data)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Bhava/Object/BhavaObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

namespace Jyotish\Bhava\Object;

use Jyotish\Base\Object;
use Jyotish\Base\BaseObject;

/**
* Parent class for bhava objects.
*
* @author Kunjara Lila das <[email protected]>
*/
class BhavaObject extends Object {
class BhavaObject extends BaseObject {

use BhavaEnvironment;

Expand Down
4 changes: 2 additions & 2 deletions src/Graha/Object/GrahaObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
namespace Jyotish\Graha\Object;

use Jyotish\Base\Biblio;
use Jyotish\Base\Object;
use Jyotish\Base\BaseObject;
use Jyotish\Graha\Graha;
use Jyotish\Rashi\Rashi;
use Jyotish\Ganita\Math;
Expand All @@ -18,7 +18,7 @@
*
* @author Kunjara Lila das <[email protected]>
*/
class GrahaObject extends Object
class GrahaObject extends BaseObject
{
use GrahaEnvironment;

Expand Down
2 changes: 1 addition & 1 deletion src/Rashi/Object/RashiObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
* @author Kunjara Lila das <[email protected]>
*/
class RashiObject extends \Jyotish\Base\Object
class RashiObject extends \Jyotish\Base\BaseObject
{
use RashiEnvironment;

Expand Down