diff --git a/Admin/Installer.php b/Admin/Installer.php index 1fca27b..a4c934b 100755 --- a/Admin/Installer.php +++ b/Admin/Installer.php @@ -50,7 +50,7 @@ final class Installer extends InstallerAbstract */ private static function installDefaultUnit() : void { - $unit = new Unit(); + $unit = new Unit(); $unit->name = 'Orange Management'; UnitMapper::create($unit); diff --git a/Controller/ApiController.php b/Controller/ApiController.php index 74762c8..3972a4b 100755 --- a/Controller/ApiController.php +++ b/Controller/ApiController.php @@ -127,12 +127,12 @@ final class ApiController extends Controller private function updateUnitFromRequest(RequestAbstract $request) : Unit { /** @var Unit $unit */ - $unit = UnitMapper::get((int) $request->getData('id')); - $unit->name = (string) ($request->getData('name') ?? $unit->name); + $unit = UnitMapper::get((int) $request->getData('id')); + $unit->name = (string) ($request->getData('name') ?? $unit->name); $unit->descriptionRaw = (string) ($request->getData('description') ?? $unit->descriptionRaw); - $unit->description = Markdown::parse((string) ($request->getData('description') ?? $unit->descriptionRaw)); + $unit->description = Markdown::parse((string) ($request->getData('description') ?? $unit->descriptionRaw)); - $parent = (int) $request->getData('parent'); + $parent = (int) $request->getData('parent'); $unit->parent = !empty($parent) ? new NullUnit($parent) : $unit->parent; $unit->setStatus((int) ($request->getData('status') ?? $unit->getStatus())); @@ -206,12 +206,12 @@ final class ApiController extends Controller */ private function createUnitFromRequest(RequestAbstract $request) : Unit { - $unit = new Unit(); - $unit->name = (string) $request->getData('name'); + $unit = new Unit(); + $unit->name = (string) $request->getData('name'); $unit->descriptionRaw = (string) ($request->getData('description') ?? ''); - $unit->description = Markdown::parse((string) ($request->getData('description') ?? '')); + $unit->description = Markdown::parse((string) ($request->getData('description') ?? '')); - $parent = (int) $request->getData('parent'); + $parent = (int) $request->getData('parent'); $unit->parent = new NullUnit($parent); $unit->setStatus((int) $request->getData('status')); @@ -362,15 +362,15 @@ final class ApiController extends Controller private function updatePositionFromRequest(RequestAbstract $request) : Position { /** @var Position $position */ - $position = PositionMapper::get((int) $request->getData('id')); - $position->name = (string) ($request->getData('name') ?? $position->name); + $position = PositionMapper::get((int) $request->getData('id')); + $position->name = (string) ($request->getData('name') ?? $position->name); $position->descriptionRaw = (string) ($request->getData('description') ?? $position->descriptionRaw); - $position->description = Markdown::parse((string) ($request->getData('description') ?? $position->descriptionRaw)); + $position->description = Markdown::parse((string) ($request->getData('description') ?? $position->descriptionRaw)); - $parent = (int) $request->getData('parent'); + $parent = (int) $request->getData('parent'); $position->parent = !empty($parent) ? new NullPosition($parent) : $position->parent; - $department = (int) $request->getData('department'); + $department = (int) $request->getData('department'); $position->department = !empty($department) ? new NullDepartment($department) : $position->department; $position->setStatus((int) ($request->getData('status') ?? $position->getStatus())); @@ -423,16 +423,16 @@ final class ApiController extends Controller */ private function createPositionFromRequest(RequestAbstract $request) : Position { - $position = new Position(); + $position = new Position(); $position->name = (string) ($request->getData('name')); $position->setStatus((int) $request->getData('status')); $position->descriptionRaw = (string) ($request->getData('description') ?? ''); - $position->description = Markdown::parse((string) ($request->getData('description') ?? '')); + $position->description = Markdown::parse((string) ($request->getData('description') ?? '')); - $parent = (int) $request->getData('parent'); + $parent = (int) $request->getData('parent'); $position->parent = new NullPosition($parent); - $department = (int) $request->getData('department'); + $department = (int) $request->getData('department'); $position->department = new NullDepartment($department); return $position; @@ -519,16 +519,16 @@ final class ApiController extends Controller private function updateDepartmentFromRequest(RequestAbstract $request) : Department { /** @var Department $department */ - $department = DepartmentMapper::get((int) $request->getData('id')); - $department->name = (string) ($request->getData('name') ?? $department->name); + $department = DepartmentMapper::get((int) $request->getData('id')); + $department->name = (string) ($request->getData('name') ?? $department->name); $department->descriptionRaw = (string) ($request->getData('description') ?? $department->descriptionRaw); - $department->description = Markdown::parse((string) ($request->getData('description') ?? $department->descriptionRaw)); + $department->description = Markdown::parse((string) ($request->getData('description') ?? $department->descriptionRaw)); - $parent = (int) $request->getData('parent'); + $parent = (int) $request->getData('parent'); $department->parent = !empty($parent) ? new NullDepartment($parent) : $department->parent; $department->setStatus((int) ($request->getData('status') ?? $department->getStatus())); - $unit = (int) $request->getData('unit'); + $unit = (int) $request->getData('unit'); $department->unit = !empty($unit) ? new NullUnit($unit) : $department->unit; return $department; @@ -601,15 +601,15 @@ final class ApiController extends Controller */ private function createDepartmentFromRequest(RequestAbstract $request) : Department { - $department = new Department(); + $department = new Department(); $department->name = (string) $request->getData('name'); $department->setStatus((int) $request->getData('status')); - $parent = (int) $request->getData('parent'); - $department->parent = new NullDepartment($parent); - $department->unit = new NullUnit((int) ($request->getData('unit') ?? 1)); + $parent = (int) $request->getData('parent'); + $department->parent = new NullDepartment($parent); + $department->unit = new NullUnit((int) ($request->getData('unit') ?? 1)); $department->descriptionRaw = (string) ($request->getData('description') ?? ''); - $department->description = Markdown::parse((string) ($request->getData('description') ?? '')); + $department->description = Markdown::parse((string) ($request->getData('description') ?? '')); return $department; } diff --git a/Models/Department.php b/Models/Department.php index d56cb9b..22c88f8 100755 --- a/Models/Department.php +++ b/Models/Department.php @@ -91,9 +91,9 @@ class Department implements \JsonSerializable, ArrayableInterface */ public function __construct(string $name = '') { - $this->name = $name; + $this->name = $name; $this->parent = new NullDepartment(); - $this->unit = new NullUnit(); + $this->unit = new NullUnit(); } /** diff --git a/Models/NullDepartment.php b/Models/NullDepartment.php index b73c66d..819c721 100755 --- a/Models/NullDepartment.php +++ b/Models/NullDepartment.php @@ -33,7 +33,7 @@ final class NullDepartment extends Department */ public function __construct(int $id = 0) { - $this->id = $id; + $this->id = $id; $this->unit = new NullUnit(); } } diff --git a/Models/NullUnit.php b/Models/NullUnit.php index 3ecb772..c346b5d 100755 --- a/Models/NullUnit.php +++ b/Models/NullUnit.php @@ -35,7 +35,7 @@ final class NullUnit extends Unit */ public function __construct(int $id = 0) { - $this->id = $id; + $this->id = $id; $this->image = new NullMedia(); } } diff --git a/Models/Position.php b/Models/Position.php index 37cd49f..1242b31 100755 --- a/Models/Position.php +++ b/Models/Position.php @@ -89,7 +89,7 @@ class Position implements \JsonSerializable, ArrayableInterface */ public function __construct() { - $this->parent = new NullPosition(); + $this->parent = new NullPosition(); $this->department = new NullDepartment(); } diff --git a/Models/Unit.php b/Models/Unit.php index 9fdc5a7..c36a724 100755 --- a/Models/Unit.php +++ b/Models/Unit.php @@ -91,7 +91,7 @@ class Unit implements \JsonSerializable, ArrayableInterface */ public function __construct() { - $this->image = new NullMedia(); + $this->image = new NullMedia(); $this->parent = new NullUnit(); } diff --git a/Theme/Backend/unit-profile.tpl.php b/Theme/Backend/unit-profile.tpl.php index 4e1644d..0292d17 100755 --- a/Theme/Backend/unit-profile.tpl.php +++ b/Theme/Backend/unit-profile.tpl.php @@ -13,8 +13,8 @@ declare(strict_types=1); use Modules\Media\Models\NullMedia; -use phpOMS\Uri\UriFactory; use Modules\Organization\Models\Status; +use phpOMS\Uri\UriFactory; /** * @var \phpOMS\Views\View $this diff --git a/tests/Models/DepartmentMapperTest.php b/tests/Models/DepartmentMapperTest.php index 64a3c5b..6e602da 100755 --- a/tests/Models/DepartmentMapperTest.php +++ b/tests/Models/DepartmentMapperTest.php @@ -30,10 +30,10 @@ class DepartmentMapperTest extends \PHPUnit\Framework\TestCase */ public function testCRUD() : void { - $department = new Department(); - $department->name = 'Management'; + $department = new Department(); + $department->name = 'Management'; $department->description = 'Description'; - $department->unit = new NullUnit(1); + $department->unit = new NullUnit(1); $id = DepartmentMapper::create($department); @@ -56,67 +56,67 @@ class DepartmentMapperTest extends \PHPUnit\Framework\TestCase $first = 2; /* 2 */ - $department = new Department(); - $department->name = 'HR'; + $department = new Department(); + $department->name = 'HR'; $department->description = 'Description'; - $department->parent = new NullDepartment($first); - $department->unit = new NullUnit(1); + $department->parent = new NullDepartment($first); + $department->unit = new NullUnit(1); DepartmentMapper::create($department); /* 3 */ - $department = new Department(); - $department->name = 'QM'; + $department = new Department(); + $department->name = 'QM'; $department->description = 'Description'; - $department->parent = new NullDepartment($first); - $department->unit = new NullUnit(1); + $department->parent = new NullDepartment($first); + $department->unit = new NullUnit(1); DepartmentMapper::create($department); /* 4 */ - $department = new Department(); - $department->name = 'Sales'; + $department = new Department(); + $department->name = 'Sales'; $department->description = 'Description'; - $department->parent = new NullDepartment($first); - $department->unit = new NullUnit(1); + $department->parent = new NullDepartment($first); + $department->unit = new NullUnit(1); DepartmentMapper::create($department); /* 5 */ - $department = new Department(); - $department->name = 'Shipping'; + $department = new Department(); + $department->name = 'Shipping'; $department->description = 'Description'; - $department->parent = new NullDepartment($first + 3); - $department->unit = new NullUnit(1); + $department->parent = new NullDepartment($first + 3); + $department->unit = new NullUnit(1); DepartmentMapper::create($department); /* 6 */ - $department = new Department(); - $department->name = 'Purchase'; + $department = new Department(); + $department->name = 'Purchase'; $department->description = 'Description'; - $department->parent = new NullDepartment($first); - $department->unit = new NullUnit(1); + $department->parent = new NullDepartment($first); + $department->unit = new NullUnit(1); DepartmentMapper::create($department); /* 7 */ - $department = new Department(); - $department->name = 'Arrival'; + $department = new Department(); + $department->name = 'Arrival'; $department->description = 'Description'; - $department->parent = new NullDepartment($first + 5); - $department->unit = new NullUnit(1); + $department->parent = new NullDepartment($first + 5); + $department->unit = new NullUnit(1); DepartmentMapper::create($department); /* 8 */ - $department = new Department(); - $department->name = 'Accounting'; + $department = new Department(); + $department->name = 'Accounting'; $department->description = 'Description'; - $department->parent = new NullDepartment($first); - $department->unit = new NullUnit(1); + $department->parent = new NullDepartment($first); + $department->unit = new NullUnit(1); DepartmentMapper::create($department); /* 9 */ - $department = new Department(); - $department->name = 'Production'; + $department = new Department(); + $department->name = 'Production'; $department->description = 'Description'; - $department->parent = new NullDepartment($first); - $department->unit = new NullUnit(1); + $department->parent = new NullDepartment($first); + $department->unit = new NullUnit(1); DepartmentMapper::create($department); } } diff --git a/tests/Models/DepartmentTest.php b/tests/Models/DepartmentTest.php index 3c2b1b2..22e3e53 100755 --- a/tests/Models/DepartmentTest.php +++ b/tests/Models/DepartmentTest.php @@ -112,12 +112,12 @@ class DepartmentTest extends \PHPUnit\Framework\TestCase */ public function testSerialize() : void { - $this->department->name = 'Name'; - $this->department->description = 'Description'; + $this->department->name = 'Name'; + $this->department->description = 'Description'; $this->department->descriptionRaw = 'DescriptionRaw'; $this->department->setStatus(Status::ACTIVE); $this->department->parent = ($p = new NullDepartment(1)); - $this->department->unit = ($u = new NullUnit(1)); + $this->department->unit = ($u = new NullUnit(1)); self::assertEquals($this->department->toArray(), $this->department->jsonSerialize()); self::assertEquals( diff --git a/tests/Models/PositionMapperTest.php b/tests/Models/PositionMapperTest.php index ccd8e08..ddcb320 100755 --- a/tests/Models/PositionMapperTest.php +++ b/tests/Models/PositionMapperTest.php @@ -29,8 +29,8 @@ class PositionMapperTest extends \PHPUnit\Framework\TestCase */ public function testCRUD() : void { - $position = new Position(); - $position->name = 'CEO'; + $position = new Position(); + $position->name = 'CEO'; $position->description = 'Description'; $id = PositionMapper::create($position); @@ -53,59 +53,59 @@ class PositionMapperTest extends \PHPUnit\Framework\TestCase $first = 2; /* 4 */ - $position = new Position(); - $position->name = 'CFO'; + $position = new Position(); + $position->name = 'CFO'; $position->description = 'Description'; - $position->parent = new NullPosition($first); - $id = PositionMapper::create($position); + $position->parent = new NullPosition($first); + $id = PositionMapper::create($position); /* 5 */ - $position = new Position(); - $position->name = 'Accountant'; + $position = new Position(); + $position->name = 'Accountant'; $position->description = 'Description'; - $position->parent = new NullPosition($id); + $position->parent = new NullPosition($id); PositionMapper::create($position); /* 6 */ - $position = new Position(); - $position->name = 'Controller'; + $position = new Position(); + $position->name = 'Controller'; $position->description = 'Description'; - $position->parent = new NullPosition($id); + $position->parent = new NullPosition($id); PositionMapper::create($position); /* 7 */ - $position = new Position(); - $position->name = 'Sales Director'; + $position = new Position(); + $position->name = 'Sales Director'; $position->description = 'Description'; - $position->parent = new NullPosition($first); + $position->parent = new NullPosition($first); PositionMapper::create($position); /* 8 */ - $position = new Position(); - $position->name = 'Purchase Director'; + $position = new Position(); + $position->name = 'Purchase Director'; $position->description = 'Description'; - $position->parent = new NullPosition($first); + $position->parent = new NullPosition($first); PositionMapper::create($position); /* 9 */ - $position = new Position(); - $position->name = 'Territory Manager'; + $position = new Position(); + $position->name = 'Territory Manager'; $position->description = 'Description'; - $position->parent = new NullPosition($first + 4); + $position->parent = new NullPosition($first + 4); PositionMapper::create($position); /* 10 */ - $position = new Position(); - $position->name = 'Territory Sales Assistant'; + $position = new Position(); + $position->name = 'Territory Sales Assistant'; $position->description = 'Description'; - $position->parent = new NullPosition($first + 6); + $position->parent = new NullPosition($first + 6); PositionMapper::create($position); /* 11 */ - $position = new Position(); - $position->name = 'Domestic Sales Manager'; + $position = new Position(); + $position->name = 'Domestic Sales Manager'; $position->description = 'Description'; - $position->parent = new NullPosition($first + 4); + $position->parent = new NullPosition($first + 4); PositionMapper::create($position); } } diff --git a/tests/Models/PositionTest.php b/tests/Models/PositionTest.php index b413ec0..024beae 100755 --- a/tests/Models/PositionTest.php +++ b/tests/Models/PositionTest.php @@ -112,11 +112,11 @@ class PositionTest extends \PHPUnit\Framework\TestCase */ public function testSerialize() : void { - $this->position->name = 'Name'; - $this->position->description = 'Description'; + $this->position->name = 'Name'; + $this->position->description = 'Description'; $this->position->descriptionRaw = 'DescriptionRaw'; $this->position->setStatus(Status::ACTIVE); - $this->position->parent = ($p = new NullPosition(1)); + $this->position->parent = ($p = new NullPosition(1)); $this->position->department = ($d = new NullDepartment(1)); self::assertEquals($this->position->toArray(), $this->position->jsonSerialize()); diff --git a/tests/Models/UnitMapperTest.php b/tests/Models/UnitMapperTest.php index 73b6f02..491796d 100755 --- a/tests/Models/UnitMapperTest.php +++ b/tests/Models/UnitMapperTest.php @@ -29,10 +29,10 @@ class UnitMapperTest extends \PHPUnit\Framework\TestCase */ public function testCRUD() : void { - $unit = new Unit(); - $unit->name = 'Scrooge Inc.'; + $unit = new Unit(); + $unit->name = 'Scrooge Inc.'; $unit->description = 'Description'; - $unit->parent = new NullUnit(1); + $unit->parent = new NullUnit(1); $id = UnitMapper::create($unit); diff --git a/tests/Models/UnitTest.php b/tests/Models/UnitTest.php index 6278204..05f80a9 100755 --- a/tests/Models/UnitTest.php +++ b/tests/Models/UnitTest.php @@ -112,12 +112,12 @@ class UnitTest extends \PHPUnit\Framework\TestCase */ public function testSerialize() : void { - $this->unit->name = 'Name'; - $this->unit->description = 'Description'; + $this->unit->name = 'Name'; + $this->unit->description = 'Description'; $this->unit->descriptionRaw = 'DescriptionRaw'; $this->unit->setStatus(Status::ACTIVE); $this->unit->parent = ($p = new NullUnit(1)); - $this->unit->image = ($i = new NullMedia(1)); + $this->unit->image = ($i = new NullMedia(1)); self::assertEquals($this->unit->toArray(), $this->unit->jsonSerialize()); self::assertEquals(