Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

chubbyphp-legacy/chubbyphp-deserialization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

24529ae · Mar 12, 2025
Mar 2, 2025
Dec 30, 2023
Jan 25, 2025
Mar 2, 2025
Mar 12, 2025
Nov 30, 2023
Oct 1, 2021
Jan 21, 2025
Mar 12, 2025
Mar 12, 2025
Mar 6, 2022
Dec 8, 2024
Nov 30, 2023
Feb 14, 2021

Repository files navigation

chubbyphp-deserialization

CI Coverage Status Mutation testing badge Latest Stable Version Total Downloads Monthly Downloads

bugs code_smells coverage duplicated_lines_density ncloc sqale_rating alert_status reliability_rating security_rating sqale_index vulnerabilities

Description

A simple deserialization.

DEPRECATED: No personal interest anymore. Please take a look to chubbyphp-parsing its a different concept. But i believe parsing is the way to go instead of deserialze/validate.

Requirements

  • php: ^8.2
  • chubbyphp/chubbyphp-decode-encode: ^1.2
  • psr/http-message: ^1.1|^2.0
  • psr/log: ^2.0|^3.0.2

Suggest

  • chubbyphp/chubbyphp-container: ^2.2
  • pimple/pimple: ^3.5
  • psr/container: ^2.0.2
  • symfony/config: ^5.4.46|^6.4.14|^7.2 (symfony integration)
  • symfony/dependency-injection: ^5.4.46|^6.4.14|^7.2 (symfony integration)

Installation

Through Composer as chubbyphp/chubbyphp-deserialization.

composer require chubbyphp/chubbyphp-deserialization "^4.2"

Usage

Accessor

Denormalizer

Field Denormalizer

Relation Field Denormalizer

Denormalizer Context

DenormalizerObjectMappingRegistry

Deserializer

<?php

use Chubbyphp\DecodeEncode\Decoder\Decoder;
use Chubbyphp\DecodeEncode\Decoder\JsonTypeDecoder;
use Chubbyphp\DecodeEncode\Decoder\JsonxTypeDecoder;
use Chubbyphp\DecodeEncode\Decoder\UrlEncodedTypeDecoder;
use Chubbyphp\DecodeEncode\Decoder\XmlTypeDecoder;
use Chubbyphp\DecodeEncode\Decoder\YamlTypeDecoder;
use Chubbyphp\Deserialization\Denormalizer\Denormalizer;
use Chubbyphp\Deserialization\Denormalizer\DenormalizerObjectMappingRegistry;
use Chubbyphp\Deserialization\Deserializer;
use MyProject\Deserialization\ModelMapping;
use MyProject\Model\Model;

$logger...;

$deserializer = new Deserializer(
    new Decoder([
        new JsonTypeDecoder(),
        new JsonxTypeDecoder(),
        new UrlEncodedTypeDecoder(),
        new XmlTypeDecoder(),
        new YamlTypeDecoder()
    ]),
    new Denormalizer(
        new DenormalizerObjectMappingRegistry([
            new ModelMapping()
        ]),
        $logger
    )
);

$model = $deserializer->deserialize(
    Model::class,
    '{"name": "php"}',
    'application/json'
);

echo $model->getName();
// 'php'

print_r($deserializer->getContentTypes());
//[
//    'application/json',
//    'application/jsonx+xml',
//    'application/x-www-form-urlencoded',
//    'application/xml',
//    'application/x-yaml'
//]

print_r($deserializer->decode(
    '{"name": "php"}',
    'application/json'
));
// ['name' => 'php']

$model = $denormalizer->denormalize(
    Model::class,
    ['name' => 'php']
);

echo $model->getName();
// 'php'

Mapping

DenormalizationFieldMapping

DenormalizationObjectMapping

LazyDenormalizationObjectMapping

Policy

ServiceFactory

chubbyphp-container

chubbyphp-laminas-config-factory

ServiceProvider

Copyright

2025 Dominik Zogg