Skip to content

Commit 77e208e

Browse files
committed
__construct() performance improved
1 parent 8a7a312 commit 77e208e

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ All notable changes to this project will be documented in this file.
66
The format is based on [Keep a Changelog](http://keepachangelog.com/)
77
and this project adheres to [Semantic Versioning](http://semver.org/).
88

9+
## [unrelased][v1.0.2](https://github.com/s3b4stian/linna-array/compare/v1.0.0...v1.0.2) - 2017-XX-XX
10+
11+
### Changed
12+
* `Linna\TypedArray->__construct()` for better performance when object is created
13+
914
## [v1.0.1](https://github.com/s3b4stian/linna-array/compare/v1.0.0...v1.0.1) - 2017-06-11
1015

1116
### Fixed

src/TypedArray.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ class TypedArray extends ArrayObject
2323
* @var array Types supported by class
2424
*/
2525
protected $allowedTypes = [
26-
'array',
27-
'bool',
28-
'callable',
29-
'float',
30-
'int',
31-
'object',
32-
'string',
26+
'array' => 1,
27+
'bool' => 1,
28+
'callable' => 1,
29+
'float' => 1,
30+
'int' => 1,
31+
'object' => 1,
32+
'string' => 1
3333
];
3434

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

0 commit comments

Comments
 (0)