File tree Expand file tree Collapse file tree 4 files changed +19
-106
lines changed Expand file tree Collapse file tree 4 files changed +19
-106
lines changed Original file line number Diff line number Diff line change @@ -35,14 +35,14 @@ class CheckBox extends Text
3535 private $ name ;
3636
3737 /**
38- * Default value
38+ * Default value.
3939 *
4040 * @var bool
4141 */
4242 private $ default = false ;
4343
4444 /**
45- * Create new instance
45+ * Create new instance.
4646 *
4747 * @param string $name
4848 * @param string $text
@@ -80,19 +80,19 @@ public function getName()
8080 }
8181
8282 /**
83- * set default checked status
84- * @param bool $default
83+ * set default checked status.
84+ *
8585 * @return CheckBox
8686 */
8787 public function setDefault (bool $ default = false )
8888 {
8989 $ this ->default = $ default ;
90+
9091 return $ this ;
9192 }
9293
9394 /**
94- * get default checked status
95- * @return bool
95+ * get default checked status.
9696 */
9797 public function isDefault (): bool
9898 {
Original file line number Diff line number Diff line change @@ -52,7 +52,7 @@ public function write(): void
5252 $ xmlWriter ->startElement ('w:checkBox ' );
5353 $ xmlWriter ->writeAttribute ('w:sizeAuto ' , '' );
5454 $ xmlWriter ->startElement ('w:default ' );
55- $ xmlWriter ->writeAttribute ('w:val ' , $ element ->getDefault () ? 1 : 0 );
55+ $ xmlWriter ->writeAttribute ('w:val ' , $ element ->isDefault () ? 1 : 0 );
5656 $ xmlWriter ->endElement (); //w:default
5757 $ xmlWriter ->endElement (); //w:checkBox
5858 $ xmlWriter ->endElement (); // w:ffData
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -85,4 +85,16 @@ public function testParagraph(): void
8585 $ oCheckBox ->setParagraphStyle (['alignment ' => Jc::CENTER , 'spaceAfter ' => 100 ]);
8686 self ::assertInstanceOf ('PhpOffice \\PhpWord \\Style \\Paragraph ' , $ oCheckBox ->getParagraphStyle ());
8787 }
88+
89+ /**
90+ * Get default value.
91+ */
92+ public function testDefault (): void
93+ {
94+ $ oCheckBox = new CheckBox ('chkBox ' , 'CheckBox ' );
95+ self ::assertFalse ($ oCheckBox ->isDefault ());
96+
97+ $ oCheckBox ->setDefault (true );
98+ self ::assertTrue ($ oCheckBox ->isDefault ());
99+ }
88100}
You can’t perform that action at this time.
0 commit comments