mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-31 14:27:29 -04:00 
			
		
		
		
	* Remove unnecessary save() on invoice * Update copyright * Working on Credit Repository * Implement credits as a paymentable entity * Add credit_id to transformer * fix rules for update payment * Fix random deleted_at keys in transformers * Fix for password_protect check
		
			
				
	
	
		
			64 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			64 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| /**
 | |
|  * Invoice Ninja (https://invoiceninja.com)
 | |
|  *
 | |
|  * @link https://github.com/invoiceninja/invoiceninja source repository
 | |
|  *
 | |
|  * @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
 | |
|  *
 | |
|  * @license https://opensource.org/licenses/AAL
 | |
|  */
 | |
| 
 | |
| namespace App\DataMapper;
 | |
| 
 | |
| /**
 | |
|  * ClientSettings
 | |
|  */
 | |
| class BaseSettings
 | |
| {
 | |
|     public function __construct($obj)
 | |
|     {
 | |
|         foreach ($obj as $key => $value) {
 | |
|             $obj->{$key} = $value;
 | |
|         }
 | |
|     }
 | |
|     
 | |
|     public static function setCasts($obj, $casts)
 | |
|     {
 | |
|         foreach ($casts as $key => $value) {
 | |
|             $obj->{$key} = self::castAttribute($key, $obj->{$key});
 | |
|         }
 | |
| 
 | |
|         return $obj;
 | |
|     }
 | |
| 
 | |
|     public static function castAttribute($key, $value)
 | |
|     {
 | |
|         switch ($key) {
 | |
|             case 'int':
 | |
|             case 'integer':
 | |
|                 return (int) $value;
 | |
|             case 'real':
 | |
|             case 'float':
 | |
|             case 'double':
 | |
|                 return (float) $value;
 | |
|             case 'string':
 | |
|                 return is_null($value) ? '' : (string) $value;
 | |
|             case 'bool':
 | |
|             case 'boolean':
 | |
|                 return (bool)($value);
 | |
|             case 'object':
 | |
|                 return json_decode($value);
 | |
|             case 'array':
 | |
|             case 'json':
 | |
|                 return json_decode($value, true);
 | |
|             default:
 | |
|                 return $value;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     public static function castSingleAttribute($key, $data)
 | |
|     {
 | |
|     }
 | |
| }
 |