예제 #1
0
 public static function compare(Address $a, Address $b)
 {
     if ($a->toArray() == $b->toArray()) {
         return true;
     }
     return false;
 }
예제 #2
0
파일: BaseDomain.php 프로젝트: dapepe/tymio
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  *                    Defaults to BasePeer::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['Domain'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['Domain'][$this->getPrimaryKey()] = true;
     $keys = DomainPeer::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getAccountId(), $keys[2] => $this->getAddressId(), $keys[3] => $this->getName(), $keys[4] => $this->getValid(), $keys[5] => $this->getDescription(), $keys[6] => $this->getNumber());
     if ($includeForeignObjects) {
         if (null !== $this->aAccount) {
             $result['Account'] = $this->aAccount->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aAddress) {
             $result['Address'] = $this->aAddress->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->collHolidayDomains) {
             $result['HolidayDomains'] = $this->collHolidayDomains->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collPropertyValues) {
             $result['PropertyValues'] = $this->collPropertyValues->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collUsers) {
             $result['Users'] = $this->collUsers->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
     }
     return $result;
 }
예제 #3
0
파일: Tax.php 프로젝트: ZayconFoods/taxify
 public function calculateTax()
 {
     if (!$this->hasLines()) {
         throw new Exception(self::ERROR_NO_LINES);
     }
     if (!$this->hasDestinationAddress()) {
         throw new Exception(self::ERROR_NO_DESTINATION_ADDRESS);
     }
     if (empty($this->document_key)) {
         throw new Exception(self::ERROR_NO_DOCUMENT_KEY);
     }
     $data = array('DocumentKey' => Taxify::toString($this->document_key), 'TaxDate' => empty($this->tax_date) ? date('Y-m-d') : $this->tax_date, 'IsCommited' => $this->is_committed, 'CustomerKey' => Taxify::toString($this->customer_key), 'CustomerTaxabilityCode' => Taxify::toString($this->customer_taxability_code), 'CustomerRegistrationNumber' => Taxify::toString($this->customer_registration_number), 'DestinationAddress' => $this->destination_address->toArray(), 'Lines' => array(), 'Options' => array(), 'Tags' => array(), 'Discounts' => array());
     if ($this->origin_address !== NULL) {
         $data['OriginAddress'] = $this->origin_address->toArray();
     }
     foreach ($this->lines as $line) {
         $data['Lines'][] = $line->toArray();
     }
     if (!empty($this->tax_request_options)) {
         foreach ($this->tax_request_options as $tax_request_option) {
             $data['Options'][] = $tax_request_option->toArray();
         }
     }
     if (!empty($this->tags)) {
         foreach ($this->tags as $tag) {
             $data['Tags'][] = $tag->toArray();
         }
     }
     if (!empty($this->discounts)) {
         foreach ($this->discounts as $discount) {
             $data['Discounts'][] = $discount->toArray();
         }
     }
     $communicator = new Communicator($this->taxify);
     $return = $communicator->call(self::CALL_CALCULATE_TAX, $data);
     return new TaxResponse(json_encode($return));
 }
예제 #4
0
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  *                    Defaults to BasePeer::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['Account'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['Account'][$this->getPrimaryKey()] = true;
     $keys = AccountPeer::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getAddressId(), $keys[2] => $this->getIdentifier(), $keys[3] => $this->getName());
     if ($includeForeignObjects) {
         if (null !== $this->aAddress) {
             $result['Address'] = $this->aAddress->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->collBookingTypes) {
             $result['BookingTypes'] = $this->collBookingTypes->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collClockingTypes) {
             $result['ClockingTypes'] = $this->collClockingTypes->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collDomains) {
             $result['Domains'] = $this->collDomains->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collHolidays) {
             $result['Holidays'] = $this->collHolidays->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collPlugins) {
             $result['Plugins'] = $this->collPlugins->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collPropertys) {
             $result['Propertys'] = $this->collPropertys->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collUsers) {
             $result['Users'] = $this->collUsers->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
     }
     return $result;
 }
예제 #5
0
 /**
  * Convert to array
  * @return array
  */
 public function toArray()
 {
     $array = array('id_courtyard' => $this->getIdCourtyard(), 'id_address' => $this->getIdAddress(), 'id_port_custom' => $this->getIdPortCustom(), 'id_forwarder' => $this->getIdForwarder(), 'id_contact' => $this->getIdContact(), 'name' => utf8_encode($this->getName()), 'status' => $this->getStatus());
     return array_merge(parent::toArray(), $array);
 }
 /**
  * retrieve an \Address with caching
  * @name get
  * @param string $address address to retrive object for
  * @param boolean $refresh if true forces refreshing of entry in cache
  * @since 0.1.0
  * @return \MariaBlockChain\Address
  *
  * <code>
  * <?php
  * $address = $blockchain->addresses->get('1124fWAtrp31Apd35zkoYqw2jRerE97HE4');
  * ?>
  * </code>
  */
 public function get($address, $refresh = false)
 {
     if ($address) {
         $cached = $this->bc->cache->get((string) $address);
         if ($cached !== false && $refresh === false) {
             $address = new Address($this->bc, $cached);
         } else {
             $address = new Address($this->bc, (string) $address);
             $this->updateCached((string) $address, $address->toArray());
         }
         return $address;
     }
 }
예제 #7
0
 /**
  * Return instance of Illuminate\Validation\Validator that is setup with Address rules and data (from html input)
  * Addresses::getValidator()->fails(); // test input from user
  *
  * @param array $input input array from user (or null to default to Input::all())
  * @return Illuminate\Validation\Validator ready to test for fails|passes
  */
 function getValidator($input = null)
 {
     $rules = Address::rules();
     if (is_null($input)) {
         $input = \Input::all();
     }
     $address = new Address($input);
     return \Validator::make($address->toArray(), $rules);
 }