Initial commit
This commit is contained in:
46
src/ManifestObject.php
Normal file
46
src/ManifestObject.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace PharLite;
|
||||
|
||||
/**
|
||||
* Class representing a single object to be added to a phar
|
||||
*
|
||||
*
|
||||
*/
|
||||
class ManifestObject
|
||||
{
|
||||
protected $filename;
|
||||
|
||||
protected $localname;
|
||||
|
||||
public function __construct($filename, $localname=null)
|
||||
{
|
||||
$this->filename = $filename;
|
||||
$this->localname = $localname;
|
||||
}
|
||||
|
||||
public function getFilename()
|
||||
{
|
||||
return $this->filename;
|
||||
}
|
||||
|
||||
public function getLocalName()
|
||||
{
|
||||
return $this->localname;
|
||||
}
|
||||
|
||||
public function addToPhar(\Phar $phar)
|
||||
{
|
||||
$phar->addFile(
|
||||
$this->getFilename(),
|
||||
$this->getLocalName()
|
||||
);
|
||||
}
|
||||
|
||||
public function addFiltered(\Phar $phar, callable $filter)
|
||||
{
|
||||
$body = file_get_contents($this->filename);
|
||||
$body = call_user_func($filter, $body);
|
||||
$phar->addFromString($this->getLocalName(), $body);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user