Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
Postcode_Locations_Result
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 1
 get_first
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2/**
3 * A set of valid locations for a postcode.
4 *
5 * @package brianhenryie/bh-wc-postcode-address-autofill
6 */
7
8namespace BrianHenryIE\WC_Postcode_Address_Autofill\API;
9
10use ArrayObject;
11
12/**
13 * Simple class to store the valid locations for a postcode.
14 *
15 * @template-extends ArrayObject<array-key, Postcode_Location>
16 */
17class Postcode_Locations_Result extends ArrayObject {
18
19    /**
20     * Simple logic to get the first correct location for a postcode.
21     *
22     * In future, this might be augmented with user-specific data, or locations might be sorted by population.
23     *
24     * @return ?Postcode_Location
25     */
26    public function get_first(): ?Postcode_Location {
27        return $this->getIterator()->valid() ? $this->getIterator()->current() : null;
28    }
29}