1<?php
2
3declare(strict_types=1);
4
5namespace JMS\Serializer\Visitor\Factory;
6
7use JMS\Serializer\Visitor\DeserializationVisitorInterface;
8use JMS\Serializer\XmlDeserializationVisitor;
9
10/**
11 * @author Asmir Mustafic <goetas@gmail.com>
12 */
13final class XmlDeserializationVisitorFactory implements DeserializationVisitorFactory
14{
15    /**
16     * @var bool
17     */
18    private $disableExternalEntities = true;
19
20    /**
21     * @var string[]
22     */
23    private $doctypeWhitelist = [];
24
25    public function getVisitor(): DeserializationVisitorInterface
26    {
27        return new XmlDeserializationVisitor($this->disableExternalEntities, $this->doctypeWhitelist);
28    }
29
30    public function enableExternalEntities(bool $enable = true): self
31    {
32        $this->disableExternalEntities = !$enable;
33        return $this;
34    }
35
36    /**
37     * @param string[] $doctypeWhitelist
38     */
39    public function setDoctypeWhitelist(array $doctypeWhitelist): self
40    {
41        $this->doctypeWhitelist = $doctypeWhitelist;
42        return $this;
43    }
44}
45