mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
30 lines
584 B
PHP
30 lines
584 B
PHP
|
<?php
|
||
|
|
||
|
namespace PhpMimeMailParser;
|
||
|
|
||
|
/**
|
||
|
* Wraps a callable as a Middleware
|
||
|
*/
|
||
|
class Middleware implements Contracts\Middleware
|
||
|
{
|
||
|
protected $parser;
|
||
|
|
||
|
/**
|
||
|
* Create a middleware using a callable $fn
|
||
|
*
|
||
|
* @param callable $fn
|
||
|
*/
|
||
|
public function __construct(callable $fn)
|
||
|
{
|
||
|
$this->parser = $fn;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Process a mime part, optionally delegating parsing to the $next MiddlewareStack
|
||
|
*/
|
||
|
public function parse(MimePart $part, MiddlewareStack $next)
|
||
|
{
|
||
|
return call_user_func($this->parser, $part, $next);
|
||
|
}
|
||
|
}
|