Code Explainers
Code explainers tagged #encapsulation
php
<?php namespace App\Support;
Locale-aware formatting with PHP's intl extension
internationalization
encapsulation
constructor-injection
Intermediate
7 steps
php
<?php namespace App\View;
Building a safe HTML escaper in PHP
security
xss
escaping
Intermediate
6 steps
typescript
type CheckoutState = "cart" | "shipping" | "payment" | "review" | "confirmed"; type CheckoutEvent = | { type: "PROCEED" }
A typed checkout state machine in TypeScript
state-machine
union-types
type-safety
Intermediate
7 steps
ruby
class CheckoutService Result = Struct.new(:success?, :order, :error, keyword_init: true) def self.call(...)
How a Rails checkout service object works
service object
transactions
result object
Intermediate
9 steps
javascript
class Stack { #items = []; push(value) {
Building a Stack with private fields
data-structures
encapsulation
iterators
Intermediate
7 steps
php
<?php class Entity {
PHP magic methods for dynamic attributes
magic-methods
overloading
encapsulation
Intermediate
6 steps
typescript
// A module-scoped Singleton: the single instance lives in this module's // closure and is never exposed directly. interface AppConfig {
A module-scoped Singleton in TypeScript
singleton
generics
encapsulation
Intermediate
7 steps