Added exceptions to gpio class
This commit is contained in:
		
							
								
								
									
										12
									
								
								lib/Gpio.php
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								lib/Gpio.php
									
									
									
									
									
								
							@@ -19,12 +19,24 @@
 | 
			
		||||
 | 
			
		||||
namespace NoccyLabs\Gpio;
 | 
			
		||||
 | 
			
		||||
use NoccyLabs\Gpio\Exception\HardwareException;
 | 
			
		||||
 | 
			
		||||
class Gpio implements \ArrayAccess
 | 
			
		||||
{
 | 
			
		||||
    protected $gpio = array();
 | 
			
		||||
    
 | 
			
		||||
    /** @var NoccyLabs\Gpio\GpioMapperInterface */
 | 
			
		||||
    protected $mapper;
 | 
			
		||||
    
 | 
			
		||||
    public function __construct()
 | 
			
		||||
    {
 | 
			
		||||
        if (!file_exists("/sys/gpio")) {
 | 
			
		||||
            throw new HardwareException("gpio sysfs is not available");
 | 
			
		||||
        }
 | 
			
		||||
        if (!is_writable("/sys/gpio/export")) {
 | 
			
		||||
            throw new HardwareException("gpio sysfs is not writable");
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public function refresh()
 | 
			
		||||
    {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user