* @copyright 2007-2019 PrestaShop SA and Contributors * @license https://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) * International Registered Trademark & Property of PrestaShop SA */ /** * Class AddressChecksumCore. */ class AddressChecksumCore implements ChecksumInterface { const SEPARATOR = '_'; /** * Generate a checksum. * * @param Address $address * * @return string SHA1 checksum for the Address */ public function generateChecksum($address) { if (!$address->id) { return sha1('No address set'); } $uniqId = ''; $fields = $address->getFields(); foreach ($fields as $name => $value) { $uniqId .= $value . self::SEPARATOR; } $uniqId = rtrim($uniqId, self::SEPARATOR); return sha1($uniqId); } }