Standard::addRow()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Smoqadam\Keyboard;
4
5
class Standard {
6
7
  public
8
    $keyboard = [],
0 ignored issues
show
Coding Style introduced by
It is generally advisable to only define one property per statement.

Only declaring a single property per statement allows you to later on add doc comments more easily.

It is also recommended by PSR2, so it is a common style that many people expect.

Loading history...
Coding Style introduced by
The visibility should be declared for property $keyboard.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
9
    $resize_keyboard,
10
    $one_time_keyboard,
11
    $selective;
12
    
13
  private
14
    $current_row = 0;
0 ignored issues
show
Coding Style introduced by
The visibility should be declared for property $current_row.

The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using

class A {
    var $property;
}

the property is implicitly global.

To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.

Loading history...
15
16
  public function __construct($resize_keyboard = false, $one_time_keyboard = false, $selective = false) {
17
    $this->resize_keyboard    = $resize_keyboard;
18
    $this->one_time_keyboard  = $one_time_keyboard;
19
    $this->selective          = $selective;
20
  }
21
  
22
  /**
23
  * Create new row.
24
  *
25
  * @return object Standard
26
  */
27
  public function addRow(){
28
    $this->current_row++;
29
    
30
    return $this;
31
  }
32
  
33
  /**
34
  * Add new button to current row.
35
  *
36
  * @param string $text 	Text of the button. If none of the optional fields are used, it will be sent to the bot as a message when the button is pressed
37
  * @param boolean $request_contact Optional. If True, the user's phone number will be sent as a contact when the button is pressed. Available in private chats only
38
  * @param boolean $request_location Optional. If True, the user's current location will be sent when the button is pressed. Available in private chats only
39
  * @return object
40
  */
41
  public function addButton(string $text, boolean $request_contact = null, boolean $request_location = null){
42
    $this->keyboard[$this->current_row][] = [
43
      'text' => $text,
44
      'request_contact' => ($request_contact != null) ? $request_contact : false,
45
      'request_location' => ($request_location != null) ? $request_location : false
46
    ];
47
    
48
    return $this;
49
  }
50
51
}
52