Skip to content

Commit

Permalink
update of init and expose data
Browse files Browse the repository at this point in the history
update of init and expose data  to test new structure
  • Loading branch information
arcanisgk committed Jun 18, 2022
1 parent cbde5cb commit 3e72711
Show file tree
Hide file tree
Showing 7 changed files with 214 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
/composer.lock
/*.log
/null
/.htaccess
/.user.ini
/example/.htaccess
/example/.user.ini
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"ArcanisGK\\PhpDevelopmentTool\\": "src/"
},
"files": [
"src/phpDevToolInitialization.php"
"src/Init/phpDevToolInitialization.php",
"src/Init/phpExposeData.php"
]
},
"authors": [
Expand Down
4 changes: 3 additions & 1 deletion example/dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,6 @@

require_once __DIR__ . "/../vendor/autoload.php";

dop(['test' => 'Hello World', 2022]);
sd(['test' => 'Hello World', 2022]);

sda(['test' => 'Hello World', 2022]);
2 changes: 2 additions & 0 deletions example/test/error_log.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1655576398 2022-06-18 13:19:58 Test Trace: No backtrace data in the ExceptionHandler.
1655576399 2022-06-18 13:19:59 Use of undefined constant wath - assumed 'wath' (this will throw an Error in a future version of PHP) Trace: No backtrace data in the ErrorHandler.
153 changes: 153 additions & 0 deletions src/ExposeData/ExposeEngine.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<?php

/**
* PHP Development Tools.
* PHP Version required 7.4.* or higher
*
* @see https://github.com/arcanisgk/PHP-Development-Tools
*
* @author Walter Nuñez (arcanisgk/original founder)
* @email icarosnet@gmail.com
* @copyright 2020 - 2022 Walter Nuñez/Icaros Net S.A.
* @license For the full copyright and licence information, please view the LICENSE
* @note This program is distributed in the hope that it will be useful
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
*/

declare(strict_types=1);

namespace ArcanisGK\PhpDevelopmentTool\ExposeData;

/**
* ExposeEngine Class.
*/
class ExposeEngine
{
/**
* @var string
*/

private string $data;

/**
* @var bool|mixed
*/

private bool $highlight = true;

/**
* @var bool|mixed
*/

private bool $end = true;

/**
* @var array
*/

private array $options;

/**
* Description: instantiate Class Static.
* @var ExposeEngine|null $instance
*/

private static ?ExposeEngine $instance = null;

/**
* @param array $data
* @return ExposeEngine
*/

public static function getInstance(array $data): ExposeEngine
{
if (!self::$instance instanceof self) {
self::$instance = new self($data);
}

return self::$instance;
}

/**
* @noinspection PhpUnused
* @param array $options
*/

public function __construct(array $options = [])
{
if (!empty($options)) {
if (isset($options['highlight'])) {
$this->highlight = $options['highlight'];
}
if (isset($options['end'])) {
$this->end = $options['end'];
}
}
$this->options = $options;
}

/**
* @param $var
* @return void
*/

public function varDump($var): void
{
$this->clean();
if ($this->highlight) {
$this->Explain($var);
} else {
$this->capture($var);
}
$this->output();
if ($this->end) {
die;
}
}

/**
* @return void
*/

private function clean(): void
{
if (ob_get_contents() || ob_get_length()) {
ob_end_clean();
flush();
}
}

/**
* @param $var
* @return void
*/

private function Explain($var)
{
echo 'Under Development<br>';
$this->capture($var);
}

/**
* @param $var
* @return void
*/

private function capture($var): void
{
ob_start();
var_dump($var);
$this->data = ob_get_contents();
ob_end_clean();
}

/**
* @return void
*/

private function output(): void
{
echo '<pre>' . $this->data . '</pre>';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
* @author Walter Nuñez (arcanisgk/original founder)
* @email icarosnet@gmail.com
* @copyright 2020 - 2022 Walter Nuñez/Icaros Net S.A.
* @license For the full copyright and licence information, please view the LICENSE
* @license For the full copyright and licence information, please view the LICENCE
* @note This program is distributed in the hope that it will be useful
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
*/

declare(strict_types=1);

namespace ArcanisGK\PhpDevelopmentTool;
namespace ArcanisGK\PhpDevelopmentTool\Init;

use ArcanisGK\PhpDevelopmentTool\BugCatcher;
use ArcanisGK\PhpDevelopmentTool\WebCLIDetector;

/**
* phpDevToolInitialization Class.
Expand Down Expand Up @@ -66,7 +69,7 @@ public function run()

$path = dirname(__DIR__) . '/src/';

$directive_reader = file_get_contents(dirname(__DIR__) . '/src/directive/php.txt');
$directive_reader = file_get_contents(dirname(__DIR__) . '/../src/directive/php.txt');

$directive_explained = str_replace("{path}", $path, $directive_reader);

Expand Down Expand Up @@ -102,9 +105,3 @@ public function run()

BugCatcher::getInstance(['dir_log' => '/']);

function dop($var)
{
echo '<pre>';
echo var_export($var);
echo '</pre>';
}
46 changes: 46 additions & 0 deletions src/Init/phpExposeData.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

/**
* PHP Development Tools.
* PHP Version required 7.4.* or higher
*
* @see https://github.com/arcanisgk/PHP-Development-Tools
*
* @author Walter Nuñez (arcanisgk/original founder)
* @email icarosnet@gmail.com
* @copyright 2020 - 2022 Walter Nuñez/Icaros Net S.A.
* @license For the full copyright and licence information, please view the LICENCE
* @note This program is distributed in the hope that it will be useful
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE.
*/

declare(strict_types=1);

use ArcanisGK\PhpDevelopmentTool\ExposeData\ExposeEngine;

/**
* @param ...$data
* @return void
* @noinspection PhpUnused
*/

function sd(...$data)
{
foreach ($data as $var) {
ExposeEngine::getInstance(['highlight' => false, 'end' => false])->varDump($var);
}
}

/**
* @param ...$data
* @return void
* @noinspection PhpUnused
*/

function sda(...$data)
{
foreach ($data as $var) {
ExposeEngine::getInstance(['highlight' => true])->varDump($var);
}
}

0 comments on commit 3e72711

Please sign in to comment.