Created
September 10, 2012 12:35
-
-
Save rickard2/3690671 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class JsonDecoder implements DecoderInterface { | |
public function decode( $data ) | |
{ | |
$decoded = @json_decode( $data, true ); | |
$decoded = $this->removeBooleans( $decoded ); | |
return $decoded; | |
} | |
private function removeBooleans( $array ) | |
{ | |
foreach ( $array as $key => $item ) { | |
if ( is_array( $item ) ) { | |
$array[ $key ] = $this->removeBooleans( $item ); | |
} else if ( $item === false ) { | |
unset( $array[ $key ] ); | |
} | |
} | |
return $array; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment