Documentation

Article
in package

Article Entity - Business object representing an article

This entity encapsulates all article data and business logic following Domain-Driven Design principles. Properties are private to ensure data integrity and encapsulation.

Business Logic:

  • getShortDescription(): Get truncated description for previews
  • getFormattedDate(): Get human-readable creation date
Tags
author

BdeLive - Group 8

version
1.0.0

Table of Contents

Properties

$adminCreatorId  : int|null
$author  : string
$createdAt  : string
$description  : string
$id  : int|null
$imageUrl  : string|null
$publisherName  : string
$slug  : string
$title  : string

Methods

__construct()  : mixed
getAdminCreatorId()  : int|null
getAuthor()  : string
getCreatedAt()  : string
getDescription()  : string
getFormattedDate()  : string
Get formatted creation date for display (French format: dd/mm/YYYY)
getFormattedDateTime()  : string
Get formatted creation date with time (French format: dd/mm/YYYY à HH:MM)
getId()  : int|null
getImageUrl()  : string|null
getImageUrlOrPlaceholder()  : string
Get a safe image URL (returns placeholder if no image)
getPublisherName()  : string
Get display name for "publié par X" (admin who published) Falls back to author if no publisher name (legacy articles)
getShortDescription()  : string
Get truncated description for article previews
getSlug()  : string
getTitle()  : string
hasImage()  : bool
Check if article has an image
setAuthor()  : void
setDescription()  : void
setImageUrl()  : void
setSlug()  : void
setTitle()  : void

Properties

$adminCreatorId

private int|null $adminCreatorId = null

$createdAt

private string $createdAt

$description

private string $description

$imageUrl

private string|null $imageUrl

$publisherName

private string $publisherName = ''

Methods

__construct()

public __construct(int|null $id, string $title, string $slug, string $description, string|null $imageUrl, string $author, string $createdAt[, int|null $adminCreatorId = null ][, string $publisherName = '' ]) : mixed
Parameters
$id : int|null

Unique identifier (null for new articles)

$title : string

Article title

$slug : string

SEO-friendly URL slug

$description : string

Article content/description

$imageUrl : string|null

Cloudinary image URL (nullable)

$author : string

Author full name (legacy / fallback)

$createdAt : string

Creation timestamp

$adminCreatorId : int|null = null

User ID of admin/superadmin who published (nullable for legacy)

$publisherName : string = ''

"Prénom Nom" of admin who published (for display "publié par X")

getAdminCreatorId()

public getAdminCreatorId() : int|null
Return values
int|null

getAuthor()

public getAuthor() : string
Return values
string

getCreatedAt()

public getCreatedAt() : string
Return values
string

getDescription()

public getDescription() : string
Return values
string

getFormattedDate()

Get formatted creation date for display (French format: dd/mm/YYYY)

public getFormattedDate() : string
Return values
string

Formatted date string

getFormattedDateTime()

Get formatted creation date with time (French format: dd/mm/YYYY à HH:MM)

public getFormattedDateTime() : string
Return values
string

Formatted datetime string

getId()

public getId() : int|null
Return values
int|null

getImageUrl()

public getImageUrl() : string|null
Return values
string|null

getImageUrlOrPlaceholder()

Get a safe image URL (returns placeholder if no image)

public getImageUrlOrPlaceholder([string $placeholder = '/assets/img/default-article.jpg' ]) : string
Parameters
$placeholder : string = '/assets/img/default-article.jpg'

Default placeholder URL

Return values
string

Image URL or placeholder

getPublisherName()

Get display name for "publié par X" (admin who published) Falls back to author if no publisher name (legacy articles)

public getPublisherName() : string
Return values
string

getShortDescription()

Get truncated description for article previews

public getShortDescription([int $limit = 150 ]) : string

Returns a shortened version of the description with ellipsis if it exceeds the specified limit. Useful for article listings and previews where full content is not needed.

Parameters
$limit : int = 150

Maximum character length (default: 150)

Return values
string

Truncated description with ellipsis if needed

getSlug()

public getSlug() : string
Return values
string

getTitle()

public getTitle() : string
Return values
string

hasImage()

Check if article has an image

public hasImage() : bool
Return values
bool

True if article has an image URL

setAuthor()

public setAuthor(string $author) : void
Parameters
$author : string

setDescription()

public setDescription(string $description) : void
Parameters
$description : string

setImageUrl()

public setImageUrl(string|null $imageUrl) : void
Parameters
$imageUrl : string|null

setSlug()

public setSlug(string $slug) : void
Parameters
$slug : string

setTitle()

public setTitle(string $title) : void
Parameters
$title : string

        
On this page

Search results