src/Transformer.php
public function transform($data = null, $rules = null)
	{
		// The data
		if ( ! $data) $data = $this->data;

		// The rules
		if ( ! $rules) $rules = $this->rules;

		// Merge the default ones in
		$rules = array_merge($this->defaultRules, $rules);

		foreach ($rules as $key => $rule)
		{
			if (isset($data[$key]))
			{
				if     ($rule == 'datetime')                      $data[$key] = Carbon::parse($data[$key]);
				elseif ($rule == 'time')                          $data[$key] = Carbon::parse($data[$key]);
				elseif ($rule == 'date')                          $data[$key] = Carbon::parse($data[$key]);
				elseif ($rule == 'image')                         $data[$key] = $this->transformImage($data[$key]);
				elseif ($rule == 'strip_tags')                    $data[$key] = strip_tags($data[$key]);
				elseif (is_string($rule) and class_exists($rule)) $data[$key] = new $rule($data[$key]);
				elseif (is_array($rule))                          $data[$key] = $data[$key];
			}
		}

		return $data;
	}
public function transform($data = null, $rules = null)
	{
		// The data
		if ( ! $data) $data = $this->data;

		// The rules
		if ( ! $rules) $rules = $this->rules;

		// Merge the default ones in
		$rules = array_merge($this->defaultRules, $rules);

		foreach ($rules as $key => $rule)
		{
			if (isset($data[$key]))
			{
				if     ($rule == 'datetime')                      $data[$key] = Carbon::parse($data[$key]);
				elseif ($rule == 'time')                          $data[$key] = Carbon::parse($data[$key]);
				elseif ($rule == 'date')                          $data[$key] = Carbon::parse($data[$key]);
				elseif ($rule == 'image')                         $data[$key] = $this->transformImage($data[$key]);
				elseif ($rule == 'strip_tags')                    $data[$key] = strip_tags($data[$key]);
				elseif (is_string($rule) and class_exists($rule)) $data[$key] = new $rule($data[$key]);
				elseif (is_array($rule))                          $data[$key] = $data[$key];
			}
		}

		return $data;
	}
public function transform ( $ data = null , $ rules = null ) { // The data if ( ! $ data ) $ data = $ this -> data ; // The rules if ( ! $ rules ) $ rules = $ this -> rules ; // Merge the default ones in $ rules = array_merge ( $ this -> defaultRules , $ rules ) ; foreach ( $ rules as $ key => $ rule ) { if ( isset ( $ data [ $ key ] ) ) { if ( $ rule == 'datetime' ) $ data [ $ key ] = Carbon :: parse ( $ data [ $ key ] ) ; elseif ( $ rule == 'time' ) $ data [ $ key ] = Carbon :: parse ( $ data [ $ key ] ) ; elseif ( $ rule == 'date' ) $ data [ $ key ] = Carbon :: parse ( $ data [ $ key ] ) ; elseif ( $ rule == 'image' ) $ data [ $ key ] = $ this -> transformImage ( $ data [ $ key ] ) ; elseif ( $ rule == 'strip_tags' ) $ data [ $ key ] = strip_tags ( $ data [ $ key ] ) ; elseif ( is_string ( $ rule ) and class_exists ( $ rule ) ) $ data [ $ key ] = new $ rule ( $ data [ $ key ] ) ; elseif ( is_array ( $ rule ) ) $ data [ $ key ] = $ data [ $ key ] ; } } return $ data ; }
Transform data types for item
@param  array $data
@param  array $rules
@return array
Transform data types for item