Skip to content

Commit

Permalink
few lil things
Browse files Browse the repository at this point in the history
  • Loading branch information
dcarbone committed Nov 17, 2024
1 parent 7a2d523 commit a3ba859
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 6 deletions.
54 changes: 54 additions & 0 deletions template/core/interfaces/interface_contained_type.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php declare(strict_types=1);

/*
* Copyright 2018-2024 Daniel Carbone ([email protected])
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/** @var \DCarbone\PHPFHIR\Config $config */

$namespace = $config->getFullyQualifiedName(false);

ob_start();

echo "<?php declare(strict_types=1);\n\n";

if ('' !== $namespace) :
echo "namespace {$namespace};\n\n";
endif;

echo $config->getBasePHPFHIRCopyrightComment();

echo "\n\n";
?>
/**
* Interface <?php echo PHPFHIR_INTERFACE_CONTAINED_TYPE; ; if ('' !== $namespace) : ?>

* This is a meta interface that must never be directly implemented by a class. It exists purely to ensure type safety
* throughout the base package.
*
* @package \<?php echo $namespace; ?>
<?php endif; ?>

*/
interface <?php echo PHPFHIR_INTERFACE_CONTAINED_TYPE; ?>

{
/**
* The return from this method is used only when json serializing this type
* @return string
*/
public function _getResourceType(): string;
}
<?php return ob_get_clean();
9 changes: 8 additions & 1 deletion template/versions/core/classes/class_version_type_map.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/** @var \DCarbone\PHPFHIR\Version $version */
/** @var \DCarbone\PHPFHIR\Version\Definition\Types $types */

$config = $version->getConfig();
$namespace = $version->getFullyQualifiedName(false);

$containerType = $types->getContainerType($version->getName());
Expand Down Expand Up @@ -54,6 +55,12 @@

echo "\n\n";
?>

use <?php echo $config->getFullyQualifiedName(false, PHPFHIR_CLASSNAME_CONFIG); ?>;
use <?php echo $config->getFullyQualifiedName(false, PHPFHIR_CLASSNAME_CONSTANTS); ?>;
use <?php echo $config->getFullyQualifiedName(false, PHPFHIR_INTERFACE_TYPE); ?>;
use <?php echo $config->getFullyQualifiedName(false, PHPFHIR_INTERFACE_TYPE_MAP); ?>;

/**
* Class <?php echo PHPFHIR_CLASSNAME_VERSION_TYPEMAP; if ('' !== $namespace) : ?>

Expand Down Expand Up @@ -138,7 +145,7 @@ public function isContainableResource(string|array|\SimpleXMLElement|<?php echo

/**
* @param \SimpleXMLElement $node Parent element containing inline resource
* @param <?php echo $version->getFullyQualifiedName(true, PHPFHIR_CLASSNAME_CONFIG); ?> $config
* @param <?php echo $config->getFullyQualifiedName(true, PHPFHIR_CLASSNAME_CONFIG); ?> $config
* @return null|<?php echo $version->getfullyQualifiedName(true, PHPFHIR_INTERFACE_CONTAINED_TYPE); ?>

*/
Expand Down
11 changes: 6 additions & 5 deletions template/versions/core/interfaces/interface_contained_type.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
/** @var \DCarbone\PHPFHIR\Version $version */
/** @var \DCarbone\PHPFHIR\Version\Definition\Types $types */

$config = $version->getConfig();
$namespace = $version->getFullyQualifiedName(false);

$containerType = $types->getContainerType($version->getName());
Expand All @@ -44,6 +45,8 @@

echo "\n\n";
?>
use <?php echo $config->getFullyQualifiedName(false, PHPFHIR_INTERFACE_TYPE); ?>;

/**
* Interface <?php echo PHPFHIR_INTERFACE_CONTAINED_TYPE; ?>
*
Expand All @@ -56,10 +59,8 @@
interface <?php echo PHPFHIR_INTERFACE_CONTAINED_TYPE; ?> extends <?php echo PHPFHIR_INTERFACE_TYPE; ?>

{
/**
* The return from this method is used only when json serializing this type
* @return string
*/
public function _getResourceType(): string;
// This interface exists purely to enable version-type enforcement within the <?php echo $version->getName(); ?>

// version package.
}
<?php return ob_get_clean();

0 comments on commit a3ba859

Please sign in to comment.