Skip to content

Commit

Permalink
Merged into one method and renamed to chmod.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bert-Jan Verwer committed Nov 28, 2016
1 parent 11c2e60 commit c3f05ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
21 changes: 7 additions & 14 deletions src/Illuminate/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,18 @@ public function put($path, $contents, $lock = false)
}

/**
* Set UNIX mode of a file or directory.
* Get or set UNIX mode of a file or directory.
*
* @param string $path
* @param bool $mode
* @return int
* @param int $mode
* @return mixed
*/
public function setUnixMode($path, $mode)
public function chmod($path, $mode = null)
{
return chmod($path, $mode);
}
if($mode) {
return chmod($path, $mode);
}

/**
* Get UNIX mode of a file or directory.
*
* @param string $path
* @return string
*/
public function getUnixMode($path)
{
return substr(sprintf('%o', fileperms($path)), -4);
}

Expand Down
8 changes: 4 additions & 4 deletions tests/Filesystem/FilesystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ public function testPutStoresFiles()
$this->assertStringEqualsFile($this->tempDir.'/file.txt', 'Hello World');
}

public function testSetUnixMode()
public function testSetChmod()
{
file_put_contents($this->tempDir.'/file.txt', 'Hello World');
$files = new Filesystem();
$files->setUnixMode($this->tempDir.'/file.txt', 0755);
$files->chmod($this->tempDir.'/file.txt', 0755);
$filePermisson = substr(sprintf('%o', fileperms($this->tempDir.'/file.txt')), -4);
$this->assertEquals('0755', $filePermisson);
}

public function testGetUnixMode()
public function testGetChmod()
{
file_put_contents($this->tempDir.'/file.txt', 'Hello World');
chmod($this->tempDir.'/file.txt', 0755);
$files = new Filesystem();
$filePermisson = $files->getUnixMode($this->tempDir.'/file.txt');
$filePermisson = $files->chmod($this->tempDir.'/file.txt');
$this->assertEquals('0755', $filePermisson);
}

Expand Down

0 comments on commit c3f05ab

Please sign in to comment.