mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-30 13:34:28 +02:00
Fixed some inspection issues.
This commit is contained in:
parent
eef26f7ae6
commit
639829f5c5
97 changed files with 305 additions and 185 deletions
|
@ -27,6 +27,7 @@ use App\Entity\Base\AbstractDBElement;
|
|||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
final class BarcodeContentGenerator
|
||||
|
@ -88,6 +89,6 @@ final class BarcodeContentGenerator
|
|||
}
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Unknown object class '.get_class($target));
|
||||
throw new InvalidArgumentException('Unknown object class '.get_class($target));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,6 +30,9 @@ use App\Entity\Parts\Manufacturer;
|
|||
use App\Entity\Parts\Part;
|
||||
use App\Entity\Parts\PartLot;
|
||||
use App\Entity\Parts\Storelocation;
|
||||
use DateTime;
|
||||
use InvalidArgumentException;
|
||||
use ReflectionClass;
|
||||
|
||||
final class BarcodeExampleElementsGenerator
|
||||
{
|
||||
|
@ -43,7 +46,7 @@ final class BarcodeExampleElementsGenerator
|
|||
case 'storelocation':
|
||||
return $this->getStorelocation();
|
||||
default:
|
||||
throw new \InvalidArgumentException('Unknown $type.');
|
||||
throw new InvalidArgumentException('Unknown $type.');
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,7 +81,7 @@ final class BarcodeExampleElementsGenerator
|
|||
|
||||
$lot->setDescription('Example Lot');
|
||||
$lot->setComment('Lot comment');
|
||||
$lot->setExpirationDate(new \DateTime('+1 days'));
|
||||
$lot->setExpirationDate(new DateTime('+1 days'));
|
||||
$lot->setStorageLocation($this->getStructuralData(Storelocation::class));
|
||||
$lot->setAmount(123);
|
||||
|
||||
|
@ -103,7 +106,7 @@ final class BarcodeExampleElementsGenerator
|
|||
private function getStructuralData(string $class): AbstractStructuralDBElement
|
||||
{
|
||||
if (!is_a($class, AbstractStructuralDBElement::class, true)) {
|
||||
throw new \InvalidArgumentException('$class must be an child of AbstractStructuralDBElement');
|
||||
throw new InvalidArgumentException('$class must be an child of AbstractStructuralDBElement');
|
||||
}
|
||||
|
||||
/** @var AbstractStructuralDBElement $parent */
|
||||
|
@ -112,7 +115,7 @@ final class BarcodeExampleElementsGenerator
|
|||
|
||||
/** @var AbstractStructuralDBElement $child */
|
||||
$child = new $class();
|
||||
$child->setName((new \ReflectionClass($class))->getShortName());
|
||||
$child->setName((new ReflectionClass($class))->getShortName());
|
||||
$child->setParent($parent);
|
||||
|
||||
return $child;
|
||||
|
|
|
@ -23,6 +23,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Services\LabelSystem\Barcodes;
|
||||
|
||||
use InvalidArgumentException;
|
||||
|
||||
final class BarcodeNormalizer
|
||||
{
|
||||
private const PREFIX_TYPE_MAP = [
|
||||
|
@ -54,7 +56,7 @@ final class BarcodeNormalizer
|
|||
$id = (int) $matches[2];
|
||||
|
||||
if (!isset(self::PREFIX_TYPE_MAP[$prefix])) {
|
||||
throw new \InvalidArgumentException('Unknown prefix '.$prefix);
|
||||
throw new InvalidArgumentException('Unknown prefix '.$prefix);
|
||||
}
|
||||
|
||||
return [self::PREFIX_TYPE_MAP[$prefix], $id];
|
||||
|
@ -66,7 +68,7 @@ final class BarcodeNormalizer
|
|||
$id = (int) $matches[2];
|
||||
|
||||
if (!isset(self::PREFIX_TYPE_MAP[$prefix])) {
|
||||
throw new \InvalidArgumentException('Unknown prefix '.$prefix);
|
||||
throw new InvalidArgumentException('Unknown prefix '.$prefix);
|
||||
}
|
||||
|
||||
return [self::PREFIX_TYPE_MAP[$prefix], $id];
|
||||
|
@ -82,6 +84,6 @@ final class BarcodeNormalizer
|
|||
return ['part', (int) $matches[1]];
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException('Unknown barcode format!');
|
||||
throw new InvalidArgumentException('Unknown barcode format!');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ namespace App\Services\LabelSystem\Barcodes;
|
|||
use App\Entity\Parts\PartLot;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Doctrine\ORM\EntityNotFoundException;
|
||||
use InvalidArgumentException;
|
||||
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
|
||||
|
||||
final class BarcodeRedirector
|
||||
|
@ -67,7 +68,7 @@ final class BarcodeRedirector
|
|||
return $this->urlGenerator->generate('part_list_store_location', ['id' => $id]);
|
||||
|
||||
default:
|
||||
throw new \InvalidArgumentException('Unknown $type: '.$type);
|
||||
throw new InvalidArgumentException('Unknown $type: '.$type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue