2017 © Pedro PelĂĄez
 

library php-typed-array

A base class for typed arrays.

image

donurks/php-typed-array

A base class for typed arrays.

  • Sunday, August 20, 2017
  • by donurks
  • Repository
  • 1 Watchers
  • 0 Stars
  • 28 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Build Status Latest Stable Version Total Downloads License, (*1)

php-typed-array

A PHP class for type safe arrays. This project is based on PHPs ArrayObject., (*2)

Features

  • type safe arrays
  • arrays for PHP language types
    • boolean
    • integer
    • string
    • float

Installation (with Composer)

Command line

composer require donurks/php-typed-array

Usage

Classes

<?php
chdir(dirname(__DIR__));
require_once "vendor/autoload.php";

class MyOwnType extends \Donurks\AbstractTypedArray
{
    protected $type = \stdClass::class;
}

$myOwnType = new MyOwnType([
    new \stdClass(),
    new \stdClass(),
    new \stdClass(),
]);

PHP language types

<?php
chdir(dirname(__DIR__));
require_once "vendor/autoload.php";

$strings = new \Donurks\TypedArray\TypeString([
    'string1',
    'string2',
    'string3'
]);

$booleans = new \Donurks\TypedArray\TypeBoolean([
    true,
    false,
    true
]);

$integers = new \Donurks\TypedArray\TypeInteger([
    1,
    124,
    3434
]);

$floats = new \Donurks\TypedArray\TypeFloat([
    1.234,
    1.2e3,
    7E-10
]);

Exception

<?php
chdir(dirname(__DIR__));
require_once "vendor/autoload.php";

$strings = new \Donurks\TypedArray\TypeString([
    'string1',
    'string2',
    'string3'
]);

$booleans = new \Donurks\TypedArray\TypeBoolean([]);
$booleans[] = true;

try {
    $booleans[] = 'not-a-boolean';    
} catch (\Donurks\TypedArray\Exception $e) {
    die($e->getMessage());
}

The Versions

20/08 2017

dev-master

9999999-dev https://github.com/donurks/php-typed-array/

A base class for typed arrays.

  Sources   Download

MIT

The Development Requires

php array type

20/08 2017

1.0.0

1.0.0.0 https://github.com/donurks/php-typed-array/

A base class for typed arrays.

  Sources   Download

MIT

The Development Requires

php array type