2017 © Pedro PelĂĄez
 

library type-hinted-arrays

A simple way to create typed collections in PHP - build on Illuminate\Support\Collection

image

vistik/type-hinted-arrays

A simple way to create typed collections in PHP - build on Illuminate\Support\Collection

  • Sunday, February 12, 2017
  • by vistik
  • Repository
  • 1 Watchers
  • 1 Stars
  • 8,611 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 6 Versions
  • 8 % Grown

The README.md

Build Status, (*1)

What is this?

This is a very simple way to make arrays type hinted!, (*2)

$list = new UserCollection(new User());, (*3)

OK, (*4)

$list = new UserCollection('User');, (*5)

Will throw:, (*6)

Vistik\Exception\InvalidTypeException: Item (string) 'User' is not a Vistik\Example\User object!, (*7)

Install

Run composer require vistik/type-hinted-arrays, (*8)

Use build in Collections for primitives

Out-of-the-box collections for: - Booleans - Integers - Floats - Strings - Emails - Numbers (float or int), (*9)

Do I have to create a type for each list? Yes, but

Look how easy it is:, (*10)

class UserCollection extends TypedCollection{
    protected $type = 'Vistik\Example\User';
}

2 simple steps, (*11)

1) Create a Class eg. AccountCollection extend TypedCollection
2) Just replace protected $type = 'Vistik\Example\User'; with your class, (*12)

or, (*13)

If the check is more then just a is_a check, you can overwrite the function: isValidItem($item) in your new Collection class, (*14)

Features

The Versions

12/02 2017

dev-master

9999999-dev

A simple way to create typed collections in PHP - build on Illuminate\Support\Collection

  Sources   Download

The Requires

 

The Development Requires

by Visti Kløft

collection array collections type hint type hinted

11/02 2017

v2.0.0

2.0.0.0

A simple way to create typed collections in PHP - build on Illuminate\Support\Collection

  Sources   Download

The Requires

 

The Development Requires

by Visti Kløft

collection array collections type hint type hinted

23/02 2015

v1.0.3

1.0.3.0

A simple way to create type hinted arrays in PHP - build on Illuminate\Support\Collection

  Sources   Download

The Requires

 

The Development Requires

by Visti Kløft

collection array collections type hint type hinted

20/02 2015

v1.0.2

1.0.2.0

A simple way to create type hinted arrays in PHP - build on Illuminate\Support\Collection

  Sources   Download

The Requires

 

The Development Requires

by Visti Kløft

collection array collections type hint type hinted

20/02 2015

v1.0.1

1.0.1.0

A simple way to create type hinted arrays in PHP - build on Illuminate\Support\Collection

  Sources   Download

The Requires

 

The Development Requires

by Visti Kløft

collection array collections type hint type hinted

20/02 2015

v1.0.0

1.0.0.0

A simple way to create type hinted arrays in PHP - build on Illuminate\Support\Collection

  Sources   Download

The Requires

 

The Development Requires

by Visti Kløft

collection array collections type hint type hinted