Skip to content

Commit

Permalink
Merge pull request #6 from sagikazarmark/improvements
Browse files Browse the repository at this point in the history
Improvements
  • Loading branch information
henrikbjorn committed May 3, 2016
2 parents bbf3e49 + fede2d3 commit 1cde16b
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 23 deletions.
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 4
indent_style = space
insert_final_newline = true
trim_trailing_whitespace = true
6 changes: 6 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spec/ export-ignore
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.travis.yml export-ignore
phpspec.yml.dist export-ignore
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
vendor
build/
vendor/
composer.lock
phpspec.yml
27 changes: 23 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,34 @@
language: php

sudo: false

cache:
directories:
- $HOME/.composer/cache

php:
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm

before_script:
- "composer require --dev phpspec/phpspec:~2.0.0-RC4 --no-update"
- "composer install --no-progress --no-plugins"
env:
global:
- TEST_COMMAND="composer test"

matrix:
fast_finish: true
include:
- php: 5.3
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest"

before_install:
- travis_retry composer self-update

install:
- travis_retry composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction

script:
- php vendor/bin/phpspec run
- $TEST_COMMAND
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Change Log


## Unreleased

### Changed

- AggregateNormalizer now implements `Symfony\Component\Serializer\SerializerAwareInterface`


## 1.0.0 - 2014-03-25

- Initial release
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2014 Bernard
Copyright (c) 2014-2016 Bernard Contributors

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ Normalt

[![Build Status](https://travis-ci.org/bernardphp/normalt.png?branch=master)](https://travis-ci.org/bernardphp/normalt)

Normalt contains additional normalizer's for use with the serializer component found in Symfony. It also
Normalt contains additional normalizers for use with the serializer component found in Symfony. It also
implements a normalizer delegator that will look at the data you want normalized and/or denormalized
and call the normalizer which supports it.

In the context of Normalt normalization is the act of converting an object into an array. Denormalization
is the opposite direction (converting array into an object). This is to my knowledge the same concept
Symfony serializer uses.


Table of Contents
-----------------

Expand All @@ -28,14 +29,16 @@ Getting Started
Getting started is as easy as requiring the library with composer.

``` bash
$ composer require bernard/normalt:~0.1
$ composer require bernard/normalt
```


Normalizers
-----------

Theese normalizers can be used with the serializer component directly or through the `AggregateNormalizer`.


### AggregateNormalizer

`AggregateNormalizer` is a delegator and aggregator as it aggregates multiple normalizers and denormalizers
Expand All @@ -48,6 +51,7 @@ It implements a subset of the full serializer and its only focus is normalizing
denormalize arrays into objects. This lets you focus on normalization instead of converting
into a specific format such as `xml`, `json` etc.


#### Usage

You need to instantiate the normalizer and the list of normalizer/denormalizers you want to use.
Expand Down Expand Up @@ -95,6 +99,7 @@ echo $user->getName(); // outputs Henrik
In contrast to the other normalizers in this package, it does __not__ make sense to use this with the
serializer as the Serializer already does most of the functionality already.


### DoctrineNormalizer

`DoctrineNormalizer` normalizes mapped objects (Entities, Documents etc.) into arrays and back again.
Expand All @@ -117,6 +122,7 @@ $array = $normalizer->normalize($user);
$user = $normalizer->denormalize($array, null);
```


### RecursiveReflectionNormalizer

This normalizes also delegates like the `AggregateNormalizer`, but delegates for each property in the object
Expand Down Expand Up @@ -144,8 +150,8 @@ $array = $normalizer->normalize($profile);
$profile = $normalize->denormalize($array, 'MyModel\Profile');
```


License
-------

Please refer to the included `LICENSE` file.

35 changes: 21 additions & 14 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
{
"name" : "bernard/normalt",
"license" : "MIT",

"autoload" : {
"psr-4" : { "Normalt\\" : "src" }
"name": "bernard/normalt",
"description": "Normalt is a extension to Symfony Serializer that only implements the Normalization part",
"keywords": ["normalization", "denormalization"],
"license": "MIT",
"require": {
"symfony/serializer": "^2.3 || ^3.0"
},

"autoload-dev" : {
"psr-4" : { "Fixtures\\" : "spec/Fixtures" }
"require-dev": {
"doctrine/common": "^2.1",
"phpspec/phpspec": "^2.5"
},

"require" : {
"symfony/serializer" : "~2.3 || ~3.0"
"autoload": {
"psr-4": { "Normalt\\": "src/" }
},

"require-dev" : {
"doctrine/common" : "~2.1"
"autoload-dev": {
"psr-4": { "Fixtures\\": "spec/Fixtures/" }
},
"scripts": {
"test": "vendor/bin/phpspec"
},
"extra": {
"branch-alias": {
"dev-master": "1.1-dev"
}
}
}
4 changes: 4 additions & 0 deletions phpspec.yml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
suites:
normalt_suite:
namespace: Normalt
formatter.name: pretty

0 comments on commit 1cde16b

Please sign in to comment.