Code Duplication    Length = 5-5 lines in 10 locations

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

@@ 60-64 (lines=5) @@
57
        $instance = new self();
58
59
        $byUsers = [];
60
        if (array_key_exists('by_users', $data) && is_array($data['by_users'])) {
61
            foreach ($data['by_users'] as $byUser) {
62
                $byUsers[] = ShallowUser::fromJson($byUser);
63
            }
64
        }
65
        $originalQuestions = [];
66
        if (array_key_exists('original_questions', $data) && is_array($data['original_questions'])) {
67
            foreach ($data['original_questions'] as $originalQuestion) {
@@ 66-70 (lines=5) @@
63
            }
64
        }
65
        $originalQuestions = [];
66
        if (array_key_exists('original_questions', $data) && is_array($data['original_questions'])) {
67
            foreach ($data['original_questions'] as $originalQuestion) {
68
                $originalQuestions[] = ShallowUser::fromJson($originalQuestion);
69
            }
70
        }
71
72
        $instance
73
            ->setByUsers($byUsers)

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

@@ 53-57 (lines=5) @@
50
    public static function fromJson(array $data)
51
    {
52
        $tags = [];
53
        if (array_key_exists('tags', $data) && is_array($data['tags'])) {
54
            foreach ($data['tags'] as $tag) {
55
                $tags[] = Tag::fromJson($tag);
56
            }
57
        }
58
59
        $instance = new self();
60
        $instance

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

@@ 50-54 (lines=5) @@
47
    {
48
        $topAnswers = [];
49
        $topQuestions = [];
50
        if (array_key_exists('top_answers', $data) && is_array($data['top_answers'])) {
51
            foreach ($data['top_answers'] as $topAnswer) {
52
                $topAnswers[] = NetworkPost::fromJson($topAnswer);
53
            }
54
        }
55
        if (array_key_exists('top_questions', $data) && is_array($data['top_questions'])) {
56
            foreach ($data['top_questions'] as $topQuestion) {
57
                $topQuestions[] = NetworkPost::fromJson($topQuestion);
@@ 55-59 (lines=5) @@
52
                $topAnswers[] = NetworkPost::fromJson($topAnswer);
53
            }
54
        }
55
        if (array_key_exists('top_questions', $data) && is_array($data['top_questions'])) {
56
            foreach ($data['top_questions'] as $topQuestion) {
57
                $topQuestions[] = NetworkPost::fromJson($topQuestion);
58
            }
59
        }
60
61
        $instance = new self();
62
        $instance

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

@@ 59-63 (lines=5) @@
56
    public static function fromJson(array $data)
57
    {
58
        $comments = [];
59
        if (array_key_exists('comments', $data) && is_array($data['comments'])) {
60
            foreach ($data['comments'] as $comment) {
61
                $comments[] = Comment::fromJson($comment);
62
            }
63
        }
64
65
        $instance = new self();
66
        $instance

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

@@ 78-82 (lines=5) @@
75
    public static function fromJson(array $data)
76
    {
77
        $answers = [];
78
        if (array_key_exists('answers', $data) && is_array($data['answers'])) {
79
            foreach ($data['answers'] as $answer) {
80
                $answers[] = Answer::fromJson($answer);
81
            }
82
        }
83
        $comments = [];
84
        if (array_key_exists('comments', $data) && is_array($data['comments'])) {
85
            foreach ($data['comments'] as $comment) {
@@ 84-88 (lines=5) @@
81
            }
82
        }
83
        $comments = [];
84
        if (array_key_exists('comments', $data) && is_array($data['comments'])) {
85
            foreach ($data['comments'] as $comment) {
86
                $comments[] = Comment::fromJson($comment);
87
            }
88
        }
89
        $tags = [];
90
        if (array_key_exists('tags', $data) && is_array($data['tags'])) {
91
            foreach ($data['tags'] as $tag) {
@@ 90-94 (lines=5) @@
87
            }
88
        }
89
        $tags = [];
90
        if (array_key_exists('tags', $data) && is_array($data['tags'])) {
91
            foreach ($data['tags'] as $tag) {
92
                $tags[] = Tag::fromJson($tag);
93
            }
94
        }
95
96
        $instance = new self();
97
        $instance

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

@@ 112-116 (lines=5) @@
109
            }
110
        }
111
        $relatedSites = [];
112
        if (array_key_exists('related_sites', $data) && is_array($data['related_sites'])) {
113
            foreach ($data['related_sites'] as $relatedSite) {
114
                $relatedSites[] = RelatedSite::fromJson($relatedSite);
115
            }
116
        }
117
118
        $instance = new self();
119
        $instance