embedded-php/core

View on GitHub

Showing 18 of 18 total issues

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public function timeInHigh(int $pin, int $timeout): int {
$pinNumber = $this->pinMap($pin);
if (isset($this->inputPins[$pinNumber]) === false) {
throw new RuntimeException(
sprintf(
Severity: Major
Found in src/Gpio/PhpGpioExt.php and 1 other location - About 3 hrs to fix
src/Gpio/PhpGpioExt.php on lines 273..295

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public function timeInLow(int $pin, int $timeout): int {
$pinNumber = $this->pinMap($pin);
if (isset($this->inputPins[$pinNumber]) === false) {
throw new RuntimeException(
sprintf(
Severity: Major
Found in src/Gpio/PhpGpioExt.php and 1 other location - About 3 hrs to fix
src/Gpio/PhpGpioExt.php on lines 249..271

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public function setInputMode(int $pin): void {
$pinNumber = $this->pinMap($pin);
if (isset($this->outputPins[$pinNumber]) === true) {
unset($this->outputPins[$pinNumber]);
}
Severity: Major
Found in src/Gpio/PhpGpioExt.php and 1 other location - About 2 hrs to fix
src/Gpio/PhpGpioExt.php on lines 132..152

Similar blocks of code found in 2 locations. Consider refactoring.
Open

public function setOutputMode(int $pin): void {
$pinNumber = $this->pinMap($pin);
if (isset($this->inputPins[$pinNumber]) === true) {
unset($this->inputPins[$pinNumber]);
}
Severity: Major
Found in src/Gpio/PhpGpioExt.php and 1 other location - About 2 hrs to fix
src/Gpio/PhpGpioExt.php on lines 110..130

Similar blocks of code found in 2 locations. Consider refactoring.
Open

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',
Severity: Major
Found in src/Gpio/PiPhpGpio.php and 1 other location - About 2 hrs to fix
src/Gpio/PiPhpGpio.php on lines 192..216

Similar blocks of code found in 2 locations. Consider refactoring.
Open

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',
Severity: Major
Found in src/Gpio/PiPhpGpio.php and 1 other location - About 2 hrs to fix
src/Gpio/PiPhpGpio.php on lines 166..190

Method __construct has 12 arguments (exceeds 4 allowed). Consider refactoring.
Open

GpioInterface $gpio,
int $busId = 0,
int $chipSelect = 0,
int $mode = 3,
int $bits = 8,
Severity: Major
Found in src/Protocol/Serial/Spi/PhpSpiExt.php - About 1 hr to fix

    Method __construct has 37 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

    public function __construct(
    GpioInterface $gpio,
    int $busId = 0,
    int $chipSelect = 0,
    int $mode = 3,
    Severity: Minor
    Found in src/Protocol/Serial/Spi/PhpSpiExt.php - About 1 hr to fix

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      public function isLow(int $pin): bool {
      if (isset($this->pins[$pin]) === false) {
      throw new RuntimeException(
      sprintf(
      'Pin %d is not in input mode',
      Severity: Major
      Found in src/Gpio/PiPhpGpio.php and 1 other location - About 1 hr to fix
      src/Gpio/PiPhpGpio.php on lines 72..92

      Similar blocks of code found in 2 locations. Consider refactoring.
      Open

      public function isHigh(int $pin): bool {
      if (isset($this->pins[$pin]) === false) {
      throw new RuntimeException(
      sprintf(
      'Pin %d is not in input mode',
      Severity: Major
      Found in src/Gpio/PiPhpGpio.php and 1 other location - About 1 hr to fix
      src/Gpio/PiPhpGpio.php on lines 94..114

      Method __construct has 9 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      GpioInterface $gpio,
      int $pinSCLK,
      int $pinSDA,
      int $pinCE,
      int $pinDC,
      Severity: Major
      Found in src/Protocol/Serial/Spi/BitBang.php - About 1 hr to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        public function setHigh(int $pin): void {
        if (isset($this->pins[$pin]) === false) {
        throw new RuntimeException(
        sprintf(
        'Pin %d is not in output mode',
        Severity: Major
        Found in src/Gpio/PiPhpGpio.php and 1 other location - About 1 hr to fix
        src/Gpio/PiPhpGpio.php on lines 138..158

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        public function setLow(int $pin): void {
        if (isset($this->pins[$pin]) === false) {
        throw new RuntimeException(
        sprintf(
        'Pin %d is not in output mode',
        Severity: Major
        Found in src/Gpio/PiPhpGpio.php and 1 other location - About 1 hr to fix
        src/Gpio/PiPhpGpio.php on lines 116..136

        Function sendBytes has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
        Open

        protected function sendBytes(int ...$bytes): void {
        if ($this->pinCE > 0) {
        $this->gpio->setLow($this->pinCE);
        }
         
         
        Severity: Minor
        Found in src/Protocol/Serial/Spi/BitBang.php - About 55 mins to fix

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        public function waitForRising(int $pin, int $timeout): bool {
        $pinNumber = $this->pinMap($pin);
        if (isset($this->inputPins[$pinNumber]) === false) {
        throw new RuntimeException(
        sprintf(
        Severity: Minor
        Found in src/Gpio/PhpGpioExt.php and 1 other location - About 40 mins to fix
        src/Gpio/PhpGpioExt.php on lines 221..233

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        public function waitForFalling(int $pin, int $timeout): bool {
        $pinNumber = $this->pinMap($pin);
        if (isset($this->inputPins[$pinNumber]) === false) {
        throw new RuntimeException(
        sprintf(
        Severity: Minor
        Found in src/Gpio/PhpGpioExt.php and 1 other location - About 40 mins to fix
        src/Gpio/PhpGpioExt.php on lines 235..247

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        public function timeInLow(int $pin, int $timeout): int {
        $t0 = microtime(true);
        if ($this->waitForFalling($pin, $timeout) === 0) {
        return 0;
        }
        Severity: Minor
        Found in src/Gpio/PiPhpGpio.php and 1 other location - About 30 mins to fix
        src/Gpio/PiPhpGpio.php on lines 218..229

        Similar blocks of code found in 2 locations. Consider refactoring.
        Open

        public function timeInHigh(int $pin, int $timeout): int {
        $t0 = microtime(true);
        if ($this->waitForRising($pin, $timeout) === 0) {
        return 0;
        }
        Severity: Minor
        Found in src/Gpio/PiPhpGpio.php and 1 other location - About 30 mins to fix
        src/Gpio/PiPhpGpio.php on lines 231..242
        Severity
        Category
        Status
        Source
        Language