• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

waynestate / base-site / 16474928041

23 Jul 2025 03:24PM UTC coverage: 99.302% (-0.7%) from 100.0%
16474928041

push

github

nickdenardis
Merge branch 'release/8.14.6'

39 of 46 new or added lines in 3 files covered. (84.78%)

996 of 1003 relevant lines covered (99.3%)

6.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

85.37
/app/Repositories/HeroRepository.php
1
<?php
2

3
namespace App\Repositories;
4

5
use Contracts\Repositories\HeroRepositoryContract;
6
use Illuminate\Cache\Repository;
7
use Waynestate\Api\Connector;
8

9
class HeroRepository implements HeroRepositoryContract
10
{
11
    /** @var Connector */
12
    protected $wsuApi;
13

14
    /** @var Repository */
15
    protected $cache;
16

17
    /**
18
     * Construct the repository.
19
     */
20
    public function __construct(
21
        Connector $wsuApi,
22
        Repository $cache,
23
    ) {
24
        $this->wsuApi = $wsuApi;
13✔
25
        $this->cache = $cache;
13✔
26
    }
27

28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function setHero(array $promos, array $data)
32
    {
33
        // Force global promos into the component structure
34
        if (!empty($promos['hero'])) {
11✔
35
            // Preserve the hero data
36
            $temporary_hero = $promos['hero'];
1✔
37
            unset($promos['hero']);
1✔
38

39
            // Force hero data into component structure
40
            if (empty($promos['hero']['data'])) {
1✔
41
                $promos['hero']['data'] = $temporary_hero;
1✔
42
            }
43

44
            if (empty($promos['hero']['component'])) {
1✔
45
                $promos['hero']['component'] = [];
1✔
46
            }
47

48
            foreach ($promos['hero']['data'] as $hero) {
1✔
49
                // Force the correct component option based on the layout
50
                if (count($promos['hero']['data']) === 1) {
1✔
51
                    if (isset($hero['option']) && $hero['option'] === 'Banner contained') {
1✔
NEW
52
                        $promos['hero']['component']['option'] = 'Banner contained';
×
53
                    } elseif (!isset($hero['option']) && config('base.layout') == 'contained-hero') {
1✔
54
                        $promos['hero']['component']['option'] = 'Banner contained';
1✔
55
                    } elseif (!isset($hero['option'])) {
1✔
NEW
56
                        $promos['hero']['component']['option'] = 'Banner small';
×
57
                    }
58
                }
59
            }
60
        }
61

62
        // Set hero buttons from components
63
        $hero_buttons = collect($promos['components'])->reject(function ($data, $component_name) {
11✔
64
            return !str_contains($component_name, 'hero-buttons');
3✔
65
        })->toArray();
11✔
66

67
        if (!empty($hero_buttons)) {
11✔
68
            $hero_buttons_key = array_key_first($hero_buttons);
2✔
69

70
            if (!empty($promos['components'][$hero_buttons_key])) {
2✔
71
                $promos['hero_buttons'] = $promos['components'][$hero_buttons_key];
2✔
72
                unset($promos['components'][$hero_buttons_key]);
2✔
73
            }
74
        }
75

76
        // Override hero from components
77
        $hero = collect($promos['components'])->reject(function ($data, $component_name) {
11✔
78
            return !str_contains($component_name, 'hero');
3✔
79
        })->toArray();
11✔
80

81
        if (!empty($hero)) {
11✔
82
            $hero_key = array_key_first($hero);
1✔
83

84
            if (!empty($promos['components'][$hero_key]['data'])) {
1✔
NEW
85
                $promos['hero'] = $promos['components'][$hero_key];
×
NEW
86
                config(['base.hero_full_controllers' => [$data['page']['controller']]]);
×
NEW
87
                unset($promos['components'][$hero_key]);
×
88
            }
89
        }
90

91
        // Replace Hero Buttons option with Text Overlay
92
        // TODO Make hero buttons it's own option
93
        if (!empty($promos['hero'])) {
11✔
94
            $promos['hero']['data'] = collect($promos['hero']['data'])->map(function ($hero_data) {
1✔
95
                if (!empty($hero_data['option']) && $hero_data['option'] == 'Buttons') {
1✔
NEW
96
                    $hero_data['option'] = 'Text Overlay';
×
97
                }
98

99
                return $hero_data;
1✔
100
            })->toArray();
1✔
101
        }
102

103
        return $promos;
11✔
104
    }
105
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc