Code Duplication    Length = 18-18 lines in 2 locations

Query/QueryBus.php 1 location

@@ 77-94 (lines=18) @@
74
     *
75
     * @throws NotFoundException
76
     */
77
    protected function ensureQueryHandlerMiddleware()
78
    {
79
        if ($this->queryHandlerMiddleware !== null) {
80
            return;
81
        }
82
83
        foreach ($this->middlewares as $priority => $collection) {
84
            foreach ($collection as $middleware) {
85
                if ($middleware instanceof QueryHandlerMiddleware) {
86
                    $this->queryHandlerMiddleware = $middleware;
87
88
                    return;
89
                }
90
            }
91
        }
92
93
        throw NotFoundException::middlewareOfType(QueryHandlerMiddleware::class);
94
    }
95
96
    /**
97
     * @return QueryHandlerMiddleware

Command/CommandBus.php 1 location

@@ 80-97 (lines=18) @@
77
     *
78
     * @throws NotFoundException
79
     */
80
    protected function ensureCommandHandlerMiddleware()
81
    {
82
        if ($this->commandHandlerMiddleware !== null) {
83
            return;
84
        }
85
86
        foreach ($this->middlewares as $priority => $collection) {
87
            foreach ($collection as $middleware) {
88
                if ($middleware instanceof CommandHandlerMiddleware) {
89
                    $this->commandHandlerMiddleware = $middleware;
90
91
                    return;
92
                }
93
            }
94
        }
95
96
        throw NotFoundException::middlewareOfType(CommandHandlerMiddleware::class);
97
    }
98
99
    /**
100
     * @return CommandHandlerMiddleware