Skip to content

wearesho-team/base-collection

Repository files navigation

Base Сollection

PHP Composer Latest Stable Version Total Downloads codecov

Implementation of typed collection.

Installation

composer require wearesho-team/base-collection

Usage

Create your class collection and implement type() method.

It must return declared (existed) class name

<?php

use Wearesho\BaseCollection;

class MyCollection extends BaseCollection
{
    public function type(): string
    {
        return stdClass::class;
    }
}

And now you have typed collection!

If you try to append item that not instance of your type you will catch an InvalidArgumentException

Authors

License

MIT

About

Typed collection

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages