diff --git a/README.md b/README.md index d079538..0b2b0b2 100644 --- a/README.md +++ b/README.md @@ -54,23 +54,10 @@ - `>= php 8.0+` -## Installation +## Installation -Prior to installing `ultimate-uploader` get the [Composer](https://getcomposer.org) dependency manager for PHP because it'll simplify installation. +Prior to installing `support package` get the [Composer](https://getcomposer.org) dependency manager for PHP because it'll simplify installation. -**Step 1** — update your `composer.json`: -```composer.json -"require": { - "tamedevelopers/validator": "^4.2.1" -} -``` - -**Step 2** — run [Composer](https://getcomposer.org): -```update -composer update -``` - -**Or composer require**: ``` composer require tamedevelopers/validator ``` @@ -89,14 +76,15 @@ use \Tamedevelopers\Validator\Validator; $form = new Validator(); ``` -- **Example 2** +- **Example 2** — `You can also pass in any data type` and this will be taken and pass to the `attribute` property. ``` -$data = [ +$form = new Tamedevelopers\Validator\Validator([ 'user' => 'F. Pete', 'marital' => 'Single', -]; +]); -$form = new Tamedevelopers\Validator\Validator($data); +// this will return the data you pass +$form->attribute ``` - or -- `Helpers Function` diff --git a/composer.json b/composer.json index 4b54543..544305b 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ ], "require": { "php": ">=8.0", - "tamedevelopers/support": "^1.0.2" + "tamedevelopers/support": "^1.0.6" }, "autoload": { "files": [ diff --git a/src/Collections/Collection.php b/src/Collections/Collection.php deleted file mode 100644 index 0b028fa..0000000 --- a/src/Collections/Collection.php +++ /dev/null @@ -1,198 +0,0 @@ -items = $this->convertOnInit($items); - } - - /** - * Get an iterator for the items. - * - * @return ArrayIterator - */ - public function getIterator() : Traversable - { - return new ArrayIterator($this->items); - } - - /** - * Determine if an item exists at an offset. - * - * @param mixed $offset - * @return bool - */ - public function offsetExists($offset): bool - { - return $this->__isset($offset); - } - - /** - * Get an item at a given offset. - * - * @param mixed $offset - * @return mixed - */ - public function offsetGet($offset): mixed - { - return $this->__get($offset); - } - - /** - * Set the item at a given offset. - * - * @param mixed $offset - * @param mixed $value - * @return void - */ - public function offsetSet($offset, $value): void - { - $this->__set($offset, $value); - } - - /** - * Unset the item at a given offset. - * - * @param mixed $offset - * @return void - */ - public function offsetUnset($offset): void - { - $this->__unset($offset); - } - - /** - * Determine if the collection has a given key. - * - * @param mixed $key - * @return bool - */ - public function has($key) - { - return array_key_exists($key, $this->items); - } - - /** - * Dynamically access collection items. - * - * @param string $key - * @return mixed - */ - public function __get($key) - { - return $this->items[$key] ?? null; - } - - /** - * Dynamically set an item in the collection. - * - * @param string $key - * @param mixed $value - * @return void - */ - public function __set($key, $value) - { - $this->items[$key] = $value; - } - - /** - * Check if an item exists in the collection. - * - * @param string $key - * @return bool - */ - public function __isset($key) - { - return isset($this->items[$key]); - } - - /** - * Remove an item from items collection. - * - * @param string $key - * @return void - */ - public function __unset($key) - { - unset($this->items[$key]); - } - - /** - * Count the number of items in the collection. - * - * @return int - */ - public function count(): int - { - return is_array($this->items) - ? count($this->items) - : 0; - } - - /** - * Convert data to array - * - * @return array - */ - public function toArray() - { - return is_array($this->items) - ? $this->items - : []; - } - - /** - * Convert data to object - * - * @return object - */ - public function toObject() - { - return json_decode( json_encode($this->items), false); - } - - /** - * Convert data to json - * - * @return string - */ - public function toJson() - { - return json_encode($this->items); - } - - /** - * Convert data to an array on Initializaiton - * @param mixed $items - * - * @return array - */ - private function convertOnInit(mixed $items = null) - { - return json_decode( json_encode($items), true); - } - -} \ No newline at end of file diff --git a/src/Methods/ValidatorMethod.php b/src/Methods/ValidatorMethod.php index 73b71c0..c0e948b 100644 --- a/src/Methods/ValidatorMethod.php +++ b/src/Methods/ValidatorMethod.php @@ -5,7 +5,7 @@ namespace Tamedevelopers\Validator\Methods; use Tamedevelopers\Validator\Validator; -use Tamedevelopers\Validator\Collections\Collection; +use Tamedevelopers\Support\Collections\Collection; class ValidatorMethod { diff --git a/src/Validator.php b/src/Validator.php index 75c5a4a..639571e 100644 --- a/src/Validator.php +++ b/src/Validator.php @@ -13,8 +13,8 @@ namespace Tamedevelopers\Validator; +use Tamedevelopers\Support\Collections\Collection; use Tamedevelopers\Validator\Traits\PropertyTrait; -use Tamedevelopers\Validator\Collections\Collection; use Tamedevelopers\Validator\Traits\ValidatorTrait; use Tamedevelopers\Validator\Methods\ValidatorMethod; use Tamedevelopers\Validator\Traits\SubmitSuccessTrait;