/** * Returns the checksum of the specified file's content. * * @param string $key * * @return string A MD5 hash */ public function checksum($key) { $this->assertHasFile($key); if ($this->adapter instanceof Adapter\ChecksumCalculator) { return $this->adapter->checksum($key); } return Util\Checksum::fromContent($this->read($key)); }
/** * {@inheritDoc} */ public function checksum($key) { return Util\Checksum::fromContent($this->read($key)); }
/** * {@inheritdoc} */ public function checksum($key) { $file = $this->find($key); return Util\Checksum::fromContent($file ? $file->getContentAsString() : ''); }
/** * {@inheritDoc} */ public function write($key, $content, array $metadata = null) { $this->files[$key]['content'] = $content; $this->files[$key]['mtime'] = time(); $this->files[$key]['checksum'] = Util\Checksum::fromContent($content); return Util\Size::fromContent($content); }
/** * Returns the checksum of the file * * @param string $key * * @return string */ public function checksum($key) { $this->assertExists($key); return Util\Checksum::fromContent($this->read($key)); }
/** * {@inheritdoc} */ public function write($key, $content) { $values = array($this->getQuotedColumn('content') => $content, $this->getQuotedColumn('mtime') => time(), $this->getQuotedColumn('checksum') => Util\Checksum::fromContent($content)); if ($this->exists($key)) { $this->connection->update($this->table, $values, array($this->getQuotedColumn('key') => $key)); } else { $values[$this->getQuotedColumn('key')] = $key; $this->connection->insert($this->table, $values); } return Util\Size::fromContent($content); }
public function testChecksumIsUpdatedOnWrite() { $adapter = new InMemory(array('foobar' => array('content' => 'Some content', 'checksum' => 'abcd'))); $adapter->write('foobar', 'Changed content'); $this->assertEquals(Checksum::fromContent('Changed content'), $adapter->checksum('foobar')); }