Skip to content
Quiet Social

Methods by convention and priorities

This documentation is translated from French. Should the two versions differ, the French version prevails.

A public method of the model, named by convention and without required parameters, does the same job as an attribute parameter. When several sources give the same field, a fixed order decides which one wins.

The table of names

Field Common method Network method
Text socialContent() {network}Content()
Internal title socialTitle() —
Pin title — pinterestTitle()
Image socialCover() {network}Cover()
Alternative text socialCoverAlt() {network}CoverAlt()
Link socialLink() {network}Link()
Tags socialTags() {network}Tags()
First comment socialFirstComment() {network}FirstComment()
Publication date socialPublishAt() —
Brand socialBrand() —
Targets socialNetworks() —
Condition shouldPublishSocially() shouldPublishTo{Network}()
Destination by name — {network}Destination()

{network} is facebook, instagram, linkedin, threads, pinterest or x: linkedinContent(), pinterestCover(), shouldPublishToInstagram(). PHP method names ignore case, so linkedInContent() works too. mode and coverDisk have no method. instagramLink() and pinterestFirstComment() are refused like the matching attribute parameters: Instagram takes no link, Pinterest no first comment.

Only public, non-static methods without required parameters count: a private or protected method of the same name is ignored. Any network method also declares the network for implicit targets.

An example

use DateTimeInterface;

class Article extends Model
{
    use PublishesToSocial;

    public function socialContent(): string
    {
        return $this->excerpt;
    }

    public function socialPublishAt(): ?DateTimeInterface
    {
        return $this->published_at;
    }

    public function shouldPublishSocially(): bool
    {
        return $this->status === 'published';
    }

    public function linkedinContent(): string
    {
        return $this->excerpt."\n\nThe full article is on our website.";
    }

    public function pinterestTitle(): string
    {
        return $this->title;
    }
}

This model does not name its targets: it declares LinkedIn (linkedinContent()) and Pinterest (pinterestTitle()), and its post goes to whichever of the two has a destination able to publish.

Priorities

For each field, the first value that is not null wins:

  1. the network method (linkedinContent());
  2. the network attribute (#[LinkedIn(content: …)]);
  3. the common method (socialContent());
  4. the common attribute (#[SocialPost(content: …)]).

The common value makes the post; a network value overrides it on that network only. A method that returns null hands over to the next level.

Three rules outside the order

  • shouldPublishSocially(), when it exists, replaces when and skip of #[SocialPost] entirely.
  • shouldPublishTo{Network}(), when it exists, replaces the skip of that network attribute: a skipped network is not targeted.
  • {network}Destination() wins over the destination of the network attribute.

A network alternative text without a network image describes the common image on that network.