1
0
mirror of https://github.com/danog/MadelineProto.git synced 2024-11-30 06:59:01 +01:00
This commit is contained in:
Daniil Gentili 2017-02-05 02:03:00 +01:00
commit 8a88dc8650
2 changed files with 17 additions and 1 deletions

View File

@ -8,7 +8,7 @@
"require": {
"php": ">=5.6.0",
"danog/phpstruct": "^1.2",
"phpseclib/phpseclib": "dev-master|^2.0.4",
"phpseclib/phpseclib": "^2.0.4",
"vlucas/phpdotenv": "^2.4"
},
"require-dev": {

View File

@ -17,6 +17,15 @@ namespace danog\MadelineProto;
*/
class Serialization
{
/**
* Serialize API class.
*
* @param string $filename the dump file
* @param API $instance
* @param bool $force
*
* @return number|bool
*/
public static function serialize($filename, $instance, $force = false)
{
if ($instance->API->should_serialize || !(file_exists($filename) && !empty(file_get_contents($filename))) || $force) {
@ -28,6 +37,13 @@ class Serialization
return false;
}
/**
* Deserialize API class.
*
* @param string $filename
*
* @return bool|API
*/
public static function deserialize($filename)
{
set_error_handler(['\danog\MadelineProto\Exception', 'ExceptionErrorHandler']);