Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 399 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 399 Revision 621
Zeile 82... Zeile 82...
82
     */
82
     */
83
    public function avg($callback = null)
83
    public function avg($callback = null)
84
    {
84
    {
85
        $callback = $this->valueRetriever($callback);
85
        $callback = $this->valueRetriever($callback);
Zeile 86... Zeile 86...
86
 
86
 
87
        $items = $this->map(function ($value) use ($callback) {
87
        $items = $this
88
            return $callback($value);
-
 
89
        })->filter(function ($value) {
88
            ->map(fn ($value) => $callback($value))
90
            return ! is_null($value);
-
 
Zeile 91... Zeile 89...
91
        });
89
            ->filter(fn ($value) => ! is_null($value));
92
 
90
 
93
        if ($count = $items->count()) {
91
        if ($count = $items->count()) {
94
            return $items->sum() / $count;
92
            return $items->sum() / $count;
Zeile 347... Zeile 345...
347
     * @return callable(TValue, TValue): bool
345
     * @return callable(TValue, TValue): bool
348
     */
346
     */
349
    protected function duplicateComparator($strict)
347
    protected function duplicateComparator($strict)
350
    {
348
    {
351
        if ($strict) {
349
        if ($strict) {
352
            return function ($a, $b) {
350
            return fn ($a, $b) => $a === $b;
353
                return $a === $b;
-
 
354
            };
-
 
355
        }
351
        }
Zeile 356... Zeile 352...
356
 
352
 
357
        return function ($a, $b) {
-
 
358
            return $a == $b;
-
 
359
        };
353
        return fn ($a, $b) => $a == $b;
Zeile 360... Zeile 354...
360
    }
354
    }
361
 
355
 
362
    /**
356
    /**
Zeile 1631... Zeile 1625...
1631
     * @param  \Illuminate\Contracts\Support\Arrayable<array-key, TZipValue>|iterable<array-key, TZipValue>  ...$items
1625
     * @param  \Illuminate\Contracts\Support\Arrayable<array-key, TZipValue>|iterable<array-key, TZipValue>  ...$items
1632
     * @return static<int, static<int, TValue|TZipValue>>
1626
     * @return static<int, static<int, TValue|TZipValue>>
1633
     */
1627
     */
1634
    public function zip($items)
1628
    public function zip($items)
1635
    {
1629
    {
1636
        $arrayableItems = array_map(function ($items) {
1630
        $arrayableItems = array_map(fn ($items) => $this->getArrayableItems($items), func_get_args());
1637
            return $this->getArrayableItems($items);
-
 
1638
        }, func_get_args());
-
 
1639
 
1631
 
1640
        $params = array_merge([function () {
-
 
1641
            return new static(func_get_args());
1632
        $params = array_merge([fn () => new static(func_get_args()), $this->items], $arrayableItems);
1642
        }, $this->items], $arrayableItems);
-
 
Zeile 1643... Zeile 1633...
1643
 
1633
 
1644
        return new static(array_map(...$params));
1634
        return new static(array_map(...$params));
Zeile 1645... Zeile 1635...
1645
    }
1635
    }