File tree Expand file tree Collapse file tree 7 files changed +59
-0
lines changed Expand file tree Collapse file tree 7 files changed +59
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+
3+ namespace JiraRestApi ;
4+
5+ trait ClassSerialize
6+ {
7+ /**
8+ * class property to Array.
9+ *
10+ * @param array $ignoreProperties this properties to be excluded from array.
11+ *
12+ * @return array
13+ */
14+ public function toArray ($ ignoreProperties = [])
15+ {
16+ $ ar = (get_object_vars ($ this ));
17+ foreach ($ ar as $ key => $ value ) {
18+ if (in_array ($ key , $ ignoreProperties )) {
19+ unset($ ar [$ key ]);
20+ }
21+ }
22+
23+ return $ ar ;
24+ }
25+
26+ /**
27+ * class property to String.
28+ *
29+ * @param array $ignoreProperties this properties to be excluded from String.
30+ *
31+ * @return string
32+ */
33+ public function toString ($ ignoreProperties = [])
34+ {
35+ $ ar = $ this ->toArray ($ ignoreProperties );
36+
37+ return json_encode ($ ar , JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE );
38+ }
39+ }
Original file line number Diff line number Diff line change 11<?php
22
33namespace JiraRestApi \Field ;
4+ use JiraRestApi \ClassSerialize ;
45
56/**
67 * Custom filed schema.
@@ -45,6 +46,8 @@ class Schema
4546 */
4647class Field implements \JsonSerializable
4748{
49+ use ClassSerialize;
50+
4851 /**
4952 * only custom field.
5053 */
Original file line number Diff line number Diff line change 22
33namespace JiraRestApi \Issue ;
44
5+ use JiraRestApi \ClassSerialize ;
6+
57class IssueField implements \JsonSerializable
68{
9+ use ClassSerialize;
10+
711 public function __construct ($ updateIssue = false )
812 {
913 if ($ updateIssue != true ) {
Original file line number Diff line number Diff line change 11<?php
22
33namespace JiraRestApi \Issue ;
4+ use JiraRestApi \ClassSerialize ;
45
56/**
67 * Class PaginatedWorklog.
78 */
89class PaginatedWorklog
910{
11+ use ClassSerialize;
12+
1013 /**
1114 * @var int Start at position
1215 */
Original file line number Diff line number Diff line change 77 */
88
99namespace JiraRestApi \Issue ;
10+ use JiraRestApi \ClassSerialize ;
1011
1112/**
1213 * Class TimeTracking.
1314 */
1415class TimeTracking implements \JsonSerializable
1516{
17+ use ClassSerialize;
18+
1619 /**
1720 * Original estimate.
1821 *
Original file line number Diff line number Diff line change 22
33namespace JiraRestApi \Issue ;
44
5+ use JiraRestApi \ClassSerialize ;
56use JiraRestApi \JiraException ;
67
78/**
89 * Class Worklog.
910 */
1011class Worklog
1112{
13+ use ClassSerialize;
14+
1215 /**
1316 * @var int id of worklog
1417 */
Original file line number Diff line number Diff line change 22
33namespace JiraRestApi \Project ;
44
5+ use JiraRestApi \ClassSerialize ;
6+
57class Project
68{
9+ use ClassSerialize;
10+
711 /**
812 * return only if Project query by key(not id).
913 *
You can’t perform that action at this time.
0 commit comments