Skip to content

Commit

Permalink
Fix some notices, and move debugging output to logging.
Browse files Browse the repository at this point in the history
  • Loading branch information
NielsdeBlaauw committed Aug 4, 2023
1 parent 08ff8b2 commit cc719eb
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 40 deletions.
15 changes: 10 additions & 5 deletions DXFighter.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
use DXFighter\lib\Polyline;
use DXFighter\lib\Spline;
use DXFighter\lib\Text;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;

/**
* Returns the class name, used for auto loading libraries
Expand All @@ -53,9 +55,11 @@ function dxf_autoloader($className) {
* Class DXFighter
* @package DXFighter
*/
class DXFighter {
class DXFighter implements LoggerAwareInterface{
protected $sections;

use LoggerAwareTrait;

/**
* @var Section
*/
Expand Down Expand Up @@ -225,7 +229,7 @@ public function move($move) {
if (method_exists($entity, 'move')) {
$entity->move($move);
} else {
echo 'The ' . get_class($entity) . ' class does not have a move function.' . PHP_EOL;
$this->logger?->warning('The ' . get_class($entity) . ' class does not have a move function.' . PHP_EOL);
}
}
}
Expand All @@ -241,7 +245,7 @@ public function rotate($rotate, $rotationCenter = array(0, 0, 0)) {
if (method_exists($entity, 'rotate')) {
$entity->rotate($rotate, $rotationCenter);
} else {
echo 'The ' . get_class($entity) . ' class does not have a rotate function.' . PHP_EOL;
$this->logger?->warning('The ' . get_class($entity) . ' class does not have a rotate function.' . PHP_EOL);
}
}
}
Expand Down Expand Up @@ -432,7 +436,8 @@ private function readBlocksSection($values) {
$block = [];
break;
case 'ENDBLK':
$blockEntity = new Block($block[2]);
$name = $block[2] ?? '';
$blockEntity = new Block($name);
$entities = $this->readEntitiesSection($entitiesSection);
foreach ($entities as $entity) {
$blockEntity->addEntity($entity);
Expand Down Expand Up @@ -631,7 +636,7 @@ private function addReadEntity($type, $data, $move = [0,0,0], $rotate = 0) {
$polyline = new Polyline(3);
break;
default:
echo 'The polyline type ' . $data[100] . ' has not been found' . PHP_EOL;
$this->logger?->notice( 'The polyline type ' . $data[100] . ' has not been found' . PHP_EOL );
return false;
}
} else {
Expand Down
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
}
],
"require": {
"psr/log": "^3.0"
},
"require-dev": {
"phpunit/phpunit": "^7",
Expand Down
Loading

0 comments on commit cc719eb

Please sign in to comment.