-
Notifications
You must be signed in to change notification settings - Fork 0
/
DebugPrintTrait.php
58 lines (55 loc) · 1.98 KB
/
DebugPrintTrait.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* FlorianWolters\Component\Core\DebugPrintTrait
*
* PHP Version 5.4
*
* @author Florian Wolters <wolters.fl@gmail.com>
* @copyright 2012-2014 Florian Wolters (http://blog.florianwolters.de)
* @license http://gnu.org/licenses/lgpl.txt LGPL-3.0+
* @link http://github.com/FlorianWolters/PHP-Component-Core-DebugPrint
*/
namespace FlorianWolters\Component\Core;
/**
* The trait {@see DebugPrintTrait} provides a *Debug Print Method* for objects.
*
* Always implement the interface {@see DebugPrintInterface} if using the trait
* {@see DebugPrintTrait}, since that allows {@link
* https://php.net/language.oop5.typehinting Type Hinting}.
*
* @since Trait available since Release 0.1.0
*/
trait DebugPrintTrait
{
use HashCodeTrait;
/**
* Returns a string representation of the object.
*
* In general, the {@see __toString} method returns a string that "textually
* represents" the object using the trait {@see DebugPrintTrait}. The result
* should be a concise but informative representation that is easy for a
* person to read.
*
* The {@see __toString} method for trait {@see DebugPrintTrait} returns a
* string consisting of the name of the class of which the object is an
* instance, the at-sign character `'@'`, and the unsigned hexadecimal
* representation of the hash code of the object. In other words, this
* method returns a string equal to the value of:
* /---code php
* \get_class($this) . '@' . $this->hashCode());
* \---
*
* The method {@see __toString} is intended to be used only for debugging
* purposes, and the content and format of the returned string may vary
* between implementations.
*
* The method {@see __toString} implements the *Debug Print Method*
* implementation pattern.
*
* @return string The string representation.
*/
public function __toString()
{
return \get_class($this) . '@' . $this->hashCode();
}
}