Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Donat
committed
May 10, 2014
1 parent
96c6794
commit 7114cff
Showing
9 changed files
with
282 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
/* | ||
* This file is part of the php-vfs package. | ||
* | ||
* (c) Michael Donat <michael.donat@me.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace VirtualFileSystem\Structure; | ||
|
||
/** | ||
* Object representation of a Link. | ||
* | ||
* @author Michael Donat <michael.donat@me.com> | ||
* @package php-vfs | ||
*/ | ||
class Link extends Node | ||
{ | ||
/** | ||
* @see http://man7.org/linux/man-pages/man2/lstat.2.html | ||
*/ | ||
const S_IFTYPE = 0120000; | ||
|
||
/** | ||
* @var Node | ||
*/ | ||
protected $destination; | ||
|
||
/** | ||
* Class constructor. | ||
* | ||
* @param string $basename | ||
*/ | ||
public function __construct($basename, Node $destination) | ||
{ | ||
parent::__construct($basename); | ||
$this->destination = $destination; | ||
} | ||
|
||
/** | ||
* Returns Link size. | ||
* | ||
* The size is the length of the destination path | ||
* | ||
* @return mixed | ||
*/ | ||
public function size() | ||
{ | ||
return $this->destination->size(); | ||
} | ||
|
||
/** | ||
* @return Node | ||
*/ | ||
public function getDestination() | ||
{ | ||
return $this->destination; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace VirtualFileSystem\Structure; | ||
|
||
class LinkTest extends \PHPUnit_Framework_TestCase | ||
{ | ||
public function testFileSizeAssumesTargetSize() | ||
{ | ||
$node = new File('file'); | ||
$node->setData('12345'); | ||
|
||
$link = new Link('link', $node); | ||
|
||
$this->assertEquals($node->size(), $link->size()); | ||
|
||
$dir = new Directory('/d'); | ||
|
||
$link = new Link('link', $dir); | ||
|
||
$this->assertEquals($dir->size(), $dir->size()); | ||
|
||
$dir->addFile($node); | ||
|
||
$this->assertEquals($dir->size(), $dir->size()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters