Files
michaelschiemer/src/Framework/View/Components/Image.php
Michael Schiemer fc3d7e6357 feat(Production): Complete production deployment infrastructure
- Add comprehensive health check system with multiple endpoints
- Add Prometheus metrics endpoint
- Add production logging configurations (5 strategies)
- Add complete deployment documentation suite:
  * QUICKSTART.md - 30-minute deployment guide
  * DEPLOYMENT_CHECKLIST.md - Printable verification checklist
  * DEPLOYMENT_WORKFLOW.md - Complete deployment lifecycle
  * PRODUCTION_DEPLOYMENT.md - Comprehensive technical reference
  * production-logging.md - Logging configuration guide
  * ANSIBLE_DEPLOYMENT.md - Infrastructure as Code automation
  * README.md - Navigation hub
  * DEPLOYMENT_SUMMARY.md - Executive summary
- Add deployment scripts and automation
- Add DEPLOYMENT_PLAN.md - Concrete plan for immediate deployment
- Update README with production-ready features

All production infrastructure is now complete and ready for deployment.
2025-10-25 19:18:37 +02:00

137 lines
3.7 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Framework\View\Components;
use App\Framework\View\ValueObjects\HtmlAttributes;
use App\Framework\View\ValueObjects\HtmlElement;
use App\Framework\View\ValueObjects\HtmlTag;
use App\Framework\View\ValueObjects\StandardHtmlElement;
use App\Framework\View\ValueObjects\TagName;
final readonly class Image implements HtmlElement
{
public HtmlTag $tag;
public HtmlAttributes $attributes;
public string $content;
public function __construct(
public string $src,
public string $alt,
public ?int $width = null,
public ?int $height = null,
public string $loading = 'lazy',
public string $decoding = 'async',
public ?string $srcset = null,
public ?string $sizes = null,
public HtmlAttributes $additionalAttributes = new HtmlAttributes()
) {
$this->tag = new HtmlTag(TagName::IMG);
$this->attributes = HtmlAttributes::empty()
->with('src', $this->src)
->with('alt', $this->alt)
->with('loading', $this->loading)
->with('decoding', $this->decoding);
if ($this->width !== null) {
$this->attributes = $this->attributes->with('width', (string) $this->width);
}
if ($this->height !== null) {
$this->attributes = $this->attributes->with('height', (string) $this->height);
}
if ($this->srcset !== null) {
$this->attributes = $this->attributes->with('srcset', $this->srcset);
}
if ($this->sizes !== null) {
$this->attributes = $this->attributes->with('sizes', $this->sizes);
}
// Merge additional attributes
foreach ($this->additionalAttributes->attributes as $name => $value) {
$this->attributes = $this->attributes->with($name, $value);
}
$this->content = '';
}
public static function create(string $src, string $alt): self
{
return new self(src: $src, alt: $alt);
}
public static function responsive(
string $src,
string $alt,
string $srcset,
string $sizes = '100vw'
): self {
return new self(
src: $src,
alt: $alt,
srcset: $srcset,
sizes: $sizes
);
}
public function withDimensions(int $width, int $height): self
{
return new self(
src: $this->src,
alt: $this->alt,
width: $width,
height: $height,
loading: $this->loading,
decoding: $this->decoding,
srcset: $this->srcset,
sizes: $this->sizes,
additionalAttributes: $this->additionalAttributes
);
}
public function eager(): self
{
return new self(
src: $this->src,
alt: $this->alt,
width: $this->width,
height: $this->height,
loading: 'eager',
decoding: $this->decoding,
srcset: $this->srcset,
sizes: $this->sizes,
additionalAttributes: $this->additionalAttributes
);
}
public function syncDecoding(): self
{
return new self(
src: $this->src,
alt: $this->alt,
width: $this->width,
height: $this->height,
loading: $this->loading,
decoding: 'sync',
srcset: $this->srcset,
sizes: $this->sizes,
additionalAttributes: $this->additionalAttributes
);
}
public function __toString(): string
{
return (string) StandardHtmlElement::create(
$this->tag->name,
$this->attributes,
$this->content
);
}
}