PayU integration by Krzysztof Gzocha
  • Namespace
  • Class

Namespaces

  • Team3
    • PayU
      • Annotation
      • Communication
        • CurlRequestBuilder
        • HttpStatusParser
        • Notification
        • Process
          • NotificationProcess
          • ResponseDeserializer
        • Request
          • Model
        • Response
          • Model
        • Sender
      • Configuration
        • Credentials
      • Order
        • Autocomplete
          • Strategy
        • Model
          • Buyer
          • Money
          • Products
          • ShippingMethods
          • Traits
        • Transformer
          • UserOrder
            • Strategy
              • Product
              • ShippingMethod
      • PropertyExtractor
        • Reader
      • Serializer
      • SignatureCalculator
        • Encoder
          • Algorithms
          • Strategy
        • ParametersSorter
        • Validator
      • ValidatorBuilder

Classes

  • Team3\PayU\ValidatorBuilder\ValidatorBuilder

Interfaces

  • Team3\PayU\ValidatorBuilder\ValidatorBuilderInterface
  1 <?php
  2 /**
  3  * @author Krzysztof Gzocha <krzysztof.gzocha@xsolve.pl>
  4  */
  5 namespace Team3\PayU\Order\Model\Traits;
  6 
  7 use Symfony\Component\Validator\Constraints as Assert;
  8 use Symfony\Component\Validator\Context\ExecutionContextInterface;
  9 
 10 trait AddressTrait
 11 {
 12     /**
 13      * @var string
 14      */
 15     protected $street;
 16 
 17     /**
 18      * @var string
 19      * @JMS\SerializedName("postalCode")
 20      */
 21     protected $postalCode;
 22 
 23     /**
 24      * @var string
 25      */
 26     protected $city;
 27 
 28     /**
 29      * @var string
 30      * @JMS\SerializedName("countryCode")
 31      * @Assert\Country()
 32      */
 33     protected $countryCode;
 34 
 35     /**
 36      * @var string
 37      */
 38     protected $name;
 39 
 40     /**
 41      * @var string
 42      * @JMS\SerializedName("recipientName")
 43      */
 44     protected $recipientName;
 45 
 46     /**
 47      * @var string
 48      * @JMS\SerializedName("recipientEmail")
 49      * @Assert\Email()
 50      */
 51     protected $recipientEmail;
 52 
 53     /**
 54      * @var string
 55      * @JMS\SerializedName("recipientPhone")
 56      */
 57     protected $recipientPhone;
 58 
 59     /**
 60      * Return true if given object is filled
 61      *
 62      * @return bool
 63      */
 64     public function isFilled()
 65     {
 66         return $this->getStreet()
 67             && $this->getCity()
 68             && $this->getCountryCode()
 69             && $this->getPostalCode();
 70     }
 71 
 72     /**
 73      * @param ExecutionContextInterface $executionContext
 74      * @Assert\Callback()
 75      */
 76     public function validate(
 77         ExecutionContextInterface $executionContext
 78     ) {
 79         if (!$this->getStreet()
 80             && !$this->getCity()
 81             && !$this->getCountryCode()
 82             && !$this->getPostalCode()) {
 83             return;
 84         }
 85 
 86         if (!$this->getStreet()
 87             || !$this->getCity()
 88             || !$this->getCountryCode()
 89             || !$this->getPostalCode()) {
 90             $executionContext
 91                 ->buildViolation(
 92                     sprintf('Object %s is not filled correctly', get_class($this))
 93                 )
 94                 ->addViolation();
 95         }
 96     }
 97 
 98     /**
 99      * @return string
100      */
101     public function getCity()
102     {
103         return $this->city;
104     }
105 
106     /**
107      * @param string $city
108      *
109      * @return $this
110      */
111     public function setCity($city)
112     {
113         $this->city = $city;
114 
115         return $this;
116     }
117 
118     /**
119      * @return string
120      */
121     public function getCountryCode()
122     {
123         return $this->countryCode;
124     }
125 
126     /**
127      * @param string $countryCode
128      *
129      * @return $this
130      */
131     public function setCountryCode($countryCode)
132     {
133         $this->countryCode = $countryCode;
134 
135         return $this;
136     }
137 
138     /**
139      * @return string
140      */
141     public function getName()
142     {
143         return $this->name;
144     }
145 
146     /**
147      * @param string $name
148      *
149      * @return $this
150      */
151     public function setName($name)
152     {
153         $this->name = $name;
154 
155         return $this;
156     }
157 
158     /**
159      * @return string
160      */
161     public function getPostalCode()
162     {
163         return $this->postalCode;
164     }
165 
166     /**
167      * @param string $postalCode
168      *
169      * @return $this
170      */
171     public function setPostalCode($postalCode)
172     {
173         $this->postalCode = $postalCode;
174 
175         return $this;
176     }
177 
178     /**
179      * @return string
180      */
181     public function getRecipientEmail()
182     {
183         return $this->recipientEmail;
184     }
185 
186     /**
187      * @param string $recipientEmail
188      *
189      * @return $this
190      */
191     public function setRecipientEmail($recipientEmail)
192     {
193         $this->recipientEmail = $recipientEmail;
194 
195         return $this;
196     }
197 
198     /**
199      * @return string
200      */
201     public function getRecipientName()
202     {
203         return $this->recipientName;
204     }
205 
206     /**
207      * @param string $recipientName
208      *
209      * @return $this
210      */
211     public function setRecipientName($recipientName)
212     {
213         $this->recipientName = $recipientName;
214 
215         return $this;
216     }
217 
218     /**
219      * @return string
220      */
221     public function getRecipientPhone()
222     {
223         return $this->recipientPhone;
224     }
225 
226     /**
227      * @param string $recipientPhone
228      *
229      * @return $this
230      */
231     public function setRecipientPhone($recipientPhone)
232     {
233         $this->recipientPhone = $recipientPhone;
234 
235         return $this;
236     }
237 
238     /**
239      * @return string
240      */
241     public function getStreet()
242     {
243         return $this->street;
244     }
245 
246     /**
247      * @param string $street
248      *
249      * @return $this
250      */
251     public function setStreet($street)
252     {
253         $this->street = $street;
254 
255         return $this;
256     }
257 }
258 
PayU integration by Krzysztof Gzocha API documentation generated by ApiGen