Type tunnel design pattern in PHP

The type tunnel pattern is not exactly a recognized software design pattern by GoF (Gang of Four book). Type tunnel is used in cases where multiple unrelated types are passed (tunneled) through adaptation layer and converted to the type the underlying layer expects.

Type tunnel design pattern UML

Type tunnel also has side effects that compensate its benefits, because in a dynamically typed language such as PHP, the types can be solved differently.

It can be used best in statically typed programming languages such as C++, but in case of PHP, implementing type tunnel isn't really applicable.

See also



Found a typo? Something wrong with this content?

Just fork and edit it.

Content of this work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license. Code snippets in examples are published under the CC0 1.0 Universal (CC0 1.0). Thanks to all contributors.