本文整理汇总了PHP中Zend_Currency::compare方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Currency::compare方法的具体用法?PHP Zend_Currency::compare怎么用?PHP Zend_Currency::compare使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Currency
的用法示例。
在下文中一共展示了Zend_Currency::compare方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCompareValues
/**
* Compare values
*/
public function testCompareValues()
{
$currency = new Zend_Currency(array('currency' => 'EUR', 'locale' => 'de_AT', 'value' => 100));
$currency2 = new Zend_Currency(array('currency' => 'EUR', 'locale' => 'de_AT', 'value' => 100));
$this->assertEquals(0, $currency->compare($currency2));
$currency3 = new Zend_Currency(array('currency' => 'EUR', 'locale' => 'de_AT', 'value' => 101));
$this->assertEquals(-1, $currency->compare($currency3));
$currency4 = new Zend_Currency(array('currency' => 'EUR', 'locale' => 'de_AT', 'value' => 99));
$this->assertEquals(1, $currency->compare($currency4));
}
示例2: _checkPreviousClaims
/**
* Identifies if the previous claims will force a referral.
*
* @param string $refNo
* The unique legacy customer reference number.
*
* @return mixed
* Returns an array of referral reasons. If there are no referral reasons,
* then will return null.
*/
protected function _checkPreviousClaims($quoteId)
{
$params = Zend_Registry::get('params');
$quoteManager = new Manager_Insurance_LandlordsPlus_Quote($quoteId);
$refNo = $quoteManager->getLegacyCustomerReference();
//Identify if buildings/contents cover is applicable for this policy, and if yes then
//retrieve the excess values.
$productMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER);
if (!empty($productMeta)) {
$isBuildingsCoverApplicable = true;
$buildingsExcess = new Zend_Currency(array('value' => $productMeta['excess'], 'precision' => 2));
} else {
$isBuildingsCoverApplicable = false;
}
$productMeta = $quoteManager->getProductMeta(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER);
if (!empty($productMeta)) {
$isContentsCoverApplicable = true;
$contentsExcess = new Zend_Currency(array('value' => $productMeta['excess'], 'precision' => 2));
} else {
$isContentsCoverApplicable = false;
}
$previousClaimsReferralReasons = array();
//Retrieve the previous claims details, if any.
if (empty($this->_previousClaimsModel)) {
$this->_previousClaimsModel = new Datasource_Insurance_PreviousClaims();
}
$previousClaimsArray = $this->_previousClaimsModel->getPreviousClaims($refNo);
if (empty($previousClaimsArray)) {
return null;
}
//First test to see if the total value of previous claims exceed the threshold.
$claimsTotal = new Zend_Currency(array('value' => 0, 'precision' => 2));
foreach ($previousClaimsArray as $previousClaim) {
$claimsTotal->add($previousClaim->getClaimValue());
}
$claimsThreshold = new Zend_Currency(array('value' => $params->uw->rt->landlordsp->claimsThreshold, 'precision' => 2));
if ($claimsTotal->isMore($claimsThreshold)) {
$previousClaimsReferralReasons[] = $params->uw->rr->landlordsp->claimsThreshold;
}
//Next text for multiple claims of the same type.
$claimTypeIds = array();
$matchFound = false;
foreach ($previousClaimsArray as $previousClaim) {
if (empty($claimTypeIds)) {
$claimTypeIds[] = $previousClaim->getClaimType()->getClaimTypeID();
continue;
}
//Compare the current ID against the other ids.
foreach ($claimTypeIds as $currentId) {
if ($currentId == $previousClaim->getClaimType()->getClaimTypeID()) {
$matchFound = true;
break;
}
}
if ($matchFound) {
//More than one type of claim of the same loss, so this will need referral.
$previousClaimsReferralReasons[] = $params->uw->rr->landlordsp->multipleSameTypeClaim;
break;
}
}
//Next test for more than one claim, and £0 or £100 excess requested.
$excessAmountsWhichRefer = $params->uw->rt->landlordsp->excessAmounts->toArray();
if (count($previousClaimsArray) > 1) {
if ($isBuildingsCoverApplicable) {
foreach ($excessAmountsWhichRefer as $excessAmount) {
if ($buildingsExcess->compare($excessAmount) == 0) {
$previousClaimsReferralReasons[] = $params->uw->rr->landlordsp->buildings->excessReduction;
break;
}
}
}
if ($isContentsCoverApplicable) {
foreach ($excessAmountsWhichRefer as $excessAmount) {
if ($contentsExcess->compare($excessAmount) == 0) {
$previousClaimsReferralReasons[] = $params->uw->rr->landlordsp->contents->excessReduction;
break;
}
}
}
}
//Return the results consistent with this method's contract.
if (empty($previousClaimsReferralReasons)) {
$returnVal = null;
} else {
$returnVal = $previousClaimsReferralReasons;
}
return $returnVal;
}