Skip to content

Commit

Permalink
code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Steeven Andrian committed May 24, 2020
1 parent e69a591 commit 9e31125
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/DataStructures/SplArrayObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/**
* O2System Standard PHP Libraries ArrayObject
*
* @package O2System\Core\SPL
* @package O2System\Spl\DataStructures
*/
class SplArrayObject extends \ArrayObject
{
Expand Down
8 changes: 8 additions & 0 deletions src/Info/SplClassInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ public function getParameter()

// ------------------------------------------------------------------------

/**
* SplClassInfo::getReflection
*
* @return \ReflectionClass
* @throws \ReflectionException
*/
public function getReflection()
{
if (empty($this->name)) {
Expand All @@ -99,6 +105,8 @@ public function getReflection()
return $this->reflection;
}

// ------------------------------------------------------------------------

/**
* SplClassInfo::getFileInfo
*
Expand Down
2 changes: 1 addition & 1 deletion src/Iterators/ArrayIterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* O2System Standard PHP Libraries ArrayIterator
*
* @package O2System\Core\SPL
* @package O2System\Spl\Iterators
*/
class ArrayIterator extends \ArrayIterator implements \JsonSerializable
{
Expand Down
2 changes: 2 additions & 0 deletions src/Patterns/Structural/Provider/AbstractProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace O2System\Spl\Patterns\Structural\Provider;

// ------------------------------------------------------------------------

use O2System\Spl\Iterators\ArrayIterator;

/**
Expand Down
2 changes: 2 additions & 0 deletions src/Patterns/Structural/Repository/AbstractRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

namespace O2System\Spl\Patterns\Structural\Repository;

// ------------------------------------------------------------------------

use O2System\Spl\Iterators\ArrayIterator;

/**
Expand Down
5 changes: 4 additions & 1 deletion src/Traits/Collectors/ConfigCollectorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace O2System\Spl\Traits\Collectors;

// ------------------------------------------------------------------------

use O2System\Kernel\DataStructures\Config;

/**
Expand All @@ -30,6 +31,8 @@ trait ConfigCollectorTrait
*/
protected $config = [];

// ------------------------------------------------------------------------

/**
* Add Config
*
Expand Down Expand Up @@ -89,7 +92,7 @@ final public function getConfig($key = null, $offset = null)
*
* @access public
*
* @param array|string $key
* @param array|string|int|Config $key
*
* @return static
*/
Expand Down
4 changes: 4 additions & 0 deletions src/Traits/Collectors/ErrorCollectorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ public function addErrors(array $errors)
*
* @param int $code Error code.
* @param string $message Error message.
*
* @return static
*/
public function addError($code, $message)
{
Expand All @@ -141,5 +143,7 @@ public function addError($code, $message)
} else {
$this->errors[ $code ] = $message;
}

return $this;
}
}
39 changes: 39 additions & 0 deletions src/Traits/Collectors/FileExtensionCollectorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,50 @@
*/
trait FileExtensionCollectorTrait
{
/**
* FileExtensionCollectorTrait::$fileExtensions
*
* @var array
*/
protected $fileExtensions = [];

// ------------------------------------------------------------------------

/**
* FileExtensionCollectorTrait::getFileExtensions
*
* @return array
*/
public function getFileExtensions()
{
return $this->fileExtensions;
}

// ------------------------------------------------------------------------

/**
* FileExtensionCollectorTrait::setFileExtensions
*
* @param array $fileExtensions
*
* @return static
*/
public function setFileExtensions(array $fileExtensions)
{
$this->fileExtensions = $fileExtensions;

return $this;
}

// ------------------------------------------------------------------------

/**
* FileExtensionCollectorTrait::addFileExtension
*
* @param array $fileExtensions
*
* @return static
*/
public function addFileExtensions(array $fileExtensions)
{
foreach ($fileExtensions as $fileExtension) {
Expand All @@ -45,6 +75,15 @@ public function addFileExtensions(array $fileExtensions)
return $this;
}

// ------------------------------------------------------------------------

/**
* FileExtensionCollectorTrait::addFileExtension
*
* @param string $fileExtension
*
* @return static
*/
public function addFileExtension($fileExtension)
{
$fileExtension = '.' . trim($fileExtension, '.');
Expand Down
69 changes: 61 additions & 8 deletions src/Traits/Collectors/FilePathCollectorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,37 @@
// ------------------------------------------------------------------------

/**
* Class PathCollectorTrait
* Class FilePathCollectorTrait
*
* @package O2System\Spl\Traits\Collectors
*/
trait FilePathCollectorTrait
{
/**
* Sub Path
* FilePathCollectorTrait::$fileDirName
*
* @type string|null
*/
protected $fileDirName = null;

// ------------------------------------------------------------------------

/**
* FilePathCollectorTrait::$filePaths
*
* List of Paths
*
* @type array
*/
protected $filePaths = [];

// ------------------------------------------------------------------------

/**
* FilePathCollectorTrait::setFileDirName
*
* @param $fileDirName
*
* @return static
*/
public function setFileDirName($fileDirName)
{
$this->fileDirName = $fileDirName;
Expand All @@ -47,24 +56,45 @@ public function setFileDirName($fileDirName)

// ------------------------------------------------------------------------

/**
* FilePathCollectorTrait::removeFilePath
*
* @param string $filePath
*
* @return static
*/
public function removeFilePath($filePath)
{
if (false !== ($key = array_search($filePath, $this->filePaths))) {
unset($this->filePaths[ $key ]);
unset($this->filePaths[$key]);
}

return $this;
}

// ------------------------------------------------------------------------

/**
* FilePathCollectorTrait::getFilePaths
*
* @param bool $reverse
*
* @return array
*/
public function getFilePaths($reverse = false)
{
return ($reverse === true ? array_reverse($this->filePaths) : $this->filePaths);
}

// ------------------------------------------------------------------------

/**
* FilePathCollectorTrait::setFilePaths
*
* @param array $filePaths
*
* @return static
*/
public function setFilePaths(array $filePaths)
{
$this->filePaths = [];
Expand All @@ -75,6 +105,13 @@ public function setFilePaths(array $filePaths)

// ------------------------------------------------------------------------

/**
* FilePathCollectorTrait::addFilePaths
*
* @param array $filePaths
*
* @return static
*/
public function addFilePaths(array $filePaths)
{
foreach ($filePaths as $filePath) {
Expand All @@ -86,6 +123,14 @@ public function addFilePaths(array $filePaths)

// ------------------------------------------------------------------------

/**
* FilePathCollectorTrait::addFilePath
*
* @param string $filePath
* @param string|int|null $offset
*
* @return static
*/
public function addFilePath($filePath, $offset = null)
{
$filePath = rtrim(
Expand All @@ -105,12 +150,20 @@ public function addFilePath($filePath, $offset = null)
}

// ------------------------------------------------------------------------


/**
* FilePathCollectorTrait::pushFilePath
*
* @param string $filePath
* @param string|int|null $offset
*
* @return static
*/
public function pushFilePath($filePath, $offset = null)
{
if (is_dir($filePath) AND ! in_array($filePath, $this->filePaths)) {
if (is_dir($filePath) AND !in_array($filePath, $this->filePaths)) {
if (isset($offset)) {
$this->filePaths[ $offset ] = $filePath;
$this->filePaths[$offset] = $filePath;
} else {
$this->filePaths[] = $filePath;
}
Expand Down

0 comments on commit 9e31125

Please sign in to comment.