Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
SubjectReader.php
Go to the documentation of this file.
1 <?php
7 
10 
19 {
26  public static function readPayment(array $subject)
27  {
28  if (!isset($subject['payment'])
29  || !$subject['payment'] instanceof PaymentDataObjectInterface
30  ) {
31  throw new \InvalidArgumentException('Payment data object should be provided');
32  }
33 
34  return $subject['payment'];
35  }
36 
43  public static function readAmount(array $subject)
44  {
45  if (!isset($subject['amount']) || !is_numeric($subject['amount'])) {
46  throw new \InvalidArgumentException('Amount should be provided');
47  }
48 
49  return $subject['amount'];
50  }
51 
58  public static function readField(array $subject)
59  {
60  if (!isset($subject['field']) || !is_string($subject['field'])) {
61  throw new \InvalidArgumentException('Field does not exist');
62  }
63 
64  return $subject['field'];
65  }
66 
73  public static function readResponse(array $subject)
74  {
75  if (!isset($subject['response']) || !is_array($subject['response'])) {
76  throw new \InvalidArgumentException('Response does not exist');
77  }
78 
79  return $subject['response'];
80  }
81 
88  public static function readStateObject(array $subject)
89  {
90  if (!isset($subject['stateObject']) || !$subject['stateObject'] instanceof DataObject) {
91  throw new \InvalidArgumentException('State object does not exist');
92  }
93 
94  return $subject['stateObject'];
95  }
96 }