Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra TextStyle and ComponentTextStyle properties #32

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 126 additions & 3 deletions src/Document/Styles/ComponentTextStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -28,6 +33,11 @@ protected function optional() {
'dropCapStyle',
'hyphenation',
'linkStyle',
'firstLineIndent',
'fontScaling',
'hangingPunctuation',
'paragraphSpacingAfter',
'paragraphSpacingBefore',
));
}

Expand Down Expand Up @@ -103,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;
}

Expand All @@ -133,6 +156,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().
*/
Expand Down
89 changes: 89 additions & 0 deletions src/Document/Styles/TextStyle.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@
*/
class TextStyle extends Base {

protected $fontFamily;
protected $fontName;
protected $fontSize;
protected $fontStyle;
protected $fontWeight;
protected $fontWidth;
protected $textColor;
protected $textShadow;
protected $textTransform;
Expand All @@ -32,8 +36,12 @@ class TextStyle extends Base {
*/
protected function optional() {
return array_merge(parent::optional(), array(
'fontFamily',
'fontName',
'fontSize',
'fontStyle',
'fontWeight',
'fontWidth',
'textColor',
'textShadow',
'textTransform',
Expand All @@ -46,6 +54,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.
*/
Expand Down Expand Up @@ -86,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 int|string $value
* fontWeight.
*
* @return $this
*/
public function setFontWeight($value) {
$this->fontWeight = $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.
*/
Expand Down