Skip to content

Commit 3277dcd

Browse files
committed
move to public readonly properties
1 parent d6dd0bd commit 3277dcd

File tree

95 files changed

+342
-1215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

95 files changed

+342
-1215
lines changed

src/CXml/Authentication/SimpleSharedSecretAuthenticator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ public function __construct(private string $sharedSecret)
1616

1717
public function authenticate(Header $header, Context $context): void
1818
{
19-
if ($this->sharedSecret !== $header->getSender()->getCredential()->getSharedSecret()) {
20-
throw new CXmlAuthenticationInvalidException($header->getSender()->getCredential());
19+
if ($this->sharedSecret !== $header->sender->credential->sharedSecret) {
20+
throw new CXmlAuthenticationInvalidException($header->sender->credential);
2121
}
2222
}
2323
}

src/CXml/Builder/OrderRequestBuilder.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,12 +86,12 @@ public static function fromPunchOutOrderMessage(
8686
?DateTimeInterface $orderDate = null,
8787
string $language = 'en',
8888
): self {
89-
if (($supplierOrderInfo = $punchOutOrderMessage->getPunchOutOrderMessageHeader()->getSupplierOrderInfo()) instanceof SupplierOrderInfo) {
90-
$orderId ??= $supplierOrderInfo->getOrderId();
91-
$orderDate ??= $supplierOrderInfo->getOrderDate();
89+
if (($supplierOrderInfo = $punchOutOrderMessage->punchOutOrderMessageHeader->getSupplierOrderInfo()) instanceof SupplierOrderInfo) {
90+
$orderId ??= $supplierOrderInfo->orderId;
91+
$orderDate ??= $supplierOrderInfo->orderDate;
9292
}
9393

94-
$currency ??= $punchOutOrderMessage->getPunchOutOrderMessageHeader()->getTotal()->getMoney()->getCurrency();
94+
$currency ??= $punchOutOrderMessage->punchOutOrderMessageHeader->total->money->currency;
9595

9696
if (null === $orderId) {
9797
throw new LogicException('orderId should either be given or present in the PunchOutOrderMessage');
@@ -109,15 +109,15 @@ public static function fromPunchOutOrderMessage(
109109
null,
110110
);
111111

112-
$orb->setShipTo($punchOutOrderMessage->getPunchOutOrderMessageHeader()->getShipTo());
112+
$orb->setShipTo($punchOutOrderMessage->punchOutOrderMessageHeader->getShipTo());
113113

114114
foreach ($punchOutOrderMessage->getPunchoutOrderMessageItems() as $item) {
115115
$orb->addItem(
116-
$item->getQuantity(),
117-
$item->getItemId(),
118-
$item->getItemDetail()->getDescription()->getValue(),
119-
$item->getItemDetail()->getUnitOfMeasure(),
120-
$item->getItemDetail()->getUnitPrice()->getMoney()->getValueCent(),
116+
$item->quantity,
117+
$item->itemId,
118+
$item->itemDetail->description->value,
119+
$item->itemDetail->unitOfMeasure,
120+
$item->itemDetail->unitPrice->money->getValueCent(),
121121
[
122122
new Classification('custom', '0'), // TODO make this configurable
123123
],
@@ -252,13 +252,13 @@ public function addItem(
252252
$priceBasisQuantity,
253253
),
254254
$requestDeliveryDate,
255-
$parent instanceof ItemOut ? $parent->getLineNumber() : null,
255+
$parent instanceof ItemOut ? $parent->lineNumber : null,
256256
);
257257

258258
$this->items[] = $item;
259259

260-
if ($priceBasisQuantity instanceof PriceBasisQuantity && $priceBasisQuantity->getQuantity() > 0) {
261-
$this->total += (int)round($quantity * ($priceBasisQuantity->getConversionFactor() / $priceBasisQuantity->getQuantity()) * $unitPrice);
260+
if ($priceBasisQuantity instanceof PriceBasisQuantity && $priceBasisQuantity->quantity > 0) {
261+
$this->total += (int)round($quantity * ($priceBasisQuantity->conversionFactor / $priceBasisQuantity->quantity) * $unitPrice);
262262
} else {
263263
$this->total += ($quantity * $unitPrice);
264264
}

src/CXml/Builder/PunchOutOrderMessageBuilder.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,15 @@ public function addItem(ItemIn $itemIn): self
165165
{
166166
$this->punchoutOrderMessageItems[] = $itemIn;
167167

168-
$moneyValueCent = $itemIn->getItemDetail()->getUnitPrice()->getMoney()->getValueCent();
169-
$itemQty = $itemIn->getQuantity();
168+
$moneyValueCent = $itemIn->itemDetail->unitPrice->money->getValueCent();
169+
$itemQty = $itemIn->quantity;
170170

171171
if (
172-
$itemIn->getItemDetail()->getPriceBasisQuantity() instanceof PriceBasisQuantity
173-
&& $itemIn->getItemDetail()->getPriceBasisQuantity()->getQuantity() > 0
172+
$itemIn->itemDetail->priceBasisQuantity instanceof PriceBasisQuantity
173+
&& $itemIn->itemDetail->priceBasisQuantity->quantity > 0
174174
) {
175-
$priceBasisQuantity = $itemIn->getItemDetail()->getPriceBasisQuantity();
176-
$this->total += (int)round($itemQty * ($priceBasisQuantity->getConversionFactor() / $priceBasisQuantity->getQuantity()) * $moneyValueCent);
175+
$priceBasisQuantity = $itemIn->itemDetail->priceBasisQuantity;
176+
$this->total += (int)round($itemQty * ($priceBasisQuantity->conversionFactor / $priceBasisQuantity->quantity) * $moneyValueCent);
177177
} else {
178178
$this->total += $moneyValueCent * $itemQty;
179179
}

src/CXml/Context.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ public function getSenderUserAgent(): ?string
6161
return null;
6262
}
6363

64-
$header = $cxml->getHeader();
64+
$header = $cxml->header;
6565
if (!$header instanceof Header) {
6666
return null;
6767
}
6868

69-
return $header->getSender()->getUserAgent();
69+
return $header->sender->userAgent;
7070
}
7171

7272
public function getPayloadId(): ?string
@@ -76,6 +76,6 @@ public function getPayloadId(): ?string
7676
return null;
7777
}
7878

79-
return $cxml->getPayloadId();
79+
return $cxml->payloadId;
8080
}
8181
}

src/CXml/Credential/Registry.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public function registerCredential(Credential $credential): void
3131
public function getCredentialByDomainAndId(string $domain, string $identity): Credential
3232
{
3333
foreach ($this->registeredCredentials as $registeredCredential) {
34-
if ($registeredCredential->getDomain() !== $domain) {
34+
if ($registeredCredential->domain !== $domain) {
3535
continue;
3636
}
3737

38-
if ($registeredCredential->getIdentity() !== $identity) {
38+
if ($registeredCredential->identity !== $identity) {
3939
continue;
4040
}
4141

@@ -51,14 +51,14 @@ public function getCredentialByDomainAndId(string $domain, string $identity): Cr
5151
*/
5252
public function authenticate(Header $header, Context $context): void
5353
{
54-
$senderCredential = $header->getSender()->getCredential();
54+
$senderCredential = $header->sender->credential;
5555

5656
$baseCredential = $this->getCredentialByDomainAndId(
57-
$senderCredential->getDomain(),
58-
$senderCredential->getIdentity(),
57+
$senderCredential->domain,
58+
$senderCredential->identity,
5959
);
6060

61-
if ($baseCredential->getSharedSecret() !== $senderCredential->getSharedSecret()) {
61+
if ($baseCredential->sharedSecret !== $senderCredential->sharedSecret) {
6262
throw new CXmlAuthenticationInvalidException($senderCredential);
6363
}
6464
}
@@ -70,8 +70,8 @@ public function validate(Credential $credential): void
7070
{
7171
// provoke an exception if credential was not found
7272
$this->getCredentialByDomainAndId(
73-
$credential->getDomain(),
74-
$credential->getIdentity(),
73+
$credential->domain,
74+
$credential->identity,
7575
);
7676
}
7777
}

src/CXml/Jms/CXmlWrappingNodeJmsEventSubscriber.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function onPostSerializePayment(ObjectEvent $event): void
8686
{
8787
$visitor = $event->getVisitor();
8888

89-
$paymentImpl = $event->getObject()->getPaymentImpl();
89+
$paymentImpl = $event->getObject()->paymentImpl;
9090

9191
$cls = (new ReflectionClass($paymentImpl))->getShortName();
9292

@@ -147,7 +147,7 @@ public function onPostSerializeCXmlMainPayload(ObjectEvent $event): void
147147

148148
// this is the actual payload object of type MessagePayloadInterface
149149
/** @phpstan-ignore-next-line */
150-
$payload = $event->getObject()->getPayload();
150+
$payload = $event->getObject()->payload ?? null;
151151

152152
if ($payload) {
153153
$cls = (new ReflectionClass($payload))->getShortName();

src/CXml/Model/Accounting.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
{
1111
private function __construct(
1212
#[Serializer\XmlAttribute]
13-
private string $name,
13+
public string $name,
1414
/**
1515
* @var AccountingSegment[]
1616
*/
1717
#[Serializer\XmlList(entry: 'AccountingSegment', inline: true)]
1818
#[Serializer\Type('array<CXml\Model\AccountingSegment>')]
19-
private array $accountingSegments,
19+
public array $accountingSegments,
2020
#[Serializer\SerializedName('Charge')]
21-
private MoneyWrapper $charge,
21+
public MoneyWrapper $charge,
2222
) {
2323
}
2424
}

src/CXml/Model/AccountingSegment.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
{
1111
private function __construct(
1212
#[Serializer\XmlAttribute]
13-
private int $id,
13+
public int $id,
1414
#[Serializer\SerializedName('Name')]
1515
#[Serializer\XmlElement(cdata: false)]
16-
private MultilanguageString $name,
16+
public MultilanguageString $name,
1717
#[Serializer\SerializedName('Description')]
1818
#[Serializer\XmlElement(cdata: false)]
19-
private MultilanguageString $description,
19+
public MultilanguageString $description,
2020
) {
2121
}
2222
}

src/CXml/Model/Address.php

Lines changed: 8 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -12,67 +12,27 @@
1212
public function __construct(
1313
#[Serializer\SerializedName('Name')]
1414
#[Serializer\XmlElement(cdata: false)]
15-
private MultilanguageString $name,
15+
public MultilanguageString $name,
1616
#[Serializer\SerializedName('PostalAddress')]
17-
private ?PostalAddress $postalAddress = null,
17+
public ?PostalAddress $postalAddress = null,
1818
#[Serializer\XmlAttribute]
1919
#[Serializer\SerializedName('addressID')]
20-
private ?string $addressId = null,
20+
public ?string $addressId = null,
2121
#[Serializer\XmlAttribute]
2222
#[Serializer\SerializedName('addressIDDomain')]
23-
private ?string $addressIdDomain = null,
23+
public ?string $addressIdDomain = null,
2424
#[Serializer\SerializedName('Email')]
2525
#[Serializer\XmlElement(cdata: false)]
26-
private ?string $email = null,
26+
public ?string $email = null,
2727
#[Serializer\SerializedName('Phone')]
2828
#[Serializer\XmlElement(cdata: false)]
29-
private ?Phone $phone = null,
29+
public ?Phone $phone = null,
3030
#[Serializer\SerializedName('Fax')]
3131
#[Serializer\XmlElement(cdata: false)]
32-
private ?string $fax = null,
32+
public ?string $fax = null,
3333
#[Serializer\SerializedName('URL')]
3434
#[Serializer\XmlElement(cdata: false)]
35-
private ?string $url = null,
35+
public ?string $url = null,
3636
) {
3737
}
38-
39-
public function getAddressId(): ?string
40-
{
41-
return $this->addressId;
42-
}
43-
44-
public function getAddressIdDomain(): ?string
45-
{
46-
return $this->addressIdDomain;
47-
}
48-
49-
public function getName(): MultilanguageString
50-
{
51-
return $this->name;
52-
}
53-
54-
public function getPostalAddress(): ?PostalAddress
55-
{
56-
return $this->postalAddress;
57-
}
58-
59-
public function getEmail(): ?string
60-
{
61-
return $this->email;
62-
}
63-
64-
public function getPhone(): ?Phone
65-
{
66-
return $this->phone;
67-
}
68-
69-
public function getFax(): ?string
70-
{
71-
return $this->fax;
72-
}
73-
74-
public function getUrl(): ?string
75-
{
76-
return $this->url;
77-
}
7838
}

src/CXml/Model/BillTo.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace CXml\Model;
66

7+
use CXml\Model\Trait\IdReferencesTrait;
78
use JMS\Serializer\Annotation as Serializer;
89

910
#[Serializer\AccessorOrder(order: 'custom', custom: ['address', 'idReferences'])]
@@ -13,12 +14,7 @@ class BillTo
1314

1415
public function __construct(
1516
#[Serializer\SerializedName('Address')]
16-
private readonly Address $address,
17+
public readonly Address $address,
1718
) {
1819
}
19-
20-
public function getAddress(): Address
21-
{
22-
return $this->address;
23-
}
2420
}

0 commit comments

Comments
 (0)