stringify($new); $audit = new Audit($account, null, $newString, $type, $subtype, $module, $ref, $content); AuditMapper::create($audit); } public function apiLogUpdate( $account, $old, $new, int $type = 0, int $subtype = 0, string $module = null, string $ref = null, string $content = null ) : void { $oldString = $this->stringify($old); $newString = $this->stringify($new); $audit = new Audit($account, $oldString, $newString, $type, $subtype, $module, $ref, $content); AuditMapper::create($audit); } public function apiLogDelete( $account, $old, $new, int $type = 0, int $subtype = 0, string $module = null, string $ref = null, string $content = null ) : void { $oldString = $this->stringify($old); $audit = new Audit($account, $oldString, null, $type, $subtype, $module, $ref, $content); AuditMapper::create($audit); } private function stringify($element) : ?string { $stringified = ''; if ($element instanceof \JsonSerializable) { $stringified = \json_encode($element); } elseif ($element instanceof \Serializable) { $stringified = $element->serialize(); } elseif (\is_string($element)) { $stringified = $element; } elseif ($element === null) { return null; } else { $stringified = $element->__toString(); } return $stringified; } }