Skip to content

Commit 8dc0933

Browse files
committed
Added missing share method
1 parent 0d4c27d commit 8dc0933

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

src/Facades/Shortcodes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
use Vedmant\LaravelShortcodes\ShortcodesManager;
88

99
/**
10-
* @method static mixed global(string $key, $value = null, $default = null)
11-
* @method static mixed|ShortcodesManager shared($key = null, $value = null, $default = null)
10+
* @method static ShortcodesManager share(string $key, $value)
11+
* @method static mixed shared($key = null, $value = null)
1212
* @method static ShortcodesManager add($name, $callable = null)
1313
* @method static ShortcodesManager remove($name)
1414
* @method static array registered()

src/Shortcode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function atts(): array
7171
*/
7272
public function shared($key = null, $defatul = null)
7373
{
74-
return $this->manager->shared($key, null, $defatul);
74+
return $this->manager->shared($key, $defatul);
7575
}
7676

7777
/**

src/ShortcodesManager.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,33 @@ public function __construct(Application $app, array $config)
4444
}
4545

4646
/**
47-
* Set / get shared variable
47+
* Share attribute
4848
*
4949
* @param string $key
5050
* @param mixed $value
51+
* @return ShortcodesManager
52+
*/
53+
public function share($key, $value)
54+
{
55+
$this->shared[$key] = $value;
56+
57+
return $this;
58+
}
59+
60+
/**
61+
* Set / get shared variable
62+
*
63+
* @param string $key
5164
* @param null $default
52-
* @return mixed|ShortcodesManager
65+
* @return mixed
5366
*/
54-
public function shared($key = null, $value = null, $default = null)
67+
public function shared($key = null, $default = null)
5568
{
5669
if ($key === null) {
5770
return $this->shared;
5871
}
5972

60-
if ($value === null) {
61-
return array_get($this->shared, $key, $default);
62-
}
63-
64-
$this->shared[$key] = $value;
65-
66-
return $this;
73+
return array_get($this->shared, $key, $default);
6774
}
6875

6976
/**

0 commit comments

Comments
 (0)