1<?php
2
3declare(strict_types=1);
4
5namespace JMS\Serializer\Tests\Fixtures;
6
7use JMS\Serializer\Annotation as Serializer;
8
9class AccessorSetter
10{
11    /**
12     * @Serializer\Type("JMS\Serializer\Tests\Fixtures\AccessorSetterElement")
13     * @Serializer\Accessor(setter="setElementDifferent")
14     *
15     * @var \stdClass
16     */
17    protected $element;
18
19    /**
20     * @Serializer\Type("array<string>")
21     * @Serializer\Accessor(setter="setCollectionDifferent")
22     * @Serializer\XmlList(inline=false)
23     *
24     * @var array
25     */
26    protected $collection;
27
28    /**
29     * @return \stdClass
30     */
31    public function getElement()
32    {
33        return $this->element;
34    }
35
36    /**
37     * @param AccessorSetterElement $element
38     */
39    public function setElementDifferent(AccessorSetterElement $element)
40    {
41        $this->element = new \stdClass();
42        $this->element->element = $element;
43    }
44
45    /**
46     * @return array
47     */
48    public function getCollection()
49    {
50        return $this->collection;
51    }
52
53    /**
54     * @param array $collection
55     */
56    public function setCollectionDifferent($collection)
57    {
58        $this->collection = array_combine($collection, $collection);
59    }
60}
61
62class AccessorSetterElement
63{
64    /**
65     * @Serializer\Type("string")
66     * @Serializer\Accessor(setter="setAttributeDifferent")
67     * @Serializer\XmlAttribute
68     *
69     * @var string
70     */
71    protected $attribute;
72
73    /**
74     * @Serializer\Type("string")
75     * @Serializer\Accessor(setter="setElementDifferent")
76     * @Serializer\XmlValue
77     *
78     * @var string
79     */
80    protected $element;
81
82    /**
83     * @return string
84     */
85    public function getAttribute()
86    {
87        return $this->attribute;
88    }
89
90    /**
91     * @param string $attribute
92     */
93    public function setAttributeDifferent($attribute)
94    {
95        $this->attribute = $attribute . '-different';
96    }
97
98    /**
99     * @param string $element
100     */
101    public function setElementDifferent($element)
102    {
103        $this->element = $element . '-different';
104    }
105
106    /**
107     * @return string
108     */
109    public function getElement()
110    {
111        return $this->element;
112    }
113}
114