2017 © Pedro Peláez
 

library serialization-helpers

Helpers to work with serialized strings

image

cs278/serialization-helpers

Helpers to work with serialized strings

  • Friday, August 7, 2015
  • by cs278
  • Repository
  • 1 Watchers
  • 1 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Serialization Helpers

Build Status Scrutinizer Code Quality, (*1)

Helpers for dealing with strings created by the serialize() function in PHP., (*2)

Usage

isSerialized($value) — Test if a supplied value is a PHP serialized string, returns true iff the syntax looks correct. This function may produce false negatives because Zend PHP’s unserialize() implementation will work on malformed strings., (*3)

isSerialized($value, &$result) — As above but also returns the unserialized value by reference., (*4)

unserialize($input) — Converts the serialized input into a PHP data type, returns the resulting data type. If an error occurs during the unserialize operation a SyntaxError will be thrown., (*5)

Examples

Test if a value is serialized:

isSerialized($value), (*6)

<?php

use Cs278\SerializationHelpers\isSerialized;

isSerialized('b:1');
// bool(false)

isSerialized('d:2.71828');
// bool(true)

Unserialize with error handling:

<?php

use Cs278\SerializationHelpers\unserialize;
use Cs278\SerializationHelpers\Exception\SyntaxError;

try {
    return unserialize('s:"foobar";');
} catch (SyntaxError $e) {
    $logger->warning('Input, `{input}` was not valid serialized data', array(
        'input' => $e->getInput(),
    ));

    return null;
}

The Versions

07/08 2015

1.0.x-dev

1.0.9999999.9999999-dev https://github.com/cs278/serialization-helpers

Helpers to work with serialized strings

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

serialization serialize unserialize

07/08 2015

dev-master

9999999-dev https://github.com/cs278/serialization-helpers

Helpers to work with serialized strings

  Sources   Download

MIT

The Requires

  • php >=5.5.0

 

The Development Requires

serialization serialize unserialize

07/08 2015

v1.0.1

1.0.1.0 https://github.com/cs278/serialization-helpers

Helpers to work with serialized strings

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

serialization serialize unserialize

06/08 2015

v1.0.0

1.0.0.0 https://github.com/cs278/serialization-helpers

Helpers to work with serialized strings

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

serialization serialize unserialize