Compare commits

..

No commits in common. "fa8adcace1b203dca1de4b958896f6668bdfec47" and "c6bfaa05f22e4599d923c7fad6a6ae4f71011c53" have entirely different histories.

2 changed files with 19 additions and 29 deletions

View File

@ -4,7 +4,7 @@ Welcome to the official Ulmus documentation.
## Quick start ## Quick start
Creating a simple user exemple entity: Creating a simple user entity:
*/app/entity/user.php* */app/entity/user.php*
```php ```php
@ -21,19 +21,29 @@ class User
{ {
use \Ulmus\EntityTrait; use \Ulmus\EntityTrait;
#[Field\Id] /**
* @Id
*/
public int $id; public int $id;
#[Field] /**
* @Field
*/
public string $fullname; public string $fullname;
#[Field] /**
* @Field
*/
public ? string $email; public ? string $email;
#[Field] /**
* @Field('name' => 'is_admin')
*/
public bool $isAdmin = false; public bool $isAdmin = false;
#[Field\Datetime] /**
* @DateTime
*/
public Datetime $birthday; public Datetime $birthday;
} }
``` ```

View File

@ -58,26 +58,6 @@ class EntityCollection extends \ArrayObject {
return null; return null;
} }
public function extract(Callable $callback) : self
{
$idx = 0;
$replace = [];
$collection = new static();
foreach($this as $key => $item) {
if ( $callback($item, $key, $idx++) ) {
$collection->append($item);
}
else {
$replace[] = $item;
}
}
$this->replaceWith($replace);
return $collection;
}
public function iterate(Callable $callback) : self public function iterate(Callable $callback) : self
{ {
foreach($this as $item) { foreach($this as $item) {
@ -137,17 +117,17 @@ class EntityCollection extends \ArrayObject {
public function searchAll(/* mixed*/ $values, string $field, bool $strict = true, bool $compareArray = false) : self public function searchAll(/* mixed*/ $values, string $field, bool $strict = true, bool $compareArray = false) : self
{ {
$collection = new static(); $obj = new static();
$values = is_array($values) && $compareArray ? [ $values ] : $values; $values = is_array($values) && $compareArray ? [ $values ] : $values;
foreach((array) $values as $value) { foreach((array) $values as $value) {
foreach ($this->search($value, $field, $strict) as $item) { foreach ($this->search($value, $field, $strict) as $item) {
$collection->append($item); $obj->append($item);
} }
} }
return $collection; return $obj;
} }
public function diffAll(/* mixed */ $values, string $field, bool $strict = true, bool $compareArray = false) : self public function diffAll(/* mixed */ $values, string $field, bool $strict = true, bool $compareArray = false) : self