From 011ec7744cd91827aa46b8926a197adb747b6515 Mon Sep 17 00:00:00 2001 From: David Beasley Date: Tue, 22 Feb 2022 16:36:54 +0000 Subject: [PATCH 1/5] Added fontFamily property --- src/Document/Styles/TextStyle.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Document/Styles/TextStyle.php b/src/Document/Styles/TextStyle.php index 2ac6fb9..56d4e37 100644 --- a/src/Document/Styles/TextStyle.php +++ b/src/Document/Styles/TextStyle.php @@ -15,6 +15,7 @@ */ class TextStyle extends Base { + protected $fontFamily; protected $fontName; protected $fontSize; protected $textColor; @@ -32,6 +33,7 @@ class TextStyle extends Base { */ protected function optional() { return array_merge(parent::optional(), array( + 'fontFamily', 'fontName', 'fontSize', 'textColor', @@ -46,6 +48,26 @@ protected function optional() { )); } + /** + * Getter for fontFamily. + */ + public function getFontFamily() { + return $this->fontFamily; + } + + /** + * Setter for fontFamily. + * + * @param string $value + * FontFamily. + * + * @return $this + */ + public function setFontFamily($value) { + $this->fontFamily = (string) $value; + return $this; + } + /** * Getter for fontName. */ From 020aae4ccc33c2ff6b15ad4563a188ff332726ba Mon Sep 17 00:00:00 2001 From: David Beasley Date: Tue, 22 Feb 2022 21:19:50 +0000 Subject: [PATCH 2/5] Added missing TextStyle font properties --- src/Document/Styles/TextStyle.php | 67 +++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/Document/Styles/TextStyle.php b/src/Document/Styles/TextStyle.php index 56d4e37..195b452 100644 --- a/src/Document/Styles/TextStyle.php +++ b/src/Document/Styles/TextStyle.php @@ -18,6 +18,9 @@ class TextStyle extends Base { protected $fontFamily; protected $fontName; protected $fontSize; + protected $fontStyle; + protected $fontWeight; + protected $fontWidth; protected $textColor; protected $textShadow; protected $textTransform; @@ -36,6 +39,9 @@ protected function optional() { 'fontFamily', 'fontName', 'fontSize', + 'fontStyle', + 'fontWeight', + 'fontWidth', 'textColor', 'textShadow', 'textTransform', @@ -108,6 +114,67 @@ public function setFontSize($value) { return $this; } + /** + * Getter for fontStyle. + */ + public function getFontStyle() { + return $this->fontStyle; + } + + /** + * Setter for fontStyle. + * + * @param string $value + * fontStyle. + * + * @return $this + */ + public function setFontStyle($value) { + $this->fontStyle = (string) $value; + return $this; + } + + /** + * Getter for fontWeight. + */ + public function getFontWeight() { + return $this->fontWeight; + } + + /** + * Setter for fontWeight. + * + * @param string $value + * fontWeight. + * + * @return $this + */ + public function setFontWeight($value) { + $this->fontWeight = (string) $value; + return $this; + } + + + /** + * Getter for fontWidth. + */ + public function getfontWidth() { + return $this->fontWidth; + } + + /** + * Setter for fontWidth. + * + * @param string $value + * fontWidth. + * + * @return $this + */ + public function setfontWidth($value) { + $this->fontWidth = (string) $value; + return $this; + } + /** * Getter for textColor. */ From 68d12b8929ffb7f4cdf929bcdeac06b2e5ea844f Mon Sep 17 00:00:00 2001 From: David Beasley Date: Tue, 22 Feb 2022 21:20:20 +0000 Subject: [PATCH 3/5] Added missing ComponentTextStyle properties --- src/Document/Styles/ComponentTextStyle.php | 110 +++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/src/Document/Styles/ComponentTextStyle.php b/src/Document/Styles/ComponentTextStyle.php index 3057763..bfe75c4 100644 --- a/src/Document/Styles/ComponentTextStyle.php +++ b/src/Document/Styles/ComponentTextStyle.php @@ -17,6 +17,11 @@ class ComponentTextStyle extends TextStyle { protected $dropCapStyle; protected $hyphenation; protected $linkStyle; + protected $firstLineIndent; + protected $fontScaling; + protected $hangingPunctuation; + protected $paragraphSpacingAfter; + protected $paragraphSpacingBefore; /** * Define optional properties. @@ -28,6 +33,11 @@ protected function optional() { 'dropCapStyle', 'hyphenation', 'linkStyle', + 'firstLineIndent', + 'fontScaling', + 'hangingPunctuation', + 'paragraphSpacingAfter', + 'paragraphSpacingBefore', )); } @@ -133,6 +143,106 @@ public function setHyphenation($value) { return $this; } + /** + * Getter for firstLineIndent. + */ + public function getFirstLineIndent() { + return $this->firstLineIndent; + } + + /** + * Setter for firstLineIndent. + * + * @param int $value + * firstLineIndent. + * + * @return $this + */ + public function setFirstLineIndent($value) { + $this->firstLineIndent = $value; + return $this; + } + + /** + * Getter for fontScaling. + */ + public function getFontScaling() { + return $this->fontScaling; + } + + /** + * Setter for fontScaling. + * + * @param bool $value + * fontScaling. + * + * @return $this + */ + public function setFontScaling($value) { + $this->fontScaling = $value; + return $this; + } + + /** + * Getter for hangingPunctuation. + */ + public function getHangingPunctuation() { + return $this->hangingPunctuation; + } + + /** + * Setter for hangingPunctuation. + * + * @param bool $value + * hangingPunctuation. + * + * @return $this + */ + public function setHangingPunctuation($value) { + $this->hangingPunctuation = $value; + return $this; + } + + /** + * Getter for paragraphSpacingAfter. + */ + public function getParagraphSpacingAfter() { + return $this->paragraphSpacingAfter; + } + + /** + * Setter for paragraphSpacingAfter. + * + * @param int $value + * paragraphSpacingAfter. + * + * @return $this + */ + public function setParagraphSpacingAfter($value) { + $this->paragraphSpacingAfter = $value; + return $this; + } + + /** + * Getter for paragraphSpacingBefore. + */ + public function getParagraphSpacingBefore() { + return $this->paragraphSpacingBefore; + } + + /** + * Setter for paragraphSpacingBefore. + * + * @param int $value + * paragraphSpacingBefore. + * + * @return $this + */ + public function setParagraphSpacingBefore($value) { + $this->paragraphSpacingBefore = $value; + return $this; + } + /** * Implements JsonSerializable::jsonSerialize(). */ From e1111d54d5265721bf00c8dc6024c8674d782614 Mon Sep 17 00:00:00 2001 From: David Beasley Date: Mon, 28 Feb 2022 16:11:23 +0000 Subject: [PATCH 4/5] Allow TextStyle fontWeight to be an integer As well as strings representing named font weights, the fontWeight property can also be an integer. Note that Apple News does not allow an integer fontWeight to be given as a string. --- src/Document/Styles/TextStyle.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Document/Styles/TextStyle.php b/src/Document/Styles/TextStyle.php index 195b452..9b1ca31 100644 --- a/src/Document/Styles/TextStyle.php +++ b/src/Document/Styles/TextStyle.php @@ -144,13 +144,13 @@ public function getFontWeight() { /** * Setter for fontWeight. * - * @param string $value + * @param int|string $value * fontWeight. * * @return $this */ public function setFontWeight($value) { - $this->fontWeight = (string) $value; + $this->fontWeight = $value; return $this; } From 546bfef375054cef77717037993b0091d5cd2e15 Mon Sep 17 00:00:00 2001 From: David Beasley Date: Tue, 1 Mar 2022 15:36:36 +0000 Subject: [PATCH 5/5] Allow ComponentTextStyle->setLinkStyle to take an array This allows the linkStyle property to be set easily with values from a config entity object. --- src/Document/Styles/ComponentTextStyle.php | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Document/Styles/ComponentTextStyle.php b/src/Document/Styles/ComponentTextStyle.php index bfe75c4..735801f 100644 --- a/src/Document/Styles/ComponentTextStyle.php +++ b/src/Document/Styles/ComponentTextStyle.php @@ -113,13 +113,26 @@ public function getLinkStyle() { /** * Setter for linkStyle. * - * @param \ChapterThree\AppleNewsAPI\Document\Styles\TextStyle $value + * @param \ChapterThree\AppleNewsAPI\Document\Styles\TextStyle | array $value * LinkStyle. * * @return $this */ - public function setLinkStyle(TextStyle $value) { - $this->linkStyle = $value; + public function setLinkStyle($value) { + if (is_object($value) && $value instanceof TextStyle) { + $this->linkStyle = $value; + } elseif (is_array($value)) { + $object = new TextStyle(); + foreach ($value as $field => $v) { + $method = 'set' . ucfirst($field); + if ($v && method_exists($object, $method)) { + $object->{$method}($v); + } + } + $this->linkStyle = $object; + } else { + $this->triggerError('linkStyle is not array or object of class TextStyle'); + } return $this; }