Skip to content

Commit 310d252

Browse files
authored
Merge pull request #6 from infocyph/feature/improvement-25
updated to add common functions
2 parents 6784ff6 + 86a8bb6 commit 310d252

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/Collection/BaseCollectionTrait.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,21 @@ public function __construct(array $data = [])
2929
$this->data = $data;
3030
}
3131

32+
/**
33+
* Create a new instance of the collection from the given data.
34+
*
35+
* This method acts as a wrapper around the `make` method,
36+
* allowing for the creation of a collection instance using
37+
* the provided data. The data is processed to ensure it is
38+
* in an array format suitable for the collection.
39+
*
40+
* @param mixed $data The data to initialize the collection with.
41+
* @return static A new instance of the collection.
42+
*/
43+
public static function from(mixed $data): static
44+
{
45+
return static::make($data);
46+
}
3247

3348
/**
3449
* Create a new instance of the collection with the given data.
@@ -46,7 +61,6 @@ public static function make(mixed $data): static
4661
return $instance;
4762
}
4863

49-
5064
/**
5165
* Dynamically handle calls to methods on the collection.
5266
*

0 commit comments

Comments
 (0)