Similar blocks of code found in 2 locations. Consider refactoring.
public function timeInHigh(int $pin, int $timeout): int {
$pinNumber = $this->pinMap($pin);
if (isset($this->inputPins[$pinNumber]) === false) {
throw new RuntimeException(
sprintf(
Similar blocks of code found in 2 locations. Consider refactoring.
public function timeInLow(int $pin, int $timeout): int {
$pinNumber = $this->pinMap($pin);
if (isset($this->inputPins[$pinNumber]) === false) {
throw new RuntimeException(
sprintf(
Similar blocks of code found in 2 locations. Consider refactoring.
public function setInputMode(int $pin): void {
$pinNumber = $this->pinMap($pin);
if (isset($this->outputPins[$pinNumber]) === true) {
unset($this->outputPins[$pinNumber]);
}
Similar blocks of code found in 2 locations. Consider refactoring.
public function setOutputMode(int $pin): void {
$pinNumber = $this->pinMap($pin);
if (isset($this->inputPins[$pinNumber]) === true) {
unset($this->inputPins[$pinNumber]);
}
Similar blocks of code found in 2 locations. Consider refactoring.
public function waitForFalling(int $pin, int $timeout): bool {
if (isset($this->pins[$pin]) === false) {
throw new RuntimeException(
sprintf(
'Pin %d is not in input mode',
Similar blocks of code found in 2 locations. Consider refactoring.
public function waitForRising(int $pin, int $timeout): bool {
if (isset($this->pins[$pin]) === false) {
throw new RuntimeException(
sprintf(
'Pin %d is not in input mode',
Method __construct
has 12 arguments (exceeds 4 allowed). Consider refactoring.
GpioInterface $gpio,
int $busId = 0,
int $chipSelect = 0,
int $mode = 3,
int $bits = 8,
Method __construct
has 37 lines of code (exceeds 25 allowed). Consider refactoring.
public function __construct(
GpioInterface $gpio,
int $busId = 0,
int $chipSelect = 0,
int $mode = 3,
Similar blocks of code found in 2 locations. Consider refactoring.
public function isLow(int $pin): bool {
if (isset($this->pins[$pin]) === false) {
throw new RuntimeException(
sprintf(
'Pin %d is not in input mode',
Similar blocks of code found in 2 locations. Consider refactoring.
public function isHigh(int $pin): bool {
if (isset($this->pins[$pin]) === false) {
throw new RuntimeException(
sprintf(
'Pin %d is not in input mode',
Method __construct
has 9 arguments (exceeds 4 allowed). Consider refactoring.
GpioInterface $gpio,
int $pinSCLK,
int $pinSDA,
int $pinCE,
int $pinDC,
Similar blocks of code found in 2 locations. Consider refactoring.
public function setHigh(int $pin): void {
if (isset($this->pins[$pin]) === false) {
throw new RuntimeException(
sprintf(
'Pin %d is not in output mode',
Similar blocks of code found in 2 locations. Consider refactoring.
public function setLow(int $pin): void {
if (isset($this->pins[$pin]) === false) {
throw new RuntimeException(
sprintf(
'Pin %d is not in output mode',
Function sendBytes
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
protected function sendBytes(int ...$bytes): void {
if ($this->pinCE > 0) {
$this->gpio->setLow($this->pinCE);
}
Similar blocks of code found in 2 locations. Consider refactoring.
public function waitForRising(int $pin, int $timeout): bool {
$pinNumber = $this->pinMap($pin);
if (isset($this->inputPins[$pinNumber]) === false) {
throw new RuntimeException(
sprintf(
Similar blocks of code found in 2 locations. Consider refactoring.
public function waitForFalling(int $pin, int $timeout): bool {
$pinNumber = $this->pinMap($pin);
if (isset($this->inputPins[$pinNumber]) === false) {
throw new RuntimeException(
sprintf(
Similar blocks of code found in 2 locations. Consider refactoring.
public function timeInLow(int $pin, int $timeout): int {
$t0 = microtime(true);
if ($this->waitForFalling($pin, $timeout) === 0) {
return 0;
}
Similar blocks of code found in 2 locations. Consider refactoring.
public function timeInHigh(int $pin, int $timeout): int {
$t0 = microtime(true);
if ($this->waitForRising($pin, $timeout) === 0) {
return 0;
}