Completed
Push — master ( 643987...ab0124 )
by Daryl
01:58
created

Map_View::_make_map_args()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Clubdeuce\WPLib\Components\GoogleMaps;
4
5
/**
6
 * Class Map_View
7
 * @package  Clubdeuce\GoogleMaps
8
 * @property Map $item
9
 */
10
class Map_View extends \WPLib_View_Base {
11
12
    function the_map() {
13
14
        wp_localize_script( 'map-control', 'objMapParams',  $this->_make_map_args() );
15
        wp_localize_script( 'map-control', 'objMapMarkers', $this->_make_markers_args() );
16
17
        echo '<div id="map" class="google-map" style="height: 400px; width: 100%"></div>';
18
19
    }
20
21
    private function _make_map_args() {
22
23
        return array(
24
            'center' => $this->item->center(),
0 ignored issues
show
Documentation Bug introduced by
The method center does not exist on object<Clubdeuce\WPLib\Components\GoogleMaps\Map>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
25
            'zoom'   => $this->item->zoom(),
0 ignored issues
show
Documentation Bug introduced by
The method zoom does not exist on object<Clubdeuce\WPLib\Components\GoogleMaps\Map>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
26
        );
27
28
    }
29
30
    /**
31
     * @return array
32
     */
33
    private function _make_markers_args() {
34
35
        return array_map( array( __CLASS__, '_make_marker_args' ), $this->item->markers() );
0 ignored issues
show
Documentation Bug introduced by
The method markers does not exist on object<Clubdeuce\WPLib\Components\GoogleMaps\Map>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
36
37
    }
38
39
    /**
40
     * @param  Marker $marker
41
     * @return array
42
     */
43
    private function _make_marker_args( $marker ) {
44
45
        return array(
46
            'position' => array( 'lat' => $marker->latitude(), 'lng' => $marker->longitude() ),
0 ignored issues
show
Documentation Bug introduced by
The method latitude does not exist on object<Clubdeuce\WPLib\C...ents\GoogleMaps\Marker>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
Documentation Bug introduced by
The method longitude does not exist on object<Clubdeuce\WPLib\C...ents\GoogleMaps\Marker>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
47
            'title'    => $marker->title(),
0 ignored issues
show
Documentation Bug introduced by
The method title does not exist on object<Clubdeuce\WPLib\C...ents\GoogleMaps\Marker>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
48
        );
49
50
    }
51
52
}
53