This repository has been archived by the owner on Feb 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Folders can be requested and item collections in those folders can be…
… obtained.
- Loading branch information
Showing
7 changed files
with
153 additions
and
90 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,27 @@ | ||
<?php | ||
|
||
namespace PhpBox\Items; | ||
|
||
class Folder extends Item { | ||
protected $contains = []; | ||
|
||
public function __construct($data) { | ||
parent::__construct($data); | ||
if(isset($data->item_collection)) { | ||
foreach ($data->item_collection->entries as $key => $value) { | ||
$this->contains[] = new Item($value); | ||
} | ||
} | ||
} | ||
|
||
public function getItems() { | ||
return $this->contains; | ||
} | ||
|
||
public function getFiles() { | ||
return array_filter($this->contains, function($x) {return $x->isFile();}); | ||
} | ||
|
||
} | ||
|
||
?> |
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,25 @@ | ||
<?php | ||
|
||
namespace PhpBox\Items; | ||
|
||
class Item implements ItemInterface { | ||
protected $data; | ||
protected $id; | ||
protected $type; | ||
|
||
public function __construct($data) { | ||
$this->data = $data; | ||
$this->type = $data->type; | ||
$this->id = $data->id; | ||
} | ||
|
||
public function isFolder() { | ||
return $this->type == 'folder'; | ||
} | ||
|
||
public function isFile() { | ||
return $this->type == 'file'; | ||
} | ||
} | ||
|
||
?> |
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,9 @@ | ||
<?php | ||
|
||
namespace PhpBox\Items; | ||
|
||
interface ItemInterface { | ||
|
||
} | ||
|
||
?> |
Oops, something went wrong.