Skip to content

Commit

Permalink
__construct() performance improved
Browse files Browse the repository at this point in the history
  • Loading branch information
s3b4stian committed Jun 15, 2017
1 parent 8a7a312 commit 77e208e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [unrelased][v1.0.2](https://github.com/s3b4stian/linna-array/compare/v1.0.0...v1.0.2) - 2017-XX-XX

### Changed
* `Linna\TypedArray->__construct()` for better performance when object is created

## [v1.0.1](https://github.com/s3b4stian/linna-array/compare/v1.0.0...v1.0.1) - 2017-06-11

### Fixed
Expand Down
16 changes: 8 additions & 8 deletions src/TypedArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ class TypedArray extends ArrayObject
* @var array Types supported by class
*/
protected $allowedTypes = [
'array',
'bool',
'callable',
'float',
'int',
'object',
'string',
'array' => 1,
'bool' => 1,
'callable' => 1,
'float' => 1,
'int' => 1,
'object' => 1,
'string' => 1
];

/**
Expand All @@ -50,7 +50,7 @@ class TypedArray extends ArrayObject
public function __construct(string $type, array $array = [])
{
//single class, multi type support :)
if (!in_array($type, $this->allowedTypes)) {
if (!isset($this->allowedTypes[$type])) {
throw new InvalidArgumentException($type.' type passed to '.__CLASS__.' not supported');
}

Expand Down

0 comments on commit 77e208e

Please sign in to comment.