miquido/observable

View on GitHub
src/Operator/Count.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

declare(strict_types=1);

namespace Miquido\Observable\Operator;

use Miquido\Observable\ObservableInterface;
use Miquido\Observable\OperatorInterface;

final class Count implements OperatorInterface
{
    public function process(ObservableInterface $source): ObservableInterface
    {
        return $source->pipe(new Reduce(function (int $carry): int {
            return $carry + 1;
        }, 0));
    }
}