seotils / has-parent
The trait allows set and get parent class of instance.
0.0.3
2016-09-06 20:30 UTC
Requires
- php: >=5.6.0
- seotils/deferred-exceptions: >=0.2
This package is not auto-updated.
Last update: 2024-10-26 19:27:07 UTC
README
Description
This trait assigns parent to a class.
License
HasParent is open-sourced software licensed under the [GPL-3.0] (https://www.gnu.org/licenses/gpl-3.0.en.html).
Requirements
Package depends on deferred-exceptions package.
-
GitHub:
- [seotils/deferred-exceptions] (https://github.com/seotils/deferred-exceptions)
-
Composer (packagist.org):
- [seotils/deferred-exceptions] (https://packagist.org/packages/seotils/deferred-exceptions)
-
PHPClasses:
- [Deferred Exceptions] (http://www.phpclasses.org/package/9854-PHP-Queue-exceptions-and-throws-them-afterwards.html)
Install
composer require seotils/has-parent
Usage
<?php namespace My; use Seotils\Traits\HasParent; /** * Parent class */ class A { public function time(){ return date('Y-m-d H:i:s'); } } /** * Class with HasParent trait */ class B { use HasParent; } // Usage $a = new A(); $b = new B(); // Assign and use parent class echo $b->parentClass( $a )->time(); // Or step by step // Assign parent class $b->parentClass( $a ); // Use parent class echo $b->parentClass()->time();
That`s all!