<?php

namespace Buckhill\Net;

use Buckhill\Net\Exceptions\NetworkException;

class Network
{
    /**
     * Returns an array of network interfaces
     *
     * @return array
     * @throws NetworkException
     */
    public function getInterfaces()
    {
        exec("ls /sys/class/net 2>&1", $output, $status);

        if($status !== 0)
        {
            $message = 'Unable to retrieve list of network interfaces.' ;

            if(isset($output[0]))
            {
                $message .= ' Error: ' . $output[0];
            }

            throw new NetworkException($message);
        }

        return $output;
    }
}