Skip to content

Commit

Permalink
2.10.0
Browse files Browse the repository at this point in the history
- [-] удалены классы `Arris\Entity\*` в связи с переносом в отдельный пакет `composer require karelwintersky/arris.entity`
- [-] удалены прочие устаревшие классы
  • Loading branch information
KarelWintersky committed Mar 30, 2024
1 parent 4b3d6cc commit a711230
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 982 deletions.
137 changes: 132 additions & 5 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# Result

- как добавить кастинг `toArray()` у экземпляра Result?

# CLI Tables

https://packagist.org/packages/jc21/clitable -- выглядит отлично, но таблицы нужно именно _создавать_
Expand All @@ -18,16 +22,16 @@ DB::suffix('suffix')->config($config)->logger($logger)->options([])->init();

# OptionHelperClass

```
```php
$options = [];

Option::get($options)->key('xxx')->env('yyy')->_('zzz');

что эквивалентно: setOption($options, 'xxx', 'yyy', 'zzz')
// что эквивалентно: setOption($options, 'xxx', 'yyy', 'zzz')

опускаем вызов метода и получаем результат, эквивалетный опции null.
// опускаем вызов метода и получаем результат, эквивалетный опции null.

или даже хелпер
// или даже хелпер

Option($options)->key('xxx')->env('yyy')->_('zzz);

Expand All @@ -43,7 +47,7 @@ if (getenv('y') !== false ) {
return $this;
}

но это ничего не даст. Нужен дополнительный метод, который таки вернет результтат цепочки:
но это ничего не даст. Нужен дополнительный метод, который таки вернет результтт цепочки:

->get()

Expand All @@ -55,4 +59,127 @@ Option::_()->key()->env()->_()->from($options);

```

# FileSearchIterator

https://stackoverflow.com/a/18090806

```php
class FileSearchIterator extends FilterIterator
{
protected $_path, $_extension, $_startWith, $_endWith;

/**
* Provides an iterator to a collection of filepath matching the given rules.
*
* If recursive is true also considers sub directories.
*
* Use in a foreach loop.
*
* @param string $path
* @param boolean $recursive If set to true recursive sub directories are enumerated.
* @param mixed $extension Either a single extension to accept or an array of such, null for no filter
* @param mixed $startWith Either a single string that must appear at the beginning of the file name, an array of such or null.
* @param mixed $endWith Either a single string that must appear at the end of the file name, an array of such or null.
* @throws LogicException
*/
public function __construct($path, $recursive = false, $extension = null, $startWith = null, $endWith = null)
{
if (!\is_dir($path)) {
throw new LogicException("$path : is not a valid folder accessible to this process");
}

if (!is_array($extension)) {
$extension = array($extension);
}

if (!is_array($startWith)) {
$startWith = array($startWith);
}

if (!is_array($endWith)) {
$endWith = array($endWith);
}

$this->_path = $path;
$this->_extension = $extension;
$this->_startWith = $startWith;
$this->_endWith = $endWith;

$it
= $recursive
? new RecursiveDirectoryIterator($path, FilesystemIterator::KEY_AS_PATHNAME | FilesystemIterator::CURRENT_AS_SELF)
: new DirectoryIterator($path);

if ($recursive) {
parent::__construct(new RecursiveIteratorIterator($it));
} else {
parent::__construct($it);
}
}

/**
* Filter function implemented for the FilterIterator
*
* @return bool
*/
#[ReturnTypeWillChange]
public function accept()
{
$info = $this->getInnerIterator()->current();

if (!$info instanceof SplFileInfo) return false;
if (!$info->isFile() || $info->isDot()) return false;

$info = pathinfo($info->getFilename());

if ($this->_extension[0] != null) {//only allow specified extensions
if (!isset($info['extension']) || $info['extension'] == null) return false;
$ext = $info['extension'];
if (!in_array($ext, $this->_extension)) return false;
}

if ($this->_startWith[0] != null) {//string match from start of filename
$found = false;
$file = $info['filename'];

foreach ($this->_startWith as $filter) {
if (strncmp($file, $filter, strlen($filter)) == 0) {
$found = true;
break;
}
}

if (!$found) return false;
}

if ($this->_endWith[0] != null) {//string match from end of filename
$found = false;
$file = $info['filename'];

foreach ($this->_endWith as $filter) {
if (substr_compare($file, $filter, -strlen($filter), strlen($filter)) === 0) {
$found = true;
break;
}
}

if (!$found) return false;
}

return true;
}
}

$fileScanner = new FileSearchIterator(__DIR__ . '/src/fonts', true, array('png'));
foreach($fileScanner as $file)
{
/**
* @var FilesystemIterator $file
*/
$fonts[] = $file->getRealPath();
}

var_dump($fonts);

```

171 changes: 0 additions & 171 deletions _legacy/DBSingleConnector.php

This file was deleted.

Loading

0 comments on commit a711230

Please sign in to comment.