Code Duplication    Length = 5-5 lines in 13 locations

src/BenatEspina/StackExchangeApiClient/Model/Answer.php 3 locations

@@ 117-121 (lines=5) @@
114
        $awardedBountyUsers = [];
115
        $comments = [];
116
117
        if (array_key_exists('tags', $data) && is_array($data['tags'])) {
118
            foreach ($data['tags'] as $tag) {
119
                $tags[] = Tag::fromJson($tag);
120
            }
121
        }
122
        if (array_key_exists('awarded_bounty_users', $data) && is_array($data['awarded_bounty_users'])) {
123
            foreach ($data['awarded_bounty_users'] as $awardedBountyUser) {
124
                $awardedBountyUsers[] = ShallowUser::fromJson($awardedBountyUser);
@@ 122-126 (lines=5) @@
119
                $tags[] = Tag::fromJson($tag);
120
            }
121
        }
122
        if (array_key_exists('awarded_bounty_users', $data) && is_array($data['awarded_bounty_users'])) {
123
            foreach ($data['awarded_bounty_users'] as $awardedBountyUser) {
124
                $awardedBountyUsers[] = ShallowUser::fromJson($awardedBountyUser);
125
            }
126
        }
127
        if (array_key_exists('comments', $data) && is_array($data['comments'])) {
128
            foreach ($data['comments'] as $comment) {
129
                $comments[] = Comment::fromJson($comment);
@@ 127-131 (lines=5) @@
124
                $awardedBountyUsers[] = ShallowUser::fromJson($awardedBountyUser);
125
            }
126
        }
127
        if (array_key_exists('comments', $data) && is_array($data['comments'])) {
128
            foreach ($data['comments'] as $comment) {
129
                $comments[] = Comment::fromJson($comment);
130
            }
131
        }
132
133
        $instance = new self();
134
        $instance

src/BenatEspina/StackExchangeApiClient/Model/CloseDetails.php 2 locations

@@ 50-54 (lines=5) @@
47
        $instance = new self();
48
49
        $byUsers = [];
50
        if (array_key_exists('by_users', $data) && is_array($data['by_users'])) {
51
            foreach ($data['by_users'] as $byUser) {
52
                $byUsers[] = ShallowUser::fromJson($byUser);
53
            }
54
        }
55
        $originalQuestions = [];
56
        if (array_key_exists('original_questions', $data) && is_array($data['original_questions'])) {
57
            foreach ($data['original_questions'] as $originalQuestion) {
@@ 56-60 (lines=5) @@
53
            }
54
        }
55
        $originalQuestions = [];
56
        if (array_key_exists('original_questions', $data) && is_array($data['original_questions'])) {
57
            foreach ($data['original_questions'] as $originalQuestion) {
58
                $originalQuestions[] = ShallowUser::fromJson($originalQuestion);
59
            }
60
        }
61
62
        $instance
63
            ->setByUsers($byUsers)

src/BenatEspina/StackExchangeApiClient/Model/NetworkUser.php 2 locations

@@ 40-44 (lines=5) @@
37
    {
38
        $topAnswers = [];
39
        $topQuestions = [];
40
        if (array_key_exists('top_answers', $data) && is_array($data['top_answers'])) {
41
            foreach ($data['top_answers'] as $topAnswer) {
42
                $topAnswers[] = NetworkPost::fromJson($topAnswer);
43
            }
44
        }
45
        if (array_key_exists('top_questions', $data) && is_array($data['top_questions'])) {
46
            foreach ($data['top_questions'] as $topQuestion) {
47
                $topQuestions[] = NetworkPost::fromJson($topQuestion);
@@ 45-49 (lines=5) @@
42
                $topAnswers[] = NetworkPost::fromJson($topAnswer);
43
            }
44
        }
45
        if (array_key_exists('top_questions', $data) && is_array($data['top_questions'])) {
46
            foreach ($data['top_questions'] as $topQuestion) {
47
                $topQuestions[] = NetworkPost::fromJson($topQuestion);
48
            }
49
        }
50
51
        $instance = new self();
52
        $instance

src/BenatEspina/StackExchangeApiClient/Model/Question.php 3 locations

@@ 68-72 (lines=5) @@
65
    public static function fromJson(array $data)
66
    {
67
        $answers = [];
68
        if (array_key_exists('answers', $data) && is_array($data['answers'])) {
69
            foreach ($data['answers'] as $answer) {
70
                $answers[] = Answer::fromJson($answer);
71
            }
72
        }
73
        $comments = [];
74
        if (array_key_exists('comments', $data) && is_array($data['comments'])) {
75
            foreach ($data['comments'] as $comment) {
@@ 74-78 (lines=5) @@
71
            }
72
        }
73
        $comments = [];
74
        if (array_key_exists('comments', $data) && is_array($data['comments'])) {
75
            foreach ($data['comments'] as $comment) {
76
                $comments[] = Comment::fromJson($comment);
77
            }
78
        }
79
        $tags = [];
80
        if (array_key_exists('tags', $data) && is_array($data['tags'])) {
81
            foreach ($data['tags'] as $tag) {
@@ 80-84 (lines=5) @@
77
            }
78
        }
79
        $tags = [];
80
        if (array_key_exists('tags', $data) && is_array($data['tags'])) {
81
            foreach ($data['tags'] as $tag) {
82
                $tags[] = Tag::fromJson($tag);
83
            }
84
        }
85
86
        $instance = new self();
87
        $instance

src/BenatEspina/StackExchangeApiClient/Model/Site.php 1 location

@@ 102-106 (lines=5) @@
99
            }
100
        }
101
        $relatedSites = [];
102
        if (array_key_exists('related_sites', $data) && is_array($data['related_sites'])) {
103
            foreach ($data['related_sites'] as $relatedSite) {
104
                $relatedSites[] = RelatedSite::fromJson($relatedSite);
105
            }
106
        }
107
108
        $instance = new self();
109
        $instance

src/BenatEspina/StackExchangeApiClient/Model/NetworkActivity.php 1 location

@@ 43-47 (lines=5) @@
40
    public static function fromJson(array $data)
41
    {
42
        $tags = [];
43
        if (array_key_exists('tags', $data) && is_array($data['tags'])) {
44
            foreach ($data['tags'] as $tag) {
45
                $tags[] = Tag::fromJson($tag);
46
            }
47
        }
48
49
        $instance = new self();
50
        $instance

src/BenatEspina/StackExchangeApiClient/Model/Post.php 1 location

@@ 49-53 (lines=5) @@
46
    public static function fromJson(array $data)
47
    {
48
        $comments = [];
49
        if (array_key_exists('comments', $data) && is_array($data['comments'])) {
50
            foreach ($data['comments'] as $comment) {
51
                $comments[] = Comment::fromJson($comment);
52
            }
53
        }
54
55
        $instance = new self();
56
        $instance