Determine if a $zone is in the legacy format.

@param array $zone

@return bool
193109
protected function isLegacyFormat(array $zone): bool
    {
        $keys = array_map(function ($value) {
            return strtolower($value);
        }, array_keys($zone));

        return
            (false === array_search('domain', $keys, true)) ||
            (false === array_search('resource-records', $keys, true));
    }
1331869
protected function fetchRecords($zone)
    {
        if (!$zone) {
            throw new \Exception('fetchRecords called with blank zone');
        }
        /* Sample get zone info call
            <urn2:getZoneInfo_V2>
                <!--You may enter ANY elements at this point-->
                <urn2:domainName>test.com</urn2:domainName>
            </urn2:getZoneInfo_V2>
        */
        $response = $this->soapCall('getZoneInfo_V2', ['domainName' => $zone]);
        if (!$response['callSuccess']) {
            throw new \Exception('SOAP callSuccess false');
        }
        $this->zones[$zone] = $response['primaryZoneInfo'];

        return $response['primaryZoneInfo']['resourceRecord'];
    }
466528
public function matchDateAndTimeAndZone($date, $time, $zone)
    {
        return $this->matchDate($date)
        && $this->matchTime($time)
        && $this->matchZone($zone);
    }
174946
private function isDeprecationLog(array $record)
    {
        $isPhpChannel = 'php' === $record['channel'];
        $isDeprecationError = isset($record['context']['type']) && E_USER_DEPRECATED === $record['context']['type'];
        $looksLikeDeprecationMessage = false !== strpos($record['message'], 'deprecated since');

        return $isPhpChannel && ($isDeprecationError || $looksLikeDeprecationMessage);
    }
637865
private static function clauseIsNested(array $clause): bool
    {
        $nestedLogicOp = $clause[0];
        $nestedClauses = $clause[1];

        return is_array($nestedClauses) && ($nestedLogicOp == LogicOp:: AND || $nestedLogicOp == LogicOp:: OR);
    }
741024
private function matchVersion(array $array)
    {
        if (!isset($array["version"])) {
            return true;
        }

        if (is_array($array["version"])) {
            foreach ($array["version"] as $version)
            {
                if ($version == $this->getVersion() || $version == "*") {
                    return true;
                }
            }
        } elseif (is_string($array["version"])) {
            if ($array["version"] == $this->getVersion() || $array["version"] == "*") {
                return true;
            }
        }

        return false;
    }
496720
public function isSatisfiedBy(array $value): bool
    {
        return isset($value['extension']) && in_array($value['extension'], $this->extensions, false) ? true : false;
    }
351246
public function delZoneRecord($zone, $recordid)
    {
        if (!$recordid) {
            throw new \Exception('missing record id');
        }
        // Make sure we know what zone to target
        if (!isset($this->zones[$zone])) {
            throw new \Exception("unknown zone {$zone} did you call getZones()?");
        }
        $uri = $this->baseuri.'/accounts/'.$this->account.'/zones/'.$zone.'/rr/'.$recordid;
        $body = ['comments' => 'automated api delete'];
        $result = $this->httpDelete($uri, $body);

        return $result;
    }
287171
public function setBytes(array $value, int $expire = 0): bool
    {
        return $this->setRaw(pack('C*', $value), $expire);
    }
469771
private function isCorrectFormat($marks)
	{
		if (!is_array($marks) || empty($marks)) {
			return false;
		} elseif (ArrayHelper::isIndexed($marks, true)) {
			if (count($marks) == 2 && isset($marks[0]) && isset($marks[1]) && is_numeric($marks[0]) && is_numeric($marks[1])) {
				return true;
			} else {
				foreach ($marks as $mark) {
					if (!$this->isCorrectFormat($mark)) {
						return false;
					}
				}

				return true;
			}
		} elseif (count($marks) == 2 && isset($marks['latitude']) && isset($marks['longitude']) && is_numeric($marks['latitude']) && is_numeric($marks['longitude'])) {
			return true;
		}

		return false;
	}
1055830
protected function legacyVersion($version)
    {
        $legacy = file_get_contents(__DIR__.'/../resources/legacy.json');

        $legacy = json_decode($legacy, true);

        return $legacy[$version];
    }
1319991
public function setDateTimeZone($zone) : DateTime
    {
        if (is_string($zone)) {
            $zone = new DateTimeZone($zone);
        }
        $this->value->setTimezone($zone);
        return $this;
    }
370555
private static function getPadding(Zone $zone)
    {
        $name = $ttl = $type = 0;

        foreach ($zone as $resourceRecord) {
            $name = max($name, strlen($resourceRecord->getName()));
            $ttl = max($ttl, strlen($resourceRecord->getTtl()));
            $type = max($type, strlen($resourceRecord->getType()));
        }

        return [
            $name,
            $ttl,
            $type,
            $name + $ttl + $type + 6,
        ];
    }
943551
private function visitLinkedZone(Zone $zone): ?array
    {
        $linkedZone = $zone->getLinkedZone();

        if (!$linkedZone instanceof Zone) {
            return null;
        }

        return [
            'identifier' => $linkedZone->getIdentifier(),
            'layout_id' => $linkedZone->getLayoutId(),
        ];
    }
172280
public function formatV1(array $record)
    {
        if (empty($record['datetime'])) {
            $record['datetime'] = gmdate('c');
        }
        $message = array(
            '@timestamp' => $record['datetime'],
            '@version' => version(),
            'host' => $this->systemName,
        );
        if (isset($record['message'])) {
            $message['message'] = $record['message'];
        }
        if (isset($record['channel'])) {
            $message['channel'] = $record['channel'];
        }
        if (isset($record['level_name'])) {
            $message['level'] = $record['level_name'];
        }
        if (!empty($record['extra'])) {
            foreach ($record['extra'] as $key => $val) {
                $message[$this->extraPrefix.$key] = $val;
            }
        }
        if (!empty($record['context'])) {
            foreach ($record['context'] as $key => $val) {
                $message[$this->contextPrefix.$key] = $val;
            }
        }

        if (isset($message['trace']) && is_array($message['trace'])) {
            $message['trace'] = implode(PHP_EOL, $message['trace']);
        }

        return $message;
    }
1090242
public static function normalise_timezone($tz) {
        global $CFG;

        if ($tz instanceof DateTimeZone) {
            return $tz->getName();
        }

        self::init_zones();
        $tz = (string)$tz;

        if (isset(self::$goodzones[$tz]) or isset(self::$bczones[$tz])) {
            return $tz;
        }

        $fixed = false;
        if (isset(self::$badzones[$tz])) {
            // Convert to known zone.
            $tz = self::$badzones[$tz];
            $fixed = true;
        } else if (is_numeric($tz)) {
            // Half hour numeric offsets were already tested, try rounding to integers here.
            $roundedtz = (string)(int)$tz;
            if (isset(self::$badzones[$roundedtz])) {
                $tz = self::$badzones[$roundedtz];
                $fixed = true;
            }
        }

        if ($fixed and isset(self::$goodzones[$tz]) or isset(self::$bczones[$tz])) {
            return $tz;
        }

        // Is server timezone usable?
        if (isset($CFG->timezone) and !is_numeric($CFG->timezone)) {
            $result = @timezone_open($CFG->timezone); // Hide notices if invalid.
            if ($result !== false) {
                return $result->getName();
            }
        }

        // Bad luck, use the php.ini default or value set in config.php.
        return self::get_default_php_timezone();
    }
1032371
public function zoneId(array $values, $operator)
    {
        if (!in_array($operator, array('=', '!='))) {
            return $this->translation->text('Unsupported operator');
        }

        $zone = $this->zone->get(reset($values));

        if (empty($zone)) {
            return $this->translation->text('@name is unavailable', array(
                '@name' => $this->translation->text('Condition')));
        }

        return true;
    }