nicoSWD /
headsec
| 1 | <?php declare(strict_types=1); |
||
| 2 | |||
| 3 | /** |
||
| 4 | * @license http://opensource.org/licenses/mit-license.php MIT |
||
| 5 | * @link https://github.com/nicoSWD |
||
| 6 | * @author Nicolas Oelgart <[email protected]> |
||
| 7 | */ |
||
| 8 | namespace nicoSWD\SecHeaderCheck\Domain\Result; |
||
| 9 | |||
| 10 | use nicoSWD\SecHeaderCheck\Domain\Header\SecurityHeader; |
||
| 11 | use nicoSWD\SecHeaderCheck\Domain\Result\Result\ContentSecurityPolicyHeaderResult; |
||
| 12 | use nicoSWD\SecHeaderCheck\Domain\Result\Result\XFrameOptionsHeaderResult; |
||
| 13 | |||
| 14 | final class ParsedHeaders |
||
| 15 | { |
||
| 16 | /** @var ParsedHeaderBag */ |
||
| 17 | private $headers; |
||
| 18 | |||
| 19 | 2 | public function __construct() |
|
| 20 | { |
||
| 21 | 2 | $this->headers = new ParsedHeaderBag(); |
|
| 22 | 2 | } |
|
| 23 | |||
| 24 | 2 | public function add(AbstractParsedHeader $header): void |
|
| 25 | { |
||
| 26 | 2 | $this->headers->add($header); |
|
| 27 | 2 | } |
|
| 28 | |||
| 29 | public function all(): ParsedHeaderBag |
||
| 30 | { |
||
| 31 | return $this->headers; |
||
| 32 | } |
||
| 33 | |||
| 34 | /** @return ContentSecurityPolicyHeaderResult[] */ |
||
| 35 | public function getContentSecurityPolicyResult() |
||
| 36 | { |
||
| 37 | return $this->headers->findMultiple(SecurityHeader::CONTENT_SECURITY_POLICY); |
||
| 38 | } |
||
| 39 | |||
| 40 | public function getXFrameOptionsResult(): ?XFrameOptionsHeaderResult |
||
| 41 | { |
||
| 42 | return $this->headers->findOne(SecurityHeader::X_FRAME_OPTIONS); |
||
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 43 | } |
||
| 44 | } |
||
| 45 |