Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
composer.phar
composer.lock
.DS_Store
.idea
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2014, Regan McEntyre (maknz)
Copyright (c) 2014, Regan McEntyre (passwd)
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# Slack for PHP

[![Build Status](https://travis-ci.org/maknz/slack.svg?branch=master)](https://travis-ci.org/maknz/slack)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/maknz/slack/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/maknz/slack/?branch=master)
[![Build Status](https://travis-ci.org/passwd/slack.svg?branch=master)](https://travis-ci.org/passwd/slack)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/passwd/slack/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/passwd/slack/?branch=master)
[![StyleCI](https://styleci.io/repos/19448330/shield)](https://styleci.io/repos/19448330)

A simple PHP package for sending messages to [Slack](https://slack.com) with [incoming webhooks](https://my.slack.com/services/new/incoming-webhook), focussed on ease-of-use and elegant syntax. **Note: this package is no longer being actively maintained.**

* Laravel integration: [Slack for Laravel](https://github.com/maknz/slack-laravel)
* Laravel integration: [Slack for Laravel](https://github.com/passwd/slack-laravel)
* Symfony integration: [NexySlackBundle](https://github.com/nexylan/NexySlackBundle)

## Requirements
Expand All @@ -18,7 +18,7 @@ A simple PHP package for sending messages to [Slack](https://slack.com) with [in
You can install the package using the [Composer](https://getcomposer.org/) package manager. You can install it by running this command in your project root:

```sh
composer require maknz/slack
composer require passwd/slack
```

Then [create an incoming webhook](https://my.slack.com/services/new/incoming-webhook) on your Slack account for the package to use. You'll need the webhook URL to instantiate the client (or for the configuration file if using Laravel).
Expand All @@ -29,7 +29,7 @@ Then [create an incoming webhook](https://my.slack.com/services/new/incoming-web

```php
// Instantiate without defaults
$client = new Maknz\Slack\Client('https://hooks.slack.com/...');
$client = new Passwd\Slack\Client('https://hooks.slack.com/...');

// Instantiate with defaults, so all messages created
// will be sent from 'Cyril' and to the #accounting channel
Expand All @@ -40,7 +40,7 @@ $settings = [
'link_names' => true
];

$client = new Maknz\Slack\Client('https://hooks.slack.com/...', $settings);
$client = new Passwd\Slack\Client('https://hooks.slack.com/...', $settings);
```

#### Settings
Expand Down
18 changes: 8 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
{
"name": "maknz/slack",
"name": "passwd/slack",
"description": "A simple PHP package for sending messages to Slack, with a focus on ease of use and elegant syntax.",
"keywords": ["laravel", "slack"],
"license": "BSD-2-Clause",
"authors": [
{
"name": "maknz",
"name": "passwd",
"email": "github@mak.geek.nz"
}
},
{
"name": "passwd"
}
],
"require": {
"php": ">=5.5.0",
"guzzlehttp/guzzle": "~6.0|~5.0|~4.0",
"guzzlehttp/guzzle": "~7.0",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "4.2.*",
"mockery/mockery": "0.9.*"
},
"suggest": {
"maknz/slack-laravel": "Required for Laravel support",
"nexylan/slack-bundle": "Required for Symfony bundle support"
},
"autoload": {
"psr-4": {
"Maknz\\Slack\\": "src/"
"Passwd\\Slack\\": "src/"
}
},
"minimum-stability": "stable"
Expand Down
2 changes: 1 addition & 1 deletion src/ActionConfirmation.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Maknz\Slack;
namespace Passwd\Slack;

class ActionConfirmation
{
Expand Down
6 changes: 3 additions & 3 deletions src/Attachment.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Maknz\Slack;
namespace Passwd\Slack;

use InvalidArgumentException;

Expand Down Expand Up @@ -571,7 +571,7 @@ public function addField($field)
return $this;
}

throw new InvalidArgumentException('The attachment field must be an instance of Maknz\Slack\AttachmentField or a keyed array');
throw new InvalidArgumentException('The attachment field must be an instance of Passwd\Slack\AttachmentField or a keyed array');
}

/**
Expand Down Expand Up @@ -668,7 +668,7 @@ public function addAction($action)
return $this;
}

throw new InvalidArgumentException('The attachment action must be an instance of Maknz\Slack\AttachmentAction or a keyed array');
throw new InvalidArgumentException('The attachment action must be an instance of Passwd\Slack\AttachmentAction or a keyed array');
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/AttachmentAction.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Maknz\Slack;
namespace Passwd\Slack;

use InvalidArgumentException;

Expand Down Expand Up @@ -206,7 +206,7 @@ public function setConfirm($confirm)
return $this;
}

throw new InvalidArgumentException('The action confirmation must be an instance of Maknz\Slack\ActionConfirmation or a keyed array');
throw new InvalidArgumentException('The action confirmation must be an instance of Passwd\Slack\ActionConfirmation or a keyed array');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/AttachmentField.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Maknz\Slack;
namespace Passwd\Slack;

class AttachmentField
{
Expand Down
12 changes: 6 additions & 6 deletions src/Client.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Maknz\Slack;
namespace Passwd\Slack;

use GuzzleHttp\Client as Guzzle;
use RuntimeException;
Expand Down Expand Up @@ -132,7 +132,7 @@ public function __construct($endpoint, array $attributes = [], Guzzle $guzzle =
*
* @param string $name The name of the method
* @param array $arguments The method arguments
* @return \Maknz\Slack\Message
* @return \Passwd\Slack\Message
*/
public function __call($name, $arguments)
{
Expand Down Expand Up @@ -337,7 +337,7 @@ public function setMarkdownInAttachments(array $fields)
/**
* Create a new message with defaults.
*
* @return \Maknz\Slack\Message
* @return \Passwd\Slack\Message
*/
public function createMessage()
{
Expand All @@ -359,7 +359,7 @@ public function createMessage()
/**
* Send a message.
*
* @param \Maknz\Slack\Message $message
* @param \Passwd\Slack\Message $message
* @return void
*/
public function sendMessage(Message $message)
Expand All @@ -378,7 +378,7 @@ public function sendMessage(Message $message)
/**
* Prepares the payload to be sent to the webhook.
*
* @param \Maknz\Slack\Message $message The message to send
* @param \Passwd\Slack\Message $message The message to send
* @return array
*/
public function preparePayload(Message $message)
Expand All @@ -405,7 +405,7 @@ public function preparePayload(Message $message)
/**
* Get the attachments in array form.
*
* @param \Maknz\Slack\Message $message
* @param \Passwd\Slack\Message $message
* @return array
*/
protected function getAttachmentsAsArrays(Message $message)
Expand Down
27 changes: 12 additions & 15 deletions src/Message.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Maknz\Slack;
namespace Passwd\Slack;

use InvalidArgumentException;

Expand All @@ -10,7 +10,7 @@ class Message
* Reference to the Slack client responsible for sending
* the message.
*
* @var \Maknz\Slack\Client
* @var \Passwd\Slack\Client
*/
protected $client;

Expand Down Expand Up @@ -85,7 +85,7 @@ class Message
/**
* Instantiate a new Message.
*
* @param \Maknz\Slack\Client $client
* @param \Passwd\Slack\Client $client
* @return void
*/
public function __construct(Client $client)
Expand Down Expand Up @@ -182,8 +182,7 @@ public function setIcon($icon)
{
if ($icon == null) {
$this->icon = $this->iconType = null;

return;
return $this;
}

if (mb_substr($icon, 0, 1) == ':' && mb_substr($icon, mb_strlen($icon) - 1, 1) == ':') {
Expand All @@ -193,7 +192,6 @@ public function setIcon($icon)
}

$this->icon = $icon;

return $this;
}

Expand Down Expand Up @@ -223,19 +221,19 @@ public function getAllowMarkdown()
* Slack's Markdown-like language.
*
* @param bool $value
* @return void
* @return $this
*/
public function setAllowMarkdown($value)
{
$this->allow_markdown = (bool) $value;
$this->allow_markdown = (bool)$value;

return $this;
}

/**
* Enable Markdown formatting for the message.
*
* @return void
* @return $this
*/
public function enableMarkdown()
{
Expand All @@ -247,7 +245,7 @@ public function enableMarkdown()
/**
* Disable Markdown formatting for the message.
*
* @return void
* @return $this
*/
public function disableMarkdown()
{
Expand All @@ -272,7 +270,7 @@ public function getMarkdownInAttachments()
* in Slack's Markdown-like language.
*
* @param array $fields
* @return void
* @return $this
*/
public function setMarkdownInAttachments(array $fields)
{
Expand Down Expand Up @@ -335,7 +333,7 @@ public function attach($attachment)
} elseif (is_array($attachment)) {
$attachmentObject = new Attachment($attachment);

if (! isset($attachment['mrkdwn_in'])) {
if (!isset($attachment['mrkdwn_in'])) {
$attachmentObject->setMarkdownFields($this->getMarkdownInAttachments());
}

Expand All @@ -344,7 +342,7 @@ public function attach($attachment)
return $this;
}

throw new InvalidArgumentException('Attachment must be an instance of Maknz\\Slack\\Attachment or a keyed array');
throw new InvalidArgumentException('Attachment must be an instance of Passwd\\Slack\\Attachment or a keyed array');
}

/**
Expand Down Expand Up @@ -390,7 +388,7 @@ public function clearAttachments()
* Send the message.
*
* @param string $text The text to send
* @return void
* @return $this
*/
public function send($text = null)
{
Expand All @@ -399,7 +397,6 @@ public function send($text = null)
}

$this->client->sendMessage($this);

return $this;
}
}
6 changes: 3 additions & 3 deletions tests/AttachmentUnitTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use Maknz\Slack\Attachment;
use Maknz\Slack\AttachmentAction;
use Maknz\Slack\AttachmentField;
use Passwd\Slack\Attachment;
use Passwd\Slack\AttachmentAction;
use Passwd\Slack\AttachmentField;

class AttachmentUnitTest extends PHPUnit_Framework_TestCase
{
Expand Down
4 changes: 2 additions & 2 deletions tests/ClientFunctionalTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

use Maknz\Slack\Client;
use Maknz\Slack\Attachment;
use Passwd\Slack\Client;
use Passwd\Slack\Attachment;

class ClientFunctionalTest extends PHPUnit_Framework_TestCase
{
Expand Down
8 changes: 4 additions & 4 deletions tests/ClientUnitTest.php
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php

use Maknz\Slack\Client;
use Passwd\Slack\Client;

class ClientUnitTest extends PHPUnit_Framework_TestCase
{
public function testInstantiationWithNoDefaults()
{
$client = new Client('http://fake.endpoint');

$this->assertInstanceOf('Maknz\Slack\Client', $client);
$this->assertInstanceOf('Passwd\Slack\Client', $client);

$this->assertSame('http://fake.endpoint', $client->getEndpoint());
}
Expand Down Expand Up @@ -57,7 +57,7 @@ public function testCreateMessage()

$message = $client->createMessage();

$this->assertInstanceOf('Maknz\Slack\Message', $message);
$this->assertInstanceOf('Passwd\Slack\Message', $message);

$this->assertSame($client->getDefaultChannel(), $message->getChannel());

Expand All @@ -72,7 +72,7 @@ public function testWildcardCallToMessage()

$message = $client->to('@regan');

$this->assertInstanceOf('Maknz\Slack\Message', $message);
$this->assertInstanceOf('Passwd\Slack\Message', $message);

$this->assertSame('@regan', $message->getChannel());
}
Expand Down
Loading