Open Journal Systems  3.3.0
BagItManifest Class Reference

Public Member Functions

 __construct ( $fileName, $pathPrefix='', $fileEncoding='UTF-8')
 
 calculateHash ($fileName)
 
 clear ()
 
 getData ()
 
 getFileEncoding ()
 
 getFileName ()
 
 getHash ($fileName)
 
 getHashEncoding ()
 
 read ($fileName=null)
 
 setFileEncoding ($fileEncoding)
 
 setHashEncoding ($hashEncoding)
 
 update ($fileList)
 
 validate (&$errors)
 
 write ($fileName=null)
 

Data Fields

 $data
 
 $fileEncoding
 
 $fileName
 
 $hashEncoding
 
 $pathPrefix
 

Detailed Description

Definition at line 45 of file bagit_manifest.php.

Constructor & Destructor Documentation

◆ __construct()

BagItManifest::__construct (   $fileName,
  $pathPrefix = '',
  $fileEncoding = 'UTF-8' 
)

Define a new BagItManifest instance.

Parameters
string$fileNameThis is the file name for the manifest file.
string$pathPrefixThis is the prefix to remove from the beginning of file names before they're used as keys in the hash mapping. The default is an empty string (i.e., nothing removed).
string$fileEncodingThis is the encoding to use when reading or writing the manifest file. The default is 'UTF-8'.

Definition at line 115 of file bagit_manifest.php.

References $fileEncoding, $fileName, $pathPrefix, and read().

Member Function Documentation

◆ calculateHash()

BagItManifest::calculateHash (   $fileName)

This calculates the hash for a file.

Parameters
string$fileNameThe path of the file to calculate the hash for.
Returns
string The hash.

Definition at line 205 of file bagit_manifest.php.

References $fileName.

Referenced by update(), and validate().

◆ clear()

BagItManifest::clear ( )

This clears the data in the manifest, both in memory and on disk.

Returns
void

Definition at line 167 of file bagit_manifest.php.

◆ getData()

BagItManifest::getData ( )

This returns all of the hash data.

Returns
array The hash data.

Definition at line 261 of file bagit_manifest.php.

References $data.

◆ getFileEncoding()

BagItManifest::getFileEncoding ( )

This returns the file encoding.

Returns
string The encoding to use when reading or writing the manifest file.

Definition at line 282 of file bagit_manifest.php.

References $fileEncoding.

◆ getFileName()

BagItManifest::getFileName ( )

This returns the manifest file's path.

Returns
string The path to the manifest file.

Definition at line 271 of file bagit_manifest.php.

References $fileName.

◆ getHash()

BagItManifest::getHash (   $fileName)

This returns the hash for a file.

Parameters
string$fileNameThis can be either the absolute file name or the file name without the path prefix.
Returns
string The file's hash.

Definition at line 245 of file bagit_manifest.php.

References $fileName.

◆ getHashEncoding()

BagItManifest::getHashEncoding ( )

This returns the hash encoding.

Returns
string The encoding to use when creating the manifest hash data.

Definition at line 310 of file bagit_manifest.php.

References $hashEncoding.

◆ read()

BagItManifest::read (   $fileName = null)

This reads the data from the file name.

Parameters
string$fileNameThis is the file name to read. It defaults to the current value of the $fileName property. If given, it will set the value of the property also.
Returns
array The data read.

Definition at line 141 of file bagit_manifest.php.

References $fileName.

Referenced by __construct().

◆ setFileEncoding()

BagItManifest::setFileEncoding (   $fileEncoding)

This sets the file encoding.

The value for this should be either 'sha1' or 'md5', but this doesn't verify that.

This also re-sets the manifest file name based upon this value.

Parameters
string$fileEncodingThe new encoding to use when reading or writing the manifest file.
Returns
void

Definition at line 300 of file bagit_manifest.php.

References $fileEncoding.

◆ setHashEncoding()

BagItManifest::setHashEncoding (   $hashEncoding)

This sets the hash encoding.

Parameters
string$hashEncodingThis sets the encoding to use when creating the manifest hash data. This must be either 'md5' or 'sha1'; however, it does not test for this.
Returns
void

Definition at line 324 of file bagit_manifest.php.

References $fileName, and $hashEncoding.

◆ update()

BagItManifest::update (   $fileList)

This updates the data in the manifest from the files passed in.

Parameters
array$fileListA list of files to include in the manifest.
Returns
array The new hash mapping from those files.

Definition at line 180 of file bagit_manifest.php.

References calculateHash(), and write().

◆ validate()

BagItManifest::validate ( $errors)

This validates the data in the manifest.

This tests three things:

  1. That the manifest file does exist;
  2. That the files in the hash mapping do exist; and
  3. That the hashes in the mapping are correct.

Problems will be added to the errors.

Parameters
array&$errorsA list of error messages. Messages about any errors in validation will be appended to this.
Returns
boolean Does this validate or not?

Definition at line 357 of file bagit_manifest.php.

References $fileName, and calculateHash().

◆ write()

BagItManifest::write (   $fileName = null)

This writes the data to the manifest file.

Parameters
string$fileNameThis is the file name to write to. It defaults to the current value of the $fileName property. If given, it will set the value of the property also.
Returns
void

Definition at line 219 of file bagit_manifest.php.

References $fileName.

Referenced by update().

Field Documentation

◆ $data

array BagItManifest::$data

A mapping of relative path name ($pathPrefix removed) to hash.

Definition at line 99 of file bagit_manifest.php.

Referenced by getData().

◆ $fileEncoding

string BagItManifest::$fileEncoding

The file encoding to use when reading or writing the manifest file.

Definition at line 89 of file bagit_manifest.php.

Referenced by __construct(), getFileEncoding(), and setFileEncoding().

◆ $fileName

string BagItManifest::$fileName

The absolute file name for the manifest file.

Definition at line 69 of file bagit_manifest.php.

Referenced by __construct(), calculateHash(), getFileName(), getHash(), read(), setHashEncoding(), validate(), and write().

◆ $hashEncoding

string BagItManifest::$hashEncoding

The hash encoding to use. This must be one of 'sha1' or 'md5'.

Definition at line 79 of file bagit_manifest.php.

Referenced by getHashEncoding(), and setHashEncoding().

◆ $pathPrefix

string BagItManifest::$pathPrefix

If given, this is the path prefix to strip off of files before using them as keys in the hash mapping (data property).

Definition at line 59 of file bagit_manifest.php.

Referenced by __construct().


The documentation for this class was generated from the following file: