2017 © Pedro PelĂĄez
 

library keep-update

keep-update

image

fezfez/keep-update

keep-update

  • Thursday, October 23, 2014
  • by fezfez
  • Repository
  • 1 Watchers
  • 0 Stars
  • 292 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

keep-update

Scrutinizer Code Quality Code Coverage Build Status SensioLabsInsight, (*1)

Keep update resolve the problem of remaps data from jsonSerialize, (*2)

Example, (*3)

I have this dto representation of my model, (*4)


class News implements \JsonSerializable { /** * @var string */ private $title; /** * @var Author */ private $author; // setters, getters public function jsonSerialize() { return array( 'title' => $this->title, 'author' => $this->author ); } } class Author implements \JsonSerializable { private $name; // setters, getters public function jsonSerialize() { return array( 'name' => $this->name ); } }

If i do, (*5)

$author = new Author();
$author->setName('Stéphane');

$news = new News();
$news->setTitle('My very news');
$news->setAuthor($author);

file_put_content('tmp', json_encode($news));

I will have a json representation in tmp file. Now i want to wake the representation., (*6)

$newsArray = json_decode(file_get_content('tmp'));

How to be sure that's the array i have is a correct representation of my dto's ? You have to create a validator class, that's very annoying..., (*7)

With keepUpdate you only have to add Annotation in your attribute, resuming the previous sample, (*8)


use KeepUpdate\Annotation; class News implements \JsonSerializable { /** * @var string */ private $title; /** * @Annotation\Chain(class="Author") * @var Author */ private $author; // setters, getters public function jsonSerialize() { return array( 'title' => $this->title, 'author' => $this->author ); } } class Author implements \JsonSerializable { private $name; // setters, getters public function jsonSerialize() { return array( 'name' => $this->name ); } } $author = new Author(); $author->setName('Stéphane'); $news = new News(); $news->setTitle('My very news'); $news->setAuthor($author); file_put_content('tmp', json_encode($news)); $newsArray = json_decode(file_get_content('tmp')); $arrayValidatorFactory = \KeepUpdate\ArrayValidatorFactory::getInstance(); try { $arrayValidatorFactory->isValid($news, $newsArray); } catch(\KeepUpdate\ValidationException $e) { echo 'Not valid !'; } // or try { $arrayValidatorFactory->isValid('News', $newsArray); } catch(\KeepUpdate\ValidationException $e) { echo 'Not valid !'; }

Validate an array representation of a dto is now more simple, (*9)

The Versions

23/10 2014

dev-master

9999999-dev https://github.com/fezfez/keep-update

keep-update

  Sources   Download

MIT

The Requires

 

The Development Requires

by Stéphane Demonchaux

validator array dto binding

23/10 2014

V0.1.2

0.1.2.0 https://github.com/fezfez/keep-update

keep-update

  Sources   Download

MIT

The Requires

 

The Development Requires

by Stéphane Demonchaux

validator array dto binding

23/10 2014

v0.1.1

0.1.1.0 https://github.com/fezfez/keep-update

keep-update

  Sources   Download

MIT

The Requires

 

The Development Requires

by Stéphane Demonchaux

validator array dto binding

23/10 2014

v0.1.0

0.1.0.0 https://github.com/fezfez/codeGenerator

keep-update

  Sources   Download

MIT

The Requires

 

The Development Requires

by Stéphane Demonchaux

crud zf2 pdo doctrine2 code generator form generator solid principles