Skip to content

Instantly share code, notes, and snippets.

View pazteddy's full-sized avatar
🏠
Working from home

Teddy Paz Muñoz pazteddy

🏠
Working from home
View GitHub Profile
@pazteddy
pazteddy / .htaccess
Created February 14, 2026 12:58
Router centralizado
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ Index.php [QSA,L]
@pazteddy
pazteddy / BookingService.php
Created February 9, 2026 16:49
Clases Customer, Room e interfaz de pago PaymentMethod
<?php
declare(strict_types=1);
class Customer
{
public function __construct(
public string $name,
public string $email
) {}
}
@pazteddy
pazteddy / Index.php
Last active February 10, 2026 15:37
Procesar orden
<?php
declare(strict_types=1);
require_once __DIR__ . '/src/ProcessOrder.php';
$cart = [
["name" => "Mouse", "price" => 100, "quantity" => 2],
["name" => "Teclado", "price" => 150, "quantity" => 1],
["name" => "Producto roto"], // sin price/quantity -> salta
@pazteddy
pazteddy / AnonymousFunctions.php
Last active January 30, 2026 17:55
Lista de usuarios con edades y roles
<?php
declare(strict_types=1);
$users = [
["name" => "Teddy", "role" => "admin", "age" => 28],
["name" => "Edgar", "role" => "user", "age" => 16],
["name" => "Devi", "role" => "editor", "age" => 22],
["name" => "Maria", "role" => "user", "age" => 35],
];
@pazteddy
pazteddy / HandlingCommonErrors.php
Last active January 27, 2026 20:31
Manejo adecuado de errores comunes
<?php
declare(strict_types=1);
function requireField(array $data, string $field): string
{
return "Implementar función";
}
function calculateTotal(float $price, int $quantity): float
{
@pazteddy
pazteddy / ArrayFunctions.php
Last active January 26, 2026 16:12
Instrucciones de tarea, listado de Catálogo y usuarios
$catalog = [
["sku" => "LP-001", "name" => "Laptop", "price" => 1200, "stock" => 3],
["sku" => "MS-002", "name" => "Mouse", "price" => 25, "stock" => 0],
["sku" => "KB-003", "name" => "Teclado", "price" => 80, "stock" => 12],
];
$usersTask = [
["id" => 1, "name" => "Ana", "email" => "ana@email.com", "role" => "user"],
["id" => 2, "name" => "Luis", "email" => "luis@email.com", "role" => "admin"],
["id" => 3, "name" => "María", "email" => "maria@email.com", "role" => "editor"],
@pazteddy
pazteddy / ArrayFunctions.php
Created January 22, 2026 17:33
Carro de compras
<?php
$cart = [
["product" => "Laptop", "price" => 1200],
["product" => "Mouse", "price" => 20],
["product" => "Teclado", "price" => 80]
];
@pazteddy
pazteddy / ArrayFunctions.php
Created January 22, 2026 16:18
Lista de usuarios
<?php
$users = [
[
"id" => 1,
"name" => "Ana García",
"username" => "ana.garcia",
"email" => "ana.garcia@example.com",
"role" => "user",
"status" => "active",
"last_login" => "2026-01-20 09:15"
@pazteddy
pazteddy / BreakContinue.md
Created January 20, 2026 16:22
Diferencias, usos típicos de break y continue

⚖️ Diferencia clara entre break y continue

Instrucción Qué hace
break Sale del bucle por completo
continue Salta la iteración actual
Uso típico Buscar algo y detener
Uso típico Filtrar o ignorar datos

❌ Errores comunes

@pazteddy
pazteddy / condicionales.md
Last active January 20, 2026 17:20
Condicionales en PHP

Situaciones recomendadas para el uso de condicionales:

Situación Recomendado
Comparaciones complejas if / else
Rangos de valores if / elseif
Comparar un solo valor fijo switch o match
Condiciones con operadores lógicos if

❌ Errores comunes (evítalos)