Skip to content

Commit 11dd34f

Browse files
committed
if comment has a textual value, we dont serialize the <Attachment> element anymore. See DTD:
1 parent 73aa01f commit 11dd34f

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/CXml/Jms/CXmlExclusionStrategy.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@ public function shouldSkipClass(ClassMetadata $metadata, Context $context): bool
1818
public function shouldSkipProperty(PropertyMetadata $property, Context $context): bool
1919
{
2020
// Check if we are serializing to XML
21-
if ($context->getFormat() !== 'xml') {
21+
if ('xml' !== $context->getFormat()) {
2222
return false;
2323
}
2424

25-
if ($property->class === Comment::class) {
26-
if ($property->name === 'attachment') {
25+
if (Comment::class === $property->class) {
26+
if ('attachment' === $property->name) {
2727
/** @var Comment $object */
2828
$object = $context->getObject();
2929

30-
//if comment has a textual value, we dont serialize the <Attachment> element anymore. See DTD:
31-
//<!ELEMENT Comments ( #PCDATA | Attachment )* >
30+
// if comment has a textual value, we dont serialize the <Attachment> element anymore. See DTD:
31+
// <!ELEMENT Comments ( #PCDATA | Attachment )* >
3232
if (isset($object->value)) {
3333
return true;
3434
}

src/CXml/Serializer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public static function create(): self
5656
)
5757
->setSerializationContextFactory(function() {
5858
return SerializationContext::create()
59-
->addExclusionStrategy(new CXmlExclusionStrategy());
59+
->addExclusionStrategy(new CXmlExclusionStrategy());
6060
})
6161
->build();
6262

tests/CXmlTest/Model/OrderRequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function setUp(): void
5151

5252
public function testReference(): void
5353
{
54-
//test whether deserialize/serialize of the reference file works
54+
// test whether deserialize/serialize of the reference file works
5555
$xml = file_get_contents(__DIR__ . '/../../metadata/cxml/samples/OrderRequest.xml');
5656
$cxml = Serializer::create()->deserialize($xml);
5757
Serializer::create()->serialize($cxml);
@@ -182,7 +182,7 @@ public function testMinimumExample(): void
182182
),
183183
new DateTime('2020-02-28'),
184184
);
185-
$item->addComment(new Comment('Test comment', 'test', '')); //, 'delivery-note.pdf'));
185+
$item->addComment(new Comment('Test comment', 'test', ''));
186186

187187
$orderRequest->addItem($item);
188188

0 commit comments

Comments
 (0)