• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

zfegg / psr-mvc / 6174499731

13 Sep 2023 03:19PM UTC coverage: 94.545% (-2.1%) from 96.623%
6174499731

Pull #20

github

web-flow
Merge f52f20a15 into 63d3fcb42
Pull Request #20: Remove factories, use `laminas/lamians-di` instead.

14 of 14 new or added lines in 3 files covered. (100.0%)

832 of 880 relevant lines covered (94.55%)

6.16 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.71
/src/Preparer/PreparerStack.php
1
<?php
2

3
declare(strict_types = 1);
4

5
namespace Zfegg\PsrMvc\Preparer;
6

7
use Psr\Http\Message\ResponseInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use SplStack;
10
use Zfegg\PsrMvc\Exception\InvalidArgumentException;
11

12
class PreparerStack extends SplStack implements ResultPreparableInterface
13
{
14

15
    public function __construct(iterable $preparers = [])
16
    {
17
        foreach ($preparers as $preparer) {
17✔
18
            $this->push($preparer);
×
19
        }
20
    }
21

22
    public function prepare(ServerRequestInterface $request, mixed $result, array $options = []): ResponseInterface
23
    {
24
        /** @var ResultPreparableInterface $preparer */
25
        foreach ($this as $preparer) {
8✔
26
            if ($preparer->supportsPreparation($request, $result, $options)) {
8✔
27
                return $preparer->prepare($request, $result, $options);
7✔
28
            }
29
        }
30

31
        throw new InvalidArgumentException("Resolve result error.");
1✔
32
    }
33

34
    public function supportsPreparation(ServerRequestInterface $request, mixed $result, array $options = []): bool
35
    {
36
        return $this->count() > 0;
1✔
37
    }
38
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc