<commit_before><?php

declare(strict_types=1);

/*
 * This file is part of the DigitalOcean API library.
 *
 * (c) <NAME> <<EMAIL>>
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace DigitalOceanV2\Api;

use DigitalOceanV2\Entity\Firewall as FirewallEntity;
use DigitalOceanV2\Exception\ExceptionInterface;

/**
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class Firewall extends AbstractApi
{
    /**
     * @param string $id
     *
     * @throws ExceptionInterface
     *
     * @return FirewallEntity
     */
    public function getById(string $id)
    {
        $firewall = $this->get(\sprintf('firewalls/%s', $id));

        return new FirewallEntity($firewall->firewall);
    }

    /**
     * @param string $name
     * @param array  $inboundRules
     * @param array  $outboundRules
     * @param array  $dropletIds
     * @param array  $tags
     *
     * @return FirewallEntity
     */<commit_msg>Added method to get all firewalls (#292)<commit_after><?php

declare(strict_types=1);

/*
 * This file is part of the DigitalOcean API library.
 *
 * (c) <NAME> <<EMAIL>>
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace DigitalOceanV2\Api;

use DigitalOceanV2\Entity\Firewall as FirewallEntity;
use DigitalOceanV2\Exception\ExceptionInterface;

/**
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL> <EMAIL>>
 */
class Firewall extends AbstractApi
{
    /**
     * @throws ExceptionInterface
     *
     * @return FirewallEntity[]
     */
    public function getAll()
    {
        $firewalls = $this->get('firewalls');

        return \array_map(function ($firewall) {
            return new FirewallEntity($firewall);
        }, $firewalls->firewalls);
    }

    /**
     * @param string $id
     *
     * @throws ExceptionInterface
     *
     * @return FirewallEntity
     */
    public function getById(string $id)
    {
        $firewall = $this->get(\sprintf('firewalls/%s', $id));

        return new FirewallEntity($firewall->firewall);
    }

    /**
     * @param string $name
     * @param array  $inboundRules
     * @param array  $outboundRules
     * @param array  $dropletIds
     * @param array  $tags
     *
     * @return FirewallEntity
     */
{'fraction_non_alphanumeric': 0.13009468917249897, 'fraction_numerical': 0.004528612597776863, 'mean_word_length': 2.7557959814528594, 'pattern_counts': {'":': 0, '<': 30, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2057032', 'n_tokens_mistral': 765, 'n_tokens_neox': 749, 'n_words': 199}