Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Commit db22f3b

Browse files
authored
Merge pull request #1 from ggrachdev/dev
Перенос файлов в модуль
2 parents 4b59aa8 + 057118f commit db22f3b

File tree

18 files changed

+498
-342
lines changed

18 files changed

+498
-342
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
```php
1010
<?php
11-
use Fred\FishGenerator\ElementFishGenerator;
11+
use GGrach\FishGenerator\Generators\FishGenerator;
1212

1313
/**
1414
* В конструктор передаем IBLOCK ID в который нужно сгенерировать тестовый элемент
@@ -21,7 +21,7 @@ use Fred\FishGenerator\ElementFishGenerator;
2121
* нему нужно обращаться через PROPERTY_... то ничего в качестве префикса ставить не нужно
2222
*/
2323

24-
$result = (new ElementFishGenerator(6))->setDebug(true)->setStrictMode(true)
24+
$result = (new FishGenerator(6))->setDebug(true)->setStrictMode(true)
2525
->setCategoryPhoto(['technics', 'business', 'city'])
2626
->setPropertyRules([
2727
/*
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?
2+
3+
namespace GGrach\FishGenerator;
4+
5+
/**
6+
* @todo Add https://dummyimage.com/
7+
* @todo https://loremflickr.com/
8+
* @todo https://loremipsum.io/ru/21-of-the-best-placeholder-image-generators/
9+
*/
10+
11+
/**
12+
* Все, что связано с логированием и дебагом
13+
*/
14+
class Debug {
15+
16+
/**
17+
* @var bool При Debug режиме записываются все сгенерированные данные в переменную, при отключенном режиме считается только количество ошибок и успешных выполнений
18+
*/
19+
protected $isDebug = false;
20+
21+
/**
22+
* @var bool При строгом режиме выбрасываются исключения при какой-либо ошибке
23+
*/
24+
protected $isStrictMode = false;
25+
26+
/**
27+
* @var array Результирующие данные
28+
*/
29+
protected $resultData = [
30+
// Количество ошибок
31+
'ERRORS_COUNT' => 0,
32+
// Описание ошибок
33+
'ERRORS' => [],
34+
// Сгенерированные элементы
35+
'GENERATED_DATA' => [],
36+
// Успешно сгенерированных элементов
37+
'SUCCESS_GENERATED' => 0
38+
];
39+
40+
public function addError($dataError) {
41+
$this->resultData['ERRORS_COUNT']++;
42+
43+
if ($this->isDebug)
44+
$this->resultData['ERRORS'][] = $dataError;
45+
}
46+
47+
public function addSuccess($dataSuccess) {
48+
$this->resultData['SUCCESS_GENERATED']++;
49+
50+
if ($this->isDebug)
51+
$this->resultData['GENERATED_DATA'][] = $dataSuccess;
52+
}
53+
54+
public function clearResultData($dataSuccess) {
55+
$this->resultData = [
56+
'ERRORS_COUNT' => 0,
57+
'ERRORS' => [],
58+
'GENERATED_DATA' => [],
59+
'SUCCESS_GENERATED' => 0
60+
];
61+
}
62+
63+
public function getResultData(): array {
64+
if ($this->isDebug)
65+
return $this->resultData;
66+
else {
67+
return [
68+
'ERRORS_COUNT' => $this->resultData['ERRORS_COUNT'],
69+
'SUCCESS_GENERATED' => $this->resultData['SUCCESS_GENERATED']
70+
];
71+
}
72+
}
73+
74+
public function setDebug(bool $valueDebug) {
75+
$this->isDebug = $valueDebug;
76+
return $this;
77+
}
78+
79+
public function setStrictMode(bool $strictMode) {
80+
$this->isStrictMode = $strictMode;
81+
return $this;
82+
}
83+
84+
}

src/Fred/FishGenerator/Exceptions/BitrixRedactionException.php renamed to ggrachdev.fish_generator/classes/general/FishGenerator/Exceptions/BitrixRedactionException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?
22

3-
namespace Fred\FishGenerator\Exceptions;
3+
namespace GGrach\FishGenerator\Exceptions;
44

55
use \Exception;
66

src/Fred/FishGenerator/Exceptions/GenerateElementException.php renamed to ggrachdev.fish_generator/classes/general/FishGenerator/Exceptions/GenerateElementException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?
22

3-
namespace Fred\FishGenerator\Exceptions;
3+
namespace GGrach\FishGenerator\Exceptions;
44

55
use \Exception;
66

src/Fred/FishGenerator/Exceptions/GeneratePhotoException.php renamed to ggrachdev.fish_generator/classes/general/FishGenerator/Exceptions/GeneratePhotoException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?
22

3-
namespace Fred\FishGenerator\Exceptions;
3+
namespace GGrach\FishGenerator\Exceptions;
44

55
use \Exception;
66

src/Fred/FishGenerator/Exceptions/GeneratorTypeException.php renamed to ggrachdev.fish_generator/classes/general/FishGenerator/Exceptions/GeneratorTypeException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?
22

3-
namespace Fred\FishGenerator\Exceptions;
3+
namespace GGrach\FishGenerator\Exceptions;
44

55
use \Exception;
66

src/Fred/FishGenerator/Exceptions/SearchIblockException.php renamed to ggrachdev.fish_generator/classes/general/FishGenerator/Exceptions/SearchIblockException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?
22

3-
namespace Fred\FishGenerator\Exceptions;
3+
namespace GGrach\FishGenerator\Exceptions;
44

55
use \Exception;
66

0 commit comments

Comments
 (0)