-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from simonhamp/picture-placements
Picture placements
- Loading branch information
Showing
13 changed files
with
128 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
|
||
namespace SimonHamp\TheOg\Theme; | ||
|
||
class Picture | ||
{ | ||
protected bool $isUrl = false; | ||
|
||
public function __construct( | ||
protected string $path, | ||
protected ?float $opacity = 1.0, | ||
protected ?PicturePlacement $placement = null, | ||
){ | ||
$this->setPath($path); | ||
$this->setOpacity($opacity); | ||
} | ||
|
||
public function opacity(): float | ||
{ | ||
return $this->opacity; | ||
} | ||
|
||
public function setOpacity(float $opacity): static | ||
{ | ||
$this->opacity = max(0, min($opacity, 1)); | ||
return $this; | ||
} | ||
|
||
public function path(): string | ||
{ | ||
return $this->path; | ||
} | ||
|
||
public function setPath(string $path): static | ||
{ | ||
if (filter_var($path, FILTER_VALIDATE_URL)) { | ||
$this->isUrl = true; | ||
} | ||
|
||
$this->path = $path; | ||
return $this; | ||
} | ||
|
||
public function placement(): ?PicturePlacement | ||
{ | ||
return $this->placement ?? null; | ||
} | ||
|
||
public function setPlacement(PicturePlacement $placement): static | ||
{ | ||
$this->placement = $placement; | ||
return $this; | ||
} | ||
|
||
public function isUrl(): bool | ||
{ | ||
return $this->isUrl; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace SimonHamp\TheOg\Theme; | ||
|
||
enum PicturePlacement: string | ||
{ | ||
case Natural = 'natural'; | ||
|
||
case Cover = 'cover'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file modified
BIN
+907 Bytes
(100%)
...on/__snapshots__/ImageTest__test_basic_image with data set avatar layout__1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.