如何根据结果长度处理API的响应

I'm working with an API which returns the direct Array when only 1 result is found (also for nested attributes). When there are more found it returns an Array with numeric index.

$response => [
    0 => [
        'title' => 'the title 1',
        'components' => [ // Array
            0 => [
                'title' => 'the title'
            ],
            1 => [
                'title' => 'the title'
            ]
            // ...
        ]
    ],
    1 => [
        'title' => 'the title 2',
        'components' => [ // Direct Array
            'title' => 'the title'
            'components' => [] // Can also be direct Array
            //...
        ]
    ],
];

Is there a "best practice" to handle these responses in PHP. Now I have to check every response with nested attributes - which can have multiple results so this can be a lot of extra lines.