コード例 #1
0
ファイル: UtilTest.php プロジェクト: cermat/valueobjects
 public function testClassEquals()
 {
     $util1 = new Util();
     $util2 = new Util();
     $this->assertTrue(Util::classEquals($util1, $util2));
     $this->assertFalse(Util::classEquals($util1, $this));
 }
コード例 #2
0
ファイル: DateTime.php プロジェクト: cermat/valueobjects
 /**
  * Tells whether two DateTime are equal by comparing their values
  *
  * @param  ValueObjectInterface $date_time
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $date_time)
 {
     if (false === Util::classEquals($this, $date_time)) {
         return false;
     }
     return $this->getDate()->sameValueAs($date_time->getDate()) && $this->getTime()->sameValueAs($date_time->getTime());
 }
コード例 #3
0
ファイル: Date.php プロジェクト: cermat/valueobjects
 /**
  * Tells whether two Date are equal by comparing their values
  *
  * @param  ValueObjectInterface $date
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $date)
 {
     if (false === Util::classEquals($this, $date)) {
         return false;
     }
     return $this->getYear()->sameValueAs($date->getYear()) && $this->getMonth()->sameValueAs($date->getMonth()) && $this->getDay()->sameValueAs($date->getDay());
 }
コード例 #4
0
ファイル: Integer.php プロジェクト: cermat/valueobjects
 /**
  * Tells whether two Integer are equal by comparing their values
  *
  * @param  ValueObjectInterface $integer
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $integer)
 {
     if (false === Util::classEquals($this, $integer)) {
         return false;
     }
     return $this->toNative() === $integer->toNative();
 }
コード例 #5
0
ファイル: StringLiteral.php プロジェクト: cermat/valueobjects
 /**
  * Tells whether two string literals are equal by comparing their values
  *
  * @param  ValueObjectInterface $stringLiteral
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $stringLiteral)
 {
     if (false === Util::classEquals($this, $stringLiteral)) {
         return false;
     }
     return $this->toNative() === $stringLiteral->toNative();
 }
コード例 #6
0
ファイル: Time.php プロジェクト: cermat/valueobjects
 /**
  * Tells whether two Time are equal by comparing their values
  *
  * @param  ValueObjectInterface $time
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $time)
 {
     if (false === Util::classEquals($this, $time)) {
         return false;
     }
     return $this->getHour()->sameValueAs($time->getHour()) && $this->getMinute()->sameValueAs($time->getMinute()) && $this->getSecond()->sameValueAs($time->getSecond());
 }
コード例 #7
0
 /**
  * Tells whether tow Coordinate objects are equal
  *
  * @param  ValueObjectInterface $coordinate
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $coordinate)
 {
     if (false === Util::classEquals($this, $coordinate)) {
         return false;
     }
     return $this->getLatitude()->sameValueAs($coordinate->getLatitude()) && $this->getLongitude()->sameValueAs($coordinate->getLongitude()) && $this->getEllipsoid()->sameValueAs($coordinate->getEllipsoid());
 }
コード例 #8
0
 public function sameValueAs(ValueObjectInterface $complex)
 {
     if (false === Util::classEquals($this, $complex)) {
         return false;
     }
     return $this->getReal()->sameValueAs($complex->getReal()) && $this->getIm()->sameValueAs($complex->getIm());
 }
コード例 #9
0
ファイル: Country.php プロジェクト: cermat/valueobjects
 /**
  * Tells whether two Country are equal
  *
  * @param  ValueObjectInterface $country
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $country)
 {
     if (false === Util::classEquals($this, $country)) {
         return false;
     }
     return $this->getCode()->sameValueAs($country->getCode());
 }
コード例 #10
0
 /**
  * Tells whether two Street objects are equal
  * @param  ValueObjectInterface $street
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $street)
 {
     if (false === Util::classEquals($this, $street)) {
         return false;
     }
     return $this->getName()->sameValueAs($street->getName()) && $this->getNumber()->sameValueAs($street->getNumber()) && $this->getElements()->sameValueAs($street->getElements());
 }
コード例 #11
0
ファイル: Url.php プロジェクト: cermat/valueobjects
 /**
  * Tells whether two Url are sameValueAs by comparing their components
  *
  * @param  ValueObjectInterface $url
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $url)
 {
     if (false === Util::classEquals($this, $url)) {
         return false;
     }
     return $this->getScheme()->sameValueAs($url->getScheme()) && $this->getUser()->sameValueAs($url->getUser()) && $this->getPassword()->sameValueAs($url->getPassword()) && $this->getDomain()->sameValueAs($url->getDomain()) && $this->getPath()->sameValueAs($url->getPath()) && $this->getPort()->sameValueAs($url->getPort()) && $this->getQueryString()->sameValueAs($url->getQueryString()) && $this->getFragmentIdentifier()->sameValueAs($url->getFragmentIdentifier());
 }
コード例 #12
0
 /**
  * Tells whether two KeyValuePair are equal
  *
  * @param  ValueObjectInterface $keyValuePair
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $keyValuePair)
 {
     if (false === Util::classEquals($this, $keyValuePair)) {
         return false;
     }
     return $this->getKey()->sameValueAs($keyValuePair->getKey()) && $this->getValue()->sameValueAs($keyValuePair->getValue());
 }
コード例 #13
0
ファイル: Currency.php プロジェクト: cermat/valueobjects
 /**
  * Tells whether two Currency are equal by comparing their names
  *
  * @param  ValueObjectInterface $currency
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $currency)
 {
     if (false === Util::classEquals($this, $currency)) {
         return false;
     }
     return $this->getCode()->toNative() == $currency->getCode()->toNative();
 }
コード例 #14
0
 /**
  * Tells whether two DateTimeZone are equal by comparing their names
  *
  * @param  ValueObjectInterface $timezone
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $timezone)
 {
     if (false === Util::classEquals($this, $timezone)) {
         return false;
     }
     return $this->getName()->sameValueAs($timezone->getName());
 }
コード例 #15
0
 /**
  *  Tells whether two Currency are equal by comparing their amount and currency
  *
  * @param  ValueObjectInterface $money
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $money)
 {
     if (false === Util::classEquals($this, $money)) {
         return false;
     }
     return $this->getAmount()->sameValueAs($money->getAmount()) && $this->getCurrency()->sameValueAs($money->getCurrency());
 }
コード例 #16
0
ファイル: Collection.php プロジェクト: cermat/valueobjects
 /**
  * Tells whether two Collection are equal by comparing their size and items (item order matters)
  *
  * @param  ValueObjectInterface $collection
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $collection)
 {
     if (false === Util::classEquals($this, $collection) || false === $this->count()->sameValueAs($collection->count())) {
         return false;
     }
     $arrayCollection = $collection->toArray();
     foreach ($this->items as $index => $item) {
         if (!isset($arrayCollection[$index]) || false === $item->sameValueAs($arrayCollection[$index])) {
             return false;
         }
     }
     return true;
 }
コード例 #17
0
 /**
  * Tells whether two names are equal by comparing their values
  *
  * @param  ValueObjectInterface $name
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $name)
 {
     if (false === Util::classEquals($this, $name)) {
         return false;
     }
     return $this->getFullName() == $name->getFullName();
 }
コード例 #18
0
ファイル: NullValue.php プロジェクト: cermat/valueobjects
 /**
  * Tells whether two objects are both NullValue
  * @param  ValueObjectInterface $null
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $null)
 {
     return Util::classEquals($this, $null);
 }
コード例 #19
0
ファイル: Address.php プロジェクト: cermat/valueobjects
 /**
  * Tells whether two Address are equal
  *
  * @param  ValueObjectInterface $address
  * @return bool
  */
 public function sameValueAs(ValueObjectInterface $address)
 {
     if (false === Util::classEquals($this, $address)) {
         return false;
     }
     return $this->getName()->sameValueAs($address->getName()) && $this->getStreet()->sameValueAs($address->getStreet()) && $this->getDistrict()->sameValueAs($address->getDistrict()) && $this->getCity()->sameValueAs($address->getCity()) && $this->getRegion()->sameValueAs($address->getRegion()) && $this->getPostalCode()->sameValueAs($address->getPostalCode()) && $this->getCountry()->sameValueAs($address->getCountry());
 }
コード例 #20
0
 /**
  * Tells whether two DateTimeWithTimeZone represents the same timestamp
  *
  * @param ValueObjectInterface $dateTimeWithTimeZone
  *
  * @return bool
  */
 public function sameTimestampAs(ValueObjectInterface $dateTimeWithTimeZone)
 {
     if (false === Util::classEquals($this, $dateTimeWithTimeZone)) {
         return false;
     }
     return $this->toNativeDateTime() == $dateTimeWithTimeZone->toNativeDateTime();
 }