Skip to content

Commit

Permalink
Artificially enforce instantiated classes to implement Kohana_Crypto
Browse files Browse the repository at this point in the history
  • Loading branch information
enov committed Aug 17, 2016
1 parent 1755df7 commit 43646f6
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion classes/Kohana/Encrypt.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,13 @@ public static function factory($name = NULL)
// Add the "Encrypt" prefix
$class = 'Encrypt_'.ucfirst($driver);

// Create a new instance and make sure it's Kohana_Crypto
$encrypt = new $class($settings);
if ( ! $encrypt instanceof Kohana_Crypto )
{
throw new Kohana_Exception('Encryption class should implement `Kohana_Crypto` interface');
}
// Create a new instance
return new $class($settings);
return $encrypt;
}
}

0 comments on commit 43646f6

Please sign in to comment.