Skip to content

Commit f617d07

Browse files
committed
wrap format
1 parent b2c95e3 commit f617d07

File tree

2 files changed

+49
-0
lines changed

2 files changed

+49
-0
lines changed

kernel/format.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,20 @@ PHP_METHOD(vtiful_format, background)
243243
}
244244
/* }}} */
245245

246+
/** {{{ \Vtiful\Kernel\Format::wrap()
247+
*/
248+
PHP_METHOD(vtiful_format, wrap)
249+
{
250+
ZVAL_COPY(return_value, getThis());
251+
252+
format_object *obj = Z_FORMAT_P(getThis());
253+
254+
if (obj->ptr.format) {
255+
format_set_text_wrap(obj->ptr.format);
256+
}
257+
}
258+
/* }}} */
259+
246260
/** {{{ \Vtiful\Kernel\Format::toResource()
247261
*/
248262
PHP_METHOD(vtiful_format, toResource)
@@ -258,6 +272,7 @@ PHP_METHOD(vtiful_format, toResource)
258272
*/
259273
zend_function_entry format_methods[] = {
260274
PHP_ME(vtiful_format, __construct, format_construct_arginfo, ZEND_ACC_PUBLIC)
275+
PHP_ME(vtiful_format, wrap, NULL, ZEND_ACC_PUBLIC)
261276
PHP_ME(vtiful_format, bold, NULL, ZEND_ACC_PUBLIC)
262277
PHP_ME(vtiful_format, italic, NULL, ZEND_ACC_PUBLIC)
263278
PHP_ME(vtiful_format, align, format_align_arginfo, ZEND_ACC_PUBLIC)

tests/format_wrap.phpt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
--TEST--
2+
Check for vtiful presence
3+
--SKIPIF--
4+
<?php if (!extension_loaded("xlswriter")) print "skip"; ?>
5+
--FILE--
6+
<?php
7+
$config = [
8+
'path' => './tests'
9+
];
10+
11+
$fileObject = new \Vtiful\Kernel\Excel($config);
12+
13+
$fileObject = $fileObject->fileName('tutorial.xlsx');
14+
$fileHandle = $fileObject->getHandle();
15+
16+
$format = new \Vtiful\Kernel\Format($fileHandle);
17+
$wrapStyle = $format->wrap()->toResource();
18+
19+
$filePath = $fileObject->header(['name', 'age'])
20+
->data([
21+
["vvvvvvvvvvvvvvvvvvvvvvvvvv\nvvvvvvvvvvvvvvvvvvvvvvvvvvv", 21],
22+
['wjx', 21]
23+
])
24+
->setRow('A2', 50, $wrapStyle)
25+
->output();
26+
27+
var_dump($filePath);
28+
?>
29+
--CLEAN--
30+
<?php
31+
@unlink(__DIR__ . '/tutorial.xlsx');
32+
?>
33+
--EXPECT--
34+
string(21) "./tests/tutorial.xlsx"

0 commit comments

Comments
 (0)