DownloadHasParent
Description
This trait assigns parent to a class.
License
HasParent is open-sourced software licensed under the GPL-3.0.
Requirements
Package depends on __deferred-exceptions__ package.
-
GitHub:
* seotils/deferred-exceptions
-
Composer (packagist.org):
* seotils/deferred-exceptions
-
PHPClasses:
* Deferred Exceptions
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!
|