Source of file DebugTrait.php
Size: 1,696 Bytes - Last Modified: 2021-12-23T10:47:32+00:00
/var/www/docs.ssmods.com/process/src/src/DebugTrait.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 | <?php namespace Sunnysideup\Vardump; use SilverStripe\ORM\FieldType\DBField; /** * small trait to make non-Viewable objects printable. */ trait DebugTrait { /** * Get the value of a field on this object, automatically inserting the value into any available casting objects * that have been specified. * * @param string $fieldName * @param array $arguments * @param bool $cache Cache this object * @param string $cacheName a custom cache name * * @return null|DBField */ public function obj($fieldName, $arguments = [], $cache = false, $cacheName = null) { if (Vardump::inst()->isSafe()) { $data = call_user_func_array([$this, $fieldName], $arguments ?: []); return Vardump::inst()->vardumpMe($data, $fieldName, $this->VardumpClassName()); } return null; } /** * for debug purposes! * * @param string $method * @param array $arguments - optional */ public function XML_val(?string $method, $arguments = []) { if (Vardump::inst()->isSafe()) { if (! is_array($arguments)) { $arguments = [$arguments]; } $data = $this->{$method}(...$arguments); return Vardump::inst()->vardumpMe($data, $method, $this->VardumpClassName()); } } public function VardumpMe(string $method) { return Vardump::inst()->vardumpMe($this->{$method}(), $method, static::class); } public function ClassName(): string { return static::class; } public function VardumpClassName(): string { return static::class; } } |