/src/Chord/Component/DataShot/Filter/Md5.php
PHP | 39 lines | 16 code | 5 blank | 18 comment | 2 complexity | 0bbf19fb32cb22e6757ba043e3861935 MD5 | raw file
- <?php
- namespace Chord\Component\DataShot\Filter;
- /*
- * This file is part of the Chord component library.
- *
- * (c) Matthias Nothhaft <matthias.nothhaft@googlemail.com>
- *
- * This source file is subject to the MIT license that is bundled
- * with this source code in the file LICENSE.
- */
- use Chord\Component\DataShot\FilterInterface;
- class Md5 implements FilterInterface
- {
- /**
- * Filters data after serialization.
- *
- * @param array Entry instance with serialized data
- */
- public function apply(Entry $entry)
- {
- $entry->setHeader('md5', md5($entry->getData()));
- }
- /**
- * Filters data before unserialization.
- *
- * @param Entry Entry instance with serialized data
- */
- public function remove(Entry $entry)
- {
- if ($entry->getHeader('md5') != md5($entry->getData())) {
- throw new InvalidArgumentException('Data is corrupt');
- }
- }
- }