Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jansenfelipe/phpstring

Create objects filling attribute classes with string data
https://github.com/jansenfelipe/phpstring

Last synced: 3 days ago
JSON representation

Create objects filling attribute classes with string data

Awesome Lists containing this project

README

        

# PHP String
[![Travis](https://travis-ci.org/jansenfelipe/phpstring.svg?branch=1.0)](https://travis-ci.org/jansenfelipe/phpstring)
[![Latest Stable Version](https://poser.pugx.org/jansenfelipe/phpstring/v/stable.svg)](https://packagist.org/packages/jansenfelipe/phpstring)
[![Total Downloads](https://poser.pugx.org/jansenfelipe/phpstring/downloads.svg)](https://packagist.org/packages/jansenfelipe/phpstring)
[![Latest Unstable Version](https://poser.pugx.org/jansenfelipe/phpstring/v/unstable.svg)](https://packagist.org/packages/jansenfelipe/phpstring)
[![MIT license](https://poser.pugx.org/jansenfelipe/phpstring/license.svg)](http://opensource.org/licenses/MIT)

Create objects filling attribute classes with string data

## How to use

Add library

```sh
$ composer require jansenfelipe/phpstring
```

Add autoload.php in your file:

```php
require_once 'vendor/autoload.php';
```

Add annotations
```php
Object

```php
$parser = new PHPString(Event::class);
$event = $parser->toObject("BH Bike Show 20160621002000Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce consequat augue at hendrerit posuere.");

echo $parser->getSize(); //output: 134
```

#### String <- Object

```php
$parser = new PHPString(Event::class);

$event = new Event();
$event->name = 'Motocross Adventure';
$event->description = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce consequat augue at hendrerit posuere.';
$event->date = Carbon::createFromFormat('Y-m-d', '2016-06-21');
$event->price = 1200.98;

$string = $parser->toString($event);
```

### License

The MIT License (MIT)