Skip to content

Commit

Permalink
Add JsonFormsUtil
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Tubach committed Jan 15, 2024
1 parent 57e9958 commit e1eb5ba
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
31 changes: 31 additions & 0 deletions Civi/RemoteTools/JsonForms/Util/JsonFormsUtil.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/*
* Copyright (C) 2024 SYSTOPIA GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation in version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

declare(strict_types = 1);

namespace Civi\RemoteTools\JsonForms\Util;

final class JsonFormsUtil {

/**
* @phpstan-param array<string> $path
*/
public static function pathToScope(array $path): string {
return '#/properties/' . implode('/properties/', $path);
}

}
33 changes: 33 additions & 0 deletions Civi/RemoteTools/JsonForms/Util/JsonFormsUtilTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/*
* Copyright (C) 2024 SYSTOPIA GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation in version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

declare(strict_types = 1);

namespace Civi\RemoteTools\JsonForms\Util;

use PHPUnit\Framework\TestCase;

/**
* @covers \Civi\RemoteTools\JsonForms\Util\JsonFormsUtil
*/
final class JsonFormsUtilTest extends TestCase {

public function testPathToScope(): void {
static::assertSame('#/ab/cd', JsonFormsUtil::pathToScope(['ab', 'cd']));
}

}

0 comments on commit e1eb5ba

Please sign in to comment.