diff --git a/.gitignore b/.gitignore index c37da9f..62ead3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ /.idea /vendor -composer.lock \ No newline at end of file +composer.lock +.phpunit.result.cache \ No newline at end of file diff --git a/composer.json b/composer.json index 1db2f64..4540fd1 100644 --- a/composer.json +++ b/composer.json @@ -2,12 +2,12 @@ "name": "loomlabs/utility.collection", "autoload": { "psr-4": { - "LoomLabs\\Utility\\Collection\\": "src/" + "Loom\\Utility\\Collection\\": "src/" } }, "autoload-dev": { "psr-4": { - "LoomLabs\\Utility\\Collection\\Tests\\": "tests/" + "Loom\\Utility\\Collection\\Tests\\": "tests/" } }, "version": "1.0.0", diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..43d44c7 --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,23 @@ + + + + + tests + + + + + + + src/ + + + \ No newline at end of file diff --git a/src/AbstractCollection.php b/src/AbstractCollection.php new file mode 100644 index 0000000..a8bd9dd --- /dev/null +++ b/src/AbstractCollection.php @@ -0,0 +1,24 @@ +items[] = $item; + } + + public function toArray(): array + { + return $this->items; + } +} \ No newline at end of file diff --git a/src/Collection.php b/src/Collection.php new file mode 100644 index 0000000..2c0fe00 --- /dev/null +++ b/src/Collection.php @@ -0,0 +1,18 @@ +items); + } + + public function count(): int + { + return count($this->items); + } +} \ No newline at end of file diff --git a/src/Interface/CollectionInterface.php b/src/Interface/CollectionInterface.php new file mode 100644 index 0000000..9f052c8 --- /dev/null +++ b/src/Interface/CollectionInterface.php @@ -0,0 +1,10 @@ +add($itemToAdd); + + $this->assertEquals($expectedResult, $collection->toArray()); + } + + public static function addDataProvider(): array + { + return [ + [ + 'startingItems' => ['apple', 'banana', 'cherry'], + 'itemToAdd' => 'grape', + 'expectedResult' => ['apple', 'banana', 'cherry', 'grape'], + ], + [ + 'startingItems' => [], + 'itemToAdd' => 1, + 'expectedResult' => [1], + ], + + ]; + } +} \ No newline at end of file